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/explain.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { join, resolve } from 'node:path'
|
|
4
|
+
import { parse as parseToml } from 'smol-toml'
|
|
3
5
|
import { readManifest } from './manifest.js'
|
|
4
6
|
import { resolveStack, isEnvVarSatisfied } from './stack-config.js'
|
|
5
7
|
import { resolveSources, materialize, hasErrors, formatIssues, requiredEnvVars, refuseOlderCli } from './layers.js'
|
|
@@ -92,10 +94,41 @@ async function build(pkgRoot: string, projectRoot: string): Promise<ExplainRepor
|
|
|
92
94
|
setup.push({ server: key, need: 'sign-in', ok: true, how: 'your assistant opens a browser to sign in the first time it starts the server' })
|
|
93
95
|
}
|
|
94
96
|
}
|
|
97
|
+
// Codex loads a project's `.codex/config.toml` only once the user has
|
|
98
|
+
// trusted the project, so every server written there waits on that.
|
|
99
|
+
if (ides.includes('codex') && Object.keys(lock.mcp).length > 0) {
|
|
100
|
+
setup.push({
|
|
101
|
+
server: 'Codex CLI',
|
|
102
|
+
need: 'trust',
|
|
103
|
+
ok: codexTrusts(projectRoot),
|
|
104
|
+
how: 'Codex reads .codex/config.toml, and so every MCP server here, only in a project you trust — run codex in this directory and trust it when it asks',
|
|
105
|
+
})
|
|
106
|
+
}
|
|
95
107
|
const notes = resolved.issues.filter((i) => i.level === 'warning').map((i) => `${i.where}: ${i.message}`)
|
|
96
108
|
return { targets, lock, setup, notes }
|
|
97
109
|
}
|
|
98
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Whether Codex has been told to trust this project: `trust_level = "trusted"`
|
|
113
|
+
* under `[projects."<path>"]` in its own config, `$CODEX_HOME/config.toml`.
|
|
114
|
+
*/
|
|
115
|
+
export function codexTrusts(projectRoot: string): boolean {
|
|
116
|
+
const file = join(process.env.CODEX_HOME || join(process.env.HOME || homedir(), '.codex'), 'config.toml')
|
|
117
|
+
let projects: Record<string, { trust_level?: unknown }>
|
|
118
|
+
try {
|
|
119
|
+
projects = ((parseToml(readFileSync(file, 'utf8')) as { projects?: Record<string, { trust_level?: unknown }> }).projects ?? {})
|
|
120
|
+
} catch {
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
const spellings = new Set([projectRoot])
|
|
124
|
+
try {
|
|
125
|
+
spellings.add(realpathSync(projectRoot))
|
|
126
|
+
} catch {
|
|
127
|
+
// The path as given is the only spelling there is.
|
|
128
|
+
}
|
|
129
|
+
return [...spellings].some((p) => projects[p]?.trust_level === 'trusted')
|
|
130
|
+
}
|
|
131
|
+
|
|
99
132
|
function render(report: ExplainReport, all: boolean): void {
|
|
100
133
|
const { lock } = report
|
|
101
134
|
const out = (s = ''): void => console.log(s)
|
|
@@ -191,6 +224,7 @@ function render(report: ExplainReport, all: boolean): void {
|
|
|
191
224
|
if (report.setup.length === 0) out(` ${c.green('✓')} Nothing to set up — every server works without a variable or a sign-in.`)
|
|
192
225
|
for (const s of report.setup) {
|
|
193
226
|
if (s.need === 'sign-in') out(` ${c.cyan('→')} ${s.server}: ${s.how}`)
|
|
227
|
+
else if (s.need === 'trust') out(` ${s.ok ? c.green('✓') : c.red('✗')} ${s.ok ? 'Codex trusts this project' : 'Codex does not trust this project yet'} ${c.dim(`— ${s.how}`)}`)
|
|
194
228
|
else out(` ${s.ok ? c.green('✓') : c.red('✗')} ${s.need} ${c.dim(`— ${s.how}${s.ok ? '' : '; set it in .env or your shell'}`)}`)
|
|
195
229
|
}
|
|
196
230
|
out('')
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
````markdown
|
|
2
|
+
# Lessons Learned
|
|
3
|
+
|
|
4
|
+
Structured log of tool/command pitfalls, workarounds, and correct approaches discovered through agent execution. **Every agent** must read this file before starting work and must add entries when they discover a new pitfall through trial-and-error.
|
|
5
|
+
|
|
6
|
+
> **This file is the collective memory of the agent team.** It prevents repeating the same mistakes across sessions.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## How to Use This File
|
|
11
|
+
|
|
12
|
+
### Before starting work
|
|
13
|
+
|
|
14
|
+
1. Read the **entire file** (or at minimum, the sections relevant to your task)
|
|
15
|
+
2. Apply any relevant lessons to your approach **before** attempting commands or tool calls
|
|
16
|
+
|
|
17
|
+
### When to add a new entry
|
|
18
|
+
|
|
19
|
+
Add a lesson when **any** of these occur:
|
|
20
|
+
- A command, tool call, or API call fails and you had to retry with a different approach
|
|
21
|
+
- You discover a parameter, syntax, or configuration quirk not documented elsewhere
|
|
22
|
+
- A workaround is needed for a third-party tool, MCP server, or platform limitation
|
|
23
|
+
- An approach that seems obvious turns out to be wrong
|
|
24
|
+
|
|
25
|
+
### Entry format
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
### LES-XXX: Short descriptive title
|
|
29
|
+
|
|
30
|
+
| Field | Value |
|
|
31
|
+
|-------|-------|
|
|
32
|
+
| **Category** | `task-management` / `mcp-tools` / `codebase-tool` / `terminal` / `framework` / `cms` / `database` / `git` / `deployment` / `browser-testing` / `general` |
|
|
33
|
+
| **Added** | YYYY-MM-DD |
|
|
34
|
+
| **Severity** | `high` (blocks work) / `medium` (wastes 5+ min) / `low` (minor annoyance) |
|
|
35
|
+
|
|
36
|
+
**Problem:** What went wrong and what error or unexpected behavior was observed.
|
|
37
|
+
|
|
38
|
+
**Wrong approach:** The obvious/intuitive approach that fails.
|
|
39
|
+
|
|
40
|
+
**Correct approach:** The working solution.
|
|
41
|
+
|
|
42
|
+
**Why:** Root cause explanation (if known).
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Lessons
|
|
48
|
+
|
|
49
|
+
<!-- Lessons are appended here by agents during sessions.
|
|
50
|
+
Start numbering from LES-001. -->
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Index by Category
|
|
55
|
+
|
|
56
|
+
| Category | Lessons |
|
|
57
|
+
|----------|---------|
|
|
58
|
+
| `task-management` | — |
|
|
59
|
+
| `mcp-tools` | — |
|
|
60
|
+
| `codebase-tool` | — |
|
|
61
|
+
| `terminal` | — |
|
|
62
|
+
| `framework` | — |
|
|
63
|
+
| `cms` | — |
|
|
64
|
+
| `database` | — |
|
|
65
|
+
| `git` | — |
|
|
66
|
+
| `deployment` | — |
|
|
67
|
+
| `browser-testing` | — |
|
|
68
|
+
| `general` | — |
|
|
69
|
+
|
|
70
|
+
````
|
package/src/cli/init.test.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
18
|
-
import { mkdtemp, readFile, readdir, rm, unlink, writeFile } from 'node:fs/promises'
|
|
18
|
+
import { mkdir, mkdtemp, readFile, readdir, rename, rm, unlink, writeFile } from 'node:fs/promises'
|
|
19
19
|
import { join, resolve } from 'node:path'
|
|
20
20
|
import { tmpdir } from 'node:os'
|
|
21
21
|
import { existsSync } from 'node:fs'
|
|
@@ -449,12 +449,12 @@ describe('VS Code adapter install', () => {
|
|
|
449
449
|
const skills = await readdir(skillsDir)
|
|
450
450
|
|
|
451
451
|
// Selected plugin skills should be present
|
|
452
|
-
expect(skills).toContain('sanity')
|
|
453
|
-
expect(skills).toContain('linear')
|
|
452
|
+
expect(skills).toContain('sanity-cms')
|
|
453
|
+
expect(skills).toContain('linear-task-management')
|
|
454
454
|
// Unselected plugin skills should NOT be present
|
|
455
|
-
expect(skills).not.toContain('supabase')
|
|
456
|
-
expect(skills).not.toContain('slack')
|
|
457
|
-
expect(skills).not.toContain('vercel')
|
|
455
|
+
expect(skills).not.toContain('supabase-database')
|
|
456
|
+
expect(skills).not.toContain('slack-notifications')
|
|
457
|
+
expect(skills).not.toContain('vercel-deployment')
|
|
458
458
|
|
|
459
459
|
// Core skills (non-plugin) should always be present
|
|
460
460
|
expect(skills).toContain('accessibility-standards')
|
|
@@ -470,9 +470,9 @@ describe('VS Code adapter install', () => {
|
|
|
470
470
|
// Plugin-linked skill directories should be absent if tool not selected
|
|
471
471
|
// (The core skills directory names don't match plugin IDs — they're separate)
|
|
472
472
|
// But plugin SKILL.md dirs should not exist
|
|
473
|
-
expect(skills).not.toContain('sanity')
|
|
474
|
-
expect(skills).not.toContain('linear')
|
|
475
|
-
expect(skills).not.toContain('supabase')
|
|
473
|
+
expect(skills).not.toContain('sanity-cms')
|
|
474
|
+
expect(skills).not.toContain('linear-task-management')
|
|
475
|
+
expect(skills).not.toContain('supabase-database')
|
|
476
476
|
})
|
|
477
477
|
|
|
478
478
|
it('injects plugin tools into agent frontmatter', async () => {
|
|
@@ -660,24 +660,28 @@ describe('Cursor adapter install', () => {
|
|
|
660
660
|
expect(agents).toContain('content-engineer.mdc')
|
|
661
661
|
})
|
|
662
662
|
|
|
663
|
-
it('
|
|
663
|
+
it('writes skills as Agent Skills in .agents/skills/, which Cursor reads', async () => {
|
|
664
664
|
const adapter = await IDE_ADAPTERS['cursor']()
|
|
665
665
|
await adapter.install(PKG_ROOT, tempDir, STACK_SANITY_LINEAR, EMPTY_REPO_INFO)
|
|
666
666
|
|
|
667
|
-
const skillsDir = join(tempDir, '.
|
|
667
|
+
const skillsDir = join(tempDir, '.agents', 'skills')
|
|
668
668
|
const skills = await readdir(skillsDir)
|
|
669
669
|
|
|
670
670
|
// Core skills should be present
|
|
671
|
-
expect(skills).toContain('self-improvement
|
|
672
|
-
expect(skills).toContain('testing-workflow
|
|
671
|
+
expect(skills).toContain('self-improvement')
|
|
672
|
+
expect(skills).toContain('testing-workflow')
|
|
673
|
+
expect(existsSync(join(skillsDir, 'testing-workflow', 'SKILL.md'))).toBe(true)
|
|
673
674
|
|
|
674
|
-
// Selected plugin skills
|
|
675
|
-
expect(skills).toContain('sanity
|
|
676
|
-
expect(skills).toContain('linear
|
|
675
|
+
// Selected plugin skills
|
|
676
|
+
expect(skills).toContain('sanity-cms')
|
|
677
|
+
expect(skills).toContain('linear-task-management')
|
|
677
678
|
|
|
678
679
|
// Unselected plugin skills should not be present
|
|
679
|
-
expect(skills).not.toContain('supabase
|
|
680
|
-
expect(skills).not.toContain('slack
|
|
680
|
+
expect(skills).not.toContain('supabase-database')
|
|
681
|
+
expect(skills).not.toContain('slack-notifications')
|
|
682
|
+
|
|
683
|
+
// Not as rules any more
|
|
684
|
+
expect(existsSync(join(tempDir, '.cursor', 'rules', 'skills'))).toBe(false)
|
|
681
685
|
})
|
|
682
686
|
|
|
683
687
|
it('generates Cursor MCP config with mcpServers format', async () => {
|
|
@@ -735,6 +739,19 @@ describe('Claude Code adapter install', () => {
|
|
|
735
739
|
await rm(tempDir, { recursive: true, force: true })
|
|
736
740
|
})
|
|
737
741
|
|
|
742
|
+
it('moves an integration skill from its old directory and leaves no empty folder behind', async () => {
|
|
743
|
+
const adapter = await IDE_ADAPTERS['claude-code']()
|
|
744
|
+
await adapter.install(PKG_ROOT, tempDir, STACK_SANITY_LINEAR, EMPTY_REPO_INFO)
|
|
745
|
+
// As releases before integration skills took their own names left it.
|
|
746
|
+
const skills = join(tempDir, '.claude', 'skills')
|
|
747
|
+
await rename(join(skills, 'sanity-cms'), join(skills, 'sanity'))
|
|
748
|
+
const result = await adapter.update(PKG_ROOT, tempDir, STACK_SANITY_LINEAR, EMPTY_REPO_INFO)
|
|
749
|
+
const entries = await readdir(skills)
|
|
750
|
+
expect(entries).toContain('sanity-cms')
|
|
751
|
+
expect(entries).not.toContain('sanity')
|
|
752
|
+
expect(result.deleted).toContain('.claude/skills/sanity/SKILL.md')
|
|
753
|
+
})
|
|
754
|
+
|
|
738
755
|
it('creates CLAUDE.md with embedded instructions', async () => {
|
|
739
756
|
const adapter = await IDE_ADAPTERS['claude-code']()
|
|
740
757
|
await adapter.install(PKG_ROOT, tempDir, STACK_EMPTY, EMPTY_REPO_INFO)
|
|
@@ -778,10 +795,10 @@ describe('Claude Code adapter install', () => {
|
|
|
778
795
|
const content = await readFile(join(tempDir, 'CLAUDE.md'), 'utf8')
|
|
779
796
|
expect(content).toContain('## Available Skills')
|
|
780
797
|
expect(content).toContain('**self-improvement**')
|
|
781
|
-
expect(content).toContain('**sanity**')
|
|
782
|
-
expect(content).toContain('**linear**')
|
|
798
|
+
expect(content).toContain('**sanity-cms**')
|
|
799
|
+
expect(content).toContain('**linear-task-management**')
|
|
783
800
|
// Unselected plugin skills should NOT appear in skill index
|
|
784
|
-
expect(content).not.
|
|
801
|
+
expect(content).not.toContain('**supabase-database**')
|
|
785
802
|
})
|
|
786
803
|
|
|
787
804
|
it('strips frontmatter from agent files in .claude/agents/', async () => {
|
|
@@ -810,9 +827,9 @@ describe('Claude Code adapter install', () => {
|
|
|
810
827
|
|
|
811
828
|
// Skills are subdirectories (Anthropic's Claude Code Skills format)
|
|
812
829
|
expect(entries).toContain('self-improvement')
|
|
813
|
-
expect(entries).toContain('sanity')
|
|
814
|
-
expect(entries).toContain('linear')
|
|
815
|
-
expect(entries).not.toContain('supabase')
|
|
830
|
+
expect(entries).toContain('sanity-cms')
|
|
831
|
+
expect(entries).toContain('linear-task-management')
|
|
832
|
+
expect(entries).not.toContain('supabase-database')
|
|
816
833
|
|
|
817
834
|
// SKILL.md exists inside each skill subdirectory
|
|
818
835
|
const skillContent = await readFile(
|
|
@@ -902,16 +919,27 @@ describe('OpenCode adapter install', () => {
|
|
|
902
919
|
|
|
903
920
|
const content = await readFile(join(tempDir, 'AGENTS.md'), 'utf8')
|
|
904
921
|
expect(content).toContain('# Project Instructions')
|
|
905
|
-
expect(content).toContain('.
|
|
922
|
+
expect(content).toContain('.agents/skills/')
|
|
906
923
|
expect(content).toContain('.opencode/agents/')
|
|
907
924
|
})
|
|
908
925
|
|
|
926
|
+
it('removes the .opencode/skills/ an earlier release wrote', async () => {
|
|
927
|
+
const adapter = await IDE_ADAPTERS['opencode']()
|
|
928
|
+
await adapter.install(PKG_ROOT, tempDir, STACK_EMPTY, EMPTY_REPO_INFO)
|
|
929
|
+
await mkdir(join(tempDir, '.opencode', 'skills', 'testing-workflow'), { recursive: true })
|
|
930
|
+
await writeFile(join(tempDir, '.opencode', 'skills', 'testing-workflow', 'SKILL.md'), 'old')
|
|
931
|
+
const result = await adapter.update(PKG_ROOT, tempDir, STACK_EMPTY, EMPTY_REPO_INFO)
|
|
932
|
+
expect(existsSync(join(tempDir, '.opencode', 'skills'))).toBe(false)
|
|
933
|
+
expect(result.deleted).toContain('.opencode/skills/')
|
|
934
|
+
})
|
|
935
|
+
|
|
909
936
|
it('creates files in .opencode/ directory structure', async () => {
|
|
910
937
|
const adapter = await IDE_ADAPTERS['opencode']()
|
|
911
938
|
await adapter.install(PKG_ROOT, tempDir, STACK_SANITY_LINEAR, EMPTY_REPO_INFO)
|
|
912
939
|
|
|
913
940
|
expect(existsSync(join(tempDir, '.opencode', 'agents'))).toBe(true)
|
|
914
|
-
expect(existsSync(join(tempDir, '.
|
|
941
|
+
expect(existsSync(join(tempDir, '.agents', 'skills', 'sanity-cms', 'SKILL.md'))).toBe(true)
|
|
942
|
+
expect(existsSync(join(tempDir, '.opencode', 'skills'))).toBe(false)
|
|
915
943
|
expect(existsSync(join(tempDir, '.opencode', 'prompts'))).toBe(true)
|
|
916
944
|
expect(existsSync(join(tempDir, '.opencode', 'workflows'))).toBe(true)
|
|
917
945
|
})
|
|
@@ -964,7 +992,7 @@ describe('OpenCode adapter install', () => {
|
|
|
964
992
|
expect(paths.merged).toContain('AGENTS.md')
|
|
965
993
|
expect(paths.framework).not.toContain('AGENTS.md')
|
|
966
994
|
expect(paths.framework).toContain('.opencode/agents/')
|
|
967
|
-
expect(paths.framework).toContain('.
|
|
995
|
+
expect(paths.framework).toContain('.agents/skills/')
|
|
968
996
|
expect(paths.framework).toContain('.opencode/prompts/')
|
|
969
997
|
expect(paths.framework).toContain('.opencode/workflows/')
|
|
970
998
|
|
|
@@ -1034,21 +1062,18 @@ describe('Windsurf adapter install', () => {
|
|
|
1034
1062
|
expect(files.length).toBeGreaterThan(0)
|
|
1035
1063
|
})
|
|
1036
1064
|
|
|
1037
|
-
it('
|
|
1065
|
+
it('writes skills as Agent Skills in .agents/skills/, which Devin Desktop reads', async () => {
|
|
1038
1066
|
const adapter = await IDE_ADAPTERS['windsurf']()
|
|
1039
1067
|
await adapter.install(PKG_ROOT, tmpDir, STACK_SANITY_LINEAR)
|
|
1040
|
-
|
|
1041
|
-
expect(existsSync(
|
|
1042
|
-
const files = (await readdir(skillsDir)).filter(f => f.endsWith('.md'))
|
|
1043
|
-
expect(files.length).toBeGreaterThan(0)
|
|
1068
|
+
expect(existsSync(join(tmpDir, '.agents', 'skills', 'sanity-cms', 'SKILL.md'))).toBe(true)
|
|
1069
|
+
expect(existsSync(join(tmpDir, '.windsurf', 'rules', 'skills'))).toBe(false)
|
|
1044
1070
|
})
|
|
1045
1071
|
|
|
1046
|
-
it('
|
|
1072
|
+
it('writes MCP servers to .devin/mcp_config.json, the project file Devin Local reads', async () => {
|
|
1047
1073
|
const adapter = await IDE_ADAPTERS['windsurf']()
|
|
1048
1074
|
await adapter.install(PKG_ROOT, tmpDir, STACK_SANITY_LINEAR)
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
const mcp = await readJson(mcpPath)
|
|
1075
|
+
expect(existsSync(join(tmpDir, '.windsurf', 'mcp.json'))).toBe(false)
|
|
1076
|
+
const mcp = await readJson(join(tmpDir, '.devin', 'mcp_config.json'))
|
|
1052
1077
|
expect(mcp).toHaveProperty('mcpServers')
|
|
1053
1078
|
})
|
|
1054
1079
|
|
|
@@ -1058,7 +1083,8 @@ describe('Windsurf adapter install', () => {
|
|
|
1058
1083
|
expect(paths.merged).toContain('.windsurfrules')
|
|
1059
1084
|
expect(paths.framework).not.toContain('.windsurfrules')
|
|
1060
1085
|
expect(paths.framework.some(p => p.includes('.windsurf/rules/'))).toBe(true)
|
|
1061
|
-
expect(paths.customizable).toContain('.
|
|
1086
|
+
expect(paths.customizable).toContain('.devin/mcp_config.json')
|
|
1087
|
+
expect(paths.framework).toContain('.agents/skills/')
|
|
1062
1088
|
})
|
|
1063
1089
|
})
|
|
1064
1090
|
|
|
@@ -1135,6 +1161,20 @@ describe('Antigravity adapter install', () => {
|
|
|
1135
1161
|
expect(content).toContain('.agents/')
|
|
1136
1162
|
})
|
|
1137
1163
|
|
|
1164
|
+
it('points GEMINI.md at AGENTS.md when Codex or OpenCode writes it, so instructions load once', async () => {
|
|
1165
|
+
const both: StackConfig = { ...STACK_SANITY_LINEAR, ides: ['antigravity', 'codex'] }
|
|
1166
|
+
for (const ide of ['antigravity', 'codex'] as const) await (await IDE_ADAPTERS[ide]()).install(PKG_ROOT, tmpDir, both)
|
|
1167
|
+
const gemini = await readFile(join(tmpDir, 'GEMINI.md'), 'utf8')
|
|
1168
|
+
expect(gemini).toContain('are in `AGENTS.md`, which this assistant also reads')
|
|
1169
|
+
expect(gemini).not.toContain('## Available Skills')
|
|
1170
|
+
expect(await readFile(join(tmpDir, 'AGENTS.md'), 'utf8')).toContain('## Available Skills')
|
|
1171
|
+
|
|
1172
|
+
// Alone, it carries everything itself.
|
|
1173
|
+
await rm(join(tmpDir, 'GEMINI.md'))
|
|
1174
|
+
await (await IDE_ADAPTERS['antigravity']()).install(PKG_ROOT, tmpDir, { ...both, ides: ['antigravity'] })
|
|
1175
|
+
expect(await readFile(join(tmpDir, 'GEMINI.md'), 'utf8')).toContain('## Available Skills')
|
|
1176
|
+
})
|
|
1177
|
+
|
|
1138
1178
|
it('creates files in .agents/ directory structure', async () => {
|
|
1139
1179
|
const adapter = await IDE_ADAPTERS['antigravity']()
|
|
1140
1180
|
await adapter.install(PKG_ROOT, tmpDir, STACK_SANITY_LINEAR)
|
|
@@ -1332,11 +1372,11 @@ describe('full stack configuration', () => {
|
|
|
1332
1372
|
|
|
1333
1373
|
// All 5 plugin skills should be installed
|
|
1334
1374
|
const skills = await readdir(join(tempDir, '.github', 'skills'))
|
|
1335
|
-
expect(skills).toContain('sanity')
|
|
1336
|
-
expect(skills).toContain('supabase')
|
|
1337
|
-
expect(skills).toContain('vercel')
|
|
1338
|
-
expect(skills).toContain('linear')
|
|
1339
|
-
expect(skills).toContain('slack')
|
|
1375
|
+
expect(skills).toContain('sanity-cms')
|
|
1376
|
+
expect(skills).toContain('supabase-database')
|
|
1377
|
+
expect(skills).toContain('vercel-deployment')
|
|
1378
|
+
expect(skills).toContain('linear-task-management')
|
|
1379
|
+
expect(skills).toContain('slack-notifications')
|
|
1340
1380
|
|
|
1341
1381
|
// MCP config should have all 5 servers
|
|
1342
1382
|
const mcpConfig = await readJson<Record<string, unknown>>(
|
package/src/cli/layers.test.ts
CHANGED
|
@@ -192,7 +192,7 @@ describe('resolving layers', () => {
|
|
|
192
192
|
expect(messages).toContain('"@acme/missing", which is not installed')
|
|
193
193
|
expect(messages).toContain('version belongs in package.json')
|
|
194
194
|
expect(messages).toContain('an absolute path')
|
|
195
|
-
expect(messages).toContain('"plain", which is
|
|
195
|
+
expect(messages).toContain('"plain", which is neither an OpenCastle baseline nor an Agent Plugin')
|
|
196
196
|
expect(hasErrors(r)).toBe(true)
|
|
197
197
|
})
|
|
198
198
|
|
|
@@ -340,7 +340,7 @@ describe('the merged source and the lock', () => {
|
|
|
340
340
|
const stack: StackConfig = { ides: ['claude-code'], techTools: ['sentry'], teamTools: [] }
|
|
341
341
|
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot)
|
|
342
342
|
try {
|
|
343
|
-
expect(readdirSync(join(src.root, 'skills', 'sentry'))).toEqual(['SKILL.md'])
|
|
343
|
+
expect(readdirSync(join(src.root, 'skills', 'sentry-monitoring'))).toEqual(['SKILL.md'])
|
|
344
344
|
} finally {
|
|
345
345
|
src.dispose()
|
|
346
346
|
}
|
package/src/cli/layers.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { packageLaunch, isPinned } from './mcp-audit.js'
|
|
|
20
20
|
import { disallowedBy, hostDisallowedBy, findInlineSecret, emptyPolicy, globMatch, hostOfUrl, hostAllowedBy, type EffectivePolicy } from './policy.js'
|
|
21
21
|
import { LOCAL_DIRS } from './gitignore.js'
|
|
22
22
|
import { satisfies, parseVersion, compareVersions } from './version-range.js'
|
|
23
|
+
import { EXTENSION_NAMESPACE, isAgentPlugin, readAgentPlugin, teamServerFor } from './agent-plugin.js'
|
|
23
24
|
import {
|
|
24
25
|
CONTENT_KINDS,
|
|
25
26
|
TEAM_CONFIG_REL,
|
|
@@ -61,6 +62,14 @@ export interface Layer {
|
|
|
61
62
|
configFile?: string
|
|
62
63
|
/** A digest of the layer's content, so a baseline that changed without a version bump still shows. */
|
|
63
64
|
integrity?: string
|
|
65
|
+
/**
|
|
66
|
+
* For a baseline that is an Agent Plugin: the `dev.opencastle/` directory
|
|
67
|
+
* holding everything but skills — instructions, agents, prompts, workflows
|
|
68
|
+
* and `config.json`. Skills stay in the plugin's own `skills/`.
|
|
69
|
+
*/
|
|
70
|
+
extensionRoot?: string
|
|
71
|
+
/** Servers that came from a plugin's `mcp.json`, and the file to name for each. */
|
|
72
|
+
serverWhere?: Record<string, string>
|
|
64
73
|
}
|
|
65
74
|
|
|
66
75
|
export interface ContentItem {
|
|
@@ -259,7 +268,7 @@ function scanLayer(layer: Layer, projectRoot: string | null): { items: ContentIt
|
|
|
259
268
|
})
|
|
260
269
|
}
|
|
261
270
|
for (const kind of CONTENT_KINDS) {
|
|
262
|
-
const dir = join(layer.root, dirs[kind])
|
|
271
|
+
const dir = join(kind !== 'skills' && layer.extensionRoot ? layer.extensionRoot : layer.root, dirs[kind])
|
|
263
272
|
for (const entry of listDir(dir, within, skipped)) {
|
|
264
273
|
if (kind === 'skills') {
|
|
265
274
|
if (!entry.isDir) continue
|
|
@@ -351,6 +360,18 @@ function findPackageDir(name: string, fromDir: string): string | null {
|
|
|
351
360
|
}
|
|
352
361
|
}
|
|
353
362
|
|
|
363
|
+
/** Where a package is found under `node_modules`, before any link is followed. */
|
|
364
|
+
function packageLink(name: string, fromDir: string): string | null {
|
|
365
|
+
let dir = fromDir
|
|
366
|
+
for (;;) {
|
|
367
|
+
const candidate = join(dir, 'node_modules', ...name.split('/'))
|
|
368
|
+
if (existsSync(join(candidate, 'package.json'))) return candidate
|
|
369
|
+
const parent = dirname(dir)
|
|
370
|
+
if (parent === dir) return null
|
|
371
|
+
dir = parent
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
354
375
|
function readLayerConfig(root: string, where: string): { config: TeamConfig; issues: TeamIssue[] } {
|
|
355
376
|
const file = join(root, LAYER_CONFIG_FILE)
|
|
356
377
|
if (!existsSync(file)) return { config: {}, issues: [] }
|
|
@@ -396,9 +417,13 @@ function loadExtends(
|
|
|
396
417
|
let id: string
|
|
397
418
|
let version: string | undefined
|
|
398
419
|
let configWhere: string
|
|
420
|
+
// Where the layer is as the project sees it — `node_modules/@acme/x`, not
|
|
421
|
+
// the store path a link resolves to — for paths written into its configs.
|
|
422
|
+
let seenAt: string
|
|
399
423
|
|
|
400
424
|
if (spec.startsWith('./') || spec.startsWith('../')) {
|
|
401
425
|
root = resolve(fromDir, spec)
|
|
426
|
+
seenAt = root
|
|
402
427
|
if (!existsSync(root) || !statSync(root).isDirectory()) {
|
|
403
428
|
fail(`extends "${spec}", which is not a directory (looked in ${display(ctx.projectRoot, root)})`)
|
|
404
429
|
return
|
|
@@ -456,14 +481,19 @@ function loadExtends(
|
|
|
456
481
|
return
|
|
457
482
|
}
|
|
458
483
|
const decl = pkg.opencastle as { baseline?: unknown } | undefined
|
|
459
|
-
|
|
484
|
+
const declared = decl && typeof decl === 'object' && 'baseline' in decl && typeof decl.baseline === 'string'
|
|
485
|
+
// Any Agent Plugin published to npm can be extended as it is: its skills
|
|
486
|
+
// and portable servers are what a baseline's are.
|
|
487
|
+
if (!declared && !isAgentPlugin(pkgDir)) {
|
|
460
488
|
fail(
|
|
461
|
-
`extends "${spec}", which is
|
|
462
|
-
`a baseline declares itself in its package.json: "opencastle": { "baseline": "." } (opencastle baseline init creates one)`,
|
|
489
|
+
`extends "${spec}", which is neither an OpenCastle baseline nor an Agent Plugin`,
|
|
490
|
+
`a baseline declares itself in its package.json: "opencastle": { "baseline": "." } (opencastle baseline init creates one); an Agent Plugin has a plugin.json at its root`,
|
|
463
491
|
)
|
|
464
492
|
return
|
|
465
493
|
}
|
|
466
|
-
root = resolve(pkgDir, decl.baseline)
|
|
494
|
+
root = declared ? resolve(pkgDir, (decl as { baseline: string }).baseline) : pkgDir
|
|
495
|
+
const linked = packageLink(spec, fromDir)
|
|
496
|
+
seenAt = linked ? resolve(linked, relative(pkgDir, root)) : root
|
|
467
497
|
if (relative(pkgDir, root).startsWith('..') || !existsSync(root)) {
|
|
468
498
|
fail(`extends "${spec}", whose "opencastle.baseline" points outside the package or at nothing`)
|
|
469
499
|
return
|
|
@@ -489,6 +519,16 @@ function loadExtends(
|
|
|
489
519
|
if (ctx.seen.has(real)) return
|
|
490
520
|
ctx.seen.add(real)
|
|
491
521
|
|
|
522
|
+
if (isAgentPlugin(root)) {
|
|
523
|
+
const plugin = loadPluginLayer(root, seenAt, id, declaredIn, ctx)
|
|
524
|
+
if (!plugin) return
|
|
525
|
+
for (const inner of plugin.config.extends ?? []) {
|
|
526
|
+
loadExtends(inner, plugin.extensionRoot, plugin.configFile, [...chain, real], ctx)
|
|
527
|
+
}
|
|
528
|
+
ctx.layers.push({ id, kind: 'baseline', root, version: version ?? plugin.version, integrity: layerIntegrity(root), ...plugin })
|
|
529
|
+
return
|
|
530
|
+
}
|
|
531
|
+
|
|
492
532
|
const { config, issues } = readLayerConfig(root, configWhere)
|
|
493
533
|
ctx.issues.push(...issues)
|
|
494
534
|
for (const inner of config.extends ?? []) {
|
|
@@ -497,6 +537,71 @@ function loadExtends(
|
|
|
497
537
|
ctx.layers.push({ id, kind: 'baseline', root, version, config, configFile: configWhere, integrity: layerIntegrity(root) })
|
|
498
538
|
}
|
|
499
539
|
|
|
540
|
+
/**
|
|
541
|
+
* A baseline that is an Agent Plugin: its skills in `skills/`, its portable
|
|
542
|
+
* servers in `mcp.json`, and OpenCastle's own content and config in
|
|
543
|
+
* `dev.opencastle/`. Returns null, having said why, for one a conformant
|
|
544
|
+
* client would refuse.
|
|
545
|
+
*
|
|
546
|
+
* A server or skill a client would skip is reported, not fatal, as the
|
|
547
|
+
* standard has it: one bad component does not stop the rest from loading.
|
|
548
|
+
*/
|
|
549
|
+
function loadPluginLayer(
|
|
550
|
+
root: string,
|
|
551
|
+
seenAt: string,
|
|
552
|
+
id: string,
|
|
553
|
+
declaredIn: string,
|
|
554
|
+
ctx: ExtendsContext,
|
|
555
|
+
): { config: TeamConfig; configFile: string; extensionRoot: string; serverWhere: Record<string, string>; version?: string } | null {
|
|
556
|
+
const report = readAgentPlugin(root)
|
|
557
|
+
if (!report.manifest) {
|
|
558
|
+
ctx.issues.push({
|
|
559
|
+
level: 'error',
|
|
560
|
+
where: declaredIn,
|
|
561
|
+
message: `extends ${id}, which is not a valid Agent Plugin: ${report.errors[0] ?? 'its plugin.json cannot be read'}`,
|
|
562
|
+
fix: `run opencastle plugin check on it`,
|
|
563
|
+
})
|
|
564
|
+
return null
|
|
565
|
+
}
|
|
566
|
+
// `skills/x/SKILL.md: name … must match` — the file, then what is wrong with it.
|
|
567
|
+
for (const e of report.errors) {
|
|
568
|
+
const at = e.indexOf(': ')
|
|
569
|
+
ctx.issues.push({ level: 'warning', where: `${id}/${e.slice(0, at)}`, message: e.slice(at + 2) })
|
|
570
|
+
}
|
|
571
|
+
const extensionRoot = join(root, EXTENSION_NAMESPACE)
|
|
572
|
+
const configFile = `${id}/${EXTENSION_NAMESPACE}/${LAYER_CONFIG_FILE}`
|
|
573
|
+
const { config, issues } = readLayerConfig(extensionRoot, configFile)
|
|
574
|
+
ctx.issues.push(...issues)
|
|
575
|
+
const servers: Record<string, TeamMcpServer> = { ...(config.mcpServers ?? {}) }
|
|
576
|
+
const serverWhere: Record<string, string> = {}
|
|
577
|
+
const pluginPath = posix(relative(ctx.projectRoot, seenAt))
|
|
578
|
+
for (const [key, portable] of Object.entries(report.servers)) {
|
|
579
|
+
if (key in servers) {
|
|
580
|
+
ctx.issues.push({
|
|
581
|
+
level: 'error',
|
|
582
|
+
where: `${id}/mcp.json`,
|
|
583
|
+
message: `defines MCP server "${key}", which ${configFile} defines too`,
|
|
584
|
+
fix: 'keep one: mcp.json for a server every assistant can start as it is, config.json for one that needs ${NAME} variables',
|
|
585
|
+
})
|
|
586
|
+
continue
|
|
587
|
+
}
|
|
588
|
+
const { server, skipped } = teamServerFor(portable, pluginPath)
|
|
589
|
+
if (!server) {
|
|
590
|
+
ctx.issues.push({ level: 'warning', where: `${id}/mcp.json`, message: `MCP server "${key}" ${skipped}` })
|
|
591
|
+
continue
|
|
592
|
+
}
|
|
593
|
+
servers[key] = server
|
|
594
|
+
serverWhere[key] = `${id}/mcp.json`
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
config: { ...config, ...(Object.keys(servers).length > 0 && { mcpServers: servers }) },
|
|
598
|
+
configFile,
|
|
599
|
+
extensionRoot,
|
|
600
|
+
serverWhere,
|
|
601
|
+
version: report.manifest.version,
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
500
605
|
/** `${VAR}`, `${env:VAR}` and `{env:VAR}` all mean the same variable. */
|
|
501
606
|
export function normaliseRefs(value: string): string {
|
|
502
607
|
return value.replace(/\$\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g, '${$1}').replace(/(?<!\$)\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g, '${$1}')
|
|
@@ -563,31 +668,55 @@ export function resolveSources(opts: ResolveOptions): ResolvedSources {
|
|
|
563
668
|
items.set(key(item), item)
|
|
564
669
|
remember(key(item), item)
|
|
565
670
|
}
|
|
566
|
-
// Integration skills:
|
|
671
|
+
// Integration skills: each integration is an Agent Plugin, and its skill sits
|
|
672
|
+
// where the standard puts one — `skills/<name>/SKILL.md`, named as its
|
|
673
|
+
// directory is. They used to be compiled under the integration's id
|
|
674
|
+
// (`skills/supabase/`) while their frontmatter said `supabase-database`, and
|
|
675
|
+
// an assistant that follows the Agent Skills spec skips a skill whose name
|
|
676
|
+
// does not match its directory.
|
|
567
677
|
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
568
678
|
const includedPlugins = stack ? getIncludedPluginIds(stack) : null
|
|
569
679
|
for (const entry of listDir(pluginsRoot)) {
|
|
570
680
|
if (!entry.isDir) continue
|
|
571
|
-
const
|
|
681
|
+
const name = PLUGINS[entry.name]?.skillName
|
|
682
|
+
if (!name) continue
|
|
683
|
+
const skill = join(pluginsRoot, entry.name, 'skills', name, 'SKILL.md')
|
|
572
684
|
if (!existsSync(skill)) continue
|
|
573
685
|
if (includedPlugins && !includedPlugins.has(entry.name)) {
|
|
574
|
-
stackOut.add(`skills/${
|
|
686
|
+
stackOut.add(`skills/${name}`)
|
|
575
687
|
continue
|
|
576
688
|
}
|
|
577
|
-
const k = `skills/${
|
|
689
|
+
const k = `skills/${name}`
|
|
578
690
|
const prev = items.get(k)
|
|
579
|
-
const item: ContentItem = { kind: 'skills', name
|
|
691
|
+
const item: ContentItem = { kind: 'skills', name, layer: 'opencastle', path: skill, plugin: entry.name, ...(prev && { overrides: prev.layer }) }
|
|
580
692
|
items.set(k, item)
|
|
581
693
|
remember(k, item)
|
|
582
694
|
}
|
|
695
|
+
// `skills/supabase`, as a layer wrote it before integration skills took their
|
|
696
|
+
// own names, still means the integration's skill.
|
|
697
|
+
const integrationSkill = (ref: string): string | null => {
|
|
698
|
+
const m = /^skills\/(.+)$/.exec(ref)
|
|
699
|
+
const name = m ? PLUGINS[m[1]]?.skillName : undefined
|
|
700
|
+
return name && name !== m![1] ? `skills/${name}` : null
|
|
701
|
+
}
|
|
583
702
|
|
|
584
703
|
const excluded: ResolvedSources['excluded'] = []
|
|
585
704
|
for (const layer of layers) {
|
|
586
705
|
if (layer.kind === 'core') continue
|
|
587
706
|
const where = layer.configFile ?? layer.id
|
|
588
|
-
for (const
|
|
707
|
+
for (const written of layer.config.exclude ?? []) {
|
|
589
708
|
// Servers are excluded where servers are merged, below.
|
|
590
|
-
if (
|
|
709
|
+
if (written.startsWith('mcpServers/')) continue
|
|
710
|
+
const renamed = items.has(written) ? null : integrationSkill(written)
|
|
711
|
+
if (renamed) {
|
|
712
|
+
issues.push({
|
|
713
|
+
level: 'warning',
|
|
714
|
+
where,
|
|
715
|
+
message: `excludes ${written}; integration skills are named for what they teach now — this means ${renamed}`,
|
|
716
|
+
fix: `write "${renamed}"`,
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
const ref = renamed ?? written
|
|
591
720
|
const prev = items.get(ref)
|
|
592
721
|
if (prev) {
|
|
593
722
|
items.delete(ref)
|
|
@@ -735,7 +864,8 @@ export function resolveSources(opts: ResolveOptions): ResolvedSources {
|
|
|
735
864
|
excluded.push({ ref, by: layer.id, from: 'mcp' })
|
|
736
865
|
}
|
|
737
866
|
for (const [k, raw] of Object.entries(layer.config.mcpServers ?? {})) {
|
|
738
|
-
const
|
|
867
|
+
const serverWhere = layer.serverWhere?.[k] ?? where
|
|
868
|
+
const shape = checkServerShape(k, raw, serverWhere)
|
|
739
869
|
if (shape.length > 0) {
|
|
740
870
|
issues.push(...shape)
|
|
741
871
|
continue
|
|
@@ -749,7 +879,7 @@ export function resolveSources(opts: ResolveOptions): ResolvedSources {
|
|
|
749
879
|
headers: Object.fromEntries(Object.entries(raw.headers).map(([n, val]) => [n, normaliseRefs(val)])),
|
|
750
880
|
}),
|
|
751
881
|
}
|
|
752
|
-
servers.set(k, { key: k, from: layer.id, server, where })
|
|
882
|
+
servers.set(k, { key: k, from: layer.id, server, where: serverWhere })
|
|
753
883
|
excludedServers.delete(k)
|
|
754
884
|
}
|
|
755
885
|
}
|