@miphamai/cli 0.85.29 → 0.85.30

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Mipham Code v0.85.29
1
+ # Mipham Code v0.85.30
2
2
 
3
3
  **Multi-model open-core intelligent coding terminal** — 12 AI providers, 138 commands, 31 tools, 28 skills + marketplace, self-update. AI-assisted code generation, security auditing, MCP protocol, and extensible skills — in a single CLI.
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miphamai/cli",
3
- "version": "0.85.29",
3
+ "version": "0.85.30",
4
4
  "description": "Mipham Code — Multi-model open-core intelligent coding terminal by MiphamAI",
5
5
  "keywords": [
6
6
  "ai",
@@ -38,7 +38,10 @@ export function AgentViewDashboard({ manager, onAttach, onExit }: DashboardProps
38
38
  // 时会**合并成一个**事件(实测 `'j\r'` → 单个 `input="j\r"`、`key.return` 为 false),
39
39
  // 两个分支都不匹配 ⇒ 症状是「这一拍什么也没发生」,不是「作用在上一行」。
40
40
  // 换句话说这一格没有可复现的故障,迁过去只会让测试**改前改后都绿**。
41
- const [selectedIndex, setSelectedIndex] = useState(0)
41
+ // 选中的是**会话 id**,不是一个位置。列表每次变化都按状态重新分组(一个 agent 跑完
42
+ // 就从 Working 挪到 Done),位置会在两次按键之间指向别的行 —— Enter / Ctrl+X 于是
43
+ // 作用在用户没看着的那个 agent 身上(314-050)。位置由 id 现算。
44
+ const [selectedId, setSelectedId] = useState<string | null>(null)
42
45
  const [peekingSessionId, setPeekingSessionId] = useState<string | null>(null)
43
46
  const [groupBy, setGroupBy] = useState<'status' | 'directory'>('status')
44
47
  const [feedback, setFeedback] = useState<string | null>(null)
@@ -122,6 +125,21 @@ export function AgentViewDashboard({ manager, onAttach, onExit }: DashboardProps
122
125
  [flatList],
123
126
  )
124
127
 
128
+ // 位置**现算**:选中 id 不在列表里(还没选 / 被移除了)时回落到第一行。
129
+ const selectedIndex = useMemo(() => {
130
+ const i = sessionsOnly.findIndex((s) => s.session.id === selectedId)
131
+ return i >= 0 ? i : 0
132
+ }, [sessionsOnly, selectedId])
133
+
134
+ /** 选中第 i 行 —— 记 id,不记位置。 */
135
+ const selectAt = useCallback(
136
+ (i: number) => {
137
+ const next = sessionsOnly[i]
138
+ if (next) setSelectedId(next.session.id)
139
+ },
140
+ [sessionsOnly],
141
+ )
142
+
125
143
  const handleAttach = useCallback(
126
144
  (sessionId: string) => {
127
145
  const session = manager.attach(sessionId)
@@ -225,9 +243,16 @@ export function AgentViewDashboard({ manager, onAttach, onExit }: DashboardProps
225
243
  // stops nothing, and the running sub-agent checks the registry's abort
226
244
  // signal. So: stop the task, then remove the row.
227
245
  const stopped = session.taskId ? getBackgroundAgentRegistry().stop(session.taskId) : false
246
+ // 光标交给**顶上来那一行**(没有就交给上一行),按 id 记 —— 位置在下一次
247
+ // 重新分组时会被别的 agent 占掉。
248
+ const removingIdx = selectedIndex
249
+ const nextId =
250
+ sessionsOnly[removingIdx + 1]?.session.id ??
251
+ sessionsOnly[removingIdx - 1]?.session.id ??
252
+ null
228
253
  manager.remove(session.id)
229
254
  setPeekingSessionId(null)
230
- setSelectedIndex((prev) => Math.max(0, Math.min(prev, sessionsOnly.length - 2)))
255
+ setSelectedId(nextId)
231
256
  showFeedback(
232
257
  stopped
233
258
  ? `Stopped + removed ${session.title || session.id}`
@@ -241,7 +266,7 @@ export function AgentViewDashboard({ manager, onAttach, onExit }: DashboardProps
241
266
  showFeedback('No sessions to navigate — spawn a background agent first')
242
267
  return
243
268
  }
244
- setSelectedIndex((prev) => Math.min(prev + 1, sessionsOnly.length - 1))
269
+ selectAt(Math.min(selectedIndex + 1, sessionsOnly.length - 1))
245
270
  setPeekingSessionId(null)
246
271
  return
247
272
  }
@@ -251,7 +276,7 @@ export function AgentViewDashboard({ manager, onAttach, onExit }: DashboardProps
251
276
  showFeedback('No sessions to navigate — spawn a background agent first')
252
277
  return
253
278
  }
254
- setSelectedIndex((prev) => Math.max(prev - 1, 0))
279
+ selectAt(Math.max(selectedIndex - 1, 0))
255
280
  setPeekingSessionId(null)
256
281
  return
257
282
  }
@@ -358,14 +383,12 @@ export function AgentViewDashboard({ manager, onAttach, onExit }: DashboardProps
358
383
  )
359
384
  }
360
385
 
361
- // Map this session's position in sessionsOnly to selectedIndex
362
- const sessionIdx = sessionsOnly.findIndex((s) => s.session.id === item.session.id)
363
-
364
386
  return (
365
387
  <SessionRow
366
388
  key={item.session.id}
367
389
  session={item.session}
368
- isSelected={sessionIdx === selectedIndex}
390
+ // 按 id 比对:下面这行按位置取到的就是当前选中的那一位
391
+ isSelected={item.session.id === sessionsOnly[selectedIndex]?.session.id}
369
392
  />
370
393
  )
371
394
  })}
