@miphamai/cli 0.85.35 → 0.85.37
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/config/loader.ts +81 -4
- package/src/core/engine.ts +29 -2
- package/src/core/hooks-executor.ts +15 -0
- package/src/core/improvement-track.ts +37 -1
- package/src/core/meta-rule-engine.ts +3 -1
- package/src/core/permission-rules.ts +60 -0
- package/src/core/permission.ts +17 -5
- package/src/core/rule-engine.ts +11 -5
- package/src/core/task-performance.ts +41 -0
- package/src/daemon/attach-protocol.ts +25 -0
- package/src/daemon/remote-engine.ts +161 -4
- package/src/daemon/session-worker.ts +50 -0
- package/src/i18n-core/detect.ts +16 -4
- package/src/i18n-core/locales/en-US.json +6 -5
- package/src/i18n-core/locales/zh-CN.json +6 -5
- package/src/i18n-core/preference.ts +55 -0
- package/src/index.tsx +3 -2
- package/src/mcp/registry.ts +66 -14
- package/src/shared/package-info.ts +3 -3
- package/src/skills/loader.ts +30 -0
- package/src/skills/seam.ts +7 -0
- package/src/tools/agent/report-findings.ts +20 -2
- package/src/tools/agent/skill.ts +9 -1
- package/src/tools/exec/bash.ts +59 -0
- package/src/tools/exec/git.ts +82 -0
- package/src/tools/network/web-fetch.ts +20 -0
- package/src/ui/app.tsx +40 -20
- package/src/ui/commands.ts +539 -98
- package/src/ui/strip-indent.ts +9 -4
package/src/ui/commands.ts
CHANGED
|
@@ -64,6 +64,7 @@ import { randomUUID } from 'node:crypto'
|
|
|
64
64
|
import {
|
|
65
65
|
buildImprovementReport,
|
|
66
66
|
formatCostLine,
|
|
67
|
+
formatNullModelLine,
|
|
67
68
|
appendImprovement,
|
|
68
69
|
readImprovements,
|
|
69
70
|
improvementRate,
|
|
@@ -89,7 +90,9 @@ import { getTelemetryConsent, enableTelemetryNow } from '../telemetry/index'
|
|
|
89
90
|
import { NO_ENDPOINT } from '../telemetry/endpoint'
|
|
90
91
|
import { stripIndent } from './strip-indent.js'
|
|
91
92
|
import { createT } from '../i18n-core/t'
|
|
92
|
-
import type { TranslationMap } from '../i18n-core/types'
|
|
93
|
+
import type { Locale, TranslationMap } from '../i18n-core/types'
|
|
94
|
+
import { SUPPORTED_LOCALES } from '../i18n-core/types'
|
|
95
|
+
import { saveLocalePreference } from '../i18n-core/preference'
|
|
93
96
|
import enUS from '../i18n-core/locales/en-US.json' with { type: 'json' }
|
|
94
97
|
import zhCN from '../i18n-core/locales/zh-CN.json' with { type: 'json' }
|
|
95
98
|
|
|
@@ -102,6 +105,15 @@ const defaultT = createT(enUS as unknown as TranslationMap, zhCN as unknown as T
|
|
|
102
105
|
function resolveT(ctx: CommandContext): (key: string, params?: Record<string, string>) => string {
|
|
103
106
|
return ctx.t && typeof ctx.t === 'function' ? ctx.t : defaultT
|
|
104
107
|
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A remote attach session's state lives on the daemon. Commands that would
|
|
111
|
+
* report success after touching only a local no-op are refused here — the
|
|
112
|
+
* alternative is a confirmation for something that did not happen.
|
|
113
|
+
*/
|
|
114
|
+
function attachedRefusal(action: string, detail: string): string {
|
|
115
|
+
return `Cannot ${action}: this session is attached to a daemon. ${detail}`
|
|
116
|
+
}
|
|
105
117
|
import {
|
|
106
118
|
initCmd,
|
|
107
119
|
setupCmd,
|
|
@@ -112,7 +124,7 @@ import {
|
|
|
112
124
|
promptAuditCmd,
|
|
113
125
|
trustCmd,
|
|
114
126
|
} from '../commands/project.js'
|
|
115
|
-
import {
|
|
127
|
+
import { releaseNotesCmd, ideCmd, terminalSetupCmd } from '../commands/environment.js'
|
|
116
128
|
import { commitCmd, pushCmd, prCmd, issueCmd } from '../commands/git.js'
|
|
117
129
|
import { suggestDirectories } from '../commands/cd-suggest.js'
|
|
118
130
|
import { keysCmd } from '../commands/keys'
|
|
@@ -134,6 +146,8 @@ export interface CommandContext {
|
|
|
134
146
|
setSessionTitle: (title: string) => void
|
|
135
147
|
setEffort: (level: string) => void
|
|
136
148
|
setFocusMode: (on: boolean) => void
|
|
149
|
+
/** Current focus-view state — `/focus` toggles from this, not from `true`. */
|
|
150
|
+
getFocusMode?: () => boolean
|
|
137
151
|
setGoal: (text: string) => void
|
|
138
152
|
setUltracodeMode: (on: boolean) => void
|
|
139
153
|
setUpdateStatus: (s: UpdateStatus) => void
|
|
@@ -146,6 +160,8 @@ export interface CommandContext {
|
|
|
146
160
|
/** i18n translate function — populated from React tree via useI18n().
|
|
147
161
|
* Falls back to module-level defaultT (en-US) in tests / bootstrap. */
|
|
148
162
|
t: (key: string, params?: Record<string, string>) => string
|
|
163
|
+
/** Locale the UI is currently mounted with (`/lang` reports this, not a guess). */
|
|
164
|
+
locale?: Locale
|
|
149
165
|
}
|
|
150
166
|
|
|
151
167
|
export interface CommandResult {
|
|
@@ -183,6 +199,31 @@ export type CommandHandler = (
|
|
|
183
199
|
args: string[],
|
|
184
200
|
) => CommandResult | Promise<CommandResult>
|
|
185
201
|
|
|
202
|
+
export type CommandOutcome = { ok: true; result: CommandResult } | { ok: false; message: string }
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Run a command handler, turning a throw into a value.
|
|
206
|
+
*
|
|
207
|
+
* Handlers reach the filesystem (`/permissions` writes settings.json, `/export`
|
|
208
|
+
* writes a file, `/resume` reads session files), so they can fail for reasons
|
|
209
|
+
* the user can act on — EACCES, ENOSPC, a read-only home. Before this wrapper the
|
|
210
|
+
* rejection escaped the submit callback: the process-wide crash handler saw an
|
|
211
|
+
* unhandled rejection and exited, so "the settings file could not be written"
|
|
212
|
+
* looked like "the command killed the CLI". A failure is that command's answer,
|
|
213
|
+
* and the session stays up.
|
|
214
|
+
*/
|
|
215
|
+
export async function runCommandHandler(
|
|
216
|
+
handler: CommandHandler,
|
|
217
|
+
ctx: CommandContext,
|
|
218
|
+
args: string[],
|
|
219
|
+
): Promise<CommandOutcome> {
|
|
220
|
+
try {
|
|
221
|
+
return { ok: true, result: await handler(ctx, args) }
|
|
222
|
+
} catch (err) {
|
|
223
|
+
return { ok: false, message: err instanceof Error ? err.message : String(err) }
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
186
227
|
// ═══════════════════════════════════════════════════════════════
|
|
187
228
|
// Session & Identity
|
|
188
229
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -234,8 +275,7 @@ const helpCmd: CommandHandler = (ctx) => {
|
|
|
234
275
|
/providers List configured providers
|
|
235
276
|
/switch <p> <m> Switch provider and model
|
|
236
277
|
/config View configuration
|
|
237
|
-
/effort <lvl> Set
|
|
238
|
-
/theme [dark|light|auto] Set terminal theme
|
|
278
|
+
/effort <lvl> Set the stream stall budget (low|medium|high|xhigh|max)
|
|
239
279
|
/ollama-refresh Refresh Ollama model list at runtime
|
|
240
280
|
|
|
241
281
|
── Tools & Skills ──────────────────
|
|
@@ -261,7 +301,7 @@ const helpCmd: CommandHandler = (ctx) => {
|
|
|
261
301
|
/todos [list|create] Task management
|
|
262
302
|
/tasks Background tasks
|
|
263
303
|
/review Code review workflow
|
|
264
|
-
/pr-comments PR
|
|
304
|
+
/pr-comments PR comments via gh + branch summary
|
|
265
305
|
/diff Show git diff
|
|
266
306
|
/workflows List workflow scripts
|
|
267
307
|
/loop <int> <p> Run prompt on interval
|
|
@@ -274,10 +314,10 @@ const helpCmd: CommandHandler = (ctx) => {
|
|
|
274
314
|
/schedule View scheduled tasks
|
|
275
315
|
|
|
276
316
|
── Git & GitHub ─────────────────────
|
|
277
|
-
/commit
|
|
278
|
-
/push
|
|
279
|
-
/pr
|
|
280
|
-
/issue
|
|
317
|
+
/commit Draft a commit message from staged changes
|
|
318
|
+
/push Show push status and the command to run
|
|
319
|
+
/pr Draft a pull request title and body
|
|
320
|
+
/issue Draft a GitHub issue from your description
|
|
281
321
|
|
|
282
322
|
── Code Quality ─────────────────────
|
|
283
323
|
/simplify Review for reuse, quality, simplification
|
|
@@ -327,7 +367,7 @@ const versionCmd: CommandHandler = (ctx) => {
|
|
|
327
367
|
content: stripIndent`
|
|
328
368
|
Mipham Code v${ctx.version}
|
|
329
369
|
|
|
330
|
-
Runtime:
|
|
370
|
+
Runtime: ${typeof Bun !== 'undefined' ? `Bun ${Bun.version}` : `Node.js ${process.version}`}
|
|
331
371
|
Platform: ${process.platform} ${process.arch}
|
|
332
372
|
Node: ${process.version}
|
|
333
373
|
CWD: ${process.cwd()}
|
|
@@ -341,6 +381,14 @@ const versionCmd: CommandHandler = (ctx) => {
|
|
|
341
381
|
}
|
|
342
382
|
|
|
343
383
|
const clearCmd: CommandHandler = (ctx) => {
|
|
384
|
+
if (ctx.engine.isRemote) {
|
|
385
|
+
return {
|
|
386
|
+
content: attachedRefusal(
|
|
387
|
+
'clear this conversation',
|
|
388
|
+
'The conversation lives on the daemon; clearing the local view would leave it untouched.',
|
|
389
|
+
),
|
|
390
|
+
}
|
|
391
|
+
}
|
|
344
392
|
ctx.engine.getContext().clear()
|
|
345
393
|
// The task list outlives the process now, so "start over" has to say so
|
|
346
394
|
// explicitly — otherwise the old plan comes back on resume and the panel keeps
|
|
@@ -357,6 +405,14 @@ const exitCmd: CommandHandler = () => ({ content: '', exit: true })
|
|
|
357
405
|
// ═══════════════════════════════════════════════════════════════
|
|
358
406
|
|
|
359
407
|
const compactCmd: CommandHandler = async (ctx) => {
|
|
408
|
+
if (ctx.engine.isRemote) {
|
|
409
|
+
return {
|
|
410
|
+
content: attachedRefusal(
|
|
411
|
+
'compact here',
|
|
412
|
+
'The conversation and its context live on the daemon, not in this terminal.',
|
|
413
|
+
),
|
|
414
|
+
}
|
|
415
|
+
}
|
|
360
416
|
const t = resolveT(ctx)
|
|
361
417
|
const context = ctx.engine.getContext()
|
|
362
418
|
const msgsBefore = context.getMessageCount()
|
|
@@ -388,6 +444,14 @@ const compactCmd: CommandHandler = async (ctx) => {
|
|
|
388
444
|
}
|
|
389
445
|
|
|
390
446
|
const contextCmd: CommandHandler = (ctx) => {
|
|
447
|
+
if (ctx.engine.isRemote) {
|
|
448
|
+
return {
|
|
449
|
+
content: attachedRefusal(
|
|
450
|
+
'show context usage here',
|
|
451
|
+
'The context window is held by the daemon session.',
|
|
452
|
+
),
|
|
453
|
+
}
|
|
454
|
+
}
|
|
391
455
|
const t = resolveT(ctx)
|
|
392
456
|
const c = ctx.engine.getContext()
|
|
393
457
|
const tokens = c.getEstimatedTokens()
|
|
@@ -480,7 +544,7 @@ const statusCmd: CommandHandler = async (ctx) => {
|
|
|
480
544
|
${t('commands.status.session_title')}
|
|
481
545
|
${t('commands.status.provider')} ${ctx.providerId}
|
|
482
546
|
${t('commands.status.model')} ${ctx.modelId}
|
|
483
|
-
${t('commands.status.messages')} ${c.
|
|
547
|
+
${t('commands.status.messages')} ${c.getMessageCount()}
|
|
484
548
|
${t('commands.status.tokens')} ~${c.getEstimatedTokens().toLocaleString()} / ${c.getMaxTokens().toLocaleString()}
|
|
485
549
|
${t('commands.status.tools')} ${tools.size} ${t('commands.status.loaded')}
|
|
486
550
|
${t('commands.status.permission')} ${liveMode(ctx)}
|
|
@@ -548,7 +612,7 @@ const modelsCmd: CommandHandler = (ctx) => {
|
|
|
548
612
|
}
|
|
549
613
|
}
|
|
550
614
|
|
|
551
|
-
const ollamaRefreshCmd: CommandHandler = (ctx) => {
|
|
615
|
+
const ollamaRefreshCmd: CommandHandler = async (ctx) => {
|
|
552
616
|
const t = resolveT(ctx)
|
|
553
617
|
const ollamaProvider = ctx.config.providers.find((p) => p.id === 'ollama')
|
|
554
618
|
if (!ollamaProvider) {
|
|
@@ -583,24 +647,60 @@ const ollamaRefreshCmd: CommandHandler = (ctx) => {
|
|
|
583
647
|
}
|
|
584
648
|
}
|
|
585
649
|
|
|
586
|
-
// 3.
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
650
|
+
// 3. Ask Ollama for each model's real context length. A hardcoded 128k made
|
|
651
|
+
// an 8k model look like 128k to /context and the compaction threshold.
|
|
652
|
+
const base = (ollamaProvider.baseUrl || 'http://localhost:11434').replace(/\/$/, '')
|
|
653
|
+
let assumed = 0
|
|
654
|
+
const models = await Promise.all(
|
|
655
|
+
refreshed.map(async (m) => {
|
|
656
|
+
let contextWindow = 0
|
|
657
|
+
try {
|
|
658
|
+
const res = await fetch(`${base}/api/show`, {
|
|
659
|
+
method: 'POST',
|
|
660
|
+
headers: { 'content-type': 'application/json' },
|
|
661
|
+
body: JSON.stringify({ name: m.id }),
|
|
662
|
+
signal: AbortSignal.timeout(1500),
|
|
663
|
+
})
|
|
664
|
+
if (res.ok) {
|
|
665
|
+
const info = (await res.json()) as { model_info?: Record<string, unknown> }
|
|
666
|
+
const key = Object.keys(info.model_info ?? {}).find((k) =>
|
|
667
|
+
k.endsWith('.context_length'),
|
|
668
|
+
)
|
|
669
|
+
const value = key ? Number(info.model_info![key]) : NaN
|
|
670
|
+
if (Number.isFinite(value) && value > 0) contextWindow = value
|
|
671
|
+
}
|
|
672
|
+
} catch {
|
|
673
|
+
// Ollama unreachable / old version — the note below records the assumption.
|
|
674
|
+
}
|
|
675
|
+
if (!contextWindow) {
|
|
676
|
+
contextWindow = 128_000
|
|
677
|
+
assumed++
|
|
678
|
+
}
|
|
679
|
+
return {
|
|
680
|
+
id: m.id,
|
|
681
|
+
name: m.id,
|
|
682
|
+
providerId: 'ollama',
|
|
683
|
+
contextWindow,
|
|
684
|
+
maxOutput: Math.min(32_000, contextWindow),
|
|
685
|
+
vision: false,
|
|
686
|
+
status: 'active' as const,
|
|
687
|
+
}
|
|
688
|
+
}),
|
|
689
|
+
)
|
|
690
|
+
ollamaProvider.models = models
|
|
596
691
|
|
|
597
692
|
const after = refreshed.length
|
|
598
693
|
const added = after - before
|
|
694
|
+
const note =
|
|
695
|
+
assumed > 0
|
|
696
|
+
? `\n\n⚠ ${assumed} model(s): context window assumed 128k (Ollama /api/show did not answer).`
|
|
697
|
+
: ''
|
|
599
698
|
return {
|
|
600
|
-
content:
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
699
|
+
content:
|
|
700
|
+
t('commands.ollama_refresh.done', {
|
|
701
|
+
total: String(after),
|
|
702
|
+
added: added > 0 ? `+${added}` : String(added),
|
|
703
|
+
}) + note,
|
|
604
704
|
}
|
|
605
705
|
} catch (err: unknown) {
|
|
606
706
|
const msg = err instanceof Error ? err.message : String(err)
|
|
@@ -693,7 +793,7 @@ const configCmd: CommandHandler = (ctx) => {
|
|
|
693
793
|
`version: ${c.version}`,
|
|
694
794
|
`defaultProvider: ${c.defaultProvider}`,
|
|
695
795
|
`defaultModel: ${c.defaultModel}`,
|
|
696
|
-
`permission: ${c.permission}`,
|
|
796
|
+
`permission: ${c.permission} (configured) — live: ${liveMode(ctx)}`,
|
|
697
797
|
`showThinking: ${c.showThinking ?? 'off'}`,
|
|
698
798
|
`showSchedulingNotices: ${c.showSchedulingNotices ?? false}`,
|
|
699
799
|
`showCommandPicker: ${c.showCommandPicker ?? false}`,
|
|
@@ -714,21 +814,18 @@ const configCmd: CommandHandler = (ctx) => {
|
|
|
714
814
|
const toolsCmd: CommandHandler = (ctx) => {
|
|
715
815
|
const t = resolveT(ctx)
|
|
716
816
|
const tools = ctx.engine.getTools()
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
network: [],
|
|
722
|
-
system: [],
|
|
723
|
-
}
|
|
817
|
+
// Group by whatever categories the registry actually declares. A fixed key
|
|
818
|
+
// list silently dropped every tool whose category was added later (artifact,
|
|
819
|
+
// scheduling), while the header still printed `tools.size`.
|
|
820
|
+
const categories = new Map<string, string[]>()
|
|
724
821
|
for (const [name, tool] of tools) {
|
|
725
|
-
categories
|
|
726
|
-
|
|
727
|
-
)
|
|
822
|
+
const items = categories.get(tool.category) ?? []
|
|
823
|
+
items.push(` ${name.padEnd(14)} ${tool.permission.padEnd(8)} ${tool.description}`)
|
|
824
|
+
categories.set(tool.category, items)
|
|
728
825
|
}
|
|
729
|
-
const sections =
|
|
730
|
-
|
|
731
|
-
|
|
826
|
+
const sections = [...categories.entries()].map(
|
|
827
|
+
([cat, items]) => `── ${cat.toUpperCase()} ──\n${items.join('\n')}`,
|
|
828
|
+
)
|
|
732
829
|
|
|
733
830
|
return {
|
|
734
831
|
content: `${t('commands.tools.title', { count: String(tools.size) })}\n\n${sections.join('\n\n')}`,
|
|
@@ -789,9 +886,17 @@ const crsiDisableCmd: CommandHandler = (ctx, args) => {
|
|
|
789
886
|
if (!ruleId) {
|
|
790
887
|
return { content: 'Usage: /crsi disable <rule-id>' }
|
|
791
888
|
}
|
|
792
|
-
engine.
|
|
889
|
+
const source = engine.getRule(ruleId)?.source
|
|
890
|
+
if (!engine.setRuleEnabled(ruleId, false)) {
|
|
891
|
+
return { content: `Rule \`${ruleId}\` not found. Use \`/crsi rules\` to see rule ids.` }
|
|
892
|
+
}
|
|
893
|
+
// Builtin/managed rules are source-of-truth and never written to the store.
|
|
894
|
+
const note =
|
|
895
|
+
source === 'builtin' || source === 'managed'
|
|
896
|
+
? '\n\nThis is a builtin/managed rule: the change is not persisted and reverts on restart.'
|
|
897
|
+
: ''
|
|
793
898
|
return {
|
|
794
|
-
content: `Rule \`${ruleId}\` has been disabled. Use \`/crsi restore ${ruleId}\` to re-enable
|
|
899
|
+
content: `Rule \`${ruleId}\` has been disabled. Use \`/crsi restore ${ruleId}\` to re-enable.${note}`,
|
|
795
900
|
}
|
|
796
901
|
}
|
|
797
902
|
|
|
@@ -837,8 +942,15 @@ const crsiRestoreCmd: CommandHandler = (ctx, args) => {
|
|
|
837
942
|
if (!ruleId) {
|
|
838
943
|
return { content: 'Usage: /crsi restore <rule-id>' }
|
|
839
944
|
}
|
|
840
|
-
engine.
|
|
841
|
-
|
|
945
|
+
const source = engine.getRule(ruleId)?.source
|
|
946
|
+
if (!engine.setRuleEnabled(ruleId, true)) {
|
|
947
|
+
return { content: `Rule \`${ruleId}\` not found. Use \`/crsi rules\` to see rule ids.` }
|
|
948
|
+
}
|
|
949
|
+
const note =
|
|
950
|
+
source === 'builtin' || source === 'managed'
|
|
951
|
+
? '\n\nThis is a builtin/managed rule: the change is not persisted and reverts on restart.'
|
|
952
|
+
: ''
|
|
953
|
+
return { content: `Rule \`${ruleId}\` has been re-enabled.${note}` }
|
|
842
954
|
}
|
|
843
955
|
|
|
844
956
|
/** Render a tiny ASCII sparkline from a series of 0-1 values (success rates). */
|
|
@@ -861,6 +973,7 @@ const crsiStatsCmd: CommandHandler = async (ctx) => {
|
|
|
861
973
|
lines.push(`Builtin: ${rules.filter((r) => r.source === 'builtin').length}`)
|
|
862
974
|
lines.push(`Auto-generated: ${rules.filter((r) => r.source === 'pattern-analyzer').length}`)
|
|
863
975
|
lines.push(`Manual: ${rules.filter((r) => r.source === 'manual').length}`)
|
|
976
|
+
lines.push(`Managed: ${rules.filter((r) => r.source === 'managed').length}`)
|
|
864
977
|
|
|
865
978
|
const effs = tracker?.allRules ?? []
|
|
866
979
|
if (effs.length > 0) {
|
|
@@ -1012,10 +1125,13 @@ const crsiModifyCmd: CommandHandler = async (ctx, args) => {
|
|
|
1012
1125
|
const sign = report.deltaMean >= 0 ? '+' : ''
|
|
1013
1126
|
// B2 代价维:只展示、不进判定(`formatCostLine` 缺席时返回 null ⇒ 整行不打)。
|
|
1014
1127
|
const costLine = formatCostLine(report)
|
|
1128
|
+
// 空模型闸:只在闸失败时出声;它解释了 verdict 为什么被降级。
|
|
1129
|
+
const nullLine = formatNullModelLine(report)
|
|
1015
1130
|
improvementLine =
|
|
1016
1131
|
`\n📊 改进判定: ${label} (delta ${sign}${report.deltaMean.toFixed(1)}, 噪声 ${report.noise.toFixed(1)}, 阈值 ${report.minEffect.toFixed(1)})` +
|
|
1017
1132
|
`\n 改进率: ${rate.improved}/${rate.total} (${(rate.rate * 100).toFixed(0)}%, Wilson 95% [${(rate.lo * 100).toFixed(0)}%, ${(rate.hi * 100).toFixed(0)}%])` +
|
|
1018
1133
|
(costLine ? `\n${costLine}` : '') +
|
|
1134
|
+
(nullLine ? `\n${nullLine}` : '') +
|
|
1019
1135
|
(report.verdict === 'regressed' ? '\n ⚠️ 任务表现倒退:--approve 将被拒绝。' : '')
|
|
1020
1136
|
}
|
|
1021
1137
|
} catch {
|
|
@@ -1133,6 +1249,9 @@ const crsiProposeCmd: CommandHandler = async (ctx, args) => {
|
|
|
1133
1249
|
// 「局部正确全局遗漏」)。ε 行可以有、代价行可以没有,故各自独立追加。
|
|
1134
1250
|
const costLine = formatCostLine(report)
|
|
1135
1251
|
if (costLine) predictionLine += `\n${costLine}`
|
|
1252
|
+
// 空模型闸同理:两条渲染路径都接。
|
|
1253
|
+
const nullLine = formatNullModelLine(report)
|
|
1254
|
+
if (nullLine) predictionLine += `\n${nullLine}`
|
|
1136
1255
|
}
|
|
1137
1256
|
} catch {
|
|
1138
1257
|
// 测量失败(LLM 不可用等)不阻断提案流程 —— 与手工路径 :889 的处置一致。
|
|
@@ -1439,19 +1558,28 @@ const crsiHealthCmd: CommandHandler = async (ctx) => {
|
|
|
1439
1558
|
|
|
1440
1559
|
// ── CRSI Section ──
|
|
1441
1560
|
lines.push('### 🧠 CRSI 学习子系统', '')
|
|
1561
|
+
// Hoisted for the composite score below — the score must be built from the
|
|
1562
|
+
// same readings the table shows, not re-derived from object presence.
|
|
1563
|
+
let activeRuleCount = 0
|
|
1564
|
+
let interceptions = 0
|
|
1565
|
+
let successes = 0
|
|
1566
|
+
let hasTracker = false
|
|
1442
1567
|
if (engine) {
|
|
1443
1568
|
const rules = engine.getActiveRules()
|
|
1569
|
+
activeRuleCount = rules.length
|
|
1444
1570
|
const builtin = rules.filter((r) => r.source === 'builtin').length
|
|
1445
1571
|
const auto = rules.filter((r) => r.source === 'pattern-analyzer').length
|
|
1446
1572
|
const manual = rules.filter((r) => r.source === 'manual').length
|
|
1573
|
+
const managed = rules.filter((r) => r.source === 'managed').length
|
|
1447
1574
|
|
|
1448
1575
|
lines.push(`| 指标 | 值 |`)
|
|
1449
1576
|
lines.push(`|------|----|`)
|
|
1450
|
-
lines.push(
|
|
1577
|
+
lines.push(
|
|
1578
|
+
`| 活跃规则 | ${rules.length} (内置 ${builtin} · 自动 ${auto} · 手动 ${manual} · 受管 ${managed}) |`,
|
|
1579
|
+
)
|
|
1451
1580
|
|
|
1452
1581
|
if (tracker) {
|
|
1453
|
-
|
|
1454
|
-
let successes = 0
|
|
1582
|
+
hasTracker = true
|
|
1455
1583
|
for (const r of rules) {
|
|
1456
1584
|
const eff = tracker.getEffectiveness(r.id)
|
|
1457
1585
|
if (eff) {
|
|
@@ -1496,9 +1624,47 @@ const crsiHealthCmd: CommandHandler = async (ctx) => {
|
|
|
1496
1624
|
}
|
|
1497
1625
|
|
|
1498
1626
|
// ── Overall Health Score ──
|
|
1627
|
+
//
|
|
1628
|
+
// Scored from **evidence**, not presence. The previous reading was
|
|
1629
|
+
// `engine ? 50 : 0` — a freshly constructed rule engine that had learned
|
|
1630
|
+
// nothing scored full marks, which made "A — 优秀" reachable by doing no
|
|
1631
|
+
// work at all. Each half is 25 points for having data + 25 for its quality
|
|
1632
|
+
// signal, and the basis is printed so the number can be audited.
|
|
1499
1633
|
lines.push('', '### 📊 综合健康评分', '')
|
|
1500
|
-
|
|
1501
|
-
const
|
|
1634
|
+
|
|
1635
|
+
const crsiBasis: string[] = []
|
|
1636
|
+
let crsiScore = 0
|
|
1637
|
+
if (activeRuleCount > 0) {
|
|
1638
|
+
crsiScore += 25
|
|
1639
|
+
crsiBasis.push(`活跃规则 ${activeRuleCount} 条 +25`)
|
|
1640
|
+
} else {
|
|
1641
|
+
crsiBasis.push('无活跃规则 +0')
|
|
1642
|
+
}
|
|
1643
|
+
if (interceptions > 0) {
|
|
1644
|
+
const pts = Math.round((successes / interceptions) * 25)
|
|
1645
|
+
crsiScore += pts
|
|
1646
|
+
crsiBasis.push(`拦截成功 ${successes}/${interceptions} +${pts}`)
|
|
1647
|
+
} else {
|
|
1648
|
+
crsiBasis.push(hasTracker ? '尚无拦截记录 +0' : '无 EffectivenessTracker +0')
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
const sisBasis: string[] = []
|
|
1652
|
+
let sisScore = 0
|
|
1653
|
+
if (db) {
|
|
1654
|
+
const stats = db.getStats()
|
|
1655
|
+
if (stats.total > 0) {
|
|
1656
|
+
sisScore += 25
|
|
1657
|
+
sisBasis.push(`免疫记忆 ${stats.total} 条 +25`)
|
|
1658
|
+
const pts = Math.round(stats.avgSuccessRate * 25)
|
|
1659
|
+
sisScore += pts
|
|
1660
|
+
sisBasis.push(`平均成功率 ${Math.round(stats.avgSuccessRate * 100)}% +${pts}`)
|
|
1661
|
+
} else {
|
|
1662
|
+
sisBasis.push('免疫记忆为空 +0', '无成功率数据 +0')
|
|
1663
|
+
}
|
|
1664
|
+
} else {
|
|
1665
|
+
sisBasis.push('SIS 未初始化 +0')
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1502
1668
|
const totalScore = crsiScore + sisScore
|
|
1503
1669
|
|
|
1504
1670
|
const grade =
|
|
@@ -1515,6 +1681,8 @@ const crsiHealthCmd: CommandHandler = async (ctx) => {
|
|
|
1515
1681
|
lines.push(`| CRSI 学习 | ${engine ? '✅ 在线' : '❌ 离线'} | ${crsiScore}/50 |`)
|
|
1516
1682
|
lines.push(`| SIS 免疫 | ${db ? '✅ 在线' : '❌ 离线'} | ${sisScore}/50 |`)
|
|
1517
1683
|
lines.push(`| **综合** | **${grade}** | **${totalScore}/100** |`)
|
|
1684
|
+
lines.push('')
|
|
1685
|
+
lines.push(`计分依据:CRSI ${crsiBasis.join(' · ')};SIS ${sisBasis.join(' · ')}`)
|
|
1518
1686
|
|
|
1519
1687
|
return { content: lines.join('\n') }
|
|
1520
1688
|
}
|
|
@@ -1585,7 +1753,7 @@ const crsiMetaCmd: CommandHandler = async (ctx) => {
|
|
|
1585
1753
|
lines.push(`- \`${mr.id}\`: ${mr.recommendation}`)
|
|
1586
1754
|
}
|
|
1587
1755
|
lines.push('')
|
|
1588
|
-
lines.push('
|
|
1756
|
+
lines.push('元规则只是建议:当前版本不自动应用,请人工复核后固化。')
|
|
1589
1757
|
}
|
|
1590
1758
|
|
|
1591
1759
|
return { content: lines.join('\n') }
|
|
@@ -2429,6 +2597,14 @@ const renameCmd: CommandHandler = (ctx, args) => {
|
|
|
2429
2597
|
}
|
|
2430
2598
|
|
|
2431
2599
|
const goalCmd: CommandHandler = (ctx, args) => {
|
|
2600
|
+
if (ctx.engine.isRemote) {
|
|
2601
|
+
return {
|
|
2602
|
+
content: attachedRefusal(
|
|
2603
|
+
'use /goal here',
|
|
2604
|
+
'Goals are owned by the daemon session; setting one here would report success without taking effect.',
|
|
2605
|
+
),
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2432
2608
|
const t = resolveT(ctx)
|
|
2433
2609
|
const input = args.join(' ')
|
|
2434
2610
|
|
|
@@ -2517,9 +2693,10 @@ const recapCmd: CommandHandler = (ctx) => {
|
|
|
2517
2693
|
const tokens = c.getEstimatedTokens()
|
|
2518
2694
|
const checkpointCount = c.getCheckpoints().length
|
|
2519
2695
|
|
|
2696
|
+
// The label says "recent": take the tail, not the first lines of the session.
|
|
2520
2697
|
const topics = msgs
|
|
2521
2698
|
.filter((m) => m.role === 'user' && typeof m.content === 'string')
|
|
2522
|
-
.slice(
|
|
2699
|
+
.slice(-5)
|
|
2523
2700
|
.map((m) => {
|
|
2524
2701
|
const text = typeof m.content === 'string' ? m.content : ''
|
|
2525
2702
|
return text.length > 80 ? text.slice(0, 80) + '...' : text
|
|
@@ -2541,6 +2718,14 @@ const recapCmd: CommandHandler = (ctx) => {
|
|
|
2541
2718
|
}
|
|
2542
2719
|
|
|
2543
2720
|
const usageCmd: CommandHandler = (ctx) => {
|
|
2721
|
+
if (ctx.engine.isRemote) {
|
|
2722
|
+
return {
|
|
2723
|
+
content: attachedRefusal(
|
|
2724
|
+
'show per-tool usage here',
|
|
2725
|
+
'Tool-level token accounting lives in the daemon session.',
|
|
2726
|
+
),
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2544
2729
|
const t = resolveT(ctx)
|
|
2545
2730
|
const c = ctx.engine.getContext()
|
|
2546
2731
|
const estTokens = c.getEstimatedTokens()
|
|
@@ -2963,6 +3148,14 @@ const pluginDisableCmd: CommandHandler = (ctx, args) => {
|
|
|
2963
3148
|
// ═══════════════════════════════════════════════════════════════
|
|
2964
3149
|
|
|
2965
3150
|
const rewindCmd: CommandHandler = (ctx) => {
|
|
3151
|
+
if (ctx.engine.isRemote) {
|
|
3152
|
+
return {
|
|
3153
|
+
content: attachedRefusal(
|
|
3154
|
+
'rewind here',
|
|
3155
|
+
'Checkpoints are restored in the daemon session, not in this terminal.',
|
|
3156
|
+
),
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
2966
3159
|
const t = resolveT(ctx)
|
|
2967
3160
|
const c = ctx.engine.getContext()
|
|
2968
3161
|
const checkpoints = c.getCheckpoints()
|
|
@@ -3037,23 +3230,66 @@ const copyCmd: CommandHandler = (ctx, args) => {
|
|
|
3037
3230
|
}
|
|
3038
3231
|
}
|
|
3039
3232
|
|
|
3233
|
+
/**
|
|
3234
|
+
* Tracked changes **including staged ones**, plus untracked files.
|
|
3235
|
+
*
|
|
3236
|
+
* `git diff --stat` compares the worktree to the index, so `git add` made every
|
|
3237
|
+
* change invisible — `/review`, `/code-review`, `/simplify`, `/verify` and
|
|
3238
|
+
* `/diff` all reported "no changes" on a fully staged tree. `HEAD` as the base
|
|
3239
|
+
* folds index and worktree into one view; untracked files need `ls-files`
|
|
3240
|
+
* because no `git diff` sees them.
|
|
3241
|
+
*/
|
|
3242
|
+
async function readGitChangeSummary(): Promise<{ stat: string; untracked: string[] }> {
|
|
3243
|
+
const { execSync } = await import('node:child_process')
|
|
3244
|
+
let stat = ''
|
|
3245
|
+
try {
|
|
3246
|
+
stat = execSync('git diff --stat HEAD', { encoding: 'utf-8', timeout: 5000 }).trim()
|
|
3247
|
+
} catch {
|
|
3248
|
+
// No HEAD yet (fresh repository) — fall back to the index/worktree diff.
|
|
3249
|
+
stat = execSync('git diff --stat', { encoding: 'utf-8', timeout: 5000 }).trim()
|
|
3250
|
+
}
|
|
3251
|
+
let untracked: string[] = []
|
|
3252
|
+
try {
|
|
3253
|
+
untracked = execSync('git ls-files --others --exclude-standard', {
|
|
3254
|
+
encoding: 'utf-8',
|
|
3255
|
+
timeout: 5000,
|
|
3256
|
+
})
|
|
3257
|
+
.split('\n')
|
|
3258
|
+
.filter(Boolean)
|
|
3259
|
+
} catch {
|
|
3260
|
+
// Not a repository / git unavailable — the stat call above already decided
|
|
3261
|
+
// whether there is anything to report.
|
|
3262
|
+
}
|
|
3263
|
+
return { stat, untracked }
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3040
3266
|
const diffCmd: CommandHandler = async (_ctx) => {
|
|
3041
3267
|
const t = resolveT(_ctx)
|
|
3042
3268
|
try {
|
|
3043
3269
|
const { execSync } = await import('node:child_process')
|
|
3044
|
-
const
|
|
3045
|
-
if (!
|
|
3270
|
+
const { stat, untracked } = await readGitChangeSummary()
|
|
3271
|
+
if (!stat && untracked.length === 0) {
|
|
3046
3272
|
return { content: t('commands.diff.clean') }
|
|
3047
3273
|
}
|
|
3048
|
-
//
|
|
3049
|
-
|
|
3274
|
+
// Full diff (staged + unstaged) limited to a readable size; untracked files
|
|
3275
|
+
// have no diff to print, so they are listed.
|
|
3276
|
+
let fullDiff = ''
|
|
3277
|
+
try {
|
|
3278
|
+
fullDiff = execSync('git diff --no-color HEAD', { encoding: 'utf-8', timeout: 5000 })
|
|
3279
|
+
} catch {
|
|
3280
|
+
fullDiff = execSync('git diff --no-color', { encoding: 'utf-8', timeout: 5000 })
|
|
3281
|
+
}
|
|
3050
3282
|
const MAX_LINES = 60
|
|
3051
3283
|
const lines = fullDiff.split('\n')
|
|
3052
|
-
|
|
3284
|
+
let truncated =
|
|
3053
3285
|
lines.length > MAX_LINES
|
|
3054
3286
|
? lines.slice(0, MAX_LINES).join('\n') +
|
|
3055
3287
|
`\n\n... (${lines.length - MAX_LINES} more lines. Use git diff to see full output.)`
|
|
3056
3288
|
: fullDiff
|
|
3289
|
+
if (truncated.trim()) truncated += '\n\n'
|
|
3290
|
+
if (untracked.length > 0) {
|
|
3291
|
+
truncated += `Untracked files:\n${untracked.map((f) => ` ${f}`).join('\n')}`
|
|
3292
|
+
}
|
|
3057
3293
|
|
|
3058
3294
|
return {
|
|
3059
3295
|
content: `${t('commands.diff.title')}\n\n${truncated}`,
|
|
@@ -3070,6 +3306,14 @@ const diffCmd: CommandHandler = async (_ctx) => {
|
|
|
3070
3306
|
// ═══════════════════════════════════════════════════════════════
|
|
3071
3307
|
|
|
3072
3308
|
const effortCmd: CommandHandler = (ctx, args) => {
|
|
3309
|
+
if (ctx.engine.isRemote) {
|
|
3310
|
+
return {
|
|
3311
|
+
content: attachedRefusal(
|
|
3312
|
+
'change effort here',
|
|
3313
|
+
"The daemon chooses the attached session's reasoning effort.",
|
|
3314
|
+
),
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3073
3317
|
const t = resolveT(ctx)
|
|
3074
3318
|
const VALID_LEVELS = ['low', 'medium', 'high', 'xhigh', 'max']
|
|
3075
3319
|
const level = args[0]?.toLowerCase()
|
|
@@ -3084,8 +3328,13 @@ const effortCmd: CommandHandler = (ctx, args) => {
|
|
|
3084
3328
|
|
|
3085
3329
|
const focusCmd: CommandHandler = (ctx) => {
|
|
3086
3330
|
const t = resolveT(ctx)
|
|
3087
|
-
|
|
3088
|
-
|
|
3331
|
+
// Toggle from the live state. It used to set `true` unconditionally while
|
|
3332
|
+
// app.tsx intercepted the command — the handler was unreachable, so the bug
|
|
3333
|
+
// was invisible; once the interception is gone it would have made /focus
|
|
3334
|
+
// impossible to turn off.
|
|
3335
|
+
const next = !(ctx.getFocusMode?.() ?? false)
|
|
3336
|
+
ctx.setFocusMode(next)
|
|
3337
|
+
return { content: t(next ? 'commands.focus.on' : 'commands.focus.off') }
|
|
3089
3338
|
}
|
|
3090
3339
|
|
|
3091
3340
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -3093,6 +3342,14 @@ const focusCmd: CommandHandler = (ctx) => {
|
|
|
3093
3342
|
// ═══════════════════════════════════════════════════════════════
|
|
3094
3343
|
|
|
3095
3344
|
const ultracodeCmd: CommandHandler = (ctx, args) => {
|
|
3345
|
+
if (ctx.engine.isRemote) {
|
|
3346
|
+
return {
|
|
3347
|
+
content: attachedRefusal(
|
|
3348
|
+
'toggle ultracode here',
|
|
3349
|
+
'The daemon owns the attached session and its system prompt.',
|
|
3350
|
+
),
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3096
3353
|
const t = resolveT(ctx)
|
|
3097
3354
|
const arg = args[0]?.toLowerCase()
|
|
3098
3355
|
if (arg === 'on') {
|
|
@@ -3344,8 +3601,8 @@ const loopCmd: CommandHandler = async (ctx, args) => {
|
|
|
3344
3601
|
or: /loop status Show autonomous loop progress
|
|
3345
3602
|
or: /loop init [path] Scaffold project vault structure
|
|
3346
3603
|
|
|
3347
|
-
Fixed interval formats:
|
|
3348
|
-
|
|
3604
|
+
Fixed interval formats (60s minimum, 1h maximum):
|
|
3605
|
+
60s — 1 minute
|
|
3349
3606
|
5m — 5 minutes
|
|
3350
3607
|
1h — 1 hour
|
|
3351
3608
|
|
|
@@ -3390,16 +3647,34 @@ const loopCmd: CommandHandler = async (ctx, args) => {
|
|
|
3390
3647
|
}
|
|
3391
3648
|
}
|
|
3392
3649
|
return {
|
|
3393
|
-
content: `── Invalid Interval ──\n\n"${interval}" is not a recognised interval.\n\nUse formats like:
|
|
3650
|
+
content: `── Invalid Interval ──\n\n"${interval}" is not a recognised interval.\n\nUse formats like: 60s, 5m, 1h, 30min\nOr use /loop auto <prompt> for autonomous mode.`,
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3654
|
+
// The scheduler accepts 60–3600s. Reject here so the user gets the range
|
|
3655
|
+
// instead of "Loop failed: delaySeconds must be in [60, 3600]".
|
|
3656
|
+
if (seconds < 60 || seconds > 3600) {
|
|
3657
|
+
return {
|
|
3658
|
+
content:
|
|
3659
|
+
`── Interval Out of Range ──\n\n"${interval}" is ${seconds}s; the scheduler accepts ` +
|
|
3660
|
+
'60–3600 seconds (1 minute to 1 hour).\n\nUse 60s, 5m, or 1h.',
|
|
3394
3661
|
}
|
|
3395
3662
|
}
|
|
3396
3663
|
|
|
3397
3664
|
// Fixed-interval loop — directly invoke ScheduleWakeup
|
|
3398
3665
|
try {
|
|
3399
3666
|
const { scheduleWakeupTool } = await import('../tools/scheduling/schedule-wakeup.js')
|
|
3667
|
+
// The interval loop must re-arm itself after each fire; nothing in the
|
|
3668
|
+
// scheduler repeats a fixed interval on its own.
|
|
3669
|
+
const scheduledPrompt =
|
|
3670
|
+
`${prompt}\n\n[Repeating every ${seconds}s — after handling this prompt, call ` +
|
|
3671
|
+
`ScheduleWakeup again with delaySeconds: ${seconds} and this same prompt to keep the ` +
|
|
3672
|
+
`loop going. Stop when the task is complete.]`
|
|
3400
3673
|
const result = await scheduleWakeupTool.execute(
|
|
3401
|
-
{ delaySeconds: seconds, reason: `Loop: ${prompt.slice(0, 40)}`, prompt },
|
|
3402
|
-
|
|
3674
|
+
{ delaySeconds: seconds, reason: `Loop: ${prompt.slice(0, 40)}`, prompt: scheduledPrompt },
|
|
3675
|
+
// Session-keyed, same as the engine's handler: a hardcoded id fires into
|
|
3676
|
+
// nobody and the loop silently never runs.
|
|
3677
|
+
{ cwd: process.cwd(), sessionId: ctx.sessionId, provider: '', model: '' },
|
|
3403
3678
|
)
|
|
3404
3679
|
if (!result.success) {
|
|
3405
3680
|
return { content: `Loop failed: ${result.error || 'unknown error'}` }
|
|
@@ -3451,13 +3726,11 @@ const doctorCmd: CommandHandler = async (ctx) => {
|
|
|
3451
3726
|
]
|
|
3452
3727
|
|
|
3453
3728
|
const c = ctx.engine.getContext()
|
|
3454
|
-
const msgs = c.getMessages()
|
|
3455
3729
|
const tokens = c.getEstimatedTokens()
|
|
3456
3730
|
const maxTokens = c.getMaxTokens()
|
|
3457
|
-
|
|
3458
|
-
lines.push(
|
|
3459
|
-
|
|
3460
|
-
)
|
|
3731
|
+
const pct = maxTokens > 0 ? `${((tokens / maxTokens) * 100).toFixed(1)}%` : '—'
|
|
3732
|
+
lines.push(`Messages ${c.getMessageCount()}`)
|
|
3733
|
+
lines.push(`Tokens ~${tokens.toLocaleString()} / ${maxTokens.toLocaleString()} (${pct})`)
|
|
3461
3734
|
lines.push(`Checkpoints ${c.getCheckpoints().length}`)
|
|
3462
3735
|
|
|
3463
3736
|
// Git info
|
|
@@ -3796,9 +4069,8 @@ function gitDiffBridgeCmd(opts: {
|
|
|
3796
4069
|
return async (ctx, args) => {
|
|
3797
4070
|
const t = resolveT(ctx)
|
|
3798
4071
|
try {
|
|
3799
|
-
const {
|
|
3800
|
-
|
|
3801
|
-
if (!diff) {
|
|
4072
|
+
const { stat, untracked } = await readGitChangeSummary()
|
|
4073
|
+
if (!stat && untracked.length === 0) {
|
|
3802
4074
|
return { content: `─ ${opts.label} ─\n\n${t(opts.noChangesKey)}` }
|
|
3803
4075
|
}
|
|
3804
4076
|
const forwarded =
|
|
@@ -3806,8 +4078,12 @@ function gitDiffBridgeCmd(opts: {
|
|
|
3806
4078
|
if (typeof forwarded === 'object') {
|
|
3807
4079
|
return { content: `─ ${opts.label} ─\n\n${forwarded.error}` }
|
|
3808
4080
|
}
|
|
4081
|
+
const untrackedBlock =
|
|
4082
|
+
untracked.length > 0
|
|
4083
|
+
? `\n\nUntracked files:\n${untracked.map((f) => ` ${f}`).join('\n')}`
|
|
4084
|
+
: ''
|
|
3809
4085
|
return {
|
|
3810
|
-
content: `─ ${opts.label} ─\n\n${t(opts.runningKey)}\n\nChanged files:\n${
|
|
4086
|
+
content: `─ ${opts.label} ─\n\n${t(opts.runningKey)}\n\nChanged files:\n${stat}${untrackedBlock}`,
|
|
3811
4087
|
forwardToAI: forwarded,
|
|
3812
4088
|
}
|
|
3813
4089
|
} catch {
|
|
@@ -3998,6 +4274,7 @@ const statsCmd: CommandHandler = (ctx) => {
|
|
|
3998
4274
|
const c = ctx.engine.getContext()
|
|
3999
4275
|
const msgs = c.getMessages()
|
|
4000
4276
|
const tokens = c.getEstimatedTokens()
|
|
4277
|
+
const maxTokens = c.getMaxTokens()
|
|
4001
4278
|
const tools = ctx.engine.getTools()
|
|
4002
4279
|
|
|
4003
4280
|
const userMsgs = msgs.filter((m) => m.role === 'user').length
|
|
@@ -4015,14 +4292,16 @@ const statsCmd: CommandHandler = (ctx) => {
|
|
|
4015
4292
|
}),
|
|
4016
4293
|
t('commands.stats.tokens', {
|
|
4017
4294
|
tokens: tokens.toLocaleString(),
|
|
4018
|
-
max:
|
|
4295
|
+
max: maxTokens.toLocaleString(),
|
|
4019
4296
|
}),
|
|
4020
4297
|
t('commands.stats.tools', { count: String(tools.size) }),
|
|
4021
4298
|
t('commands.stats.provider', { provider: ctx.providerId }),
|
|
4022
4299
|
t('commands.stats.model', { model: ctx.modelId }),
|
|
4023
4300
|
t('commands.stats.permission', { permission: liveMode(ctx) }),
|
|
4024
4301
|
'',
|
|
4025
|
-
t('commands.stats.usage', {
|
|
4302
|
+
t('commands.stats.usage', {
|
|
4303
|
+
pct: maxTokens > 0 ? ((tokens / maxTokens) * 100).toFixed(1) : '—',
|
|
4304
|
+
}),
|
|
4026
4305
|
]
|
|
4027
4306
|
|
|
4028
4307
|
// ── CRSI & SIS extensions ──
|
|
@@ -4081,9 +4360,10 @@ const summaryCmd: CommandHandler = (ctx) => {
|
|
|
4081
4360
|
return { content: t('commands.summary.no_conversation') }
|
|
4082
4361
|
}
|
|
4083
4362
|
|
|
4363
|
+
// "recent topics" means the latest five user messages, not the earliest.
|
|
4084
4364
|
const userMsgs = msgs
|
|
4085
4365
|
.filter((m) => m.role === 'user' && typeof m.content === 'string')
|
|
4086
|
-
.slice(
|
|
4366
|
+
.slice(-5)
|
|
4087
4367
|
.map((m) => {
|
|
4088
4368
|
const text = typeof m.content === 'string' ? m.content : ''
|
|
4089
4369
|
return text.length > 100 ? text.slice(0, 100) + '...' : text
|
|
@@ -4207,7 +4487,7 @@ const cdCmd: CommandHandler = async (ctx, args) => {
|
|
|
4207
4487
|
}
|
|
4208
4488
|
}
|
|
4209
4489
|
|
|
4210
|
-
const
|
|
4490
|
+
const hooksListCmd: CommandHandler = async (ctx) => {
|
|
4211
4491
|
const t = resolveT(ctx)
|
|
4212
4492
|
const { loadSettingsJson } = await import('../config/loader')
|
|
4213
4493
|
const cwd = process.cwd()
|
|
@@ -4459,6 +4739,12 @@ const reviewCmd = codeReviewCmd
|
|
|
4459
4739
|
// PR Comments
|
|
4460
4740
|
// ═══════════════════════════════════════════════════════════════
|
|
4461
4741
|
|
|
4742
|
+
function snippetForReview(body: string | undefined): string {
|
|
4743
|
+
const oneLine = (body ?? '').replace(/\s+/g, ' ').trim()
|
|
4744
|
+
if (!oneLine) return '(empty)'
|
|
4745
|
+
return oneLine.length > 200 ? `${oneLine.slice(0, 200)}…` : oneLine
|
|
4746
|
+
}
|
|
4747
|
+
|
|
4462
4748
|
const prCommentsCmd: CommandHandler = async () => {
|
|
4463
4749
|
try {
|
|
4464
4750
|
const { execSync } = await import('node:child_process')
|
|
@@ -4508,9 +4794,52 @@ const prCommentsCmd: CommandHandler = async () => {
|
|
|
4508
4794
|
lines.push('')
|
|
4509
4795
|
}
|
|
4510
4796
|
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
)
|
|
4797
|
+
// The command is called `/pr-comments`, so it must read the PR's comments.
|
|
4798
|
+
// `gh pr view` is read-only; when it cannot answer (no PR for this branch,
|
|
4799
|
+
// gh missing, not authenticated) say which — the branch summary above is
|
|
4800
|
+
// not a substitute and silently showing only it is the fake reading.
|
|
4801
|
+
lines.push('PR comments:')
|
|
4802
|
+
try {
|
|
4803
|
+
const raw = execSync('gh pr view --json number,title,url,reviews,comments', {
|
|
4804
|
+
encoding: 'utf-8',
|
|
4805
|
+
timeout: 8000,
|
|
4806
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
4807
|
+
env: { ...process.env, LC_ALL: 'C', LANG: 'C' },
|
|
4808
|
+
}).trim()
|
|
4809
|
+
const pr = JSON.parse(raw) as {
|
|
4810
|
+
number?: number
|
|
4811
|
+
title?: string
|
|
4812
|
+
url?: string
|
|
4813
|
+
reviews?: { author?: { login?: string }; state?: string; body?: string }[]
|
|
4814
|
+
comments?: { author?: { login?: string }; body?: string }[]
|
|
4815
|
+
}
|
|
4816
|
+
const reviews = pr.reviews ?? []
|
|
4817
|
+
const comments = pr.comments ?? []
|
|
4818
|
+
lines.push(` PR #${pr.number ?? '?'}: ${pr.title ?? ''}`.trimEnd())
|
|
4819
|
+
if (pr.url) lines.push(` ${pr.url}`)
|
|
4820
|
+
for (const r of reviews.slice(-10)) {
|
|
4821
|
+
lines.push(` @${r.author?.login ?? '?'} (${r.state ?? '?'}): ${snippetForReview(r.body)}`)
|
|
4822
|
+
}
|
|
4823
|
+
for (const c of comments.slice(-10)) {
|
|
4824
|
+
lines.push(` @${c.author?.login ?? '?'}: ${snippetForReview(c.body)}`)
|
|
4825
|
+
}
|
|
4826
|
+
if (reviews.length === 0 && comments.length === 0) {
|
|
4827
|
+
lines.push(' No reviews or comments on this PR yet.')
|
|
4828
|
+
}
|
|
4829
|
+
lines.push('')
|
|
4830
|
+
} catch (err) {
|
|
4831
|
+
const e = err as { status?: number; stderr?: string; message?: string }
|
|
4832
|
+
const reason =
|
|
4833
|
+
e.status === 127
|
|
4834
|
+
? 'gh CLI not found'
|
|
4835
|
+
: (e.stderr ?? '').trim().split('\n')[0] ||
|
|
4836
|
+
(e.message ?? 'unknown error').split('\n')[0] ||
|
|
4837
|
+
'unknown error'
|
|
4838
|
+
lines.push(` unavailable — ${reason.slice(0, 160)}`)
|
|
4839
|
+
lines.push(' Only the local branch summary above is available.')
|
|
4840
|
+
lines.push('')
|
|
4841
|
+
}
|
|
4842
|
+
|
|
4514
4843
|
lines.push('To review PR: type "review this PR" or use /review.')
|
|
4515
4844
|
|
|
4516
4845
|
return { content: lines.join('\n') }
|
|
@@ -4931,11 +5260,26 @@ const upgradeCmd: CommandHandler = async (ctx) => {
|
|
|
4931
5260
|
|
|
4932
5261
|
const langCmd: CommandHandler = (ctx, args) => {
|
|
4933
5262
|
const t = resolveT(ctx)
|
|
4934
|
-
const requested = args[0]
|
|
4935
|
-
|
|
4936
|
-
|
|
5263
|
+
const requested = args[0]?.toLowerCase().replace('_', '-')
|
|
5264
|
+
const current = ctx.locale ?? 'en-US'
|
|
5265
|
+
|
|
5266
|
+
if (!requested) {
|
|
5267
|
+
return { content: t('commands.lang.current', { locale: current }) }
|
|
5268
|
+
}
|
|
5269
|
+
|
|
5270
|
+
const locale = SUPPORTED_LOCALES.find((l) => l.toLowerCase() === requested) as Locale | undefined
|
|
5271
|
+
if (!locale) {
|
|
5272
|
+
return {
|
|
5273
|
+
content: `${t('commands.lang.current', { locale: current })}\n\nUsage: /lang ${SUPPORTED_LOCALES.join(' | ')}`,
|
|
5274
|
+
}
|
|
4937
5275
|
}
|
|
4938
|
-
|
|
5276
|
+
|
|
5277
|
+
// Persisted for the next start; this session keeps the locale it was mounted
|
|
5278
|
+
// with (the provider is created once, before any command runs).
|
|
5279
|
+
if (!saveLocalePreference(locale)) {
|
|
5280
|
+
return { content: `Failed to save the locale preference to ~/.mipham/settings.json.` }
|
|
5281
|
+
}
|
|
5282
|
+
return { content: t('commands.lang.set', { locale }) }
|
|
4939
5283
|
}
|
|
4940
5284
|
|
|
4941
5285
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -4944,6 +5288,29 @@ const langCmd: CommandHandler = (ctx, args) => {
|
|
|
4944
5288
|
|
|
4945
5289
|
const noPlanCmd: CommandHandler = (ctx) => {
|
|
4946
5290
|
const t = resolveT(ctx)
|
|
5291
|
+
const mode = liveMode(ctx)
|
|
5292
|
+
if (mode !== 'plan') {
|
|
5293
|
+
return {
|
|
5294
|
+
content:
|
|
5295
|
+
`Not in plan mode (current mode: ${mode}). Nothing changed.\n\n` +
|
|
5296
|
+
'Use /plan to start a plan, or Shift+Tab to cycle modes.',
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
5299
|
+
if (!ctx.setPermissionMode) {
|
|
5300
|
+
return {
|
|
5301
|
+
content: 'This surface cannot switch permission modes. Use Shift+Tab to leave plan mode.',
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
ctx.setPermissionMode('default')
|
|
5305
|
+
const now = liveMode(ctx)
|
|
5306
|
+
// The org limit can clamp the request (same read-back as /approve).
|
|
5307
|
+
if (now === 'plan') {
|
|
5308
|
+
return {
|
|
5309
|
+
content:
|
|
5310
|
+
"Plan mode exit requested, but the organisation's permission limit kept the mode at plan. " +
|
|
5311
|
+
'Use Shift+Tab or contact your administrator.',
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
4947
5314
|
return { content: t('commands.no_plan.confirmed') }
|
|
4948
5315
|
}
|
|
4949
5316
|
|
|
@@ -5078,7 +5445,7 @@ const workflowRunCmd = async (name: string): Promise<CommandResult> => {
|
|
|
5078
5445
|
}
|
|
5079
5446
|
}
|
|
5080
5447
|
|
|
5081
|
-
const
|
|
5448
|
+
const workflowTaskCmd: CommandHandler = async (_ctx, args) => {
|
|
5082
5449
|
const task = args.join(' ').trim()
|
|
5083
5450
|
|
|
5084
5451
|
if (!task) {
|
|
@@ -6005,9 +6372,20 @@ const artifactListCmd: CommandHandler = async (ctx, _args) => {
|
|
|
6005
6372
|
}
|
|
6006
6373
|
|
|
6007
6374
|
const artifactServerCmd: CommandHandler = async (_ctx, _args) => {
|
|
6008
|
-
|
|
6375
|
+
// The server picks a free port and records it in the manifest; 9876 is only
|
|
6376
|
+
// the first candidate. Reporting the constant would name a port nothing
|
|
6377
|
+
// listens on whenever it was taken.
|
|
6378
|
+
const { readManifest } = await import('../artifacts/manifest')
|
|
6379
|
+
const { artifactsRoot } = await import('../artifacts/paths')
|
|
6380
|
+
const { port } = readManifest(artifactsRoot(process.cwd()))
|
|
6381
|
+
if (!port) {
|
|
6382
|
+
return {
|
|
6383
|
+
content:
|
|
6384
|
+
'── Artifact Server ──\n\n Not running. The server starts when an artifact is created or opened.',
|
|
6385
|
+
}
|
|
6386
|
+
}
|
|
6009
6387
|
return {
|
|
6010
|
-
content: `── Artifact Server ──\n\n URL:
|
|
6388
|
+
content: `── Artifact Server ──\n\n URL: http://localhost:${port}\n Port: ${port}\n\nArtifacts are served locally. No external network access.`,
|
|
6011
6389
|
}
|
|
6012
6390
|
}
|
|
6013
6391
|
|
|
@@ -6037,6 +6415,7 @@ const commandsListCmd: CommandHandler = () => {
|
|
|
6037
6415
|
History: [],
|
|
6038
6416
|
'Model & Provider': [],
|
|
6039
6417
|
'Tools & Skills': [],
|
|
6418
|
+
'Code Quality': [],
|
|
6040
6419
|
Plugins: [],
|
|
6041
6420
|
Workflow: [],
|
|
6042
6421
|
Project: [],
|
|
@@ -6087,7 +6466,6 @@ const commandsListCmd: CommandHandler = () => {
|
|
|
6087
6466
|
'/switch': 'Model & Provider',
|
|
6088
6467
|
'/config': 'Model & Provider',
|
|
6089
6468
|
'/effort': 'Model & Provider',
|
|
6090
|
-
'/theme': 'Model & Provider',
|
|
6091
6469
|
'/upgrade': 'Model & Provider',
|
|
6092
6470
|
'/tools': 'Tools & Skills',
|
|
6093
6471
|
'/skills': 'Tools & Skills',
|
|
@@ -6105,6 +6483,7 @@ const commandsListCmd: CommandHandler = () => {
|
|
|
6105
6483
|
'/plugin-enable': 'Plugins',
|
|
6106
6484
|
'/plugin-disable': 'Plugins',
|
|
6107
6485
|
'/commands': 'Tools & Skills',
|
|
6486
|
+
'/crsi': 'Tools & Skills',
|
|
6108
6487
|
'/crsi rules': 'Tools & Skills',
|
|
6109
6488
|
'/crsi disable': 'Tools & Skills',
|
|
6110
6489
|
'/crsi analyze': 'Tools & Skills',
|
|
@@ -6121,6 +6500,7 @@ const commandsListCmd: CommandHandler = () => {
|
|
|
6121
6500
|
'/crsi interpret': 'Tools & Skills',
|
|
6122
6501
|
'/crsi critique': 'Tools & Skills',
|
|
6123
6502
|
'/crsi red-team': 'Tools & Skills',
|
|
6503
|
+
'/sis': 'Tools & Skills',
|
|
6124
6504
|
'/sis errors': 'Tools & Skills',
|
|
6125
6505
|
'/sis stats': 'Tools & Skills',
|
|
6126
6506
|
'/sis clear': 'Tools & Skills',
|
|
@@ -6207,6 +6587,54 @@ const commandsListCmd: CommandHandler = () => {
|
|
|
6207
6587
|
|
|
6208
6588
|
const registry = new Map<string, CommandHandler>()
|
|
6209
6589
|
|
|
6590
|
+
/**
|
|
6591
|
+
* Parents that read `args[0]` themselves instead of routing through
|
|
6592
|
+
* `subcommandRouter`. Their multi-word entries (`/keys rotate`, `/resume last`)
|
|
6593
|
+
* are aliases, so the reachability guard exempts them from the router marker.
|
|
6594
|
+
*/
|
|
6595
|
+
export const SELF_ROUTING_PARENTS: ReadonlySet<string> = new Set(['/keys', '/resume'])
|
|
6596
|
+
|
|
6597
|
+
/** Handlers built by `subcommandRouter` — the reachability guard's marker. */
|
|
6598
|
+
const subcommandRouters = new WeakSet<CommandHandler>()
|
|
6599
|
+
|
|
6600
|
+
/** True when `handler` was produced by `subcommandRouter`. */
|
|
6601
|
+
export function isSubcommandRouter(handler: CommandHandler | undefined): boolean {
|
|
6602
|
+
return handler !== undefined && subcommandRouters.has(handler)
|
|
6603
|
+
}
|
|
6604
|
+
|
|
6605
|
+
/**
|
|
6606
|
+
* A handler whose job is to hand `args[0]` to the multi-word command registered
|
|
6607
|
+
* under `parent` (`/crsi rules`, `/sis stats`, `/hooks health`).
|
|
6608
|
+
*
|
|
6609
|
+
* `parseSlashCommand` keeps only `parts[0]`, so a multi-word key without a parent
|
|
6610
|
+
* is unreachable — the input renders nothing at all. When nothing resolves, the
|
|
6611
|
+
* router falls back to `fallback` if one is given (bare `/hooks` lists hooks,
|
|
6612
|
+
* bare `/workflow <task>` still forwards a task), otherwise it prints the
|
|
6613
|
+
* subcommand list instead of staying silent.
|
|
6614
|
+
*/
|
|
6615
|
+
function subcommandRouter(parent: string, fallback?: CommandHandler): CommandHandler {
|
|
6616
|
+
const handler: CommandHandler = async (ctx, args) => {
|
|
6617
|
+
const sub = args[0]?.toLowerCase()
|
|
6618
|
+
const routed = sub ? registry.get(`${parent} ${sub}`) : undefined
|
|
6619
|
+
if (routed) return routed(ctx, args.slice(1))
|
|
6620
|
+
if (fallback) return fallback(ctx, args)
|
|
6621
|
+
|
|
6622
|
+
const subs = getCommandNames()
|
|
6623
|
+
.filter((name) => name.startsWith(`${parent} `))
|
|
6624
|
+
.map((name) => name.slice(parent.length + 1))
|
|
6625
|
+
return {
|
|
6626
|
+
content: [
|
|
6627
|
+
`Usage: ${parent} <subcommand> [...args]`,
|
|
6628
|
+
'',
|
|
6629
|
+
'Subcommands:',
|
|
6630
|
+
...subs.map((name) => ` ${name}`),
|
|
6631
|
+
].join('\n'),
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
subcommandRouters.add(handler)
|
|
6635
|
+
return handler
|
|
6636
|
+
}
|
|
6637
|
+
|
|
6210
6638
|
// Session
|
|
6211
6639
|
registry.set('/help', helpCmd)
|
|
6212
6640
|
const pickCmd: CommandHandler = (ctx) => ({
|
|
@@ -6266,6 +6694,7 @@ registry.set('/remove-plugin', removePluginCmd)
|
|
|
6266
6694
|
registry.set('/plugin-enable', pluginEnableCmd)
|
|
6267
6695
|
registry.set('/plugin-disable', pluginDisableCmd)
|
|
6268
6696
|
registry.set('/commands', commandsListCmd)
|
|
6697
|
+
registry.set('/crsi', subcommandRouter('/crsi'))
|
|
6269
6698
|
registry.set('/crsi rules', crsiRulesCmd)
|
|
6270
6699
|
registry.set('/crsi disable', crsiDisableCmd)
|
|
6271
6700
|
registry.set('/crsi analyze', crsiAnalyzeCmd)
|
|
@@ -6283,6 +6712,7 @@ registry.set('/crsi meta', crsiMetaCmd)
|
|
|
6283
6712
|
registry.set('/crsi interpret', crsiInterpretCmd)
|
|
6284
6713
|
registry.set('/crsi critique', crsiCritiqueCmd)
|
|
6285
6714
|
registry.set('/crsi red-team', crsiRedTeamCmd)
|
|
6715
|
+
registry.set('/sis', subcommandRouter('/sis'))
|
|
6286
6716
|
registry.set('/sis errors', sisErrorsCmd)
|
|
6287
6717
|
registry.set('/sis stats', sisStatsCmd)
|
|
6288
6718
|
registry.set('/sis clear', sisClearCmd)
|
|
@@ -6300,7 +6730,7 @@ registry.set('/tasks', tasksCmd)
|
|
|
6300
6730
|
registry.set('/diff', diffCmd)
|
|
6301
6731
|
registry.set('/loop', loopCmd)
|
|
6302
6732
|
registry.set('/no-plan', noPlanCmd)
|
|
6303
|
-
registry.set('/workflow',
|
|
6733
|
+
registry.set('/workflow', subcommandRouter('/workflow', workflowTaskCmd))
|
|
6304
6734
|
registry.set('/workflows', workflowsCmd)
|
|
6305
6735
|
registry.set('/workflow view', workflowViewCmd)
|
|
6306
6736
|
registry.set('/workflow watch', workflowWatchCmd)
|
|
@@ -6333,7 +6763,6 @@ registry.set('/trust', trustCmd)
|
|
|
6333
6763
|
registry.set('/prompt-audit', promptAuditCmd)
|
|
6334
6764
|
|
|
6335
6765
|
// Environment
|
|
6336
|
-
registry.set('/theme', themeCmd)
|
|
6337
6766
|
registry.set('/lang', langCmd)
|
|
6338
6767
|
registry.set('/ide', ideCmd)
|
|
6339
6768
|
registry.set('/terminal-setup', terminalSetupCmd)
|
|
@@ -6377,7 +6806,7 @@ registry.set('/files', filesCmd)
|
|
|
6377
6806
|
registry.set('/stats', statsCmd)
|
|
6378
6807
|
registry.set('/summary', summaryCmd)
|
|
6379
6808
|
registry.set('/cd', cdCmd)
|
|
6380
|
-
registry.set('/hooks',
|
|
6809
|
+
registry.set('/hooks', subcommandRouter('/hooks', hooksListCmd))
|
|
6381
6810
|
registry.set('/hooks health', hooksHealthCmd)
|
|
6382
6811
|
registry.set('/hooks enable', hooksEnableCmd)
|
|
6383
6812
|
registry.set('/telemetry', telemetryCmd)
|
|
@@ -6391,6 +6820,15 @@ export function getCommand(name: string): CommandHandler | undefined {
|
|
|
6391
6820
|
return registry.get(name)
|
|
6392
6821
|
}
|
|
6393
6822
|
|
|
6823
|
+
/**
|
|
6824
|
+
* What the UI shows when dispatch resolves nothing. Before this, an unknown
|
|
6825
|
+
* slash command rendered **nothing** — the input was cleared and no message was
|
|
6826
|
+
* pushed, which is indistinguishable from the CLI being broken.
|
|
6827
|
+
*/
|
|
6828
|
+
export function unknownCommandMessage(command: string): string {
|
|
6829
|
+
return `Unknown command: ${command}\n\nType /help to see available commands, or /commands for the full list.`
|
|
6830
|
+
}
|
|
6831
|
+
|
|
6394
6832
|
export function getCommandNames(): string[] {
|
|
6395
6833
|
return Array.from(registry.keys()).sort()
|
|
6396
6834
|
}
|
|
@@ -6403,7 +6841,9 @@ export function getCommandNames(): string[] {
|
|
|
6403
6841
|
* at all — the other five are, so listing them here is belt-and-braces rather
|
|
6404
6842
|
* than a claim that they are missing.
|
|
6405
6843
|
*/
|
|
6406
|
-
|
|
6844
|
+
// `/focus` is NOT here: it lives in the registry and toggles through
|
|
6845
|
+
// `getFocusMode` — the app-side duplicate was removed so there is one handler.
|
|
6846
|
+
const PRE_REGISTRY_COMMANDS = ['/switch', '/pick', '/model-picker', '/exit', '/quit']
|
|
6407
6847
|
|
|
6408
6848
|
/**
|
|
6409
6849
|
* The bucket an unrecognised command name is recorded under.
|
|
@@ -6481,8 +6921,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
|
6481
6921
|
'/providers': 'List configured providers',
|
|
6482
6922
|
'/switch': 'Switch provider and model',
|
|
6483
6923
|
'/config': 'View configuration',
|
|
6484
|
-
'/effort': 'Set reasoning
|
|
6485
|
-
'/theme': 'Set terminal theme',
|
|
6924
|
+
'/effort': 'Set the stream stall budget (does not change reasoning depth)',
|
|
6486
6925
|
'/lang': 'Set display language (en-US, zh-CN)',
|
|
6487
6926
|
'/tools': 'List available tools',
|
|
6488
6927
|
'/skills': 'List loaded skills',
|
|
@@ -6499,6 +6938,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
|
6499
6938
|
'/remove-plugin': 'Remove an installed plugin',
|
|
6500
6939
|
'/plugin-enable': 'Enable a disabled plugin',
|
|
6501
6940
|
'/plugin-disable': 'Disable an enabled plugin',
|
|
6941
|
+
'/crsi': 'CRSI subcommands — run /crsi for the list',
|
|
6502
6942
|
'/crsi rules': 'List all active CRSI rules with their status',
|
|
6503
6943
|
'/crsi disable': 'Disable a CRSI rule by ID',
|
|
6504
6944
|
'/crsi analyze': 'Manually trigger CRSI pattern analysis across all agents',
|
|
@@ -6516,6 +6956,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
|
6516
6956
|
'/crsi interpret': 'Tool-call behavior dashboard — error patterns, usage, health',
|
|
6517
6957
|
'/crsi critique': 'Enable/disable RLAIF self-critique on tool calls',
|
|
6518
6958
|
'/crsi red-team': 'Run adversarial self-test — verify SIS blocks known attacks',
|
|
6959
|
+
'/sis': 'SIS subcommands — run /sis for the list',
|
|
6519
6960
|
'/sis errors': 'List all active SIS immune memory signatures',
|
|
6520
6961
|
'/sis stats': 'Show SIS self-immune system aggregate statistics',
|
|
6521
6962
|
'/sis clear': 'Retire an immune memory signature by ID',
|
|
@@ -6526,7 +6967,7 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
|
6526
6967
|
'/todos': 'Task management (list/create tasks)',
|
|
6527
6968
|
'/tasks': 'Background tasks',
|
|
6528
6969
|
'/review': 'Review code for bugs, security, performance (alias for /code-review)',
|
|
6529
|
-
'/pr-comments': 'PR
|
|
6970
|
+
'/pr-comments': 'PR comments via gh + local branch summary',
|
|
6530
6971
|
'/diff': 'Show git diff',
|
|
6531
6972
|
'/workflows': 'List workflow scripts',
|
|
6532
6973
|
'/workflow view': 'View workflow run details or list runs',
|
|
@@ -6560,10 +7001,10 @@ const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
|
6560
7001
|
'/fork': 'Fork task into isolated worktree',
|
|
6561
7002
|
'/artifact': 'Manage artifacts',
|
|
6562
7003
|
'/schedule': 'View scheduled tasks and cron jobs',
|
|
6563
|
-
'/commit': '
|
|
6564
|
-
'/push': '
|
|
6565
|
-
'/pr': '
|
|
6566
|
-
'/issue': '
|
|
7004
|
+
'/commit': 'Draft a commit message from staged changes',
|
|
7005
|
+
'/push': 'Show push status and the command to run',
|
|
7006
|
+
'/pr': 'Draft a pull request title and body',
|
|
7007
|
+
'/issue': 'Draft a GitHub issue from your description',
|
|
6567
7008
|
'/code-review': 'Review code for bugs, security, performance (7 dimensions)',
|
|
6568
7009
|
'/simplify': 'Cleanup-only review: reuse, simplification, efficiency, abstraction',
|
|
6569
7010
|
'/verify': 'Runtime verification — observe actual execution, not tests',
|