feat: operational self-improvement — every skill learns from failures

Adds universal operational learning capture to the preamble completion protocol.
At the end of every skill session, the agent reflects on CLI failures, wrong
approaches, and project quirks, logging them as type "operational" to the
learnings JSONL. Future sessions surface these automatically.

- generateCompletionStatus(ctx) now includes operational capture section
- Preamble bash shows top 3 learnings inline when count > 5
- New "operational" type in generateLearningsLog alongside pattern/pitfall/etc
- Updated unit tests + operational seed entry in learnings E2E

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-03-29 21:04:35 -07:00
parent b6fcfd84b7
commit cade276c20
30 changed files with 594 additions and 8 deletions
+10 -1
View File
@@ -213,11 +213,20 @@ describe('gen-skill-docs', () => {
expect(browseTmpl).toContain('{{PREAMBLE}}');
});
test('generated SKILL.md contains no contributor mode (removed)', () => {
test('generated SKILL.md contains operational self-improvement (replaced contributor mode)', () => {
const content = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8');
expect(content).not.toContain('Contributor Mode');
expect(content).not.toContain('gstack_contributor');
expect(content).not.toContain('contributor-logs');
expect(content).toContain('Operational Self-Improvement');
expect(content).toContain('gstack-learnings-log');
expect(content).toContain('gstack-learnings-search --limit 3');
});
test('generated SKILL.md with LEARNINGS_LOG contains operational type', () => {
// Check a skill that has LEARNINGS_LOG (e.g., review)
const content = fs.readFileSync(path.join(ROOT, 'review', 'SKILL.md'), 'utf-8');
expect(content).toContain('operational');
});
test('generated SKILL.md contains session awareness', () => {
+5
View File
@@ -67,6 +67,11 @@ describeIfSelected('Learnings E2E', ['learnings-show'], () => {
insight: 'User wants rubocop to run before every commit, no exceptions.',
confidence: 10, source: 'user-stated', ts: new Date().toISOString(),
},
{
skill: 'qa', type: 'operational', key: 'test-timeout-flag',
insight: 'bun test requires --timeout 30000 for E2E tests in this project.',
confidence: 9, source: 'observed', ts: new Date().toISOString(),
},
];
fs.writeFileSync(