Merge pull request #2121 from gsd-build/feat/1861-pattern-mapper
feat: add gsd-pattern-mapper agent for codebase pattern analysis
This commit is contained in:
@@ -1196,6 +1196,7 @@ describe('E2E: Copilot full install verification', () => {
|
||||
'gsd-integration-checker.agent.md',
|
||||
'gsd-intel-updater.agent.md',
|
||||
'gsd-nyquist-auditor.agent.md',
|
||||
'gsd-pattern-mapper.agent.md',
|
||||
'gsd-phase-researcher.agent.md',
|
||||
'gsd-plan-checker.agent.md',
|
||||
'gsd-planner.agent.md',
|
||||
|
||||
111
tests/pattern-mapper.test.cjs
Normal file
111
tests/pattern-mapper.test.cjs
Normal file
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Tests for Pattern Mapper feature (#1861)
|
||||
*
|
||||
* Covers:
|
||||
* - Config key workflow.pattern_mapper in VALID_CONFIG_KEYS
|
||||
* - Default value is true
|
||||
* - Config round-trip (set/get)
|
||||
* - init plan-phase output includes patterns_path (null when missing, path when present)
|
||||
*/
|
||||
|
||||
const { describe, test, beforeEach, afterEach } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
|
||||
|
||||
describe('pattern-mapper config key', () => {
|
||||
let tmpDir;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = createTempProject();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup(tmpDir);
|
||||
});
|
||||
|
||||
test('workflow.pattern_mapper is a valid config key', () => {
|
||||
// Setting an invalid key produces an error; a valid key succeeds
|
||||
const result = runGsdTools('config-set workflow.pattern_mapper true', tmpDir, { HOME: tmpDir });
|
||||
assert.ok(result.success, `Expected success but got error: ${result.error}`);
|
||||
});
|
||||
|
||||
test('default value is true in CONFIG_DEFAULTS', () => {
|
||||
// Create a new project config and verify the default
|
||||
const result = runGsdTools('config-new-project', tmpDir, { HOME: tmpDir });
|
||||
assert.ok(result.success, `config-new-project failed: ${result.error}`);
|
||||
|
||||
const configPath = path.join(tmpDir, '.planning', 'config.json');
|
||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
||||
assert.strictEqual(config.workflow.pattern_mapper, true);
|
||||
});
|
||||
|
||||
test('config round-trip set/get', () => {
|
||||
// Ensure config exists first
|
||||
runGsdTools('config-new-project', tmpDir, { HOME: tmpDir });
|
||||
|
||||
// Set to false
|
||||
const setResult = runGsdTools('config-set workflow.pattern_mapper false', tmpDir, { HOME: tmpDir });
|
||||
assert.ok(setResult.success, `config-set failed: ${setResult.error}`);
|
||||
|
||||
// Get should return false
|
||||
const getResult = runGsdTools('config-get workflow.pattern_mapper', tmpDir, { HOME: tmpDir });
|
||||
assert.ok(getResult.success, `config-get failed: ${getResult.error}`);
|
||||
assert.strictEqual(getResult.output, 'false');
|
||||
});
|
||||
});
|
||||
|
||||
describe('init plan-phase patterns_path', () => {
|
||||
let tmpDir;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = createTempProject();
|
||||
// Create minimal planning structure for init plan-phase
|
||||
const planningDir = path.join(tmpDir, '.planning');
|
||||
fs.writeFileSync(path.join(planningDir, 'STATE.md'), [
|
||||
'# State',
|
||||
'',
|
||||
'## Current Phase',
|
||||
'Phase 1 — Foundation',
|
||||
].join('\n'));
|
||||
fs.writeFileSync(path.join(planningDir, 'ROADMAP.md'), [
|
||||
'# Roadmap',
|
||||
'',
|
||||
'## Phase 1: Foundation',
|
||||
'Build the foundation.',
|
||||
'**Status:** Planning',
|
||||
'**Requirements:** [FOUND-01]',
|
||||
].join('\n'));
|
||||
|
||||
// Create phase directory
|
||||
const phaseDir = path.join(planningDir, 'phases', '01-foundation');
|
||||
fs.mkdirSync(phaseDir, { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup(tmpDir);
|
||||
});
|
||||
|
||||
test('patterns_path is null when no PATTERNS.md exists', () => {
|
||||
const result = runGsdTools('init plan-phase 1', tmpDir, { HOME: tmpDir });
|
||||
assert.ok(result.success, `init plan-phase failed: ${result.error}`);
|
||||
|
||||
const data = JSON.parse(result.output);
|
||||
assert.strictEqual(data.patterns_path, null);
|
||||
});
|
||||
|
||||
test('patterns_path contains correct path when PATTERNS.md exists', () => {
|
||||
// Create a PATTERNS.md in the phase directory
|
||||
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01-foundation');
|
||||
fs.writeFileSync(path.join(phaseDir, '01-PATTERNS.md'), '# Patterns\n');
|
||||
|
||||
const result = runGsdTools('init plan-phase 1', tmpDir, { HOME: tmpDir });
|
||||
assert.ok(result.success, `init plan-phase failed: ${result.error}`);
|
||||
|
||||
const data = JSON.parse(result.output);
|
||||
assert.ok(data.patterns_path, 'patterns_path should not be null');
|
||||
assert.ok(data.patterns_path.includes('PATTERNS.md'), `Expected path to contain PATTERNS.md, got: ${data.patterns_path}`);
|
||||
assert.ok(data.patterns_path.includes('01-foundation'), `Expected path to include phase dir, got: ${data.patterns_path}`);
|
||||
});
|
||||
});
|
||||
@@ -53,6 +53,7 @@ const ALLOWLIST = new Set([
|
||||
'get-shit-done/bin/lib/security.cjs', // The security module itself
|
||||
'get-shit-done/workflows/discuss-phase.md', // Large workflow (~50K) with power mode + i18n
|
||||
'get-shit-done/workflows/execute-phase.md', // Large orchestration workflow (~51K) with wave execution + code-review gate
|
||||
'get-shit-done/workflows/plan-phase.md', // Large orchestration workflow (~52K) with pattern mapper + TDD mode
|
||||
'hooks/gsd-prompt-guard.js', // The prompt guard hook
|
||||
'tests/security.test.cjs', // Security tests
|
||||
'tests/prompt-injection-scan.test.cjs', // This file
|
||||
|
||||
Reference in New Issue
Block a user