opencastle 1.1.1 → 1.3.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 +26 -9
- package/bin/cli.mjs +6 -0
- package/dist/cli/adapters/antigravity.d.ts +0 -1
- package/dist/cli/adapters/antigravity.d.ts.map +1 -1
- package/dist/cli/adapters/antigravity.js +2 -1
- package/dist/cli/adapters/antigravity.js.map +1 -1
- package/dist/cli/adapters/claude-code.d.ts +0 -1
- package/dist/cli/adapters/claude-code.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.js +0 -1
- package/dist/cli/adapters/claude-code.js.map +1 -1
- package/dist/cli/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/adapters/cursor.js +8 -1
- package/dist/cli/adapters/cursor.js.map +1 -1
- package/dist/cli/adapters/opencode.d.ts +12 -5
- package/dist/cli/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/adapters/opencode.js +17 -5
- package/dist/cli/adapters/opencode.js.map +1 -1
- package/dist/cli/adapters/rules-dir-base.d.ts +12 -1
- package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +43 -57
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/rules-dir-base.test.js +27 -18
- package/dist/cli/adapters/rules-dir-base.test.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +11 -0
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +44 -14
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts +2 -1
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +2 -1
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/adapters/windsurf.d.ts.map +1 -1
- package/dist/cli/adapters/windsurf.js +11 -1
- package/dist/cli/adapters/windsurf.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 +114 -34
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/ci.d.ts.map +1 -1
- package/dist/cli/ci.js +18 -4
- package/dist/cli/ci.js.map +1 -1
- package/dist/cli/codex-target.test.js +14 -1
- package/dist/cli/codex-target.test.js.map +1 -1
- 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 +2 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/doctor.test.js +2 -2
- package/dist/cli/doctor.test.js.map +1 -1
- package/dist/cli/explain.d.ts +5 -0
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js +38 -2
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/init.test.js +78 -42
- 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 +3 -1
- 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 +2 -0
- package/dist/cli/mcp-audit.js.map +1 -1
- package/dist/cli/mcp-upgrade.test.js +24 -1
- package/dist/cli/mcp-upgrade.test.js.map +1 -1
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +22 -3
- 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/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 +9 -0
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +5 -4
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/team-commands.test.js +14 -2
- package/dist/cli/team-commands.test.js.map +1 -1
- package/dist/cli/team-sources.test.js +10 -0
- package/dist/cli/team-sources.test.js.map +1 -1
- package/dist/cli/types.d.ts +1 -1
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +18 -0
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/windsurf-target.test.d.ts +2 -0
- package/dist/cli/windsurf-target.test.d.ts.map +1 -0
- package/dist/cli/windsurf-target.test.js +62 -0
- package/dist/cli/windsurf-target.test.js.map +1 -0
- 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/dist/orchestrator/plugins/registry.test.d.ts +2 -0
- package/dist/orchestrator/plugins/registry.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/registry.test.js +37 -0
- package/dist/orchestrator/plugins/registry.test.js.map +1 -0
- package/package.json +2 -1
- package/src/cli/adapters/antigravity.ts +2 -1
- package/src/cli/adapters/claude-code.ts +0 -1
- package/src/cli/adapters/cursor.ts +8 -1
- package/src/cli/adapters/opencode.ts +18 -6
- package/src/cli/adapters/rules-dir-base.test.ts +28 -18
- package/src/cli/adapters/rules-dir-base.ts +51 -90
- package/src/cli/adapters/single-file-base.ts +53 -14
- package/src/cli/adapters/vscode.ts +2 -1
- package/src/cli/adapters/windsurf.ts +11 -1
- package/src/cli/agent-plugin.test.ts +267 -0
- package/src/cli/agent-plugin.ts +469 -0
- package/src/cli/baseline.ts +115 -32
- package/src/cli/ci.ts +19 -4
- package/src/cli/codex-target.test.ts +15 -1
- 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.test.ts +2 -2
- package/src/cli/doctor.ts +2 -0
- package/src/cli/explain.ts +36 -2
- package/src/cli/fixtures/lessons-template-1.0.md +70 -0
- package/src/cli/init.test.ts +82 -42
- 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 +3 -1
- package/src/cli/mcp-audit.ts +2 -0
- package/src/cli/mcp-upgrade.test.ts +26 -1
- package/src/cli/mcp.ts +22 -3
- 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/secret-scan.ts +154 -0
- package/src/cli/sync-check.test.ts +5 -4
- package/src/cli/sync-check.ts +9 -0
- package/src/cli/team-commands.test.ts +18 -2
- package/src/cli/team-sources.test.ts +11 -0
- package/src/cli/types.ts +1 -1
- package/src/cli/update.ts +20 -0
- package/src/cli/windsurf-target.test.ts +70 -0
- 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/registry.test.ts +42 -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
|
@@ -2,9 +2,12 @@ import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync
|
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises'
|
|
3
3
|
import { tmpdir } from 'node:os'
|
|
4
4
|
import { isAbsolute, join, relative, resolve } from 'node:path'
|
|
5
|
-
import { resolveSources, materialize, cliVersionOf,
|
|
5
|
+
import { resolveSources, materialize, cliVersionOf, hasErrors } from './layers.js'
|
|
6
|
+
import type { TeamIssue } from './team-config.js'
|
|
6
7
|
import { contentReport, tokensOf } from './lock.js'
|
|
7
8
|
import { CONFIG_SCHEMA_URL } from './team-config.js'
|
|
9
|
+
import { EXTENSION_NAMESPACE, claudeManifestFor, isAgentPlugin, mcpSchemaUrl, pluginNameFrom, pluginSchemaUrl, readAgentPlugin, type PluginManifest } from './agent-plugin.js'
|
|
10
|
+
import { staleClaudeFiles } from './plugin.js'
|
|
8
11
|
import { c } from './prompt.js'
|
|
9
12
|
import type { CliContext } from './types.js'
|
|
10
13
|
|
|
@@ -16,16 +19,24 @@ import type { CliContext } from './types.js'
|
|
|
16
19
|
* package manager does the fetching, the lockfile does the pinning, and an
|
|
17
20
|
* upgrade bot does the rollout — one pull request per repository, each with
|
|
18
21
|
* `opencastle review` explaining what it changes.
|
|
22
|
+
*
|
|
23
|
+
* A baseline `init` creates is also an Agent Plugin: `plugin.json`, skills in
|
|
24
|
+
* `skills/`, portable servers in `mcp.json`, and the rest of OpenCastle's layer
|
|
25
|
+
* — instructions, agents, prompts, workflows, policy — in `dev.opencastle/`.
|
|
26
|
+
* Assistants that read Agent Plugins can install it as it is; OpenCastle
|
|
27
|
+
* compiles all of it into every assistant for every repository that extends it.
|
|
19
28
|
*/
|
|
20
29
|
|
|
21
30
|
const HELP = `
|
|
22
31
|
opencastle baseline <init|check> [dir] [options]
|
|
23
32
|
|
|
24
|
-
init [dir] Scaffold a baseline package (default: ./opencastle-baseline)
|
|
25
|
-
|
|
26
|
-
a README on publishing and adopting it, and a
|
|
33
|
+
init [dir] Scaffold a baseline package (default: ./opencastle-baseline)
|
|
34
|
+
that is also an Agent Plugin: example instructions, a skill
|
|
35
|
+
and a policy, a README on publishing and adopting it, and a
|
|
36
|
+
CI check.
|
|
27
37
|
check [dir] Validate a baseline the way every repository extending it
|
|
28
|
-
will
|
|
38
|
+
will — its config, its content, its policy and its packaging —
|
|
39
|
+
and, when it is an Agent Plugin, the way assistants load it.
|
|
29
40
|
|
|
30
41
|
Options:
|
|
31
42
|
--name <pkg> Package name for init (default: @your-org/opencastle-baseline)
|
|
@@ -34,24 +45,35 @@ const HELP = `
|
|
|
34
45
|
`
|
|
35
46
|
|
|
36
47
|
function files(name: string, cliVersion: string): Record<string, string> {
|
|
48
|
+
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.'
|
|
49
|
+
const manifest: PluginManifest = {
|
|
50
|
+
$schema: pluginSchemaUrl(),
|
|
51
|
+
name: pluginNameFrom(name),
|
|
52
|
+
version: '0.1.0',
|
|
53
|
+
description,
|
|
54
|
+
license: 'UNLICENSED',
|
|
55
|
+
}
|
|
37
56
|
return {
|
|
38
57
|
'package.json':
|
|
39
58
|
JSON.stringify(
|
|
40
59
|
{
|
|
41
60
|
name,
|
|
42
61
|
version: '0.1.0',
|
|
43
|
-
description
|
|
62
|
+
description,
|
|
44
63
|
license: 'UNLICENSED',
|
|
45
|
-
files: ['
|
|
46
|
-
opencastle: { baseline: '
|
|
47
|
-
scripts: { check: 'opencastle baseline check' },
|
|
64
|
+
files: ['plugin.json', 'mcp.json', 'skills/', `${EXTENSION_NAMESPACE}/`, '.claude-plugin/', '.mcp.json'],
|
|
65
|
+
opencastle: { baseline: '.' },
|
|
66
|
+
scripts: { check: 'opencastle baseline check', build: 'opencastle plugin build' },
|
|
48
67
|
devDependencies: { opencastle: `^${cliVersion}` },
|
|
49
68
|
publishConfig: { access: 'restricted' },
|
|
50
69
|
},
|
|
51
70
|
null,
|
|
52
71
|
2,
|
|
53
72
|
) + '\n',
|
|
54
|
-
'
|
|
73
|
+
'plugin.json': JSON.stringify(manifest, null, 2) + '\n',
|
|
74
|
+
'mcp.json': JSON.stringify({ $schema: mcpSchemaUrl(), mcpServers: {} }, null, 2) + '\n',
|
|
75
|
+
'.claude-plugin/plugin.json': JSON.stringify(claudeManifestFor(manifest), null, 2) + '\n',
|
|
76
|
+
[`${EXTENSION_NAMESPACE}/config.json`]: `{
|
|
55
77
|
"$schema": "${CONFIG_SCHEMA_URL}",
|
|
56
78
|
// Every repository that extends this baseline is held to this policy.
|
|
57
79
|
// A repository can tighten it in its own .opencastle/config.json, never relax it.
|
|
@@ -70,12 +92,14 @@ function files(name: string, cliVersion: string): Record<string, string> {
|
|
|
70
92
|
// Tokens every assistant may load before it reads the task.
|
|
71
93
|
"contextBudget": 8000
|
|
72
94
|
},
|
|
73
|
-
// Servers
|
|
74
|
-
// spells
|
|
95
|
+
// Servers that need a variable — a token, a tenant — go here: write it as
|
|
96
|
+
// \${NAME} and OpenCastle spells it the way each assistant expects. A server
|
|
97
|
+
// every assistant can start as it is goes in ../mcp.json, where assistants
|
|
98
|
+
// that install this as an Agent Plugin find it too.
|
|
75
99
|
"mcpServers": {}
|
|
76
100
|
}
|
|
77
101
|
`,
|
|
78
|
-
|
|
102
|
+
[`${EXTENSION_NAMESPACE}/instructions/engineering-standards.md`]: `# Engineering standards
|
|
79
103
|
|
|
80
104
|
These apply to every repository in the organisation, and every assistant reads
|
|
81
105
|
them before every task. Keep this file short: detail belongs in a skill, which
|
|
@@ -85,7 +109,7 @@ loads only when a task needs it.
|
|
|
85
109
|
- Never write credentials into files; read them from the environment.
|
|
86
110
|
- Keep changes small and focused; one pull request, one purpose.
|
|
87
111
|
`,
|
|
88
|
-
'
|
|
112
|
+
'skills/code-review/SKILL.md': `---
|
|
89
113
|
name: code-review
|
|
90
114
|
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
115
|
---
|
|
@@ -100,18 +124,27 @@ Word feedback as a question or a suggestion with the reason attached.
|
|
|
100
124
|
`,
|
|
101
125
|
'README.md': `# ${name}
|
|
102
126
|
|
|
103
|
-
Our AI assistant standard
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
Our AI assistant standard. It is two things at once:
|
|
128
|
+
|
|
129
|
+
- an [OpenCastle](https://www.opencastle.dev) baseline — every repository that
|
|
130
|
+
extends it gets the same instructions, skills and MCP servers in every
|
|
131
|
+
assistant its developers use (Claude Code, Cursor, Copilot, OpenCode,
|
|
132
|
+
Windsurf, Codex CLI, Antigravity) and is held to the same policy;
|
|
133
|
+
- an [Agent Plugin](https://agent-plugins.org) — GitHub Copilot, VS Code,
|
|
134
|
+
Cursor, Codex and Kiro can install its skills and MCP servers as they are,
|
|
135
|
+
and Claude Code through \`.claude-plugin/\`.
|
|
107
136
|
|
|
108
137
|
## What is in it
|
|
109
138
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
| Path | What it is | Read by |
|
|
140
|
+
| --- | --- | --- |
|
|
141
|
+
| \`plugin.json\` | The Agent Plugins manifest | Every assistant that reads Agent Plugins |
|
|
142
|
+
| \`skills/<name>/SKILL.md\` | Agent Skills, loaded when a task matches | Every assistant |
|
|
143
|
+
| \`mcp.json\` | MCP servers every assistant can start as they are | Every assistant |
|
|
144
|
+
| \`${EXTENSION_NAMESPACE}/instructions/\` | Loaded by every assistant before every task | OpenCastle |
|
|
145
|
+
| \`${EXTENSION_NAMESPACE}/agents/\`, \`prompts/\`, \`workflows/\` | Optional | OpenCastle |
|
|
146
|
+
| \`${EXTENSION_NAMESPACE}/config.json\` | Servers that need variables, and the policy | OpenCastle |
|
|
147
|
+
| \`.claude-plugin/plugin.json\`, \`.mcp.json\` | Claude Code's copies — \`npm run build\` writes them | Claude Code |
|
|
115
148
|
|
|
116
149
|
## Adopting it in a repository
|
|
117
150
|
|
|
@@ -133,9 +166,10 @@ The version comes from package.json and the lockfile, like any dependency.
|
|
|
133
166
|
|
|
134
167
|
## Changing it
|
|
135
168
|
|
|
136
|
-
1. Edit
|
|
137
|
-
|
|
138
|
-
|
|
169
|
+
1. Edit it, then run \`npm run build\` (Claude Code's copies) and
|
|
170
|
+
\`npm run check\` — it validates the baseline the way every repository
|
|
171
|
+
extending it will, and the plugin the way assistants load it.
|
|
172
|
+
2. Bump the version in package.json and plugin.json, and publish.
|
|
139
173
|
3. Let your upgrade bot (Renovate, Dependabot) open the pull requests. In each,
|
|
140
174
|
CI runs \`opencastle sync --check\` and adds \`opencastle review\`'s summary of
|
|
141
175
|
what the new version changes for that repository's assistants.
|
|
@@ -170,7 +204,8 @@ async function init(pkgRoot: string, dir: string, name: string): Promise<void> {
|
|
|
170
204
|
await writeFile(abs, text)
|
|
171
205
|
}
|
|
172
206
|
console.log(`\n ${c.green('✓')} Created the baseline ${c.bold(name)} in ${dir}/`)
|
|
173
|
-
console.log(` ${c.dim('
|
|
207
|
+
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}/`)
|
|
208
|
+
console.log(` ${c.dim('Next: edit it, run')} ${c.cyan(`npx opencastle baseline check ${dir}`)}${c.dim(', then publish it.')}`)
|
|
174
209
|
console.log(` ${c.dim('Repositories adopt it with')} ${c.cyan(`npm i -D ${name}`)} ${c.dim('and')} ${c.cyan(`"extends": ["${name}"]`)}\n`)
|
|
175
210
|
}
|
|
176
211
|
|
|
@@ -190,6 +225,7 @@ function check(pkgRoot: string, dir: string): CheckReport {
|
|
|
190
225
|
let layerRoot = root
|
|
191
226
|
let name = dir
|
|
192
227
|
let version: string | undefined
|
|
228
|
+
let published: string[] | undefined
|
|
193
229
|
const pkgFile = join(root, 'package.json')
|
|
194
230
|
if (existsSync(pkgFile)) {
|
|
195
231
|
let pkg: { name?: string; version?: string; files?: string[]; opencastle?: { baseline?: string } } = {}
|
|
@@ -200,6 +236,7 @@ function check(pkgRoot: string, dir: string): CheckReport {
|
|
|
200
236
|
}
|
|
201
237
|
name = pkg.name ?? name
|
|
202
238
|
version = pkg.version
|
|
239
|
+
published = pkg.files
|
|
203
240
|
if (typeof pkg.opencastle?.baseline !== 'string') {
|
|
204
241
|
errors.push('package.json: has no "opencastle": { "baseline": "<dir>" }, so no repository can extend it')
|
|
205
242
|
} else {
|
|
@@ -220,6 +257,43 @@ function check(pkgRoot: string, dir: string): CheckReport {
|
|
|
220
257
|
}
|
|
221
258
|
if (!existsSync(layerRoot)) errors.push(`${relative(process.cwd(), layerRoot) || '.'}: the layer directory does not exist`)
|
|
222
259
|
|
|
260
|
+
// The plugin side: what an assistant that installs it as an Agent Plugin sees.
|
|
261
|
+
if (errors.length === 0 && isAgentPlugin(layerRoot)) {
|
|
262
|
+
const report = readAgentPlugin(layerRoot)
|
|
263
|
+
errors.push(...report.errors)
|
|
264
|
+
warnings.push(...report.warnings)
|
|
265
|
+
if (report.manifest) {
|
|
266
|
+
for (const f of staleClaudeFiles(layerRoot, report)) {
|
|
267
|
+
errors.push(`${f}: does not match plugin.json and mcp.json — run opencastle plugin build`)
|
|
268
|
+
}
|
|
269
|
+
if (!existsSync(join(layerRoot, '.claude-plugin', 'plugin.json'))) {
|
|
270
|
+
warnings.push('.claude-plugin/plugin.json: missing — Claude Code reads only its own manifest; run opencastle plugin build')
|
|
271
|
+
}
|
|
272
|
+
if (version && report.manifest.version && version !== report.manifest.version) {
|
|
273
|
+
warnings.push(`plugin.json: version ${report.manifest.version}, while package.json says ${version} — assistants offer updates by plugin.json's`)
|
|
274
|
+
}
|
|
275
|
+
// `files` decides what npm publishes; a plugin missing its manifest or
|
|
276
|
+
// its skills installs as nothing.
|
|
277
|
+
if (published) {
|
|
278
|
+
const at = relative(root, layerRoot).split('\\').join('/')
|
|
279
|
+
for (const part of ['plugin.json', 'skills', 'mcp.json', EXTENSION_NAMESPACE, '.claude-plugin', '.mcp.json']) {
|
|
280
|
+
if (!existsSync(join(layerRoot, part))) continue
|
|
281
|
+
const path = at ? `${at}/${part}` : part
|
|
282
|
+
const shipped = published.some((f) => {
|
|
283
|
+
const entry = f.replace(/\/$/, '')
|
|
284
|
+
return entry === path || path.startsWith(`${entry}/`)
|
|
285
|
+
})
|
|
286
|
+
if (!shipped) errors.push(`package.json: "files" does not include ${path}, so npm publish would leave it out`)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} else if (errors.length === 0) {
|
|
291
|
+
warnings.push(
|
|
292
|
+
'is not an Agent Plugin, so only OpenCastle can use it — assistants that read Agent Plugins cannot install it. ' +
|
|
293
|
+
'`opencastle baseline init` shows the layout: skills/ and mcp.json at the root, the rest in dev.opencastle/',
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
|
|
223
297
|
const contributes = { skills: 0, agents: 0, instructions: 0, prompts: 0, workflows: 0, mcpServers: 0 }
|
|
224
298
|
let contextTokens = 0
|
|
225
299
|
if (errors.length === 0) {
|
|
@@ -230,9 +304,17 @@ function check(pkgRoot: string, dir: string): CheckReport {
|
|
|
230
304
|
const spec = relative(join(project, '.opencastle'), layerRoot).split('\\').join('/')
|
|
231
305
|
writeFileSync(join(project, '.opencastle', 'config.json'), JSON.stringify({ extends: [spec.startsWith('.') ? spec : `./${spec}`] }))
|
|
232
306
|
const resolved = resolveSources({ pkgRoot, projectRoot: project, stack: { ides: [], techTools: [], teamTools: [] } })
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
307
|
+
// The scratch project names the baseline by its path from there —
|
|
308
|
+
// `../../../../Users/ana/base` — and stripping the `../` left an absolute
|
|
309
|
+
// path with its leading slash gone. Named instead as it was given here.
|
|
310
|
+
const id = relative(project, layerRoot).split('\\').join('/') || '.'
|
|
311
|
+
const here = dir === '.' ? '' : `${dir.replace(/\/$/, '')}/`
|
|
312
|
+
const shown = (text: string): string =>
|
|
313
|
+
text.split(`${id}/`).join(here).split(id).join(name).split(project).join('<repository>')
|
|
314
|
+
// One string per problem, its remedy on the line below — not the icons
|
|
315
|
+
// `formatIssues` prints, which the report below adds again.
|
|
316
|
+
const said = (i: TeamIssue): string => shown(`${i.where}: ${i.message}${i.fix ? `\n→ ${i.fix}` : ''}`)
|
|
317
|
+
for (const i of resolved.issues) (i.level === 'error' ? errors : warnings).push(said(i))
|
|
236
318
|
for (const item of resolved.items.values()) {
|
|
237
319
|
if (item.layer !== 'opencastle') contributes[item.kind]++
|
|
238
320
|
}
|
|
@@ -281,8 +363,9 @@ export default async function baseline({ pkgRoot, args }: CliContext): Promise<v
|
|
|
281
363
|
const parts = Object.entries(k).filter(([, n]) => n > 0).map(([kind, n]) => `${n} ${kind === 'mcpServers' ? 'MCP server(s)' : kind}`)
|
|
282
364
|
console.log(` Contributes: ${parts.length > 0 ? parts.join(', ') : c.dim('nothing yet')}`)
|
|
283
365
|
if (report.contextTokens) console.log(` A repository extending it loads ~${report.contextTokens} tokens up front, with OpenCastle's own content`)
|
|
284
|
-
|
|
285
|
-
for (const
|
|
366
|
+
const indent = (text: string): string => text.split('\n').join('\n ')
|
|
367
|
+
for (const e of report.errors) console.log(` ${c.red('✗')} ${indent(e)}`)
|
|
368
|
+
for (const w of report.warnings) console.log(` ${c.yellow('!')} ${c.dim(indent(w))}`)
|
|
286
369
|
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
370
|
}
|
|
288
371
|
if (report.errors.length > 0) process.exit(1)
|
package/src/cli/ci.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process'
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs'
|
|
3
3
|
import { mkdir, writeFile, appendFile } from 'node:fs/promises'
|
|
4
|
-
import { basename, dirname, join, relative, sep } from 'node:path'
|
|
4
|
+
import { basename, dirname, join, relative, resolve, sep } from 'node:path'
|
|
5
5
|
import { readManifest } from './manifest.js'
|
|
6
6
|
import { cliVersionOf, resolveSources } from './layers.js'
|
|
7
7
|
import { resolveStack } from './stack-config.js'
|
|
@@ -48,6 +48,21 @@ function git(cwd: string, args: string[]): string | null {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* The repository's root, spelled the way the project's path is.
|
|
53
|
+
*
|
|
54
|
+
* `--show-toplevel` follows links, so on macOS a project under `/var/…` had a
|
|
55
|
+
* root under `/private/var/…`: every path compared against the project's own
|
|
56
|
+
* spelling fell outside the repository, a baseline kept beside the project was
|
|
57
|
+
* left out of the workflow's paths, and the CODEOWNERS found was named by a
|
|
58
|
+
* path the user never typed. `--show-cdup` is the way up from the project,
|
|
59
|
+
* applied to the project's own path.
|
|
60
|
+
*/
|
|
61
|
+
function repoRootOf(projectRoot: string): string {
|
|
62
|
+
const up = git(projectRoot, ['rev-parse', '--show-cdup'])
|
|
63
|
+
return up === null ? projectRoot : resolve(projectRoot, up || '.')
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
function packageManagerOf(root: string): PackageManager {
|
|
52
67
|
if (existsSync(join(root, 'pnpm-lock.yaml'))) return 'pnpm'
|
|
53
68
|
if (existsSync(join(root, 'yarn.lock'))) return 'yarn'
|
|
@@ -79,7 +94,7 @@ function findUp(start: string, names: string[], stop: string): string | null {
|
|
|
79
94
|
* baseline kept elsewhere in the repository, whose change must run it too.
|
|
80
95
|
*/
|
|
81
96
|
export function planCi(projectRoot: string, cliVersion: string, owners?: string, extraPaths: string[] = []): Plan {
|
|
82
|
-
const repoRoot =
|
|
97
|
+
const repoRoot = repoRootOf(projectRoot)
|
|
83
98
|
const prefix = (git(projectRoot, ['rev-parse', '--show-prefix']) ?? '').replace(/\/$/, '')
|
|
84
99
|
const branch = (git(projectRoot, ['symbolic-ref', '--short', 'refs/remotes/origin/HEAD']) ?? 'origin/main').replace(/^origin\//, '')
|
|
85
100
|
|
|
@@ -234,7 +249,7 @@ export default async function ci({ pkgRoot, args }: CliContext): Promise<void> {
|
|
|
234
249
|
const manifest = await readManifest(projectRoot)
|
|
235
250
|
const manifestVersion = manifest?.version
|
|
236
251
|
// Baselines kept elsewhere in this repository: a change there must run the check.
|
|
237
|
-
const repoRoot =
|
|
252
|
+
const repoRoot = repoRootOf(projectRoot)
|
|
238
253
|
const extra: string[] = []
|
|
239
254
|
try {
|
|
240
255
|
const resolved = resolveSources({ pkgRoot, projectRoot, stack: resolveStack(manifest!), repoInfo: manifest?.repoInfo })
|
|
@@ -247,7 +262,7 @@ export default async function ci({ pkgRoot, args }: CliContext): Promise<void> {
|
|
|
247
262
|
// The workflow is still right without them; sync --check will name the problem.
|
|
248
263
|
}
|
|
249
264
|
const plan = planCi(projectRoot, manifestVersion ?? cliVersionOf(pkgRoot), owners, extra)
|
|
250
|
-
const rel = (p: string): string => p.
|
|
265
|
+
const rel = (p: string): string => relative(repoRoot, p).split(sep).join('/')
|
|
251
266
|
|
|
252
267
|
if (args.includes('--dry-run')) {
|
|
253
268
|
console.log(`\n ${c.dim(`[dry-run] ${rel(plan.workflowPath)}:`)}\n`)
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* because each compared the project against the same wrong paths.
|
|
9
9
|
*/
|
|
10
10
|
import { execFileSync } from 'node:child_process'
|
|
11
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
11
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
|
12
12
|
import { tmpdir } from 'node:os'
|
|
13
13
|
import { dirname, join, resolve } from 'node:path'
|
|
14
14
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
@@ -169,6 +169,20 @@ describe.skipIf(!built)('Codex CLI as a target', () => {
|
|
|
169
169
|
run(project, 'sync', '--check')
|
|
170
170
|
})
|
|
171
171
|
|
|
172
|
+
it('explain says whether Codex trusts the project, since it reads config.toml only then', () => {
|
|
173
|
+
run(project, 'init', '--yes')
|
|
174
|
+
const codexHome = join(project, '..', `${project.split('/').pop()}-codex-home`)
|
|
175
|
+
const explain = (): { setup: Array<{ need: string; ok: boolean }> } =>
|
|
176
|
+
JSON.parse(execFileSync('node', [cli, 'explain', '--json'], { cwd: project, encoding: 'utf8', env: { ...process.env, CODEX_HOME: codexHome } }))
|
|
177
|
+
try {
|
|
178
|
+
expect(explain().setup).toContainEqual(expect.objectContaining({ need: 'trust', ok: false }))
|
|
179
|
+
write(codexHome, { 'config.toml': `[projects.${JSON.stringify(realpathSync(project))}]\ntrust_level = "trusted"\n` })
|
|
180
|
+
expect(explain().setup).toContainEqual(expect.objectContaining({ need: 'trust', ok: true }))
|
|
181
|
+
} finally {
|
|
182
|
+
rmSync(codexHome, { recursive: true, force: true })
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
|
|
172
186
|
it('remove --all takes our servers out of config.toml and leaves the user’s setup', () => {
|
|
173
187
|
run(project, 'init', '--yes')
|
|
174
188
|
run(project, 'remove', '--all', '--yes')
|
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.test.ts
CHANGED
|
@@ -193,7 +193,7 @@ describe('cursor adapter getDoctorChecks', () => {
|
|
|
193
193
|
expect(checks.length).toBeGreaterThan(0)
|
|
194
194
|
expect(checks.find((c) => c.path === '.cursorrules')?.type).toBe('file')
|
|
195
195
|
expect(checks.find((c) => c.path === '.cursor/rules/agents/')?.countFilter).toBe('.mdc')
|
|
196
|
-
expect(checks.find((c) => c.path === '.
|
|
196
|
+
expect(checks.find((c) => c.path === '.agents/skills/')?.type).toBe('dir')
|
|
197
197
|
})
|
|
198
198
|
})
|
|
199
199
|
|
|
@@ -218,7 +218,7 @@ describe('opencode adapter getDoctorChecks', () => {
|
|
|
218
218
|
expect(checks.length).toBeGreaterThan(0)
|
|
219
219
|
expect(checks.find((c) => c.path === 'AGENTS.md')?.type).toBe('file')
|
|
220
220
|
expect(checks.find((c) => c.path === '.opencode/agents/')).toBeDefined()
|
|
221
|
-
expect(checks.find((c) => c.path === '.
|
|
221
|
+
expect(checks.find((c) => c.path === '.agents/skills/')).toBeDefined()
|
|
222
222
|
// opencode: separate prompts and workflows dirs
|
|
223
223
|
expect(checks.find((c) => c.path === '.opencode/prompts/')).toBeDefined()
|
|
224
224
|
expect(checks.find((c) => c.path === '.opencode/workflows/')).toBeDefined()
|
package/src/cli/doctor.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { UnreadableConfigError } from './types.js';
|
|
18
18
|
import { checkMcpSupplyChain } from './mcp-audit.js';
|
|
19
19
|
import { parseMcpConfigText } from './mcp-file.js';
|
|
20
|
+
import { checkLessons } from './lessons.js';
|
|
20
21
|
import {
|
|
21
22
|
teamStateFor,
|
|
22
23
|
teamAuditContext,
|
|
@@ -950,6 +951,7 @@ export async function runSharedChecks(
|
|
|
950
951
|
await checkGitignoreBlock(projectRoot),
|
|
951
952
|
await checkTornBlocks(projectRoot, manifest),
|
|
952
953
|
checkRootFileClassification(manifest),
|
|
954
|
+
checkLessons(projectRoot),
|
|
953
955
|
...team,
|
|
954
956
|
];
|
|
955
957
|
|