@miphamai/cli 0.7.7 → 0.7.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miphamai/cli",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "Mipham Code — Multi-model open-core intelligent coding terminal by MiphamAI",
5
5
  "keywords": [
6
6
  "ai",
package/src/ui/app.tsx CHANGED
@@ -175,12 +175,12 @@ export function App({
175
175
  return
176
176
  }
177
177
 
178
- let injectMessage: string | undefined
178
+ let forwardToAI: string | undefined
179
179
 
180
180
  const handler = getCommand(command)
181
181
  if (handler) {
182
182
  const result = await handler(mkCtx(), args)
183
- injectMessage = result.injectMessage
183
+ forwardToAI = result.forwardToAI
184
184
  setMessages((prev) => [
185
185
  ...prev,
186
186
  { role: 'user', content: input },
@@ -206,12 +206,12 @@ export function App({
206
206
  }
207
207
  }
208
208
 
209
- // Bridge: if command set injectMessage, route to AI processing
210
- if (injectMessage) {
211
- input = injectMessage
209
+ // Bridge: if command set forwardToAI, route the message to AI processing
210
+ if (forwardToAI) {
211
+ input = forwardToAI
212
212
  // fall through to normal AI processing below
213
213
  } else {
214
- // Unknown slash command or handler returned: proceed to normal AI processing
214
+ // No handler matched or handler didn't request AI routing — stop here
215
215
  return
216
216
  }
217
217
  }
@@ -40,8 +40,9 @@ export interface CommandResult {
40
40
  clearMessages?: boolean
41
41
  /** Content to copy to clipboard (handled by caller) */
42
42
  copyContent?: string
43
- /** If set, inject this as a user message and route to AI processing (bridges slash commands → skills) */
44
- injectMessage?: string
43
+ /** If set, route this message to the AI engine — bridges slash commands → skill/agent invocation.
44
+ * The app layer replaces the user input with this string and falls through to AI processing. */
45
+ forwardToAI?: string
45
46
  }
46
47
 
47
48
  type CommandHandler = (
@@ -1196,7 +1197,7 @@ const loopCmd: CommandHandler = async (_ctx, args) => {
1196
1197
 
1197
1198
  return {
1198
1199
  content: `── Loop Started ──\n\nInterval: ${interval} (${seconds}s)\nPrompt: "${prompt}"\n\nScheduling via ScheduleWakeup — the prompt will re-schedule itself each cycle.\nUse /schedule to view active loops.`,
1199
- injectMessage: `use ScheduleWakeup to set up a recurring loop. delaySeconds=${seconds}, prompt: "${prompt}". Include at the end of the prompt: "Then call ScheduleWakeup again with delaySeconds=${seconds} and the same prompt to continue the loop."`,
1200
+ forwardToAI: `use ScheduleWakeup to set up a recurring loop. delaySeconds=${seconds}, prompt: "${prompt}". Include at the end of the prompt: "Then call ScheduleWakeup again with delaySeconds=${seconds} and the same prompt to continue the loop."`,
1200
1201
  }
1201
1202
  }
1202
1203
 
@@ -1430,82 +1431,71 @@ const issueCmd: CommandHandler = async () => {
1430
1431
  }
1431
1432
  }
1432
1433
 
1433
- // ═══════════════════════════════════════════════════════════════
1434
- // Code Quality Commands (Claude Code parity)
1435
- // ═══════════════════════════════════════════════════════════════
1436
-
1437
1434
  // ═══════════════════════════════════════════════════════════════
1438
1435
  // Code Quality — bridge slash commands to skills (Claude Code parity)
1439
1436
  // ═══════════════════════════════════════════════════════════════
1440
1437
 
1441
- const codeReviewCmd: CommandHandler = async () => {
1442
- try {
1443
- const { execSync } = await import('node:child_process')
1444
- const diff = execSync('git diff --stat', { encoding: 'utf-8', timeout: 5000 }).trim()
1445
- if (!diff) {
1446
- return {
1447
- content:
1448
- '─ Code Review ─\n\nNo uncommitted changes to review.\n\nTo review a specific file: /code-review path/to/file.ts',
1438
+ /** Factory for git-diff-based commands that bridge to AI skills via forwardToAI. */
1439
+ function gitDiffBridgeCmd(opts: {
1440
+ label: string
1441
+ noChangesHint: string
1442
+ runningMsg: string
1443
+ forwardToAI: string
1444
+ }): CommandHandler {
1445
+ return async () => {
1446
+ try {
1447
+ const { execSync } = await import('node:child_process')
1448
+ const diff = execSync('git diff --stat', { encoding: 'utf-8', timeout: 5000 }).trim()
1449
+ if (!diff) {
1450
+ return { content: `─ ${opts.label} ─\n\n${opts.noChangesHint}` }
1449
1451
  }
1450
- }
1451
- return {
1452
- content:
1453
- '─ Code Review ─\n\nReviewing uncommitted changes with the code-review skill (7 dimensions: correctness, security, performance, code quality, architecture, testing, language-specific)...',
1454
- injectMessage:
1455
- 'use the code-review skill to review all uncommitted changes. Check all 7 dimensions: correctness, security, performance, code quality, architecture & design, testing, and language-specific issues.',
1456
- }
1457
- } catch {
1458
- return { content: '─ Code Review ─\n\nCould not detect changes. Are you in a git repository?' }
1459
- }
1460
- }
1461
-
1462
- const simplifyCmd: CommandHandler = async () => {
1463
- try {
1464
- const { execSync } = await import('node:child_process')
1465
- const diff = execSync('git diff --stat', { encoding: 'utf-8', timeout: 5000 }).trim()
1466
- if (!diff) {
1467
1452
  return {
1468
- content:
1469
- '─ Simplify ─\n\nNo uncommitted changes to simplify.\n\nMake changes first, then run /simplify for cleanup review.',
1453
+ content: `─ ${opts.label} ─\n\n${opts.runningMsg}\n\nChanged files:\n${diff}`,
1454
+ forwardToAI: opts.forwardToAI,
1470
1455
  }
1471
- }
1472
- return {
1473
- content:
1474
- '─ Simplify ─\n\nRunning cleanup review — 4 passes: reuse, simplification, efficiency, abstraction level...',
1475
- injectMessage:
1476
- 'use the self-review skill to review these uncommitted changes. Focus on 4 cleanup passes: 1) Reuse — find duplicated logic, replace with existing helpers; 2) Simplification — flatten nesting, remove redundant state and dead code; 3) Efficiency — fix repeated object creation, unnecessary I/O, memory issues; 4) Abstraction Level — ensure code sits at the right architectural layer. Apply equivalent transformations only — do NOT change logic or fix bugs.',
1477
- }
1478
- } catch {
1479
- return { content: '─ Simplify ─\n\nCould not detect changes. Are you in a git repository?' }
1480
- }
1481
- }
1482
-
1483
- const verifyCmd: CommandHandler = async () => {
1484
- try {
1485
- const { execSync } = await import('node:child_process')
1486
- const diff = execSync('git diff --stat', { encoding: 'utf-8', timeout: 5000 }).trim()
1487
- if (!diff) {
1456
+ } catch {
1488
1457
  return {
1489
- content:
1490
- '─ Verify ─\n\nNo uncommitted changes to verify.\n\nMake changes first, then run /verify for runtime verification.',
1458
+ content: `─ ${opts.label} ─\n\nCould not detect changes. Are you in a git repository?`,
1491
1459
  }
1492
1460
  }
1493
- return {
1494
- content:
1495
- '─ Verify ─\n\nRunning runtime verification — observing actual execution behavior (not tests, not typecheck)...',
1496
- injectMessage:
1497
- 'verify these uncommitted changes through runtime observation only. For each change: 1) Find the user-facing surface (CLI command, API endpoint, UI interaction); 2) Drive the changed code to execute; 3) Push boundaries — pass null, repeated values, wrong types, interrupt mid-flow (Ctrl-C), resize window; 4) Report verdict per change: PASS (works as expected), FAIL (does not work or breaks something), BLOCKED (cannot reach observable state), SKIP (no runtime surface, e.g. pure documentation). Do NOT run the test suite — observe real execution behavior only.',
1498
- }
1499
- } catch {
1500
- return { content: '─ Verify ─\n\nCould not detect changes. Are you in a git repository?' }
1501
1461
  }
1502
1462
  }
1503
1463
 
1504
- const designCmd: CommandHandler = async (_ctx, args) => {
1464
+ const codeReviewCmd = gitDiffBridgeCmd({
1465
+ label: 'Code Review',
1466
+ noChangesHint:
1467
+ 'No uncommitted changes to review.\n\nTo review a specific file: /code-review path/to/file.ts',
1468
+ runningMsg:
1469
+ 'Reviewing uncommitted changes with the code-review skill (7 dimensions: correctness, security, performance, code quality, architecture, testing, language-specific)...',
1470
+ forwardToAI:
1471
+ 'use the code-review skill to review all uncommitted changes. Check all 7 dimensions: correctness, security, performance, code quality, architecture & design, testing, and language-specific issues.',
1472
+ })
1473
+
1474
+ const simplifyCmd = gitDiffBridgeCmd({
1475
+ label: 'Simplify',
1476
+ noChangesHint:
1477
+ 'No uncommitted changes to simplify.\n\nMake changes first, then run /simplify for cleanup review.',
1478
+ runningMsg:
1479
+ 'Running cleanup review — 4 passes: reuse, simplification, efficiency, abstraction level...',
1480
+ forwardToAI:
1481
+ 'use the self-review skill to review these uncommitted changes. Focus on 4 cleanup passes: 1) Reuse — find duplicated logic, replace with existing helpers; 2) Simplification — flatten nesting, remove redundant state and dead code; 3) Efficiency — fix repeated object creation, unnecessary I/O, memory issues; 4) Abstraction Level — ensure code sits at the right architectural layer. Apply equivalent transformations only — do NOT change logic or fix bugs.',
1482
+ })
1483
+
1484
+ const verifyCmd = gitDiffBridgeCmd({
1485
+ label: 'Verify',
1486
+ noChangesHint:
1487
+ 'No uncommitted changes to verify.\n\nMake changes first, then run /verify for runtime verification.',
1488
+ runningMsg:
1489
+ 'Running runtime verification — observing actual execution behavior (not tests, not typecheck)...',
1490
+ forwardToAI:
1491
+ 'verify these uncommitted changes through runtime observation only. For each change: 1) Find the user-facing surface (CLI command, API endpoint, UI interaction); 2) Drive the changed code to execute; 3) Push boundaries — pass null, repeated values, wrong types, interrupt mid-flow (Ctrl-C), resize window; 4) Report verdict per change: PASS (works as expected), FAIL (does not work or breaks something), BLOCKED (cannot reach observable state), SKIP (no runtime surface, e.g. pure documentation). Do NOT run the test suite — observe real execution behavior only.',
1492
+ })
1493
+
1494
+ const designCmd: CommandHandler = (_ctx, args) => {
1505
1495
  const topic = args.join(' ') || 'the current task'
1506
1496
  return {
1507
1497
  content: `─ Design ─\n\nStarting architectural design session for: ${topic}\n\nExploring approaches, trade-offs, component breakdown, data flow...`,
1508
- injectMessage: `help me design the architecture for ${topic}. Explore 2-3 approaches with trade-offs, then present a design covering: component breakdown, data flow, interfaces between components, error handling strategy, and testing approach. Use the plan sub-agent if deeper analysis would help. Prefer simplicity — YAGNI.`,
1498
+ forwardToAI: `help me design the architecture for ${topic}. Explore 2-3 approaches with trade-offs, then present a design covering: component breakdown, data flow, interfaces between components, error handling strategy, and testing approach. Use the plan sub-agent if deeper analysis would help. Prefer simplicity — YAGNI.`,
1509
1499
  }
1510
1500
  }
1511
1501