@miphamai/cli 0.16.5 → 0.18.0

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.
@@ -8,6 +8,7 @@ import type { QueryEngine } from '../core/engine'
8
8
  import type { MiphamConfig } from '../shared/index.ts'
9
9
  import type { SkillsLoader } from '../skills/loader'
10
10
  import type { PluginManager } from '../plugin/plugin-manager'
11
+ import type { Message } from '../shared/types.js'
11
12
  import { McpClient } from '../mcp/client'
12
13
  import { NPM_INSTALL_COMMAND, NPM_UPDATE_COMMAND, PACKAGE_VERSION } from '../shared/index.ts'
13
14
  import { getPreference } from '../config/preferences'
@@ -23,6 +24,7 @@ import {
23
24
  } from '../commands/project.js'
24
25
  import { themeCmd, releaseNotesCmd, ideCmd, terminalSetupCmd } from '../commands/environment.js'
25
26
  import { commitCmd, pushCmd, prCmd, issueCmd } from '../commands/git.js'
27
+ import { keysCmd } from '../commands/keys'
26
28
 
27
29
  export interface CommandContext {
28
30
  engine: QueryEngine
@@ -58,6 +60,8 @@ export interface CommandResult {
58
60
  /** If set, route this message to the AI engine — bridges slash commands → skill/agent invocation.
59
61
  * The app layer replaces the user input with this string and falls through to AI processing. */
60
62
  forwardToAI?: string
63
+ /** If set, restored messages to load into the session (used by /resume last). */
64
+ forwardedMessages?: Message[]
61
65
  }
62
66
 
63
67
  export type CommandHandler = (
@@ -98,6 +102,8 @@ const helpCmd: CommandHandler = (ctx) => {
98
102
  /export Export conversation to file
99
103
  /doctor System diagnostics
100
104
  /resume List saved sessions
105
+ /resume last Restore most recent session
106
+ /resume delete <name> Delete a saved session
101
107
  /branch <name> Fork conversation
102
108
 
103
109
  ── History ─────────────────────────
@@ -182,6 +188,9 @@ const helpCmd: CommandHandler = (ctx) => {
182
188
  ── Account ─────────────────────────
183
189
  /login Show API key status
184
190
  /logout Clear credentials guide
191
+ /keys List API key rotation status
192
+ /keys rotate Rotate an API key
193
+ /keys audit Check for expired keys
185
194
  /feedback Send feedback
186
195
 
187
196
  ── Agents ──────────────────────────
@@ -1967,7 +1976,70 @@ const prCommentsCmd: CommandHandler = async () => {
1967
1976
  // Resume
1968
1977
  // ═══════════════════════════════════════════════════════════════
1969
1978
 
1979
+ const resumeLastCmd: CommandHandler = async () => {
1980
+ const { SessionStore } = await import('../core/session-store')
1981
+
1982
+ const latest = SessionStore.getLatest()
1983
+ if (!latest) {
1984
+ return {
1985
+ content:
1986
+ '─ Resume Session ─\n\nNo saved sessions found.\n\nSessions are auto-saved to ~/.mipham/sessions/ when Mipham Code exits.',
1987
+ }
1988
+ }
1989
+
1990
+ const session = SessionStore.load(latest.name)
1991
+ if (!session) {
1992
+ return {
1993
+ content: `─ Load Failed ─\n\nCould not load session "${latest.name}". The file may have been removed.`,
1994
+ }
1995
+ }
1996
+
1997
+ const date = new Date(latest.updatedAt).toLocaleString()
1998
+ return {
1999
+ content: [
2000
+ '─ Session Restored ─',
2001
+ '',
2002
+ `Name: ${latest.name}`,
2003
+ `Messages: ${session.messages.length}`,
2004
+ `Provider: ${latest.provider} / ${latest.model}`,
2005
+ `Updated: ${date}`,
2006
+ '',
2007
+ `${session.messages.length} messages loaded. Context has been restored.`,
2008
+ ].join('\n'),
2009
+ forwardedMessages: session.messages,
2010
+ }
2011
+ }
2012
+
2013
+ const resumeDeleteCmd: CommandHandler = async (_ctx, args) => {
2014
+ const name = args.join(' ').trim()
2015
+ if (!name) {
2016
+ return {
2017
+ content:
2018
+ 'Usage: /resume delete <session-name>\n\nDelete a saved session. Use /resume to list all sessions.',
2019
+ }
2020
+ }
2021
+
2022
+ const { SessionStore } = await import('../core/session-store')
2023
+ const deleted = SessionStore.delete(name)
2024
+
2025
+ return deleted
2026
+ ? { content: `✓ Session "${name}" deleted.` }
2027
+ : { content: `✗ Session "${name}" not found. Use /resume to list all sessions.` }
2028
+ }
2029
+
1970
2030
  const resumeCmd: CommandHandler = async (_ctx, args) => {
2031
+ const sub = args[0]?.toLowerCase()
2032
+
2033
+ // Sub-command: /resume last
2034
+ if (sub === 'last') {
2035
+ return resumeLastCmd(_ctx, args.slice(1))
2036
+ }
2037
+
2038
+ // Sub-command: /resume delete <name>
2039
+ if (sub === 'delete') {
2040
+ return resumeDeleteCmd(_ctx, args.slice(1))
2041
+ }
2042
+
1971
2043
  const { SessionStore } = await import('../core/session-store')
1972
2044
 
1973
2045
  // If a name is provided, show load instructions
@@ -1985,6 +2057,7 @@ const resumeCmd: CommandHandler = async (_ctx, args) => {
1985
2057
  `Updated: ${session.metadata.updatedAt}`,
1986
2058
  '',
1987
2059
  'To resume this session:',
2060
+ ` /resume last — restore the most recent session`,
1988
2061
  ` mipham --resume "${targetName}"`,
1989
2062
  '',
1990
2063
  'Or restart Mipham Code — the most recent session loads automatically.',
@@ -2017,8 +2090,10 @@ const resumeCmd: CommandHandler = async (_ctx, args) => {
2017
2090
  '',
2018
2091
  `Total: ${sessions.length} session(s) • Location: ~/.mipham/sessions/`,
2019
2092
  '',
2020
- 'To resume a session: /resume <name>',
2021
- 'To resume from CLI: mipham --resume "<name>"',
2093
+ 'To resume a session: /resume <name>',
2094
+ 'To resume most recent: /resume last',
2095
+ 'To delete a session: /resume delete <name>',
2096
+ 'To resume from CLI: mipham --resume "<name>"',
2022
2097
  '',
2023
2098
  'Sessions are auto-saved on exit. The most recent session loads automatically on restart.',
2024
2099
  ]
@@ -2993,6 +3068,8 @@ const commandsListCmd: CommandHandler = () => {
2993
3068
  '/export': 'Session & Identity',
2994
3069
  '/doctor': 'Session & Identity',
2995
3070
  '/resume': 'Session & Identity',
3071
+ '/resume last': 'Session & Identity',
3072
+ '/resume delete': 'Session & Identity',
2996
3073
  '/branch': 'Session & Identity',
2997
3074
  '/rewind': 'History',
2998
3075
  '/undo': 'History',
@@ -3049,6 +3126,9 @@ const commandsListCmd: CommandHandler = () => {
3049
3126
  '/release-notes': 'Environment',
3050
3127
  '/login': 'Account',
3051
3128
  '/logout': 'Account',
3129
+ '/keys': 'Account',
3130
+ '/keys rotate': 'Account',
3131
+ '/keys audit': 'Account',
3052
3132
  '/feedback': 'Account',
3053
3133
  '/agents': 'Agents',
3054
3134
  '/bg': 'Agents',
@@ -3175,6 +3255,8 @@ registry.set('/pr-comments', prCommentsCmd)
3175
3255
  registry.set('/doctor', doctorCmd)
3176
3256
  registry.set('/export', exportCmd)
3177
3257
  registry.set('/resume', resumeCmd)
3258
+ registry.set('/resume last', resumeLastCmd)
3259
+ registry.set('/resume delete', resumeDeleteCmd)
3178
3260
  registry.set('/memory', memoryCmd)
3179
3261
  registry.set('/upgrade', upgradeCmd)
3180
3262
 
@@ -3198,6 +3280,9 @@ registry.set('/release-notes', releaseNotesCmd)
3198
3280
  registry.set('/mcp', mcpCmd)
3199
3281
  registry.set('/login', loginCmd)
3200
3282
  registry.set('/logout', logoutCmd)
3283
+ registry.set('/keys', keysCmd)
3284
+ registry.set('/keys rotate', keysCmd)
3285
+ registry.set('/keys audit', keysCmd)
3201
3286
  registry.set('/feedback', feedbackCmd)
3202
3287
  registry.set('/agents', agentsCmd)
3203
3288
  registry.set('/bg', bgCmd)
@@ -3266,6 +3351,8 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
3266
3351
  '/export': 'Export conversation to file',
3267
3352
  '/doctor': 'System diagnostics',
3268
3353
  '/resume': 'List saved sessions',
3354
+ '/resume last': 'Restore the most recent saved session',
3355
+ '/resume delete': 'Delete a saved session',
3269
3356
  '/branch': 'Fork conversation',
3270
3357
  '/rewind': 'Undo last AI turn',
3271
3358
  '/undo': 'Same as /rewind',
@@ -3322,6 +3409,9 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
3322
3409
  '/upgrade': 'Show upgrade instructions',
3323
3410
  '/login': 'Show API key status',
3324
3411
  '/logout': 'Clear credentials guide',
3412
+ '/keys': 'List API key rotation status',
3413
+ '/keys rotate': 'Rotate an API key',
3414
+ '/keys audit': 'Check for expired keys',
3325
3415
  '/feedback': 'Send feedback',
3326
3416
  '/agents': 'Agent view dashboard',
3327
3417
  '/bg': 'Run a background agent task',