Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/gstack-learnings-log
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let j;
try { j = JSON.parse(raw); } catch { process.stderr.write('gstack-learnings-log: invalid JSON, skipping\n'); process.exit(1); }

// Field validation: type must be from allowed list
const ALLOWED_TYPES = ['pattern', 'pitfall', 'preference', 'architecture', 'tool', 'operational'];
const ALLOWED_TYPES = ['pattern', 'pitfall', 'preference', 'architecture', 'tool', 'operational', 'investigation'];
if (!j.type || !ALLOWED_TYPES.includes(j.type)) {
process.stderr.write('gstack-learnings-log: invalid type \"' + (j.type || '') + '\", must be one of: ' + ALLOWED_TYPES.join(', ') + '\n');
process.exit(1);
Expand Down
21 changes: 21 additions & 0 deletions test/learnings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ describe('gstack-learnings-log', () => {
expect(parsed.confidence).toBe(8);
});

test('accepts investigation learnings with affected files', () => {
const input = JSON.stringify({
skill: 'investigate',
type: 'investigation',
key: 'root-cause-key',
insight: 'Root cause summary',
confidence: 9,
source: 'observed',
files: ['affected/file1.ts', 'affected/file2.ts'],
});
const result = runLog(input);
expect(result.exitCode).toBe(0);

const f = findLearningsFile();
expect(f).not.toBeNull();
const parsed = JSON.parse(fs.readFileSync(f!, 'utf-8').trim());
expect(parsed.skill).toBe('investigate');
expect(parsed.type).toBe('investigation');
expect(parsed.files).toEqual(['affected/file1.ts', 'affected/file2.ts']);
});

test('auto-injects timestamp when ts is missing', () => {
const input = '{"skill":"review","type":"pattern","key":"ts-test","insight":"test","confidence":5,"source":"observed"}';
runLog(input);
Expand Down
Loading