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
package/src/cli/init.ts
CHANGED
|
@@ -5,18 +5,22 @@ import { multiselect, confirm, closePrompts, c } from './prompt.js'
|
|
|
5
5
|
import { readManifest, writeManifest, createManifest } from './manifest.js'
|
|
6
6
|
import { removeDirIfExists, copyDir, getOrchestratorRoot } from './copy.js'
|
|
7
7
|
import { updateGitignore } from './gitignore.js'
|
|
8
|
-
import {
|
|
8
|
+
import { getCustomizationsTransform } from './stack-config.js'
|
|
9
9
|
import { getMcpConfigRelPath, stripManagedMcpServers } from './mcp.js'
|
|
10
10
|
import { getPluginsBySubCategory } from '../orchestrator/plugins/index.js'
|
|
11
11
|
import type { PluginConfig } from '../orchestrator/plugins/types.js'
|
|
12
12
|
import { detectRepoInfo, mergeStackIntoRepoInfo, formatRepoInfo, buildDetectedToolsSet, detectCurrentIde, detectAssistantConfigs } from './detect.js'
|
|
13
13
|
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
14
14
|
import { IDE_LABELS } from './types.js'
|
|
15
|
-
import type { CliContext, CopyResults, IdeChoice, TechTool, TeamTool, StackConfig } from './types.js'
|
|
15
|
+
import type { CliContext, CopyResults, IdeAdapter, IdeChoice, TechTool, TeamTool, StackConfig } from './types.js'
|
|
16
16
|
import { bootstrapCustomizations } from './bootstrap.js'
|
|
17
17
|
import { stripManagedBlock, stripManagedBlockFromFile } from './managed-block.js'
|
|
18
|
-
import { resolveManagedPaths, declaredManagedPaths } from './managed-paths.js'
|
|
18
|
+
import { resolveManagedPaths, declaredManagedPaths, ownerOf, removeOwnedFiles } from './managed-paths.js'
|
|
19
19
|
import { noteUnreadable } from './unreadable-report.js'
|
|
20
|
+
import { resolveSources, materialize, hasErrors, formatIssues, requiredEnvVars } from './layers.js'
|
|
21
|
+
import { buildLock, writeLock, priorTeam } from './lock.js'
|
|
22
|
+
import { parseVersion, compareVersions } from './version-range.js'
|
|
23
|
+
import { COMMAND_NAMESPACE } from './command-namespace.js'
|
|
20
24
|
|
|
21
25
|
const INIT_HELP = `
|
|
22
26
|
opencastle init [options]
|
|
@@ -28,6 +32,8 @@ const INIT_HELP = `
|
|
|
28
32
|
--customize, --reconfigure Choose IDEs and integrations manually
|
|
29
33
|
--yes, -y Accept the detected setup without asking
|
|
30
34
|
--dry-run Preview what would be changed without writing files
|
|
35
|
+
--allow-downgrade Re-run with this OpenCastle even though a newer one
|
|
36
|
+
compiled the project
|
|
31
37
|
--help, -h Show this help
|
|
32
38
|
`
|
|
33
39
|
|
|
@@ -200,6 +206,19 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
200
206
|
console.log(`\n 🏰 ${c.bold('OpenCastle')} ${c.dim(`v${pkg.version}`)}`)
|
|
201
207
|
console.log(` ${c.dim('Compiles your AI assistant config for every assistant you use')}\n`)
|
|
202
208
|
|
|
209
|
+
// The same guard `sync` has: re-running `init` over a project a newer
|
|
210
|
+
// release compiled recompiles it with this one, and restamps the manifest.
|
|
211
|
+
if (existing) {
|
|
212
|
+
const mine = parseVersion(pkg.version)
|
|
213
|
+
const theirs = parseVersion(existing.version)
|
|
214
|
+
if (mine && theirs && compareVersions(mine, theirs) < 0 && !args.includes('--allow-downgrade')) {
|
|
215
|
+
console.error(` ${c.red('✗')} This project was compiled by OpenCastle ${existing.version}; this is ${pkg.version}.`)
|
|
216
|
+
console.error(` ${c.dim(`Run npx opencastle@${existing.version} — or pass --allow-downgrade to go back on purpose.`)}\n`)
|
|
217
|
+
closePrompts()
|
|
218
|
+
process.exit(1)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
203
222
|
// ── Detect ──────────────────────────────────────────────────────
|
|
204
223
|
console.log(` ${c.dim('Scanning repository…')}`)
|
|
205
224
|
const repoInfo = await detectRepoInfo(projectRoot)
|
|
@@ -294,6 +313,19 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
294
313
|
console.log()
|
|
295
314
|
}
|
|
296
315
|
|
|
316
|
+
// The team's sources, before anything is written. A repository that already
|
|
317
|
+
// carries `.opencastle/config.json` — a clone of a team project being set up
|
|
318
|
+
// again — must compile to the same standard `sync` holds it to, or refuse.
|
|
319
|
+
const resolved = resolveSources({ pkgRoot, projectRoot, stack, repoInfo: combinedRepoInfo })
|
|
320
|
+
if (hasErrors(resolved)) {
|
|
321
|
+
const errors = resolved.issues.filter((i) => i.level === 'error')
|
|
322
|
+
console.error(`\n ${c.red('✗')} The team's sources have ${errors.length} problem(s); nothing was written.\n`)
|
|
323
|
+
for (const line of formatIssues(errors)) console.error(` ${line}`)
|
|
324
|
+
console.error('')
|
|
325
|
+
closePrompts()
|
|
326
|
+
process.exit(1)
|
|
327
|
+
}
|
|
328
|
+
|
|
297
329
|
// ── Dry run ─────────────────────────────────────────────────────
|
|
298
330
|
if (dryRun) {
|
|
299
331
|
for (const ide of ides) {
|
|
@@ -350,10 +382,21 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
350
382
|
const previous = await resolveManagedPaths({ ...existing, ide: dropped[0], ides: dropped })
|
|
351
383
|
const keeping = await declaredManagedPaths(ides as string[])
|
|
352
384
|
const kept = new Set([...keeping.framework, ...(keeping.merged ?? [])])
|
|
353
|
-
|
|
385
|
+
// And what a release before the `oc:` namespace left outside them.
|
|
386
|
+
const droppedAdapters: IdeAdapter[] = []
|
|
387
|
+
for (const id of dropped) {
|
|
388
|
+
const load = IDE_ADAPTERS[id]
|
|
389
|
+
if (load) droppedAdapters.push(await load())
|
|
390
|
+
}
|
|
391
|
+
const legacy = droppedAdapters.flatMap((a) => a.getLegacyOutputs?.(projectRoot) ?? [])
|
|
392
|
+
for (const p of [...previous.framework, ...legacy]) {
|
|
354
393
|
if (kept.has(p)) continue
|
|
355
394
|
const fullPath = resolve(projectRoot, p)
|
|
356
|
-
|
|
395
|
+
// A directory the target shares with the user loses only its own files.
|
|
396
|
+
const owns = ownerOf(droppedAdapters, p, projectRoot)
|
|
397
|
+
if (owns) {
|
|
398
|
+
removeOwnedFiles(projectRoot, p, owns)
|
|
399
|
+
} else if (p.endsWith('/')) {
|
|
357
400
|
await removeDirIfExists(fullPath)
|
|
358
401
|
} else if (existsSync(fullPath)) {
|
|
359
402
|
await unlink(fullPath)
|
|
@@ -396,102 +439,122 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
396
439
|
const unreadable: string[] = []
|
|
397
440
|
const failedTargets: Array<{ ide: string; message: string }> = []
|
|
398
441
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
results
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
442
|
+
const source = materialize(resolved, pkgRoot, ...priorTeam(projectRoot))
|
|
443
|
+
try {
|
|
444
|
+
for (const ide of ides) {
|
|
445
|
+
const adapter = await IDE_ADAPTERS[ide]()
|
|
446
|
+
// Re-running over an existing install recompiles; a first install scaffolds.
|
|
447
|
+
//
|
|
448
|
+
// `install` is scaffold-once by contract, so re-init left every generated
|
|
449
|
+
// file exactly as it found it — and then stamped the manifest with the
|
|
450
|
+
// current version. The record said 0.36 while the tree was still 0.30. It
|
|
451
|
+
// was recoverable, because `sync --check` compares content and not version
|
|
452
|
+
// numbers, but a command that writes a version it did not compile is
|
|
453
|
+
// asserting something it has not done.
|
|
454
|
+
// One target failing must not abort the others, and must not abort the
|
|
455
|
+
// manifest. The loop had no guard, and the manifest is written after it, so
|
|
456
|
+
// a second target throwing — an unwritable `.github/copilot-instructions.md`
|
|
457
|
+
// is enough — left the first target's 78 files on disk with no manifest at
|
|
458
|
+
// all: the front door said "not set up", `sync` said to run `init`, `init`
|
|
459
|
+
// failed the same way, and `remove --all` refused to uninstall what it had
|
|
460
|
+
// just installed. Single-target installs write the root file first and so
|
|
461
|
+
// throw before anything lands, which is why this only showed up with two.
|
|
462
|
+
let results: CopyResults
|
|
463
|
+
try {
|
|
464
|
+
results = isReinit
|
|
465
|
+
? await adapter.update(pkgRoot, projectRoot, stack, combinedRepoInfo, source)
|
|
466
|
+
: await adapter.install(pkgRoot, projectRoot, stack, combinedRepoInfo, source)
|
|
467
|
+
} catch (err) {
|
|
468
|
+
failedTargets.push({ ide, message: (err as Error).message })
|
|
469
|
+
continue
|
|
470
|
+
}
|
|
471
|
+
totalCreated += results.created.length
|
|
472
|
+
totalSkipped += results.skipped.length
|
|
473
|
+
skippedPaths.push(...results.skipped)
|
|
474
|
+
for (const file of results.unreadable ?? []) {
|
|
475
|
+
noteUnreadable(unreadable, file)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
adoptedRoots.push(...(results.adopted ?? []))
|
|
479
|
+
repairedRoots.push(...(results.repaired ?? []))
|
|
480
|
+
damagedRoots.push(...(results.damagedRoots ?? []))
|
|
481
|
+
severedRoots.push(...(results.severedRoots ?? []))
|
|
482
|
+
staleRoots.push(...(results.staleRoots ?? []))
|
|
483
|
+
tornRoots.push(...(results.tornRoots ?? []))
|
|
432
484
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
allManagedPaths.framework.push(...managed.framework)
|
|
442
|
-
allManagedPaths.customizable.push(...managed.customizable)
|
|
443
|
-
// Deduplicated: opencode and codex share AGENTS.md, so a per-adapter push
|
|
444
|
-
// listed it twice — "Merged into your existing …, AGENTS.md, AGENTS.md".
|
|
445
|
-
for (const m of managed.merged ?? []) {
|
|
446
|
-
if (!allManagedPaths.merged.includes(m)) allManagedPaths.merged.push(m)
|
|
485
|
+
const managed = adapter.getManagedPaths()
|
|
486
|
+
allManagedPaths.framework.push(...managed.framework)
|
|
487
|
+
allManagedPaths.customizable.push(...managed.customizable)
|
|
488
|
+
// Deduplicated: opencode and codex share AGENTS.md, so a per-adapter push
|
|
489
|
+
// listed it twice — "Merged into your existing …, AGENTS.md, AGENTS.md".
|
|
490
|
+
for (const m of managed.merged ?? []) {
|
|
491
|
+
if (!allManagedPaths.merged.includes(m)) allManagedPaths.merged.push(m)
|
|
492
|
+
}
|
|
447
493
|
}
|
|
448
|
-
}
|
|
449
494
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
//
|
|
454
|
-
//
|
|
455
|
-
// `
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
assumeYes || (await confirm('Overwrite existing files?', true, 'refuse'))
|
|
459
|
-
if (overwrite) {
|
|
460
|
-
// Recompile in place rather than emptying the tree first.
|
|
461
|
-
//
|
|
462
|
-
// Deleting every framework path and re-installing was the old shape, and
|
|
463
|
-
// it made `init` the one command that could destroy an install by
|
|
464
|
-
// failing: an unwritable CLAUDE.md, met after 62 files had already been
|
|
465
|
-
// unlinked, left the directories empty and the manifest claiming an
|
|
466
|
-
// install. `update` writes the new output before sweeping what has no
|
|
467
|
-
// source left, which is the same guarantee `sync` gives.
|
|
468
|
-
totalCreated = 0
|
|
469
|
-
totalSkipped = 0
|
|
495
|
+
// If all files were skipped (orphaned install — no manifest but files exist).
|
|
496
|
+
//
|
|
497
|
+
// Or if a release before the `oc:` namespace left its commands here. The
|
|
498
|
+
// namespaced files are new, so they count as created and "all skipped" no
|
|
499
|
+
// longer holds for any install that old — its stale `/bug-fix` stayed beside
|
|
500
|
+
// `/oc:bug-fix` and its agent bodies were never refreshed.
|
|
501
|
+
const previousOutput: string[] = []
|
|
502
|
+
if (!isReinit) {
|
|
470
503
|
for (const ide of ides) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
//
|
|
486
|
-
//
|
|
487
|
-
//
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
504
|
+
previousOutput.push(...((await IDE_ADAPTERS[ide]()).getLegacyOutputs?.(projectRoot) ?? []))
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (((totalCreated === 0 && totalSkipped > 0) || previousOutput.length > 0) && !isReinit) {
|
|
508
|
+
console.log(
|
|
509
|
+
` ${c.yellow('⚠')} Found ${totalSkipped + previousOutput.length} existing files from a previous installation.`,
|
|
510
|
+
)
|
|
511
|
+
// `--yes` is documented as "accept the detected setup without asking", and
|
|
512
|
+
// this was the one question it did not cover. On a TTY it still asked.
|
|
513
|
+
// `refuse`, because the default here overwrites. A piped run that ran out of
|
|
514
|
+
// answers before this question took the destructive branch in silence.
|
|
515
|
+
const overwrite =
|
|
516
|
+
assumeYes || (await confirm('Overwrite existing files?', true, 'refuse'))
|
|
517
|
+
if (overwrite) {
|
|
518
|
+
// Recompile in place rather than emptying the tree first.
|
|
519
|
+
//
|
|
520
|
+
// Deleting every framework path and re-installing was the old shape, and
|
|
521
|
+
// it made `init` the one command that could destroy an install by
|
|
522
|
+
// failing: an unwritable CLAUDE.md, met after 62 files had already been
|
|
523
|
+
// unlinked, left the directories empty and the manifest claiming an
|
|
524
|
+
// install. `update` writes the new output before sweeping what has no
|
|
525
|
+
// source left, which is the same guarantee `sync` gives.
|
|
526
|
+
totalCreated = 0
|
|
527
|
+
totalSkipped = 0
|
|
528
|
+
for (const ide of ides) {
|
|
529
|
+
const adapter = await IDE_ADAPTERS[ide]()
|
|
530
|
+
// Guarded like the main loop above, and for the same reason: this one
|
|
531
|
+
// was not, so a re-entry over an orphaned install that failed on the
|
|
532
|
+
// second target left 91 files on disk with no manifest and every
|
|
533
|
+
// command dead-ended — the front door saying "not set up", `sync`
|
|
534
|
+
// saying run `init`, `init` failing identically, `remove` refusing.
|
|
535
|
+
let results: CopyResults
|
|
536
|
+
try {
|
|
537
|
+
results = await adapter.update(pkgRoot, projectRoot, stack, combinedRepoInfo, source)
|
|
538
|
+
} catch (err) {
|
|
539
|
+
failedTargets.push({ ide, message: (err as Error).message })
|
|
540
|
+
continue
|
|
541
|
+
}
|
|
542
|
+
// `copied` too. Counting only `created` and `skipped` made this path
|
|
543
|
+
// report "Created 0 files / Left 29 existing files untouched" over a
|
|
544
|
+
// run that had just rewritten 78 of them — the summary asserting the
|
|
545
|
+
// opposite of what happened, on the one path that exists to overwrite.
|
|
546
|
+
totalCreated += results.created.length + results.copied.length
|
|
547
|
+
totalSkipped += results.skipped.length
|
|
548
|
+
for (const file of results.unreadable ?? []) {
|
|
549
|
+
noteUnreadable(unreadable, file)
|
|
550
|
+
}
|
|
492
551
|
}
|
|
493
552
|
}
|
|
494
553
|
}
|
|
554
|
+
|
|
555
|
+
await writeLock(projectRoot, buildLock(source, { ides: ides as string[], stack, repoInfo: combinedRepoInfo }))
|
|
556
|
+
} finally {
|
|
557
|
+
source.dispose()
|
|
495
558
|
}
|
|
496
559
|
|
|
497
560
|
// ── Scaffold customizations to .opencastle/ ──────────────────────────────
|
|
@@ -569,12 +632,16 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
569
632
|
// install, and resetting it threw away when the project actually adopted the tool.
|
|
570
633
|
if (existing?.installedAt) manifest.installedAt = existing.installedAt
|
|
571
634
|
manifest.stack = stack
|
|
572
|
-
|
|
635
|
+
// Detected again now that the install exists, as `sync` will detect it. The
|
|
636
|
+
// first detection ran before the MCP configs were written, so the record
|
|
637
|
+
// differed from what the next sync saw and that sync rewrote the manifest —
|
|
638
|
+
// a committed file changing on a run that changed nothing about the project.
|
|
639
|
+
manifest.repoInfo = mergeStackIntoRepoInfo(await detectRepoInfo(projectRoot), stack)
|
|
573
640
|
await writeManifest(projectRoot, manifest)
|
|
574
641
|
|
|
575
642
|
// ── Update .gitignore ───────────────────────────────────────────
|
|
576
643
|
// Only local artefacts and .env; the generated config is meant to be committed.
|
|
577
|
-
const envVars =
|
|
644
|
+
const envVars = requiredEnvVars(resolved, stack, combinedRepoInfo)
|
|
578
645
|
const gitignoreResult = await updateGitignore(projectRoot)
|
|
579
646
|
|
|
580
647
|
// ── Summary ─────────────────────────────────────────────────────
|
|
@@ -786,6 +853,17 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
786
853
|
` ${step}. Set the environment variable${envVars.length > 1 ? 's' : ''} listed above (in .env or your shell)`
|
|
787
854
|
)
|
|
788
855
|
}
|
|
856
|
+
// The commands are namespaced, and a name nobody tells you is a name nobody
|
|
857
|
+
// types. Only where `/oc:` is a slash command.
|
|
858
|
+
const withCommands = ides.filter((id) => id === 'claude-code' || id === 'vscode')
|
|
859
|
+
if (withCommands.length > 0) {
|
|
860
|
+
step++
|
|
861
|
+
const where = withCommands.map((id) => (id === 'vscode' ? 'Copilot Chat' : 'Claude Code')).join(' or ')
|
|
862
|
+
console.log(
|
|
863
|
+
` ${step}. Type ${c.cyan(`/${COMMAND_NAMESPACE}:`)} in ${where} for OpenCastle's commands — ` +
|
|
864
|
+
`${c.cyan(`/${COMMAND_NAMESPACE}:bootstrap-customizations`)} first on an existing codebase`,
|
|
865
|
+
)
|
|
866
|
+
}
|
|
789
867
|
step++
|
|
790
868
|
console.log(` ${step}. Commit the .opencastle/ folder to your repository`)
|
|
791
869
|
|