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
package/src/cli/baseline.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { isAbsolute, join, relative, resolve } from 'node:path'
|
|
|
5
5
|
import { resolveSources, materialize, cliVersionOf, formatIssues, hasErrors } from './layers.js'
|
|
6
6
|
import { contentReport, tokensOf } from './lock.js'
|
|
7
7
|
import { CONFIG_SCHEMA_URL } from './team-config.js'
|
|
8
|
+
import { EXTENSION_NAMESPACE, claudeManifestFor, isAgentPlugin, mcpSchemaUrl, pluginNameFrom, pluginSchemaUrl, readAgentPlugin, type PluginManifest } from './agent-plugin.js'
|
|
9
|
+
import { staleClaudeFiles } from './plugin.js'
|
|
8
10
|
import { c } from './prompt.js'
|
|
9
11
|
import type { CliContext } from './types.js'
|
|
10
12
|
|
|
@@ -16,16 +18,24 @@ import type { CliContext } from './types.js'
|
|
|
16
18
|
* package manager does the fetching, the lockfile does the pinning, and an
|
|
17
19
|
* upgrade bot does the rollout — one pull request per repository, each with
|
|
18
20
|
* `opencastle review` explaining what it changes.
|
|
21
|
+
*
|
|
22
|
+
* A baseline `init` creates is also an Agent Plugin: `plugin.json`, skills in
|
|
23
|
+
* `skills/`, portable servers in `mcp.json`, and the rest of OpenCastle's layer
|
|
24
|
+
* — instructions, agents, prompts, workflows, policy — in `dev.opencastle/`.
|
|
25
|
+
* Assistants that read Agent Plugins can install it as it is; OpenCastle
|
|
26
|
+
* compiles all of it into every assistant for every repository that extends it.
|
|
19
27
|
*/
|
|
20
28
|
|
|
21
29
|
const HELP = `
|
|
22
30
|
opencastle baseline <init|check> [dir] [options]
|
|
23
31
|
|
|
24
|
-
init [dir] Scaffold a baseline package (default: ./opencastle-baseline)
|
|
25
|
-
|
|
26
|
-
a README on publishing and adopting it, and a
|
|
32
|
+
init [dir] Scaffold a baseline package (default: ./opencastle-baseline)
|
|
33
|
+
that is also an Agent Plugin: example instructions, a skill
|
|
34
|
+
and a policy, a README on publishing and adopting it, and a
|
|
35
|
+
CI check.
|
|
27
36
|
check [dir] Validate a baseline the way every repository extending it
|
|
28
|
-
will
|
|
37
|
+
will — its config, its content, its policy and its packaging —
|
|
38
|
+
and, when it is an Agent Plugin, the way assistants load it.
|
|
29
39
|
|
|
30
40
|
Options:
|
|
31
41
|
--name <pkg> Package name for init (default: @your-org/opencastle-baseline)
|
|
@@ -34,24 +44,35 @@ const HELP = `
|
|
|
34
44
|
`
|
|
35
45
|
|
|
36
46
|
function files(name: string, cliVersion: string): Record<string, string> {
|
|
47
|
+
const description = 'Our AI assistant standard: compiled by OpenCastle into every assistant in every repository that extends it, and an Agent Plugin any assistant that reads them can install.'
|
|
48
|
+
const manifest: PluginManifest = {
|
|
49
|
+
$schema: pluginSchemaUrl(),
|
|
50
|
+
name: pluginNameFrom(name),
|
|
51
|
+
version: '0.1.0',
|
|
52
|
+
description,
|
|
53
|
+
license: 'UNLICENSED',
|
|
54
|
+
}
|
|
37
55
|
return {
|
|
38
56
|
'package.json':
|
|
39
57
|
JSON.stringify(
|
|
40
58
|
{
|
|
41
59
|
name,
|
|
42
60
|
version: '0.1.0',
|
|
43
|
-
description
|
|
61
|
+
description,
|
|
44
62
|
license: 'UNLICENSED',
|
|
45
|
-
files: ['
|
|
46
|
-
opencastle: { baseline: '
|
|
47
|
-
scripts: { check: 'opencastle baseline check' },
|
|
63
|
+
files: ['plugin.json', 'mcp.json', 'skills/', `${EXTENSION_NAMESPACE}/`, '.claude-plugin/', '.mcp.json'],
|
|
64
|
+
opencastle: { baseline: '.' },
|
|
65
|
+
scripts: { check: 'opencastle baseline check', build: 'opencastle plugin build' },
|
|
48
66
|
devDependencies: { opencastle: `^${cliVersion}` },
|
|
49
67
|
publishConfig: { access: 'restricted' },
|
|
50
68
|
},
|
|
51
69
|
null,
|
|
52
70
|
2,
|
|
53
71
|
) + '\n',
|
|
54
|
-
'
|
|
72
|
+
'plugin.json': JSON.stringify(manifest, null, 2) + '\n',
|
|
73
|
+
'mcp.json': JSON.stringify({ $schema: mcpSchemaUrl(), mcpServers: {} }, null, 2) + '\n',
|
|
74
|
+
'.claude-plugin/plugin.json': JSON.stringify(claudeManifestFor(manifest), null, 2) + '\n',
|
|
75
|
+
[`${EXTENSION_NAMESPACE}/config.json`]: `{
|
|
55
76
|
"$schema": "${CONFIG_SCHEMA_URL}",
|
|
56
77
|
// Every repository that extends this baseline is held to this policy.
|
|
57
78
|
// A repository can tighten it in its own .opencastle/config.json, never relax it.
|
|
@@ -70,12 +91,14 @@ function files(name: string, cliVersion: string): Record<string, string> {
|
|
|
70
91
|
// Tokens every assistant may load before it reads the task.
|
|
71
92
|
"contextBudget": 8000
|
|
72
93
|
},
|
|
73
|
-
// Servers
|
|
74
|
-
// spells
|
|
94
|
+
// Servers that need a variable — a token, a tenant — go here: write it as
|
|
95
|
+
// \${NAME} and OpenCastle spells it the way each assistant expects. A server
|
|
96
|
+
// every assistant can start as it is goes in ../mcp.json, where assistants
|
|
97
|
+
// that install this as an Agent Plugin find it too.
|
|
75
98
|
"mcpServers": {}
|
|
76
99
|
}
|
|
77
100
|
`,
|
|
78
|
-
|
|
101
|
+
[`${EXTENSION_NAMESPACE}/instructions/engineering-standards.md`]: `# Engineering standards
|
|
79
102
|
|
|
80
103
|
These apply to every repository in the organisation, and every assistant reads
|
|
81
104
|
them before every task. Keep this file short: detail belongs in a skill, which
|
|
@@ -85,7 +108,7 @@ loads only when a task needs it.
|
|
|
85
108
|
- Never write credentials into files; read them from the environment.
|
|
86
109
|
- Keep changes small and focused; one pull request, one purpose.
|
|
87
110
|
`,
|
|
88
|
-
'
|
|
111
|
+
'skills/code-review/SKILL.md': `---
|
|
89
112
|
name: code-review
|
|
90
113
|
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
114
|
---
|
|
@@ -100,18 +123,27 @@ Word feedback as a question or a suggestion with the reason attached.
|
|
|
100
123
|
`,
|
|
101
124
|
'README.md': `# ${name}
|
|
102
125
|
|
|
103
|
-
Our AI assistant standard
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
126
|
+
Our AI assistant standard. It is two things at once:
|
|
127
|
+
|
|
128
|
+
- an [OpenCastle](https://www.opencastle.dev) baseline — every repository that
|
|
129
|
+
extends it gets the same instructions, skills and MCP servers in every
|
|
130
|
+
assistant its developers use (Claude Code, Cursor, Copilot, OpenCode,
|
|
131
|
+
Windsurf, Codex CLI, Antigravity) and is held to the same policy;
|
|
132
|
+
- an [Agent Plugin](https://agent-plugins.org) — GitHub Copilot, VS Code,
|
|
133
|
+
Cursor, Codex and Kiro can install its skills and MCP servers as they are,
|
|
134
|
+
and Claude Code through \`.claude-plugin/\`.
|
|
107
135
|
|
|
108
136
|
## What is in it
|
|
109
137
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
138
|
+
| Path | What it is | Read by |
|
|
139
|
+
| --- | --- | --- |
|
|
140
|
+
| \`plugin.json\` | The Agent Plugins manifest | Every assistant that reads Agent Plugins |
|
|
141
|
+
| \`skills/<name>/SKILL.md\` | Agent Skills, loaded when a task matches | Every assistant |
|
|
142
|
+
| \`mcp.json\` | MCP servers every assistant can start as they are | Every assistant |
|
|
143
|
+
| \`${EXTENSION_NAMESPACE}/instructions/\` | Loaded by every assistant before every task | OpenCastle |
|
|
144
|
+
| \`${EXTENSION_NAMESPACE}/agents/\`, \`prompts/\`, \`workflows/\` | Optional | OpenCastle |
|
|
145
|
+
| \`${EXTENSION_NAMESPACE}/config.json\` | Servers that need variables, and the policy | OpenCastle |
|
|
146
|
+
| \`.claude-plugin/plugin.json\`, \`.mcp.json\` | Claude Code's copies — \`npm run build\` writes them | Claude Code |
|
|
115
147
|
|
|
116
148
|
## Adopting it in a repository
|
|
117
149
|
|
|
@@ -133,9 +165,10 @@ The version comes from package.json and the lockfile, like any dependency.
|
|
|
133
165
|
|
|
134
166
|
## Changing it
|
|
135
167
|
|
|
136
|
-
1. Edit
|
|
137
|
-
|
|
138
|
-
|
|
168
|
+
1. Edit it, then run \`npm run build\` (Claude Code's copies) and
|
|
169
|
+
\`npm run check\` — it validates the baseline the way every repository
|
|
170
|
+
extending it will, and the plugin the way assistants load it.
|
|
171
|
+
2. Bump the version in package.json and plugin.json, and publish.
|
|
139
172
|
3. Let your upgrade bot (Renovate, Dependabot) open the pull requests. In each,
|
|
140
173
|
CI runs \`opencastle sync --check\` and adds \`opencastle review\`'s summary of
|
|
141
174
|
what the new version changes for that repository's assistants.
|
|
@@ -170,7 +203,8 @@ async function init(pkgRoot: string, dir: string, name: string): Promise<void> {
|
|
|
170
203
|
await writeFile(abs, text)
|
|
171
204
|
}
|
|
172
205
|
console.log(`\n ${c.green('✓')} Created the baseline ${c.bold(name)} in ${dir}/`)
|
|
173
|
-
console.log(` ${c.dim('
|
|
206
|
+
console.log(` ${c.dim('It is an Agent Plugin too: skills/ and mcp.json are portable; the rest of the layer is in')} ${EXTENSION_NAMESPACE}/`)
|
|
207
|
+
console.log(` ${c.dim('Next: edit it, run')} ${c.cyan(`npx opencastle baseline check ${dir}`)}${c.dim(', then publish it.')}`)
|
|
174
208
|
console.log(` ${c.dim('Repositories adopt it with')} ${c.cyan(`npm i -D ${name}`)} ${c.dim('and')} ${c.cyan(`"extends": ["${name}"]`)}\n`)
|
|
175
209
|
}
|
|
176
210
|
|
|
@@ -190,6 +224,7 @@ function check(pkgRoot: string, dir: string): CheckReport {
|
|
|
190
224
|
let layerRoot = root
|
|
191
225
|
let name = dir
|
|
192
226
|
let version: string | undefined
|
|
227
|
+
let published: string[] | undefined
|
|
193
228
|
const pkgFile = join(root, 'package.json')
|
|
194
229
|
if (existsSync(pkgFile)) {
|
|
195
230
|
let pkg: { name?: string; version?: string; files?: string[]; opencastle?: { baseline?: string } } = {}
|
|
@@ -200,6 +235,7 @@ function check(pkgRoot: string, dir: string): CheckReport {
|
|
|
200
235
|
}
|
|
201
236
|
name = pkg.name ?? name
|
|
202
237
|
version = pkg.version
|
|
238
|
+
published = pkg.files
|
|
203
239
|
if (typeof pkg.opencastle?.baseline !== 'string') {
|
|
204
240
|
errors.push('package.json: has no "opencastle": { "baseline": "<dir>" }, so no repository can extend it')
|
|
205
241
|
} else {
|
|
@@ -220,6 +256,43 @@ function check(pkgRoot: string, dir: string): CheckReport {
|
|
|
220
256
|
}
|
|
221
257
|
if (!existsSync(layerRoot)) errors.push(`${relative(process.cwd(), layerRoot) || '.'}: the layer directory does not exist`)
|
|
222
258
|
|
|
259
|
+
// The plugin side: what an assistant that installs it as an Agent Plugin sees.
|
|
260
|
+
if (errors.length === 0 && isAgentPlugin(layerRoot)) {
|
|
261
|
+
const report = readAgentPlugin(layerRoot)
|
|
262
|
+
errors.push(...report.errors)
|
|
263
|
+
warnings.push(...report.warnings)
|
|
264
|
+
if (report.manifest) {
|
|
265
|
+
for (const f of staleClaudeFiles(layerRoot, report)) {
|
|
266
|
+
errors.push(`${f}: does not match plugin.json and mcp.json — run opencastle plugin build`)
|
|
267
|
+
}
|
|
268
|
+
if (!existsSync(join(layerRoot, '.claude-plugin', 'plugin.json'))) {
|
|
269
|
+
warnings.push('.claude-plugin/plugin.json: missing — Claude Code reads only its own manifest; run opencastle plugin build')
|
|
270
|
+
}
|
|
271
|
+
if (version && report.manifest.version && version !== report.manifest.version) {
|
|
272
|
+
warnings.push(`plugin.json: version ${report.manifest.version}, while package.json says ${version} — assistants offer updates by plugin.json's`)
|
|
273
|
+
}
|
|
274
|
+
// `files` decides what npm publishes; a plugin missing its manifest or
|
|
275
|
+
// its skills installs as nothing.
|
|
276
|
+
if (published) {
|
|
277
|
+
const at = relative(root, layerRoot).split('\\').join('/')
|
|
278
|
+
for (const part of ['plugin.json', 'skills', 'mcp.json', EXTENSION_NAMESPACE, '.claude-plugin', '.mcp.json']) {
|
|
279
|
+
if (!existsSync(join(layerRoot, part))) continue
|
|
280
|
+
const path = at ? `${at}/${part}` : part
|
|
281
|
+
const shipped = published.some((f) => {
|
|
282
|
+
const entry = f.replace(/\/$/, '')
|
|
283
|
+
return entry === path || path.startsWith(`${entry}/`)
|
|
284
|
+
})
|
|
285
|
+
if (!shipped) errors.push(`package.json: "files" does not include ${path}, so npm publish would leave it out`)
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
} else if (errors.length === 0) {
|
|
290
|
+
warnings.push(
|
|
291
|
+
'is not an Agent Plugin, so only OpenCastle can use it — assistants that read Agent Plugins cannot install it. ' +
|
|
292
|
+
'`opencastle baseline init` shows the layout: skills/ and mcp.json at the root, the rest in dev.opencastle/',
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
|
|
223
296
|
const contributes = { skills: 0, agents: 0, instructions: 0, prompts: 0, workflows: 0, mcpServers: 0 }
|
|
224
297
|
let contextTokens = 0
|
|
225
298
|
if (errors.length === 0) {
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex CLI, driven through the built CLI the way a project meets it.
|
|
3
|
+
*
|
|
4
|
+
* Codex reads a repository's skills only from `.agents/skills/` and its MCP
|
|
5
|
+
* servers only from `.codex/config.toml`. Every release up to 1.0.0 wrote
|
|
6
|
+
* `.codex/skills/` and `.codex/mcp.json` instead, so a Codex user got the root
|
|
7
|
+
* AGENTS.md and nothing else — and every check reported the install healthy,
|
|
8
|
+
* because each compared the project against the same wrong paths.
|
|
9
|
+
*/
|
|
10
|
+
import { execFileSync } from 'node:child_process'
|
|
11
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
12
|
+
import { tmpdir } from 'node:os'
|
|
13
|
+
import { dirname, join, resolve } from 'node:path'
|
|
14
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
15
|
+
import { parse as parseToml } from 'smol-toml'
|
|
16
|
+
import type { Manifest } from './types.js'
|
|
17
|
+
import { teamEntryFor } from './mcp.js'
|
|
18
|
+
|
|
19
|
+
const pkgRoot = resolve(import.meta.dirname, '..', '..')
|
|
20
|
+
const cli = join(pkgRoot, 'bin', 'cli.mjs')
|
|
21
|
+
const built = existsSync(join(pkgRoot, 'dist', 'cli', 'init.js'))
|
|
22
|
+
|
|
23
|
+
const USERS_CONFIG = `# Codex settings, written by hand
|
|
24
|
+
model = "gpt-5-codex"
|
|
25
|
+
approval_policy = "on-request"
|
|
26
|
+
|
|
27
|
+
[mcp_servers.mine]
|
|
28
|
+
command = "my-own-server"
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
function write(root: string, files: Record<string, string>): void {
|
|
32
|
+
for (const [rel, text] of Object.entries(files)) {
|
|
33
|
+
mkdirSync(dirname(join(root, rel)), { recursive: true })
|
|
34
|
+
writeFileSync(join(root, rel), text)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function run(project: string, ...args: string[]): string {
|
|
39
|
+
return execFileSync('node', [cli, ...args], { cwd: project, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function servers(project: string): Record<string, Record<string, unknown>> {
|
|
43
|
+
const text = readFileSync(join(project, '.codex/config.toml'), 'utf8')
|
|
44
|
+
return ((parseToml(text) as { mcp_servers?: Record<string, Record<string, unknown>> }).mcp_servers ?? {})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe("a team server in Codex's own fields", () => {
|
|
48
|
+
it('sends a bearer token, and a header that is one variable, from the environment', () => {
|
|
49
|
+
const { entry } = teamEntryFor(
|
|
50
|
+
'acme-docs',
|
|
51
|
+
{
|
|
52
|
+
type: 'http',
|
|
53
|
+
url: 'https://docs.acme.example/mcp',
|
|
54
|
+
headers: { Authorization: 'Bearer ${ACME_DOCS_TOKEN}', 'X-Tenant': '${ACME_TENANT}', 'X-Client': 'opencastle' },
|
|
55
|
+
},
|
|
56
|
+
'codex',
|
|
57
|
+
)
|
|
58
|
+
expect(entry).toEqual({
|
|
59
|
+
url: 'https://docs.acme.example/mcp',
|
|
60
|
+
bearer_token_env_var: 'ACME_DOCS_TOKEN',
|
|
61
|
+
env_http_headers: { 'X-Tenant': 'ACME_TENANT' },
|
|
62
|
+
http_headers: { 'X-Client': 'opencastle' },
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('forwards a variable the server reads under its own name, and keeps literal values', () => {
|
|
67
|
+
const { entry } = teamEntryFor(
|
|
68
|
+
'acme-flags',
|
|
69
|
+
{ command: 'npx', args: ['-y', '@acme/flags-mcp@1.2.3'], env: { FLAGS_TOKEN: '${FLAGS_TOKEN}', MODE: 'ci' } },
|
|
70
|
+
'codex',
|
|
71
|
+
)
|
|
72
|
+
expect(entry).toEqual({
|
|
73
|
+
command: 'npx',
|
|
74
|
+
args: ['-y', '@acme/flags-mcp@1.2.3'],
|
|
75
|
+
env: { MODE: 'ci' },
|
|
76
|
+
env_vars: ['FLAGS_TOKEN'],
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('leaves a reference it cannot express as written, for doctor to name', () => {
|
|
81
|
+
const { entry } = teamEntryFor('x', { command: 'srv', env: { API_KEY: '${OTHER_NAME}' } }, 'codex')
|
|
82
|
+
expect(entry).toEqual({ command: 'srv', env: { API_KEY: '${OTHER_NAME}' } })
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
describe.skipIf(!built)('Codex CLI as a target', () => {
|
|
87
|
+
let project: string
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
project = mkdtempSync(join(tmpdir(), 'oc-codex-target-'))
|
|
90
|
+
execFileSync('git', ['init', '-q'], { cwd: project })
|
|
91
|
+
// A project that uses Supabase, so the stack carries a remote server, and
|
|
92
|
+
// a Codex setup of the user's own that every write must leave alone.
|
|
93
|
+
write(project, {
|
|
94
|
+
'package.json': JSON.stringify({ name: 'app', dependencies: { '@supabase/supabase-js': '^2.0.0' } }),
|
|
95
|
+
'.codex/config.toml': USERS_CONFIG,
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
afterEach(() => rmSync(project, { recursive: true, force: true }))
|
|
99
|
+
|
|
100
|
+
it('installs skills and servers where Codex reads them, after the user’s own settings', () => {
|
|
101
|
+
run(project, 'init', '--yes')
|
|
102
|
+
expect(existsSync(join(project, '.agents/skills/testing-workflow/SKILL.md'))).toBe(true)
|
|
103
|
+
expect(existsSync(join(project, '.codex/skills'))).toBe(false)
|
|
104
|
+
expect(existsSync(join(project, '.codex/mcp.json'))).toBe(false)
|
|
105
|
+
const text = readFileSync(join(project, '.codex/config.toml'), 'utf8')
|
|
106
|
+
expect(text.startsWith(USERS_CONFIG)).toBe(true)
|
|
107
|
+
expect(servers(project).Supabase).toEqual({ url: 'https://mcp.supabase.com/mcp' })
|
|
108
|
+
expect(servers(project).mine).toEqual({ command: 'my-own-server' })
|
|
109
|
+
run(project, 'sync', '--check')
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('the sync that upgrades a 1.0.0 install moves skills and servers, and keeps what is the user’s', () => {
|
|
113
|
+
run(project, 'init', '--yes')
|
|
114
|
+
// Back to how 1.0.0 left it: skills under `.codex/skills/`, servers in a
|
|
115
|
+
// `.codex/mcp.json` it created, and a manifest that recorded both.
|
|
116
|
+
rmSync(join(project, '.agents'), { recursive: true, force: true })
|
|
117
|
+
write(project, {
|
|
118
|
+
'.codex/config.toml': USERS_CONFIG,
|
|
119
|
+
'.codex/skills/testing-workflow/SKILL.md': '---\nname: testing-workflow\ndescription: old\n---\nold\n',
|
|
120
|
+
'.codex/mcp.json': JSON.stringify({ mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' } } }, null, 2) + '\n',
|
|
121
|
+
})
|
|
122
|
+
const path = join(project, '.opencastle/manifest.json')
|
|
123
|
+
const manifest = JSON.parse(readFileSync(path, 'utf8')) as Manifest
|
|
124
|
+
manifest.version = '1.0.0'
|
|
125
|
+
manifest.createdConfigs = ['.codex/mcp.json']
|
|
126
|
+
manifest.managedPaths = {
|
|
127
|
+
framework: ['.codex/agents/', '.codex/skills/', '.codex/prompts/', '.codex/workflows/'],
|
|
128
|
+
customizable: ['.opencastle/', '.codex/mcp.json'],
|
|
129
|
+
merged: ['AGENTS.md'],
|
|
130
|
+
}
|
|
131
|
+
writeFileSync(path, JSON.stringify(manifest, null, 2))
|
|
132
|
+
|
|
133
|
+
const out = run(project, 'sync', '--yes')
|
|
134
|
+
expect(out).toContain('Removed .codex/mcp.json')
|
|
135
|
+
expect(existsSync(join(project, '.codex/skills'))).toBe(false)
|
|
136
|
+
expect(existsSync(join(project, '.codex/mcp.json'))).toBe(false)
|
|
137
|
+
expect(readFileSync(join(project, '.agents/skills/testing-workflow/SKILL.md'), 'utf8')).not.toContain('description: old')
|
|
138
|
+
expect(readFileSync(join(project, '.codex/config.toml'), 'utf8').startsWith(USERS_CONFIG)).toBe(true)
|
|
139
|
+
expect(servers(project).Supabase).toBeDefined()
|
|
140
|
+
|
|
141
|
+
const after = JSON.parse(readFileSync(path, 'utf8')) as Manifest
|
|
142
|
+
expect(after.createdConfigs ?? []).not.toContain('.codex/mcp.json')
|
|
143
|
+
expect(after.managedPaths?.framework).toContain('.agents/skills/')
|
|
144
|
+
expect(after.managedPaths?.framework).not.toContain('.codex/skills/')
|
|
145
|
+
run(project, 'sync', '--check')
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
it('keeps servers a person added to the old .codex/mcp.json, and says where they belong', () => {
|
|
149
|
+
run(project, 'init', '--yes')
|
|
150
|
+
write(project, {
|
|
151
|
+
'.codex/mcp.json': JSON.stringify({ mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' }, theirs: { command: 'x' } } }),
|
|
152
|
+
})
|
|
153
|
+
const out = run(project, 'sync', '--yes', '--force')
|
|
154
|
+
expect(out).toContain("Took OpenCastle's servers out of .codex/mcp.json")
|
|
155
|
+
expect(out).toContain('.codex/config.toml')
|
|
156
|
+
const left = JSON.parse(readFileSync(join(project, '.codex/mcp.json'), 'utf8')) as { mcpServers: object }
|
|
157
|
+
expect(Object.keys(left.mcpServers)).toEqual(['theirs'])
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it('shares .agents/skills/ with Antigravity without either sweep removing the other’s files', () => {
|
|
161
|
+
write(project, { 'GEMINI.md': '# Gemini\n' })
|
|
162
|
+
run(project, 'init', '--yes')
|
|
163
|
+
const manifest = JSON.parse(readFileSync(join(project, '.opencastle/manifest.json'), 'utf8')) as Manifest
|
|
164
|
+
expect(manifest.ides).toEqual(expect.arrayContaining(['codex', 'antigravity']))
|
|
165
|
+
const skills = readdirSync(join(project, '.agents/skills')).sort()
|
|
166
|
+
expect(skills).toContain('testing-workflow')
|
|
167
|
+
run(project, 'sync', '--yes', '--force')
|
|
168
|
+
expect(readdirSync(join(project, '.agents/skills')).sort()).toEqual(skills)
|
|
169
|
+
run(project, 'sync', '--check')
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it('remove --all takes our servers out of config.toml and leaves the user’s setup', () => {
|
|
173
|
+
run(project, 'init', '--yes')
|
|
174
|
+
run(project, 'remove', '--all', '--yes')
|
|
175
|
+
expect(readFileSync(join(project, '.codex/config.toml'), 'utf8')).toBe(USERS_CONFIG)
|
|
176
|
+
expect(existsSync(join(project, '.agents/skills'))).toBe(false)
|
|
177
|
+
})
|
|
178
|
+
})
|
package/src/cli/convoy/gates.ts
CHANGED
|
@@ -3,150 +3,17 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
|
3
3
|
import { readFile } from 'node:fs/promises'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
import { inflateSync } from 'node:zlib'
|
|
6
|
-
import { parse as yamlParse } from 'yaml'
|
|
7
6
|
import { filePathFields } from './contracts.js'
|
|
8
7
|
import type { BrowserTestConfig, MCPServerConfig } from './types.js'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{ name: 'AWS Access Key', pattern: /AKIA[0-9A-Z]{16}/i },
|
|
19
|
-
{
|
|
20
|
-
name: 'AWS Secret Key',
|
|
21
|
-
// eslint-disable-next-line no-useless-escape
|
|
22
|
-
pattern: /(?:aws_secret_access_key|secret_key)\s*[=:]\s*[A-Za-z0-9\/+=]{40}/i,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'Generic API Key',
|
|
26
|
-
pattern: /(?:api[_-]?key|apikey)\s*[=:]\s*['"]?[A-Za-z0-9_-]{20,}/i,
|
|
27
|
-
},
|
|
28
|
-
{ name: 'Bearer Token', pattern: /[Bb]earer\s+[A-Za-z0-9\-._~+/]+=*/ },
|
|
29
|
-
{ name: 'Private Key', pattern: /-----BEGIN (?:RSA|EC|OPENSSH) PRIVATE KEY-----/ },
|
|
30
|
-
{
|
|
31
|
-
name: 'Connection String',
|
|
32
|
-
// eslint-disable-next-line no-useless-escape
|
|
33
|
-
pattern: /(?:postgres|mysql|mongodb|redis):\/\/[^\s]+:[^\s]+@/,
|
|
34
|
-
},
|
|
35
|
-
{ name: 'GitHub Token', pattern: /(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{36,}/ },
|
|
36
|
-
{
|
|
37
|
-
name: 'Generic Password',
|
|
38
|
-
pattern: /(?:password|passwd|pwd)\s*[=:]\s*['"]?[^\s'"]{8,}/i,
|
|
39
|
-
},
|
|
40
|
-
{ name: 'Slack Token', pattern: /xox[bprs]-[A-Za-z0-9-]{10,}/i },
|
|
41
|
-
{
|
|
42
|
-
name: 'Generic Secret',
|
|
43
|
-
pattern: /(?:secret|token|credential)\s*[=:]\s*['"]?[A-Za-z0-9_-]{16,}/i,
|
|
44
|
-
},
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
// ── Public types ──────────────────────────────────────────────────────────────
|
|
48
|
-
|
|
49
|
-
export interface SecretScanResult {
|
|
50
|
-
clean: boolean
|
|
51
|
-
findings: Array<{ pattern: string; file: string; line: number; snippet: string }>
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ── Allowlist ─────────────────────────────────────────────────────────────────
|
|
55
|
-
|
|
56
|
-
interface AllowlistEntry {
|
|
57
|
-
pattern?: string
|
|
58
|
-
literal?: string
|
|
59
|
-
reason: string
|
|
60
|
-
paths?: string[]
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let _allowlist: AllowlistEntry[] | null = null
|
|
64
|
-
|
|
65
|
-
/** The config path used for the allowlist. Override for testing. */
|
|
66
|
-
export let _allowlistConfigPath = join(process.cwd(), '.opencastle', 'secret-scan-config.yml')
|
|
67
|
-
|
|
68
|
-
/** Reset the allowlist cache (for testing). */
|
|
69
|
-
export function _resetAllowlistCache(): void {
|
|
70
|
-
_allowlist = null
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Override the allowlist config path and reset cache (for testing). */
|
|
74
|
-
export function _setAllowlistConfigPath(path: string): void {
|
|
75
|
-
_allowlistConfigPath = path
|
|
76
|
-
_allowlist = null
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function loadAllowlist(): AllowlistEntry[] {
|
|
80
|
-
if (_allowlist !== null) return _allowlist
|
|
81
|
-
try {
|
|
82
|
-
if (!existsSync(_allowlistConfigPath)) {
|
|
83
|
-
_allowlist = []
|
|
84
|
-
return _allowlist
|
|
85
|
-
}
|
|
86
|
-
const content = readFileSync(_allowlistConfigPath, 'utf-8')
|
|
87
|
-
const parsed = yamlParse(content) as Record<string, unknown> | null
|
|
88
|
-
if (!parsed || !Array.isArray(parsed['allowlist'])) {
|
|
89
|
-
_allowlist = []
|
|
90
|
-
return _allowlist
|
|
91
|
-
}
|
|
92
|
-
_allowlist = parsed['allowlist'] as AllowlistEntry[]
|
|
93
|
-
return _allowlist
|
|
94
|
-
} catch {
|
|
95
|
-
_allowlist = []
|
|
96
|
-
return _allowlist
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function isSuppressed(
|
|
101
|
-
finding: { snippet: string },
|
|
102
|
-
filePath: string,
|
|
103
|
-
allowlist: AllowlistEntry[],
|
|
104
|
-
): boolean {
|
|
105
|
-
for (const entry of allowlist) {
|
|
106
|
-
if (entry.paths && entry.paths.length > 0) {
|
|
107
|
-
if (!entry.paths.some((p) => filePath.includes(p))) continue
|
|
108
|
-
}
|
|
109
|
-
if (entry.literal) {
|
|
110
|
-
if (finding.snippet.includes(entry.literal)) return true
|
|
111
|
-
} else if (entry.pattern) {
|
|
112
|
-
try {
|
|
113
|
-
if (new RegExp(entry.pattern, 'i').test(finding.snippet)) return true
|
|
114
|
-
} catch {
|
|
115
|
-
// Invalid regex in allowlist — skip entry
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return false
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// ── scanForSecrets ────────────────────────────────────────────────────────────
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Scan text content line-by-line for secrets using the default pattern set.
|
|
126
|
-
* Allowlist entries in `.opencastle/secret-scan-config.yml` suppress false positives.
|
|
127
|
-
*/
|
|
128
|
-
export function scanForSecrets(content: string, filePath = ''): SecretScanResult {
|
|
129
|
-
const allowlist = loadAllowlist()
|
|
130
|
-
const lines = content.split('\n')
|
|
131
|
-
const findings: SecretScanResult['findings'] = []
|
|
132
|
-
|
|
133
|
-
for (let i = 0; i < lines.length; i++) {
|
|
134
|
-
const line = lines[i]
|
|
135
|
-
for (const { name, pattern } of SECRET_PATTERNS) {
|
|
136
|
-
if (pattern.test(line)) {
|
|
137
|
-
const snippet = line.length > 100 ? line.slice(0, 97) + '...' : line
|
|
138
|
-
const finding = { pattern: name, file: filePath, line: i + 1, snippet }
|
|
139
|
-
if (!isSuppressed(finding, filePath, allowlist)) {
|
|
140
|
-
findings.push(finding)
|
|
141
|
-
}
|
|
142
|
-
// Only report the first matching pattern per line
|
|
143
|
-
break
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return { clean: findings.length === 0, findings }
|
|
149
|
-
}
|
|
8
|
+
// Secret scanning is shared with the compiler's commands, so it lives outside the engine.
|
|
9
|
+
import { scanForSecrets, type SecretScanResult } from '../secret-scan.js'
|
|
10
|
+
export {
|
|
11
|
+
scanForSecrets,
|
|
12
|
+
_resetAllowlistCache,
|
|
13
|
+
_setAllowlistConfigPath,
|
|
14
|
+
_allowlistConfigPath,
|
|
15
|
+
type SecretScanResult,
|
|
16
|
+
} from '../secret-scan.js'
|
|
150
17
|
|
|
151
18
|
// ── withSecretScan ────────────────────────────────────────────────────────────
|
|
152
19
|
|
package/src/cli/copy.ts
CHANGED
|
@@ -172,28 +172,3 @@ export async function removeDirIfExists(dirPath: string): Promise<void> {
|
|
|
172
172
|
export function getPluginsRoot(pkgRoot: string): string {
|
|
173
173
|
return resolve(pkgRoot, 'src', 'orchestrator', 'plugins');
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Scan plugin directories for SKILL.md files.
|
|
178
|
-
* Returns entries with plugin ID and skill file path.
|
|
179
|
-
*/
|
|
180
|
-
export async function getPluginSkillEntries(
|
|
181
|
-
pluginsRoot: string,
|
|
182
|
-
includedPluginIds?: Set<string>
|
|
183
|
-
): Promise<Array<{ id: string; skillPath: string }>> {
|
|
184
|
-
if (!existsSync(pluginsRoot)) return [];
|
|
185
|
-
|
|
186
|
-
const entries = await readdir(pluginsRoot, { withFileTypes: true });
|
|
187
|
-
const results: Array<{ id: string; skillPath: string }> = [];
|
|
188
|
-
|
|
189
|
-
for (const entry of entries) {
|
|
190
|
-
if (!entry.isDirectory()) continue;
|
|
191
|
-
if (includedPluginIds && !includedPluginIds.has(entry.name)) continue;
|
|
192
|
-
const skillPath = resolve(pluginsRoot, entry.name, 'SKILL.md');
|
|
193
|
-
if (existsSync(skillPath)) {
|
|
194
|
-
results.push({ id: entry.name, skillPath });
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return results;
|
|
199
|
-
}
|
|
@@ -39,9 +39,9 @@ const HIDDEN = extractKeys('HIDDEN')
|
|
|
39
39
|
const REPLACED = extractKeys('REPLACED')
|
|
40
40
|
|
|
41
41
|
describe('visible command surface', () => {
|
|
42
|
-
it('exposes the six product commands, the
|
|
42
|
+
it('exposes the six product commands, the seven team commands, and the convoy namespace', () => {
|
|
43
43
|
expect(new Set(VISIBLE)).toEqual(
|
|
44
|
-
new Set(['init', 'sync', 'add', 'doctor', 'remove', 'explain', 'review', 'ci', 'baseline', 'fleet', 'convoy']),
|
|
44
|
+
new Set(['init', 'sync', 'add', 'doctor', 'remove', 'explain', 'review', 'ci', 'baseline', 'plugin', 'promote', 'fleet', 'convoy']),
|
|
45
45
|
)
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -560,6 +560,8 @@ describe('declared flags are flags the parser reads', () => {
|
|
|
560
560
|
explain: ['explain.ts'],
|
|
561
561
|
ci: ['ci.ts'],
|
|
562
562
|
baseline: ['baseline.ts'],
|
|
563
|
+
plugin: ['plugin.ts'],
|
|
564
|
+
promote: ['promote.ts'],
|
|
563
565
|
fleet: ['fleet.ts'],
|
|
564
566
|
}
|
|
565
567
|
// Read by the entrypoint for every command, not by the modules.
|
package/src/cli/doctor.ts
CHANGED
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
} from './managed-block.js';
|
|
17
17
|
import { UnreadableConfigError } from './types.js';
|
|
18
18
|
import { checkMcpSupplyChain } from './mcp-audit.js';
|
|
19
|
+
import { parseMcpConfigText } from './mcp-file.js';
|
|
20
|
+
import { checkLessons } from './lessons.js';
|
|
19
21
|
import {
|
|
20
22
|
teamStateFor,
|
|
21
23
|
teamAuditContext,
|
|
@@ -464,7 +466,7 @@ export function checkMcpFromPaths(projectRoot: string, mcpPaths: string[]): Chec
|
|
|
464
466
|
const abs = resolve(projectRoot, p);
|
|
465
467
|
if (!existsSync(abs)) continue;
|
|
466
468
|
try {
|
|
467
|
-
|
|
469
|
+
parseMcpConfigText(readFileSync(abs, 'utf8'), p);
|
|
468
470
|
} catch (err) {
|
|
469
471
|
return {
|
|
470
472
|
ok: false,
|
|
@@ -949,6 +951,7 @@ export async function runSharedChecks(
|
|
|
949
951
|
await checkGitignoreBlock(projectRoot),
|
|
950
952
|
await checkTornBlocks(projectRoot, manifest),
|
|
951
953
|
checkRootFileClassification(manifest),
|
|
954
|
+
checkLessons(projectRoot),
|
|
952
955
|
...team,
|
|
953
956
|
];
|
|
954
957
|
|
|
@@ -986,7 +989,7 @@ export default async function doctor({ pkgRoot, args }: CliContext): Promise<voi
|
|
|
986
989
|
|
|
987
990
|
let manifest: Manifest | null = null;
|
|
988
991
|
let manifestUnreadable: string | undefined;
|
|
989
|
-
let manifestReason: '
|
|
992
|
+
let manifestReason: UnreadableConfigError['reason'] = 'unparseable';
|
|
990
993
|
try {
|
|
991
994
|
manifest = await readManifest(projectRoot);
|
|
992
995
|
} catch (err) {
|