openhorse 0.2.0 → 0.2.1

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.
@@ -103,7 +103,7 @@ async function forkSubagent(options) {
103
103
  case 'tool_result':
104
104
  toolCalls.push({
105
105
  name: event.name,
106
- args: {}, // 简化
106
+ args: event.args,
107
107
  result: event.result,
108
108
  });
109
109
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"fork.js","sourceRoot":"","sources":["../../src/agents/fork.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAoDH,oCAgIC;AAgCD,sDAEC;AAKD,0DAEC;AAxND,4CAA2F;AAC3F,oCAAiC;AAuCjC,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;GAEG;AACI,KAAK,UAAU,YAAY,CAAC,OAAoB;IACrD,MAAM,EACJ,cAAc,GAAG,IAAI,EACrB,KAAK,GAAG,aAAK,EACb,QAAQ,GAAG,CAAC,EACZ,UAAU,GAAG,KAAK,EAClB,eAAe,EACf,cAAc,GAAG,EAAE,EACnB,kBAAkB,EAClB,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,aAAa,GAAG,EAAE,EAClB,aAAa,GAAG,EAAE,GACnB,GAAG,OAAO,CAAC;IAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtD,kBAAkB;IAClB,IAAI,QAAmB,CAAC;IAExB,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,iBAAiB;QACjB,QAAQ,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC;QAC/B,eAAe;QACf,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,eAAe,eA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;IACnB,UAAU;IACV,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,GAAG,EAAE,CAAC;YAClB,OAAO,SAAS,CAAC,GAAG,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,+EAA+E;AAC/E,QAAQ;AACR,+EAA+E;AAE/E,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAE/C;;GAEG;AACH,SAAgB,qBAAqB,CAAC,OAAe;IACnD,OAAO,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,GAAG,oBAAoB,KAAK,OAAO,EAAE,CAAC;AAC/C,CAAC"}
@@ -3,9 +3,12 @@
3
3
  *
4
4
  * 注册所有 slash 命令,提供查找和列表功能。
5
5
  */
6
- import type { SlashCommand, CommandContext, CommandResult } from './types';
6
+ import { type SlashCommand, type CommandCategory, type CommandContext, type CommandResult } from './types';
7
+ export declare function getCommandCategoryLabel(category: CommandCategory | undefined): string;
8
+ export declare function sortCommands(commands: SlashCommand[]): SlashCommand[];
7
9
  declare function handleChat(ctx: CommandContext, input: string): Promise<CommandResult>;
8
10
  export declare function getCommands(): SlashCommand[];
11
+ export declare function getVisibleCommands(): SlashCommand[];
9
12
  export declare function findCommand(name: string): SlashCommand | undefined;
10
13
  export declare function getCommandNames(): string[];
11
14
  export { handleChat as executeChat };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAqlB3E,iBAAe,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAiTpF;AA4uBD,wBAAgB,WAAW,IAAI,YAAY,EAAE,CAE5C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAElE;AAED,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAED,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAEnB,MAAM,SAAS,CAAC;AA4EjB,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAErF;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAQrE;AAgmBD,iBAAe,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA0SpF;AA84BD,wBAAgB,WAAW,IAAI,YAAY,EAAE,CAE5C;AAED,wBAAgB,kBAAkB,IAAI,YAAY,EAAE,CAEnD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAElE;AAED,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAED,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,CAAC"}
@@ -8,11 +8,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getCommandCategoryLabel = getCommandCategoryLabel;
12
+ exports.sortCommands = sortCommands;
11
13
  exports.getCommands = getCommands;
14
+ exports.getVisibleCommands = getVisibleCommands;
12
15
  exports.findCommand = findCommand;
13
16
  exports.getCommandNames = getCommandNames;
14
17
  exports.executeChat = handleChat;
15
18
  const chalk_1 = __importDefault(require("chalk"));
19
+ const types_1 = require("./types");
16
20
  const task_manager_1 = require("../services/task-manager");
17
21
  const agent_runner_1 = require("../services/agent-runner");
18
22
  const config_1 = require("../services/config");
@@ -38,6 +42,43 @@ const ERROR = chalk_1.default.red;
38
42
  const WARN = chalk_1.default.yellow;
39
43
  const SUCCESS = chalk_1.default.green;
40
44
  const HEADER = chalk_1.default.cyan.bold;
45
+ const CATEGORY_ORDER = [
46
+ 'workflow',
47
+ 'session',
48
+ 'context',
49
+ 'tools',
50
+ 'model',
51
+ 'system',
52
+ 'diagnostics',
53
+ 'legacy',
54
+ ];
55
+ const CATEGORY_LABELS = {
56
+ workflow: 'Workflow',
57
+ session: 'Session',
58
+ context: 'Context',
59
+ tools: 'Tools',
60
+ model: 'Model',
61
+ system: 'System',
62
+ diagnostics: 'Diagnostics',
63
+ legacy: 'Legacy',
64
+ };
65
+ function commandCategory(command) {
66
+ return command.category ?? 'system';
67
+ }
68
+ function getCommandCategoryLabel(category) {
69
+ return CATEGORY_LABELS[category ?? 'system'];
70
+ }
71
+ function sortCommands(commands) {
72
+ return [...commands].sort((a, b) => {
73
+ const categoryDelta = CATEGORY_ORDER.indexOf(commandCategory(a)) - CATEGORY_ORDER.indexOf(commandCategory(b));
74
+ if (categoryDelta !== 0)
75
+ return categoryDelta;
76
+ const priorityDelta = (a.priority ?? 100) - (b.priority ?? 100);
77
+ if (priorityDelta !== 0)
78
+ return priorityDelta;
79
+ return a.name.localeCompare(b.name);
80
+ });
81
+ }
41
82
  function isAbortError(error, abortSignal) {
42
83
  if (abortSignal?.aborted)
43
84
  return true;
@@ -74,13 +115,20 @@ function showHelp() {
74
115
  console.log();
75
116
  console.log(HEADER('Commands:'));
76
117
  console.log();
77
- for (const cmd of COMMANDS) {
78
- const aliases = cmd.aliases ? ` (${cmd.aliases.join(', ')})` : '';
79
- const params = cmd.params?.map(p => `<${p.name}>`).join(' ') || '';
80
- console.log(` ${ACCENT(`/${cmd.name}`)}${aliases} ${DIM(params)}`);
81
- console.log(` ${DIM(cmd.description)}`);
118
+ const visible = getVisibleCommands();
119
+ for (const category of CATEGORY_ORDER) {
120
+ const items = visible.filter(cmd => commandCategory(cmd) === category);
121
+ if (items.length === 0)
122
+ continue;
123
+ console.log(DIM(getCommandCategoryLabel(category)));
124
+ for (const cmd of items) {
125
+ const aliases = cmd.aliases ? ` (${cmd.aliases.join(', ')})` : '';
126
+ const params = cmd.argumentHint || cmd.params?.map(p => `<${p.name}>`).join(' ') || '';
127
+ console.log(` ${ACCENT(`/${cmd.name}`)}${aliases} ${DIM(params)}`);
128
+ console.log(` ${DIM(cmd.description)}`);
129
+ }
130
+ console.log();
82
131
  }
83
- console.log();
84
132
  console.log(DIM('Type any text without / prefix to chat with the LLM.'));
85
133
  console.log();
86
134
  return { success: true };
@@ -422,6 +470,54 @@ function handleModel(ctx, args) {
422
470
  console.log();
423
471
  return { success: true };
424
472
  }
473
+ function normalizePermissionMode(raw) {
474
+ const value = raw.trim().toLowerCase();
475
+ if (!value)
476
+ return null;
477
+ if (value === 'accept' || value === 'acceptedits' || value === 'accept-edits' || value === 'edit') {
478
+ return 'acceptEdits';
479
+ }
480
+ if (value === 'default' || value === 'ask')
481
+ return 'default';
482
+ if (value === 'plan' || value === 'readonly' || value === 'read-only')
483
+ return 'plan';
484
+ if (value === 'auto' || value === 'full-auto')
485
+ return 'auto';
486
+ return null;
487
+ }
488
+ function handleMode(ctx, args) {
489
+ const current = ctx.store.getSnapshot().permissionMode;
490
+ const trimmed = args.trim();
491
+ if (!trimmed || trimmed === '?' || trimmed === 'help') {
492
+ console.log();
493
+ console.log(HEADER('Permission Mode'));
494
+ console.log(DIM('─'.repeat(40)));
495
+ console.log(` Current ${ACCENT(current)} ${DIM((0, types_1.getModeDisplayText)(current) || 'ask before sensitive actions')}`);
496
+ console.log();
497
+ console.log(` ${ACCENT('/mode next')} Cycle to the next mode`);
498
+ console.log(` ${ACCENT('/mode default')} Ask before sensitive actions`);
499
+ console.log(` ${ACCENT('/mode accept-edits')} Auto-accept file edits`);
500
+ console.log(` ${ACCENT('/mode plan')} Plan first, avoid executing edits`);
501
+ console.log(` ${ACCENT('/mode auto')} Auto-run allowed actions`);
502
+ console.log();
503
+ return { success: true };
504
+ }
505
+ const next = trimmed === 'next'
506
+ ? (0, types_1.getNextPermissionMode)(current)
507
+ : normalizePermissionMode(trimmed);
508
+ if (!next || !types_1.PERMISSION_MODES.includes(next)) {
509
+ return {
510
+ success: false,
511
+ error: `Unknown mode: ${trimmed}. Use one of: default, accept-edits, plan, auto, next.`,
512
+ };
513
+ }
514
+ ctx.store.setPermissionMode(next);
515
+ const display = (0, types_1.getModeDisplayText)(next);
516
+ return {
517
+ success: true,
518
+ output: `Mode changed to ${next}${display ? ` (${display})` : ''}.`,
519
+ };
520
+ }
425
521
  function handleTask(ctx, args) {
426
522
  const [sub, ...rest] = args.trim().split(/\s+/);
427
523
  if (sub === 'list' || sub === 'ls') {
@@ -597,8 +693,6 @@ async function handleChat(ctx, input) {
597
693
  let finalUsage;
598
694
  let responseStarted = false;
599
695
  const sessionMessagesToRecord = [];
600
- let lastToolCallId = '';
601
- let lastToolArgs = {};
602
696
  // Issue #22: 批量工具调用进度显示
603
697
  let toolCallCount = 0;
604
698
  let lastProgressUpdate = 0;
@@ -692,23 +786,18 @@ async function handleChat(ctx, input) {
692
786
  (0, progress_1.showToolProgress)(toolCallCount, event.name);
693
787
  lastProgressUpdate = Date.now();
694
788
  }
695
- // 收集完整的 tool_call 信息
696
- lastToolCallId = event.callId;
697
- lastToolArgs = event.args;
698
789
  break;
699
790
  case 'tool_result':
700
791
  // Issue #22: 隐藏进度指示
701
792
  (0, progress_1.hideProgress)();
702
793
  // 显示工具结果后,准备下一轮(不启动 spinner)
703
- const parsedResult = JSON.parse(event.result);
704
- const toolSuccess = parsedResult.success !== false;
705
- writeLine((0, box_1.toolLine)(event.name, lastToolArgs, toolSuccess, event.duration));
794
+ writeLine((0, box_1.toolLine)(event.name, event.args, event.success, event.duration));
706
795
  // 显示错误详情
707
- if (!toolSuccess && parsedResult.error) {
708
- writeLine(ERROR(` Error: ${parsedResult.error}`));
796
+ if (!event.success && event.error) {
797
+ writeLine(ERROR(` Error: ${event.error}`));
709
798
  }
710
799
  // Debug: 显示接收到的参数
711
- if (!toolSuccess && Object.keys(lastToolArgs).length === 0) {
800
+ if (!event.success && Object.keys(event.args).length === 0) {
712
801
  writeLine(WARN(` ⚠ Tool received empty arguments - LLM may not be providing parameters correctly`));
713
802
  writeLine(DIM(` Try using /model qwen or /model gpt4o for better tool calling support`));
714
803
  }
@@ -717,7 +806,7 @@ async function handleChat(ctx, input) {
717
806
  role: 'tool',
718
807
  content: event.result,
719
808
  timestamp: Date.now(),
720
- toolCallId: lastToolCallId,
809
+ toolCallId: event.callId,
721
810
  });
722
811
  break;
723
812
  case 'message':
@@ -920,6 +1009,53 @@ function handleMcp(ctx) {
920
1009
  console.log();
921
1010
  return { success: true };
922
1011
  }
1012
+ function handleTools(ctx) {
1013
+ const tools = ctx.store.getSnapshot().tools.length > 0
1014
+ ? ctx.store.getSnapshot().tools
1015
+ : (0, tools_1.getRuntimeTools)();
1016
+ const staticTools = tools.filter(tool => !tool.name.startsWith('mcp__'));
1017
+ const mcpTools = tools.filter(tool => tool.name.startsWith('mcp__'));
1018
+ console.log();
1019
+ console.log(HEADER('Available Tools'));
1020
+ console.log(DIM('─'.repeat(40)));
1021
+ console.log(` Static tools ${ACCENT(String(staticTools.length))}`);
1022
+ console.log(` MCP tools ${ACCENT(String(mcpTools.length))}`);
1023
+ console.log();
1024
+ const visible = [...staticTools, ...mcpTools].slice(0, 28);
1025
+ for (const tool of visible) {
1026
+ const label = tool.name.startsWith('mcp__') ? 'mcp' : 'tool';
1027
+ console.log(` ${ACCENT(tool.name)} ${DIM(`[${label}]`)}`);
1028
+ console.log(` ${DIM(tool.description.slice(0, 96))}`);
1029
+ }
1030
+ if (tools.length > visible.length) {
1031
+ console.log();
1032
+ console.log(DIM(` ... ${tools.length - visible.length} more tools hidden`));
1033
+ }
1034
+ console.log();
1035
+ return { success: true };
1036
+ }
1037
+ function handleTodos(ctx) {
1038
+ const todos = ctx.store.getSnapshot().todos;
1039
+ console.log();
1040
+ console.log(HEADER('Todos'));
1041
+ console.log(DIM('─'.repeat(40)));
1042
+ if (todos.length === 0) {
1043
+ console.log(DIM(' No active todos yet.'));
1044
+ console.log();
1045
+ return { success: true };
1046
+ }
1047
+ for (const todo of todos) {
1048
+ const marker = todo.status === 'completed' ? SUCCESS('✓')
1049
+ : todo.status === 'in_progress' ? WARN('›')
1050
+ : DIM('○');
1051
+ console.log(` ${marker} ${todo.content}`);
1052
+ if (todo.activeForm && todo.activeForm !== todo.content) {
1053
+ console.log(` ${DIM(todo.activeForm)}`);
1054
+ }
1055
+ }
1056
+ console.log();
1057
+ return { success: true };
1058
+ }
923
1059
  function handleClearHistory(ctx) {
924
1060
  const history = ctx.store.getSnapshot().conversationHistory;
925
1061
  if (history.length === 0) {
@@ -1292,167 +1428,275 @@ function generateHistorySummary(messages) {
1292
1428
  }
1293
1429
  return parts.join('. ');
1294
1430
  }
1431
+ function continueAsSlashChat(name, args) {
1432
+ const trimmed = args.trim();
1433
+ return {
1434
+ success: true,
1435
+ continueAsChat: true,
1436
+ chatInput: `/${name}${trimmed ? ` ${trimmed}` : ''}`,
1437
+ };
1438
+ }
1295
1439
  // ============================================================================
1296
1440
  // 命令注册表
1297
1441
  // ============================================================================
1298
1442
  const COMMANDS = [
1299
- // 系统命令
1443
+ // Coding workflows
1300
1444
  {
1301
- name: 'help',
1302
- aliases: ['h'],
1303
- description: 'Show available commands',
1445
+ name: 'review',
1446
+ description: 'Review the current change or requested files',
1447
+ argumentHint: '[scope]',
1448
+ category: 'workflow',
1449
+ priority: 10,
1450
+ type: 'chat',
1451
+ execute: (_ctx, args) => continueAsSlashChat('review', args),
1452
+ },
1453
+ {
1454
+ name: 'security',
1455
+ aliases: ['audit'],
1456
+ description: 'Review code or dependencies for security risks',
1457
+ argumentHint: '[scope]',
1458
+ category: 'workflow',
1459
+ priority: 20,
1460
+ type: 'chat',
1461
+ execute: (_ctx, args) => continueAsSlashChat('security', args),
1462
+ },
1463
+ {
1464
+ name: 'test-gen',
1465
+ aliases: ['tests'],
1466
+ description: 'Generate or improve tests for a target area',
1467
+ argumentHint: '[scope]',
1468
+ category: 'workflow',
1469
+ priority: 30,
1470
+ type: 'chat',
1471
+ execute: (_ctx, args) => continueAsSlashChat('test-gen', args),
1472
+ },
1473
+ {
1474
+ name: 'todos',
1475
+ aliases: ['todo'],
1476
+ description: 'Show current agent todo state',
1477
+ category: 'workflow',
1478
+ priority: 40,
1304
1479
  type: 'builtin',
1305
- execute: () => showHelp(),
1480
+ execute: (ctx) => handleTodos(ctx),
1306
1481
  },
1482
+ // Sessions and context lifecycle
1307
1483
  {
1308
- name: 'status',
1309
- aliases: ['s'],
1310
- description: 'Show system status overview',
1484
+ name: 'resume',
1485
+ description: 'Resume a previous session',
1486
+ argumentHint: '[number|session-id|name]',
1487
+ category: 'session',
1488
+ priority: 10,
1311
1489
  type: 'builtin',
1312
- execute: (ctx) => showStatus(ctx),
1490
+ execute: (ctx, args) => handleResume(ctx, args),
1313
1491
  },
1314
1492
  {
1315
- name: 'clear',
1316
- description: 'Clear the terminal screen',
1493
+ name: 'sessions',
1494
+ description: 'List recent sessions',
1495
+ category: 'session',
1496
+ priority: 20,
1317
1497
  type: 'builtin',
1318
- execute: () => {
1319
- process.stdout.write('\x1Bc');
1320
- return { success: true };
1321
- },
1498
+ execute: (ctx, args) => handleSessions(ctx, args),
1322
1499
  },
1323
1500
  {
1324
- name: 'clear-history',
1325
- aliases: ['reset'],
1326
- description: 'Clear conversation history (keep config)',
1501
+ name: 'session-rename',
1502
+ aliases: ['rename-session'],
1503
+ description: 'Rename a saved session',
1504
+ argumentHint: '<number|session-id|name> <new name>',
1505
+ category: 'session',
1506
+ priority: 30,
1327
1507
  type: 'builtin',
1328
- execute: (ctx) => handleClearHistory(ctx),
1508
+ execute: (ctx, args) => handleSessionRename(ctx, args),
1329
1509
  },
1330
1510
  {
1331
1511
  name: 'compact',
1332
1512
  description: 'Compact conversation history to reduce context size',
1333
1513
  argumentHint: '[threshold]',
1514
+ category: 'session',
1515
+ priority: 40,
1334
1516
  type: 'builtin',
1335
1517
  execute: (ctx, args) => handleCompact(ctx, args),
1336
1518
  },
1337
1519
  {
1338
- name: 'exit',
1339
- aliases: ['quit', 'q'],
1340
- description: 'Shutdown and exit',
1520
+ name: 'clear-history',
1521
+ aliases: ['reset'],
1522
+ description: 'Clear conversation history (keep config)',
1523
+ category: 'session',
1524
+ priority: 50,
1341
1525
  type: 'builtin',
1342
- execute: (ctx) => handleExit(ctx),
1526
+ execute: (ctx) => handleClearHistory(ctx),
1343
1527
  },
1344
- // 成本/用量命令
1528
+ // Harness, memory, and skills
1345
1529
  {
1346
- name: 'cost',
1347
- description: 'Show session token usage',
1530
+ name: 'harness',
1531
+ description: 'Show Context Harness state, or `/harness explain` for prompt assembly details',
1532
+ argumentHint: '[explain]',
1533
+ category: 'context',
1534
+ priority: 10,
1348
1535
  type: 'builtin',
1349
- execute: (ctx) => handleCost(ctx),
1536
+ execute: (ctx, args) => showHarness(ctx, args),
1350
1537
  },
1351
1538
  {
1352
- name: 'usage',
1353
- aliases: ['stats'],
1354
- description: 'Show detailed usage statistics',
1539
+ name: 'skills',
1540
+ description: 'List loaded skills (built-in / user / project)',
1541
+ category: 'context',
1542
+ priority: 20,
1355
1543
  type: 'builtin',
1356
- execute: (ctx) => handleUsage(ctx),
1544
+ execute: (ctx) => handleSkills(ctx),
1545
+ },
1546
+ {
1547
+ name: 'memory',
1548
+ description: 'Show memory status, or `/memory reindex` to rebuild semantic index',
1549
+ argumentHint: '[reindex]',
1550
+ category: 'context',
1551
+ priority: 30,
1552
+ type: 'builtin',
1553
+ execute: (ctx, args) => handleMemory(ctx, args),
1554
+ },
1555
+ // Tools and safety
1556
+ {
1557
+ name: 'tools',
1558
+ aliases: ['tool'],
1559
+ description: 'List available built-in and MCP tools',
1560
+ category: 'tools',
1561
+ priority: 10,
1562
+ type: 'builtin',
1563
+ execute: (ctx) => handleTools(ctx),
1357
1564
  },
1358
- // 配置命令
1565
+ {
1566
+ name: 'mcp',
1567
+ description: 'Show connected MCP servers and their status',
1568
+ category: 'tools',
1569
+ priority: 20,
1570
+ type: 'builtin',
1571
+ execute: (ctx) => handleMcp(ctx),
1572
+ },
1573
+ {
1574
+ name: 'safety',
1575
+ description: 'Show safety checker status and audit summary',
1576
+ category: 'tools',
1577
+ priority: 30,
1578
+ type: 'builtin',
1579
+ execute: (ctx) => showSafety(ctx),
1580
+ },
1581
+ // Model and runtime configuration
1359
1582
  {
1360
1583
  name: 'model',
1361
1584
  description: 'Show or change the current model',
1362
1585
  argumentHint: '[model|list|help]',
1586
+ category: 'model',
1587
+ priority: 10,
1363
1588
  type: 'builtin',
1364
1589
  execute: (ctx, args) => handleModel(ctx, args),
1365
1590
  },
1366
1591
  {
1367
- name: 'config',
1368
- description: 'Show current configuration',
1369
- type: 'builtin',
1370
- execute: (ctx) => showConfig(ctx),
1371
- },
1372
- // Agent/Harness 命令
1373
- {
1374
- name: 'agents',
1375
- description: 'List registered agents and their status',
1592
+ name: 'mode',
1593
+ aliases: ['permissions', 'perm'],
1594
+ description: 'Show or change tool permission mode',
1595
+ argumentHint: '[default|accept-edits|plan|auto|next]',
1596
+ category: 'model',
1597
+ priority: 20,
1376
1598
  type: 'builtin',
1377
- execute: (ctx) => showAgents(ctx),
1599
+ execute: (ctx, args) => handleMode(ctx, args),
1378
1600
  },
1379
1601
  {
1380
- name: 'memory',
1381
- description: 'Show memory status, or `/memory reindex` to rebuild semantic index',
1382
- argumentHint: '[reindex]',
1602
+ name: 'config',
1603
+ description: 'Show current configuration',
1604
+ category: 'model',
1605
+ priority: 30,
1383
1606
  type: 'builtin',
1384
- execute: (ctx, args) => handleMemory(ctx, args),
1607
+ execute: (ctx) => showConfig(ctx),
1385
1608
  },
1609
+ // System commands
1386
1610
  {
1387
- name: 'safety',
1388
- description: 'Show safety checker status and audit summary',
1611
+ name: 'help',
1612
+ aliases: ['h'],
1613
+ description: 'Show available commands',
1614
+ category: 'system',
1615
+ priority: 10,
1389
1616
  type: 'builtin',
1390
- execute: (ctx) => showSafety(ctx),
1617
+ execute: () => showHelp(),
1391
1618
  },
1392
1619
  {
1393
- name: 'harness',
1394
- description: 'Show Context Harness state, or `/harness explain` for prompt assembly details',
1395
- argumentHint: '[explain]',
1620
+ name: 'status',
1621
+ aliases: ['s'],
1622
+ description: 'Show system status overview',
1623
+ category: 'system',
1624
+ priority: 20,
1396
1625
  type: 'builtin',
1397
- execute: (ctx, args) => showHarness(ctx, args),
1626
+ execute: (ctx) => showStatus(ctx),
1398
1627
  },
1399
- // Task 命令
1400
1628
  {
1401
- name: 'task',
1402
- description: 'Submit or list tasks',
1403
- params: [{ name: 'action', description: 'list | <task-name>', required: false }],
1629
+ name: 'clear',
1630
+ description: 'Clear the terminal screen',
1631
+ category: 'system',
1632
+ priority: 30,
1404
1633
  type: 'builtin',
1405
- execute: (ctx, args) => handleTask(ctx, args),
1634
+ execute: () => {
1635
+ process.stdout.write('\x1Bc');
1636
+ return { success: true };
1637
+ },
1406
1638
  },
1407
1639
  {
1408
- name: 'run',
1409
- description: 'Create and run a task through Agent + LLM',
1410
- params: [{ name: 'description', description: 'Task description', required: true }],
1640
+ name: 'exit',
1641
+ aliases: ['quit', 'q'],
1642
+ description: 'Shutdown and exit',
1643
+ category: 'system',
1644
+ priority: 40,
1411
1645
  type: 'builtin',
1412
- execute: (ctx, args) => handleRun(ctx, args),
1646
+ execute: (ctx) => handleExit(ctx),
1413
1647
  },
1414
- // Session 命令
1648
+ // Diagnostics
1415
1649
  {
1416
- name: 'sessions',
1417
- description: 'List recent sessions',
1650
+ name: 'usage',
1651
+ aliases: ['stats'],
1652
+ description: 'Show detailed usage statistics',
1653
+ category: 'diagnostics',
1654
+ priority: 10,
1418
1655
  type: 'builtin',
1419
- execute: (ctx, args) => handleSessions(ctx, args),
1656
+ execute: (ctx) => handleUsage(ctx),
1420
1657
  },
1421
1658
  {
1422
- name: 'resume',
1423
- description: 'Resume a previous session',
1424
- argumentHint: '[number|session-id|name]',
1659
+ name: 'cost',
1660
+ description: 'Show session token usage',
1661
+ category: 'diagnostics',
1662
+ priority: 20,
1425
1663
  type: 'builtin',
1426
- execute: (ctx, args) => handleResume(ctx, args),
1664
+ execute: (ctx) => handleCost(ctx),
1427
1665
  },
1428
1666
  {
1429
- name: 'session-rename',
1430
- aliases: ['rename-session'],
1431
- description: 'Rename a saved session',
1432
- argumentHint: '<number|session-id|name> <new name>',
1667
+ name: 'agents',
1668
+ description: 'List registered agents and their status',
1669
+ category: 'diagnostics',
1670
+ priority: 30,
1433
1671
  type: 'builtin',
1434
- execute: (ctx, args) => handleSessionRename(ctx, args),
1672
+ execute: (ctx) => showAgents(ctx),
1435
1673
  },
1436
- // MCP
1674
+ // Legacy commands kept executable for compatibility, but not shown in Ink help/palette.
1437
1675
  {
1438
- name: 'mcp',
1439
- description: 'Show connected MCP servers and their status',
1676
+ name: 'task',
1677
+ description: 'Submit or list tasks',
1678
+ params: [{ name: 'action', description: 'list | <task-name>', required: false }],
1679
+ category: 'legacy',
1440
1680
  type: 'builtin',
1441
- execute: (ctx) => handleMcp(ctx),
1681
+ isHidden: true,
1682
+ execute: (ctx, args) => handleTask(ctx, args),
1442
1683
  },
1443
- // Skills
1444
1684
  {
1445
- name: 'skills',
1446
- description: 'List loaded skills (built-in / user / project)',
1685
+ name: 'run',
1686
+ description: 'Create and run a task through Agent + LLM',
1687
+ params: [{ name: 'description', description: 'Task description', required: true }],
1688
+ category: 'legacy',
1447
1689
  type: 'builtin',
1448
- execute: (ctx) => handleSkills(ctx),
1690
+ isHidden: true,
1691
+ execute: (ctx, args) => handleRun(ctx, args),
1449
1692
  },
1450
- // Chat 命令
1451
1693
  {
1452
1694
  name: 'chat',
1453
1695
  description: 'Send a message to the LLM',
1454
1696
  params: [{ name: 'message', description: 'Message to send', required: true }],
1697
+ category: 'legacy',
1455
1698
  type: 'chat',
1699
+ isHidden: true,
1456
1700
  execute: (ctx, args) => ({ success: true, continueAsChat: true, chatInput: args }),
1457
1701
  },
1458
1702
  ];
@@ -1460,12 +1704,15 @@ const COMMANDS = [
1460
1704
  // 导出
1461
1705
  // ============================================================================
1462
1706
  function getCommands() {
1463
- return COMMANDS;
1707
+ return sortCommands(COMMANDS);
1708
+ }
1709
+ function getVisibleCommands() {
1710
+ return sortCommands(COMMANDS.filter(command => !command.isHidden));
1464
1711
  }
1465
1712
  function findCommand(name) {
1466
1713
  return COMMANDS.find(c => c.name === name || c.aliases?.includes(name));
1467
1714
  }
1468
1715
  function getCommandNames() {
1469
- return COMMANDS.map(c => c.name);
1716
+ return getVisibleCommands().map(c => c.name);
1470
1717
  }
1471
1718
  //# sourceMappingURL=index.js.map