Files
msd-core/tests/bug-2334-quick-gsd-sdk-preflight.test.cjs
Tom Boucher 334a64168e chore(npm): rebrand packages to @opengsd scope (#127)
* chore(npm): rebrand packages to @opengsd scope

Rename:
- get-shit-done-redux → @opengsd/get-shit-done-redux
- @gsd-redux/sdk → @opengsd/gsd-sdk

Add publishConfig.access=public for first-time scoped publish.
CLI binary names (get-shit-done-redux, gsd-sdk, gsd-tools) unchanged.

Sweeps install commands, npx invocations, CI publish/version-check
workflows, tests, docs, READMEs (all translations), and the
PACKAGE_NAME constant in check-latest-version.

Bumps qs 6.15.1 → 6.15.2 to clear a moderate advisory surfaced by
the audit-clean test (GHSA-q8mj-m7cp-5q26).

Closes #126

* chore: pin 2.0.0 release + remove canary workflow

- Bump both packages 1.50.0-canary.0 → 2.0.0 for first @opengsd publish
- Remove .github/workflows/canary.yml and canary dist-tag handling in
  release.yml / release-sdk.yml
- Drop canary section from VERSIONING.md

Refs #126

* chore: address review findings + harden tarball-smoke timeout

- .changeset/opengsd-org-rename.md: match project's custom
  parse.cjs frontmatter (type: Changed / pr: 127); the scoped
  @changesets/cli keys were silently rejected.
- CONTEXT.md: drop two canary-stream policy lines and a dangling
  DEFECT.CANARY-VERSION-LEAK.cross-ref now that canary.yml is gone.
- tests/release-tarball-smoke.install.test.cjs: pass
  timeout: 600_000 for npm pack + global install; the 3-minute
  runNpm default was timing out on slower Docker hosts (cartographer).

Refs #126

* fix(sdk): add missing type/runtime devDependencies for build

prepublishOnly invokes tsc which couldn't resolve @types/node,
@types/ws, or synckit. They had been hoisted from root but were
not declared in sdk/'s own package.json — first publish from a
clean SDK tree failed.

Refs #126

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(ci): use npm pack stdout instead of glob to find tarball

`npm pack --silent` for a scoped package (@opengsd/get-shit-done-redux)
produces `opengsd-get-shit-done-redux-*.tgz`, not `get-shit-done-redux-*.tgz`.
Capture the filename from stdout instead of a hardcoded glob so the step
works regardless of package name format.

Fixes smoke (ubuntu-latest, 22, false) CI failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: treat workflow-file changes as test-skip eligible

`.github/workflows/install-smoke.yml` (and other workflow files)
were in neither `test.yml` paths nor `test-skip.yml` paths-ignore,
so neither workflow ran on a workflow-only commit — leaving the
required test-skip check perpetually missing.

Refs #126

* chore: reset version to 1.0.0 for first @opengsd publish

Nothing has been published yet under the @opengsd scope, so the
inaugural release uses 1.0.0 rather than 2.0.0. The "major bump"
in the changeset reflects the breaking install-command change for
users migrating from the prior unscoped `get-shit-done-redux`, not
a numeric continuation from a 1.x line under the new identity.

Refs #126

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 16:22:41 -04:00

76 lines
3.5 KiB
JavaScript

/**
* Regression test for bug #2334
*
* /gsd-quick crashed with `command not found: gsd-sdk` (exit code 127) when
* the gsd-sdk binary was not installed or not in PATH. The workflow's Step 2
* called `gsd-sdk query init.quick` directly with no pre-flight check and no
* fallback, so missing gsd-sdk caused an immediate abort with no helpful message.
*
* Fix: Step 2 must check for gsd-sdk in PATH before invoking it. If absent,
* emit a human-readable error pointing users to the install command.
*/
'use strict';
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const WORKFLOW_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'quick.md');
// allow-test-rule: source-text-is-the-product
// quick.md is the AI instruction workflow — the `command -v gsd-sdk` guard IS the fix.
// There is no behavioral equivalent: the check runs inside the AI agent, not in gsd-tools.
describe('bug #2334: quick workflow gsd-sdk pre-flight check', () => {
let content;
test('workflow file exists', () => {
assert.ok(fs.existsSync(WORKFLOW_PATH), 'workflows/quick.md should exist');
content = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
});
test('Step 2 checks for gsd-sdk before invoking it', () => {
content = content || fs.readFileSync(WORKFLOW_PATH, 'utf-8');
// The check must appear before the first gsd-sdk invocation in Step 2.
// After the #3797 architectural fix, callsites use $GSD_SDK (not bare gsd-sdk),
// so we search for the $GSD_SDK form of the init.quick call.
const step2Start = content.indexOf('**Step 2:');
assert.ok(step2Start !== -1, 'Step 2 must exist in quick workflow');
// Accept either the bare form (legacy) or the $GSD_SDK form (post-#3797)
let firstSdkCall = content.indexOf('$GSD_SDK query init.quick', step2Start);
if (firstSdkCall === -1) {
firstSdkCall = content.indexOf('gsd-sdk query init.quick', step2Start);
}
assert.ok(firstSdkCall !== -1, 'gsd-sdk query init.quick must be present in Step 2');
// Find any gsd-sdk availability check between the Step 2 heading and the first call
const step2Section = content.slice(step2Start, firstSdkCall);
const hasCommandCheck = step2Section.includes('command -v gsd-sdk') || step2Section.includes('which gsd-sdk');
assert.ok(
hasCommandCheck,
'Step 2 must check for gsd-sdk in PATH (via `command -v gsd-sdk` or `which gsd-sdk`) ' +
'before calling `gsd-sdk query init.quick`. Without this guard, the workflow crashes ' +
'with exit code 127 when gsd-sdk is not installed (root cause of #2334).'
);
});
test('pre-flight error message references the install command', () => {
content = content || fs.readFileSync(WORKFLOW_PATH, 'utf-8');
const step2Start = content.indexOf('**Step 2:');
// Accept either form of the SDK call (bare or $GSD_SDK)
let firstSdkCall = content.indexOf('$GSD_SDK query init.quick', step2Start);
if (firstSdkCall === -1) {
firstSdkCall = content.indexOf('gsd-sdk query init.quick', step2Start);
}
const step2Section = content.slice(step2Start, firstSdkCall);
const hasInstallHint = step2Section.includes('@opengsd/get-shit-done-redux') || step2Section.includes('gsd-update') || step2Section.includes('/gsd-update');
assert.ok(
hasInstallHint,
'Pre-flight error must include a hint on how to install query-capable gsd-sdk (npm install -g @opengsd/get-shit-done-redux or /gsd-update)'
);
});
});