Skip to content

Commit be2f877

Browse files
committed
refactor(memory): derive VALID_STRATEGIES and help text from schema
Eliminates source-of-truth drift by deriving the valid strategies array and CLI help text from MemoryStrategyTypeSchema.options instead of maintaining hand-written duplicates. Constraint: MemoryStrategyTypeSchema is the single source of truth Confidence: high Scope-risk: narrow
1 parent f236ed8 commit be2f877

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/cli/commands/add/validate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
BuildTypeSchema,
55
GatewayExceptionLevelSchema,
66
GatewayNameSchema,
7+
MemoryStrategyTypeSchema,
78
ModelProviderSchema,
89
ProtocolModeSchema,
910
RuntimeAuthorizerTypeSchema,
@@ -33,7 +34,7 @@ export interface ValidationResult {
3334

3435
// Constants
3536
const MEMORY_OPTIONS = ['none', 'shortTerm', 'longAndShortTerm'] as const;
36-
const VALID_STRATEGIES = ['SEMANTIC', 'SUMMARIZATION', 'USER_PREFERENCE', 'CUSTOM'];
37+
const VALID_STRATEGIES: readonly string[] = MemoryStrategyTypeSchema.options;
3738

3839
/**
3940
* Validate that a credential name exists in the project spec.

src/cli/primitives/MemoryPrimitive.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { findConfigRoot } from '../../lib';
22
import type { Memory, MemoryStrategy, MemoryStrategyType } from '../../schema';
3-
import { DEFAULT_STRATEGY_NAMESPACES, MemorySchema } from '../../schema';
3+
import { DEFAULT_STRATEGY_NAMESPACES, MemorySchema, MemoryStrategyTypeSchema } from '../../schema';
44
import { validateAddMemoryOptions } from '../commands/add/validate';
55
import { getErrorMessage } from '../errors';
66
import type { RemovalPreview, RemovalResult, SchemaChange } from '../operations/remove/types';
@@ -126,7 +126,7 @@ export class MemoryPrimitive extends BasePrimitive<AddMemoryOptions, RemovableMe
126126
.option('--name <name>', 'Memory name [non-interactive]')
127127
.option(
128128
'--strategies <types>',
129-
'Comma-separated strategies: SEMANTIC, SUMMARIZATION, USER_PREFERENCE, CUSTOM [non-interactive]'
129+
`Comma-separated strategies: ${MemoryStrategyTypeSchema.options.join(', ')} [non-interactive]`
130130
)
131131
.option('--expiry <days>', 'Event expiry duration in days (default: 30) [non-interactive]')
132132
.option('--json', 'Output as JSON [non-interactive]')

0 commit comments

Comments
 (0)