@@ -1418,7 +1418,7 @@ export class QueryEngine {
1418
1418
  const hint = isMcpTool
1419
1419
  ? `\nMCP tool "${name}" is no longer available. The MCP server may have been removed or disconnected. Use tool-search to discover available tools.`
1420
1420
  : `\nTool "${name}" is not registered. Available tools may have changed — check the tool list.`
1421
- return { success: false, content: '', error: `Unknown tool: ${name}${hint}` }
1421
+ return { success: false, content: '', error: `Unknown tool: ${name}${hint}`, notRun: true }
1422
1422
  }
1423
1423
 
1424
1424
  // Security: check permission before executing.
@@ -1442,10 +1442,11 @@ export class QueryEngine {
1442
1442
  success: false,
1443
1443
  content: '',
1444
1444
  error: baseError + moveOnHint,
1445
- // Held back, not judged: the auto-mode classifier had no usable answer.
1446
- // The display says "Not run" for these instead of showing a result line
1447
- // that reads as if the tool had run and returned that text (296-056).
1448
- notRun: decision.retryable === true,
1445
+ // It did not run. Whatever refused it — a deny rule, the mode, or the
1446
+ // auto-mode classifier with no usable answer — the text below is a
1447
+ // *reason*, not output, and a collapsed tool group otherwise renders it
1448
+ // as a result line (296-056, 314-031).
1449
+ notRun: true,
1449
1450
  }
1450
1451
  }
1451
1452
  // P1-4: Tool allowed — reset block counter
@@ -1461,6 +1462,7 @@ export class QueryEngine {
1461
1462
  success: false,
1462
1463
  content: '',
1463
1464
  error: preResult.reason || t('errors.tool_blocked', { name }),
1465
+ notRun: true,
1464
1466
  }
1465
1467
  }
1466
1468
 
@@ -1477,6 +1479,7 @@ export class QueryEngine {
1477
1479
  success: false,
1478
1480
  content: '',
1479
1481
  error: preResult.reason || t('errors.tool_hook_ask', { name }),
1482
+ notRun: true,
1480
1483
  }
1481
1484
  }
1482
1485
 
@@ -1611,7 +1614,7 @@ export class QueryEngine {
1611
1614
  success: false,
1612
1615
  content: '',
1613
1616
  error: this.buildDenialError(name, tool, effectiveParams, recheck),
1614
- notRun: recheck.retryable === true,
1617
+ notRun: true,
1615
1618
  }
1616
1619
  }
1617
1620
  }
@@ -9,7 +9,7 @@
9
9
  export const PACKAGE_NAME = '@miphamai/cli' as const
10
10
 
11
11
  /** 当前发布版本 */
12
- export const PACKAGE_VERSION = '0.85.29' as const
12
+ export const PACKAGE_VERSION = '0.85.30' as const
13
13
 
14
14
  /** npm install 全局安装命令 */
15
15
  export const NPM_INSTALL_COMMAND = `npm install -g ${PACKAGE_NAME}` as const
@@ -90,4 +90,4 @@ export const TOOL_COUNT = 31 as const
90
90
  * —— `test/e2e/full-pipeline.test.ts` 在 Linux 上整文件 skip、在 macOS 上跑 ——
91
91
  * 但**总数相同**(两边都把被 skip 的算进去)。
92
92
  */
93
- export const TEST_COUNT = 4612 as const
93
+ export const TEST_COUNT = 4620 as const
@@ -102,13 +102,14 @@ export interface ToolResult {
102
102
  content: string
103
103
  error?: string
104
104
  /**
105
- * The call was **held back, not judged** — `auto` mode asked the classifier and
106
- * got no usable answer, so nothing ran and asking again is appropriate (296-056).
105
+ * The call **never ran** — refused before execution by the permission gate, a
106
+ * PreToolUse hook, or `auto` mode's classifier, or the tool was not found.
107
107
  *
108
108
  * It is not a third failure state: `success` stays `false` and `error` still
109
109
  * carries the text the model reads. This bit exists only so the *display* can
110
- * tell "held back" from "ran and returned this", which are otherwise the same
111
- * shape (both are `success: false` + an error string).
110
+ * tell "did not run" from "ran and returned this", which are otherwise the same
111
+ * shape (both are `success: false` + an error string). A collapsed tool group
112
+ * that renders every failure as a result line reads as if the command ran.
112
113
  */
113
114
  notRun?: boolean
114
115
  }
