opencastle 1.11.0 → 1.11.1
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/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/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/doctor.ts +5 -4
- package/src/cli/explain.ts +4 -5
- 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
|
@@ -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) {
|