@miphamai/cli 0.85.52 → 0.85.53

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,6 +1,6 @@
1
- # Mipham Code v0.85.52
1
+ # Mipham Code v0.85.53
2
2
 
3
- **Multi-model open-core intelligent coding terminal** — 12 AI providers, 141 commands, 31 tools, 28 skills + marketplace, self-update. AI-assisted code generation, security auditing, MCP protocol, and extensible skills — in a single CLI.
3
+ **Multi-model open-core intelligent coding terminal** — 12 AI providers, 150 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
 
5
5
  Built by [One Mipham Corporation](https://onemipham.com) (北京华安麦逄科技有限公司) | Brand: MiphamAI
6
6
 
@@ -16,7 +16,7 @@ Requirements: **Bun 1.2+** (recommended) or **Node.js 22+**
16
16
  ## Features
17
17
 
18
18
  - **12 AI Providers** — Anthropic Claude · OpenAI GPT · DeepSeek · Kimi (Moonshot) · Google Gemini · Doubao 豆包 · Tencent Hunyuan 混元 · Qwen 通义千问 · MiniMax(国内 / 国际)· Ollama(本地)· MiphamAI
19
- - **141 Slash Commands** — Interactive command picker (↑↓ Enter Esc), intuitive command interface, zero re-learning
19
+ - **150 Slash Commands** — Interactive command picker (↑↓ Enter Esc), intuitive command interface, zero re-learning
20
20
  - **31 Built-in Tools** — File ops, shell execution, agent dispatch, MCP integration, web search
21
21
  - **28 Skills + Marketplace** — 22 standard + 6 Mipham-exclusive skills. `/browse-skills` `/install-skill` community marketplace
22
22
  - **Self-Update** — `mipham update` / `/upgrade` — one command to check, backup config, upgrade, restore. API keys preserved
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miphamai/cli",
3
- "version": "0.85.52",
3
+ "version": "0.85.53",
4
4
  "description": "Mipham Code — Multi-model open-core intelligent coding terminal by MiphamAI",
5
5
  "keywords": [
6
6
  "ai",
@@ -174,6 +174,9 @@ export class ContextManager {
174
174
  this.calculateThresholds()
175
175
  }
176
176
 
177
+ /** User-chosen hard-compaction threshold; `null` = derive from the window. */
178
+ private compactionThresholdOverride: number | null = null
179
+
177
180
  private log?: SessionLog
178
181
 
179
182
  /**
@@ -222,6 +225,15 @@ export class ContextManager {
222
225
  * microcompact: 200K→0.70(→clamped 0.70), 500K→0.80, 1M→0.85
223
226
  */
224
227
  calculateThresholds(): void {
228
+ // An explicit user override wins over the window formula — including on
229
+ // model switches, which re-enter here through `updateMaxTokens()`. It must
230
+ // be applied before the `!w` early return: a session with adaptive
231
+ // thresholds off still has a context window value of undefined.
232
+ if (this.compactionThresholdOverride !== null) {
233
+ this.config.compactionThreshold = this.compactionThresholdOverride
234
+ return
235
+ }
236
+
225
237
  const w = this.config.contextWindow
226
238
  if (!w) return
227
239
 
@@ -236,6 +248,15 @@ export class ContextManager {
236
248
  return this.config.compactionThreshold
237
249
  }
238
250
 
251
+ /**
252
+ * Set (or clear, with `null`) a user-chosen hard-compaction threshold.
253
+ * Microcompaction keeps its own earlier window-derived schedule.
254
+ */
255
+ setCompactionThresholdOverride(threshold: number | null): void {
256
+ this.compactionThresholdOverride = threshold
257
+ this.calculateThresholds()
258
+ }
259
+
239
260
  /** Dynamically update the max token limit (e.g., when switching models). */
240
261
  updateMaxTokens(maxTokens: number, contextWindow?: number): void {
241
262
  this.config.maxTokens = maxTokens
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Cross-session insight report — counts only.
3
+ *
4
+ * Reads the CLI's own session logs (`~/.mipham/sessions/*.jsonl`) and produces
5
+ * an aggregate report. Deliberately never prints message text, tool input or
6
+ * tool output: the point is "where did my tool calls go", not a transcript.
7
+ *
8
+ * Counting rule that is easy to get wrong: `messageToEvents` splits a tool
9
+ * call/result out of a message only when that message holds a **single**
10
+ * block; a multi-block turn stays one `assistant/message` / `user/message`.
11
+ * Counting event types alone therefore under-reports tool calls and failures,
12
+ * so both shapes are counted here.
13
+ */
14
+
15
+ import { readdirSync, readFileSync, statSync } from 'node:fs'
16
+ import { join } from 'node:path'
17
+ import { interruptedCallNotice, isValidEvent, type SessionEvent } from './session-log'
18
+ import { miphamHome } from './paths.ts'
19
+
20
+ export interface SessionInsightsInput {
21
+ name: string
22
+ events: SessionEvent[]
23
+ }
24
+
25
+ export interface InsightsReport {
26
+ sessions: number
27
+ events: number
28
+ userMessages: number
29
+ assistantMessages: number
30
+ toolCalls: number
31
+ toolFailures: number
32
+ toolUnknown: number
33
+ compactions: number
34
+ topTools: Array<{ name: string; count: number }>
35
+ models: Array<{ provider: string; model: string; count: number }>
36
+ firstAt: number | null
37
+ lastAt: number | null
38
+ }
39
+
40
+ export interface LoadedSessionLogs {
41
+ inputs: SessionInsightsInput[]
42
+ skippedFiles: number
43
+ skippedLines: number
44
+ }
45
+
46
+ const DEFAULT_MAX_FILES = 200
47
+ const DEFAULT_MAX_BYTES = 20 * 1024 * 1024
48
+ const DEFAULT_MAX_TOTAL_BYTES = 64 * 1024 * 1024
49
+
50
+ /** Aggregate the already-parsed events. Pure: no I/O, deterministic. */
51
+ export function summarizeSessions(inputs: SessionInsightsInput[]): InsightsReport {
52
+ const topTools = new Map<string, number>()
53
+ const models = new Map<string, { provider: string; model: string; count: number }>()
54
+ const interrupted = interruptedCallNotice()
55
+
56
+ let events = 0
57
+ let userMessages = 0
58
+ let assistantMessages = 0
59
+ let toolCalls = 0
60
+ let toolFailures = 0
61
+ let toolUnknown = 0
62
+ let compactions = 0
63
+ let firstAt: number | null = null
64
+ let lastAt: number | null = null
65
+
66
+ const bumpTool = (name: string) => {
67
+ toolCalls += 1
68
+ topTools.set(name, (topTools.get(name) ?? 0) + 1)
69
+ }
70
+
71
+ for (const input of inputs) {
72
+ for (const event of input.events) {
73
+ events += 1
74
+ if (Number.isFinite(event.at) && event.at > 0) {
75
+ firstAt = firstAt === null ? event.at : Math.min(firstAt, event.at)
76
+ lastAt = lastAt === null ? event.at : Math.max(lastAt, event.at)
77
+ }
78
+
79
+ switch (event.type) {
80
+ case 'user/message': {
81
+ userMessages += 1
82
+ if (Array.isArray(event.message.content)) {
83
+ for (const block of event.message.content) {
84
+ if (block.type === 'tool_result' && block.is_error === true) toolFailures += 1
85
+ }
86
+ }
87
+ break
88
+ }
89
+ case 'assistant/message': {
90
+ assistantMessages += 1
91
+ if (Array.isArray(event.message.content)) {
92
+ for (const block of event.message.content) {
93
+ if (block.type === 'tool_use') bumpTool(block.name)
94
+ }
95
+ }
96
+ break
97
+ }
98
+ case 'tool/call':
99
+ bumpTool(event.name)
100
+ break
101
+ case 'tool/result':
102
+ if (event.result.success === false) {
103
+ // Synthesized on resume for calls that were in flight when the
104
+ // process died — "outcome unknown" is not the same as "failed".
105
+ if (event.result.content === interrupted) toolUnknown += 1
106
+ else toolFailures += 1
107
+ }
108
+ break
109
+ case 'compaction/summary':
110
+ compactions += 1
111
+ break
112
+ case 'session/start': {
113
+ const provider = event.provider ?? 'unknown'
114
+ const model = event.model ?? 'unknown'
115
+ const key = `${provider}\u0000${model}`
116
+ const seen = models.get(key)
117
+ if (seen) seen.count += 1
118
+ else models.set(key, { provider, model, count: 1 })
119
+ break
120
+ }
121
+ default:
122
+ break
123
+ }
124
+ }
125
+ }
126
+
127
+ return {
128
+ sessions: inputs.length,
129
+ events,
130
+ userMessages,
131
+ assistantMessages,
132
+ toolCalls,
133
+ toolFailures,
134
+ toolUnknown,
135
+ compactions,
136
+ topTools: [...topTools.entries()]
137
+ .map(([name, count]) => ({ name, count }))
138
+ .sort((a, b) => b.count - a.count || a.name.localeCompare(b.name))
139
+ .slice(0, 10),
140
+ models: [...models.values()].sort(
141
+ (a, b) =>
142
+ b.count - a.count || `${a.provider}/${a.model}`.localeCompare(`${b.provider}/${b.model}`),
143
+ ),
144
+ firstAt,
145
+ lastAt,
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Read session logs newest-first with hard budgets, so one pathological
151
+ * directory cannot turn a slash command into a multi-GB synchronous read.
152
+ */
153
+ export function loadSessionLogs(
154
+ dir: string = miphamHome('sessions'),
155
+ opts: { maxFiles?: number; maxBytes?: number; maxTotalBytes?: number } = {},
156
+ ): LoadedSessionLogs {
157
+ const maxFiles = opts.maxFiles ?? DEFAULT_MAX_FILES
158
+ const maxBytes = opts.maxBytes ?? DEFAULT_MAX_BYTES
159
+ const maxTotalBytes = opts.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES
160
+
161
+ const inputs: SessionInsightsInput[] = []
162
+ let skippedFiles = 0
163
+ let skippedLines = 0
164
+
165
+ let names: string[]
166
+ try {
167
+ names = readdirSync(dir).filter((name) => name.endsWith('.jsonl'))
168
+ } catch {
169
+ return { inputs, skippedFiles, skippedLines }
170
+ }
171
+
172
+ const files: Array<{ name: string; mtimeMs: number; size: number }> = []
173
+ for (const name of names) {
174
+ try {
175
+ const st = statSync(join(dir, name))
176
+ files.push({ name, mtimeMs: st.mtimeMs, size: st.size })
177
+ } catch {
178
+ skippedFiles += 1
179
+ }
180
+ }
181
+
182
+ files.sort((a, b) => b.mtimeMs - a.mtimeMs)
183
+ const selected = files.slice(0, maxFiles)
184
+ skippedFiles += files.length - selected.length
185
+
186
+ let totalBytes = 0
187
+ for (const file of selected) {
188
+ if (file.size > maxBytes || totalBytes + file.size > maxTotalBytes) {
189
+ skippedFiles += 1
190
+ continue
191
+ }
192
+ totalBytes += file.size
193
+
194
+ try {
195
+ const raw = readFileSync(join(dir, file.name), 'utf-8')
196
+ const events: SessionEvent[] = []
197
+ for (const line of raw.split('\n')) {
198
+ const text = line.trim()
199
+ if (!text) continue
200
+ try {
201
+ const parsed: unknown = JSON.parse(text)
202
+ if (isValidEvent(parsed)) events.push(parsed)
203
+ else skippedLines += 1
204
+ } catch {
205
+ skippedLines += 1
206
+ }
207
+ }
208
+ inputs.push({ name: file.name, events })
209
+ } catch {
210
+ skippedFiles += 1
211
+ }
212
+ }
213
+
214
+ return { inputs, skippedFiles, skippedLines }
215
+ }
216
+
217
+ export function formatInsightsReport(
218
+ report: InsightsReport,
219
+ dir: string,
220
+ loaded: { skippedFiles: number; skippedLines: number },
221
+ ): string {
222
+ if (report.sessions === 0) {
223
+ return `No session logs found at ${dir}.`
224
+ }
225
+
226
+ const range =
227
+ report.firstAt !== null && report.lastAt !== null
228
+ ? `${new Date(report.firstAt).toISOString()} → ${new Date(report.lastAt).toISOString()}`
229
+ : 'unknown'
230
+
231
+ const lines: string[] = [
232
+ '── Session Insights ──',
233
+ `Scanned: ${dir} (${report.sessions} sessions, ${report.events} events)`,
234
+ '',
235
+ `Messages: user ${report.userMessages} · assistant ${report.assistantMessages}`,
236
+ `Tool calls: ${report.toolCalls} (failures ${report.toolFailures}, unknown ${report.toolUnknown})`,
237
+ `Compactions: ${report.compactions}`,
238
+ `Range: ${range}`,
239
+ ]
240
+
241
+ if (report.models.length > 0) {
242
+ lines.push('', 'Models:')
243
+ for (const m of report.models) lines.push(` ${m.provider}/${m.model} ${m.count}`)
244
+ }
245
+
246
+ if (report.topTools.length > 0) {
247
+ lines.push('', 'Top tools:')
248
+ for (const t of report.topTools) lines.push(` ${t.name} ${t.count}`)
249
+ }
250
+
251
+ if (loaded.skippedFiles > 0 || loaded.skippedLines > 0) {
252
+ lines.push('', `Skipped: ${loaded.skippedFiles} file(s), ${loaded.skippedLines} line(s).`)
253
+ }
254
+
255
+ return lines.join('\n')
256
+ }
@@ -177,7 +177,7 @@ function endsWithNewline(path: string): boolean {
177
177
  }
178
178
 
179
179
  /** 补上的那条结果的正文:说明事情本身,并给出下一步,而不是只报一个状态。 */
180
- function interruptedCallNotice(): string {
180
+ export function interruptedCallNotice(): string {
181
181
  return (
182
182
  `This tool call was in flight when the session ended, so its outcome is unknown — ` +
183
183
  `the result was never recorded.\n` +
@@ -424,7 +424,7 @@ export function isValidMessage(m: unknown): boolean {
424
424
  * 不校验 `session/start`、`assistant/chunk`、`checker/decision`:投影对它们无分支;
425
425
  * 未知类型一律放行(前向兼容 —— 认不出来不等于要销毁它)。
426
426
  */
427
- function isValidEvent(e: unknown): e is SessionEvent {
427
+ export function isValidEvent(e: unknown): e is SessionEvent {
428
428
  if (!e || typeof e !== 'object') return false
429
429
  const ev = e as Record<string, unknown>
430
430
  if (typeof ev.type !== 'string') return false
package/src/index.tsx CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  loadSettingsJson,
13
13
  settingsPathFor,
14
14
  } from './config/loader'
15
+ import { getPreference } from './config/preferences'
15
16
  import {
16
17
  registerActiveSession,
17
18
  heartbeatSession,
@@ -253,6 +254,7 @@ interface SetupGateProps {
253
254
  version?: string
254
255
  sessionId: string
255
256
  agentViewManager?: AgentViewManager
257
+ reloadPlugins?: () => { plugins: number; skills: number }
256
258
  locale: string
257
259
  t: (key: string) => string
258
260
  }
@@ -300,6 +302,7 @@ function SetupGate(props: SetupGateProps) {
300
302
  version: props.version,
301
303
  sessionId: props.sessionId,
302
304
  agentViewManager: props.agentViewManager,
305
+ reloadPlugins: props.reloadPlugins,
303
306
  })
304
307
  }
305
308
 
@@ -837,6 +840,13 @@ export async function runApp(options: RunOptions): Promise<void> {
837
840
  // Create query engine
838
841
  const ruleEngine = new ExperienceRuleEngine()
839
842
  const engine = new QueryEngine(registry, context, tools, permission, ruleEngine)
843
+
844
+ // `/autocompact` persists a user override; apply it before the first turn.
845
+ const savedAutocompact = Number.parseFloat(getPreference('autocompactThreshold', ''))
846
+ if (Number.isFinite(savedAutocompact) && savedAutocompact >= 0.5 && savedAutocompact <= 0.95) {
847
+ engine.getContext().setCompactionThresholdOverride(savedAutocompact)
848
+ }
849
+
840
850
  engine.setHookEngine(hookEngine)
841
851
  engine.setArtifactServer(artifactServer)
842
852
  engine.setAgentViewManager(agentViewManager)
@@ -939,6 +949,31 @@ export async function runApp(options: RunOptions): Promise<void> {
939
949
  )
940
950
  }
941
951
 
952
+ // `/reload-plugins` re-runs the same load path. `loadPlugins` has no internal
953
+ // gate, so it must stay unreachable under `--safe-mode` (which skips plugin
954
+ // loading entirely) and under `disableAllHooks` (which exists to keep plugin
955
+ // hooks out): re-running it there would register what the operator turned off.
956
+ const reloadPlugins =
957
+ safeMode || settingsJson.disableAllHooks
958
+ ? undefined
959
+ : () => {
960
+ for (const plugin of pluginManager.list()) {
961
+ hookEngine.unregisterSource(plugin.name)
962
+ }
963
+ loadPlugins(
964
+ pluginManager,
965
+ agentRegistry,
966
+ skillsLoader,
967
+ hookEngine,
968
+ McpClient.getInstance(),
969
+ tools,
970
+ )
971
+ return {
972
+ plugins: pluginManager.getEnabled().length,
973
+ skills: skillsLoader.countByType().total,
974
+ }
975
+ }
976
+
942
977
  engine.setupContextSummarizer()
943
978
 
944
979
  // ── Cross-session messaging: register session, heartbeat, shutdown ──
@@ -1125,6 +1160,7 @@ export async function runApp(options: RunOptions): Promise<void> {
1125
1160
  version: options.version,
1126
1161
  sessionId: sessionName,
1127
1162
  agentViewManager,
1163
+ reloadPlugins,
1128
1164
  locale,
1129
1165
  t,
1130
1166
  }),
@@ -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.52' as const
12
+ export const PACKAGE_VERSION = '0.85.53' as const
13
13
 
14
14
  /** npm install 全局安装命令 */
15
15
  export const NPM_INSTALL_COMMAND = `npm install -g ${PACKAGE_NAME}` as const
@@ -75,7 +75,7 @@ export const COMPANY_SHORT = '华安麦逄科技' as const
75
75
  */
76
76
 
77
77
  /** Slash 命令总数(真源:`getCommandNames().length`,`apps/cli/src/ui/commands.ts`) */
78
- export const SLASH_COMMAND_COUNT = 141 as const
78
+ export const SLASH_COMMAND_COUNT = 150 as const
79
79
 
80
80
  /** 内置提供商总数(真源:`DEFAULT_PROVIDERS.length`,`apps/cli/src/shared/constants.ts`) */
81
81
  export const PROVIDER_COUNT = 12 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 = 5449 as const
93
+ export const TEST_COUNT = 5477 as const
package/src/ui/app.tsx CHANGED
@@ -13,7 +13,7 @@ import { MODE_CYCLE } from '../core/permission-config'
13
13
  import { readGitBranch, resolveGitPr, prColor, type GitPr } from '../core/git-pr'
14
14
  import type { SkillsLoader } from '../skills/loader'
15
15
  import type { PluginManager } from '../plugin/plugin-manager'
16
- import { setPreference } from '../config/preferences'
16
+ import { getPreference, setPreference } from '../config/preferences'
17
17
  import { saveProviderApiKey } from '../config/loader'
18
18
  import { recordCommand } from '../telemetry/index'
19
19
  import { recordCrash } from '../telemetry/crash'
@@ -71,7 +71,9 @@ import {
71
71
  unknownCommandMessage,
72
72
  handleSwitch,
73
73
  runCommandHandler,
74
+ statuslineVisibility,
74
75
  type CommandContext,
76
+ type StatuslineMode,
75
77
  } from './commands'
76
78
  import { useI18n } from '../i18n-context'
77
79
  import type { PermissionMode } from '../shared/index.ts'
@@ -93,6 +95,7 @@ interface AppProps {
93
95
  version?: string
94
96
  sessionId?: string
95
97
  agentViewManager?: AgentViewManager
98
+ reloadPlugins?: () => { plugins: number; skills: number }
96
99
  }
97
100
 
98
101
  export interface ToolMeta {
@@ -354,6 +357,7 @@ export function App({
354
357
  version,
355
358
  sessionId,
356
359
  agentViewManager,
360
+ reloadPlugins,
357
361
  }: AppProps) {
358
362
  const { t, locale } = useI18n()
359
363
  const PERMISSION_LABELS = useMemo<Record<PermissionMode, string>>(
@@ -452,6 +456,10 @@ export function App({
452
456
  const [_sessionTitle, setSessionTitle] = useState('')
453
457
  const [_effort, setEffort] = useState('high')
454
458
  const [focusMode, setFocusMode] = useState(false)
459
+ const [statuslineMode, setStatuslineMode] = useState<StatuslineMode>(() => {
460
+ const saved = getPreference('statuslineMode', 'full')
461
+ return saved === 'compact' || saved === 'off' ? saved : 'full'
462
+ })
455
463
  const [_ultracodeMode, setUltracodeMode] = useState(false)
456
464
  const [goalText, setGoalText] = useState('')
457
465
  // 初始值取自 live 权限系统 —— 启动时 config 的模式可能已被组织级限制钳到别处
@@ -617,6 +625,7 @@ export function App({
617
625
  if ('setUltracodeMode' in engine) engine.setUltracodeMode(on)
618
626
  },
619
627
  setUpdateStatus: (s: UpdateStatus) => setUpdateStatus(s),
628
+ setStatuslineMode: (mode: StatuslineMode) => setStatuslineMode(mode),
620
629
  // Same read-back as Shift+Tab: `setMode` may clamp the request (org
621
630
  // `maxAllowedMode` / `forbiddenModes`), so the footer and the gate must
622
631
  // both read the mode that took effect, not the one we asked for.
@@ -627,6 +636,7 @@ export function App({
627
636
  },
628
637
  skillsLoader,
629
638
  pluginManager,
639
+ reloadPlugins,
630
640
  t,
631
641
  locale,
632
642
  }),
@@ -637,6 +647,7 @@ export function App({
637
647
  modelId,
638
648
  skillsLoader,
639
649
  pluginManager,
650
+ reloadPlugins,
640
651
  sessionId,
641
652
  t,
642
653
  locale,
@@ -1490,6 +1501,8 @@ export function App({
1490
1501
  )
1491
1502
  }
1492
1503
 
1504
+ const statuslineSegments = statuslineVisibility(statuslineMode)
1505
+
1493
1506
  return (
1494
1507
  <ErrorBoundary
1495
1508
  onError={(error) => {
@@ -1686,11 +1699,13 @@ export function App({
1686
1699
  />
1687
1700
 
1688
1701
  {/* graft status line — mirrors graft's own "◤ graft · …" bar */}
1689
- <GraftStatusLine
1690
- cwd={process.cwd()}
1691
- ctxPct={contextUsagePct(engine)}
1692
- tokens={sessionTokens(engine)}
1693
- />
1702
+ {statuslineSegments.graft && (
1703
+ <GraftStatusLine
1704
+ cwd={process.cwd()}
1705
+ ctxPct={contextUsagePct(engine)}
1706
+ tokens={sessionTokens(engine)}
1707
+ />
1708
+ )}
1694
1709
 
1695
1710
  {/* Update notification — green, right-aligned, mirrors Claude Code's "Update installed · Restart to apply".
1696
1711
  While the startup banner is showing it already carries this line, so the footer copy is suppressed to avoid a duplicate. */}
@@ -1710,20 +1725,22 @@ export function App({
1710
1725
  <Text color={PERMISSION_COLORS[permissionMode]}>
1711
1726
  {permissionGlyphPrefix(permissionMode) + PERMISSION_LABELS[permissionMode]}
1712
1727
  </Text>
1713
- <Text dimColor>
1714
- {' '}
1715
- ({t('ui.status.shift_tab_cycle')}:{' '}
1716
- {MODE_CYCLE.map((m) => PERMISSION_LABELS[m]).join(' · ')}){' · '}
1717
- {t('ui.status.esc_to_interrupt')}
1718
- {' · '}
1719
- {t('ui.status.left_for_agents')}
1720
- </Text>
1728
+ {statuslineSegments.hints && (
1729
+ <Text dimColor>
1730
+ {' '}
1731
+ ({t('ui.status.shift_tab_cycle')}:{' '}
1732
+ {MODE_CYCLE.map((m) => PERMISSION_LABELS[m]).join(' · ')}){' · '}
1733
+ {t('ui.status.esc_to_interrupt')}
1734
+ {' · '}
1735
+ {t('ui.status.left_for_agents')}
1736
+ </Text>
1737
+ )}
1721
1738
  {ctrlC.armed && <Text color="yellow"> {t('ui.status.ctrl_c_again')}</Text>}
1722
1739
  </Box>
1723
1740
  </Box>
1724
1741
 
1725
1742
  {/* Git branch — dim, bottom-most, mirrors Claude Code's "⏺ main" */}
1726
- {gitBranch && (
1743
+ {statuslineSegments.git && gitBranch && (
1727
1744
  <Box>
1728
1745
  <Text dimColor>⏺ {gitBranch}</Text>
1729
1746
  {gitPr && <Text color={prColor(gitPr)}> · PR #{gitPr.number}</Text>}
@@ -20,6 +20,7 @@ import { registerMcpServerTools, unregisterMcpServerTools } from '../mcp/registr
20
20
  import { buildCapabilityReport, type CapabilityLedgers } from '../core/capability-inventory'
21
21
  import { formatFixRate, isAutoFixable } from '../core/error-signature-db'
22
22
  import { InstructionsLoader } from '../core/instructions'
23
+ import { formatInsightsReport, loadSessionLogs, summarizeSessions } from '../core/session-insights'
23
24
  import { UNDISPATCHED_EVENTS } from '../core/hooks-config'
24
25
  import { findDerivableSections, DERIVABLE_HINTS } from '../core/claude-md-audit'
25
26
  import { miphamHome, workflowScriptDir, workflowScriptDirs, worktreeRoot } from '../core/paths.ts'
@@ -171,6 +172,26 @@ import { clearTasks, formatTaskList } from '../tools/exec/task'
171
172
  import { estimateCost, loadPriceBook } from '../providers/pricing'
172
173
  import type { UsageSummary } from '../core/usage-tracker'
173
174
 
175
+ export type StatuslineMode = 'full' | 'compact' | 'off'
176
+
177
+ export const STATUSLINE_MODES: readonly StatuslineMode[] = ['full', 'compact', 'off']
178
+
179
+ /**
180
+ * Which footer segments a mode shows. The permission label is deliberately
181
+ * absent: it is safety information and stays visible in every mode.
182
+ */
183
+ export function statuslineVisibility(mode: StatuslineMode): {
184
+ graft: boolean
185
+ hints: boolean
186
+ git: boolean
187
+ } {
188
+ return {
189
+ graft: mode === 'full',
190
+ hints: mode === 'full',
191
+ git: mode !== 'off',
192
+ }
193
+ }
194
+
174
195
  export interface CommandContext {
175
196
  engine: QueryEngine
176
197
  config: MiphamConfig
@@ -189,6 +210,10 @@ export interface CommandContext {
189
210
  setGoal: (text: string) => void
190
211
  setUltracodeMode: (on: boolean) => void
191
212
  setUpdateStatus: (s: UpdateStatus) => void
213
+ /** Live footer-mode change; absent on surfaces that cannot repaint the App. */
214
+ setStatuslineMode?: (mode: StatuslineMode) => void
215
+ /** Re-run plugin loading; absent under `--safe-mode` / `disableAllHooks`. */
216
+ reloadPlugins?: () => { plugins: number; skills: number }
192
217
  /** Request a permission-mode change and let the App read back the mode that
193
218
  * actually took effect (org limits can clamp it). Absent on surfaces that
194
219
  * cannot switch modes (e.g. a remote attach stub). */
@@ -3686,6 +3711,22 @@ const browseMarketplaceCmd: CommandHandler = async (_ctx) => {
3686
3711
  // Plugins — Community plugin marketplace + local management
3687
3712
  // ═══════════════════════════════════════════════════════════════
3688
3713
 
3714
+ const reloadPluginsCmd: CommandHandler = (ctx) => {
3715
+ if (!ctx.reloadPlugins) {
3716
+ return { content: 'Plugin reload is not available in this session.' }
3717
+ }
3718
+ try {
3719
+ const r = ctx.reloadPlugins()
3720
+ return {
3721
+ content:
3722
+ `✓ Reloaded ${r.plugins} enabled plugin(s); ${r.skills} skills loaded.\n\n` +
3723
+ 'Boundaries: already-connected MCP servers stay connected; skills/agents loaded from plugins that are now disabled remain until restart.',
3724
+ }
3725
+ } catch (err) {
3726
+ return { content: `Plugin reload failed: ${String(err)}` }
3727
+ }
3728
+ }
3729
+
3689
3730
  const pluginsCmd: CommandHandler = (ctx) => {
3690
3731
  const t = resolveT(ctx)
3691
3732
  const manager = ctx.pluginManager
@@ -4872,6 +4913,21 @@ function resolveMaxFindings(
4872
4913
  }
4873
4914
  }
4874
4915
 
4916
+ export const SECURITY_REVIEW_PROMPT =
4917
+ 'Use the security-review skill to review all uncommitted changes for security vulnerabilities only: ' +
4918
+ 'injection, auth/permission bypass, secret exposure, unsafe deserialization, path traversal, and dependency risk. ' +
4919
+ 'Do not report general style or simplification issues — /simplify owns those. ' +
4920
+ 'For each finding give file:line, severity, and a concrete fix. ' +
4921
+ 'If there is nothing to report, write exactly: "Security review found no issues."'
4922
+
4923
+ const securityReviewCmd = gitDiffBridgeCmd({
4924
+ label: 'Security Review',
4925
+ noChangesKey: 'commands.code_review.no_changes',
4926
+ runningKey: 'commands.code_review.running',
4927
+ errorKey: 'commands.code_review.error',
4928
+ forwardToAI: SECURITY_REVIEW_PROMPT,
4929
+ })
4930
+
4875
4931
  const codeReviewCmd = gitDiffBridgeCmd({
4876
4932
  label: 'Code Review',
4877
4933
  noChangesKey: 'commands.code_review.no_changes',
@@ -5021,6 +5077,75 @@ const filesCmd: CommandHandler = async (ctx) => {
5021
5077
  }
5022
5078
  }
5023
5079
 
5080
+ const autocompactCmd: CommandHandler = (ctx, args) => {
5081
+ if ((ctx.engine as { isRemote?: boolean }).isRemote === true) {
5082
+ return {
5083
+ content:
5084
+ 'Attached to a daemon: the daemon owns context compaction; this session cannot change its threshold.',
5085
+ }
5086
+ }
5087
+ const cm = ctx.engine.getContext()
5088
+ const arg = (args[0] ?? '').toLowerCase()
5089
+ const current = cm.getCompactionThreshold()
5090
+ if (!arg) {
5091
+ return {
5092
+ content:
5093
+ `Auto-compaction (hard) threshold: ${(current * 100).toFixed(0)}% of context ` +
5094
+ `(window ${cm.getMaxTokens().toLocaleString()} tokens). ` +
5095
+ `Microcompaction still fires earlier on its own window-derived schedule.\n\n` +
5096
+ 'Usage: /autocompact <50-95%> | default',
5097
+ }
5098
+ }
5099
+ if (arg === 'default' || arg === 'off') {
5100
+ cm.setCompactionThresholdOverride(null)
5101
+ setPreference('autocompactThreshold', '')
5102
+ return {
5103
+ content: `Auto-compaction threshold cleared; using the window-derived value (${(cm.getCompactionThreshold() * 100).toFixed(0)}%).`,
5104
+ }
5105
+ }
5106
+ const pct = arg.endsWith('%') ? Number.parseFloat(arg) / 100 : Number.parseFloat(arg)
5107
+ if (!Number.isFinite(pct) || pct < 0.5 || pct > 0.95) {
5108
+ return {
5109
+ content: `Invalid threshold "${arg}". Use a value between 0.50 and 0.95 (or "default").`,
5110
+ }
5111
+ }
5112
+ cm.setCompactionThresholdOverride(pct)
5113
+ setPreference('autocompactThreshold', String(pct))
5114
+ return { content: `Auto-compaction threshold set to ${(pct * 100).toFixed(0)}%.` }
5115
+ }
5116
+
5117
+ const statuslineCmd: CommandHandler = (ctx, args) => {
5118
+ const requested = (args[0] ?? '').toLowerCase()
5119
+ const current = getPreference('statuslineMode', 'full')
5120
+ if (!requested) {
5121
+ return {
5122
+ content:
5123
+ `Statusline mode: ${current}\n\n` +
5124
+ 'Usage: /statusline <full|compact|off>\n' +
5125
+ ' full graft line + hints + git branch\n' +
5126
+ ' compact permission + git branch only\n' +
5127
+ ' off permission line only (never hides the permission mode)',
5128
+ }
5129
+ }
5130
+ if (!STATUSLINE_MODES.includes(requested as StatuslineMode)) {
5131
+ return { content: `Unknown statusline mode "${requested}". Choose full, compact, or off.` }
5132
+ }
5133
+ const mode = requested as StatuslineMode
5134
+ setPreference('statuslineMode', mode)
5135
+ ctx.setStatuslineMode?.(mode)
5136
+ return { content: `Statusline mode set to ${mode}.` }
5137
+ }
5138
+
5139
+ const insightsCmd: CommandHandler = (ctx) => {
5140
+ const dir = miphamHome('sessions')
5141
+ const loaded = loadSessionLogs(dir)
5142
+ const note =
5143
+ (ctx.engine as { isRemote?: boolean }).isRemote === true
5144
+ ? "Attached to a daemon: this covers local CLI sessions only; the attached session's audit log is not included.\n\n"
5145
+ : ''
5146
+ return { content: note + formatInsightsReport(summarizeSessions(loaded.inputs), dir, loaded) }
5147
+ }
5148
+
5024
5149
  const statsCmd: CommandHandler = (ctx) => {
5025
5150
  const t = resolveT(ctx)
5026
5151
  const c = ctx.engine.getContext()
@@ -6777,6 +6902,24 @@ Or use the Agent tool in a conversation to launch a sub-agent.`,
6777
6902
  return { content: lines.join('\n') }
6778
6903
  }
6779
6904
 
6905
+ const subtaskCmd: CommandHandler = (_ctx, args) => {
6906
+ const prompt = args.join(' ').trim()
6907
+ if (!prompt) {
6908
+ return {
6909
+ content:
6910
+ 'Usage: /subtask <task>\n\n' +
6911
+ "Sends a fork subagent with this conversation's full context; its result returns to this chat.",
6912
+ }
6913
+ }
6914
+ return {
6915
+ content: "Dispatching a fork subagent with this conversation's context…",
6916
+ forwardToAI:
6917
+ 'Use the Agent tool with subagent_type "fork", run_in_background: false, and description "subtask" ' +
6918
+ 'to complete this task with the full conversation context, then report its result in this conversation:\n\n' +
6919
+ prompt,
6920
+ }
6921
+ }
6922
+
6780
6923
  const bgCmd: CommandHandler = async (ctx, args) => {
6781
6924
  const prompt = args.join(' ')
6782
6925
  if (!prompt.trim()) {
@@ -7220,6 +7363,7 @@ const commandsListCmd: CommandHandler = () => {
7220
7363
  '/dream': 'Session & Identity',
7221
7364
  '/constitution': 'Session & Identity',
7222
7365
  '/bug-report': 'Session & Identity',
7366
+ '/bug': 'Session & Identity',
7223
7367
  '/changelog': 'Session & Identity',
7224
7368
  '/resume': 'Session & Identity',
7225
7369
  '/resume last': 'Session & Identity',
@@ -7251,6 +7395,8 @@ const commandsListCmd: CommandHandler = () => {
7251
7395
  '/remove-skill': 'Tools & Skills',
7252
7396
  '/mcp': 'Tools & Skills',
7253
7397
  '/plugins': 'Plugins',
7398
+ '/plugin': 'Plugins',
7399
+ '/reload-plugins': 'Plugins',
7254
7400
  '/browse-plugins': 'Plugins',
7255
7401
  '/install-plugin': 'Plugins',
7256
7402
  '/remove-plugin': 'Plugins',
@@ -7302,6 +7448,7 @@ const commandsListCmd: CommandHandler = () => {
7302
7448
  '/prompt-audit': 'Code Quality',
7303
7449
  '/ide': 'Environment',
7304
7450
  '/terminal-setup': 'Environment',
7451
+ '/statusline': 'Environment',
7305
7452
  '/memory': 'Environment',
7306
7453
  '/release-notes': 'Environment',
7307
7454
  '/login': 'Account',
@@ -7313,6 +7460,8 @@ const commandsListCmd: CommandHandler = () => {
7313
7460
  '/feedback': 'Account',
7314
7461
  '/telemetry': 'Account',
7315
7462
  '/agents': 'Agents',
7463
+ '/list-agents': 'Agents',
7464
+ '/subtask': 'Agents',
7316
7465
  '/bg': 'Agents',
7317
7466
  '/fork': 'Agents',
7318
7467
  '/artifact': 'Artifacts',
@@ -7323,12 +7472,15 @@ const commandsListCmd: CommandHandler = () => {
7323
7472
  '/ship': 'Workflow',
7324
7473
  '/issue': 'Workflow',
7325
7474
  '/code-review': 'Code Quality',
7475
+ '/security-review': 'Code Quality',
7326
7476
  '/simplify': 'Code Quality',
7327
7477
  '/verify': 'Code Quality',
7328
7478
  '/design': 'Code Quality',
7329
7479
  '/lint': 'Code Quality',
7330
7480
  '/files': 'Session & Identity',
7331
7481
  '/stats': 'Session & Identity',
7482
+ '/insights': 'Session & Identity',
7483
+ '/autocompact': 'Session & Identity',
7332
7484
  '/summary': 'Session & Identity',
7333
7485
  '/cd': 'Session & Identity',
7334
7486
  '/hooks': 'Workflow',
@@ -7464,6 +7616,8 @@ registry.set('/marketplace', marketplaceCmd)
7464
7616
  registry.set('/browse-marketplace', browseMarketplaceCmd)
7465
7617
  registry.set('/remove-skill', removeSkillCmd)
7466
7618
  registry.set('/plugins', pluginsCmd)
7619
+ registry.set('/plugin', pluginsCmd)
7620
+ registry.set('/reload-plugins', reloadPluginsCmd)
7467
7621
  registry.set('/browse-plugins', browsePluginsCmd)
7468
7622
  registry.set('/install-plugin', installPluginCmd)
7469
7623
  registry.set('/remove-plugin', removePluginCmd)
@@ -7496,6 +7650,7 @@ registry.set('/sis cleanup', sisCleanupCmd)
7496
7650
  registry.set('/dream', dreamCmd)
7497
7651
  registry.set('/constitution', constitutionCmd)
7498
7652
  registry.set('/bug-report', bugReportCmd)
7653
+ registry.set('/bug', bugReportCmd)
7499
7654
  registry.set('/changelog', changelogCmd)
7500
7655
 
7501
7656
  // Workflow
@@ -7554,8 +7709,10 @@ registry.set('/keys audit', keysCmd)
7554
7709
  registry.set('/keys view', keysCmd)
7555
7710
  registry.set('/feedback', feedbackCmd)
7556
7711
  registry.set('/agents', agentsCmd)
7712
+ registry.set('/list-agents', agentsCmd)
7557
7713
  registry.set('/bg', bgCmd)
7558
7714
  registry.set('/fork', forkCmd)
7715
+ registry.set('/subtask', subtaskCmd)
7559
7716
 
7560
7717
  // Artifacts
7561
7718
  registry.set('/artifact', artifactBaseCmd)
@@ -7573,6 +7730,7 @@ registry.set('/issue', issueCmd)
7573
7730
 
7574
7731
  // Code Quality (Claude Code parity)
7575
7732
  registry.set('/code-review', codeReviewCmd)
7733
+ registry.set('/security-review', securityReviewCmd)
7576
7734
  registry.set('/simplify', simplifyCmd)
7577
7735
  registry.set('/verify', verifyCmd)
7578
7736
  registry.set('/design', designCmd)
@@ -7580,6 +7738,9 @@ registry.set('/lint', lintCmd)
7580
7738
 
7581
7739
  // Session Enhancement (Claude Code parity)
7582
7740
  registry.set('/files', filesCmd)
7741
+ registry.set('/insights', insightsCmd)
7742
+ registry.set('/autocompact', autocompactCmd)
7743
+ registry.set('/statusline', statuslineCmd)
7583
7744
  registry.set('/stats', statsCmd)
7584
7745
  registry.set('/summary', summaryCmd)
7585
7746
  registry.set('/cd', cdCmd)
@@ -7681,6 +7842,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
7681
7842
  '/dream': 'Background memory consolidation',
7682
7843
  '/constitution': 'View or reload constitutional principles',
7683
7844
  '/bug-report': 'Generate diagnostic report for GitHub Issues',
7845
+ '/bug': 'Report a bug (alias of /bug-report)',
7684
7846
  '/changelog': 'Recent version history',
7685
7847
  '/resume': 'List saved sessions',
7686
7848
  '/resume last': 'Restore the most recent saved session',
@@ -7711,6 +7873,9 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
7711
7873
  '/remove-skill': 'Remove an installed skill',
7712
7874
  '/mcp': 'MCP server status',
7713
7875
  '/plugins': 'List installed plugins',
7876
+ '/plugin':
7877
+ 'List plugins (alias of /plugins; use /install-plugin, /remove-plugin, /plugin-enable, /plugin-disable to manage)',
7878
+ '/reload-plugins': 'Reload enabled plugins in this session',
7714
7879
  '/browse-plugins': 'Browse community plugin marketplace',
7715
7880
  '/install-plugin': 'Install a plugin from npm or local path',
7716
7881
  '/remove-plugin': 'Remove an installed plugin',
@@ -7776,6 +7941,8 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
7776
7941
  '/keys view': 'View a provider plaintext API key',
7777
7942
  '/feedback': 'Send feedback',
7778
7943
  '/agents': 'Agent view dashboard',
7944
+ '/list-agents': 'List background agent sessions (alias of /agents)',
7945
+ '/subtask': 'Send a fork subagent with full context; its result returns here',
7779
7946
  '/bg': 'Run a background agent task',
7780
7947
  '/fork': 'Fork task into isolated worktree',
7781
7948
  '/artifact': 'Manage artifacts',
@@ -7786,11 +7953,15 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
7786
7953
  '/ship': 'Commit, push, open a PR, review and fix it — never merges',
7787
7954
  '/issue': 'Draft a GitHub issue from your description',
7788
7955
  '/code-review': 'Review code for bugs, security, performance (7 dimensions)',
7956
+ '/security-review': 'Review pending changes for security issues (security-review skill)',
7789
7957
  '/simplify': 'Cleanup-only review: reuse, simplification, efficiency, abstraction',
7790
7958
  '/verify': 'Runtime verification — observe actual execution, not tests',
7791
7959
  '/design': 'Start architectural design session — explore approaches and trade-offs',
7792
7960
  '/lint': 'Run linting on the project',
7793
7961
  '/files': 'List files in current working directory',
7962
+ '/insights': 'Analyze local session history (counts only, no message text)',
7963
+ '/autocompact': 'Show or set the hard context-compaction threshold',
7964
+ '/statusline': 'Configure the footer status line (full|compact|off)',
7794
7965
  '/stats': 'Show session usage statistics',
7795
7966
  '/summary': 'Generate session summary',
7796
7967
  '/cd': 'Change session working directory',