@@ -19,8 +19,50 @@ export const DEFAULTS: Record<string, unknown> = {
1919 "cli.stdin_buffer_limit" : 10_485_760 ,
2020 "cli.auto_approve" : false ,
2121 "cli.help_text_max_length" : 1000 ,
22+ // Namespace-mode aliases (apcore >= 0.15.0 Config Bus)
23+ "apcore-cli.stdin_buffer_limit" : 10_485_760 ,
24+ "apcore-cli.auto_approve" : false ,
25+ "apcore-cli.help_text_max_length" : 1000 ,
26+ "apcore-cli.logging_level" : "WARNING" ,
2227} ;
2328
29+ /** Namespace key ↔ legacy key mapping for backward compatibility. */
30+ const NAMESPACE_TO_LEGACY : Record < string , string > = {
31+ "apcore-cli.stdin_buffer_limit" : "cli.stdin_buffer_limit" ,
32+ "apcore-cli.auto_approve" : "cli.auto_approve" ,
33+ "apcore-cli.help_text_max_length" : "cli.help_text_max_length" ,
34+ "apcore-cli.logging_level" : "logging.level" ,
35+ } ;
36+ const LEGACY_TO_NAMESPACE : Record < string , string > = Object . fromEntries (
37+ Object . entries ( NAMESPACE_TO_LEGACY ) . map ( ( [ k , v ] ) => [ v , k ] ) ,
38+ ) ;
39+
40+ /**
41+ * Register the apcore-cli Config Bus namespace (apcore >= 0.15.0).
42+ * Safe to call even when apcore-js is unavailable or < 0.15.0.
43+ */
44+ export function registerConfigNamespace ( ) : void {
45+ try {
46+ // Dynamic import to avoid hard failure when apcore-js is not available
47+ // eslint-disable-next-line @typescript-eslint/no-require-imports
48+ const { Config } = require ( "apcore-js" ) ;
49+ if ( typeof Config ?. registerNamespace === "function" ) {
50+ Config . registerNamespace ( {
51+ name : "apcore-cli" ,
52+ envPrefix : "APCORE_CLI" ,
53+ defaults : {
54+ stdin_buffer_limit : 10_485_760 ,
55+ auto_approve : false ,
56+ help_text_max_length : 1000 ,
57+ logging_level : "WARNING" ,
58+ } ,
59+ } ) ;
60+ }
61+ } catch {
62+ // apcore-js not installed or < 0.15.0 — graceful no-op
63+ }
64+ }
65+
2466// ---------------------------------------------------------------------------
2567// ConfigResolver
2668// ---------------------------------------------------------------------------
@@ -64,11 +106,18 @@ export class ConfigResolver {
64106 }
65107 }
66108
67- // Tier 3: Config file
109+ // Tier 3: Config file (try both namespace and legacy keys)
68110 const fileValue = this . resolveFromFile ( key ) ;
69111 if ( fileValue !== undefined ) {
70112 return fileValue ;
71113 }
114+ const altKey = NAMESPACE_TO_LEGACY [ key ] ?? LEGACY_TO_NAMESPACE [ key ] ;
115+ if ( altKey ) {
116+ const altFileValue = this . resolveFromFile ( altKey ) ;
117+ if ( altFileValue !== undefined ) {
118+ return altFileValue ;
119+ }
120+ }
72121
73122 // Tier 4: Defaults
74123 return DEFAULTS [ key ] ;
0 commit comments