opencastle 1.11.0 → 1.12.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 +3 -1
- package/dist/cli/agent-plugin.d.ts +2 -2
- package/dist/cli/agent-plugin.js +2 -2
- package/dist/cli/baseline.js +2 -2
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +5 -4
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js +4 -5
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/plugin-command.test.js +1 -1
- package/dist/cli/plugin-command.test.js.map +1 -1
- package/dist/cli/plugin.js +2 -2
- package/dist/cli/plugin.js.map +1 -1
- package/dist/cli/stack-config-update.test.js +115 -2
- package/dist/cli/stack-config-update.test.js.map +1 -1
- package/dist/cli/stack-config.d.ts +17 -0
- package/dist/cli/stack-config.d.ts.map +1 -1
- package/dist/cli/stack-config.js +123 -2
- package/dist/cli/stack-config.js.map +1 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +6 -0
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +23 -0
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/team-health.d.ts.map +1 -1
- package/dist/cli/team-health.js +14 -3
- package/dist/cli/team-health.js.map +1 -1
- package/dist/cli/team-health.test.d.ts +2 -0
- package/dist/cli/team-health.test.d.ts.map +1 -0
- package/dist/cli/team-health.test.js +44 -0
- package/dist/cli/team-health.test.js.map +1 -0
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +2 -3
- package/dist/cli/update.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/agent-plugin.ts +2 -2
- package/src/cli/baseline.ts +2 -2
- package/src/cli/doctor.ts +5 -4
- package/src/cli/explain.ts +4 -5
- package/src/cli/plugin-command.test.ts +1 -1
- package/src/cli/plugin.ts +2 -2
- package/src/cli/stack-config-update.test.ts +123 -2
- package/src/cli/stack-config.ts +116 -2
- package/src/cli/sync-check.test.ts +29 -0
- package/src/cli/sync-check.ts +5 -0
- package/src/cli/team-health.test.ts +51 -0
- package/src/cli/team-health.ts +11 -2
- package/src/cli/update.ts +2 -3
- package/src/orchestrator/instructions/general.instructions.md +1 -1
- package/src/orchestrator/skills/self-improvement/SKILL.md +10 -1
|
@@ -14,6 +14,8 @@ import { buildCheckReport } from './sync-check.js'
|
|
|
14
14
|
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
15
15
|
import { writeManifest as writeManifestOnly } from './manifest.js'
|
|
16
16
|
import { recordLockFor } from './lock.js'
|
|
17
|
+
import { renderLesson } from './lessons.js'
|
|
18
|
+
import { refreshLessons } from './lessons-rules.js'
|
|
17
19
|
import type { Manifest } from './types.js'
|
|
18
20
|
|
|
19
21
|
/** A compile writes the manifest and the lock; tests that compile by hand do both. */
|
|
@@ -65,6 +67,33 @@ describe('drift detection', () => {
|
|
|
65
67
|
expect(report.checked).toBeGreaterThan(0)
|
|
66
68
|
})
|
|
67
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The fresh compile runs in an empty directory, which has no lessons, so its
|
|
72
|
+
* lessons rule says "No lessons yet". Every project with a lesson was told its
|
|
73
|
+
* rule differed from that, after every `sync`: a drift no command could clear.
|
|
74
|
+
*/
|
|
75
|
+
it('holds the lessons rule to the lessons, not to a compile that has none', async () => {
|
|
76
|
+
mkdirSync(join(projectRoot, '.opencastle', 'lessons'), { recursive: true })
|
|
77
|
+
writeFileSync(
|
|
78
|
+
join(projectRoot, '.opencastle', 'lessons', '2026-10-07-quote-paths.md'),
|
|
79
|
+
renderLesson({
|
|
80
|
+
id: '2026-10-07-quote-paths', title: 'Quote paths with spaces', category: 'terminal', severity: 'medium',
|
|
81
|
+
added: '2026-10-07', citations: [], status: 'active', body: 'Unquoted paths break.',
|
|
82
|
+
}),
|
|
83
|
+
)
|
|
84
|
+
await install()
|
|
85
|
+
refreshLessons(join(projectRoot, '.opencastle'))
|
|
86
|
+
const rule = join(projectRoot, '.github', 'instructions', 'opencastle-lessons.instructions.md')
|
|
87
|
+
expect(readFileSync(rule, 'utf8')).toContain('Quote paths with spaces')
|
|
88
|
+
|
|
89
|
+
expect((await buildCheckReport(pkgRoot, projectRoot)).drift).toEqual([])
|
|
90
|
+
|
|
91
|
+
// Still held to the lessons: an edit by hand is drift, once, and `sync` clears it.
|
|
92
|
+
appendFileSync(rule, '- a lesson nobody wrote\n')
|
|
93
|
+
const drift = (await buildCheckReport(pkgRoot, projectRoot)).drift.filter((d) => d.path.endsWith('opencastle-lessons.instructions.md'))
|
|
94
|
+
expect(drift.map((d) => d.kind)).toEqual(['outdated'])
|
|
95
|
+
})
|
|
96
|
+
|
|
68
97
|
it('catches a generated file edited in place', async () => {
|
|
69
98
|
await install()
|
|
70
99
|
const target = join(projectRoot, '.github', 'agents', 'developer.agent.md')
|
package/src/cli/sync-check.ts
CHANGED
|
@@ -183,6 +183,11 @@ function comparePath(
|
|
|
183
183
|
const f = join(fresh, rel)
|
|
184
184
|
const a = join(actual, rel)
|
|
185
185
|
const shown = `${managedPath.replace(/\/$/, '')}/${rel}`
|
|
186
|
+
// The compile runs in an empty directory with no lessons, so its lessons
|
|
187
|
+
// rule says there are none. The rule is held to the project's lessons
|
|
188
|
+
// below, like the index; compared here, every project with a lesson
|
|
189
|
+
// drifted after every sync.
|
|
190
|
+
if (isLessonRule(shown)) continue
|
|
186
191
|
checked++
|
|
187
192
|
if (!existsSync(a)) {
|
|
188
193
|
drift.push({ ide, path: shown, kind: 'missing' })
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, 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 { checkReferences, teamStateFor } from './team-health.js'
|
|
6
|
+
import type { Manifest } from './types.js'
|
|
7
|
+
|
|
8
|
+
const pkgRoot = resolve(import.meta.dirname, '..', '..')
|
|
9
|
+
const manifest: Manifest = {
|
|
10
|
+
version: '1.0.0',
|
|
11
|
+
ide: 'vscode',
|
|
12
|
+
ides: ['vscode'],
|
|
13
|
+
installedAt: '2026-10-09T00:00:00.000Z',
|
|
14
|
+
updatedAt: '2026-10-09T00:00:00.000Z',
|
|
15
|
+
stack: { ides: ['vscode'], techTools: [], teamTools: [] },
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A Convex project has a `convex/` directory and imports `convex/react`. The
|
|
20
|
+
* check read the import as a path into that directory and told the team its
|
|
21
|
+
* instructions named a file that does not exist.
|
|
22
|
+
*/
|
|
23
|
+
describe('team instructions match this repository', () => {
|
|
24
|
+
let dir: string
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
dir = mkdtempSync(join(tmpdir(), 'oc-team-health-'))
|
|
28
|
+
mkdirSync(join(dir, 'convex'))
|
|
29
|
+
mkdirSync(join(dir, '.opencastle'))
|
|
30
|
+
writeFileSync(join(dir, 'convex', 'schema.ts'), 'export default {}\n')
|
|
31
|
+
writeFileSync(join(dir, 'package.json'), JSON.stringify({ name: 'app', dependencies: { convex: '^1.46.0' } }))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
rmSync(dir, { recursive: true, force: true })
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const check = (instructions: string): string => {
|
|
39
|
+
writeFileSync(join(dir, '.opencastle', 'project.instructions.md'), instructions)
|
|
40
|
+
return checkReferences(teamStateFor(pkgRoot, dir, manifest), dir).detail ?? ''
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
it('reads a dependency and an extensionless subpath as an import, not a path', () => {
|
|
44
|
+
expect(check('# Project\n\nData access is typed hooks over `convex/react`; the schema is `convex/schema.ts`.\n'))
|
|
45
|
+
.toBe('every script and path the team content names exists')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('still names a file under that directory that is gone', () => {
|
|
49
|
+
expect(check('# Project\n\nThe old resolvers are in `convex/legacy.ts`.\n')).toContain('`convex/legacy.ts`, which does not exist')
|
|
50
|
+
})
|
|
51
|
+
})
|
package/src/cli/team-health.ts
CHANGED
|
@@ -155,8 +155,13 @@ const PATH_SPAN = /`([A-Za-z0-9_.@-][A-Za-z0-9_.@/-]*\/[A-Za-z0-9_.@/-]*[A-Za-z0
|
|
|
155
155
|
*/
|
|
156
156
|
export function checkReferences(state: TeamState, projectRoot: string): HealthResult {
|
|
157
157
|
let scripts: Record<string, string> | null = null
|
|
158
|
+
const dependencies = new Set<string>()
|
|
158
159
|
try {
|
|
159
|
-
|
|
160
|
+
const pkg = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8')) as Record<string, Record<string, string> | undefined>
|
|
161
|
+
scripts = pkg.scripts ?? {}
|
|
162
|
+
for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
|
|
163
|
+
for (const name of Object.keys(pkg[field] ?? {})) dependencies.add(name)
|
|
164
|
+
}
|
|
160
165
|
} catch {
|
|
161
166
|
scripts = null
|
|
162
167
|
}
|
|
@@ -189,7 +194,11 @@ export function checkReferences(state: TeamState, projectRoot: string): HealthRe
|
|
|
189
194
|
// a reference.
|
|
190
195
|
const top = resolve(projectRoot, first)
|
|
191
196
|
if (!existsSync(top) || !statSync(top).isDirectory()) continue
|
|
192
|
-
if (
|
|
197
|
+
if (existsSync(resolve(projectRoot, path))) continue
|
|
198
|
+
// A dependency's name and a subpath with no extension is an import —
|
|
199
|
+
// `convex/react` beside a Convex project's own `convex/` directory.
|
|
200
|
+
if (dependencies.has(first) && !/\.[A-Za-z0-9]+$/.test(path)) continue
|
|
201
|
+
dead.push(`${ref} names \`${path}\`, which does not exist`)
|
|
193
202
|
}
|
|
194
203
|
}
|
|
195
204
|
}
|
package/src/cli/update.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
updateSkillMatrixFile,
|
|
12
12
|
resolveStack,
|
|
13
13
|
getCustomizationsTransform,
|
|
14
|
-
isEnvVarSatisfied, isPreselected } from './stack-config.js'
|
|
14
|
+
isEnvVarSatisfied, isPreselected, envFileTextFor } from './stack-config.js'
|
|
15
15
|
import { rebuildMcpConfig, getMcpConfigRelPath, retireLegacyMcpConfig, LEGACY_MCP_CONFIGS } from './mcp.js'
|
|
16
16
|
import { updateGitignore, LOCAL_DIRS } from './gitignore.js'
|
|
17
17
|
import { resolveManagedPaths, REQUIRED_CUSTOMIZATIONS } from './managed-paths.js'
|
|
@@ -959,8 +959,7 @@ export default async function update({
|
|
|
959
959
|
// gate, so `opencastle add sentry` never mentioned the token it now needs.
|
|
960
960
|
if (newStack) {
|
|
961
961
|
const envVars = requiredEnvVars(resolved, newStack, repoInfo)
|
|
962
|
-
const
|
|
963
|
-
const missing = envVars.filter(({ envVar }) => !isEnvVarSatisfied(envVar, envFile))
|
|
962
|
+
const missing = envVars.filter(({ envVar, server }) => !isEnvVarSatisfied(envVar, envFileTextFor(projectRoot, server)))
|
|
964
963
|
if (missing.length > 0) {
|
|
965
964
|
console.log(`\n ${c.yellow('⚠')} Environment variables still needed:\n`)
|
|
966
965
|
for (const { envVar, hint } of missing) {
|
|
@@ -15,6 +15,6 @@ The project's own instructions win: the Project Context loaded with these, the r
|
|
|
15
15
|
- **Fail visibly** — surface errors; never swallow an exception.
|
|
16
16
|
- **Comments say why**, not what.
|
|
17
17
|
- **Git.** Never push to `main`: every change goes through a branch and a pull request (**git-workflow**).
|
|
18
|
-
- **Memory: the team's or the user's.** The team's lessons load with these instructions (if they did not, read `.opencastle/LESSONS-LEARNED.md`); open the ones that touch your task. Save what you learn in your own memory, as you normally do: in Claude Code and VS Code, OpenCastle shares what is about the project with the team when the session ends, and leaves what is about the user. So save what is about the user (their preferences, role, habits, machine) as about the user. In any other assistant, record what you confirm about the project as a lesson (**self-improvement**).
|
|
18
|
+
- **Memory: the team's or the user's.** The team's lessons load with these instructions (if they did not, read `.opencastle/LESSONS-LEARNED.md`); open the ones that touch your task. Save what you learn in your own memory, as you normally do: in Claude Code and VS Code, OpenCastle shares what is about the project with the team when the session ends, and leaves what is about the user. So save what is about the user (their preferences, role, habits, machine) as about the user. In any other assistant, record what you confirm about the project as a lesson. A procedure you had to work out — how to run, test or release something here — that no skill covers becomes a team skill, in the same change (**self-improvement**).
|
|
19
19
|
|
|
20
20
|
<!-- End of Coding Standards -->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: self-improvement
|
|
3
|
-
description: "Keeps the team's memory: where what you learned goes (your memory, shared with the team when it is about the project,
|
|
3
|
+
description: "Keeps the team's memory: where what you learned goes (your memory, shared with the team when it is about the project, a lesson in .opencastle/lessons/, or a team skill for a procedure), and how lessons are cited, re-verified and graduated. Use when you confirm something true for anyone working in the repository (a fix after a failure, a convention, a decision, a quirk, a correction about the code), when you work out a procedure no skill covers, when you touch a lesson copied from memory, when doctor reports a lesson's cited code changed, or when the lessons index grows long."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Self-Improvement
|
|
@@ -17,6 +17,7 @@ In Claude Code and VS Code, save it in your own memory as you normally do. When
|
|
|
17
17
|
|-------------|------------|-------------|
|
|
18
18
|
| The project: true for anyone working in this repository | About the project (a correction, a project note, a pointer to where something lives) | `pnpm build` fails without `CI=1` set; every migration ships with a down file; the staging API allows 10 requests a second; the user says "we never use default exports" |
|
|
19
19
|
| The user: true for them, wherever they work | About the user. It stays theirs and never becomes a lesson | They want short answers; they use fish; their role; their editor; paths on their machine |
|
|
20
|
+
| A procedure you had to work out, which no skill covers | A team skill, written in the same change (below) | How to run the end-to-end tests against a local database; the steps to release the mobile app |
|
|
20
21
|
| Every repository in the organisation | About the project, saying it holds in every repository; it graduates into the baseline's skill (below) | The company's deploy pipeline needs a manual approval; an internal service's API contract |
|
|
21
22
|
| This task only | Nothing | A one-off workaround; a guess you have not confirmed |
|
|
22
23
|
|
|
@@ -44,6 +45,14 @@ Search the lessons themselves first — the index has titles only — so you do
|
|
|
44
45
|
rg -i "CRON_SECRET" .opencastle/lessons/ || true
|
|
45
46
|
```
|
|
46
47
|
|
|
48
|
+
## Write down a procedure
|
|
49
|
+
|
|
50
|
+
A lesson holds a fact. Steps you had to work out — to run, test, seed or release something in this repository — belong in a team skill, which an agent loads when a task matches. Write it once the steps have worked, in the same change:
|
|
51
|
+
|
|
52
|
+
1. Look for a skill that already covers it (`npx opencastle explain` lists them) and add to that one if there is.
|
|
53
|
+
2. Otherwise create `.opencastle/skills/<name>/SKILL.md`: `name` is the directory's name, in kebab-case; `description` is one line, what it is for and then "Use when …"; the body is the steps, each with the exact command and how to tell it worked.
|
|
54
|
+
3. Run `npx opencastle sync`, which compiles it for every assistant, and commit the skill with the compiled copies. A lesson that holds the same steps: `npx opencastle lesson archive <id> --into .opencastle/skills/<name>/SKILL.md`.
|
|
55
|
+
|
|
47
56
|
## When cited code has changed
|
|
48
57
|
|
|
49
58
|
`doctor` names it: `<id> cites <file>, which has changed since it was verified`. Read the lesson against the code:
|