@miphamai/cli 0.85.34 → 0.85.36
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 +4 -4
- package/package.json +1 -1
- package/src/commands/environment.ts +53 -69
- package/src/commands/git.ts +53 -16
- package/src/commands/keys.ts +28 -17
- package/src/commands/project.ts +10 -17
- package/src/commands/workflow-view.ts +24 -6
- package/src/core/context.ts +22 -5
- package/src/core/engine.ts +32 -5
- package/src/core/hooks-config.ts +32 -0
- package/src/core/improvement-track.ts +37 -1
- package/src/core/memory/memory-loader.ts +2 -2
- package/src/core/meta-rule-engine.ts +3 -1
- package/src/core/rule-engine.ts +11 -5
- package/src/core/session-log.ts +14 -6
- package/src/core/task-performance.ts +41 -0
- package/src/daemon/attach-protocol.ts +25 -0
- package/src/daemon/engine-capabilities.ts +124 -2
- package/src/daemon/remote-engine.ts +161 -4
- package/src/daemon/server.ts +13 -1
- package/src/daemon/session-worker.ts +50 -0
- package/src/i18n-core/detect.ts +16 -4
- package/src/i18n-core/locales/en-US.json +7 -5
- package/src/i18n-core/locales/zh-CN.json +7 -5
- package/src/i18n-core/preference.ts +55 -0
- package/src/index.tsx +3 -2
- package/src/mcp/registry.ts +29 -1
- package/src/shared/package-info.ts +3 -3
- package/src/tools/exec/git.ts +82 -0
- package/src/ui/app.tsx +26 -19
- package/src/ui/commands.ts +527 -100
- package/src/ui/strip-indent.ts +9 -4
package/src/tools/exec/git.ts
CHANGED
|
@@ -106,6 +106,85 @@ function isOutsideWorktree(command: string, cwd: string): string | null {
|
|
|
106
106
|
*/
|
|
107
107
|
const PROGRAM_EXECUTING_OPTIONS = ['--upload-pack', '--receive-pack', '--exec-path']
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* `git filter-branch` options whose value is a shell command. `--subdirectory-filter`
|
|
111
|
+
* is deliberately absent: it names a directory, not a program.
|
|
112
|
+
*/
|
|
113
|
+
const FILTER_BRANCH_EXEC_OPTIONS = new Set([
|
|
114
|
+
'--setup',
|
|
115
|
+
'--env-filter',
|
|
116
|
+
'--tree-filter',
|
|
117
|
+
'--index-filter',
|
|
118
|
+
'--parent-filter',
|
|
119
|
+
'--msg-filter',
|
|
120
|
+
'--commit-filter',
|
|
121
|
+
'--tag-name-filter',
|
|
122
|
+
])
|
|
123
|
+
|
|
124
|
+
/** Options that consume the next argv token and take no value of interest here. */
|
|
125
|
+
const GLOBAL_OPTIONS_WITH_VALUE = new Set([
|
|
126
|
+
'-c',
|
|
127
|
+
'--config',
|
|
128
|
+
'-C',
|
|
129
|
+
'--git-dir',
|
|
130
|
+
'--work-tree',
|
|
131
|
+
'--namespace',
|
|
132
|
+
])
|
|
133
|
+
|
|
134
|
+
/** Index of the git subcommand, skipping global options and their values. */
|
|
135
|
+
function subcommandIndex(argv: string[]): number {
|
|
136
|
+
for (let i = 0; i < argv.length; i++) {
|
|
137
|
+
const arg = argv[i]!
|
|
138
|
+
if (GLOBAL_OPTIONS_WITH_VALUE.has(arg)) {
|
|
139
|
+
i++
|
|
140
|
+
continue
|
|
141
|
+
}
|
|
142
|
+
if (arg.startsWith('-')) continue
|
|
143
|
+
return i
|
|
144
|
+
}
|
|
145
|
+
return -1
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Subcommands whose *own* argument is a program for git to run:
|
|
150
|
+
* `bisect run <cmd>`, `submodule foreach <cmd>`, `rebase --exec <cmd>`,
|
|
151
|
+
* and `filter-branch`'s `--*-filter <cmd>` options. Like the option list above,
|
|
152
|
+
* these are code execution reached without the approval prompt Bash would have
|
|
153
|
+
* shown. `maintenance register` only takes a config file; `scalar` is not a git
|
|
154
|
+
* subcommand, so neither is listed.
|
|
155
|
+
*/
|
|
156
|
+
function findProgramExecutingSubcommand(argv: string[]): string | null {
|
|
157
|
+
const at = subcommandIndex(argv)
|
|
158
|
+
if (at === -1) return null
|
|
159
|
+
const sub = argv[at]!
|
|
160
|
+
const next = argv[at + 1]
|
|
161
|
+
|
|
162
|
+
if (sub === 'bisect' && next === 'run') {
|
|
163
|
+
return `bisect run ${argv[at + 2] ?? ''}`.trim()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if ((sub === 'submodule' || sub === 'submodule--helper') && next === 'foreach') {
|
|
167
|
+
return `${sub} foreach ${argv[at + 2] ?? ''}`.trim()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (sub === 'rebase') {
|
|
171
|
+
for (const arg of argv.slice(at + 1)) {
|
|
172
|
+
// `-x` and `--exec` run a command; short flags may be combined (`-ix`).
|
|
173
|
+
if (arg === '--exec' || /^-[a-zA-Z]*x[a-zA-Z]*$/.test(arg)) return `rebase ${arg}`
|
|
174
|
+
if (arg.startsWith('--exec=')) return arg
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (sub === 'filter-branch') {
|
|
179
|
+
for (const arg of argv.slice(at + 1)) {
|
|
180
|
+
const name = arg.includes('=') ? arg.slice(0, arg.indexOf('=')) : arg
|
|
181
|
+
if (FILTER_BRANCH_EXEC_OPTIONS.has(name)) return `filter-branch ${arg}`
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return null
|
|
186
|
+
}
|
|
187
|
+
|
|
109
188
|
/** Config keys whose value git runs as a program. */
|
|
110
189
|
const PROGRAM_EXECUTING_CONFIG_KEY =
|
|
111
190
|
/^(?:core\.(?:sshCommand|pager|askpass|editor)|alias\.|credential\.helper)/i
|
|
@@ -120,6 +199,9 @@ const PROGRAM_EXECUTING_CONFIG_KEY =
|
|
|
120
199
|
* is what git actually gets, so it has no such gap.
|
|
121
200
|
*/
|
|
122
201
|
export function findProgramExecutingArg(argv: string[]): string | null {
|
|
202
|
+
const subcommand = findProgramExecutingSubcommand(argv)
|
|
203
|
+
if (subcommand !== null) return subcommand
|
|
204
|
+
|
|
123
205
|
for (let i = 0; i < argv.length; i++) {
|
|
124
206
|
const arg = argv[i]!
|
|
125
207
|
|
package/src/ui/app.tsx
CHANGED
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
getCommand,
|
|
57
57
|
looksLikeSlashCommand,
|
|
58
58
|
parseSlashCommand,
|
|
59
|
+
unknownCommandMessage,
|
|
59
60
|
handleSwitch,
|
|
60
61
|
type CommandContext,
|
|
61
62
|
} from './commands'
|
|
@@ -307,7 +308,7 @@ export function App({
|
|
|
307
308
|
sessionId,
|
|
308
309
|
agentViewManager,
|
|
309
310
|
}: AppProps) {
|
|
310
|
-
const { t } = useI18n()
|
|
311
|
+
const { t, locale } = useI18n()
|
|
311
312
|
const PERMISSION_LABELS = useMemo<Record<PermissionMode, string>>(
|
|
312
313
|
() => ({
|
|
313
314
|
default: t('ui.permission.manual'),
|
|
@@ -565,8 +566,16 @@ export function App({
|
|
|
565
566
|
engine.setEffort(level)
|
|
566
567
|
},
|
|
567
568
|
setFocusMode: (on: boolean) => setFocusMode(on),
|
|
569
|
+
getFocusMode: () => focusMode,
|
|
568
570
|
setGoal: (text: string) => setGoalText(text),
|
|
569
|
-
setUltracodeMode: (on: boolean) =>
|
|
571
|
+
setUltracodeMode: (on: boolean) => {
|
|
572
|
+
setUltracodeMode(on)
|
|
573
|
+
// The mode must reach the engine: the React state is display-only, and
|
|
574
|
+
// the previous wiring left the instruction alive for exactly one turn.
|
|
575
|
+
// Attached sessions have no local engine to configure (the command
|
|
576
|
+
// refuses there); the guard keeps that a runtime no-op, not a crash.
|
|
577
|
+
if ('setUltracodeMode' in engine) engine.setUltracodeMode(on)
|
|
578
|
+
},
|
|
570
579
|
setUpdateStatus: (s: UpdateStatus) => setUpdateStatus(s),
|
|
571
580
|
// Same read-back as Shift+Tab: `setMode` may clamp the request (org
|
|
572
581
|
// `maxAllowedMode` / `forbiddenModes`), so the footer and the gate must
|
|
@@ -579,6 +588,7 @@ export function App({
|
|
|
579
588
|
skillsLoader,
|
|
580
589
|
pluginManager,
|
|
581
590
|
t,
|
|
591
|
+
locale,
|
|
582
592
|
}),
|
|
583
593
|
[
|
|
584
594
|
engine,
|
|
@@ -589,7 +599,11 @@ export function App({
|
|
|
589
599
|
pluginManager,
|
|
590
600
|
sessionId,
|
|
591
601
|
t,
|
|
602
|
+
locale,
|
|
592
603
|
setPermissionMode,
|
|
604
|
+
// `/focus` reads the live value through `getFocusMode`; without the dep
|
|
605
|
+
// the memoised ctx would keep returning the state it was born with.
|
|
606
|
+
focusMode,
|
|
593
607
|
],
|
|
594
608
|
)
|
|
595
609
|
|
|
@@ -1154,9 +1168,9 @@ export function App({
|
|
|
1154
1168
|
const { command, args } = parseSlashCommand(input)
|
|
1155
1169
|
|
|
1156
1170
|
// Counted here rather than at the registry lookup below: /switch, /pick,
|
|
1157
|
-
// /model-picker, /exit
|
|
1158
|
-
//
|
|
1159
|
-
//
|
|
1171
|
+
// /model-picker, /exit and /quit are special-cased and return before
|
|
1172
|
+
// ever reaching it, so counting there would silently under-report five
|
|
1173
|
+
// of the most-used commands.
|
|
1160
1174
|
//
|
|
1161
1175
|
// `commandLabelFor` collapses unrecognised names into `/unknown` — see it
|
|
1162
1176
|
// for why an unbounded `command_name` is not a cosmetic problem.
|
|
@@ -1197,26 +1211,19 @@ export function App({
|
|
|
1197
1211
|
void exitSession(0)
|
|
1198
1212
|
}
|
|
1199
1213
|
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1214
|
+
let forwardToAI: string | undefined
|
|
1215
|
+
|
|
1216
|
+
const handler = getCommand(command)
|
|
1217
|
+
if (!handler) {
|
|
1218
|
+
// An unrecognised command used to fall through to `return` without
|
|
1219
|
+
// pushing a message — the input vanished and nothing explained it.
|
|
1204
1220
|
setMessages((prev) => [
|
|
1205
1221
|
...prev,
|
|
1206
1222
|
{ role: 'user', content: input },
|
|
1207
|
-
{
|
|
1208
|
-
role: 'system',
|
|
1209
|
-
content: nextFocus
|
|
1210
|
-
? '✓ Focus mode ON — showing only the most recent exchange. Type /focus again to show all.'
|
|
1211
|
-
: '✓ Focus mode OFF — showing all messages.',
|
|
1212
|
-
},
|
|
1223
|
+
{ role: 'system', content: unknownCommandMessage(command) },
|
|
1213
1224
|
])
|
|
1214
1225
|
return
|
|
1215
1226
|
}
|
|
1216
|
-
|
|
1217
|
-
let forwardToAI: string | undefined
|
|
1218
|
-
|
|
1219
|
-
const handler = getCommand(command)
|
|
1220
1227
|
if (handler) {
|
|
1221
1228
|
const result = await handler(mkCtx(), args)
|
|
1222
1229
|
forwardToAI = result.forwardToAI
|