@@ -145,9 +146,9 @@ export interface StreamChunk {
145
146
  */
146
147
  isError?: boolean
147
148
  /**
148
- * `type: 'tool_result'` only. The call never ran because `auto` mode's
149
- * classifier had no usable answer — held back, not judged (296-056). Distinct
150
- * from the `retryable` field below, which describes a *provider* error.
149
+ * `type: 'tool_result'` only. The call never ran — refused by the permission
150
+ * gate, a PreToolUse hook, or `auto` mode's classifier. Distinct from the
151
+ * `retryable` field below, which describes a *provider* error.
151
152
  */
152
153
  notRun?: boolean
153
154
  error?: string
@@ -614,10 +614,23 @@ export function createBashTool(credentialConfig?: CredentialMaskingConfig): Tool
614
614
 
615
615
  try {
616
616
  // ── Credential masking: filter sensitive env vars ──
617
- let spawnEnv: Record<string, string | undefined> | undefined
617
+ let spawnEnv: Record<string, string | undefined> = {
618
+ ...(process.env as Record<string, string | undefined>),
619
+ }
620
+ // bash reads these *before* it runs the command, so an exported one
621
+ // silently reconfigures every command we start:
622
+ // SHELLOPTS — `set -o` options. Exported `errexit` stops a whole
623
+ // script at its first failing statement (`a; false; b` printed only
624
+ // `a`, exit 1), which reads as "the command did less than asked".
625
+ // BASHOPTS — the `shopt` equivalents (`nullglob`, `globstar`, …).
626
+ // BASH_ENV — a file non-interactive bash sources first: arbitrary
627
+ // code from the parent process ahead of the user's command.
628
+ // The parent's shell is not the model's shell; the tool's contract is
629
+ // that the command runs as written.
630
+ for (const key of ['SHELLOPTS', 'BASHOPTS', 'BASH_ENV']) delete spawnEnv[key]
618
631
  if (credentialConfig?.enabled && credentialConfig.env_filter.enabled) {
619
632
  const { filterEnv } = await import('../../core/credential-masker')
620
- spawnEnv = filterEnv(process.env as Record<string, string | undefined>, credentialConfig)
633
+ spawnEnv = filterEnv(spawnEnv, credentialConfig)
621
634
  }
622
635
 
623
636
  const proc = Bun.spawn(['bash', '-c', command], {
package/src/ui/app.tsx CHANGED
@@ -1024,6 +1024,11 @@ export function App({
1024
1024
  async (input: string) => {
1025
1025
  if (!input.trim()) return
1026
1026
 
1027
+ // 用户真正敲的那串。转发型斜杠命令会把 `input` 换成给模型的指令正文
1028
+ // (`input = forwardToAI`),而会话名取自**用户**的话 —— 否则第一条命令就能
1029
+ // 把会话命名成一段内部指令(314-025)。
1030
+ const typedInput = input
1031
+
1027
1032
  // ── @mention: direct cross-session message — only when the name resolves
1028
1033
  // to a live session; otherwise fall through to normal AI processing so a
1029
1034
  // leading `@word` (e.g. "@bob please review") isn't hijacked as a send. ──
@@ -1219,7 +1224,7 @@ export function App({
1219
1224
  ) {
1220
1225
  const currentName = discoverSessions().find((s) => s.id === sessionId)?.name
1221
1226
  if (isDefaultSessionName(currentName, process.cwd())) {
1222
- const title = deriveSessionTitle(input)
1227
+ const title = deriveSessionTitle(typedInput)
1223
1228
  if (title && sessionId) renameActiveSession(sessionId, title)
1224
1229
  }
1225
1230
  }
@@ -1299,6 +1304,10 @@ export function App({
1299
1304
  }
1300
1305
  // Escape: close apiKeyPrompt → close picker → abort loading (does NOT exit app)
1301
1306
  if (key.escape) {
1307
+ // 面板开着时 Esc 归面板(关看板 / 从会话视图退回)。Ink 把同一个按键派发给
1308
+ // **所有**挂载的 `useInput`,所以这里若再跑一遍 `dismissTopmost()`,关面板的
1309
+ // 那一下会顺带 abort 正在跑的主回合 —— 用户想关的是面板,不是停掉对话(314-056)。
1310
+ if (agentViewOpen || attachedSessionId) return
1302
1311
  if (dismissTopmost()) return
1303
1312
  // Otherwise let InputBar handle Escape (clear draft)
1304
1313
  return