@miphamai/cli 0.85.43 → 0.85.45

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/ui/chat.tsx CHANGED
@@ -4,7 +4,7 @@ import { useI18n } from '../i18n-context'
4
4
  import type { ChatMessage } from './app'
5
5
  import {
6
6
  decodeDisplayEntities,
7
- safeSlice,
7
+ safeSliceWithEllipsis,
8
8
  sanitizeInlineField,
9
9
  stripControlCharsForDisplay,
10
10
  } from '../shared/sanitize'
@@ -123,7 +123,9 @@ const MessageRow = React.memo(
123
123
  {msg.toolMeta.name ? (
124
124
  <Text color={toolColor(msg.toolMeta.name)}>
125
125
  {msg.toolMeta.collapsed ? '⏺' : '⏺ ▼'} {sanitizeInlineField(msg.toolMeta.name)}
126
- {msg.toolMeta.input ? ` (${safeSlice(display(msg.toolMeta.input), 120)})` : ''}
126
+ {msg.toolMeta.input
127
+ ? ` (${safeSliceWithEllipsis(display(msg.toolMeta.input), 120)})`
128
+ : ''}
127
129
  </Text>
128
130
  ) : null}
129
131
  {/* Tool result line: ⎿ summary text */}
@@ -134,7 +136,9 @@ const MessageRow = React.memo(
134
136
  <Text dimColor>
135
137
  {' ⎿ '}
136
138
  {t('ui.tool.not_run')}
137
- {msg.toolMeta.output ? ` — ${safeSlice(display(msg.toolMeta.output), 300)}` : ''}
139
+ {msg.toolMeta.output
140
+ ? ` — ${safeSliceWithEllipsis(display(msg.toolMeta.output), 300)}`
141
+ : ''}
138
142
  </Text>
139
143
  ) : msg.toolMeta.noResult ? (
140
144
  // The call ended without output. Saying so is the point: an empty
@@ -147,7 +151,7 @@ const MessageRow = React.memo(
147
151
  ) : msg.toolMeta.output ? (
148
152
  <Text dimColor>
149
153
  {' ⎿ '}
150
- {safeSlice(display(msg.toolMeta.output), 300)}
154
+ {safeSliceWithEllipsis(display(msg.toolMeta.output), 300)}
151
155
  </Text>
152
156
  ) : msg.content && !msg.toolMeta.collapsed ? (
153
157
  <Text dimColor>{display(msg.content)}</Text>
@@ -2,7 +2,7 @@ import React, { useState, useMemo, useEffect } from 'react'
2
2
  import { Box, Text, useInput } from 'ink'
3
3
  import TextInput from 'ink-text-input'
4
4
  import { useI18n } from '../i18n-context'
5
- import { getCommandList } from './commands.js'
5
+ import { getCommandList, rankCommandMatches } from './commands.js'
6
6
  import { commandToken, hasInlineArgs } from './command-token.js'
7
7
  import { useKeyState } from './use-key-state'
8
8
 
@@ -68,10 +68,7 @@ export function CommandPicker({
68
68
  // full line — so "/loop 60s echo hello" still matches "/loop").
69
69
  const filtered = useMemo(() => {
70
70
  const q = commandToken(filter)
71
- if (!q) return allCommands
72
- return allCommands.filter(
73
- (cmd) => cmd.name.toLowerCase().includes(q) || cmd.description.toLowerCase().includes(q),
74
- )
71
+ return rankCommandMatches(allCommands, q)
75
72
  }, [filter, allCommands])
76
73
 
77
74
  // Reset cursor when filter changes
@@ -140,7 +140,7 @@ import {
140
140
  trustCmd,
141
141
  } from '../commands/project.js'
142
142
  import { releaseNotesCmd, ideCmd, terminalSetupCmd } from '../commands/environment.js'
143
- import { commitCmd, pushCmd, prCmd, issueCmd } from '../commands/git.js'
143
+ import { commitCmd, pushCmd, prCmd, issueCmd, shipCmd } from '../commands/git.js'
144
144
  import { suggestDirectories } from '../commands/cd-suggest.js'
145
145
  import { keysCmd } from '../commands/keys'
146
146
  import { workflowViewCmd, workflowWatchCmd } from '../commands/workflow-view.js'
@@ -2881,11 +2881,30 @@ const changelogCmd: CommandHandler = async (ctx) => {
2881
2881
  // Workflow
2882
2882
  // ═══════════════════════════════════════════════════════════════
2883
2883
 
2884
- const planCmd: CommandHandler = (_ctx, args) => {
2885
- const t = resolveT(_ctx)
2884
+ const planCmd: CommandHandler = (ctx, args) => {
2885
+ const t = resolveT(ctx)
2886
2886
  const description = args.join(' ') || undefined
2887
+
2888
+ // The shortcut's job is to put the session in plan mode **now**. It used to
2889
+ // only forward a prompt asking the model to call EnterPlanMode, so the mode
2890
+ // changed only if the model cooperated — a shortcut with no landing point.
2891
+ // Read the mode back: the organisation's ceiling can clamp the request.
2892
+ let modeNote = ''
2893
+ if (liveMode(ctx) !== 'plan') {
2894
+ if (!ctx.setPermissionMode) {
2895
+ modeNote = 'This surface cannot switch permission modes — use Shift+Tab.\n\n'
2896
+ } else {
2897
+ ctx.setPermissionMode('plan')
2898
+ const now = liveMode(ctx)
2899
+ modeNote =
2900
+ now === 'plan'
2901
+ ? '✓ Plan mode on — edits stay refused until you /approve or /no-plan.\n\n'
2902
+ : `Plan mode was requested, but the organisation's permission limit kept the mode at ${now}.\n\n`
2903
+ }
2904
+ }
2905
+
2887
2906
  return {
2888
- content: t('commands.plan.content'),
2907
+ content: modeNote + t('commands.plan.content'),
2889
2908
  forwardToAI: description
2890
2909
  ? `Use EnterPlanMode with description: "${description}". Then explore, design, and use ExitPlanMode when ready for approval.`
2891
2910
  : 'Use EnterPlanMode to enter plan mode. Explore the codebase, design an approach, then use ExitPlanMode to submit for approval.',
@@ -2965,7 +2984,7 @@ const todosCmd: CommandHandler = (_ctx, args) => {
2965
2984
  // Phase 1 — New Session Commands
2966
2985
  // ═══════════════════════════════════════════════════════════════
2967
2986
 
2968
- const renameCmd: CommandHandler = (ctx, args) => {
2987
+ const renameCmd: CommandHandler = async (ctx, args) => {
2969
2988
  const t = resolveT(ctx)
2970
2989
  const name = args.join(' ')
2971
2990
  if (!name.trim()) {
@@ -2982,6 +3001,24 @@ const renameCmd: CommandHandler = (ctx, args) => {
2982
3001
  if (finalName === null) {
2983
3002
  return { content: t('commands.rename.unsaved', { name: name.trim() }) }
2984
3003
  }
3004
+ // The saved transcript has its own name — `<name>.jsonl` — and `/resume`
3005
+ // resolves *that* namespace. Renaming only the registry/title left the two
3006
+ // namespaces split: `/rename Bug Fix` succeeded, yet `/resume Bug Fix`
3007
+ // found nothing while `/resume <old>` still did (v2.0.64-004).
3008
+ const log = ctx.engine.getContext().getLog?.()
3009
+ if (log) {
3010
+ const oldName = log.getName()
3011
+ const status = log.rename(finalName)
3012
+ if (status === 'renamed') {
3013
+ const { SessionStore } = await import('../core/session-store')
3014
+ SessionStore.renameEntry(oldName, finalName)
3015
+ } else if (status === 'conflict') {
3016
+ // The title/registry name changed, but the transcript already belongs to
3017
+ // another saved session under that name. Say so instead of claiming a
3018
+ // rename the user cannot resume.
3019
+ return { content: t('commands.rename.log_conflict', { name: finalName, old: oldName }) }
3020
+ }
3021
+ }
2985
3022
  return { content: t('commands.rename.confirmed', { name: finalName }) }
2986
3023
  }
2987
3024
 
@@ -3189,6 +3226,9 @@ const reloadSkillsCmd: CommandHandler = (ctx) => {
3189
3226
  try {
3190
3227
  const config = ctx.config
3191
3228
  ctx.skillsLoader.loadBuiltin(process.cwd())
3229
+ // The project scope is not covered by `loadBuiltin` (that reads
3230
+ // `<cwd>/skills/{standard,mipham}` — the repo's own dev layout).
3231
+ ctx.skillsLoader.loadProjectSkills(process.cwd())
3192
3232
  if (config.skills?.paths) {
3193
3233
  ctx.skillsLoader.loadExternal(config.skills.paths)
3194
3234
  }
@@ -4110,10 +4150,48 @@ const doctorCmd: CommandHandler = async (ctx) => {
4110
4150
  `Provider ${ctx.providerId} / ${ctx.modelId}`,
4111
4151
  `Permission ${liveMode(ctx)}`,
4112
4152
  `Providers ${ctx.config.providers.length} configured (${ctx.config.providers.filter((p) => p.status !== 'upcoming').length} active)`,
4113
- '',
4114
- t('commands.doctor.session_section'),
4115
4153
  ]
4116
4154
 
4155
+ // ── API connectivity (331-003) ──
4156
+ // A boolean status line cannot tell "the endpoint answered 401" from "nothing
4157
+ // answered". Ask the provider for the detail, and name the three non-answers
4158
+ // (no registry, upcoming provider, untested probe) instead of rendering them
4159
+ // as a red dot.
4160
+ lines.push('')
4161
+ lines.push(t('commands.doctor.api_section'))
4162
+ const registry = ctx.engine.getRegistry?.()
4163
+ const activeConfig = ctx.config.providers.find((p) => p.id === ctx.providerId)
4164
+ lines.push(t('commands.doctor.api_target', { provider: ctx.providerId, model: ctx.modelId }))
4165
+ if (!registry) {
4166
+ lines.push(
4167
+ t('commands.doctor.api_not_tested', { reason: 'no provider registry in this session' }),
4168
+ )
4169
+ } else if (typeof registry.probeConnectivity !== 'function') {
4170
+ // A daemon proxy exposes a narrower registry; say the probe is unavailable
4171
+ // rather than calling a method that is not there.
4172
+ lines.push(
4173
+ t('commands.doctor.api_not_tested', { reason: 'this registry has no connectivity probe' }),
4174
+ )
4175
+ } else if (!activeConfig || activeConfig.status === 'upcoming') {
4176
+ lines.push(
4177
+ t('commands.doctor.api_not_tested', { reason: 'the active provider is not configured' }),
4178
+ )
4179
+ } else {
4180
+ const probe = await registry.probeConnectivity(ctx.providerId)
4181
+ if (!probe) {
4182
+ lines.push(t('commands.doctor.api_not_tested', { reason: 'provider not registered' }))
4183
+ } else if (!probe.tested) {
4184
+ lines.push(t('commands.doctor.api_not_tested', { reason: probe.detail }))
4185
+ } else if (probe.ok) {
4186
+ lines.push(t('commands.doctor.api_reachable', { detail: probe.detail }))
4187
+ } else {
4188
+ lines.push(t('commands.doctor.api_unreachable', { detail: probe.detail }))
4189
+ }
4190
+ }
4191
+
4192
+ lines.push('')
4193
+ lines.push(t('commands.doctor.session_section'))
4194
+
4117
4195
  const c = ctx.engine.getContext()
4118
4196
  const tokens = c.getEstimatedTokens()
4119
4197
  const maxTokens = c.getMaxTokens()
@@ -6872,6 +6950,7 @@ const commandsListCmd: CommandHandler = () => {
6872
6950
  '/providers': 'Model & Provider',
6873
6951
  '/switch': 'Model & Provider',
6874
6952
  '/config': 'Model & Provider',
6953
+ '/settings': 'Model & Provider',
6875
6954
  '/effort': 'Model & Provider',
6876
6955
  '/upgrade': 'Model & Provider',
6877
6956
  '/tools': 'Tools & Skills',
@@ -6953,6 +7032,7 @@ const commandsListCmd: CommandHandler = () => {
6953
7032
  '/commit': 'Workflow',
6954
7033
  '/push': 'Workflow',
6955
7034
  '/pr': 'Workflow',
7035
+ '/ship': 'Workflow',
6956
7036
  '/issue': 'Workflow',
6957
7037
  '/code-review': 'Code Quality',
6958
7038
  '/simplify': 'Code Quality',
@@ -7082,6 +7162,7 @@ registry.set('/ollama-refresh', ollamaRefreshCmd)
7082
7162
  registry.set('/provider', providerCmd)
7083
7163
  registry.set('/providers', providersCmd)
7084
7164
  registry.set('/config', configCmd)
7165
+ registry.set('/settings', configCmd) // CC-compatible alias
7085
7166
  registry.set('/effort', effortCmd)
7086
7167
  registry.set('/switch', switchCmd)
7087
7168
 
@@ -7199,6 +7280,7 @@ registry.set('/schedule', scheduleCmd)
7199
7280
  registry.set('/commit', commitCmd)
7200
7281
  registry.set('/push', pushCmd)
7201
7282
  registry.set('/pr', prCmd)
7283
+ registry.set('/ship', shipCmd)
7202
7284
  registry.set('/issue', issueCmd)
7203
7285
 
7204
7286
  // Code Quality (Claude Code parity)
@@ -7328,6 +7410,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
7328
7410
  '/providers': 'List configured providers',
7329
7411
  '/switch': 'Switch provider and model',
7330
7412
  '/config': 'View configuration',
7413
+ '/settings': 'View configuration (alias of /config)',
7331
7414
  '/effort': 'Set the stream stall budget (does not change reasoning depth)',
7332
7415
  '/lang': 'Set display language (en-US, zh-CN)',
7333
7416
  '/tools': 'List available tools',
@@ -7412,6 +7495,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
7412
7495
  '/commit': 'Draft a commit message from staged changes',
7413
7496
  '/push': 'Show push status and the command to run',
7414
7497
  '/pr': 'Draft a pull request title and body',
7498
+ '/ship': 'Commit, push, open a PR, review and fix it — never merges',
7415
7499
  '/issue': 'Draft a GitHub issue from your description',
7416
7500
  '/code-review': 'Review code for bugs, security, performance (7 dimensions)',
7417
7501
  '/simplify': 'Cleanup-only review: reuse, simplification, efficiency, abstraction',
@@ -7436,6 +7520,38 @@ export function getCommandList(): CommandEntry[] {
7436
7520
  }))
7437
7521
  }
7438
7522
 
7523
+ /**
7524
+ * Match and **rank** slash commands for a query.
7525
+ *
7526
+ * Both slash surfaces used to filter with `includes()` and take the first
7527
+ * entry of an alphabetically sorted list, so a description match could outrank
7528
+ * the command the user was typing: `/memory` (description match on `/dream`'s
7529
+ * "Background memory consolidation") selected `/dream`, and Enter ran it.
7530
+ *
7531
+ * Order: exact name > name prefix > name substring > description-only. Within
7532
+ * a rank the alphabetical order is kept, so the result stays predictable.
7533
+ * Description matches are still included (a user looking for "fork" should see
7534
+ * a command *described* as forking); they simply no longer outrank names.
7535
+ */
7536
+ export function rankCommandMatches<T extends CommandEntry>(commands: T[], query: string): T[] {
7537
+ const q = query.trim().toLowerCase()
7538
+ if (!q) return commands
7539
+ const scored: Array<{ cmd: T; rank: number }> = []
7540
+ for (const cmd of commands) {
7541
+ const name = cmd.name.toLowerCase()
7542
+ const bare = name.startsWith('/') ? name.slice(1) : name
7543
+ let rank: number
7544
+ if (bare === q) rank = 0
7545
+ else if (bare.startsWith(q)) rank = 1
7546
+ else if (bare.includes(q)) rank = 2
7547
+ else if (cmd.description.toLowerCase().includes(q)) rank = 3
7548
+ else continue
7549
+ scored.push({ cmd, rank })
7550
+ }
7551
+ scored.sort((a, b) => a.rank - b.rank || a.cmd.name.localeCompare(b.cmd.name))
7552
+ return scored.map((s) => s.cmd)
7553
+ }
7554
+
7439
7555
  export function looksLikeSlashCommand(input: string): boolean {
7440
7556
  return input.trim().startsWith('/')
7441
7557
  }
package/src/ui/input.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect, useRef, useMemo } from 'react'
2
2
  import { Box, Text, useInput } from 'ink'
3
- import { getCommandList } from './commands.js'
3
+ import { getCommandList, rankCommandMatches } from './commands.js'
4
4
  import { CommandPicker } from './command-picker.js'
5
5
  import { useI18n } from '../i18n-context'
6
6
  import { discoverSessions } from '../agent/cross-session/discovery'
@@ -41,6 +41,14 @@ interface InputBarProps {
41
41
  autocompleteEnabled?: boolean
42
42
  /** 默认 400ms;app.tsx 传 config.autocomplete?.debounceMs ?? 400。 */
43
43
  autocompleteDebounceMs?: number
44
+ /**
45
+ * 草稿文本(由调用方持有)。本组件会被调用方卸载(模型选择器 / API-key 提示 /
46
+ * Ctrl+G 面板),草稿若只活在这里会随卸载消失;调用方持有后,重新挂载时从
47
+ * 这里取回。
48
+ */
49
+ draft?: string
50
+ /** 每次草稿变化同步给调用方。 */
51
+ onDraftChange?: (value: string) => void
44
52
  }
45
53
 
46
54
  // ── Loading verb keys (i18n) ──
@@ -396,9 +404,19 @@ export function InputBar({
396
404
  recentMessages,
397
405
  autocompleteEnabled = true,
398
406
  autocompleteDebounceMs = 400,
407
+ draft,
408
+ onDraftChange,
399
409
  }: InputBarProps) {
400
410
  const { t } = useI18n()
401
- const [value, setValue] = useState('')
411
+ // The draft is seeded from the caller's copy and mirrored back on every change.
412
+ // `app.tsx` unmounts this component when the model picker / API-key prompt /
413
+ // agent view opens; history was hoisted above for exactly that reason, and the
414
+ // typed text was not — opening the picker mid-prompt silently ate it.
415
+ const [value, setLocalValue] = useState(draft ?? '')
416
+ const setValue = (next: string): void => {
417
+ setLocalValue(next)
418
+ onDraftChange?.(next)
419
+ }
402
420
  // Ref mirror of value — used by useInput to read latest without stale closure.
403
421
  const valueRef = useRef(value)
404
422
  // Ref mirror of `pickerActive` for the same reason, and one more: the key
@@ -457,12 +475,7 @@ export function InputBar({
457
475
  // filter hid commands a user was plainly looking for ("fork" should surface a
458
476
  // command described as "fork the conversation"), so the two slash surfaces now
459
477
  // agree on one semantic.
460
- return allCommands
461
- .filter(
462
- (c) =>
463
- c.name.toLowerCase().includes(filter) || c.description.toLowerCase().includes(filter),
464
- )
465
- .slice(0, 8)
478
+ return rankCommandMatches(allCommands, filter).slice(0, 8)
466
479
  }, [value, allCommands])
467
480
 
468
481
  // ── @mention hints (cross-session recipients) ──
package/src/ui/picker.tsx CHANGED
@@ -106,7 +106,7 @@ export function ModelPicker({
106
106
  }
107
107
 
108
108
  // Tab or right arrow → switch to model panel
109
- if (key.tab || (activePanel.read() === 'provider' && input === 'l')) {
109
+ if (key.tab || key.rightArrow || (activePanel.read() === 'provider' && input === 'l')) {
110
110
  activePanel.set('model')
111
111
  return
112
112
  }