opencastle 0.38.1 → 1.0.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 +81 -1
- package/bin/cli.mjs +20 -3
- package/dist/cli/adapters/antigravity.d.ts +1 -1
- package/dist/cli/adapters/antigravity.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.d.ts +1 -1
- package/dist/cli/adapters/claude-code.d.ts.map +1 -1
- package/dist/cli/adapters/codex.d.ts +1 -1
- package/dist/cli/adapters/codex.d.ts.map +1 -1
- package/dist/cli/adapters/cursor.d.ts +1 -1
- package/dist/cli/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/adapters/opencode.d.ts +1 -1
- package/dist/cli/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.d.ts +3 -2
- package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +13 -25
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +30 -43
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts +3 -2
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +19 -71
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/adapters/windsurf.d.ts +1 -1
- package/dist/cli/adapters/windsurf.d.ts.map +1 -1
- package/dist/cli/baseline.d.ts +3 -0
- package/dist/cli/baseline.d.ts.map +1 -0
- package/dist/cli/baseline.js +280 -0
- package/dist/cli/baseline.js.map +1 -0
- package/dist/cli/bootstrap.d.ts +1 -0
- package/dist/cli/bootstrap.d.ts.map +1 -1
- package/dist/cli/bootstrap.js +1 -1
- package/dist/cli/bootstrap.js.map +1 -1
- package/dist/cli/ci.d.ts +18 -0
- package/dist/cli/ci.d.ts.map +1 -0
- package/dist/cli/ci.js +279 -0
- package/dist/cli/ci.js.map +1 -0
- package/dist/cli/dispatcher.test.js +2 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +5 -0
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts +3 -3
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +66 -9
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/explain.d.ts +3 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +210 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/fleet.d.ts +30 -0
- package/dist/cli/fleet.d.ts.map +1 -0
- package/dist/cli/fleet.js +149 -0
- package/dist/cli/fleet.js.map +1 -0
- package/dist/cli/github-report.d.ts +49 -0
- package/dist/cli/github-report.d.ts.map +1 -0
- package/dist/cli/github-report.js +161 -0
- package/dist/cli/github-report.js.map +1 -0
- package/dist/cli/github-report.test.d.ts +2 -0
- package/dist/cli/github-report.test.d.ts.map +1 -0
- package/dist/cli/github-report.test.js +146 -0
- package/dist/cli/github-report.test.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +135 -94
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +26 -25
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts +152 -0
- package/dist/cli/layers.d.ts.map +1 -0
- package/dist/cli/layers.js +932 -0
- package/dist/cli/layers.js.map +1 -0
- package/dist/cli/layers.test.d.ts +2 -0
- package/dist/cli/layers.test.d.ts.map +1 -0
- package/dist/cli/layers.test.js +483 -0
- package/dist/cli/layers.test.js.map +1 -0
- package/dist/cli/lock.d.ts +130 -0
- package/dist/cli/lock.d.ts.map +1 -0
- package/dist/cli/lock.js +320 -0
- package/dist/cli/lock.js.map +1 -0
- package/dist/cli/mcp-audit.d.ts +164 -0
- package/dist/cli/mcp-audit.d.ts.map +1 -0
- package/dist/cli/mcp-audit.js +504 -0
- package/dist/cli/mcp-audit.js.map +1 -0
- package/dist/cli/mcp-audit.test.d.ts +2 -0
- package/dist/cli/mcp-audit.test.d.ts.map +1 -0
- package/dist/cli/mcp-audit.test.js +215 -0
- package/dist/cli/mcp-audit.test.js.map +1 -0
- package/dist/cli/mcp-upgrade.test.d.ts +2 -0
- package/dist/cli/mcp-upgrade.test.d.ts.map +1 -0
- package/dist/cli/mcp-upgrade.test.js +118 -0
- package/dist/cli/mcp-upgrade.test.js.map +1 -0
- package/dist/cli/mcp.d.ts +74 -5
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +340 -32
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/policy.d.ts +58 -0
- package/dist/cli/policy.d.ts.map +1 -0
- package/dist/cli/policy.js +194 -0
- package/dist/cli/policy.js.map +1 -0
- package/dist/cli/publish-workflow.test.js +55 -1
- package/dist/cli/publish-workflow.test.js.map +1 -1
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +3 -2
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/review.d.ts +25 -0
- package/dist/cli/review.d.ts.map +1 -0
- package/dist/cli/review.js +437 -0
- package/dist/cli/review.js.map +1 -0
- package/dist/cli/status.d.ts +2 -0
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +25 -4
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/status.test.js +5 -3
- package/dist/cli/status.test.js.map +1 -1
- package/dist/cli/sync-check.d.ts +16 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +219 -13
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +14 -8
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -0
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/team-ci.test.d.ts +2 -0
- package/dist/cli/team-ci.test.d.ts.map +1 -0
- package/dist/cli/team-ci.test.js +169 -0
- package/dist/cli/team-ci.test.js.map +1 -0
- package/dist/cli/team-commands.test.d.ts +2 -0
- package/dist/cli/team-commands.test.d.ts.map +1 -0
- package/dist/cli/team-commands.test.js +233 -0
- package/dist/cli/team-commands.test.js.map +1 -0
- package/dist/cli/team-config.d.ts +88 -0
- package/dist/cli/team-config.d.ts.map +1 -0
- package/dist/cli/team-config.js +261 -0
- package/dist/cli/team-config.js.map +1 -0
- package/dist/cli/team-health.d.ts +49 -0
- package/dist/cli/team-health.d.ts.map +1 -0
- package/dist/cli/team-health.js +205 -0
- package/dist/cli/team-health.js.map +1 -0
- package/dist/cli/team-sources.test.d.ts +2 -0
- package/dist/cli/team-sources.test.d.ts.map +1 -0
- package/dist/cli/team-sources.test.js +542 -0
- package/dist/cli/team-sources.test.js.map +1 -0
- package/dist/cli/types.d.ts +16 -2
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +204 -44
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/version-range.d.ts +24 -0
- package/dist/cli/version-range.d.ts.map +1 -0
- package/dist/cli/version-range.js +157 -0
- package/dist/cli/version-range.js.map +1 -0
- package/dist/cli/website-plugins.test.d.ts +2 -0
- package/dist/cli/website-plugins.test.d.ts.map +1 -0
- package/dist/cli/website-plugins.test.js +34 -0
- package/dist/cli/website-plugins.test.js.map +1 -0
- package/dist/orchestrator/plugins/chrome-devtools/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/chrome-devtools/config.js +11 -1
- package/dist/orchestrator/plugins/chrome-devtools/config.js.map +1 -1
- package/dist/orchestrator/plugins/contentful/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/contentful/config.js +11 -1
- package/dist/orchestrator/plugins/contentful/config.js.map +1 -1
- package/dist/orchestrator/plugins/convex/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/convex/config.js +11 -1
- package/dist/orchestrator/plugins/convex/config.js.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.js +14 -1
- package/dist/orchestrator/plugins/coolify/config.js.map +1 -1
- package/dist/orchestrator/plugins/figma/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/figma/config.js +24 -13
- package/dist/orchestrator/plugins/figma/config.js.map +1 -1
- package/dist/orchestrator/plugins/linear/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/linear/config.js +27 -17
- package/dist/orchestrator/plugins/linear/config.js.map +1 -1
- package/dist/orchestrator/plugins/netlify/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/netlify/config.js +23 -9
- package/dist/orchestrator/plugins/netlify/config.js.map +1 -1
- package/dist/orchestrator/plugins/nextjs/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/nextjs/config.js +11 -1
- package/dist/orchestrator/plugins/nextjs/config.js.map +1 -1
- package/dist/orchestrator/plugins/nx/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/nx/config.js +11 -1
- package/dist/orchestrator/plugins/nx/config.js.map +1 -1
- package/dist/orchestrator/plugins/pins.test.d.ts +2 -0
- package/dist/orchestrator/plugins/pins.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/pins.test.js +78 -0
- package/dist/orchestrator/plugins/pins.test.js.map +1 -0
- package/dist/orchestrator/plugins/playwright/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/playwright/config.js +11 -1
- package/dist/orchestrator/plugins/playwright/config.js.map +1 -1
- package/dist/orchestrator/plugins/prisma/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/prisma/config.js +17 -2
- package/dist/orchestrator/plugins/prisma/config.js.map +1 -1
- package/dist/orchestrator/plugins/resend/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/resend/config.js +17 -1
- package/dist/orchestrator/plugins/resend/config.js.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.js +13 -1
- package/dist/orchestrator/plugins/sentry/config.js.map +1 -1
- package/dist/orchestrator/plugins/slack/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/slack/config.js +20 -1
- package/dist/orchestrator/plugins/slack/config.js.map +1 -1
- package/dist/orchestrator/plugins/strapi/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/strapi/config.js +11 -1
- package/dist/orchestrator/plugins/strapi/config.js.map +1 -1
- package/dist/orchestrator/plugins/trello/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/trello/config.js +21 -1
- package/dist/orchestrator/plugins/trello/config.js.map +1 -1
- package/dist/orchestrator/plugins/types.d.ts +22 -0
- package/dist/orchestrator/plugins/types.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/cli/adapters/rules-dir-base.ts +23 -44
- package/src/cli/adapters/single-file-base.ts +43 -46
- package/src/cli/adapters/vscode.ts +28 -71
- package/src/cli/baseline.ts +289 -0
- package/src/cli/bootstrap.ts +1 -1
- package/src/cli/ci.ts +289 -0
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +5 -0
- package/src/cli/doctor.ts +92 -6
- package/src/cli/explain.ts +210 -0
- package/src/cli/fleet.ts +176 -0
- package/src/cli/github-report.test.ts +158 -0
- package/src/cli/github-report.ts +179 -0
- package/src/cli/init.test.ts +27 -27
- package/src/cli/init.ts +135 -93
- package/src/cli/layers.test.ts +525 -0
- package/src/cli/layers.ts +1089 -0
- package/src/cli/lock.ts +395 -0
- package/src/cli/mcp-audit.test.ts +259 -0
- package/src/cli/mcp-audit.ts +619 -0
- package/src/cli/mcp-upgrade.test.ts +135 -0
- package/src/cli/mcp.ts +373 -34
- package/src/cli/policy.ts +207 -0
- package/src/cli/publish-workflow.test.ts +60 -1
- package/src/cli/remove.ts +8 -2
- package/src/cli/review.ts +457 -0
- package/src/cli/status.test.ts +5 -3
- package/src/cli/status.ts +29 -4
- package/src/cli/sync-check.test.ts +16 -8
- package/src/cli/sync-check.ts +245 -14
- package/src/cli/sync.ts +2 -0
- package/src/cli/team-ci.test.ts +195 -0
- package/src/cli/team-commands.test.ts +253 -0
- package/src/cli/team-config.ts +289 -0
- package/src/cli/team-health.ts +234 -0
- package/src/cli/team-sources.test.ts +578 -0
- package/src/cli/types.ts +19 -1
- package/src/cli/update.ts +217 -44
- package/src/cli/version-range.ts +150 -0
- package/src/cli/website-plugins.test.ts +41 -0
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/customizations/README.md +1 -1
- package/src/orchestrator/plugins/chrome-devtools/SKILL.md +1 -1
- package/src/orchestrator/plugins/chrome-devtools/config.ts +11 -1
- package/src/orchestrator/plugins/contentful/SKILL.md +1 -1
- package/src/orchestrator/plugins/contentful/config.ts +11 -1
- package/src/orchestrator/plugins/convex/SKILL.md +1 -1
- package/src/orchestrator/plugins/convex/config.ts +11 -1
- package/src/orchestrator/plugins/coolify/config.ts +14 -1
- package/src/orchestrator/plugins/cypress/SKILL.md +1 -1
- package/src/orchestrator/plugins/figma/SKILL.md +18 -14
- package/src/orchestrator/plugins/figma/config.ts +24 -13
- package/src/orchestrator/plugins/jira/SKILL.md +2 -2
- package/src/orchestrator/plugins/linear/SKILL.md +6 -14
- package/src/orchestrator/plugins/linear/config.ts +27 -17
- package/src/orchestrator/plugins/netlify/SKILL.md +1 -1
- package/src/orchestrator/plugins/netlify/config.ts +23 -9
- package/src/orchestrator/plugins/nextjs/config.ts +11 -1
- package/src/orchestrator/plugins/nx/config.ts +11 -1
- package/src/orchestrator/plugins/pins.test.ts +80 -0
- package/src/orchestrator/plugins/playwright/SKILL.md +1 -1
- package/src/orchestrator/plugins/playwright/config.ts +11 -1
- package/src/orchestrator/plugins/prisma/SKILL.md +1 -1
- package/src/orchestrator/plugins/prisma/config.ts +17 -2
- package/src/orchestrator/plugins/resend/config.ts +17 -1
- package/src/orchestrator/plugins/sanity/SKILL.md +1 -1
- package/src/orchestrator/plugins/sentry/config.ts +13 -1
- package/src/orchestrator/plugins/slack/config.ts +20 -1
- package/src/orchestrator/plugins/strapi/SKILL.md +1 -1
- package/src/orchestrator/plugins/strapi/config.ts +11 -1
- package/src/orchestrator/plugins/supabase/SKILL.md +1 -1
- package/src/orchestrator/plugins/trello/SKILL.md +1 -1
- package/src/orchestrator/plugins/trello/config.ts +21 -1
- package/src/orchestrator/plugins/types.ts +24 -0
- package/src/orchestrator/plugins/vercel/SKILL.md +1 -1
- package/src/orchestrator/plugins/vitest/SKILL.md +1 -1
- package/src/orchestrator/skill-config-links.test.ts +30 -0
- package/src/orchestrator/skills/git-workflow/SKILL.md +1 -1
|
@@ -3,9 +3,9 @@ import { mkdir, writeFile, readdir, readFile, rm, rename } from 'node:fs/promise
|
|
|
3
3
|
import { existsSync, readdirSync, realpathSync } from 'node:fs'
|
|
4
4
|
import { writeManagedBlock, recordMerge } from '../managed-block.js'
|
|
5
5
|
import { TIERS, TIER_IDS, isTier, tierForAgent, type Tier } from '../tiers.js'
|
|
6
|
-
import { mergeCopyResults, copyDir
|
|
6
|
+
import { mergeCopyResults, copyDir } from '../copy.js'
|
|
7
7
|
import { scaffoldMcpConfigInto } from '../mcp.js'
|
|
8
|
-
import {
|
|
8
|
+
import { withSource, type CompileSource } from '../layers.js'
|
|
9
9
|
import type { CopyResults, DoctorCheck, IdeAdapter, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
10
10
|
import { stripFrontmatter, parseFrontmatterMeta } from './frontmatter.js'
|
|
11
11
|
|
|
@@ -169,13 +169,26 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
169
169
|
projectRoot: string,
|
|
170
170
|
stack: StackConfig | undefined,
|
|
171
171
|
repoInfo: RepoInfo | undefined,
|
|
172
|
-
overwrite: boolean
|
|
172
|
+
overwrite: boolean,
|
|
173
|
+
source: CompileSource | undefined,
|
|
173
174
|
): Promise<CopyResults> {
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
return withSource(pkgRoot, stack, source, (src) => compileFrom(src, projectRoot, stack, repoInfo, overwrite))
|
|
176
|
+
}
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
/**
|
|
179
|
+
* One pass over the merged source. What the stack leaves out, what a team
|
|
180
|
+
* excluded, and the integrations' skills are already settled in it, so this
|
|
181
|
+
* compiles what it finds.
|
|
182
|
+
*/
|
|
183
|
+
async function compileFrom(
|
|
184
|
+
src: CompileSource,
|
|
185
|
+
projectRoot: string,
|
|
186
|
+
stack: StackConfig | undefined,
|
|
187
|
+
repoInfo: RepoInfo | undefined,
|
|
188
|
+
overwrite: boolean,
|
|
189
|
+
): Promise<CopyResults> {
|
|
190
|
+
const srcRoot = src.root
|
|
191
|
+
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
179
192
|
|
|
180
193
|
// 1. Build root instructions file.
|
|
181
194
|
// Always built: the content goes into a managed block, so a file the user
|
|
@@ -224,7 +237,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
224
237
|
const usedTiers = new Set<Tier>()
|
|
225
238
|
for (const file of (await readdir(agentsDir)).sort()) {
|
|
226
239
|
if (!file.endsWith('.md')) continue
|
|
227
|
-
if (excludedAgents.has(file)) continue
|
|
228
240
|
const meta = parseFrontmatterMeta(
|
|
229
241
|
await readFile(resolve(agentsDir, file), 'utf8')
|
|
230
242
|
)
|
|
@@ -259,10 +271,21 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
259
271
|
).filter((e) => e.isDirectory())
|
|
260
272
|
const skillRef = (name: string): string =>
|
|
261
273
|
`${refDir}/skills/${name}/SKILL.md`
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
274
|
+
// Integration skills are listed after the rest, as they always were:
|
|
275
|
+
// reordering the index would change every root file on upgrade for
|
|
276
|
+
// no reason anyone could see in the diff.
|
|
277
|
+
const integrations = new Set(
|
|
278
|
+
[...src.resolved.items.values()].filter((i) => i.plugin && i.layer === 'opencastle').map((i) => i.name),
|
|
279
|
+
)
|
|
280
|
+
// Code-point order, not the machine's locale: under a Danish or
|
|
281
|
+
// Estonian locale `localeCompare` ordered names differently, and the
|
|
282
|
+
// root file then differed between two teammates' checkouts.
|
|
283
|
+
const byName = (a: { name: string }, b: { name: string }): number => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
|
|
284
|
+
const ordered = [
|
|
285
|
+
...subdirs.filter((e) => !integrations.has(e.name)).sort(byName),
|
|
286
|
+
...subdirs.filter((e) => integrations.has(e.name)).sort(byName),
|
|
287
|
+
]
|
|
288
|
+
for (const entry of ordered) {
|
|
266
289
|
const skillFile = resolve(skillsDir, entry.name, 'SKILL.md')
|
|
267
290
|
if (!existsSync(skillFile)) continue
|
|
268
291
|
const meta = parseFrontmatterMeta(await readFile(skillFile, 'utf8'))
|
|
@@ -272,18 +295,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
272
295
|
)
|
|
273
296
|
}
|
|
274
297
|
|
|
275
|
-
// Plugin skills
|
|
276
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
277
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
278
|
-
const pluginEntries = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
279
|
-
for (const { id, skillPath } of pluginEntries.sort((a, b) => a.id.localeCompare(b.id))) {
|
|
280
|
-
const pluginMeta = parseFrontmatterMeta(await readFile(skillPath, 'utf8'))
|
|
281
|
-
const pluginDesc = pluginMeta['description'] ?? ''
|
|
282
|
-
skillLines.push(
|
|
283
|
-
`- **${id}** (\`${skillRef(id)}\`): ${pluginDesc}`
|
|
284
|
-
)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
298
|
sections.push(skillLines.join('\n'))
|
|
288
299
|
}
|
|
289
300
|
|
|
@@ -300,7 +311,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
300
311
|
await mkdir(destAgents, { recursive: true })
|
|
301
312
|
for (const file of await readdir(agentsDir)) {
|
|
302
313
|
if (!file.endsWith('.md')) continue
|
|
303
|
-
if (excludedAgents.has(file)) continue
|
|
304
314
|
const destPath = resolve(destAgents, file)
|
|
305
315
|
const content = await readFile(resolve(agentsDir, file), 'utf8')
|
|
306
316
|
await emit(projectRoot, destPath, stripFrontmatter(content) + '\n', overwrite, results)
|
|
@@ -318,7 +328,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
318
328
|
await readdir(skillsDir, { withFileTypes: true })
|
|
319
329
|
).filter((e) => e.isDirectory())
|
|
320
330
|
for (const entry of subdirs) {
|
|
321
|
-
if (excludedSkills.has(entry.name)) continue
|
|
322
331
|
const skillFile = resolve(skillsDir, entry.name, 'SKILL.md')
|
|
323
332
|
if (!existsSync(skillFile)) continue
|
|
324
333
|
const sub = await copyDir(
|
|
@@ -338,21 +347,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
338
347
|
}
|
|
339
348
|
}
|
|
340
349
|
|
|
341
|
-
// 3b. Plugin skills → dotDir/skills/<plugin-id>/SKILL.md
|
|
342
|
-
{
|
|
343
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
344
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
345
|
-
const pluginEntries = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
346
|
-
const destSkills = resolve(dotDirPath, 'skills')
|
|
347
|
-
await mkdir(destSkills, { recursive: true })
|
|
348
|
-
for (const { id, skillPath } of pluginEntries) {
|
|
349
|
-
const pluginDestDir = resolve(destSkills, id)
|
|
350
|
-
await mkdir(pluginDestDir, { recursive: true })
|
|
351
|
-
const destPath = resolve(pluginDestDir, 'SKILL.md')
|
|
352
|
-
await emit(projectRoot, destPath, await readFile(skillPath, 'utf8'), overwrite, results)
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
350
|
// 4. Prompts → dotDir/<promptsDir>/<name>.md
|
|
357
351
|
const promptDir = resolve(srcRoot, 'prompts')
|
|
358
352
|
if (existsSync(promptDir)) {
|
|
@@ -389,7 +383,8 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
389
383
|
config.mcpConfigPath,
|
|
390
384
|
stack,
|
|
391
385
|
repoInfo,
|
|
392
|
-
config.mcpFormat
|
|
386
|
+
config.mcpFormat,
|
|
387
|
+
src.mcp,
|
|
393
388
|
)
|
|
394
389
|
|
|
395
390
|
return results
|
|
@@ -400,16 +395,18 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
400
395
|
pkgRoot: string,
|
|
401
396
|
projectRoot: string,
|
|
402
397
|
stack?: StackConfig,
|
|
403
|
-
repoInfo?: RepoInfo
|
|
398
|
+
repoInfo?: RepoInfo,
|
|
399
|
+
source?: CompileSource,
|
|
404
400
|
): Promise<CopyResults> {
|
|
405
|
-
return compile(pkgRoot, projectRoot, stack, repoInfo, false)
|
|
401
|
+
return compile(pkgRoot, projectRoot, stack, repoInfo, false, source)
|
|
406
402
|
}
|
|
407
403
|
|
|
408
404
|
async function update(
|
|
409
405
|
pkgRoot: string,
|
|
410
406
|
projectRoot: string,
|
|
411
407
|
stack?: StackConfig,
|
|
412
|
-
repoInfo?: RepoInfo
|
|
408
|
+
repoInfo?: RepoInfo,
|
|
409
|
+
source?: CompileSource,
|
|
413
410
|
): Promise<CopyResults> {
|
|
414
411
|
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
415
412
|
const dotDirPath = resolve(projectRoot, config.dotDir)
|
|
@@ -444,7 +441,7 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
444
441
|
// written again — and reversing the order silently turned `sync` into a
|
|
445
442
|
// no-op on content. The sweep's job now is only to remove output with no
|
|
446
443
|
// source left, which is the one thing recompiling cannot do.
|
|
447
|
-
const installResult = await compile(pkgRoot, projectRoot, stack, repoInfo, true)
|
|
444
|
+
const installResult = await compile(pkgRoot, projectRoot, stack, repoInfo, true, source)
|
|
448
445
|
|
|
449
446
|
// 4. Now that the new output exists, drop anything stale beside it.
|
|
450
447
|
//
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { resolve } from 'node:path'
|
|
2
|
-
import { mkdir, readFile,
|
|
2
|
+
import { mkdir, readFile, unlink, rename } from 'node:fs/promises'
|
|
3
3
|
import { existsSync, readdirSync, realpathSync } from 'node:fs'
|
|
4
4
|
import { writeManagedBlock, recordMerge } from '../managed-block.js'
|
|
5
|
-
import { mergeCopyResults, copyDir
|
|
5
|
+
import { mergeCopyResults, copyDir } from '../copy.js'
|
|
6
6
|
import { scaffoldMcpConfigInto } from '../mcp.js'
|
|
7
|
-
import {
|
|
7
|
+
import { getAgentTransform } from '../stack-config.js'
|
|
8
|
+
import { withSource, type CompileSource } from '../layers.js'
|
|
8
9
|
import type { CopyResults, CopyDirOptions, DoctorCheck, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -42,16 +43,10 @@ const FRAMEWORK_DIRS = [
|
|
|
42
43
|
*/
|
|
43
44
|
function copyRulesFor(
|
|
44
45
|
dir: string,
|
|
45
|
-
excludedSkills: Set<string>,
|
|
46
|
-
excludedAgents: Set<string>,
|
|
47
46
|
stack?: StackConfig,
|
|
48
47
|
): { filter?: (_name: string, _srcPath: string) => boolean; transform?: CopyDirOptions['transform'] } {
|
|
49
|
-
if (dir === 'skills') return { filter: (name) => !excludedSkills.has(name) }
|
|
50
48
|
if (dir === 'agents') {
|
|
51
|
-
return {
|
|
52
|
-
filter: (name) => !excludedAgents.has(name),
|
|
53
|
-
transform: stack ? getAgentTransform(stack) : undefined,
|
|
54
|
-
}
|
|
49
|
+
return { transform: stack ? getAgentTransform(stack) : undefined }
|
|
55
50
|
}
|
|
56
51
|
if (dir === 'agent-workflows') {
|
|
57
52
|
// The directory's own README documents the templates for contributors; it is
|
|
@@ -97,18 +92,25 @@ export async function install(
|
|
|
97
92
|
pkgRoot: string,
|
|
98
93
|
projectRoot: string,
|
|
99
94
|
stack?: StackConfig,
|
|
100
|
-
repoInfo?: RepoInfo
|
|
95
|
+
repoInfo?: RepoInfo,
|
|
96
|
+
source?: CompileSource,
|
|
97
|
+
): Promise<CopyResults> {
|
|
98
|
+
return withSource(pkgRoot, stack, source, (src) => installFrom(src, projectRoot, stack, repoInfo))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function installFrom(
|
|
102
|
+
src: CompileSource,
|
|
103
|
+
projectRoot: string,
|
|
104
|
+
stack: StackConfig | undefined,
|
|
105
|
+
repoInfo: RepoInfo | undefined,
|
|
101
106
|
): Promise<CopyResults> {
|
|
102
|
-
const srcRoot =
|
|
107
|
+
const srcRoot = src.root
|
|
103
108
|
const destRoot = resolve(projectRoot, '.github')
|
|
104
109
|
|
|
105
110
|
await mkdir(destRoot, { recursive: true })
|
|
106
111
|
|
|
107
112
|
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
108
113
|
|
|
109
|
-
const excludedSkills = stack ? getExcludedSkills(stack) : new Set<string>()
|
|
110
|
-
const excludedAgents = stack ? getExcludedAgents(stack) : new Set<string>()
|
|
111
|
-
|
|
112
114
|
// copilot-instructions.md — merged, not replaced. A project that already has
|
|
113
115
|
// one keeps it; the generated content goes into a managed block below it.
|
|
114
116
|
const copilotSrc = resolve(srcRoot, 'copilot-instructions.md')
|
|
@@ -124,28 +126,12 @@ export async function install(
|
|
|
124
126
|
if (!existsSync(srcDir)) continue
|
|
125
127
|
const destDir = resolve(destRoot, dir)
|
|
126
128
|
|
|
127
|
-
const { filter, transform } = copyRulesFor(dir,
|
|
129
|
+
const { filter, transform } = copyRulesFor(dir, stack)
|
|
128
130
|
|
|
129
131
|
const sub = await copyDir(srcDir, destDir, { filter, transform })
|
|
130
132
|
mergeCopyResults(results, sub)
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
// Plugin skills → .github/skills/<plugin-id>/
|
|
134
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
135
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
136
|
-
const pluginSkills = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
137
|
-
for (const { id, skillPath } of pluginSkills) {
|
|
138
|
-
const pluginDestDir = resolve(destRoot, 'skills', id)
|
|
139
|
-
await mkdir(pluginDestDir, { recursive: true })
|
|
140
|
-
const destPath = resolve(pluginDestDir, 'SKILL.md')
|
|
141
|
-
if (existsSync(destPath)) {
|
|
142
|
-
results.skipped.push(destPath)
|
|
143
|
-
} else {
|
|
144
|
-
await copyFile(skillPath, destPath)
|
|
145
|
-
results.created.push(destPath)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
135
|
// MCP server config → .vscode/mcp.json (scaffold once)
|
|
150
136
|
await scaffoldMcpConfigInto(
|
|
151
137
|
results,
|
|
@@ -153,7 +139,8 @@ export async function install(
|
|
|
153
139
|
'.vscode/mcp.json',
|
|
154
140
|
stack,
|
|
155
141
|
repoInfo,
|
|
156
|
-
'vscode'
|
|
142
|
+
'vscode',
|
|
143
|
+
src.mcp,
|
|
157
144
|
)
|
|
158
145
|
|
|
159
146
|
return results
|
|
@@ -163,16 +150,18 @@ export async function update(
|
|
|
163
150
|
pkgRoot: string,
|
|
164
151
|
projectRoot: string,
|
|
165
152
|
stack?: StackConfig,
|
|
166
|
-
_repoInfo?: RepoInfo
|
|
153
|
+
_repoInfo?: RepoInfo,
|
|
154
|
+
source?: CompileSource,
|
|
167
155
|
): Promise<CopyResults> {
|
|
168
|
-
|
|
156
|
+
return withSource(pkgRoot, stack, source, (src) => updateFrom(src, projectRoot, stack))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function updateFrom(src: CompileSource, projectRoot: string, stack: StackConfig | undefined): Promise<CopyResults> {
|
|
160
|
+
const srcRoot = src.root
|
|
169
161
|
const destRoot = resolve(projectRoot, '.github')
|
|
170
162
|
|
|
171
163
|
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
172
164
|
|
|
173
|
-
const excludedSkills = stack ? getExcludedSkills(stack) : new Set<string>()
|
|
174
|
-
const excludedAgents = stack ? getExcludedAgents(stack) : new Set<string>()
|
|
175
|
-
|
|
176
165
|
// `.github/` may not exist: a teammate clones a repo whose generated config was
|
|
177
166
|
// never committed, and `update` used to die with ENOENT before writing anything.
|
|
178
167
|
await mkdir(destRoot, { recursive: true })
|
|
@@ -207,45 +196,13 @@ export async function update(
|
|
|
207
196
|
if (!existsSync(srcDir)) continue
|
|
208
197
|
const destDir = resolve(destRoot, dir)
|
|
209
198
|
|
|
210
|
-
const { filter, transform } = copyRulesFor(dir,
|
|
199
|
+
const { filter, transform } = copyRulesFor(dir, stack)
|
|
211
200
|
|
|
212
201
|
const sub = await copyDir(srcDir, destDir, { overwrite: true, filter, transform })
|
|
213
202
|
mergeCopyResults(results, sub)
|
|
214
203
|
for (const abs of sub.visited ?? []) visited.add(abs)
|
|
215
204
|
}
|
|
216
205
|
|
|
217
|
-
// Plugin skills → .github/skills/<plugin-id>/ (overwrite)
|
|
218
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
219
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
220
|
-
const pluginSkills = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
221
|
-
for (const { id, skillPath } of pluginSkills) {
|
|
222
|
-
const pluginDestDir = resolve(destRoot, 'skills', id)
|
|
223
|
-
await mkdir(pluginDestDir, { recursive: true })
|
|
224
|
-
const destPath = resolve(pluginDestDir, 'SKILL.md')
|
|
225
|
-
visited.add(destPath)
|
|
226
|
-
const content = await readFile(skillPath, 'utf8')
|
|
227
|
-
const existed = existsSync(destPath)
|
|
228
|
-
// The same guard the other three write paths got. Unguarded, a directory
|
|
229
|
-
// wearing `SKILL.md`'s name took `sync` down with a bare `EISDIR` that named
|
|
230
|
-
// nothing to act on.
|
|
231
|
-
let onDisk: string | null = null
|
|
232
|
-
if (existed) {
|
|
233
|
-
try {
|
|
234
|
-
onDisk = await readFile(destPath, 'utf8')
|
|
235
|
-
} catch {
|
|
236
|
-
;(results.unreadable ??= []).push(`${destPath}\u0000unreadable`)
|
|
237
|
-
results.skipped.push(destPath)
|
|
238
|
-
continue
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (onDisk === content) {
|
|
242
|
-
results.skipped.push(destPath)
|
|
243
|
-
} else {
|
|
244
|
-
await writeFile(destPath, content)
|
|
245
|
-
results[existed ? 'copied' : 'created'].push(destPath)
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
206
|
// Now drop output with no source left.
|
|
250
207
|
for (const abs of beforeSweep.keys()) {
|
|
251
208
|
if (await reconcileCase(abs, visited)) continue
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { isAbsolute, join, relative, resolve } from 'node:path'
|
|
5
|
+
import { resolveSources, materialize, cliVersionOf, formatIssues, hasErrors } from './layers.js'
|
|
6
|
+
import { contentReport, tokensOf } from './lock.js'
|
|
7
|
+
import { CONFIG_SCHEMA_URL } from './team-config.js'
|
|
8
|
+
import { c } from './prompt.js'
|
|
9
|
+
import type { CliContext } from './types.js'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `opencastle baseline`: the organisation's standard as a package.
|
|
13
|
+
*
|
|
14
|
+
* A baseline is an ordinary npm package that says so in its package.json. Every
|
|
15
|
+
* repository adds it as a devDependency and names it in `extends`; the
|
|
16
|
+
* package manager does the fetching, the lockfile does the pinning, and an
|
|
17
|
+
* upgrade bot does the rollout — one pull request per repository, each with
|
|
18
|
+
* `opencastle review` explaining what it changes.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const HELP = `
|
|
22
|
+
opencastle baseline <init|check> [dir] [options]
|
|
23
|
+
|
|
24
|
+
init [dir] Scaffold a baseline package (default: ./opencastle-baseline):
|
|
25
|
+
a layer with example instructions, a skill and a policy,
|
|
26
|
+
a README on publishing and adopting it, and a CI check.
|
|
27
|
+
check [dir] Validate a baseline the way every repository extending it
|
|
28
|
+
will: its config, its content, its policy and its packaging.
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--name <pkg> Package name for init (default: @your-org/opencastle-baseline)
|
|
32
|
+
--json Machine-readable output for check
|
|
33
|
+
--help, -h Show this help
|
|
34
|
+
`
|
|
35
|
+
|
|
36
|
+
function files(name: string, cliVersion: string): Record<string, string> {
|
|
37
|
+
return {
|
|
38
|
+
'package.json':
|
|
39
|
+
JSON.stringify(
|
|
40
|
+
{
|
|
41
|
+
name,
|
|
42
|
+
version: '0.1.0',
|
|
43
|
+
description: "Our AI assistant standard, compiled by OpenCastle into every assistant in every repository that extends it.",
|
|
44
|
+
license: 'UNLICENSED',
|
|
45
|
+
files: ['layer/'],
|
|
46
|
+
opencastle: { baseline: 'layer' },
|
|
47
|
+
scripts: { check: 'opencastle baseline check' },
|
|
48
|
+
devDependencies: { opencastle: `^${cliVersion}` },
|
|
49
|
+
publishConfig: { access: 'restricted' },
|
|
50
|
+
},
|
|
51
|
+
null,
|
|
52
|
+
2,
|
|
53
|
+
) + '\n',
|
|
54
|
+
'layer/config.json': `{
|
|
55
|
+
"$schema": "${CONFIG_SCHEMA_URL}",
|
|
56
|
+
// Every repository that extends this baseline is held to this policy.
|
|
57
|
+
// A repository can tighten it in its own .opencastle/config.json, never relax it.
|
|
58
|
+
"policy": {
|
|
59
|
+
"mcp": {
|
|
60
|
+
// The MCP servers an assistant may start. Integration servers not listed here
|
|
61
|
+
// are left out of the generated config, and a hand-added one fails doctor and CI.
|
|
62
|
+
"allow": ["chrome-devtools", "Playwright", "Linear", "Sentry"],
|
|
63
|
+
// Remote servers may only connect to these hosts.
|
|
64
|
+
"remoteHosts": ["mcp.linear.app"],
|
|
65
|
+
// Every local server runs an exact version, so every laptop runs the same code.
|
|
66
|
+
"requirePinned": true
|
|
67
|
+
},
|
|
68
|
+
// Items no repository may exclude or replace.
|
|
69
|
+
"require": ["instructions/engineering-standards"],
|
|
70
|
+
// Tokens every assistant may load before it reads the task.
|
|
71
|
+
"contextBudget": 8000
|
|
72
|
+
},
|
|
73
|
+
// Servers every repository gets. Write variables as \${NAME}; OpenCastle
|
|
74
|
+
// spells them the way each assistant expects.
|
|
75
|
+
"mcpServers": {}
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
78
|
+
'layer/instructions/engineering-standards.md': `# Engineering standards
|
|
79
|
+
|
|
80
|
+
These apply to every repository in the organisation, and every assistant reads
|
|
81
|
+
them before every task. Keep this file short: detail belongs in a skill, which
|
|
82
|
+
loads only when a task needs it.
|
|
83
|
+
|
|
84
|
+
- Write tests for behaviour you change, and run them before you say you are done.
|
|
85
|
+
- Never write credentials into files; read them from the environment.
|
|
86
|
+
- Keep changes small and focused; one pull request, one purpose.
|
|
87
|
+
`,
|
|
88
|
+
'layer/skills/code-review/SKILL.md': `---
|
|
89
|
+
name: code-review
|
|
90
|
+
description: "How we review code: what to check, what to block on, and how to word feedback. Use when reviewing a pull request or preparing one for review."
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
# Code review
|
|
94
|
+
|
|
95
|
+
Block on: correctness, security, missing tests for changed behaviour, and
|
|
96
|
+
anything that makes the next change harder. Comment, do not block, on style
|
|
97
|
+
a formatter could fix.
|
|
98
|
+
|
|
99
|
+
Word feedback as a question or a suggestion with the reason attached.
|
|
100
|
+
`,
|
|
101
|
+
'README.md': `# ${name}
|
|
102
|
+
|
|
103
|
+
Our AI assistant standard, as an [OpenCastle](https://www.opencastle.dev) baseline.
|
|
104
|
+
Every repository that extends it gets the same instructions, skills and MCP
|
|
105
|
+
servers in every assistant its developers use — Claude Code, Cursor, Copilot,
|
|
106
|
+
OpenCode, Windsurf, Codex CLI and Antigravity — and is held to the same policy.
|
|
107
|
+
|
|
108
|
+
## What is in it
|
|
109
|
+
|
|
110
|
+
- \`layer/instructions/\` — loaded by every assistant before every task
|
|
111
|
+
- \`layer/skills/<name>/SKILL.md\` — loaded when a task matches its description
|
|
112
|
+
- \`layer/agents/*.agent.md\`, \`layer/prompts/\`, \`layer/workflows/\` — optional
|
|
113
|
+
- \`layer/config.json\` — MCP servers every repository gets, and the policy
|
|
114
|
+
(allowed servers and hosts, pinning, required items, context budget)
|
|
115
|
+
|
|
116
|
+
## Adopting it in a repository
|
|
117
|
+
|
|
118
|
+
\`\`\`sh
|
|
119
|
+
npm i -D ${name} opencastle
|
|
120
|
+
\`\`\`
|
|
121
|
+
|
|
122
|
+
\`\`\`jsonc
|
|
123
|
+
// .opencastle/config.json
|
|
124
|
+
{ "extends": ["${name}"] }
|
|
125
|
+
\`\`\`
|
|
126
|
+
|
|
127
|
+
\`\`\`sh
|
|
128
|
+
npx opencastle sync # compile it into every assistant
|
|
129
|
+
npx opencastle ci # fail pull requests on drift or policy breaks
|
|
130
|
+
\`\`\`
|
|
131
|
+
|
|
132
|
+
The version comes from package.json and the lockfile, like any dependency.
|
|
133
|
+
|
|
134
|
+
## Changing it
|
|
135
|
+
|
|
136
|
+
1. Edit \`layer/\`, then run \`npm run check\` — it validates the baseline the way
|
|
137
|
+
every repository extending it will.
|
|
138
|
+
2. Bump the version and publish.
|
|
139
|
+
3. Let your upgrade bot (Renovate, Dependabot) open the pull requests. In each,
|
|
140
|
+
CI runs \`opencastle sync --check\` and adds \`opencastle review\`'s summary of
|
|
141
|
+
what the new version changes for that repository's assistants.
|
|
142
|
+
`,
|
|
143
|
+
'.github/workflows/check.yml': `name: Check baseline
|
|
144
|
+
on: [pull_request, push]
|
|
145
|
+
permissions:
|
|
146
|
+
contents: read
|
|
147
|
+
jobs:
|
|
148
|
+
check:
|
|
149
|
+
runs-on: ubuntu-latest
|
|
150
|
+
steps:
|
|
151
|
+
- uses: actions/checkout@v4
|
|
152
|
+
- uses: actions/setup-node@v4
|
|
153
|
+
with:
|
|
154
|
+
node-version: 22
|
|
155
|
+
- run: npm install
|
|
156
|
+
- run: npx --no opencastle baseline check
|
|
157
|
+
`,
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function init(pkgRoot: string, dir: string, name: string): Promise<void> {
|
|
162
|
+
const root = resolve(dir)
|
|
163
|
+
if (existsSync(join(root, 'package.json'))) {
|
|
164
|
+
console.error(`\n ${c.red('✗')} ${dir} already has a package.json — pick an empty directory.\n`)
|
|
165
|
+
process.exit(1)
|
|
166
|
+
}
|
|
167
|
+
for (const [rel, text] of Object.entries(files(name, cliVersionOf(pkgRoot)))) {
|
|
168
|
+
const abs = join(root, rel)
|
|
169
|
+
await mkdir(resolve(abs, '..'), { recursive: true })
|
|
170
|
+
await writeFile(abs, text)
|
|
171
|
+
}
|
|
172
|
+
console.log(`\n ${c.green('✓')} Created the baseline ${c.bold(name)} in ${dir}/`)
|
|
173
|
+
console.log(` ${c.dim('Next: edit layer/, run')} ${c.cyan(`npx opencastle baseline check ${dir}`)}${c.dim(', then publish it.')}`)
|
|
174
|
+
console.log(` ${c.dim('Repositories adopt it with')} ${c.cyan(`npm i -D ${name}`)} ${c.dim('and')} ${c.cyan(`"extends": ["${name}"]`)}\n`)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface CheckReport {
|
|
178
|
+
baseline: string
|
|
179
|
+
version?: string
|
|
180
|
+
errors: string[]
|
|
181
|
+
warnings: string[]
|
|
182
|
+
contributes: { skills: number; agents: number; instructions: number; prompts: number; workflows: number; mcpServers: number }
|
|
183
|
+
contextTokens: number
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function check(pkgRoot: string, dir: string): CheckReport {
|
|
187
|
+
const root = resolve(dir)
|
|
188
|
+
const errors: string[] = []
|
|
189
|
+
const warnings: string[] = []
|
|
190
|
+
let layerRoot = root
|
|
191
|
+
let name = dir
|
|
192
|
+
let version: string | undefined
|
|
193
|
+
const pkgFile = join(root, 'package.json')
|
|
194
|
+
if (existsSync(pkgFile)) {
|
|
195
|
+
let pkg: { name?: string; version?: string; files?: string[]; opencastle?: { baseline?: string } } = {}
|
|
196
|
+
try {
|
|
197
|
+
pkg = JSON.parse(readFileSync(pkgFile, 'utf8'))
|
|
198
|
+
} catch (err) {
|
|
199
|
+
errors.push(`package.json: is not valid JSON — ${(err as Error).message}`)
|
|
200
|
+
}
|
|
201
|
+
name = pkg.name ?? name
|
|
202
|
+
version = pkg.version
|
|
203
|
+
if (typeof pkg.opencastle?.baseline !== 'string') {
|
|
204
|
+
errors.push('package.json: has no "opencastle": { "baseline": "<dir>" }, so no repository can extend it')
|
|
205
|
+
} else {
|
|
206
|
+
layerRoot = resolve(root, pkg.opencastle.baseline)
|
|
207
|
+
const rel = relative(root, layerRoot).split('\\').join('/')
|
|
208
|
+
// Consumers refuse a layer outside the package, so this must too — or
|
|
209
|
+
// it would pass here and fail in every repository that extends it.
|
|
210
|
+
if (rel.startsWith('..') || isAbsolute(rel)) {
|
|
211
|
+
errors.push(`package.json: "opencastle.baseline" points outside the package (${pkg.opencastle.baseline}), which no repository extending it will accept`)
|
|
212
|
+
}
|
|
213
|
+
// `files` decides what `npm publish` ships. A baseline whose layer is not
|
|
214
|
+
// in it publishes as an empty package, and every repository extending it
|
|
215
|
+
// compiles nothing from it — with no error anywhere.
|
|
216
|
+
if (pkg.files && rel !== '' && !pkg.files.some((f) => f.replace(/\/$/, '') === rel || rel.startsWith(f.replace(/\/$/, '') + '/'))) {
|
|
217
|
+
errors.push(`package.json: "files" does not include ${rel}/, so npm publish would ship a baseline with nothing in it`)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (!existsSync(layerRoot)) errors.push(`${relative(process.cwd(), layerRoot) || '.'}: the layer directory does not exist`)
|
|
222
|
+
|
|
223
|
+
const contributes = { skills: 0, agents: 0, instructions: 0, prompts: 0, workflows: 0, mcpServers: 0 }
|
|
224
|
+
let contextTokens = 0
|
|
225
|
+
if (errors.length === 0) {
|
|
226
|
+
// Resolved exactly as a repository extending it would resolve it.
|
|
227
|
+
const project = mkdtempSync(join(tmpdir(), 'opencastle-baseline-check-'))
|
|
228
|
+
try {
|
|
229
|
+
mkdirSync(join(project, '.opencastle'), { recursive: true })
|
|
230
|
+
const spec = relative(join(project, '.opencastle'), layerRoot).split('\\').join('/')
|
|
231
|
+
writeFileSync(join(project, '.opencastle', 'config.json'), JSON.stringify({ extends: [spec.startsWith('.') ? spec : `./${spec}`] }))
|
|
232
|
+
const resolved = resolveSources({ pkgRoot, projectRoot: project, stack: { ides: [], techTools: [], teamTools: [] } })
|
|
233
|
+
const shown = (text: string): string => text.split(project).join('<repository>').replace(/(\.\.\/)+/g, '')
|
|
234
|
+
for (const line of formatIssues(resolved.issues.filter((i) => i.level === 'error'))) errors.push(shown(line))
|
|
235
|
+
for (const line of formatIssues(resolved.issues.filter((i) => i.level === 'warning'))) warnings.push(shown(line))
|
|
236
|
+
for (const item of resolved.items.values()) {
|
|
237
|
+
if (item.layer !== 'opencastle') contributes[item.kind]++
|
|
238
|
+
}
|
|
239
|
+
contributes.mcpServers = resolved.servers.size
|
|
240
|
+
if (!hasErrors(resolved)) {
|
|
241
|
+
const source = materialize(resolved, pkgRoot)
|
|
242
|
+
try {
|
|
243
|
+
const r = contentReport(source)
|
|
244
|
+
contextTokens = tokensOf(r.instructionChars + r.indexChars)
|
|
245
|
+
} finally {
|
|
246
|
+
source.dispose()
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} finally {
|
|
250
|
+
rmSync(project, { recursive: true, force: true })
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return { baseline: name, version, errors, warnings, contributes, contextTokens }
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export default async function baseline({ pkgRoot, args }: CliContext): Promise<void> {
|
|
257
|
+
const [sub, ...rest] = args
|
|
258
|
+
if (!sub || args.includes('--help') || args.includes('-h') || !['init', 'check'].includes(sub)) {
|
|
259
|
+
console.log(HELP)
|
|
260
|
+
if (sub && !['init', 'check', '--help', '-h'].includes(sub)) process.exit(1)
|
|
261
|
+
return
|
|
262
|
+
}
|
|
263
|
+
const nameAt = rest.indexOf('--name')
|
|
264
|
+
if (nameAt !== -1 && (!rest[nameAt + 1] || rest[nameAt + 1].startsWith('--'))) {
|
|
265
|
+
console.error(` ${c.red('✗')} --name needs a package name, e.g. --name @acme/opencastle-baseline`)
|
|
266
|
+
process.exit(1)
|
|
267
|
+
}
|
|
268
|
+
const positional = rest.filter((a, i) => !a.startsWith('--') && !(nameAt !== -1 && i === nameAt + 1))
|
|
269
|
+
|
|
270
|
+
if (sub === 'init') {
|
|
271
|
+
await init(pkgRoot, positional[0] ?? 'opencastle-baseline', nameAt !== -1 ? rest[nameAt + 1] : '@your-org/opencastle-baseline')
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const report = check(pkgRoot, positional[0] ?? '.')
|
|
276
|
+
if (rest.includes('--json')) {
|
|
277
|
+
console.log(JSON.stringify(report, null, 2))
|
|
278
|
+
} else {
|
|
279
|
+
console.log(`\n 🏰 ${c.bold('Baseline')} ${report.baseline}${report.version ? c.dim(` ${report.version}`) : ''}\n`)
|
|
280
|
+
const k = report.contributes
|
|
281
|
+
const parts = Object.entries(k).filter(([, n]) => n > 0).map(([kind, n]) => `${n} ${kind === 'mcpServers' ? 'MCP server(s)' : kind}`)
|
|
282
|
+
console.log(` Contributes: ${parts.length > 0 ? parts.join(', ') : c.dim('nothing yet')}`)
|
|
283
|
+
if (report.contextTokens) console.log(` A repository extending it loads ~${report.contextTokens} tokens up front, with OpenCastle's own content`)
|
|
284
|
+
for (const e of report.errors) console.log(` ${c.red('✗')} ${e}`)
|
|
285
|
+
for (const w of report.warnings) console.log(` ${c.yellow('!')} ${c.dim(w)}`)
|
|
286
|
+
console.log(report.errors.length === 0 ? `\n ${c.green('✓')} Ready to publish.\n` : `\n ${c.red(`${report.errors.length} problem(s) to fix before publishing.`)}\n`)
|
|
287
|
+
}
|
|
288
|
+
if (report.errors.length > 0) process.exit(1)
|
|
289
|
+
}
|
package/src/cli/bootstrap.ts
CHANGED
|
@@ -413,7 +413,7 @@ async function removeDataPipelineConfig(
|
|
|
413
413
|
result.removed.push('stack/data-pipeline-config.md')
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
const TRACKER_TOOLS = new Set<string>(['linear', 'jira', 'trello'])
|
|
416
|
+
export const TRACKER_TOOLS = new Set<string>(['linear', 'jira', 'trello'])
|
|
417
417
|
|
|
418
418
|
async function handleTrackerConfig(
|
|
419
419
|
opencastleDir: string,
|