@hncode/hncode 0.8.2 → 0.8.4

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/src/config.js CHANGED
@@ -313,6 +313,27 @@ export function clampRatio(value, fallback) {
313
313
  return (v > 0 && v < 1) ? v : fallback;
314
314
  }
315
315
 
316
+ // ---- the runtime's own language -------------------------------------------
317
+
318
+ /**
319
+ * The language the SYSTEM is set to, as `zh` or `en`.
320
+ *
321
+ * Region, not timezone: a machine can sit in any timezone and still be an English
322
+ * install. `Intl` reports what the user picked in their OS settings, which is the same
323
+ * value their other applications follow. Anything outside Chinese falls back to English,
324
+ * which is what the UI is authored in.
325
+ *
326
+ * The locale is a parameter so a test can drive both branches without touching the host.
327
+ */
328
+ export function systemLanguage(locale) {
329
+ let tag = locale;
330
+ if (tag === undefined) {
331
+ try { tag = new Intl.DateTimeFormat().resolvedOptions().locale; } catch { tag = ''; }
332
+ }
333
+ const norm = String(tag || '').trim().toLowerCase().replace('_', '-');
334
+ return (norm === 'zh' || norm.startsWith('zh-')) ? 'zh' : 'en';
335
+ }
336
+
316
337
  export function resolveConfig() {
317
338
  const root = loadBaseToml() || {};
318
339
  // Merge plugin-provided defaults UNDER the user's config: an explicitly set
@@ -484,17 +505,21 @@ const b = baseUrl.replace(/\/+$/, '');
484
505
  // Backwards-compat: read legacy cool_mode key if calm_mode is not set.
485
506
  : (root.calm_mode === true || root.calm_mode === 'true'
486
507
  || root.cool_mode === true || root.cool_mode === 'true'),
487
- // UI LANGUAGE (/lang): which language the TERMINAL UI speaks. Only the strings a
488
- // person reads are translated — command descriptions, the help panel, menu hints
489
- // and turn states. The system prompt and everything the model reads stay English,
490
- // because those are instructions to the model rather than text for a reader, and a
491
- // half-translated instruction set is worse than an English one.
492
- //
493
- // Anything unrecognised falls back to English rather than failing the launch.
494
- lang: (() => {
495
- const raw = String(process.env.HNCODE_LANG || root.lang || '').trim().toLowerCase().replace('_', '-');
496
- if (raw === 'zh' || raw.startsWith('zh-')) return 'zh';
497
- return 'en';
508
+ lang: (() => {
509
+ const explicit = String(process.env.HNCODE_LANG || root.lang || '').trim().toLowerCase().replace('_', '-');
510
+ if (explicit === 'zh' || explicit.startsWith('zh-')) return 'zh';
511
+ if (explicit === 'en' || explicit.startsWith('en-')) return 'en';
512
+ return systemLanguage();
513
+ })(),
514
+ // THINKING TAGS: whether the model is told to wrap its reasoning in
515
+ // `<|thinking|>…<|/thinking|>`. THREE states: `auto` follows the model (a model with
516
+ // a native reasoning channel does not need the tag, one without it does), and `on`
517
+ // / `off` decide by hand.
518
+ thinkingTags: (() => {
519
+ const raw = String(process.env.HNCODE_THINKING_TAGS || root.thinking_tags || 'auto').trim().toLowerCase();
520
+ if (raw === 'on' || raw === 'true' || raw === 'yes' || raw === '1') return 'on';
521
+ if (raw === 'off' || raw === 'false' || raw === 'no' || raw === '0') return 'off';
522
+ return 'auto';
498
523
  })(),
499
524
  subagentModel: process.env.HNCODE_SUBAGENT_MODEL || root.subagent_model || '',
500
525
  // SECONDARY MODEL (/secondary-model): the cheap model for side work — /btw,