opencastle 0.38.2 → 1.1.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 +89 -4
- package/bin/cli.mjs +20 -3
- package/dist/cli/adapters/antigravity.d.ts +1 -1
- package/dist/cli/adapters/antigravity.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.d.ts +8 -4
- package/dist/cli/adapters/claude-code.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.js +13 -7
- package/dist/cli/adapters/claude-code.js.map +1 -1
- package/dist/cli/adapters/codex.d.ts +1 -1
- package/dist/cli/adapters/codex.d.ts.map +1 -1
- package/dist/cli/adapters/cursor.d.ts +1 -1
- package/dist/cli/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/adapters/opencode.d.ts +1 -1
- package/dist/cli/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.d.ts +3 -2
- package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +13 -25
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +8 -1
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +43 -46
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts +14 -3
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +63 -75
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/adapters/windsurf.d.ts +1 -1
- package/dist/cli/adapters/windsurf.d.ts.map +1 -1
- package/dist/cli/baseline.d.ts +3 -0
- package/dist/cli/baseline.d.ts.map +1 -0
- package/dist/cli/baseline.js +280 -0
- package/dist/cli/baseline.js.map +1 -0
- package/dist/cli/ci.d.ts +18 -0
- package/dist/cli/ci.d.ts.map +1 -0
- package/dist/cli/ci.js +279 -0
- package/dist/cli/ci.js.map +1 -0
- package/dist/cli/command-namespace.d.ts +91 -0
- package/dist/cli/command-namespace.d.ts.map +1 -0
- package/dist/cli/command-namespace.js +218 -0
- package/dist/cli/command-namespace.js.map +1 -0
- package/dist/cli/command-namespace.test.d.ts +2 -0
- package/dist/cli/command-namespace.test.d.ts.map +1 -0
- package/dist/cli/command-namespace.test.js +356 -0
- package/dist/cli/command-namespace.test.js.map +1 -0
- package/dist/cli/copy.d.ts +1 -1
- package/dist/cli/copy.d.ts.map +1 -1
- package/dist/cli/copy.js +3 -2
- 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 +5 -0
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts +3 -3
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +66 -9
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/doctor.test.js +2 -2
- package/dist/cli/doctor.test.js.map +1 -1
- package/dist/cli/explain.d.ts +3 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +222 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/fleet.d.ts +30 -0
- package/dist/cli/fleet.d.ts.map +1 -0
- package/dist/cli/fleet.js +149 -0
- package/dist/cli/fleet.js.map +1 -0
- package/dist/cli/github-report.d.ts +49 -0
- package/dist/cli/github-report.d.ts.map +1 -0
- package/dist/cli/github-report.js +161 -0
- package/dist/cli/github-report.js.map +1 -0
- package/dist/cli/github-report.test.d.ts +2 -0
- package/dist/cli/github-report.test.d.ts.map +1 -0
- package/dist/cli/github-report.test.js +146 -0
- package/dist/cli/github-report.test.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +171 -96
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +35 -29
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts +152 -0
- package/dist/cli/layers.d.ts.map +1 -0
- package/dist/cli/layers.js +932 -0
- package/dist/cli/layers.js.map +1 -0
- package/dist/cli/layers.test.d.ts +2 -0
- package/dist/cli/layers.test.d.ts.map +1 -0
- package/dist/cli/layers.test.js +483 -0
- package/dist/cli/layers.test.js.map +1 -0
- package/dist/cli/lock.d.ts +130 -0
- package/dist/cli/lock.d.ts.map +1 -0
- package/dist/cli/lock.js +320 -0
- package/dist/cli/lock.js.map +1 -0
- package/dist/cli/managed-paths.d.ts +18 -1
- package/dist/cli/managed-paths.d.ts.map +1 -1
- package/dist/cli/managed-paths.js +72 -2
- package/dist/cli/managed-paths.js.map +1 -1
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +2 -0
- package/dist/cli/manifest.js.map +1 -1
- package/dist/cli/mcp-audit.d.ts +164 -0
- package/dist/cli/mcp-audit.d.ts.map +1 -0
- package/dist/cli/mcp-audit.js +504 -0
- package/dist/cli/mcp-audit.js.map +1 -0
- package/dist/cli/mcp-audit.test.d.ts +2 -0
- package/dist/cli/mcp-audit.test.d.ts.map +1 -0
- package/dist/cli/mcp-audit.test.js +215 -0
- package/dist/cli/mcp-audit.test.js.map +1 -0
- package/dist/cli/mcp-upgrade.test.d.ts +2 -0
- package/dist/cli/mcp-upgrade.test.d.ts.map +1 -0
- package/dist/cli/mcp-upgrade.test.js +118 -0
- package/dist/cli/mcp-upgrade.test.js.map +1 -0
- package/dist/cli/mcp.d.ts +74 -5
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +340 -32
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/policy.d.ts +58 -0
- package/dist/cli/policy.d.ts.map +1 -0
- package/dist/cli/policy.js +194 -0
- package/dist/cli/policy.js.map +1 -0
- package/dist/cli/publish-workflow.test.js +55 -1
- package/dist/cli/publish-workflow.test.js.map +1 -1
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +25 -6
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/review.d.ts +25 -0
- package/dist/cli/review.d.ts.map +1 -0
- package/dist/cli/review.js +437 -0
- package/dist/cli/review.js.map +1 -0
- package/dist/cli/status.d.ts +2 -0
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +25 -4
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/status.test.js +5 -3
- package/dist/cli/status.test.js.map +1 -1
- package/dist/cli/sync-check.d.ts +16 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +241 -17
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +14 -8
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -0
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/team-ci.test.d.ts +2 -0
- package/dist/cli/team-ci.test.d.ts.map +1 -0
- package/dist/cli/team-ci.test.js +169 -0
- package/dist/cli/team-ci.test.js.map +1 -0
- package/dist/cli/team-commands.test.d.ts +2 -0
- package/dist/cli/team-commands.test.d.ts.map +1 -0
- package/dist/cli/team-commands.test.js +233 -0
- package/dist/cli/team-commands.test.js.map +1 -0
- package/dist/cli/team-config.d.ts +88 -0
- package/dist/cli/team-config.d.ts.map +1 -0
- package/dist/cli/team-config.js +261 -0
- package/dist/cli/team-config.js.map +1 -0
- package/dist/cli/team-health.d.ts +49 -0
- package/dist/cli/team-health.d.ts.map +1 -0
- package/dist/cli/team-health.js +205 -0
- package/dist/cli/team-health.js.map +1 -0
- package/dist/cli/team-sources.test.d.ts +2 -0
- package/dist/cli/team-sources.test.d.ts.map +1 -0
- package/dist/cli/team-sources.test.js +542 -0
- package/dist/cli/team-sources.test.js.map +1 -0
- package/dist/cli/types.d.ts +48 -2
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +218 -44
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/version-range.d.ts +24 -0
- package/dist/cli/version-range.d.ts.map +1 -0
- package/dist/cli/version-range.js +157 -0
- package/dist/cli/version-range.js.map +1 -0
- package/dist/cli/website-plugins.test.d.ts +2 -0
- package/dist/cli/website-plugins.test.d.ts.map +1 -0
- package/dist/cli/website-plugins.test.js +34 -0
- package/dist/cli/website-plugins.test.js.map +1 -0
- package/dist/orchestrator/plugins/chrome-devtools/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/chrome-devtools/config.js +11 -1
- package/dist/orchestrator/plugins/chrome-devtools/config.js.map +1 -1
- package/dist/orchestrator/plugins/contentful/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/contentful/config.js +11 -1
- package/dist/orchestrator/plugins/contentful/config.js.map +1 -1
- package/dist/orchestrator/plugins/convex/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/convex/config.js +11 -1
- package/dist/orchestrator/plugins/convex/config.js.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.js +14 -1
- package/dist/orchestrator/plugins/coolify/config.js.map +1 -1
- package/dist/orchestrator/plugins/figma/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/figma/config.js +24 -13
- package/dist/orchestrator/plugins/figma/config.js.map +1 -1
- package/dist/orchestrator/plugins/linear/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/linear/config.js +27 -17
- package/dist/orchestrator/plugins/linear/config.js.map +1 -1
- package/dist/orchestrator/plugins/netlify/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/netlify/config.js +23 -9
- package/dist/orchestrator/plugins/netlify/config.js.map +1 -1
- package/dist/orchestrator/plugins/nextjs/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/nextjs/config.js +11 -1
- package/dist/orchestrator/plugins/nextjs/config.js.map +1 -1
- package/dist/orchestrator/plugins/nx/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/nx/config.js +11 -1
- package/dist/orchestrator/plugins/nx/config.js.map +1 -1
- package/dist/orchestrator/plugins/pins.test.d.ts +2 -0
- package/dist/orchestrator/plugins/pins.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/pins.test.js +78 -0
- package/dist/orchestrator/plugins/pins.test.js.map +1 -0
- package/dist/orchestrator/plugins/playwright/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/playwright/config.js +11 -1
- package/dist/orchestrator/plugins/playwright/config.js.map +1 -1
- package/dist/orchestrator/plugins/prisma/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/prisma/config.js +17 -2
- package/dist/orchestrator/plugins/prisma/config.js.map +1 -1
- package/dist/orchestrator/plugins/resend/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/resend/config.js +17 -1
- package/dist/orchestrator/plugins/resend/config.js.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.js +13 -1
- package/dist/orchestrator/plugins/sentry/config.js.map +1 -1
- package/dist/orchestrator/plugins/slack/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/slack/config.js +20 -1
- package/dist/orchestrator/plugins/slack/config.js.map +1 -1
- package/dist/orchestrator/plugins/strapi/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/strapi/config.js +11 -1
- package/dist/orchestrator/plugins/strapi/config.js.map +1 -1
- package/dist/orchestrator/plugins/trello/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/trello/config.js +21 -1
- package/dist/orchestrator/plugins/trello/config.js.map +1 -1
- package/dist/orchestrator/plugins/types.d.ts +22 -0
- package/dist/orchestrator/plugins/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/cli/adapters/claude-code.ts +13 -7
- package/src/cli/adapters/rules-dir-base.ts +23 -44
- package/src/cli/adapters/single-file-base.ts +65 -50
- package/src/cli/adapters/vscode.ts +75 -77
- package/src/cli/baseline.ts +289 -0
- package/src/cli/ci.ts +289 -0
- package/src/cli/command-namespace.test.ts +417 -0
- package/src/cli/command-namespace.ts +222 -0
- package/src/cli/copy.ts +6 -2
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +5 -0
- package/src/cli/doctor.test.ts +2 -2
- package/src/cli/doctor.ts +92 -6
- package/src/cli/explain.ts +222 -0
- package/src/cli/fleet.ts +176 -0
- package/src/cli/github-report.test.ts +158 -0
- package/src/cli/github-report.ts +179 -0
- package/src/cli/init.test.ts +36 -31
- package/src/cli/init.ts +174 -96
- package/src/cli/layers.test.ts +525 -0
- package/src/cli/layers.ts +1089 -0
- package/src/cli/lock.ts +395 -0
- package/src/cli/managed-paths.ts +73 -3
- package/src/cli/manifest.ts +2 -0
- package/src/cli/mcp-audit.test.ts +259 -0
- package/src/cli/mcp-audit.ts +619 -0
- package/src/cli/mcp-upgrade.test.ts +135 -0
- package/src/cli/mcp.ts +373 -34
- package/src/cli/policy.ts +207 -0
- package/src/cli/publish-workflow.test.ts +60 -1
- package/src/cli/remove.ts +28 -6
- package/src/cli/review.ts +457 -0
- package/src/cli/status.test.ts +5 -3
- package/src/cli/status.ts +29 -4
- package/src/cli/sync-check.test.ts +16 -8
- package/src/cli/sync-check.ts +264 -17
- package/src/cli/sync.ts +2 -0
- package/src/cli/team-ci.test.ts +195 -0
- package/src/cli/team-commands.test.ts +253 -0
- package/src/cli/team-config.ts +289 -0
- package/src/cli/team-health.ts +234 -0
- package/src/cli/team-sources.test.ts +578 -0
- package/src/cli/types.ts +51 -1
- package/src/cli/update.ts +229 -44
- package/src/cli/version-range.ts +150 -0
- package/src/cli/website-plugins.test.ts +41 -0
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/plugins/chrome-devtools/config.ts +11 -1
- package/src/orchestrator/plugins/contentful/config.ts +11 -1
- package/src/orchestrator/plugins/convex/config.ts +11 -1
- package/src/orchestrator/plugins/coolify/config.ts +14 -1
- package/src/orchestrator/plugins/figma/SKILL.md +18 -14
- package/src/orchestrator/plugins/figma/config.ts +24 -13
- package/src/orchestrator/plugins/linear/SKILL.md +6 -14
- package/src/orchestrator/plugins/linear/config.ts +27 -17
- package/src/orchestrator/plugins/netlify/config.ts +23 -9
- package/src/orchestrator/plugins/nextjs/config.ts +11 -1
- package/src/orchestrator/plugins/nx/config.ts +11 -1
- package/src/orchestrator/plugins/pins.test.ts +80 -0
- package/src/orchestrator/plugins/playwright/config.ts +11 -1
- package/src/orchestrator/plugins/prisma/config.ts +17 -2
- package/src/orchestrator/plugins/resend/config.ts +17 -1
- package/src/orchestrator/plugins/sentry/config.ts +13 -1
- package/src/orchestrator/plugins/slack/config.ts +20 -1
- package/src/orchestrator/plugins/strapi/config.ts +11 -1
- package/src/orchestrator/plugins/trello/config.ts +21 -1
- package/src/orchestrator/plugins/types.ts +24 -0
- package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -4
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { resolve, join, basename } from 'node:path'
|
|
2
2
|
import { mkdir, writeFile, readdir, readFile, unlink, rename } from 'node:fs/promises'
|
|
3
3
|
import { existsSync, readdirSync, realpathSync } from 'node:fs'
|
|
4
|
-
import {
|
|
4
|
+
import { withSource, type CompileSource } from '../layers.js'
|
|
5
5
|
import { scaffoldMcpConfigInto } from '../mcp.js'
|
|
6
|
-
import { getExcludedSkills, getExcludedAgents, getIncludedPluginIds } from '../stack-config.js'
|
|
7
6
|
import type { CopyResults, DoctorCheck, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
8
7
|
import { splitFrontmatter, parseFrontmatterString } from './frontmatter.js'
|
|
9
8
|
import { writeManagedBlock, recordMerge } from '../managed-block.js'
|
|
@@ -56,8 +55,8 @@ export interface RulesDirConfig {
|
|
|
56
55
|
export interface RulesDirAdapter {
|
|
57
56
|
IDE_ID: IdeChoice
|
|
58
57
|
IDE_LABEL: string
|
|
59
|
-
install(pkgRoot: string, projectRoot: string, stack?: StackConfig, repoInfo?: RepoInfo): Promise<CopyResults>
|
|
60
|
-
update(pkgRoot: string, projectRoot: string, stack?: StackConfig, repoInfo?: RepoInfo): Promise<CopyResults>
|
|
58
|
+
install(pkgRoot: string, projectRoot: string, stack?: StackConfig, repoInfo?: RepoInfo, source?: CompileSource): Promise<CopyResults>
|
|
59
|
+
update(pkgRoot: string, projectRoot: string, stack?: StackConfig, repoInfo?: RepoInfo, source?: CompileSource): Promise<CopyResults>
|
|
61
60
|
getManagedPaths(): ManagedPaths
|
|
62
61
|
getDoctorChecks(): DoctorCheck[]
|
|
63
62
|
}
|
|
@@ -302,42 +301,24 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
302
301
|
}
|
|
303
302
|
}
|
|
304
303
|
|
|
305
|
-
/** Plugin skills land as a single rule file per plugin id. */
|
|
306
|
-
async function convertPluginSkills(
|
|
307
|
-
pkgRoot: string,
|
|
308
|
-
rulesRoot: string,
|
|
309
|
-
results: CopyResults,
|
|
310
|
-
stack: StackConfig | undefined,
|
|
311
|
-
overwrite: boolean,
|
|
312
|
-
): Promise<void> {
|
|
313
|
-
const pluginEntries = await getPluginSkillEntries(
|
|
314
|
-
getPluginsRoot(pkgRoot),
|
|
315
|
-
stack ? getIncludedPluginIds(stack) : undefined,
|
|
316
|
-
)
|
|
317
|
-
const skillsDest = resolve(rulesRoot, 'skills')
|
|
318
|
-
await mkdir(skillsDest, { recursive: true })
|
|
319
|
-
for (const { id, skillPath } of pluginEntries) {
|
|
320
|
-
await writeConverted(
|
|
321
|
-
skillPath,
|
|
322
|
-
resolve(skillsDest, `${id}${ruleExt}`),
|
|
323
|
-
{ descriptionFallback: `Skill: ${id}` },
|
|
324
|
-
results,
|
|
325
|
-
overwrite,
|
|
326
|
-
)
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
304
|
async function install(
|
|
331
305
|
pkgRoot: string,
|
|
332
306
|
projectRoot: string,
|
|
333
307
|
stack?: StackConfig,
|
|
334
308
|
repoInfo?: RepoInfo,
|
|
309
|
+
source?: CompileSource,
|
|
335
310
|
): Promise<CopyResults> {
|
|
336
|
-
|
|
337
|
-
|
|
311
|
+
return withSource(pkgRoot, stack, source, (src) => installFrom(src, projectRoot, stack, repoInfo))
|
|
312
|
+
}
|
|
338
313
|
|
|
339
|
-
|
|
340
|
-
|
|
314
|
+
async function installFrom(
|
|
315
|
+
src: CompileSource,
|
|
316
|
+
projectRoot: string,
|
|
317
|
+
stack: StackConfig | undefined,
|
|
318
|
+
repoInfo: RepoInfo | undefined,
|
|
319
|
+
): Promise<CopyResults> {
|
|
320
|
+
const srcRoot = src.root
|
|
321
|
+
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
341
322
|
|
|
342
323
|
// Merged, not skipped: a project that already has a rules file keeps it and
|
|
343
324
|
// gains the generated pointer in a managed block below.
|
|
@@ -354,10 +335,8 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
354
335
|
await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, {
|
|
355
336
|
descriptionPrefix: 'Agent: ',
|
|
356
337
|
removeExt: '.agent.md',
|
|
357
|
-
excludeFiles: excludedAgents,
|
|
358
338
|
})
|
|
359
|
-
await convertSkills(srcRoot, resolve(rulesRoot, 'skills'), results, false
|
|
360
|
-
await convertPluginSkills(pkgRoot, rulesRoot, results, stack, false)
|
|
339
|
+
await convertSkills(srcRoot, resolve(rulesRoot, 'skills'), results, false)
|
|
361
340
|
await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
|
|
362
341
|
descriptionPrefix: 'Workflow: ',
|
|
363
342
|
excludeFiles: new Set(['README.md']),
|
|
@@ -367,7 +346,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
367
346
|
removeExt: '.prompt.md',
|
|
368
347
|
})
|
|
369
348
|
|
|
370
|
-
await scaffoldMcpConfigInto(results, projectRoot, mcpPath, stack, repoInfo, ideId)
|
|
349
|
+
await scaffoldMcpConfigInto(results, projectRoot, mcpPath, stack, repoInfo, ideId, src.mcp)
|
|
371
350
|
|
|
372
351
|
return results
|
|
373
352
|
}
|
|
@@ -377,12 +356,14 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
377
356
|
projectRoot: string,
|
|
378
357
|
stack?: StackConfig,
|
|
379
358
|
_repoInfo?: RepoInfo,
|
|
359
|
+
source?: CompileSource,
|
|
380
360
|
): Promise<CopyResults> {
|
|
381
|
-
|
|
382
|
-
|
|
361
|
+
return withSource(pkgRoot, stack, source, (src) => updateFrom(src, projectRoot))
|
|
362
|
+
}
|
|
383
363
|
|
|
384
|
-
|
|
385
|
-
const
|
|
364
|
+
async function updateFrom(src: CompileSource, projectRoot: string): Promise<CopyResults> {
|
|
365
|
+
const srcRoot = src.root
|
|
366
|
+
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
386
367
|
|
|
387
368
|
const rootPath = resolve(projectRoot, rootRulesFile)
|
|
388
369
|
const rootMerge = await writeManagedBlock(rootPath, rootIntro)
|
|
@@ -413,10 +394,8 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
413
394
|
descriptionPrefix: 'Agent: ',
|
|
414
395
|
removeExt: '.agent.md',
|
|
415
396
|
overwrite: true,
|
|
416
|
-
excludeFiles: excludedAgents,
|
|
417
397
|
})
|
|
418
|
-
await convertSkills(srcRoot, resolve(rulesRoot, 'skills'), results, true
|
|
419
|
-
await convertPluginSkills(pkgRoot, rulesRoot, results, stack, true)
|
|
398
|
+
await convertSkills(srcRoot, resolve(rulesRoot, 'skills'), results, true)
|
|
420
399
|
await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
|
|
421
400
|
descriptionPrefix: 'Workflow: ',
|
|
422
401
|
overwrite: true,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { resolve, basename, relative } from 'node:path'
|
|
1
|
+
import { resolve, basename, relative, sep } from 'node:path'
|
|
2
2
|
import { mkdir, writeFile, readdir, readFile, rm, rename } from 'node:fs/promises'
|
|
3
3
|
import { existsSync, readdirSync, realpathSync } from 'node:fs'
|
|
4
4
|
import { writeManagedBlock, recordMerge } from '../managed-block.js'
|
|
5
5
|
import { TIERS, TIER_IDS, isTier, tierForAgent, type Tier } from '../tiers.js'
|
|
6
|
-
import { mergeCopyResults, copyDir
|
|
6
|
+
import { mergeCopyResults, copyDir } from '../copy.js'
|
|
7
7
|
import { scaffoldMcpConfigInto } from '../mcp.js'
|
|
8
|
-
import {
|
|
8
|
+
import { withSource, type CompileSource } from '../layers.js'
|
|
9
9
|
import type { CopyResults, DoctorCheck, IdeAdapter, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
10
10
|
import { stripFrontmatter, parseFrontmatterMeta } from './frontmatter.js'
|
|
11
11
|
|
|
@@ -31,6 +31,11 @@ export interface SingleFileAdapterConfig {
|
|
|
31
31
|
workflowPrefix: string
|
|
32
32
|
/** Framework subdirectories (under dotDir) to remove during update */
|
|
33
33
|
frameworkDirs: string[]
|
|
34
|
+
/**
|
|
35
|
+
* Output an earlier release wrote outside today's framework directories,
|
|
36
|
+
* present on disk now, relative to the project root. Removed on update.
|
|
37
|
+
*/
|
|
38
|
+
legacyOutputs?: (_projectRoot: string) => string[]
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
/**
|
|
@@ -109,7 +114,9 @@ async function reconcileCase(onDisk: string, visited: Set<string>): Promise<bool
|
|
|
109
114
|
return false
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
export function createSingleFileAdapter(
|
|
117
|
+
export function createSingleFileAdapter(
|
|
118
|
+
config: SingleFileAdapterConfig,
|
|
119
|
+
): IdeAdapter & { getLegacyOutputs(_projectRoot: string): string[] } {
|
|
113
120
|
/**
|
|
114
121
|
* Write one generated file and report what actually happened to it.
|
|
115
122
|
*
|
|
@@ -169,13 +176,26 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
169
176
|
projectRoot: string,
|
|
170
177
|
stack: StackConfig | undefined,
|
|
171
178
|
repoInfo: RepoInfo | undefined,
|
|
172
|
-
overwrite: boolean
|
|
179
|
+
overwrite: boolean,
|
|
180
|
+
source: CompileSource | undefined,
|
|
173
181
|
): Promise<CopyResults> {
|
|
174
|
-
|
|
175
|
-
|
|
182
|
+
return withSource(pkgRoot, stack, source, (src) => compileFrom(src, projectRoot, stack, repoInfo, overwrite))
|
|
183
|
+
}
|
|
176
184
|
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
/**
|
|
186
|
+
* One pass over the merged source. What the stack leaves out, what a team
|
|
187
|
+
* excluded, and the integrations' skills are already settled in it, so this
|
|
188
|
+
* compiles what it finds.
|
|
189
|
+
*/
|
|
190
|
+
async function compileFrom(
|
|
191
|
+
src: CompileSource,
|
|
192
|
+
projectRoot: string,
|
|
193
|
+
stack: StackConfig | undefined,
|
|
194
|
+
repoInfo: RepoInfo | undefined,
|
|
195
|
+
overwrite: boolean,
|
|
196
|
+
): Promise<CopyResults> {
|
|
197
|
+
const srcRoot = src.root
|
|
198
|
+
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
179
199
|
|
|
180
200
|
// 1. Build root instructions file.
|
|
181
201
|
// Always built: the content goes into a managed block, so a file the user
|
|
@@ -224,7 +244,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
224
244
|
const usedTiers = new Set<Tier>()
|
|
225
245
|
for (const file of (await readdir(agentsDir)).sort()) {
|
|
226
246
|
if (!file.endsWith('.md')) continue
|
|
227
|
-
if (excludedAgents.has(file)) continue
|
|
228
247
|
const meta = parseFrontmatterMeta(
|
|
229
248
|
await readFile(resolve(agentsDir, file), 'utf8')
|
|
230
249
|
)
|
|
@@ -259,10 +278,21 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
259
278
|
).filter((e) => e.isDirectory())
|
|
260
279
|
const skillRef = (name: string): string =>
|
|
261
280
|
`${refDir}/skills/${name}/SKILL.md`
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
281
|
+
// Integration skills are listed after the rest, as they always were:
|
|
282
|
+
// reordering the index would change every root file on upgrade for
|
|
283
|
+
// no reason anyone could see in the diff.
|
|
284
|
+
const integrations = new Set(
|
|
285
|
+
[...src.resolved.items.values()].filter((i) => i.plugin && i.layer === 'opencastle').map((i) => i.name),
|
|
286
|
+
)
|
|
287
|
+
// Code-point order, not the machine's locale: under a Danish or
|
|
288
|
+
// Estonian locale `localeCompare` ordered names differently, and the
|
|
289
|
+
// root file then differed between two teammates' checkouts.
|
|
290
|
+
const byName = (a: { name: string }, b: { name: string }): number => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
|
|
291
|
+
const ordered = [
|
|
292
|
+
...subdirs.filter((e) => !integrations.has(e.name)).sort(byName),
|
|
293
|
+
...subdirs.filter((e) => integrations.has(e.name)).sort(byName),
|
|
294
|
+
]
|
|
295
|
+
for (const entry of ordered) {
|
|
266
296
|
const skillFile = resolve(skillsDir, entry.name, 'SKILL.md')
|
|
267
297
|
if (!existsSync(skillFile)) continue
|
|
268
298
|
const meta = parseFrontmatterMeta(await readFile(skillFile, 'utf8'))
|
|
@@ -272,18 +302,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
272
302
|
)
|
|
273
303
|
}
|
|
274
304
|
|
|
275
|
-
// Plugin skills
|
|
276
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
277
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
278
|
-
const pluginEntries = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
279
|
-
for (const { id, skillPath } of pluginEntries.sort((a, b) => a.id.localeCompare(b.id))) {
|
|
280
|
-
const pluginMeta = parseFrontmatterMeta(await readFile(skillPath, 'utf8'))
|
|
281
|
-
const pluginDesc = pluginMeta['description'] ?? ''
|
|
282
|
-
skillLines.push(
|
|
283
|
-
`- **${id}** (\`${skillRef(id)}\`): ${pluginDesc}`
|
|
284
|
-
)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
305
|
sections.push(skillLines.join('\n'))
|
|
288
306
|
}
|
|
289
307
|
|
|
@@ -300,7 +318,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
300
318
|
await mkdir(destAgents, { recursive: true })
|
|
301
319
|
for (const file of await readdir(agentsDir)) {
|
|
302
320
|
if (!file.endsWith('.md')) continue
|
|
303
|
-
if (excludedAgents.has(file)) continue
|
|
304
321
|
const destPath = resolve(destAgents, file)
|
|
305
322
|
const content = await readFile(resolve(agentsDir, file), 'utf8')
|
|
306
323
|
await emit(projectRoot, destPath, stripFrontmatter(content) + '\n', overwrite, results)
|
|
@@ -318,7 +335,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
318
335
|
await readdir(skillsDir, { withFileTypes: true })
|
|
319
336
|
).filter((e) => e.isDirectory())
|
|
320
337
|
for (const entry of subdirs) {
|
|
321
|
-
if (excludedSkills.has(entry.name)) continue
|
|
322
338
|
const skillFile = resolve(skillsDir, entry.name, 'SKILL.md')
|
|
323
339
|
if (!existsSync(skillFile)) continue
|
|
324
340
|
const sub = await copyDir(
|
|
@@ -338,21 +354,6 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
338
354
|
}
|
|
339
355
|
}
|
|
340
356
|
|
|
341
|
-
// 3b. Plugin skills → dotDir/skills/<plugin-id>/SKILL.md
|
|
342
|
-
{
|
|
343
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
344
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
345
|
-
const pluginEntries = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
346
|
-
const destSkills = resolve(dotDirPath, 'skills')
|
|
347
|
-
await mkdir(destSkills, { recursive: true })
|
|
348
|
-
for (const { id, skillPath } of pluginEntries) {
|
|
349
|
-
const pluginDestDir = resolve(destSkills, id)
|
|
350
|
-
await mkdir(pluginDestDir, { recursive: true })
|
|
351
|
-
const destPath = resolve(pluginDestDir, 'SKILL.md')
|
|
352
|
-
await emit(projectRoot, destPath, await readFile(skillPath, 'utf8'), overwrite, results)
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
357
|
// 4. Prompts → dotDir/<promptsDir>/<name>.md
|
|
357
358
|
const promptDir = resolve(srcRoot, 'prompts')
|
|
358
359
|
if (existsSync(promptDir)) {
|
|
@@ -389,7 +390,8 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
389
390
|
config.mcpConfigPath,
|
|
390
391
|
stack,
|
|
391
392
|
repoInfo,
|
|
392
|
-
config.mcpFormat
|
|
393
|
+
config.mcpFormat,
|
|
394
|
+
src.mcp,
|
|
393
395
|
)
|
|
394
396
|
|
|
395
397
|
return results
|
|
@@ -400,16 +402,18 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
400
402
|
pkgRoot: string,
|
|
401
403
|
projectRoot: string,
|
|
402
404
|
stack?: StackConfig,
|
|
403
|
-
repoInfo?: RepoInfo
|
|
405
|
+
repoInfo?: RepoInfo,
|
|
406
|
+
source?: CompileSource,
|
|
404
407
|
): Promise<CopyResults> {
|
|
405
|
-
return compile(pkgRoot, projectRoot, stack, repoInfo, false)
|
|
408
|
+
return compile(pkgRoot, projectRoot, stack, repoInfo, false, source)
|
|
406
409
|
}
|
|
407
410
|
|
|
408
411
|
async function update(
|
|
409
412
|
pkgRoot: string,
|
|
410
413
|
projectRoot: string,
|
|
411
414
|
stack?: StackConfig,
|
|
412
|
-
repoInfo?: RepoInfo
|
|
415
|
+
repoInfo?: RepoInfo,
|
|
416
|
+
source?: CompileSource,
|
|
413
417
|
): Promise<CopyResults> {
|
|
414
418
|
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
415
419
|
const dotDirPath = resolve(projectRoot, config.dotDir)
|
|
@@ -427,7 +431,7 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
427
431
|
for (const rel of filesUnderDir(dirPath)) {
|
|
428
432
|
before.set(
|
|
429
433
|
resolve(dirPath, rel),
|
|
430
|
-
`${config.dotDir}/${relative(dotDirPath, dirPath)}/${rel}`,
|
|
434
|
+
`${config.dotDir}/${relative(dotDirPath, dirPath).split(sep).join('/')}/${rel}`,
|
|
431
435
|
)
|
|
432
436
|
}
|
|
433
437
|
}
|
|
@@ -444,7 +448,7 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
444
448
|
// written again — and reversing the order silently turned `sync` into a
|
|
445
449
|
// no-op on content. The sweep's job now is only to remove output with no
|
|
446
450
|
// source left, which is the one thing recompiling cannot do.
|
|
447
|
-
const installResult = await compile(pkgRoot, projectRoot, stack, repoInfo, true)
|
|
451
|
+
const installResult = await compile(pkgRoot, projectRoot, stack, repoInfo, true, source)
|
|
448
452
|
|
|
449
453
|
// 4. Now that the new output exists, drop anything stale beside it.
|
|
450
454
|
//
|
|
@@ -462,6 +466,13 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
462
466
|
await rm(abs, { force: true })
|
|
463
467
|
}
|
|
464
468
|
}
|
|
469
|
+
// What an earlier release put where this one no longer writes — the
|
|
470
|
+
// un-namespaced commands at the top of `.claude/commands/`. Asked after the
|
|
471
|
+
// recompile, so a failure there leaves the old commands working.
|
|
472
|
+
for (const rel of getLegacyOutputs(projectRoot)) {
|
|
473
|
+
await rm(resolve(projectRoot, rel), { force: true })
|
|
474
|
+
;(results.deleted ??= []).push(rel)
|
|
475
|
+
}
|
|
465
476
|
// Pass the three categories through as they came back. Folding `created`
|
|
466
477
|
// into `copied` was how "Updated N framework files" stayed plausible while
|
|
467
478
|
// nothing was being rewritten — the count was of files visited, not changed.
|
|
@@ -490,6 +501,10 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
490
501
|
return results
|
|
491
502
|
}
|
|
492
503
|
|
|
504
|
+
function getLegacyOutputs(projectRoot: string): string[] {
|
|
505
|
+
return config.legacyOutputs?.(projectRoot) ?? []
|
|
506
|
+
}
|
|
507
|
+
|
|
493
508
|
function getManagedPaths(): ManagedPaths {
|
|
494
509
|
// Deduplicate dirs (e.g. promptsDir === workflowsDir for claude-code's 'commands')
|
|
495
510
|
const dirs = new Set(['agents', 'skills', ...config.frameworkDirs])
|
|
@@ -515,7 +530,7 @@ export function createSingleFileAdapter(config: SingleFileAdapterConfig): IdeAda
|
|
|
515
530
|
return checks
|
|
516
531
|
}
|
|
517
532
|
|
|
518
|
-
return { install, update, getManagedPaths, getDoctorChecks }
|
|
533
|
+
return { install, update, getManagedPaths, getDoctorChecks, getLegacyOutputs }
|
|
519
534
|
}
|
|
520
535
|
|
|
521
536
|
/** Every file under a directory, relative to it. */
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { resolve } from 'node:path'
|
|
2
|
-
import { mkdir, readFile,
|
|
1
|
+
import { basename, resolve } from 'node:path'
|
|
2
|
+
import { mkdir, readFile, unlink, rename } from 'node:fs/promises'
|
|
3
3
|
import { existsSync, readdirSync, realpathSync } from 'node:fs'
|
|
4
4
|
import { writeManagedBlock, recordMerge } from '../managed-block.js'
|
|
5
|
-
import { mergeCopyResults, copyDir
|
|
5
|
+
import { mergeCopyResults, copyDir } from '../copy.js'
|
|
6
6
|
import { scaffoldMcpConfigInto } from '../mcp.js'
|
|
7
|
-
import {
|
|
7
|
+
import { getAgentTransform } from '../stack-config.js'
|
|
8
|
+
import { withSource, type CompileSource } from '../layers.js'
|
|
8
9
|
import type { CopyResults, CopyDirOptions, DoctorCheck, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
10
|
+
import { isOurVscodePrompt, legacyVscodePrompts, vscodePromptFile, withCommandName } from '../command-namespace.js'
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* VS Code / GitHub Copilot adapter.
|
|
@@ -17,7 +19,7 @@ import type { CopyResults, CopyDirOptions, DoctorCheck, ManagedPaths, RepoInfo,
|
|
|
17
19
|
* instructions/ → .github/instructions/
|
|
18
20
|
* skills/ → .github/skills/
|
|
19
21
|
* agent-workflows/ → .github/agent-workflows/
|
|
20
|
-
* prompts
|
|
22
|
+
* prompts/<name>.prompt.md → .github/prompts/oc.<name>.prompt.md (/oc:<name>)
|
|
21
23
|
* customizations/ → .opencastle/ (scaffolded once)
|
|
22
24
|
*/
|
|
23
25
|
|
|
@@ -42,15 +44,22 @@ const FRAMEWORK_DIRS = [
|
|
|
42
44
|
*/
|
|
43
45
|
function copyRulesFor(
|
|
44
46
|
dir: string,
|
|
45
|
-
excludedSkills: Set<string>,
|
|
46
|
-
excludedAgents: Set<string>,
|
|
47
47
|
stack?: StackConfig,
|
|
48
|
-
):
|
|
49
|
-
if (dir === 'skills') return { filter: (name) => !excludedSkills.has(name) }
|
|
48
|
+
): Pick<CopyDirOptions, 'filter' | 'transform' | 'rename'> {
|
|
50
49
|
if (dir === 'agents') {
|
|
50
|
+
return { transform: stack ? getAgentTransform(stack) : undefined }
|
|
51
|
+
}
|
|
52
|
+
if (dir === 'prompts') {
|
|
53
|
+
// The `oc:` namespace. VS Code reads prompt files from the top of
|
|
54
|
+
// `.github/prompts/` only, so it goes in the file name as `oc.` and in the
|
|
55
|
+
// command name — the frontmatter `name`, which VS Code prefers — as `oc:`.
|
|
56
|
+
const PROMPT = '.prompt.md'
|
|
51
57
|
return {
|
|
52
|
-
|
|
53
|
-
transform:
|
|
58
|
+
rename: (name) => (name.endsWith(PROMPT) ? vscodePromptFile(name) : name),
|
|
59
|
+
transform: (content, srcPath) =>
|
|
60
|
+
srcPath.endsWith(PROMPT)
|
|
61
|
+
? withCommandName(content, basename(srcPath).slice(0, -PROMPT.length))
|
|
62
|
+
: content,
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
65
|
if (dir === 'agent-workflows') {
|
|
@@ -97,18 +106,25 @@ export async function install(
|
|
|
97
106
|
pkgRoot: string,
|
|
98
107
|
projectRoot: string,
|
|
99
108
|
stack?: StackConfig,
|
|
100
|
-
repoInfo?: RepoInfo
|
|
109
|
+
repoInfo?: RepoInfo,
|
|
110
|
+
source?: CompileSource,
|
|
101
111
|
): Promise<CopyResults> {
|
|
102
|
-
|
|
112
|
+
return withSource(pkgRoot, stack, source, (src) => installFrom(src, projectRoot, stack, repoInfo))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function installFrom(
|
|
116
|
+
src: CompileSource,
|
|
117
|
+
projectRoot: string,
|
|
118
|
+
stack: StackConfig | undefined,
|
|
119
|
+
repoInfo: RepoInfo | undefined,
|
|
120
|
+
): Promise<CopyResults> {
|
|
121
|
+
const srcRoot = src.root
|
|
103
122
|
const destRoot = resolve(projectRoot, '.github')
|
|
104
123
|
|
|
105
124
|
await mkdir(destRoot, { recursive: true })
|
|
106
125
|
|
|
107
126
|
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
108
127
|
|
|
109
|
-
const excludedSkills = stack ? getExcludedSkills(stack) : new Set<string>()
|
|
110
|
-
const excludedAgents = stack ? getExcludedAgents(stack) : new Set<string>()
|
|
111
|
-
|
|
112
128
|
// copilot-instructions.md — merged, not replaced. A project that already has
|
|
113
129
|
// one keeps it; the generated content goes into a managed block below it.
|
|
114
130
|
const copilotSrc = resolve(srcRoot, 'copilot-instructions.md')
|
|
@@ -124,28 +140,10 @@ export async function install(
|
|
|
124
140
|
if (!existsSync(srcDir)) continue
|
|
125
141
|
const destDir = resolve(destRoot, dir)
|
|
126
142
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const sub = await copyDir(srcDir, destDir, { filter, transform })
|
|
143
|
+
const sub = await copyDir(srcDir, destDir, copyRulesFor(dir, stack))
|
|
130
144
|
mergeCopyResults(results, sub)
|
|
131
145
|
}
|
|
132
146
|
|
|
133
|
-
// Plugin skills → .github/skills/<plugin-id>/
|
|
134
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
135
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
136
|
-
const pluginSkills = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
137
|
-
for (const { id, skillPath } of pluginSkills) {
|
|
138
|
-
const pluginDestDir = resolve(destRoot, 'skills', id)
|
|
139
|
-
await mkdir(pluginDestDir, { recursive: true })
|
|
140
|
-
const destPath = resolve(pluginDestDir, 'SKILL.md')
|
|
141
|
-
if (existsSync(destPath)) {
|
|
142
|
-
results.skipped.push(destPath)
|
|
143
|
-
} else {
|
|
144
|
-
await copyFile(skillPath, destPath)
|
|
145
|
-
results.created.push(destPath)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
147
|
// MCP server config → .vscode/mcp.json (scaffold once)
|
|
150
148
|
await scaffoldMcpConfigInto(
|
|
151
149
|
results,
|
|
@@ -153,7 +151,8 @@ export async function install(
|
|
|
153
151
|
'.vscode/mcp.json',
|
|
154
152
|
stack,
|
|
155
153
|
repoInfo,
|
|
156
|
-
'vscode'
|
|
154
|
+
'vscode',
|
|
155
|
+
src.mcp,
|
|
157
156
|
)
|
|
158
157
|
|
|
159
158
|
return results
|
|
@@ -163,16 +162,18 @@ export async function update(
|
|
|
163
162
|
pkgRoot: string,
|
|
164
163
|
projectRoot: string,
|
|
165
164
|
stack?: StackConfig,
|
|
166
|
-
_repoInfo?: RepoInfo
|
|
165
|
+
_repoInfo?: RepoInfo,
|
|
166
|
+
source?: CompileSource,
|
|
167
167
|
): Promise<CopyResults> {
|
|
168
|
-
|
|
168
|
+
return withSource(pkgRoot, stack, source, (src) => updateFrom(src, projectRoot, stack))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function updateFrom(src: CompileSource, projectRoot: string, stack: StackConfig | undefined): Promise<CopyResults> {
|
|
172
|
+
const srcRoot = src.root
|
|
169
173
|
const destRoot = resolve(projectRoot, '.github')
|
|
170
174
|
|
|
171
175
|
const results: CopyResults = { copied: [], skipped: [], created: [] }
|
|
172
176
|
|
|
173
|
-
const excludedSkills = stack ? getExcludedSkills(stack) : new Set<string>()
|
|
174
|
-
const excludedAgents = stack ? getExcludedAgents(stack) : new Set<string>()
|
|
175
|
-
|
|
176
177
|
// `.github/` may not exist: a teammate clones a repo whose generated config was
|
|
177
178
|
// never committed, and `update` used to die with ENOENT before writing anything.
|
|
178
179
|
await mkdir(destRoot, { recursive: true })
|
|
@@ -191,7 +192,12 @@ export async function update(
|
|
|
191
192
|
const beforeSweep = new Map<string, string>()
|
|
192
193
|
for (const dir of FRAMEWORK_DIRS) {
|
|
193
194
|
const abs = resolve(destRoot, dir)
|
|
194
|
-
for (const rel of filesUnderDir(abs))
|
|
195
|
+
for (const rel of filesUnderDir(abs)) {
|
|
196
|
+
const shown = `.github/${dir}/${rel}`
|
|
197
|
+
// A prompt someone wrote beside ours is theirs to keep.
|
|
198
|
+
if (!ownsFile(shown, projectRoot)) continue
|
|
199
|
+
beforeSweep.set(resolve(abs, rel), shown)
|
|
200
|
+
}
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
// Recompile over the existing tree, then sweep — not the other way round.
|
|
@@ -207,45 +213,11 @@ export async function update(
|
|
|
207
213
|
if (!existsSync(srcDir)) continue
|
|
208
214
|
const destDir = resolve(destRoot, dir)
|
|
209
215
|
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
const sub = await copyDir(srcDir, destDir, { overwrite: true, filter, transform })
|
|
216
|
+
const sub = await copyDir(srcDir, destDir, { overwrite: true, ...copyRulesFor(dir, stack) })
|
|
213
217
|
mergeCopyResults(results, sub)
|
|
214
218
|
for (const abs of sub.visited ?? []) visited.add(abs)
|
|
215
219
|
}
|
|
216
220
|
|
|
217
|
-
// Plugin skills → .github/skills/<plugin-id>/ (overwrite)
|
|
218
|
-
const pluginsRoot = getPluginsRoot(pkgRoot)
|
|
219
|
-
const includedPlugins = stack ? getIncludedPluginIds(stack) : undefined
|
|
220
|
-
const pluginSkills = await getPluginSkillEntries(pluginsRoot, includedPlugins)
|
|
221
|
-
for (const { id, skillPath } of pluginSkills) {
|
|
222
|
-
const pluginDestDir = resolve(destRoot, 'skills', id)
|
|
223
|
-
await mkdir(pluginDestDir, { recursive: true })
|
|
224
|
-
const destPath = resolve(pluginDestDir, 'SKILL.md')
|
|
225
|
-
visited.add(destPath)
|
|
226
|
-
const content = await readFile(skillPath, 'utf8')
|
|
227
|
-
const existed = existsSync(destPath)
|
|
228
|
-
// The same guard the other three write paths got. Unguarded, a directory
|
|
229
|
-
// wearing `SKILL.md`'s name took `sync` down with a bare `EISDIR` that named
|
|
230
|
-
// nothing to act on.
|
|
231
|
-
let onDisk: string | null = null
|
|
232
|
-
if (existed) {
|
|
233
|
-
try {
|
|
234
|
-
onDisk = await readFile(destPath, 'utf8')
|
|
235
|
-
} catch {
|
|
236
|
-
;(results.unreadable ??= []).push(`${destPath}\u0000unreadable`)
|
|
237
|
-
results.skipped.push(destPath)
|
|
238
|
-
continue
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (onDisk === content) {
|
|
242
|
-
results.skipped.push(destPath)
|
|
243
|
-
} else {
|
|
244
|
-
await writeFile(destPath, content)
|
|
245
|
-
results[existed ? 'copied' : 'created'].push(destPath)
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
221
|
// Now drop output with no source left.
|
|
250
222
|
for (const abs of beforeSweep.keys()) {
|
|
251
223
|
if (await reconcileCase(abs, visited)) continue
|
|
@@ -261,6 +233,32 @@ export async function update(
|
|
|
261
233
|
return results
|
|
262
234
|
}
|
|
263
235
|
|
|
236
|
+
const PROMPTS_DIR = '.github/prompts/'
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* `.github/prompts/` is shared: VS Code reads prompt files only at its top, so
|
|
240
|
+
* OpenCastle's `oc.` files and a person's own sit side by side. Every other
|
|
241
|
+
* framework directory is wholly generated.
|
|
242
|
+
*/
|
|
243
|
+
export function ownsFile(rel: string, projectRoot: string): boolean {
|
|
244
|
+
const norm = rel.replace(/\\/g, '/')
|
|
245
|
+
if (!norm.startsWith(PROMPTS_DIR)) return true
|
|
246
|
+
const name = norm.slice(PROMPTS_DIR.length)
|
|
247
|
+
// VS Code reads nothing deeper, and OpenCastle writes nothing deeper.
|
|
248
|
+
if (name.includes('/')) return false
|
|
249
|
+
return isOurVscodePrompt(name, resolve(projectRoot, norm), projectRoot)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** The one framework directory this target shares with the user. */
|
|
253
|
+
export function getSharedDirs(): string[] {
|
|
254
|
+
return [PROMPTS_DIR]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** The un-namespaced prompts an earlier release wrote. `update`'s sweep removes them. */
|
|
258
|
+
export function getLegacyOutputs(projectRoot: string): string[] {
|
|
259
|
+
return legacyVscodePrompts(projectRoot)
|
|
260
|
+
}
|
|
261
|
+
|
|
264
262
|
export function getManagedPaths(): ManagedPaths {
|
|
265
263
|
return {
|
|
266
264
|
framework: FRAMEWORK_DIRS.map((d) => `.github/${d}/`),
|