@miphamai/cli 0.85.44 → 0.85.46

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.
@@ -757,6 +757,64 @@ function changeDirectoryTargets(words: string[], depth = 0): string[] {
757
757
  return out
758
758
  }
759
759
 
760
+ /** Commands whose exit code 1 means "answered, found nothing" — not failure. */
761
+ const NO_MATCH_READERS = new Set(['grep', 'egrep', 'fgrep', 'rg', 'ag', 'ack'])
762
+ /** Commands whose exit code 1 means "the files differ" — not failure. */
763
+ const NO_DIFF_COMMANDS = new Set(['diff', 'cmp'])
764
+
765
+ /**
766
+ * Resolve the base command of the first shell segment, skipping leading
767
+ * assignments, wrappers and their options.
768
+ */
769
+ function firstCommandWords(command: string): string[] {
770
+ const seg = splitShellSegments(command).find((s) => s.trim().length > 0)
771
+ if (!seg) return []
772
+ const words = seg.trim().split(/\s+/)
773
+ let i = 0
774
+ while (
775
+ i < words.length &&
776
+ (/^[A-Za-z_][A-Za-z0-9_]*=/.test(words[i]!) ||
777
+ ['sudo', 'doas', 'env', 'command', 'exec', 'time', 'nice', 'nohup'].includes(words[i]!))
778
+ ) {
779
+ i += 1
780
+ }
781
+ while (i < words.length && words[i]!.startsWith('-')) i += 1
782
+ return words.slice(i)
783
+ }
784
+
785
+ /**
786
+ * Does exit code 1 from this command mean "no matches / no differences"?
787
+ *
788
+ * `grep` answered the question and found nothing; `git diff` found no change.
789
+ * Reporting those as command failures made the model retry a search that had
790
+ * already succeeded, and taught it to read exit 1 as breakage. The detection is
791
+ * deliberately narrow: the command must be a known reader/differ, the exit code
792
+ * exactly 1, and stderr empty (a real error — unreadable file, bad regex — also
793
+ * exits non-zero but writes a diagnostic).
794
+ *
795
+ * Returns the note to attach, or null when this is an ordinary failure.
796
+ */
797
+ export function noMatchExitNote(command: string, exitCode: number, stderr: string): string | null {
798
+ if (exitCode !== 1 || stderr.trim() !== '') return null
799
+ const words = firstCommandWords(command)
800
+ const base = (words[0] || '').split('/').pop()
801
+ if (!base) return null
802
+ if (NO_MATCH_READERS.has(base)) return 'no matches found'
803
+ if (NO_DIFF_COMMANDS.has(base)) return 'no differences found'
804
+ if (base === 'git') {
805
+ let j = 1
806
+ while (j < words.length && words[j]!.startsWith('-')) {
807
+ const opt = words[j]!
808
+ j += 1
809
+ if (['-C', '-c', '--git-dir', '--work-tree'].includes(opt) && j < words.length) j += 1
810
+ }
811
+ const sub = (words[j] || '').split('/').pop()
812
+ if (sub === 'grep') return 'no matches found'
813
+ if (sub === 'diff') return 'no differences found'
814
+ }
815
+ return null
816
+ }
817
+
760
818
  export function createBashTool(credentialConfig?: CredentialMaskingConfig): ToolDefinition {
761
819
  return {
762
820
  name: 'Bash',
@@ -938,7 +996,11 @@ export function createBashTool(credentialConfig?: CredentialMaskingConfig): Tool
938
996
  ? (await import('../../core/credential-masker')).maskOutput(rawStderr, credentialConfig)
939
997
  : rawStderr
940
998
 
941
- if (exitCode !== 0) {
999
+ // `grep`/`git diff` exit 1 when they answered and found nothing. That is
1000
+ // a result, not a failure (CC 2.1.144-012).
1001
+ const noMatchNote = aborted || timedOut ? null : noMatchExitNote(command, exitCode, stderr)
1002
+
1003
+ if (exitCode !== 0 && !noMatchNote) {
942
1004
  let errorContent = output.slice(0, 5_000)
943
1005
  if (violations.length > 0) {
944
1006
  errorContent += '\n\n── Sandbox Violations ──\n' + violations.join('\n')
@@ -994,6 +1056,9 @@ export function createBashTool(credentialConfig?: CredentialMaskingConfig): Tool
994
1056
  (successContent.length > 0 ? '\n\n' : '') + '── stderr ──\n' + stderrText
995
1057
  }
996
1058
  if (successContent.length === 0) successContent = '(no output)'
1059
+ if (noMatchNote) {
1060
+ successContent += `\n\n[exit code 1: ${noMatchNote} — not a failure]`
1061
+ }
997
1062
  if (violations.length > 0) {
998
1063
  successContent += '\n\n── Sandbox Violations ──\n' + violations.join('\n')
999
1064
  }
@@ -382,6 +382,17 @@ export function createGitTool(
382
382
 
383
383
  if (exitCode !== 0) {
384
384
  const stderr = await new Response(proc.stderr).text()
385
+ // `git diff` exits 1 when the trees differ and `git grep` exits 1 when
386
+ // nothing matched. Both answered the question; neither is a failure
387
+ // (CC 2.1.144-012). A real error also exits non-zero but writes a
388
+ // diagnostic to stderr, so that half stays on the error path.
389
+ const sub = argv[subcommandIndex(argv)]
390
+ if (exitCode === 1 && stderr.trim() === '' && (sub === 'diff' || sub === 'grep')) {
391
+ return {
392
+ success: true,
393
+ content: (await scrub(output)).slice(0, 50_000) || '(no output)',
394
+ }
395
+ }
385
396
  return {
386
397
  success: false,
387
398
  content: '',
@@ -120,13 +120,26 @@ export const editTool: ToolDefinition = {
120
120
  // O_NONBLOCK only got us past the *open*. It does not bound the read:
121
121
  // `/dev/zero` yields bytes forever (OOM) and a FIFO yields whatever a
122
122
  // writer chooses to send. Refuse on file type, not on size.
123
- if (!fstatSync(rfd).isFile()) {
123
+ const stat = fstatSync(rfd)
124
+ if (!stat.isFile()) {
124
125
  return {
125
126
  success: false,
126
127
  content: '',
127
128
  error: `Path is not a regular file (FIFO, socket or device): ${filePath}`,
128
129
  }
129
130
  }
131
+ // Bound the read *before* it happens. The 10 MB check below runs on
132
+ // `content.length` — by then the whole file is already in memory, so a
133
+ // multi-GB file OOMs the process before the guard can speak. 4 is the
134
+ // UTF-8 bytes-per-code-unit ceiling, so `size > 4 × MAX` guarantees the
135
+ // post-read character check would have refused it anyway.
136
+ if (stat.size > MAX_FILE_SIZE * 4) {
137
+ return {
138
+ success: false,
139
+ content: '',
140
+ error: `File too large (${(stat.size / 1e6).toFixed(1)} MB). Max: 10 MB.`,
141
+ }
142
+ }
130
143
  const raw = readFileSync(rfd)
131
144
  if (!isValidUtf8(raw)) {
132
145
  return {
@@ -28,6 +28,16 @@ const GLOB_IGNORE_BATCH = 500
28
28
  * Filtering is a convenience; silently returning *nothing* because git could
29
29
  * not answer would be indistinguishable from "no matches".
30
30
  */
31
+ /**
32
+ * Jujutsu (`.jj`) and Sapling (`.sl`) keep repository metadata in those
33
+ * directories — the equivalent of `.git`. ripgrep and `Bun.Glob` only know the
34
+ * older VCS names, so without this a search descends into a second copy of the
35
+ * worktree (CC 2.1.86-002).
36
+ */
37
+ export function isVcsMetadataPath(path: string): boolean {
38
+ return path.split(/[\\/]/).some((segment) => segment === '.jj' || segment === '.sl')
39
+ }
40
+
31
41
  export function filterGitIgnored(paths: string[], cwd: string): string[] {
32
42
  if (paths.length === 0) return paths
33
43
  const ignored = new Set<string>()
@@ -71,7 +81,8 @@ export function createGlobTool(credentialConfig?: CredentialMaskingConfig): Tool
71
81
  // 却仍报「截断到 500」;反过来先过滤再数,截断标记描述的才是真实结果集。
72
82
  const keep = (batch: string[]) => {
73
83
  if (batch.length === 0) return
74
- for (const p of filterGitIgnored(batch, basePath)) results.push(p)
84
+ const visible = batch.filter((p) => !isVcsMetadataPath(p))
85
+ for (const p of filterGitIgnored(visible, basePath)) results.push(p)
75
86
  }
76
87
  for await (const file of glob.scan({ cwd: basePath, absolute: true })) {
77
88
  pending.push(file)
@@ -173,7 +173,23 @@ export function createGrepTool(credentialConfig?: CredentialMaskingConfig): Tool
173
173
  }
174
174
 
175
175
  // 1. ripgrep (fast path)
176
- const rgArgs = ['rg', '-n', '--heading', '--color=never', '-M', '500', pattern]
176
+ // `.jj`/`.sl` are Jujutsu/Sapling metadata; ripgrep only ignores `.git`,
177
+ // `.hg`, `.svn` and `.bzr` by default, so a search would descend into the
178
+ // other VCS's copy of the worktree (CC 2.1.86-002). First, so an explicit
179
+ // `include` can still name them.
180
+ const rgArgs = [
181
+ 'rg',
182
+ '-n',
183
+ '--heading',
184
+ '--color=never',
185
+ '-M',
186
+ '500',
187
+ '--glob',
188
+ '!.jj',
189
+ '--glob',
190
+ '!.sl',
191
+ pattern,
192
+ ]
177
193
  if (include) rgArgs.push('--glob', include)
178
194
  rgArgs.push(searchPath)
179
195
  try {
@@ -58,8 +58,15 @@ export const toolSearchTool: ToolDefinition = {
58
58
  required: [],
59
59
  },
60
60
  async execute(params, ctx) {
61
- const query = ((params.query as string) || '').toLowerCase()
62
- const serverFilter = (params.server as string) || ''
61
+ const rawQuery = ((params.query as string) || '').toLowerCase()
62
+ // A caller often pastes the *fully qualified* name it saw in a tool listing
63
+ // (`mcp__server__tool`). Matching that whole string against the bare tool
64
+ // name found nothing, and the fallback description matcher surfaced
65
+ // unrelated siblings — the tool that was named did not appear at all
66
+ // (CC 2.1.113-031). Split it back into server + tool name.
67
+ const qualified = /^mcp__(.+?)__(.+)$/.exec(rawQuery)
68
+ const query = qualified ? qualified[2]!.replace(/\*+$/, '') : rawQuery
69
+ const serverFilter = (params.server as string) || (qualified ? qualified[1]! : '')
63
70
  const limit = (params.limit as number) || 20
64
71
 
65
72
  const client = McpClient.getInstance()
@@ -95,6 +102,8 @@ export const toolSearchTool: ToolDefinition = {
95
102
  server: string
96
103
  tool: string
97
104
  description: string
105
+ /** Exact name > name prefix > name substring > description only. */
106
+ score: number
98
107
  }
99
108
 
100
109
  const matches: Match[] = []
@@ -103,13 +112,24 @@ export const toolSearchTool: ToolDefinition = {
103
112
  try {
104
113
  const tools = client.getTools(serverName)
105
114
  for (const tool of tools) {
106
- const nameMatch = !query || tool.name.toLowerCase().includes(query)
107
- const descMatch = !query || (tool.description || '').toLowerCase().includes(query)
108
- if (nameMatch || descMatch) {
115
+ const name = tool.name.toLowerCase()
116
+ const score = !query
117
+ ? 1
118
+ : name === query
119
+ ? 4
120
+ : name.startsWith(query)
121
+ ? 3
122
+ : name.includes(query)
123
+ ? 2
124
+ : (tool.description || '').toLowerCase().includes(query)
125
+ ? 1
126
+ : 0
127
+ if (score > 0) {
109
128
  matches.push({
110
129
  server: serverName,
111
130
  tool: tool.name,
112
131
  description: capMcpText(tool.description || ''),
132
+ score,
113
133
  })
114
134
  }
115
135
  }
@@ -118,6 +138,10 @@ export const toolSearchTool: ToolDefinition = {
118
138
  }
119
139
  }
120
140
 
141
+ // The name the caller typed must come first; description-only siblings are
142
+ // the noise that buried it.
143
+ matches.sort((a, b) => b.score - a.score || a.tool.localeCompare(b.tool))
144
+
121
145
  if (matches.length === 0) {
122
146
  // A zero-hit answer is the wrong answer when the name the caller searched
123
147
  // for is a *built-in* tool: nothing is missing, it was never an MCP tool.
@@ -11,6 +11,39 @@ const bundles: Record<string, TranslationMap> = {
11
11
  }
12
12
  const t = createT(bundles['en-US'] || (enUS as TranslationMap), enUS as TranslationMap)
13
13
 
14
+ /**
15
+ * Coerce scalars the model sent as strings into the type the schema declares.
16
+ *
17
+ * Models occasionally emit `"true"` for a boolean, or `" 5 "` / `"+5"` for a
18
+ * numeric `offset`/`limit`. Type-checking those verbatim rejected an otherwise
19
+ * well-formed call ("expected boolean, received string"), so the model spent a
20
+ * turn re-typing a value it had already supplied. Only the exact spellings that
21
+ * cannot mean anything else are converted; everything else is left for
22
+ * `validateParams` to refuse.
23
+ */
24
+ function coerceScalars(
25
+ schema: Record<string, unknown>,
26
+ params: Record<string, unknown>,
27
+ ): Record<string, unknown> {
28
+ const properties = schema.properties as Record<string, { type: string }> | undefined
29
+ if (!properties) return params
30
+ const out = { ...params }
31
+ for (const [key, def] of Object.entries(properties)) {
32
+ const value = out[key]
33
+ if (typeof value !== 'string') continue
34
+ const trimmed = value.trim()
35
+ if (def.type === 'boolean') {
36
+ if (trimmed === 'true') out[key] = true
37
+ else if (trimmed === 'false') out[key] = false
38
+ } else if (def.type === 'integer') {
39
+ if (/^[+-]?\d+$/.test(trimmed)) out[key] = Number(trimmed)
40
+ } else if (def.type === 'number') {
41
+ if (/^[+-]?\d+(?:\.\d+)?$/.test(trimmed)) out[key] = Number(trimmed)
42
+ }
43
+ }
44
+ return out
45
+ }
46
+
14
47
  /**
15
48
  * Validate tool parameters against the tool's JSON Schema definition.
16
49
  * Returns an array of error messages (empty = valid).
@@ -87,7 +120,7 @@ export function withValidation(tool: ToolDefinition): ToolDefinition {
87
120
  }
88
121
  }
89
122
 
90
- const cleanParams = sanitizeParams(params)
123
+ const cleanParams = coerceScalars(schema, sanitizeParams(params))
91
124
  const errors = validateParams(schema, cleanParams)
92
125
  if (errors.length > 0) {
93
126
  return {
package/src/ui/app.tsx CHANGED
@@ -1,7 +1,6 @@
1
1
  import React, { useState, useCallback, useEffect, useRef, useMemo } from 'react'
2
2
  import { Box, Text, useInput } from 'ink'
3
3
  import TextInput from 'ink-text-input'
4
- import { execSync } from 'node:child_process'
5
4
  import { ErrorBoundary } from './error-boundary'
6
5
  import { useCtrlCConfirm } from './ctrl-c-confirm'
7
6
  import { formatThinking } from './thinking'
@@ -11,7 +10,7 @@ import type { MiphamConfig } from '../shared/index.ts'
11
10
  import type { Llm } from '../providers/llm'
12
11
  import { AUTOCOMPLETE_MAX_CONTEXT, type RecentMessage } from '../core/autocomplete'
13
12
  import { MODE_CYCLE } from '../core/permission-config'
14
- import { resolveGitPr, prColor, type GitPr } from '../core/git-pr'
13
+ import { readGitBranch, resolveGitPr, prColor, type GitPr } from '../core/git-pr'
15
14
  import type { SkillsLoader } from '../skills/loader'
16
15
  import type { PluginManager } from '../plugin/plugin-manager'
17
16
  import { setPreference } from '../config/preferences'
@@ -388,21 +387,10 @@ export function App({
388
387
  // InputBar is unmounted by the picker / API-key prompt / agent view.
389
388
  const [inputDraft, setInputDraft] = useState('')
390
389
  const [updateStatus, setUpdateStatus] = useState<UpdateStatus | null>(null)
391
- // Current git branch — read once at mount (not a git repo → null).
392
- // `stdio` 显式给:默认下 git 的 stderr 是继承的,「不是仓库」这个正常路径会把
393
- // `fatal:` 漏到终端上(与 `core/instructions.ts` 的 `gitRoot` 同一件事)。
394
- // stdout 仍须是管道,否则读到的永远是空串 —— 分支名直接消失,且不报错。
395
- const [gitBranch] = useState<string | null>(() => {
396
- try {
397
- const b = execSync('git branch --show-current', {
398
- encoding: 'utf-8',
399
- stdio: ['ignore', 'pipe', 'pipe'],
400
- }).trim()
401
- return b || null
402
- } catch {
403
- return null
404
- }
405
- })
390
+ // Current git branch. Read on demand rather than frozen at mount: `/cd`
391
+ // moves the session into another repository and the footer used to keep
392
+ // naming the previous one's branch (CC 2.1.176-012).
393
+ const [gitBranch, setGitBranch] = useState<string | null>(() => readGitBranch())
406
394
  // Current branch's PR (head = branch) — async detect; gh unavailable / no PR → null.
407
395
  const [gitPr, setGitPr] = useState<GitPr | null>(null)
408
396
  useEffect(() => {
@@ -599,6 +587,7 @@ export function App({
599
587
  version: version || '0.0.0',
600
588
  sessionId: sessionId || '',
601
589
  setSessionTitle: (title: string) => setSessionTitle(title),
590
+ setGitBranch: (branch: string | null) => setGitBranch(branch),
602
591
  setEffort: (level: string) => {
603
592
  setEffort(level)
604
593
  setPreference('lastCodeReviewEffort', level)
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>
@@ -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'
@@ -159,6 +159,8 @@ export interface CommandContext {
159
159
  sessionId: string
160
160
  // Callbacks for commands that mutate App state
161
161
  setSessionTitle: (title: string) => void
162
+ /** Refresh the footer's git branch after the session moves directory (`/cd`). */
163
+ setGitBranch?: (branch: string | null) => void
162
164
  setEffort: (level: string) => void
163
165
  setFocusMode: (on: boolean) => void
164
166
  /** Current focus-view state — `/focus` toggles from this, not from `true`. */
@@ -4150,10 +4152,48 @@ const doctorCmd: CommandHandler = async (ctx) => {
4150
4152
  `Provider ${ctx.providerId} / ${ctx.modelId}`,
4151
4153
  `Permission ${liveMode(ctx)}`,
4152
4154
  `Providers ${ctx.config.providers.length} configured (${ctx.config.providers.filter((p) => p.status !== 'upcoming').length} active)`,
4153
- '',
4154
- t('commands.doctor.session_section'),
4155
4155
  ]
4156
4156
 
4157
+ // ── API connectivity (331-003) ──
4158
+ // A boolean status line cannot tell "the endpoint answered 401" from "nothing
4159
+ // answered". Ask the provider for the detail, and name the three non-answers
4160
+ // (no registry, upcoming provider, untested probe) instead of rendering them
4161
+ // as a red dot.
4162
+ lines.push('')
4163
+ lines.push(t('commands.doctor.api_section'))
4164
+ const registry = ctx.engine.getRegistry?.()
4165
+ const activeConfig = ctx.config.providers.find((p) => p.id === ctx.providerId)
4166
+ lines.push(t('commands.doctor.api_target', { provider: ctx.providerId, model: ctx.modelId }))
4167
+ if (!registry) {
4168
+ lines.push(
4169
+ t('commands.doctor.api_not_tested', { reason: 'no provider registry in this session' }),
4170
+ )
4171
+ } else if (typeof registry.probeConnectivity !== 'function') {
4172
+ // A daemon proxy exposes a narrower registry; say the probe is unavailable
4173
+ // rather than calling a method that is not there.
4174
+ lines.push(
4175
+ t('commands.doctor.api_not_tested', { reason: 'this registry has no connectivity probe' }),
4176
+ )
4177
+ } else if (!activeConfig || activeConfig.status === 'upcoming') {
4178
+ lines.push(
4179
+ t('commands.doctor.api_not_tested', { reason: 'the active provider is not configured' }),
4180
+ )
4181
+ } else {
4182
+ const probe = await registry.probeConnectivity(ctx.providerId)
4183
+ if (!probe) {
4184
+ lines.push(t('commands.doctor.api_not_tested', { reason: 'provider not registered' }))
4185
+ } else if (!probe.tested) {
4186
+ lines.push(t('commands.doctor.api_not_tested', { reason: probe.detail }))
4187
+ } else if (probe.ok) {
4188
+ lines.push(t('commands.doctor.api_reachable', { detail: probe.detail }))
4189
+ } else {
4190
+ lines.push(t('commands.doctor.api_unreachable', { detail: probe.detail }))
4191
+ }
4192
+ }
4193
+
4194
+ lines.push('')
4195
+ lines.push(t('commands.doctor.session_section'))
4196
+
4157
4197
  const c = ctx.engine.getContext()
4158
4198
  const tokens = c.getEstimatedTokens()
4159
4199
  const maxTokens = c.getMaxTokens()
@@ -4845,6 +4885,10 @@ const cdCmd: CommandHandler = async (ctx, args) => {
4845
4885
 
4846
4886
  try {
4847
4887
  process.chdir(resolved)
4888
+ // The branch badge describes the session's directory, not the one it was
4889
+ // opened in; refresh it or `/cd` leaves the previous repository's branch
4890
+ // on screen (CC 2.1.176-012).
4891
+ ctx.setGitBranch?.((await import('../core/git-pr')).readGitBranch())
4848
4892
 
4849
4893
  // `/cd` 只搬了 cwd,而**按目录装载的闸门**分两半:
4850
4894
  // • 能在这里重放的 —— `.mipham/rules/*.md` 与 settings.json 的 permission 规则;
@@ -5407,7 +5451,16 @@ const resumeCmd: CommandHandler = async (ctx, args) => {
5407
5451
  }
5408
5452
  }
5409
5453
 
5410
- const sessions = SessionStore.list()
5454
+ // The running session is on disk too (events are appended as they happen), so
5455
+ // listing every file offered the conversation the user is already in — and
5456
+ // resuming it is a no-op that looks like a broken restore (CC 2.1.73-008).
5457
+ // The live name comes from the log, which `/rename` updates.
5458
+ const { sanitizeSessionName } = await import('../core/session-log')
5459
+ const currentName = ctx.engine.getContext().getLog?.()?.getName() ?? ctx.sessionId
5460
+ const sessions = SessionStore.list().filter(
5461
+ (s) =>
5462
+ s.name !== currentName && sanitizeSessionName(s.name) !== sanitizeSessionName(currentName),
5463
+ )
5411
5464
 
5412
5465
  if (sessions.length === 0) {
5413
5466
  return {
@@ -6994,6 +7047,7 @@ const commandsListCmd: CommandHandler = () => {
6994
7047
  '/commit': 'Workflow',
6995
7048
  '/push': 'Workflow',
6996
7049
  '/pr': 'Workflow',
7050
+ '/ship': 'Workflow',
6997
7051
  '/issue': 'Workflow',
6998
7052
  '/code-review': 'Code Quality',
6999
7053
  '/simplify': 'Code Quality',
@@ -7241,6 +7295,7 @@ registry.set('/schedule', scheduleCmd)
7241
7295
  registry.set('/commit', commitCmd)
7242
7296
  registry.set('/push', pushCmd)
7243
7297
  registry.set('/pr', prCmd)
7298
+ registry.set('/ship', shipCmd)
7244
7299
  registry.set('/issue', issueCmd)
7245
7300
 
7246
7301
  // Code Quality (Claude Code parity)
@@ -7455,6 +7510,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
7455
7510
  '/commit': 'Draft a commit message from staged changes',
7456
7511
  '/push': 'Show push status and the command to run',
7457
7512
  '/pr': 'Draft a pull request title and body',
7513
+ '/ship': 'Commit, push, open a PR, review and fix it — never merges',
7458
7514
  '/issue': 'Draft a GitHub issue from your description',
7459
7515
  '/code-review': 'Review code for bugs, security, performance (7 dimensions)',
7460
7516
  '/simplify': 'Cleanup-only review: reuse, simplification, efficiency, abstraction',