spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / agents-md / hooks / modes / legacy-mode-of.ts
33 lines · 1019 BRaw
1import type { Mode } from './types'
2
3/**
4 * Each value the option took under its old key, `projectInstructions`, and
5 * the mode that keeps its meaning.
6 */
7const LEGACY_MODES: Readonly<Record<string, Mode>> = {
8 none: 'managed-only',
9 claude: 'claude-md',
10 'agents-fallback': 'claude-md-or-agents-md',
11 both: 'claude-md-and-agents-md',
12}
13
14/**
15 * The mode a value stored under the old `projectInstructions` key keeps; a
16 * value it never took reads as `claude-md`, which adds nothing, never as the
17 * default, which loads AGENTS.md.
18 *
19 * COMPAT_BREAK(agents-md-project-instructions): drop the projectInstructions
20 * mapping once stored settings have migrated.
21 *
22 * @param value the `projectInstructions` option as stored
23 * @returns the mode it keeps, undefined when nothing is stored there
24 */
25export function legacyModeOf(value: unknown): Mode | undefined {
26 if (value === undefined) {
27 return undefined
28 }
29
30 return (
31 (typeof value === 'string' ? LEGACY_MODES[value] : undefined) ?? 'claude-md'
32 )
33}