mirror of
https://github.com/glittercowboy/get-shit-done
synced 2026-05-14 02:56:38 +02:00
* feat(#2982): extend no-source-grep lint to catch var-binding readFileSync.includes() The base lint (scripts/lint-no-source-grep.cjs) only catches readFileSync(...).<text-method>() chained directly. The much more common var-binding form escapes it: const src = fs.readFileSync(p, 'utf8'); // 50 lines later if (src.includes('foo')) {} // ← still grep, lint missed it Scan of the test suite found ~141 files using this pattern. Implementation built TDD per #2982 with structured-IR assertions: scripts/lint-no-source-grep-extras.cjs - detectVarBindingViolations(src) — pure detector, two passes: pass 1 collects vars bound from readFileSync, pass 2 finds any <var>.<includes|startsWith|endsWith|match|search>( on those vars. - detectWrappedAssertOkMatch(src) — flags assert.ok(<expr>.match(...)) which escapes the assert.match rule. - VIOLATION enum exposes stable codes for tests to assert on. scripts/lint-no-source-grep.cjs - Wires the new detectors into the existing per-file check; one additional violation row per file with the first 3 sample tokens. tests/bug-2982-lint-var-binding.test.cjs - 13 tests, all assertions on typed VIOLATION enum / structured records. Covers all 5 text-match methods, multi-var, no-bind, string literal (must NOT trigger), wrapped assert.ok(.match), and assert.match (must NOT double-flag). Migration backlog (#2974 expanded scope): - 42 files annotated `// allow-test-rule: source-text-is-the-product` (legitimate — they read .md/.json/.yml files whose deployed text IS the product) - 3 files annotated `// allow-test-rule: pending-migration-to-typed-ir [#2974]` (read .cjs/.js source — clear migration debt) - 95 files annotated `pending-migration-to-typed-ir [#2974]` with `Per-file review may reclassify as source-text-is-the-product during migration` (mixed — manual review under #2974) After this lands the lint reports 0 violations on main; new violations in PRs surface immediately. Closes #2982 Refs #2974 * test(#2982): fix truncated test name per CR The label ended with a bare '(' from a copy-paste mishap. Now reads 'does NOT flag .matchAll(...) — matchAll is not match, so assert.ok(.matchAll(...)) is not flagged'. * chore(#2982): add changeset fragment for PR #2985 * chore(#2982): add changeset fragment for PR #2985
127 lines
4.7 KiB
JavaScript
127 lines
4.7 KiB
JavaScript
// allow-test-rule: pending-migration-to-typed-ir [#2974]
|
|
// Tracked in #2974 for migration to typed-IR assertions per CONTRIBUTING.md
|
|
// "Prohibited: Raw Text Matching on Test Outputs". Per-file review may
|
|
// reclassify some entries as source-text-is-the-product during migration.
|
|
|
|
/**
|
|
* Import Command Tests — import-command.test.cjs
|
|
*
|
|
* Structural assertions for the /gsd-import command and workflow files.
|
|
*/
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const CMD_PATH = path.join(__dirname, '..', 'commands', 'gsd', 'import.md');
|
|
const WF_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'import.md');
|
|
|
|
// ─── File Existence ────────────────────────────────────────────────────────────
|
|
|
|
describe('import command file structure', () => {
|
|
test('command file exists', () => {
|
|
assert.ok(fs.existsSync(CMD_PATH), 'commands/gsd/import.md should exist');
|
|
});
|
|
|
|
test('workflow file exists', () => {
|
|
assert.ok(fs.existsSync(WF_PATH), 'get-shit-done/workflows/import.md should exist');
|
|
});
|
|
});
|
|
|
|
// ─── Command Frontmatter ───────────────────────────────────────────────────────
|
|
|
|
describe('import command frontmatter', () => {
|
|
const content = fs.readFileSync(CMD_PATH, 'utf-8');
|
|
|
|
test('has name field', () => {
|
|
assert.match(content, /^name:\s*gsd:import$/m);
|
|
});
|
|
|
|
test('has description field', () => {
|
|
assert.match(content, /^description:\s*.+$/m);
|
|
});
|
|
|
|
test('has argument-hint with --from', () => {
|
|
assert.match(content, /^argument-hint:.*--from/m);
|
|
});
|
|
});
|
|
|
|
// ─── Command References Workflow ───────────────────────────────────────────────
|
|
|
|
describe('import command references', () => {
|
|
const content = fs.readFileSync(CMD_PATH, 'utf-8');
|
|
|
|
test('references the import workflow', () => {
|
|
assert.ok(
|
|
content.includes('@~/.claude/get-shit-done/workflows/import.md'),
|
|
'command should reference the workflow via @~/.claude/get-shit-done/workflows/import.md'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Workflow Content ──────────────────────────────────────────────────────────
|
|
|
|
describe('import workflow content', () => {
|
|
const content = fs.readFileSync(WF_PATH, 'utf-8');
|
|
|
|
test('contains --from mode handling', () => {
|
|
assert.ok(
|
|
content.includes('--from'),
|
|
'workflow should contain --from mode handling'
|
|
);
|
|
});
|
|
|
|
test('does NOT contain --prd implementation', () => {
|
|
// --prd should be mentioned as deferred/future only, not implemented
|
|
assert.ok(
|
|
content.includes('--prd'),
|
|
'workflow should mention --prd exists'
|
|
);
|
|
assert.ok(
|
|
content.includes('not yet implemented') || content.includes('follow-up PR') || content.includes('future release'),
|
|
'workflow should defer --prd to a future release'
|
|
);
|
|
// Should not have a full "Path B: MODE=prd" implementation section
|
|
assert.ok(
|
|
!content.includes('## Path B: MODE=prd'),
|
|
'workflow should NOT have a Path B implementation for --prd'
|
|
);
|
|
});
|
|
|
|
test('references path validation for --from argument', () => {
|
|
// After fix: inline path check instead of security.cjs CLI invocation
|
|
assert.ok(
|
|
content.includes('traversal') || content.includes('validatePath') || content.includes('..'),
|
|
'workflow should validate the file path'
|
|
);
|
|
});
|
|
|
|
test('includes REQUIREMENTS.md in conflict detection context loading', () => {
|
|
assert.ok(
|
|
content.includes('REQUIREMENTS.md'),
|
|
'workflow should load REQUIREMENTS.md for conflict detection'
|
|
);
|
|
});
|
|
|
|
test('includes BLOCKER/WARNING/INFO conflict severity model', () => {
|
|
assert.ok(content.includes('[BLOCKER]'), 'workflow should include BLOCKER severity');
|
|
assert.ok(content.includes('[WARNING]'), 'workflow should include WARNING severity');
|
|
assert.ok(content.includes('[INFO]'), 'workflow should include INFO severity');
|
|
});
|
|
|
|
test('includes plan-checker validation gate', () => {
|
|
assert.ok(
|
|
content.includes('gsd-plan-checker'),
|
|
'workflow should delegate validation to gsd-plan-checker'
|
|
);
|
|
});
|
|
|
|
test('no-args usage display is present', () => {
|
|
assert.ok(
|
|
content.includes('Usage: /gsd:import') || content.includes('Usage: /gsd-import'),
|
|
'workflow should display usage when no arguments provided'
|
|
);
|
|
});
|
|
});
|