@miphamai/cli 0.85.43 → 0.85.44
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 +3 -3
- package/package.json +1 -1
- package/src/agent/agent-context.ts +49 -0
- package/src/agent/agent-registry.ts +6 -0
- package/src/agent/sub-agent.ts +5 -0
- package/src/core/engine.ts +117 -7
- package/src/core/hooks-executor.ts +11 -1
- package/src/core/permission-rules.ts +168 -29
- package/src/core/permission.ts +20 -0
- package/src/core/session-log.ts +39 -1
- package/src/core/session-store.ts +33 -1
- package/src/core/tool-gate.ts +7 -1
- package/src/daemon/engine-capabilities.ts +4 -0
- package/src/i18n-core/locales/en-US.json +6 -1
- package/src/i18n-core/locales/zh-CN.json +6 -1
- package/src/index.tsx +6 -1
- package/src/mcp/registry.ts +11 -3
- package/src/mcp/types.ts +6 -0
- package/src/providers/anthropic.ts +14 -1
- package/src/providers/bootstrap.ts +13 -0
- package/src/providers/openai-compat.ts +6 -1
- package/src/shared/package-info.ts +3 -3
- package/src/shared/types.ts +9 -0
- package/src/skills/loader.ts +30 -0
- package/src/tools/file/glob.ts +58 -6
- package/src/tools/file/grep.ts +9 -1
- package/src/ui/app.tsx +41 -21
- package/src/ui/command-picker.tsx +2 -5
- package/src/ui/commands.ts +79 -4
- package/src/ui/input.tsx +21 -8
- package/src/ui/picker.tsx +1 -1
package/src/ui/commands.ts
CHANGED
|
@@ -2881,11 +2881,30 @@ const changelogCmd: CommandHandler = async (ctx) => {
|
|
|
2881
2881
|
// Workflow
|
|
2882
2882
|
// ═══════════════════════════════════════════════════════════════
|
|
2883
2883
|
|
|
2884
|
-
const planCmd: CommandHandler = (
|
|
2885
|
-
const t = resolveT(
|
|
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
|
}
|
|
@@ -6872,6 +6912,7 @@ const commandsListCmd: CommandHandler = () => {
|
|
|
6872
6912
|
'/providers': 'Model & Provider',
|
|
6873
6913
|
'/switch': 'Model & Provider',
|
|
6874
6914
|
'/config': 'Model & Provider',
|
|
6915
|
+
'/settings': 'Model & Provider',
|
|
6875
6916
|
'/effort': 'Model & Provider',
|
|
6876
6917
|
'/upgrade': 'Model & Provider',
|
|
6877
6918
|
'/tools': 'Tools & Skills',
|
|
@@ -7082,6 +7123,7 @@ registry.set('/ollama-refresh', ollamaRefreshCmd)
|
|
|
7082
7123
|
registry.set('/provider', providerCmd)
|
|
7083
7124
|
registry.set('/providers', providersCmd)
|
|
7084
7125
|
registry.set('/config', configCmd)
|
|
7126
|
+
registry.set('/settings', configCmd) // CC-compatible alias
|
|
7085
7127
|
registry.set('/effort', effortCmd)
|
|
7086
7128
|
registry.set('/switch', switchCmd)
|
|
7087
7129
|
|
|
@@ -7328,6 +7370,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
|
7328
7370
|
'/providers': 'List configured providers',
|
|
7329
7371
|
'/switch': 'Switch provider and model',
|
|
7330
7372
|
'/config': 'View configuration',
|
|
7373
|
+
'/settings': 'View configuration (alias of /config)',
|
|
7331
7374
|
'/effort': 'Set the stream stall budget (does not change reasoning depth)',
|
|
7332
7375
|
'/lang': 'Set display language (en-US, zh-CN)',
|
|
7333
7376
|
'/tools': 'List available tools',
|
|
@@ -7436,6 +7479,38 @@ export function getCommandList(): CommandEntry[] {
|
|
|
7436
7479
|
}))
|
|
7437
7480
|
}
|
|
7438
7481
|
|
|
7482
|
+
/**
|
|
7483
|
+
* Match and **rank** slash commands for a query.
|
|
7484
|
+
*
|
|
7485
|
+
* Both slash surfaces used to filter with `includes()` and take the first
|
|
7486
|
+
* entry of an alphabetically sorted list, so a description match could outrank
|
|
7487
|
+
* the command the user was typing: `/memory` (description match on `/dream`'s
|
|
7488
|
+
* "Background memory consolidation") selected `/dream`, and Enter ran it.
|
|
7489
|
+
*
|
|
7490
|
+
* Order: exact name > name prefix > name substring > description-only. Within
|
|
7491
|
+
* a rank the alphabetical order is kept, so the result stays predictable.
|
|
7492
|
+
* Description matches are still included (a user looking for "fork" should see
|
|
7493
|
+
* a command *described* as forking); they simply no longer outrank names.
|
|
7494
|
+
*/
|
|
7495
|
+
export function rankCommandMatches<T extends CommandEntry>(commands: T[], query: string): T[] {
|
|
7496
|
+
const q = query.trim().toLowerCase()
|
|
7497
|
+
if (!q) return commands
|
|
7498
|
+
const scored: Array<{ cmd: T; rank: number }> = []
|
|
7499
|
+
for (const cmd of commands) {
|
|
7500
|
+
const name = cmd.name.toLowerCase()
|
|
7501
|
+
const bare = name.startsWith('/') ? name.slice(1) : name
|
|
7502
|
+
let rank: number
|
|
7503
|
+
if (bare === q) rank = 0
|
|
7504
|
+
else if (bare.startsWith(q)) rank = 1
|
|
7505
|
+
else if (bare.includes(q)) rank = 2
|
|
7506
|
+
else if (cmd.description.toLowerCase().includes(q)) rank = 3
|
|
7507
|
+
else continue
|
|
7508
|
+
scored.push({ cmd, rank })
|
|
7509
|
+
}
|
|
7510
|
+
scored.sort((a, b) => a.rank - b.rank || a.cmd.name.localeCompare(b.cmd.name))
|
|
7511
|
+
return scored.map((s) => s.cmd)
|
|
7512
|
+
}
|
|
7513
|
+
|
|
7439
7514
|
export function looksLikeSlashCommand(input: string): boolean {
|
|
7440
7515
|
return input.trim().startsWith('/')
|
|
7441
7516
|
}
|
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
|
-
|
|
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
|
}
|