@alexwkleung/reika 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/README.zh-CN.md +15 -0
- package/dist/agent/bashread.js +177 -0
- package/dist/agent/compaction.js +5 -0
- package/dist/agent/compactionreport.js +184 -0
- package/dist/agent/loop.js +172 -45
- package/dist/agent/noteslotmonitor.js +82 -0
- package/dist/agent/prefillcost.js +16 -0
- package/dist/agent/prompt.js +5 -2
- package/dist/agent/readtrace.js +18 -8
- package/dist/check/typecheck.js +29 -0
- package/dist/cli.js +2 -2
- package/dist/config.js +30 -17
- package/dist/context/bootstrap.js +4 -2
- package/dist/debug.js +15 -0
- package/dist/{headless.js → headless/headless.js} +182 -48
- package/dist/{headlessargs.js → headless/headlessargs.js} +12 -2
- package/dist/headless/headlessprompt.js +132 -0
- package/dist/mcp/client.js +97 -5
- package/dist/mcp/manager.js +15 -2
- package/dist/provider/client.js +28 -0
- package/dist/provider/latches.js +3 -0
- package/dist/provider/noteslot.js +239 -0
- package/dist/provider/templatekwargs.js +31 -0
- package/dist/provider/toolcall.js +22 -1
- package/dist/provider/transport.js +12 -9
- package/dist/session.js +21 -1
- package/dist/{skills.js → skills/skills.js} +93 -13
- package/dist/store/sessions.js +39 -2
- package/dist/store/transcript.js +35 -0
- package/dist/tools/_carriers.js +119 -0
- package/dist/tools/_danger.js +539 -90
- package/dist/tools/_readonly.js +13 -12
- package/dist/ui/App.js +183 -70
- package/dist/ui/Approval.js +80 -33
- package/dist/ui/Confirm.js +1 -27
- package/dist/ui/DiffView.js +23 -12
- package/dist/ui/Question.js +152 -19
- package/dist/ui/ResumeSelect.js +3 -2
- package/dist/ui/Status.js +19 -7
- package/dist/ui/commands.js +47 -1
- package/dist/ui/dialogspecs.js +38 -0
- package/dist/ui/layout.js +118 -0
- package/package.json +1 -1
- /package/dist/{skillmatch.js → skills/skillmatch.js} +0 -0
package/dist/tools/_readonly.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { scanQuotes } from './_heredoc.js';
|
|
2
|
+
import { skipCarrier } from './_carriers.js';
|
|
2
3
|
// Shell commands that only READ — asked as TWO questions, because the two callers pull in opposite
|
|
3
4
|
// directions and collapsing them costs whichever one is on the losing side.
|
|
4
5
|
//
|
|
@@ -373,21 +374,21 @@ function readAnsiC(word, start, emit) {
|
|
|
373
374
|
// (#621) — while `_danger.ts`, which matches a command's own patterns through an unlisted carrier
|
|
374
375
|
// (`timeout 5 rm` still gates), saw the gh read and did not flag it. (`xargs` is the other carrier,
|
|
375
376
|
// read in `_sandbox.ts`'s verb reader, where the command it runs is known to be the argument.)
|
|
376
|
-
//
|
|
377
|
-
//
|
|
378
|
-
|
|
377
|
+
//
|
|
378
|
+
// Which carriers are read through, and what their own options and operands are, is
|
|
379
|
+
// `_carriers.ts`'s table (#756): `_danger.ts`'s verb strip walks the same entries, and a carrier
|
|
380
|
+
// only one of the two knew was a fetch left ungated on one side and a refused read on the other.
|
|
381
|
+
// Only the TRANSPARENT entry of the table is skipped here — `nice` and `timeout` bound or
|
|
382
|
+
// deprioritize the command, while `sudo`/`env`/`nohup` change what running it means — and the walk
|
|
383
|
+
// loops, so `timeout 30 nice gh pr view 1` is still the `gh` read.
|
|
379
384
|
export function dropCarriers(wordList) {
|
|
380
385
|
let i = 0;
|
|
381
|
-
|
|
382
|
-
i
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
i++;
|
|
387
|
-
}
|
|
388
|
-
i++; // the DURATION operand
|
|
386
|
+
for (;;) {
|
|
387
|
+
const next = skipCarrier(wordList, i, true);
|
|
388
|
+
if (next < 0)
|
|
389
|
+
return wordList.slice(i);
|
|
390
|
+
i = next;
|
|
389
391
|
}
|
|
390
|
-
return wordList.slice(i);
|
|
391
392
|
}
|
|
392
393
|
// Plan mode's sed: a line-range or pattern-range print (`sed -n '120,180p' f`,
|
|
393
394
|
// `sed -n '/## A/,/## B/p' f`) — the read models reach for most, refused before at a round's cost.
|
package/dist/ui/App.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
3
3
|
import { Box, Static, Text, useApp, useInput } from 'ink';
|
|
4
|
-
import { basename, dirname, isAbsolute,
|
|
4
|
+
import { basename, dirname, isAbsolute, resolve } from 'node:path';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { Splash } from './Splash.js';
|
|
7
7
|
import { Scrollback } from './Scrollback.js';
|
|
@@ -9,13 +9,14 @@ import { VERSION } from '../version.js';
|
|
|
9
9
|
import { Input } from './Input.js';
|
|
10
10
|
import { Working, WORKING_WORDS } from './Working.js';
|
|
11
11
|
import { PlanProgress, planProgressRows } from './PlanProgress.js';
|
|
12
|
-
import { Status } from './Status.js';
|
|
12
|
+
import { Status, statusRows } from './Status.js';
|
|
13
13
|
import { createSession } from '../session.js';
|
|
14
14
|
import { resolvePr } from './pr.js';
|
|
15
15
|
import { clearIdentity, enableAnon, isAnon } from './identity.js';
|
|
16
16
|
import { theme } from './theme.js';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { Approval } from './Approval.js';
|
|
18
|
+
import { APPROVAL_FEEDBACK_INDEX, APPROVAL_OPTIONS, CONFIRM_ACCEPT, CONFIRM_DECLINE, pastedUrlConfirmSpec, skillConfirmSpec, } from './dialogspecs.js';
|
|
19
|
+
import { Confirm, TOGGLE_CANCEL, TOGGLE_OFF, TOGGLE_ON, implementModeConfirmSpec, toggleConfirmSpec, } from './Confirm.js';
|
|
19
20
|
import { Question, questionDialogHeight } from './Question.js';
|
|
20
21
|
import { inheritProfile, loadConfig, modeSwitchProfile, resolveDefaultMode, resolveProfile, } from '../config.js';
|
|
21
22
|
import { loadLastState, persistableMode, saveLastState, startMode, startProfiles, } from '../laststate.js';
|
|
@@ -25,15 +26,16 @@ import { budgetWarning, formatBudget } from '../context/bundlesize.js';
|
|
|
25
26
|
import { debugEnabled, debugLog, processSessionStem } from '../debug.js';
|
|
26
27
|
import { noteFrameState } from './framedrops.js';
|
|
27
28
|
import { addFileToIndex } from '../context/files.js';
|
|
28
|
-
import { saveTranscript,
|
|
29
|
+
import { saveTranscript, buildTranscriptMeta, } from '../store/transcript.js';
|
|
29
30
|
import {} from '../agent/loop.js';
|
|
30
31
|
import { compactThreshold } from '../agent/compaction.js';
|
|
31
32
|
import { createPrefixWarmer } from '../agent/warm.js';
|
|
32
33
|
import { execStream } from '../tools/bash.js';
|
|
34
|
+
import { isOffline } from '../tools/_net.js';
|
|
33
35
|
import { expandMentions } from '../agent/mentions.js';
|
|
34
36
|
import { attachImageBlocks, NATIVE_IMAGE_NOTE, readNativeAttachments, nextImageMarker, } from '../agent/attachments.js';
|
|
35
37
|
import { expandPastedUrls, planPastedUrls } from '../agent/pastedurls.js';
|
|
36
|
-
import { matchSkill, shouldConfirmInject } from '../skillmatch.js';
|
|
38
|
+
import { matchSkill, shouldConfirmInject } from '../skills/skillmatch.js';
|
|
37
39
|
import { imageReader, pasteIsNative } from '../ocr/select.js';
|
|
38
40
|
import { systemOcr } from '../ocr/system.js';
|
|
39
41
|
import { sniffImageMime } from '../ocr/vision.js';
|
|
@@ -42,10 +44,11 @@ import { isWarmEdge } from './warmtrigger.js';
|
|
|
42
44
|
import { Suggestions, suggestionRows } from './Suggestions.js';
|
|
43
45
|
import { ModelSelect } from './ModelSelect.js';
|
|
44
46
|
import { mcpStartupLine } from './format.js';
|
|
47
|
+
import { useContentWidth } from './layout.js';
|
|
45
48
|
import { ResumeSelect } from './ResumeSelect.js';
|
|
46
|
-
import { countRealTurns, forAutosave, listSessions, loadSession, modelHistoryFromScrollback, newSessionPath, projectHistoryDir, ROOT_HISTORY_DIR, writeSession, } from '../store/sessions.js';
|
|
49
|
+
import { countRealTurns, forAutosave, listSessions, loadSession, modelHistoryFromScrollback, newSessionPath, projectHistoryDir, ROOT_HISTORY_DIR, saveHeader, writeSession, } from '../store/sessions.js';
|
|
47
50
|
import { buildModelTargets } from './models.js';
|
|
48
|
-
import { buildImplementPrompt, IMPLEMENT_MODES, isImplementCommand, isMinimalPrompt, isGrindPrompt, isSaveCommand, nextMode, turnMode, turnPromptMode, turnRefines, turnTools, } from './commands.js';
|
|
51
|
+
import { buildImplementPrompt, buildSearchPrompt, IMPLEMENT_MODES, isImplementCommand, isMinimalPrompt, isGrindPrompt, isSaveCommand, nextMode, searchModeRefusal, searchUnavailableNotice, turnMode, turnPromptMode, turnRefines, turnTools, } from './commands.js';
|
|
49
52
|
import { acceptSuggestion, computeSuggestions } from './suggest.js';
|
|
50
53
|
import { buildSummary, hasActivity } from './summary.js';
|
|
51
54
|
import { QueuedList } from './QueuedList.js';
|
|
@@ -75,6 +78,18 @@ function promptPlaceholder() {
|
|
|
75
78
|
return withHint.length + 6 <= (process.stdout.columns || 80) ? withHint : base;
|
|
76
79
|
}
|
|
77
80
|
const AUTOSAVE_INTERVAL_MS = 3000;
|
|
81
|
+
// A resumed session reaches the scrollback a slice at a time (#854): a commit renders its messages'
|
|
82
|
+
// markdown, highlighting and wrap synchronously, and one commit for the whole session held the
|
|
83
|
+
// event loop — the resuming spinner's timer included — for as long as that took (~2s at 460
|
|
84
|
+
// messages). Slices are sized to about this long each, so the spinner ticks between them.
|
|
85
|
+
const RESUME_SLICE_MS = 40;
|
|
86
|
+
const RESUME_FIRST_SLICE = 4;
|
|
87
|
+
// Scaled from how long the last slice took, so its cost does not depend on what the messages hold;
|
|
88
|
+
// growth is held to doubling, since a run of tiny messages says little about the next ones.
|
|
89
|
+
function nextResumeSliceSize(size, tookMs) {
|
|
90
|
+
const scaled = Math.round((size * RESUME_SLICE_MS) / Math.max(tookMs, 1));
|
|
91
|
+
return Math.min(Math.max(scaled, 1), size * 2);
|
|
92
|
+
}
|
|
78
93
|
export function App() {
|
|
79
94
|
const { exit } = useApp();
|
|
80
95
|
const [messages, setMessages] = useState([]);
|
|
@@ -234,6 +249,9 @@ export function App() {
|
|
|
234
249
|
// the note on the label below), and without this the picker just vanished and the app sat on a
|
|
235
250
|
// stale frame until it landed.
|
|
236
251
|
const [resuming, setResuming] = useState(null);
|
|
252
|
+
// Held for the whole resume, slices included: a submit or a mode switch between two slices would
|
|
253
|
+
// land its rows in the middle of the resumed scrollback, or swap it for the other side's.
|
|
254
|
+
const resumingRef = useRef(false);
|
|
237
255
|
// `status` is still 'idle' during expansion (submitToModel flips it), so without this a second
|
|
238
256
|
// Enter during a slow fetch starts a duplicate turn. Ref, not state: the handler closes over
|
|
239
257
|
// its render's value, so a fast double-press would read a stale `false`.
|
|
@@ -907,8 +925,9 @@ export function App() {
|
|
|
907
925
|
// in-flight turn's tools and prompt, the same reason /plan et al. refuse while busy; a
|
|
908
926
|
// keystroke shouldn't spam that refusal into scrollback, so it just no-ops.
|
|
909
927
|
if (key.tab && key.shift) {
|
|
910
|
-
if (statusRef.current === 'idle')
|
|
928
|
+
if (statusRef.current === 'idle' && !resumingRef.current) {
|
|
911
929
|
transitionMode(nextMode(modeRef.current), []);
|
|
930
|
+
}
|
|
912
931
|
return;
|
|
913
932
|
}
|
|
914
933
|
const sug = suggestionStateRef.current;
|
|
@@ -949,44 +968,26 @@ export function App() {
|
|
|
949
968
|
// The header both /save and the auto-save write. `msgs` is what the file's body holds.
|
|
950
969
|
const transcriptMeta = (msgs, cwd, midTurn) => {
|
|
951
970
|
// Use the active profile's model/base so the saved meta reflects what was actually running,
|
|
952
|
-
// not the default.
|
|
971
|
+
// not the default.
|
|
953
972
|
const profile = config.profiles[activeProfileRef.current] ?? config.profiles.default;
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
// header and a screenshot of the footer can never disagree.
|
|
957
|
-
const last = lastUsageRef.current;
|
|
958
|
-
const totals = usageRef.current;
|
|
959
|
-
const shrink = sessionRef.current?.shrink ?? { sheds: 0, folds: 0 };
|
|
960
|
-
const window = profile.contextWindow ?? config.contextWindow;
|
|
961
|
-
// The session's reserve is the learned one (#551), the number the next round compacts at.
|
|
962
|
-
const minGen = sessionRef.current?.config.minGenTokens ?? profile.minGenTokens;
|
|
963
|
-
const usable = window ? Math.round(compactThreshold(window, minGen)) : undefined;
|
|
964
|
-
const usage = {
|
|
965
|
-
turns: msgs.filter(m => m.role === 'assistant').length,
|
|
966
|
-
promptTokens: totals.promptTokens,
|
|
967
|
-
completionTokens: totals.completionTokens,
|
|
968
|
-
...(totals.cachedTokens != null ? { cachedTokens: totals.cachedTokens } : {}),
|
|
969
|
-
contextTokens: last?.promptTokens ?? estimatedContextRef.current,
|
|
970
|
-
// No call has landed yet, so the context size above is the pre-send estimate.
|
|
971
|
-
...(last?.promptTokens == null ? { contextEstimated: true } : {}),
|
|
972
|
-
...(window ? { contextWindow: window } : {}),
|
|
973
|
-
...(usable ? { contextUsable: usable } : {}),
|
|
974
|
-
...(last?.cachedTokens != null ? { lastCachedTokens: last.cachedTokens } : {}),
|
|
975
|
-
...(shrink.sheds > 0 || shrink.folds > 0
|
|
976
|
-
? { ...shrink, shrinkEvents: shrinkEventsRef.current }
|
|
977
|
-
: {}),
|
|
978
|
-
};
|
|
979
|
-
return {
|
|
980
|
-
version: TRANSCRIPT_VERSION,
|
|
981
|
-
savedAt: new Date().toISOString(),
|
|
973
|
+
return buildTranscriptMeta({
|
|
974
|
+
msgs,
|
|
982
975
|
model: profile.model,
|
|
983
976
|
baseURL: profile.baseURL,
|
|
984
977
|
cwd,
|
|
985
|
-
messageCount: msgs.length,
|
|
986
978
|
mode: modeRef.current,
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
979
|
+
midTurn,
|
|
980
|
+
status: {
|
|
981
|
+
totals: usageRef.current,
|
|
982
|
+
lastUsage: lastUsageRef.current,
|
|
983
|
+
estimatedContext: estimatedContextRef.current,
|
|
984
|
+
shrink: sessionRef.current?.shrink ?? { sheds: 0, folds: 0 },
|
|
985
|
+
shrinkEvents: shrinkEventsRef.current,
|
|
986
|
+
contextWindow: profile.contextWindow ?? config.contextWindow,
|
|
987
|
+
// The session's reserve is the learned one (#551), the number the next round compacts at.
|
|
988
|
+
minGenTokens: sessionRef.current?.config.minGenTokens ?? profile.minGenTokens,
|
|
989
|
+
},
|
|
990
|
+
});
|
|
990
991
|
};
|
|
991
992
|
// Both sides of the chat boundary, wherever each currently lives.
|
|
992
993
|
const sessionSides = () => {
|
|
@@ -1080,9 +1081,16 @@ export function App() {
|
|
|
1080
1081
|
autosaveHoldRef.current = null;
|
|
1081
1082
|
};
|
|
1082
1083
|
const resumeSession = async (entry, projectDir) => {
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1084
|
+
resumingRef.current = true;
|
|
1085
|
+
try {
|
|
1086
|
+
await loadResumedSession(entry, projectDir);
|
|
1087
|
+
}
|
|
1088
|
+
finally {
|
|
1089
|
+
resumingRef.current = false;
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
const loadResumedSession = async (entry, projectDir) => {
|
|
1093
|
+
// Set before the first await, so the frame lands while the file is still being read.
|
|
1086
1094
|
setResuming(`Resuming "${entry.title ?? 'untitled'}"`);
|
|
1087
1095
|
let sides;
|
|
1088
1096
|
try {
|
|
@@ -1106,6 +1114,23 @@ export function App() {
|
|
|
1106
1114
|
logSessionFile(entry.path);
|
|
1107
1115
|
}
|
|
1108
1116
|
autosaveHoldRef.current = countRealTurns(sides.agent) + countRealTurns(sides.chat);
|
|
1117
|
+
// A session with only one side opens on that side (#875): resumed from the other, it would
|
|
1118
|
+
// land on an empty screen, its messages one /chat or /agent away. A session with both stays
|
|
1119
|
+
// put. Leaving chat goes to agent rather than the session's last mode, which could be plan or
|
|
1120
|
+
// shell. The conversation was just reset, so there is no screen to stash — only the session's
|
|
1121
|
+
// side and the mode move.
|
|
1122
|
+
const agentTurns = countRealTurns(sides.agent);
|
|
1123
|
+
const chatTurns = countRealTurns(sides.chat);
|
|
1124
|
+
const switchedTo = modeRef.current !== 'chat' && agentTurns === 0 && chatTurns > 0
|
|
1125
|
+
? 'chat'
|
|
1126
|
+
: modeRef.current === 'chat' && chatTurns === 0 && agentTurns > 0
|
|
1127
|
+
? 'agent'
|
|
1128
|
+
: null;
|
|
1129
|
+
if (switchedTo) {
|
|
1130
|
+
sessionRef.current?.switchSide(switchedTo === 'chat' ? 'chat' : 'agent');
|
|
1131
|
+
modeRef.current = switchedTo;
|
|
1132
|
+
setMode(switchedTo);
|
|
1133
|
+
}
|
|
1109
1134
|
const inChat = modeRef.current === 'chat';
|
|
1110
1135
|
const active = inChat ? sides.chat : sides.agent;
|
|
1111
1136
|
const other = inChat ? sides.agent : sides.chat;
|
|
@@ -1113,15 +1138,27 @@ export function App() {
|
|
|
1113
1138
|
sessionRef.current?.loadHistory(modelHistoryFromScrollback(active), modelHistoryFromScrollback(other));
|
|
1114
1139
|
const where = inChat ? 'chat' : 'agent';
|
|
1115
1140
|
const otherNote = other.length > 0 ? ` (+ ${other.length} on the ${inChat ? 'agent' : 'chat'} side)` : '';
|
|
1116
|
-
|
|
1141
|
+
const resumed = [
|
|
1117
1142
|
...active,
|
|
1118
1143
|
{
|
|
1119
1144
|
role: 'system',
|
|
1120
|
-
content: `Resumed "${entry.title ?? 'untitled'}" — ${active.length} ${where} messages${otherNote} from ${entry.path}`,
|
|
1145
|
+
content: `Resumed "${entry.title ?? 'untitled'}" — ${active.length} ${where} messages${otherNote}${switchedTo ? `, switched to ${switchedTo} mode,` : ''} from ${entry.path}`,
|
|
1121
1146
|
},
|
|
1122
|
-
]
|
|
1123
|
-
|
|
1124
|
-
|
|
1147
|
+
];
|
|
1148
|
+
let size = RESUME_FIRST_SLICE;
|
|
1149
|
+
for (let at = 0; at < resumed.length;) {
|
|
1150
|
+
const slice = resumed.slice(at, at + size);
|
|
1151
|
+
const started = performance.now();
|
|
1152
|
+
// The first slice replaces the old conversation; the rest extend it.
|
|
1153
|
+
setMessages(at === 0 ? slice : prev => [...prev, ...slice]);
|
|
1154
|
+
at += slice.length;
|
|
1155
|
+
if (at >= resumed.length)
|
|
1156
|
+
break;
|
|
1157
|
+
// A timer, not a microtask: the spinner ticks on an interval, which only a yield to the timer
|
|
1158
|
+
// phase lets fire. Measured past the yield, so the commit counts whenever React flushes it.
|
|
1159
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
|
1160
|
+
size = nextResumeSliceSize(size, performance.now() - started);
|
|
1161
|
+
}
|
|
1125
1162
|
setResuming(null);
|
|
1126
1163
|
};
|
|
1127
1164
|
const requestExit = () => {
|
|
@@ -1410,6 +1447,36 @@ export function App() {
|
|
|
1410
1447
|
undefined, mode === 'vibe' ? 'agent' : undefined, undefined, true);
|
|
1411
1448
|
return;
|
|
1412
1449
|
}
|
|
1450
|
+
if (name === 'search') {
|
|
1451
|
+
// `/search <query>` (#829): the direct road to the search tool. A mode's own prompt says to
|
|
1452
|
+
// use `search` only when the answer needs current information, which leaves the decision to
|
|
1453
|
+
// the model; this makes it the user's. Availability is read off the session's own tool lists
|
|
1454
|
+
// rather than re-derived from config, so it agrees with the offline case too — that one is
|
|
1455
|
+
// decided once at startup (`opts.offline` in tools/index.ts) and never revisited.
|
|
1456
|
+
const query = args.trim();
|
|
1457
|
+
const say = (content) => setMessages(prev => [...prev, echo, { role: 'system', content }]);
|
|
1458
|
+
if (!query) {
|
|
1459
|
+
say('Usage: /search <query> — the model runs one web search and answers from the results.');
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
const refusal = searchModeRefusal(mode);
|
|
1463
|
+
if (refusal) {
|
|
1464
|
+
say(refusal);
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
// Vibe plans before it acts, and a search is a question, not a task: it runs as an agent turn,
|
|
1468
|
+
// the same one-turn override /implement and /compact take out of vibe.
|
|
1469
|
+
const target = mode === 'vibe' ? 'agent' : mode;
|
|
1470
|
+
const lists = sessionRef.current?.lists;
|
|
1471
|
+
if (!lists || !turnTools(target, lists).some(t => t.name === 'search')) {
|
|
1472
|
+
say(searchUnavailableNotice(isOffline()));
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
// No echo of its own, like a skill: runTurn emits the user message, rendered from `raw`, so
|
|
1476
|
+
// the bubble reads `/search react 19` while the model receives the instructions.
|
|
1477
|
+
await submitToModel(buildSearchPrompt(query), raw, target === mode ? undefined : target);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1413
1480
|
if (name === 'cd') {
|
|
1414
1481
|
const target = args.trim();
|
|
1415
1482
|
if (!target) {
|
|
@@ -1447,24 +1514,39 @@ export function App() {
|
|
|
1447
1514
|
return;
|
|
1448
1515
|
}
|
|
1449
1516
|
const target = args.trim().toLowerCase();
|
|
1450
|
-
if (target !== '' && target !== 'root') {
|
|
1451
|
-
say('Usage: /resume (this project) or /resume root (manual /save files).');
|
|
1517
|
+
if (target !== '' && target !== 'all' && target !== 'root') {
|
|
1518
|
+
say('Usage: /resume (this project; chats only in chat mode), /resume all, or /resume root (manual /save files).');
|
|
1452
1519
|
return;
|
|
1453
1520
|
}
|
|
1454
1521
|
const projectDir = projectHistoryDir(bundle.cwd);
|
|
1455
1522
|
// The session in progress is not something to resume into.
|
|
1456
1523
|
const notCurrent = (e) => e.path !== sessionPathRef.current;
|
|
1524
|
+
// Chat history is kept apart from every other mode's, so chat mode lists chats (#875). A
|
|
1525
|
+
// project file saved before the header counted chat turns is not listed here; /resume all
|
|
1526
|
+
// still has it.
|
|
1527
|
+
const chatsOnly = target === '' && modeRef.current === 'chat';
|
|
1457
1528
|
let entries = [];
|
|
1458
1529
|
let heading = 'saved with /save';
|
|
1459
|
-
if (target
|
|
1530
|
+
if (target !== 'root') {
|
|
1460
1531
|
entries = (await listSessions(projectDir)).filter(notCurrent);
|
|
1461
|
-
|
|
1532
|
+
if (chatsOnly)
|
|
1533
|
+
entries = entries.filter(e => e.chat);
|
|
1534
|
+
heading = chatsOnly ? 'chats in this project' : 'this project';
|
|
1462
1535
|
}
|
|
1463
|
-
// A project with
|
|
1536
|
+
// A project with nothing to list falls back to the manual saves — in chat mode, the ones that
|
|
1537
|
+
// hold a chat (#882).
|
|
1464
1538
|
if (entries.length === 0) {
|
|
1465
|
-
entries = await listSessions(ROOT_HISTORY_DIR);
|
|
1539
|
+
entries = await listSessions(ROOT_HISTORY_DIR, true);
|
|
1540
|
+
if (chatsOnly)
|
|
1541
|
+
entries = entries.filter(e => e.chat);
|
|
1466
1542
|
if (target === '' && entries.length > 0)
|
|
1467
|
-
heading =
|
|
1543
|
+
heading = chatsOnly
|
|
1544
|
+
? 'no chats for this project — saved with /save'
|
|
1545
|
+
: 'none for this project — saved with /save';
|
|
1546
|
+
}
|
|
1547
|
+
if (entries.length === 0 && chatsOnly) {
|
|
1548
|
+
say('No saved chats for this project. /resume all lists every session.');
|
|
1549
|
+
return;
|
|
1468
1550
|
}
|
|
1469
1551
|
if (entries.length === 0) {
|
|
1470
1552
|
say(target === 'root'
|
|
@@ -1498,7 +1580,7 @@ export function App() {
|
|
|
1498
1580
|
return;
|
|
1499
1581
|
}
|
|
1500
1582
|
try {
|
|
1501
|
-
const { jsonlPath, txtPath } = await saveTranscript(
|
|
1583
|
+
const { jsonlPath, txtPath } = await saveTranscript(ROOT_HISTORY_DIR, msgs, saveHeader(transcriptMeta(msgs, bundle.cwd, midTurn), msgs), { redact: !raw });
|
|
1502
1584
|
setMessages(prev => [
|
|
1503
1585
|
...prev,
|
|
1504
1586
|
echo,
|
|
@@ -1542,10 +1624,11 @@ export function App() {
|
|
|
1542
1624
|
' /tokens show token usage this session',
|
|
1543
1625
|
' /stats show full session summary',
|
|
1544
1626
|
' /save save the full conversation to history, even mid-turn (--raw skips redaction)',
|
|
1545
|
-
' /resume [root]
|
|
1627
|
+
' /resume [all|root] resume a saved session of this project (chat mode: chats only; all: every session; root: the /save files)',
|
|
1546
1628
|
' /skills list available skills (loaded from your skill directories)',
|
|
1547
1629
|
' /mcp list MCP servers and their tools (REIKA_MCP_SERVERS)',
|
|
1548
1630
|
' /<server>:<tool> call an MCP tool directly (JSON args, or the bare string for a one-arg tool)',
|
|
1631
|
+
' /search <query> search the web: the model runs one search and answers from the results',
|
|
1549
1632
|
' /exit, /quit exit reika (prints summary)',
|
|
1550
1633
|
' @<path> in agent mode, inline a file as context',
|
|
1551
1634
|
' ctrl-v paste an image; its text is read out and attached (macOS/Windows)',
|
|
@@ -1739,12 +1822,12 @@ export function App() {
|
|
|
1739
1822
|
const list = bundle?.skills ?? [];
|
|
1740
1823
|
if (list.length === 0) {
|
|
1741
1824
|
response =
|
|
1742
|
-
'No skills loaded. Drop *.md files in ~/.config/reika/skills/ or <cwd>/.
|
|
1825
|
+
'No skills loaded. Drop *.md files or SKILL.md folders in ~/.config/reika/skills/, <cwd>/.reika/skills/, ~/.agents/skills/ or <cwd>/.agents/skills/.';
|
|
1743
1826
|
}
|
|
1744
1827
|
else {
|
|
1745
1828
|
response = [
|
|
1746
1829
|
'Available skills (invoke as /<name>):',
|
|
1747
|
-
...list.map(s => ` /${s.name.padEnd(16)} ${s.description} ${s.source === 'project' ? '(project)' : ''}`),
|
|
1830
|
+
...list.map(s => ` /${s.name.padEnd(16)} ${s.description} ${s.from ? `(${s.from})` : s.source === 'project' ? '(project)' : ''}`),
|
|
1748
1831
|
].join('\n');
|
|
1749
1832
|
}
|
|
1750
1833
|
break;
|
|
@@ -2090,6 +2173,10 @@ export function App() {
|
|
|
2090
2173
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2091
2174
|
}, [status, pending, confirm, queue]);
|
|
2092
2175
|
const onSubmit = async (input) => {
|
|
2176
|
+
// Left in the box rather than queued: the resume replaces the conversation the prompt was
|
|
2177
|
+
// typed against, and the user sees it land before deciding to send.
|
|
2178
|
+
if (resumingRef.current)
|
|
2179
|
+
return;
|
|
2093
2180
|
// An answer being typed for `ask_user` — not a message for the model. Intercepted ahead of the
|
|
2094
2181
|
// busy-queue branch below: a question only exists mid-turn, so every such submit would otherwise
|
|
2095
2182
|
// be queued as the user's next prompt.
|
|
@@ -2539,8 +2626,38 @@ export function App() {
|
|
|
2539
2626
|
statusProfile?.minGenTokens ??
|
|
2540
2627
|
config.minGenTokens))
|
|
2541
2628
|
: undefined;
|
|
2542
|
-
|
|
2543
|
-
const
|
|
2629
|
+
const statusWidth = useContentWidth();
|
|
2630
|
+
const statusProps = {
|
|
2631
|
+
model: config?.profiles[activeProfile]?.model ?? config?.model ?? '',
|
|
2632
|
+
turns: messages.filter(m => m.role === 'assistant').length,
|
|
2633
|
+
status: status === 'busy' ? phase : status,
|
|
2634
|
+
elapsed: status === 'busy' ? elapsed : null,
|
|
2635
|
+
usage: totalUsage,
|
|
2636
|
+
contextTokens: lastUsage?.promptTokens ?? estimatedContext,
|
|
2637
|
+
contextWindow: statusWindow,
|
|
2638
|
+
contextUsable: statusUsable,
|
|
2639
|
+
sheds: shrink.sheds,
|
|
2640
|
+
folds: shrink.folds,
|
|
2641
|
+
cachedTokens: lastUsage?.cachedTokens,
|
|
2642
|
+
decodeRate: decodeRate,
|
|
2643
|
+
pr: pr,
|
|
2644
|
+
autoApprove: config?.autoApprove === 'bypass'
|
|
2645
|
+
? 'bypass'
|
|
2646
|
+
: effectiveAutoApprove(config, sessionAutoApprove) === 'safe'
|
|
2647
|
+
? 'safe'
|
|
2648
|
+
: undefined,
|
|
2649
|
+
unattended: unattended,
|
|
2650
|
+
modeTag: mode,
|
|
2651
|
+
exitArmed: exitArmed && status === 'idle' && pending === null && inputValue === '',
|
|
2652
|
+
};
|
|
2653
|
+
// Status rows past the one the baseline chrome assumes: a narrow pane (three iTerm2 panes) wraps
|
|
2654
|
+
// the bar onto several, and unbudgeted they push the live frame to viewport height, where Ink
|
|
2655
|
+
// repaints with a scrollback clear on every chunk.
|
|
2656
|
+
const statusExtraRows = Math.max(0, statusRows(statusProps, statusWidth) - 1);
|
|
2657
|
+
// Live rows above a dialog (plan checklist, queued messages, a wrapped status bar) it has to
|
|
2658
|
+
// leave viewport room for.
|
|
2659
|
+
const dialogReservedRows = statusExtraRows +
|
|
2660
|
+
(planSteps && (mode === 'agent' || mode === 'vibe') ? planProgressRows(planSteps) : 0) +
|
|
2544
2661
|
(queue.length > 0 ? queue.length + 1 : 0);
|
|
2545
2662
|
if (status === 'error') {
|
|
2546
2663
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "Error" }), _jsx(Text, { children: error })] }));
|
|
@@ -2619,8 +2736,8 @@ export function App() {
|
|
|
2619
2736
|
modelSelect !== null ||
|
|
2620
2737
|
resumeSelect !== null ||
|
|
2621
2738
|
confirm !== null, attachedBelow: suggestionState !== null, reservedRows: question
|
|
2622
|
-
? questionDialogHeight(question.request, questionTyping, dialogReservedRows)
|
|
2623
|
-
:
|
|
2739
|
+
? questionDialogHeight(question.request, questionTyping, dialogReservedRows, questionSelected)
|
|
2740
|
+
: statusExtraRows, suggesting: !!suggestionState && suggestionState.items.length > 0, history: inputHistory, mode: mode, value: inputValue, onChange: onInputChange, onSubmit: onSubmit, onPasteImage: onPasteImageSafely, onPasteText: onPasteText, placeholder:
|
|
2624
2741
|
// A reason that should stop the model has to say so: "tell me the script" read as
|
|
2625
2742
|
// run-then-tell and drew retries, "don't run anything" did not (decline-terse/-ask).
|
|
2626
2743
|
approvalTyping
|
|
@@ -2629,9 +2746,5 @@ export function App() {
|
|
|
2629
2746
|
? 'Run a shell command'
|
|
2630
2747
|
: mode === 'vibe'
|
|
2631
2748
|
? 'Describe a change — it plans first, then implements'
|
|
2632
|
-
: promptPlaceholder() }), suggestionState ? (_jsx(Suggestions, { state: suggestionState, selectedIndex: suggestionSelected })) : null, _jsx(Status, {
|
|
2633
|
-
? 'bypass'
|
|
2634
|
-
: effectiveAutoApprove(config, sessionAutoApprove) === 'safe'
|
|
2635
|
-
? 'safe'
|
|
2636
|
-
: undefined, unattended: unattended, modeTag: mode, exitArmed: exitArmed && status === 'idle' && pending === null && inputValue === '' })] }))] }));
|
|
2749
|
+
: promptPlaceholder() }), suggestionState ? (_jsx(Suggestions, { state: suggestionState, selectedIndex: suggestionSelected })) : null, _jsx(Status, { ...statusProps })] }))] }));
|
|
2637
2750
|
}
|