opencastle 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -6
- package/bin/cli.mjs +6 -0
- package/dist/cli/adapters/codex.d.ts +19 -6
- package/dist/cli/adapters/codex.d.ts.map +1 -1
- package/dist/cli/adapters/codex.js +24 -7
- package/dist/cli/adapters/codex.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +7 -0
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +59 -22
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/agent-plugin.d.ts +119 -0
- package/dist/cli/agent-plugin.d.ts.map +1 -0
- package/dist/cli/agent-plugin.js +449 -0
- package/dist/cli/agent-plugin.js.map +1 -0
- package/dist/cli/agent-plugin.test.d.ts +2 -0
- package/dist/cli/agent-plugin.test.d.ts.map +1 -0
- package/dist/cli/agent-plugin.test.js +227 -0
- package/dist/cli/agent-plugin.test.js.map +1 -0
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +99 -26
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/codex-target.test.d.ts +2 -0
- package/dist/cli/codex-target.test.d.ts.map +1 -0
- package/dist/cli/codex-target.test.js +154 -0
- package/dist/cli/codex-target.test.js.map +1 -0
- package/dist/cli/convoy/gates.d.ts +2 -20
- package/dist/cli/convoy/gates.d.ts.map +1 -1
- package/dist/cli/convoy/gates.js +3 -111
- package/dist/cli/convoy/gates.js.map +1 -1
- package/dist/cli/copy.d.ts +0 -8
- package/dist/cli/copy.d.ts.map +1 -1
- package/dist/cli/copy.js +0 -21
- package/dist/cli/copy.js.map +1 -1
- package/dist/cli/dispatcher.test.js +2 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +2 -0
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +4 -1
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +5 -4
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +58 -34
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts +8 -0
- package/dist/cli/layers.d.ts.map +1 -1
- package/dist/cli/layers.js +130 -13
- package/dist/cli/layers.js.map +1 -1
- package/dist/cli/layers.test.js +2 -2
- package/dist/cli/layers.test.js.map +1 -1
- package/dist/cli/legacy-install.test.js +8 -1
- package/dist/cli/legacy-install.test.js.map +1 -1
- package/dist/cli/lesson-command.test.d.ts +2 -0
- package/dist/cli/lesson-command.test.d.ts.map +1 -0
- package/dist/cli/lesson-command.test.js +100 -0
- package/dist/cli/lesson-command.test.js.map +1 -0
- package/dist/cli/lesson.d.ts +0 -9
- package/dist/cli/lesson.d.ts.map +1 -1
- package/dist/cli/lesson.js +212 -276
- package/dist/cli/lesson.js.map +1 -1
- package/dist/cli/lessons.d.ts +134 -0
- package/dist/cli/lessons.d.ts.map +1 -0
- package/dist/cli/lessons.js +493 -0
- package/dist/cli/lessons.js.map +1 -0
- package/dist/cli/lessons.test.d.ts +2 -0
- package/dist/cli/lessons.test.d.ts.map +1 -0
- package/dist/cli/lessons.test.js +214 -0
- package/dist/cli/lessons.test.js.map +1 -0
- package/dist/cli/managed-paths.d.ts.map +1 -1
- package/dist/cli/managed-paths.js +2 -0
- package/dist/cli/managed-paths.js.map +1 -1
- package/dist/cli/mcp-audit.d.ts.map +1 -1
- package/dist/cli/mcp-audit.js +7 -3
- package/dist/cli/mcp-audit.js.map +1 -1
- package/dist/cli/mcp-file.d.ts +37 -0
- package/dist/cli/mcp-file.d.ts.map +1 -0
- package/dist/cli/mcp-file.js +291 -0
- package/dist/cli/mcp-file.js.map +1 -0
- package/dist/cli/mcp-file.test.d.ts +2 -0
- package/dist/cli/mcp-file.test.d.ts.map +1 -0
- package/dist/cli/mcp-file.test.js +121 -0
- package/dist/cli/mcp-file.test.js.map +1 -0
- package/dist/cli/mcp.d.ts +15 -0
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +123 -56
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/pack-plugins.d.ts +8 -0
- package/dist/cli/pack-plugins.d.ts.map +1 -0
- package/dist/cli/pack-plugins.js +70 -0
- package/dist/cli/pack-plugins.js.map +1 -0
- package/dist/cli/plugin-command.test.d.ts +2 -0
- package/dist/cli/plugin-command.test.d.ts.map +1 -0
- package/dist/cli/plugin-command.test.js +114 -0
- package/dist/cli/plugin-command.test.js.map +1 -0
- package/dist/cli/plugin.d.ts +30 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +291 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/promote-command.test.d.ts +2 -0
- package/dist/cli/promote-command.test.d.ts.map +1 -0
- package/dist/cli/promote-command.test.js +151 -0
- package/dist/cli/promote-command.test.js.map +1 -0
- package/dist/cli/promote.d.ts +12 -0
- package/dist/cli/promote.d.ts.map +1 -0
- package/dist/cli/promote.js +364 -0
- package/dist/cli/promote.js.map +1 -0
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +23 -4
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/secret-scan.d.ts +21 -0
- package/dist/cli/secret-scan.d.ts.map +1 -0
- package/dist/cli/secret-scan.js +114 -0
- package/dist/cli/secret-scan.js.map +1 -0
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +13 -3
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +2 -2
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/team-commands.test.js +2 -2
- package/dist/cli/team-commands.test.js.map +1 -1
- package/dist/cli/types.d.ts +5 -2
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js +3 -0
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/unreadable-report.d.ts +7 -0
- package/dist/cli/unreadable-report.d.ts.map +1 -1
- package/dist/cli/unreadable-report.js +14 -0
- package/dist/cli/unreadable-report.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +73 -5
- package/dist/cli/update.js.map +1 -1
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts +2 -0
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js +32 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js.map +1 -0
- package/package.json +3 -1
- package/src/cli/adapters/codex.ts +25 -7
- package/src/cli/adapters/single-file-base.ts +69 -26
- package/src/cli/agent-plugin.test.ts +267 -0
- package/src/cli/agent-plugin.ts +469 -0
- package/src/cli/baseline.ts +99 -26
- package/src/cli/codex-target.test.ts +178 -0
- package/src/cli/convoy/gates.ts +9 -142
- package/src/cli/copy.ts +0 -25
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +2 -0
- package/src/cli/doctor.ts +5 -2
- package/src/cli/fixtures/lessons-template-1.0.md +70 -0
- package/src/cli/init.test.ts +59 -34
- package/src/cli/init.ts +5 -4
- package/src/cli/layers.test.ts +2 -2
- package/src/cli/layers.ts +144 -14
- package/src/cli/legacy-install.test.ts +11 -1
- package/src/cli/lesson-command.test.ts +117 -0
- package/src/cli/lesson.ts +215 -266
- package/src/cli/lessons.test.ts +254 -0
- package/src/cli/lessons.ts +540 -0
- package/src/cli/managed-paths.ts +2 -0
- package/src/cli/mcp-audit.ts +7 -3
- package/src/cli/mcp-file.test.ts +138 -0
- package/src/cli/mcp-file.ts +302 -0
- package/src/cli/mcp.ts +130 -60
- package/src/cli/pack-plugins.ts +70 -0
- package/src/cli/plugin-command.test.ts +125 -0
- package/src/cli/plugin.ts +309 -0
- package/src/cli/promote-command.test.ts +170 -0
- package/src/cli/promote.ts +371 -0
- package/src/cli/remove.ts +20 -4
- package/src/cli/secret-scan.ts +154 -0
- package/src/cli/sync-check.test.ts +2 -2
- package/src/cli/sync-check.ts +13 -3
- package/src/cli/team-commands.test.ts +2 -2
- package/src/cli/types.ts +5 -2
- package/src/cli/unreadable-report.ts +14 -0
- package/src/cli/update.ts +81 -5
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/agents/researcher.agent.md +1 -1
- package/src/orchestrator/customizations/LESSONS-LEARNED.md +10 -66
- package/src/orchestrator/customizations/README.md +2 -1
- package/src/orchestrator/customizations/logs/README.md +1 -1
- package/src/orchestrator/plugins/agent-plugins.test.ts +34 -0
- package/src/orchestrator/plugins/astro/mcp.json +9 -0
- package/src/orchestrator/plugins/astro/plugin.json +21 -0
- package/src/orchestrator/plugins/chrome-devtools/mcp.json +13 -0
- package/src/orchestrator/plugins/chrome-devtools/plugin.json +21 -0
- package/src/orchestrator/plugins/cloudflare/mcp.json +9 -0
- package/src/orchestrator/plugins/cloudflare/plugin.json +21 -0
- package/src/orchestrator/plugins/contentful/mcp.json +13 -0
- package/src/orchestrator/plugins/contentful/plugin.json +21 -0
- package/src/orchestrator/plugins/convex/mcp.json +15 -0
- package/src/orchestrator/plugins/convex/plugin.json +21 -0
- package/src/orchestrator/plugins/coolify/mcp.json +13 -0
- package/src/orchestrator/plugins/coolify/plugin.json +25 -0
- package/src/orchestrator/plugins/cypress/plugin.json +21 -0
- package/src/orchestrator/plugins/drizzle/plugin.json +21 -0
- package/src/orchestrator/plugins/expo/mcp.json +9 -0
- package/src/orchestrator/plugins/expo/plugin.json +21 -0
- package/src/orchestrator/plugins/figma/mcp.json +9 -0
- package/src/orchestrator/plugins/figma/plugin.json +21 -0
- package/src/orchestrator/plugins/hetzner/plugin.json +24 -0
- package/src/orchestrator/plugins/jira/mcp.json +9 -0
- package/src/orchestrator/plugins/jira/plugin.json +21 -0
- package/src/orchestrator/plugins/linear/mcp.json +9 -0
- package/src/orchestrator/plugins/linear/plugin.json +21 -0
- package/src/orchestrator/plugins/netlify/mcp.json +13 -0
- package/src/orchestrator/plugins/netlify/plugin.json +21 -0
- package/src/orchestrator/plugins/nextjs/mcp.json +13 -0
- package/src/orchestrator/plugins/nextjs/plugin.json +21 -0
- package/src/orchestrator/plugins/notion/mcp.json +9 -0
- package/src/orchestrator/plugins/notion/plugin.json +21 -0
- package/src/orchestrator/plugins/nx/mcp.json +14 -0
- package/src/orchestrator/plugins/nx/plugin.json +21 -0
- package/src/orchestrator/plugins/playwright/mcp.json +13 -0
- package/src/orchestrator/plugins/playwright/plugin.json +21 -0
- package/src/orchestrator/plugins/prisma/mcp.json +14 -0
- package/src/orchestrator/plugins/prisma/plugin.json +21 -0
- package/src/orchestrator/plugins/resend/mcp.json +13 -0
- package/src/orchestrator/plugins/resend/plugin.json +24 -0
- package/src/orchestrator/plugins/sanity/mcp.json +9 -0
- package/src/orchestrator/plugins/sanity/plugin.json +21 -0
- package/src/orchestrator/plugins/sentry/mcp.json +12 -0
- package/src/orchestrator/plugins/sentry/plugin.json +24 -0
- package/src/orchestrator/plugins/slack/mcp.json +13 -0
- package/src/orchestrator/plugins/slack/plugin.json +24 -0
- package/src/orchestrator/plugins/strapi/mcp.json +13 -0
- package/src/orchestrator/plugins/strapi/plugin.json +21 -0
- package/src/orchestrator/plugins/stripe/mcp.json +9 -0
- package/src/orchestrator/plugins/stripe/plugin.json +21 -0
- package/src/orchestrator/plugins/supabase/mcp.json +9 -0
- package/src/orchestrator/plugins/supabase/plugin.json +21 -0
- package/src/orchestrator/plugins/teams/plugin.json +24 -0
- package/src/orchestrator/plugins/trello/mcp.json +13 -0
- package/src/orchestrator/plugins/trello/plugin.json +25 -0
- package/src/orchestrator/plugins/turborepo/plugin.json +21 -0
- package/src/orchestrator/plugins/vercel/mcp.json +9 -0
- package/src/orchestrator/plugins/vercel/plugin.json +21 -0
- package/src/orchestrator/plugins/vitest/plugin.json +21 -0
- package/src/orchestrator/skill-config-links.test.ts +2 -1
- package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +1 -1
- package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
- package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
- package/src/orchestrator/skills/memory-merger/SKILL.md +17 -21
- package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +44 -23
- package/src/orchestrator/skills/self-improvement/SKILL.md +30 -15
- /package/src/orchestrator/plugins/astro/{SKILL.md → skills/astro-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/chrome-devtools/{SKILL.md → skills/browser-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cloudflare/{SKILL.md → skills/cloudflare-platform/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/contentful/{SKILL.md → skills/contentful-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/convex/{SKILL.md → skills/convex-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/coolify/{SKILL.md → skills/coolify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cypress/{SKILL.md → skills/cypress-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/drizzle/{SKILL.md → skills/drizzle-orm/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/expo/{SKILL.md → skills/expo-development/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/figma/{SKILL.md → skills/figma-design/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/hetzner/{SKILL.md → skills/hetzner-cloud/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/jira/{SKILL.md → skills/jira-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/linear/{SKILL.md → skills/linear-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/netlify/{SKILL.md → skills/netlify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nextjs/{SKILL.md → skills/nextjs-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/notion/{SKILL.md → skills/notion-knowledge-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nx/{SKILL.md → skills/nx-workspace/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/playwright/{SKILL.md → skills/playwright-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/prisma/{SKILL.md → skills/prisma-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/resend/{SKILL.md → skills/resend-email/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sanity/{SKILL.md → skills/sanity-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sentry/{SKILL.md → skills/sentry-monitoring/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/slack/{SKILL.md → skills/slack-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/strapi/{SKILL.md → skills/strapi-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/stripe/{SKILL.md → skills/stripe-payments/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/supabase/{SKILL.md → skills/supabase-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/teams/{SKILL.md → skills/teams-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/trello/{SKILL.md → skills/trello-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/turborepo/{SKILL.md → skills/turborepo-monorepo/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vercel/{SKILL.md → skills/vercel-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vitest/{SKILL.md → skills/vitest-testing/SKILL.md} +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join, resolve } from 'node:path'
|
|
4
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
5
|
+
import {
|
|
6
|
+
INDEX_MARKER,
|
|
7
|
+
checkLessons,
|
|
8
|
+
citedPath,
|
|
9
|
+
fingerprintsOf,
|
|
10
|
+
lessonsIndexDrift,
|
|
11
|
+
newLessonId,
|
|
12
|
+
parseLegacyLessons,
|
|
13
|
+
parseLesson,
|
|
14
|
+
readLessons,
|
|
15
|
+
renderIndex,
|
|
16
|
+
renderLesson,
|
|
17
|
+
slugOf,
|
|
18
|
+
staleCitations,
|
|
19
|
+
syncLessons,
|
|
20
|
+
type Lesson,
|
|
21
|
+
} from './lessons.js'
|
|
22
|
+
|
|
23
|
+
const pkgRoot = resolve(import.meta.dirname, '..', '..')
|
|
24
|
+
|
|
25
|
+
/** The shape agents actually left the old file in: entries after the index, odd categories, a stray fence. */
|
|
26
|
+
const LEGACY = `\`\`\`\`markdown
|
|
27
|
+
# Lessons Learned
|
|
28
|
+
|
|
29
|
+
Intro the team wrote.
|
|
30
|
+
|
|
31
|
+
### LES-001: Observability logging is mandatory
|
|
32
|
+
|
|
33
|
+
| Field | Value |
|
|
34
|
+
|-------|-------|
|
|
35
|
+
| **Category** | \`general\` |
|
|
36
|
+
| **Added** | 2026-03-01 |
|
|
37
|
+
| **Severity** | \`high\` (blocks work) |
|
|
38
|
+
|
|
39
|
+
**Problem:** Nothing was logged.
|
|
40
|
+
|
|
41
|
+
**Correct approach:** Log every session.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### LES-002: Writing files via terminal fails when content contains \`!\`
|
|
46
|
+
|
|
47
|
+
| Field | Value |
|
|
48
|
+
|-------|-------|
|
|
49
|
+
| **Category** | \`tooling\` |
|
|
50
|
+
| **Added** | 2026-03-16 |
|
|
51
|
+
| **Severity** | \`high\` (blocks file creation) |
|
|
52
|
+
|
|
53
|
+
**Problem:** zsh history expansion.
|
|
54
|
+
|
|
55
|
+
**Wrong approach:**
|
|
56
|
+
- heredocs
|
|
57
|
+
|
|
58
|
+
## Index by Category
|
|
59
|
+
|
|
60
|
+
| Category | Lessons |
|
|
61
|
+
|----------|---------|
|
|
62
|
+
| \`general\` | LES-001, LES-002 |
|
|
63
|
+
|
|
64
|
+
\`\`\`\`
|
|
65
|
+
|
|
66
|
+
### LES-007: Use N/A for tracker_issue when no tracker is configured
|
|
67
|
+
|
|
68
|
+
| Field | Value |
|
|
69
|
+
|-------|-------|
|
|
70
|
+
| **Category** | \`general\` |
|
|
71
|
+
| **Added** | 2026-03-05 |
|
|
72
|
+
| **Severity** | \`medium\` (wastes 5+ min) |
|
|
73
|
+
|
|
74
|
+
**Problem:** TAS-PENDING everywhere.
|
|
75
|
+
`
|
|
76
|
+
|
|
77
|
+
function lesson(over: Partial<Lesson> = {}): Lesson {
|
|
78
|
+
return {
|
|
79
|
+
id: '2026-10-02-quote-shell-variables',
|
|
80
|
+
title: 'Always quote shell variables',
|
|
81
|
+
category: 'terminal',
|
|
82
|
+
severity: 'medium',
|
|
83
|
+
added: '2026-10-02',
|
|
84
|
+
citations: [],
|
|
85
|
+
status: 'active',
|
|
86
|
+
body: '**Problem:** Paths with spaces break.',
|
|
87
|
+
file: '2026-10-02-quote-shell-variables.md',
|
|
88
|
+
...over,
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
describe('naming a lesson', () => {
|
|
93
|
+
it('slugs a title to lowercase words, under 50 characters', () => {
|
|
94
|
+
expect(slugOf('Always quote $SHELL variables — even in CI!')).toBe('always-quote-shell-variables-even-in-ci')
|
|
95
|
+
expect(slugOf('a'.repeat(80))).toBe('lesson')
|
|
96
|
+
expect(slugOf('Café au lait')).toBe('cafe-au-lait')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('gives two lessons with the same title on the same day different ids', () => {
|
|
100
|
+
const taken = new Set(['2026-10-02-quote-shell-variables'])
|
|
101
|
+
expect(newLessonId('Quote shell variables', '2026-10-02', taken)).toBe('2026-10-02-quote-shell-variables-2')
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
describe('a lesson file', () => {
|
|
106
|
+
it('round-trips through its frontmatter, keeping dates as strings', () => {
|
|
107
|
+
const l = lesson({ citations: ['scripts/a.sh:12'], verified: '2026-10-02', fingerprints: { 'scripts/a.sh': '0123456789ab' } })
|
|
108
|
+
const parsed = parseLesson(renderLesson(l), l.file)
|
|
109
|
+
expect(parsed).toEqual(l)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('names what is wrong with a file that is not a lesson', () => {
|
|
113
|
+
expect(parseLesson('just text', 'x.md')).toBe('has no frontmatter')
|
|
114
|
+
expect(parseLesson('---\nid: x\n---\nbody', 'x.md')).toBe('has no title')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('cites a path, with or without a line', () => {
|
|
118
|
+
expect(citedPath('src/a.ts:12')).toBe('src/a.ts')
|
|
119
|
+
expect(citedPath('./src/a.ts#L3-L9')).toBe('src/a.ts')
|
|
120
|
+
expect(citedPath('src/a.ts')).toBe('src/a.ts')
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
describe('the old single-file log', () => {
|
|
125
|
+
it('reads every entry wherever it sits, with what it says', () => {
|
|
126
|
+
const found = parseLegacyLessons(LEGACY)
|
|
127
|
+
expect(found.map((l) => l.id)).toEqual(['LES-001', 'LES-002', 'LES-007'])
|
|
128
|
+
expect(found[1]).toMatchObject({ category: 'tooling', severity: 'high', added: '2026-03-16' })
|
|
129
|
+
expect(found[0].body).toBe('**Problem:** Nothing was logged.\n\n**Correct approach:** Log every session.')
|
|
130
|
+
expect(found[1].body).toContain('- heredocs')
|
|
131
|
+
expect(found[1].body).not.toContain('````')
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
describe('syncing lessons', () => {
|
|
136
|
+
let dir: string
|
|
137
|
+
beforeEach(() => {
|
|
138
|
+
dir = mkdtempSync(join(tmpdir(), 'oc-lessons-'))
|
|
139
|
+
})
|
|
140
|
+
afterEach(() => rmSync(dir, { recursive: true, force: true }))
|
|
141
|
+
|
|
142
|
+
it('moves an old log into one file per lesson, keeps a backup, and indexes them', () => {
|
|
143
|
+
writeFileSync(join(dir, 'LESSONS-LEARNED.md'), LEGACY)
|
|
144
|
+
const out = syncLessons(dir)
|
|
145
|
+
expect(out.migrated).toBe(3)
|
|
146
|
+
expect(out.backup).toMatch(/LESSONS-LEARNED\.md\.opencastle-backup$/)
|
|
147
|
+
expect(readFileSync(join(dir, 'LESSONS-LEARNED.md.opencastle-backup'), 'utf8')).toBe(LEGACY)
|
|
148
|
+
expect(readdirSync(join(dir, 'lessons')).sort()).toEqual([
|
|
149
|
+
'LES-001-observability-logging-is-mandatory.md',
|
|
150
|
+
'LES-002-writing-files-via-terminal-fails-when-content.md',
|
|
151
|
+
'LES-007-use-n-a-for-tracker-issue-when-no-tracker-is.md',
|
|
152
|
+
])
|
|
153
|
+
const index = readFileSync(join(dir, 'LESSONS-LEARNED.md'), 'utf8')
|
|
154
|
+
expect(index.startsWith(INDEX_MARKER)).toBe(true)
|
|
155
|
+
expect(index).toContain('## tooling')
|
|
156
|
+
expect(lessonsIndexDrift(dir)).toBeNull()
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it('does it once: a second sync changes nothing', () => {
|
|
160
|
+
writeFileSync(join(dir, 'LESSONS-LEARNED.md'), LEGACY)
|
|
161
|
+
syncLessons(dir)
|
|
162
|
+
const before = readFileSync(join(dir, 'LESSONS-LEARNED.md'), 'utf8')
|
|
163
|
+
expect(syncLessons(dir)).toMatchObject({ migrated: 0, index: 'unchanged' })
|
|
164
|
+
expect(readFileSync(join(dir, 'LESSONS-LEARNED.md'), 'utf8')).toBe(before)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('replaces an untouched template without a backup', () => {
|
|
168
|
+
// As 1.0.0 shipped it, kept as a fixture: CI's shallow clone has no history to read it from.
|
|
169
|
+
const template = readFileSync(join(import.meta.dirname, 'fixtures', 'lessons-template-1.0.md'), 'utf8')
|
|
170
|
+
writeFileSync(join(dir, 'LESSONS-LEARNED.md'), template)
|
|
171
|
+
const out = syncLessons(dir)
|
|
172
|
+
expect(out).toMatchObject({ migrated: 0, index: 'updated' })
|
|
173
|
+
expect(out.backup).toBeUndefined()
|
|
174
|
+
expect(existsSync(join(dir, 'LESSONS-LEARNED.md.opencastle-backup'))).toBe(false)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('leaves a project that removed the index alone', () => {
|
|
178
|
+
expect(syncLessons(dir).index).toBe('absent')
|
|
179
|
+
expect(existsSync(join(dir, 'LESSONS-LEARNED.md'))).toBe(false)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('reports an index a merge left behind, and sync rebuilds it', () => {
|
|
183
|
+
writeFileSync(join(dir, 'LESSONS-LEARNED.md'), renderIndex([]))
|
|
184
|
+
mkdirSync(join(dir, 'lessons'))
|
|
185
|
+
writeFileSync(join(dir, 'lessons', 'a.md'), renderLesson(lesson()))
|
|
186
|
+
expect(lessonsIndexDrift(dir)).toMatch(/does not list/)
|
|
187
|
+
syncLessons(dir)
|
|
188
|
+
expect(lessonsIndexDrift(dir)).toBeNull()
|
|
189
|
+
expect(readFileSync(join(dir, 'LESSONS-LEARNED.md'), 'utf8')).toContain('Always quote shell variables')
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('lists archived lessons apart, with where they went', () => {
|
|
193
|
+
const index = renderIndex([lesson(), lesson({ id: 'b', file: 'b.md', title: 'Old', status: 'archived', mergedInto: 'skills/x/SKILL.md' })])
|
|
194
|
+
expect(index).toMatch(/## Archived[\s\S]*\*\*Old\*\* → `skills\/x\/SKILL\.md`/)
|
|
195
|
+
expect(index.split('## Archived')[0]).not.toContain('**Old**')
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
describe('the shipped template', () => {
|
|
200
|
+
it('is the index of no lessons, exactly as sync writes it', () => {
|
|
201
|
+
const shipped = readFileSync(join(pkgRoot, 'src', 'orchestrator', 'customizations', 'LESSONS-LEARNED.md'), 'utf8')
|
|
202
|
+
expect(shipped).toBe(renderIndex([]))
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
describe('citations against the code', () => {
|
|
207
|
+
let project: string
|
|
208
|
+
beforeEach(() => {
|
|
209
|
+
project = mkdtempSync(join(tmpdir(), 'oc-cite-'))
|
|
210
|
+
mkdirSync(join(project, 'src'))
|
|
211
|
+
writeFileSync(join(project, 'src', 'a.ts'), 'export const a = 1\n')
|
|
212
|
+
writeFileSync(join(project, 'src', 'b.ts'), 'export const b = 1\n')
|
|
213
|
+
})
|
|
214
|
+
afterEach(() => rmSync(project, { recursive: true, force: true }))
|
|
215
|
+
|
|
216
|
+
const verifiedNow = (citations: string[], over: Partial<Lesson> = {}): Lesson =>
|
|
217
|
+
lesson({ citations, verified: '2026-10-01', fingerprints: fingerprintsOf(project, citations), ...over })
|
|
218
|
+
|
|
219
|
+
it('says nothing while the cited code is as it was verified', () => {
|
|
220
|
+
expect(staleCitations(project, [verifiedNow(['src/a.ts:1'])])).toEqual([])
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
it('names a cited file that changed since, and one that is gone', () => {
|
|
224
|
+
const l = verifiedNow(['src/a.ts:1', 'src/b.ts'])
|
|
225
|
+
writeFileSync(join(project, 'src', 'a.ts'), 'export const a = 2\n')
|
|
226
|
+
rmSync(join(project, 'src', 'b.ts'))
|
|
227
|
+
expect(staleCitations(project, [l]).map((s) => `${s.citation}:${s.why}`)).toEqual(['src/a.ts:1:changed', 'src/b.ts:missing'])
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
it('does not read a checkout with CRLF line endings as a change', () => {
|
|
231
|
+
const l = verifiedNow(['src/a.ts'])
|
|
232
|
+
writeFileSync(join(project, 'src', 'a.ts'), 'export const a = 1\r\n')
|
|
233
|
+
expect(staleCitations(project, [l])).toEqual([])
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
it('checks a citation with no fingerprint for existence only', () => {
|
|
237
|
+
writeFileSync(join(project, 'src', 'a.ts'), 'anything\n')
|
|
238
|
+
expect(staleCitations(project, [lesson({ citations: ['src/a.ts'] })])).toEqual([])
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
it('doctor warns with the lesson, the citation and the command that clears it', () => {
|
|
242
|
+
const dir = join(project, '.opencastle')
|
|
243
|
+
mkdirSync(join(dir, 'lessons'), { recursive: true })
|
|
244
|
+
writeFileSync(join(dir, 'lessons', 'a.md'), renderLesson(verifiedNow(['src/a.ts'], { id: 'a' })))
|
|
245
|
+
syncLessons(dir)
|
|
246
|
+
expect(checkLessons(project).warning).toBeUndefined()
|
|
247
|
+
writeFileSync(join(project, 'src', 'a.ts'), 'export const a = 3\n')
|
|
248
|
+
const result = checkLessons(project)
|
|
249
|
+
expect(result.warning).toBe(true)
|
|
250
|
+
expect(result.detail).toBe('a cites src/a.ts, which has changed since it was verified on 2026-10-01')
|
|
251
|
+
expect(result.fix).toContain('opencastle lesson verify a')
|
|
252
|
+
expect(readLessons(dir).lessons).toHaveLength(1)
|
|
253
|
+
})
|
|
254
|
+
})
|