strands-darwin 0.0.35 → 0.0.36
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 +20 -3
- package/README.zh-CN.md +20 -3
- package/dist/src/agent/prompt-cache.js +15 -2
- package/dist/src/agent/prompt-cache.js.map +1 -1
- package/dist/src/agent/rewind.d.ts +2 -0
- package/dist/src/agent/rewind.js +4 -1
- package/dist/src/agent/rewind.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +64 -10
- package/dist/src/agent/runtime.js +192 -33
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/session.d.ts +96 -4
- package/dist/src/agent/session.js +249 -9
- package/dist/src/agent/session.js.map +1 -1
- package/dist/src/agent/stream-idle.d.ts +16 -0
- package/dist/src/agent/stream-idle.js +127 -0
- package/dist/src/agent/stream-idle.js.map +1 -0
- package/dist/src/agent/working-context.d.ts +21 -1
- package/dist/src/agent/working-context.js +28 -1
- package/dist/src/agent/working-context.js.map +1 -1
- package/dist/src/agent/workspace-trust.d.ts +112 -0
- package/dist/src/agent/workspace-trust.js +207 -0
- package/dist/src/agent/workspace-trust.js.map +1 -0
- package/dist/src/agentcore/auto-policy.d.ts +7 -0
- package/dist/src/agentcore/auto-policy.js +50 -0
- package/dist/src/agentcore/auto-policy.js.map +1 -0
- package/dist/src/agentcore/auto-state.d.ts +43 -0
- package/dist/src/agentcore/auto-state.js +73 -0
- package/dist/src/agentcore/auto-state.js.map +1 -0
- package/dist/src/agentcore/cli.d.ts +2 -0
- package/dist/src/agentcore/cli.js +38 -0
- package/dist/src/agentcore/cli.js.map +1 -0
- package/dist/src/agentcore/config.d.ts +48 -0
- package/dist/src/agentcore/config.js +44 -0
- package/dist/src/agentcore/config.js.map +1 -0
- package/dist/src/agentcore/controller.d.ts +105 -0
- package/dist/src/agentcore/controller.js +979 -0
- package/dist/src/agentcore/controller.js.map +1 -0
- package/dist/src/agentcore/projection.d.ts +2 -0
- package/dist/src/agentcore/projection.js +8 -0
- package/dist/src/agentcore/projection.js.map +1 -0
- package/dist/src/agentcore/records.d.ts +41 -0
- package/dist/src/agentcore/records.js +149 -0
- package/dist/src/agentcore/records.js.map +1 -0
- package/dist/src/agentcore/state.d.ts +16 -0
- package/dist/src/agentcore/state.js +149 -0
- package/dist/src/agentcore/state.js.map +1 -0
- package/dist/src/agentcore/tools.d.ts +3 -0
- package/dist/src/agentcore/tools.js +11 -0
- package/dist/src/agentcore/tools.js.map +1 -0
- package/dist/src/agentcore/transport.d.ts +37 -0
- package/dist/src/agentcore/transport.js +242 -0
- package/dist/src/agentcore/transport.js.map +1 -0
- package/dist/src/agentcore/upload-projection.d.ts +208 -0
- package/dist/src/agentcore/upload-projection.js +823 -0
- package/dist/src/agentcore/upload-projection.js.map +1 -0
- package/dist/src/agents/child-recipe.js +4 -1
- package/dist/src/agents/child-recipe.js.map +1 -1
- package/dist/src/agents/loader.d.ts +12 -0
- package/dist/src/agents/loader.js +15 -1
- package/dist/src/agents/loader.js.map +1 -1
- package/dist/src/agents/subagent-tool.js +2 -4
- package/dist/src/agents/subagent-tool.js.map +1 -1
- package/dist/src/agents/workflow-tool.js +2 -4
- package/dist/src/agents/workflow-tool.js.map +1 -1
- package/dist/src/cli-doctor.js +7 -0
- package/dist/src/cli-doctor.js.map +1 -1
- package/dist/src/cli-import.d.ts +1 -0
- package/dist/src/cli-import.js +26 -0
- package/dist/src/cli-import.js.map +1 -0
- package/dist/src/cli-main.js +60 -10
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/cli-permissions.d.ts +2 -0
- package/dist/src/cli-permissions.js +20 -0
- package/dist/src/cli-permissions.js.map +1 -0
- package/dist/src/cli-sessions.js +6 -2
- package/dist/src/cli-sessions.js.map +1 -1
- package/dist/src/cli-usage.d.ts +9 -1
- package/dist/src/cli-usage.js +13 -0
- package/dist/src/cli-usage.js.map +1 -1
- package/dist/src/cli.js +19 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/custom-commands.d.ts +1 -1
- package/dist/src/commands/custom-commands.js +14 -6
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/commands/review-command.d.ts +10 -0
- package/dist/src/commands/review-command.js +28 -0
- package/dist/src/commands/review-command.js.map +1 -0
- package/dist/src/config-file.d.ts +9 -0
- package/dist/src/config-file.js +82 -0
- package/dist/src/config-file.js.map +1 -0
- package/dist/src/config.d.ts +66 -5
- package/dist/src/config.js +126 -42
- package/dist/src/config.js.map +1 -1
- package/dist/src/dev-repl.js +17 -1
- package/dist/src/dev-repl.js.map +1 -1
- package/dist/src/headless-protocol.d.ts +24 -1
- package/dist/src/headless-protocol.js +18 -0
- package/dist/src/headless-protocol.js.map +1 -1
- package/dist/src/headless-runner.d.ts +8 -0
- package/dist/src/headless-runner.js +37 -1
- package/dist/src/headless-runner.js.map +1 -1
- package/dist/src/hooks/hook-process.js +7 -2
- package/dist/src/hooks/hook-process.js.map +1 -1
- package/dist/src/hooks/lifecycle-hooks.js +3 -1
- package/dist/src/hooks/lifecycle-hooks.js.map +1 -1
- package/dist/src/hooks/tool-hooks.js +3 -1
- package/dist/src/hooks/tool-hooks.js.map +1 -1
- package/dist/src/import-claude-files.d.ts +28 -0
- package/dist/src/import-claude-files.js +227 -0
- package/dist/src/import-claude-files.js.map +1 -0
- package/dist/src/import-claude-snippets.d.ts +2 -0
- package/dist/src/import-claude-snippets.js +105 -0
- package/dist/src/import-claude-snippets.js.map +1 -0
- package/dist/src/import-claude.d.ts +13 -0
- package/dist/src/import-claude.js +287 -0
- package/dist/src/import-claude.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +57 -1
- package/dist/src/mcp/registry.js +78 -6
- package/dist/src/mcp/registry.js.map +1 -1
- package/dist/src/memory/command.d.ts +1 -1
- package/dist/src/memory/command.js +89 -4
- package/dist/src/memory/command.js.map +1 -1
- package/dist/src/memory/controller.d.ts +32 -0
- package/dist/src/memory/controller.js +39 -3
- package/dist/src/memory/controller.js.map +1 -1
- package/dist/src/memory/state.d.ts +6 -0
- package/dist/src/memory/state.js +6 -1
- package/dist/src/memory/state.js.map +1 -1
- package/dist/src/memory/store.d.ts +13 -0
- package/dist/src/memory/store.js +38 -2
- package/dist/src/memory/store.js.map +1 -1
- package/dist/src/memory/tools.d.ts +7 -0
- package/dist/src/memory/tools.js +12 -1
- package/dist/src/memory/tools.js.map +1 -1
- package/dist/src/paths.js +3 -0
- package/dist/src/paths.js.map +1 -1
- package/dist/src/permissions-test.d.ts +18 -0
- package/dist/src/permissions-test.js +207 -0
- package/dist/src/permissions-test.js.map +1 -0
- package/dist/src/pricing/model-prices.d.ts +8 -5
- package/dist/src/pricing/model-prices.js +30 -15
- package/dist/src/pricing/model-prices.js.map +1 -1
- package/dist/src/project-identity.d.ts +3 -0
- package/dist/src/project-identity.js +8 -0
- package/dist/src/project-identity.js.map +1 -0
- package/dist/src/project-overrides.d.ts +57 -0
- package/dist/src/project-overrides.js +79 -0
- package/dist/src/project-overrides.js.map +1 -0
- package/dist/src/skills/builtin/setup-agentcore-memory/SKILL.md +158 -0
- package/dist/src/skills/loader.d.ts +1 -1
- package/dist/src/skills/loader.js +4 -1
- package/dist/src/skills/loader.js.map +1 -1
- package/dist/src/tools/background-bash.d.ts +6 -0
- package/dist/src/tools/background-bash.js +26 -0
- package/dist/src/tools/background-bash.js.map +1 -1
- package/dist/src/tools/shell-env.d.ts +24 -0
- package/dist/src/tools/shell-env.js +34 -0
- package/dist/src/tools/shell-env.js.map +1 -1
- package/dist/src/trajectory/reader.d.ts +1 -1
- package/dist/src/trajectory/reader.js +23 -3
- package/dist/src/trajectory/reader.js.map +1 -1
- package/dist/src/trajectory/resume-recap.d.ts +11 -1
- package/dist/src/trajectory/resume-recap.js +10 -1
- package/dist/src/trajectory/resume-recap.js.map +1 -1
- package/dist/src/trajectory/rewind-history.d.ts +8 -0
- package/dist/src/trajectory/rewind-history.js +81 -0
- package/dist/src/trajectory/rewind-history.js.map +1 -0
- package/dist/src/tui/App.d.ts +5 -1
- package/dist/src/tui/App.js +284 -51
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +1 -1
- package/dist/src/tui/InputBox.js +1 -1
- package/dist/src/tui/MessageList.js +1 -1
- package/dist/src/tui/MessageList.js.map +1 -1
- package/dist/src/tui/PermissionPrompt.js +5 -3
- package/dist/src/tui/PermissionPrompt.js.map +1 -1
- package/dist/src/tui/QueuedMessages.js +14 -8
- package/dist/src/tui/QueuedMessages.js.map +1 -1
- package/dist/src/tui/ToolCallPanel.js +2 -2
- package/dist/src/tui/ToolCallPanel.js.map +1 -1
- package/dist/src/tui/WorkspaceTrustPrompt.d.ts +8 -0
- package/dist/src/tui/WorkspaceTrustPrompt.js +37 -0
- package/dist/src/tui/WorkspaceTrustPrompt.js.map +1 -0
- package/dist/src/tui/draft-stash.d.ts +25 -0
- package/dist/src/tui/draft-stash.js +49 -0
- package/dist/src/tui/draft-stash.js.map +1 -0
- package/dist/src/tui/frame-budget.d.ts +2 -2
- package/dist/src/tui/frame-budget.js +3 -3
- package/dist/src/tui/frame-budget.js.map +1 -1
- package/dist/src/tui/help-format.d.ts +2 -2
- package/dist/src/tui/help-format.js +3 -3
- package/dist/src/tui/help-format.js.map +1 -1
- package/dist/src/tui/mcp-format.d.ts +9 -0
- package/dist/src/tui/mcp-format.js +5 -3
- package/dist/src/tui/mcp-format.js.map +1 -1
- package/dist/src/tui/permission-rule-preview.d.ts +23 -0
- package/dist/src/tui/permission-rule-preview.js +38 -0
- package/dist/src/tui/permission-rule-preview.js.map +1 -0
- package/dist/src/tui/prompt-editor.d.ts +12 -0
- package/dist/src/tui/prompt-editor.js +38 -28
- package/dist/src/tui/prompt-editor.js.map +1 -1
- package/dist/src/tui/prompt-history-search.js +3 -2
- package/dist/src/tui/prompt-history-search.js.map +1 -1
- package/dist/src/tui/prompt-queue.d.ts +4 -2
- package/dist/src/tui/prompt-queue.js +18 -3
- package/dist/src/tui/prompt-queue.js.map +1 -1
- package/dist/src/tui/rewind-search.js +4 -3
- package/dist/src/tui/rewind-search.js.map +1 -1
- package/dist/src/tui/search-preview.d.ts +2 -0
- package/dist/src/tui/search-preview.js +9 -0
- package/dist/src/tui/search-preview.js.map +1 -0
- package/dist/src/tui/shell-command.js +4 -1
- package/dist/src/tui/shell-command.js.map +1 -1
- package/dist/src/tui/spinner.d.ts +1 -0
- package/dist/src/tui/spinner.js +6 -0
- package/dist/src/tui/spinner.js.map +1 -0
- package/dist/src/tui/status-format.d.ts +9 -0
- package/dist/src/tui/status-format.js +37 -2
- package/dist/src/tui/status-format.js.map +1 -1
- package/dist/src/tui/subagent-format.js +6 -0
- package/dist/src/tui/subagent-format.js.map +1 -1
- package/dist/src/tui/task-format.d.ts +5 -0
- package/dist/src/tui/task-format.js +15 -0
- package/dist/src/tui/task-format.js.map +1 -1
- package/dist/src/tui/trust-format.d.ts +31 -0
- package/dist/src/tui/trust-format.js +102 -0
- package/dist/src/tui/trust-format.js.map +1 -0
- package/dist/src/tui/turn-state.d.ts +1 -0
- package/dist/src/tui/turn-state.js +2 -0
- package/dist/src/tui/turn-state.js.map +1 -1
- package/package.json +2 -1
package/dist/src/tui/App.js
CHANGED
|
@@ -19,6 +19,7 @@ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, us
|
|
|
19
19
|
import { AGENTS_FILENAME } from '../agent/instructions.js';
|
|
20
20
|
import { APPROVAL_MODES, describeApprovalMode, isApprovalMode, } from '../agent/permission.js';
|
|
21
21
|
import { compactAndRecord, compactFocusRefusal, normalizeCompactFocus } from '../agent/compact.js';
|
|
22
|
+
import { permissionTestReport } from '../permissions-test.js';
|
|
22
23
|
import { formatUsageValue, sumUsage, usageBuckets, usageRows, cacheEffectivenessRows } from '../agent/usage.js';
|
|
23
24
|
import { describeModelCosts } from '../agent/cost.js';
|
|
24
25
|
import { averageRequestInputTokens } from '../agent/call-stats.js';
|
|
@@ -38,6 +39,7 @@ import { DARWIN_DIRNAME } from '../paths.js';
|
|
|
38
39
|
import { readBackgroundTail, readBackgroundTails } from '../tools/background-tail.js';
|
|
39
40
|
import { formatShellEnvNotice } from '../tools/shell-env.js';
|
|
40
41
|
import { exportTranscript } from '../trajectory/export.js';
|
|
42
|
+
import { loadRewindHistory } from '../trajectory/rewind-history.js';
|
|
41
43
|
import { readPromptHistory, } from '../trajectory/prompt-history.js';
|
|
42
44
|
import { InputBox, MAX_COMPLETIONS, completionSelection, moveCompletionSelection, } from './InputBox.js';
|
|
43
45
|
import { busySuffix } from './busy-suffix.js';
|
|
@@ -47,10 +49,11 @@ import { fenceOpenAfter } from './markdown.js';
|
|
|
47
49
|
import { PERMISSION_BOX_FIXED_ROWS, frameBudget, promptBoxWanted, queueListWanted, toolDetailsVisible, toolInputRows, toolPanelWanted, } from './frame-budget.js';
|
|
48
50
|
import { MessageList } from './MessageList.js';
|
|
49
51
|
import { PermissionPrompt, permissionBoxClaim } from './PermissionPrompt.js';
|
|
52
|
+
import { PermissionRulePreview, ruleReviewClaim, ruleReviewLayout } from './permission-rule-preview.js';
|
|
50
53
|
import { welcomeLayout } from './WelcomeHeader.js';
|
|
51
54
|
import { ActiveToolCalls } from './ToolCallPanel.js';
|
|
52
55
|
import { QueuedMessages } from './QueuedMessages.js';
|
|
53
|
-
import { backspaceAtCursor, deleteAtCursor, deleteWordAfter, deleteWordBefore, insertAtCursor, killToRowEdge, layoutEditor, moveHorizontal, moveToRowEdge, moveVertical, moveWordHorizontal, popUndo, pushUndo, } from './prompt-editor.js';
|
|
56
|
+
import { backspaceAtCursor, deleteAtCursor, deleteWordAfter, deleteWordBefore, insertAtCursor, killToRowEdge, layoutEditor, moveHorizontal, moveToRowEdge, moveVertical, moveWordHorizontal, popUndo, pushUndo, updateLastCut, LAST_CUT_OVERFLOW_NOTICE, } from './prompt-editor.js';
|
|
54
57
|
import { NO_WORKSPACE_PATHS, applyPathCompletion, scanWorkspacePaths, workspacePathsNote, } from './path-completion.js';
|
|
55
58
|
import { promptCompletionState, visiblePromptCompletions, } from './prompt-completion.js';
|
|
56
59
|
import { openPromptRecall, promptRecallIndicator, stepPromptRecall, } from './prompt-recall.js';
|
|
@@ -58,9 +61,10 @@ import { acceptPromptHistorySearch, appendPromptHistorySearchQuery, backspacePro
|
|
|
58
61
|
import { ESCAPE_REWIND_CHORD_MS, acceptRewindSearch, appendRewindSearchQuery, backspaceRewindSearchQuery, cancelRewindSearch, clearRewindSearchQuery, moveRewindSearchSelection, openRewindSearch, rewindSearchView, } from './rewind-search.js';
|
|
59
62
|
import { TANGENT_COMMAND_USAGE, armTangent, captureReturnPoint, discardedPromptCount, parseTangentCommand, rewindDraftAfterBranch, tangentCommandOutcome, tangentEndedByNotice, tangentHeaderSuffix, tangentReturnNotice, tangentStatusFact, } from './tangent.js';
|
|
60
63
|
import { clipboardImageFact, readClipboardImage } from './clipboard-image.js';
|
|
64
|
+
import { DRAFT_STASH_DROP_NOTICE, stashHint, toggleDraftStash } from './draft-stash.js';
|
|
61
65
|
import { delegationWakeEntries, hasQueuedImage, isTaskWake, partitionQueue, queuedCountHint, refusesToQueue, takeBackDraft, } from './prompt-queue.js';
|
|
62
66
|
import { composeShellReport, parseShellCommand, projectShellOutput, runShellCommand, } from './shell-command.js';
|
|
63
|
-
import { formatTaskCompletion, formatTasksReport } from './task-format.js';
|
|
67
|
+
import { formatTaskCompletion, formatTasksReport, runningTasksHeader } from './task-format.js';
|
|
64
68
|
import { TASK_WAKE_TAIL_LINES, formatTaskNotification, formatTaskWakeUndelivered, taskNotificationFields, } from './task-wake.js';
|
|
65
69
|
import { formatDispatchCancellation, formatDispatchCompletion, formatDispatchesReport, } from './subagent-format.js';
|
|
66
70
|
import { liveBackgroundDelegationRefusal } from '../agent/background-delegation.js';
|
|
@@ -73,6 +77,7 @@ import { PlanChecklist } from './PlanChecklist.js';
|
|
|
73
77
|
import { ringTerminalBell } from './terminal-bell.js';
|
|
74
78
|
import { notifyTerminal } from './terminal-notify.js';
|
|
75
79
|
import { createTerminalTitleWriter, deriveTerminalTitleState } from './terminal-title.js';
|
|
80
|
+
import { formatTrustNotice } from './trust-format.js';
|
|
76
81
|
import { initialTurnState, turnReducer } from './turn-state.js';
|
|
77
82
|
import { visualColor, visualMarker } from './visual-language.js';
|
|
78
83
|
/** Window in which a second Ctrl+C means "exit", not "cancel again". */
|
|
@@ -111,7 +116,7 @@ function normalizeDraftText(value) {
|
|
|
111
116
|
return value.replace(/\r+\n/g, '\n').replace(/\r/g, '\n').replace(NON_TEXT_CONTROLS, '');
|
|
112
117
|
}
|
|
113
118
|
export function App({ runtime: initialRuntime, permissions, initialHistory = [], startNewSession, startRewind, }) {
|
|
114
|
-
const { exit, waitUntilRenderFlush } = useApp();
|
|
119
|
+
const { exit: inkExit, waitUntilRenderFlush } = useApp();
|
|
115
120
|
const { columns, rows } = useWindowSize();
|
|
116
121
|
const { write: writeToTerminal } = useStdout();
|
|
117
122
|
// The live session. A prop at startup, state afterwards: `/clear` replaces the
|
|
@@ -139,11 +144,11 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
139
144
|
const statusRef = useRef(status);
|
|
140
145
|
statusRef.current = status;
|
|
141
146
|
const [workspacePaths, setWorkspacePaths] = useState(NO_WORKSPACE_PATHS);
|
|
142
|
-
const commandNames = useMemo(() => [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
const commandNames = useMemo(() => [...new Set([
|
|
148
|
+
...BUILTIN_COMMAND_NAMES,
|
|
149
|
+
...runtime.info.commandNames,
|
|
150
|
+
...runtime.info.skillNames,
|
|
151
|
+
])], [runtime]);
|
|
147
152
|
// Escape suppresses one computed query generation, not the draft. Mirrors are
|
|
148
153
|
// required for the same reason as the editor/selection mirrors: a second batched
|
|
149
154
|
// key must see the first Escape before React commits its render.
|
|
@@ -182,6 +187,23 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
182
187
|
attachedImageRef.current = next;
|
|
183
188
|
setAttachedImageState(next);
|
|
184
189
|
}, []);
|
|
190
|
+
// SER-085: one unsent composer snapshot, never passed to submit/runtime/records.
|
|
191
|
+
const [draftStash, setDraftStashState] = useState(undefined);
|
|
192
|
+
const draftStashRef = useRef(draftStash);
|
|
193
|
+
const setDraftStash = useCallback((next) => {
|
|
194
|
+
draftStashRef.current = next;
|
|
195
|
+
setDraftStashState(next);
|
|
196
|
+
}, []);
|
|
197
|
+
const exit = useCallback(() => {
|
|
198
|
+
if (draftStashRef.current === undefined) {
|
|
199
|
+
inkExit();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
setDraftStash(undefined);
|
|
203
|
+
dispatch({ type: 'notice', text: DRAFT_STASH_DROP_NOTICE });
|
|
204
|
+
// Let the bounded notice reach Static before Ink unmounts the composer.
|
|
205
|
+
void waitUntilRenderFlush().finally(() => inkExit());
|
|
206
|
+
}, [dispatch, inkExit, setDraftStash, waitUntilRenderFlush]);
|
|
185
207
|
const layout = layoutEditor(draft, columns, editor.cursor);
|
|
186
208
|
const preferredColumn = useRef(undefined);
|
|
187
209
|
// Composer undo (SER-044): the drafts destroyed by kill/word-delete chords,
|
|
@@ -189,6 +211,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
189
211
|
// editor's ownership (submit, queue take-back, recall walk, search accept),
|
|
190
212
|
// so Ctrl+_ can never resurrect a prompt that was already sent or recorded.
|
|
191
213
|
const undoStack = useRef([]);
|
|
214
|
+
// SER-084: one last cut, cleared at the same ownership seams as undo. Never
|
|
215
|
+
// clipboard/record/model state; typing, movement and undo leave it intact.
|
|
216
|
+
const lastCut = useRef('');
|
|
192
217
|
/**
|
|
193
218
|
* Applies one destructive editing chord: snapshots the exact draft it
|
|
194
219
|
* destroys (only when it destroys anything — a no-op kill at an edge must
|
|
@@ -200,8 +225,12 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
200
225
|
const next = edit(current);
|
|
201
226
|
if (next.text !== current.text)
|
|
202
227
|
undoStack.current = pushUndo(undoStack.current, current);
|
|
228
|
+
const cut = updateLastCut(lastCut.current, current, next);
|
|
229
|
+
lastCut.current = cut.text;
|
|
230
|
+
if (cut.overflow)
|
|
231
|
+
dispatch({ type: 'notice', text: LAST_CUT_OVERFLOW_NOTICE, severity: 'warn' });
|
|
203
232
|
setEditor(next);
|
|
204
|
-
}, [setEditor]);
|
|
233
|
+
}, [dispatch, setEditor]);
|
|
205
234
|
// The frame's fixed furniture. Only the header is *measured*: its height depends
|
|
206
235
|
// on nothing below it, so measuring it cannot oscillate. Everything else states
|
|
207
236
|
// what it wants and `frameBudget` hands out the rows — see `frame-budget.ts` for
|
|
@@ -234,6 +263,10 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
234
263
|
const diagnosticsWarned = useRef(false);
|
|
235
264
|
/** One bounded project-memory degradation notice per runtime. */
|
|
236
265
|
const memoryWarned = useRef(false);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
if (runtime.config.agentCoreMemory !== undefined)
|
|
268
|
+
dispatch({ type: 'notice', text: runtime.cloudMemoryStatus });
|
|
269
|
+
}, [runtime, dispatch]);
|
|
237
270
|
/** True while `/clear` is assembling the successor runtime; see the handler. */
|
|
238
271
|
const clearing = useRef(false);
|
|
239
272
|
/** Kill handle of the running `!` command; undefined whenever none is running. */
|
|
@@ -312,6 +345,15 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
312
345
|
});
|
|
313
346
|
}, [dispatch]);
|
|
314
347
|
const pendingPermission = useSyncExternalStore((onChange) => permissions.subscribe(onChange), permissions.getSnapshot, permissions.getSnapshot);
|
|
348
|
+
const [ruleReview, setRuleReview] = useState();
|
|
349
|
+
const renderedRuleReview = useRef(undefined);
|
|
350
|
+
const reviewing = ruleReview?.request === pendingPermission && pendingPermission !== undefined
|
|
351
|
+
? ruleReview : undefined;
|
|
352
|
+
// Background activity is independent of the foreground turn.
|
|
353
|
+
// The manager publishes starts and terminal transitions, never output or ticks.
|
|
354
|
+
const subscribeTaskActivity = useCallback((onChange) => runtime.subscribeToBackgroundTaskActivity(onChange), [runtime]);
|
|
355
|
+
const readRunningTaskCount = useCallback(() => runtime.runningBackgroundTaskCount, [runtime]);
|
|
356
|
+
const runningTaskCount = useSyncExternalStore(subscribeTaskActivity, readRunningTaskCount, readRunningTaskCount);
|
|
315
357
|
// A pending confirmation outranks streaming: the loop is blocked on it.
|
|
316
358
|
const effectiveStatus = pendingPermission !== undefined ? 'awaiting-permission' : status;
|
|
317
359
|
// Built-ins stay first, then project commands, then skills. Collision filtering
|
|
@@ -453,16 +495,25 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
453
495
|
// a `/tangent` return (SER-083) both land here, so the terminal clear, the editor
|
|
454
496
|
// hand-back rule, the per-session latches and the omission notice cannot drift.
|
|
455
497
|
// The only difference between the two is the draft: `rewindDraftAfterBranch`.
|
|
456
|
-
const adoptBranchSuccessor = useCallback((next, kind,
|
|
498
|
+
const adoptBranchSuccessor = useCallback(async (next, kind, checkpoint, sourceSessionId) => {
|
|
499
|
+
// The predecessor is retired, so its closing trajectory append has settled.
|
|
500
|
+
// Display-only replay cannot alter the SDK-restored conversation.
|
|
501
|
+
const history = await loadRewindHistory(next.info.projectRoot, sourceSessionId, checkpoint);
|
|
457
502
|
writeToTerminal(CLEAR_TERMINAL);
|
|
458
|
-
recordAction({ type: 'clear' });
|
|
503
|
+
recordAction({ type: 'clear', history });
|
|
459
504
|
setRuntime(next);
|
|
505
|
+
clipboardReadGeneration.current += 1;
|
|
506
|
+
if (draftStashRef.current !== undefined) {
|
|
507
|
+
setDraftStash(undefined);
|
|
508
|
+
withNoticeDiagnostics(recordAction, next.diagnostics)({ type: 'notice', text: DRAFT_STASH_DROP_NOTICE });
|
|
509
|
+
}
|
|
460
510
|
setRewindSearch(undefined);
|
|
461
511
|
// The restored session replaces the whole editor state; the selected prompt
|
|
462
512
|
// returns unsent (a tangent return hands back nothing — the user asked to
|
|
463
513
|
// return, not to resend), and undo must not reach across the session boundary.
|
|
464
514
|
undoStack.current = [];
|
|
465
|
-
|
|
515
|
+
lastCut.current = '';
|
|
516
|
+
const draft = rewindDraftAfterBranch(kind, checkpoint.prompt);
|
|
466
517
|
setEditor({ text: draft, cursor: { offset: draft.length, affinity: 'upstream' } });
|
|
467
518
|
setSelectedCompletion(0);
|
|
468
519
|
contextWarnLatch.current = createContextWarnLatch();
|
|
@@ -476,7 +527,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
476
527
|
text: `rewound conversation into new session ${next.info.sessionId}; source ${sourceSessionId} remains saved and resumable. ` +
|
|
477
528
|
'Workspace unchanged: workspace files, shell and ! effects, hooks, MCP writes, subagents, background jobs, and learned-memory files were not rewound.',
|
|
478
529
|
});
|
|
479
|
-
}, [recordAction, setEditor, setQueued, setRewindSearch, setSelectedCompletion, writeToTerminal]);
|
|
530
|
+
}, [recordAction, setDraftStash, setEditor, setQueued, setRewindSearch, setSelectedCompletion, writeToTerminal]);
|
|
480
531
|
// When the first no-op Escape landed on an empty idle composer; a second one
|
|
481
532
|
// within ESCAPE_REWIND_CHORD_MS opens the chooser. Cleared by any other key or
|
|
482
533
|
// owner, so the chord can never straddle a draft, a turn or a menu.
|
|
@@ -543,7 +594,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
543
594
|
: undefined;
|
|
544
595
|
const busyRetryWait = busyElapsedMs === undefined ? undefined : liveRetryWait(runtime);
|
|
545
596
|
const queuedCounts = partitionQueue(queued);
|
|
546
|
-
const
|
|
597
|
+
const statusHint = hintForStatus(effectiveStatus, busyElapsedMs === undefined ? undefined : busySuffix(busyElapsedMs, liveSpend(runtime), busyRetryWait), queuedCounts.user.length, queuedCounts.wakes.length);
|
|
598
|
+
const streamingHint = statusHint === undefined ? undefined : stashHint(statusHint, draftStash !== undefined, columns);
|
|
547
599
|
const activeToolClaims = state.activeTools.map((tool) => ({
|
|
548
600
|
detailRows: toolDetailsVisible(tool.name, state.toolDetailsExpanded)
|
|
549
601
|
? toolInputRows(tool.input, columns, tool.name).length
|
|
@@ -575,7 +627,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
575
627
|
floor: 1,
|
|
576
628
|
}
|
|
577
629
|
: {
|
|
578
|
-
wanted:
|
|
630
|
+
wanted: reviewing === undefined
|
|
631
|
+
? permissionBoxClaim(pendingPermission, permissions.waiting, columns)
|
|
632
|
+
: ruleReviewClaim(reviewing.rule, columns),
|
|
579
633
|
// The box keeps its heading, summary and decision row while it can:
|
|
580
634
|
// a question that scrolled off the frame blocks the agent loop.
|
|
581
635
|
floor: PERMISSION_BOX_FIXED_ROWS,
|
|
@@ -592,24 +646,46 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
592
646
|
// One row still names the checklist and states its full item count.
|
|
593
647
|
floor: state.livePlan.length === 0 ? 0 : 1,
|
|
594
648
|
},
|
|
595
|
-
//
|
|
596
|
-
//
|
|
597
|
-
|
|
598
|
-
queued: { wanted: queueListWanted(queued.length), floor: 0 },
|
|
649
|
+
// Typed entries keep their rows; settled-task notifications share one summary.
|
|
650
|
+
// Floor 0 — the busy hint counts both when the listing is fully cut.
|
|
651
|
+
queued: { wanted: queueListWanted(queued.length, queued.filter(isTaskWake).length), floor: 0 },
|
|
599
652
|
// The answer yields first: it is the one participant whose content is already
|
|
600
653
|
// guaranteed to reach `<Static>` history in full.
|
|
601
654
|
live: { wanted: liveTextRows === 0 ? 0 : liveTextRows + LIVE_BLOCK_CHROME_ROWS, floor: 0 },
|
|
602
655
|
});
|
|
603
|
-
//
|
|
604
|
-
//
|
|
605
|
-
|
|
606
|
-
|
|
656
|
+
// A changed viewport starts review over. An Enter may acknowledge only a page
|
|
657
|
+
// flushed by Ink, never a newly selected rule or an unrendered next page.
|
|
658
|
+
const activeRuleReview = useMemo(() => reviewing === undefined ? undefined : {
|
|
659
|
+
...reviewing,
|
|
660
|
+
offset: reviewing.columns === columns && reviewing.maxRows === grants.prompt ? reviewing.offset : 0,
|
|
661
|
+
columns,
|
|
662
|
+
maxRows: grants.prompt,
|
|
663
|
+
}, [reviewing, columns, grants.prompt]);
|
|
664
|
+
useLayoutEffect(() => {
|
|
665
|
+
renderedRuleReview.current = undefined;
|
|
666
|
+
let current = true;
|
|
667
|
+
if (reviewing !== undefined && activeRuleReview !== undefined &&
|
|
668
|
+
(reviewing.columns !== columns || reviewing.maxRows !== grants.prompt))
|
|
669
|
+
setRuleReview(activeRuleReview);
|
|
670
|
+
else if (ruleReview !== undefined && reviewing === undefined)
|
|
671
|
+
setRuleReview(undefined);
|
|
672
|
+
else if (activeRuleReview !== undefined)
|
|
673
|
+
void waitUntilRenderFlush().then(() => {
|
|
674
|
+
if (current)
|
|
675
|
+
renderedRuleReview.current = activeRuleReview;
|
|
676
|
+
}, () => { });
|
|
677
|
+
return () => { current = false; };
|
|
678
|
+
}, [activeRuleReview, reviewing, ruleReview, columns, grants.prompt, waitUntilRenderFlush]);
|
|
679
|
+
// One clock for live tools and the background-task marker, including while the
|
|
680
|
+
// foreground is idle or awaiting permission. No tick when all activity stops.
|
|
681
|
+
// `/compact` alone has no per-call tool panel to animate.
|
|
682
|
+
const animateActivity = effectiveStatus === 'streaming' || effectiveStatus === 'shell' || runningTaskCount > 0;
|
|
607
683
|
useEffect(() => {
|
|
608
|
-
if (
|
|
684
|
+
if (!animateActivity)
|
|
609
685
|
return;
|
|
610
686
|
const timer = setInterval(() => setFrame((f) => f + 1), SPINNER_INTERVAL_MS);
|
|
611
687
|
return () => clearInterval(timer);
|
|
612
|
-
}, [
|
|
688
|
+
}, [animateActivity]);
|
|
613
689
|
// A `!` command must not outlive the TUI that ran it: on unmount (Ctrl+D, /exit,
|
|
614
690
|
// a second Ctrl+C) the group gets the same TERM→KILL reaping a cancel gives it.
|
|
615
691
|
useEffect(() => () => shellRun.current?.kill(), []);
|
|
@@ -659,6 +735,16 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
659
735
|
return;
|
|
660
736
|
dispatch({ type: 'notice', text: `shell env: ${notice} — see /status` });
|
|
661
737
|
}, [dispatch, runtime]);
|
|
738
|
+
// SER-090: what the checkout declared and this session held back, said once in the
|
|
739
|
+
// transcript on the same terms — a trusted project or an empty inventory adds no
|
|
740
|
+
// line. Per runtime, so a `/clear` successor (which inherits the decision) states
|
|
741
|
+
// it again; `/status` and `/mcp` carry the same held items on their existing rows.
|
|
742
|
+
useEffect(() => {
|
|
743
|
+
const notice = formatTrustNotice(runtime.info.workspaceTrust, runtime.info.projectRoot);
|
|
744
|
+
if (notice === undefined)
|
|
745
|
+
return;
|
|
746
|
+
dispatch({ type: 'notice', text: notice, severity: 'warn' });
|
|
747
|
+
}, [dispatch, runtime]);
|
|
662
748
|
// Terminal task events are transcript-only observers: they never alter turn
|
|
663
749
|
// status, active tools, permissions, or the agent loop. React dispatch also
|
|
664
750
|
// causes an immediate idle render; cleanup prevents shutdown notices after exit.
|
|
@@ -762,6 +848,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
762
848
|
// The queue's entries replace the draft wholesale; the drafts destroyed by
|
|
763
849
|
// earlier chords are no longer what Ctrl+_ should bring back.
|
|
764
850
|
undoStack.current = [];
|
|
851
|
+
lastCut.current = '';
|
|
765
852
|
setEditor({ text, cursor: { offset: text.length, affinity: 'upstream' } });
|
|
766
853
|
preferredColumn.current = undefined;
|
|
767
854
|
setSelectedCompletion(0);
|
|
@@ -929,6 +1016,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
929
1016
|
diagnosticsWarned.current = true;
|
|
930
1017
|
dispatch({ type: 'notice', text: `diagnostics: ${diagnosticsProblem}`, severity: 'warn' });
|
|
931
1018
|
}
|
|
1019
|
+
if (runtime.config.agentCoreMemory !== undefined)
|
|
1020
|
+
dispatch({ type: 'notice', text: runtime.cloudMemoryStatus });
|
|
932
1021
|
const memoryProblem = runtime.memoryStatus?.problem;
|
|
933
1022
|
if (memoryProblem !== undefined && !memoryWarned.current) {
|
|
934
1023
|
memoryWarned.current = true;
|
|
@@ -941,6 +1030,10 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
941
1030
|
}, [prepareAnswerClose, returnQueuedToEditor, runtime, setTangent, waitUntilRenderFlush]);
|
|
942
1031
|
const submit = useCallback(async (raw, queuedEntry) => {
|
|
943
1032
|
const text = raw.trim();
|
|
1033
|
+
if (clearing.current) {
|
|
1034
|
+
dispatch({ type: 'notice', text: 'Session management in progress; submit again when it finishes' });
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
944
1037
|
// A drained entry owns its optional image, including explicit absence. It
|
|
945
1038
|
// must never borrow a newer attachment still sitting beside the editor.
|
|
946
1039
|
const image = queuedEntry === undefined ? attachedImageRef.current : queuedEntry.image;
|
|
@@ -951,6 +1044,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
951
1044
|
// that retain the draft: clearing there only loses undo history — the
|
|
952
1045
|
// failure mode this guards against is resurrecting a sent prompt.
|
|
953
1046
|
undoStack.current = [];
|
|
1047
|
+
lastCut.current = '';
|
|
954
1048
|
// A drained background-task wake (SER-069): one ordinary turn through the
|
|
955
1049
|
// same `runTurn` a prompt uses — hooks, permission gate, trajectory barrier
|
|
956
1050
|
// and `TurnComplete` all fire — but nothing above the model applies: no
|
|
@@ -1050,7 +1144,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1050
1144
|
// like /mode: this never reaches the agent, and there is no tool that can
|
|
1051
1145
|
// invoke it. Additions have no path through here; they stay exclusively
|
|
1052
1146
|
// with the permission-prompt grant flow.
|
|
1053
|
-
if (
|
|
1147
|
+
if (/^\/permissions(?:\s|$)/.test(text)) {
|
|
1054
1148
|
setEditor({ text: '', cursor: { offset: 0, affinity: 'downstream' } });
|
|
1055
1149
|
setSelectedCompletion(0);
|
|
1056
1150
|
dispatch({ type: 'userInput', text });
|
|
@@ -1061,6 +1155,25 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1061
1155
|
// narrows future context synchronously; remember is an explicit typed command,
|
|
1062
1156
|
// never a model tool. Keep it idle-only so a running request cannot race a
|
|
1063
1157
|
// system-prompt replacement.
|
|
1158
|
+
if (/^\/cloud-memory(?:\s|$)/.test(text)) {
|
|
1159
|
+
if (status !== 'idle' || clearing.current) {
|
|
1160
|
+
dispatch({ type: 'notice', text: '/cloud-memory does not queue — run it after current work finishes' });
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
clearing.current = true;
|
|
1164
|
+
setEditor({ text: '', cursor: { offset: 0, affinity: 'downstream' } });
|
|
1165
|
+
setSelectedCompletion(0);
|
|
1166
|
+
try {
|
|
1167
|
+
dispatch({ type: 'notice', text: await runtime.manageCloudMemory(text.slice('/cloud-memory'.length).trim()) });
|
|
1168
|
+
}
|
|
1169
|
+
catch (error) {
|
|
1170
|
+
dispatch({ type: 'notice', text: error instanceof Error ? error.message : 'Cloud memory context refresh failed' });
|
|
1171
|
+
}
|
|
1172
|
+
finally {
|
|
1173
|
+
clearing.current = false;
|
|
1174
|
+
}
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1064
1177
|
if (/^\/memory(?:\s|$)/.test(text)) {
|
|
1065
1178
|
if (status !== 'idle') {
|
|
1066
1179
|
dispatch({ type: 'notice', text: '/memory does not queue — run it after current work finishes' });
|
|
@@ -1224,6 +1337,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1224
1337
|
overriddenServerNames: runtime.info.mcpOverriddenServerNames,
|
|
1225
1338
|
ignoredConfigPath: runtime.info.mcpIgnoredConfigPath,
|
|
1226
1339
|
candidatePaths: [candidates.global, candidates.preferred, candidates.fallback],
|
|
1340
|
+
heldServers: runtime.info.workspaceTrust.heldMcpServers,
|
|
1227
1341
|
}),
|
|
1228
1342
|
});
|
|
1229
1343
|
return;
|
|
@@ -1241,6 +1355,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1241
1355
|
dispatch({ type: 'notice', text: '/status takes no arguments' });
|
|
1242
1356
|
return;
|
|
1243
1357
|
}
|
|
1358
|
+
await runtime.refreshCloudPolicy(); // Local-only peer policy discovery; never cloud retrieval.
|
|
1244
1359
|
// The /context machinery, degraded rather than fatal: a failed estimate
|
|
1245
1360
|
// costs one line of the report, never the report.
|
|
1246
1361
|
let context;
|
|
@@ -1263,11 +1378,13 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1263
1378
|
allowRuleCount: runtime.allowRuleCount,
|
|
1264
1379
|
denyRuleCount: runtime.denyRuleCount,
|
|
1265
1380
|
tangent: tangentStatusFact(tangentRef.current),
|
|
1381
|
+
cloudMemory: runtime.cloudMemoryStatus,
|
|
1266
1382
|
mcpServers: runtime.listMcpServers(),
|
|
1267
1383
|
skillNames: runtime.info.skillNames,
|
|
1268
1384
|
hookSources: runtime.info.hookSources,
|
|
1269
1385
|
hookShadowNotices: runtime.info.hookShadowNotices,
|
|
1270
1386
|
shellEnv: runtime.info.shellEnv,
|
|
1387
|
+
workspaceTrust: runtime.info.workspaceTrust,
|
|
1271
1388
|
projectRoot: runtime.info.projectRoot,
|
|
1272
1389
|
homeDir: os.homedir(),
|
|
1273
1390
|
trajectory: runtime.trajectoryStatus,
|
|
@@ -1475,6 +1592,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1475
1592
|
}
|
|
1476
1593
|
discarded = discardedPromptCount(outcome.state, catalogue);
|
|
1477
1594
|
next = await startRewind(outcome.state.returnPoint);
|
|
1595
|
+
await adoptBranchSuccessor(next, 'tangent', outcome.state.returnPoint, sourceSessionId);
|
|
1478
1596
|
}
|
|
1479
1597
|
catch (error) {
|
|
1480
1598
|
// Stale or unmapped row: the rewind path's own error, and the tangent stays
|
|
@@ -1489,7 +1607,6 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1489
1607
|
finally {
|
|
1490
1608
|
clearing.current = false;
|
|
1491
1609
|
}
|
|
1492
|
-
adoptBranchSuccessor(next, 'tangent', outcome.state.returnPoint.prompt, sourceSessionId);
|
|
1493
1610
|
setTangent(undefined);
|
|
1494
1611
|
withNoticeDiagnostics(recordAction, next.diagnostics)({ type: 'notice', text: tangentReturnNotice(discarded) });
|
|
1495
1612
|
return;
|
|
@@ -1552,6 +1669,10 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1552
1669
|
writeToTerminal(CLEAR_TERMINAL);
|
|
1553
1670
|
dispatch({ type: 'clear' });
|
|
1554
1671
|
setRuntime(next);
|
|
1672
|
+
if (draftStashRef.current !== undefined) {
|
|
1673
|
+
setDraftStash(undefined);
|
|
1674
|
+
withNoticeDiagnostics(recordAction, next.diagnostics)({ type: 'notice', text: DRAFT_STASH_DROP_NOTICE });
|
|
1675
|
+
}
|
|
1555
1676
|
// Per-session latches, reset with the session they were latched for.
|
|
1556
1677
|
contextWarnLatch.current = createContextWarnLatch();
|
|
1557
1678
|
trajectoryWarned.current = false;
|
|
@@ -1634,7 +1755,17 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1634
1755
|
dispatch({ type: 'notice', text: WORKFLOW_COMMAND_USAGE });
|
|
1635
1756
|
return;
|
|
1636
1757
|
}
|
|
1637
|
-
|
|
1758
|
+
// A drained entry must not erase a newer draft. Reserve its image across
|
|
1759
|
+
// asynchronous activation too, so a dequeued image cannot lose ownership.
|
|
1760
|
+
if (queuedEntry === undefined) {
|
|
1761
|
+
setEditor({ text: '', cursor: { offset: 0, affinity: 'downstream' } });
|
|
1762
|
+
}
|
|
1763
|
+
if (image !== undefined) {
|
|
1764
|
+
imageTurnInFlight.current = true;
|
|
1765
|
+
clipboardReadGeneration.current += 1;
|
|
1766
|
+
if (queuedEntry === undefined)
|
|
1767
|
+
setAttachedImage(undefined);
|
|
1768
|
+
}
|
|
1638
1769
|
setSelectedCompletion(0);
|
|
1639
1770
|
dispatch({ type: 'userInput', text });
|
|
1640
1771
|
// Skills and project commands send their expanded prompt instead of the
|
|
@@ -1651,7 +1782,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1651
1782
|
? 'delegating via the workflow tool'
|
|
1652
1783
|
: expanded.kind === 'init'
|
|
1653
1784
|
? 'writing project instructions with /init'
|
|
1654
|
-
:
|
|
1785
|
+
: expanded.kind === 'review'
|
|
1786
|
+
? 'reviewing current changes with /review'
|
|
1787
|
+
: `loaded command "/${expanded.command.name}"`,
|
|
1655
1788
|
});
|
|
1656
1789
|
toSend = expanded.message;
|
|
1657
1790
|
}
|
|
@@ -1659,9 +1792,17 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1659
1792
|
catch (error) {
|
|
1660
1793
|
dispatch({
|
|
1661
1794
|
type: 'notice',
|
|
1662
|
-
text: `could not expand ${text}: ${error instanceof Error ? error.message : String(error)}`,
|
|
1795
|
+
text: `could not expand ${text}: ${error instanceof Error ? error.message : String(error)}; prompt not sent — restored to the editor`,
|
|
1663
1796
|
severity: 'error',
|
|
1664
1797
|
});
|
|
1798
|
+
if (image !== undefined)
|
|
1799
|
+
imageTurnInFlight.current = false;
|
|
1800
|
+
// The drain already shifted this entry. Return it plus later user entries
|
|
1801
|
+
// ahead of any draft typed during activation; wakes retain their ordinary
|
|
1802
|
+
// queue disposition. No user command remains to auto-drain after failure.
|
|
1803
|
+
setQueued([{ text: raw, ...(image === undefined ? {} : { image }) }, ...queuedRef.current]);
|
|
1804
|
+
returnQueuedToEditor(true);
|
|
1805
|
+
return;
|
|
1665
1806
|
}
|
|
1666
1807
|
// Reports from `!` commands run since the last turn ride ahead of this
|
|
1667
1808
|
// prompt (PRD D5): one string through the ordinary send path, so the
|
|
@@ -1674,12 +1815,6 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1674
1815
|
// The invocation owns its image while streaming. Success consumes it; a
|
|
1675
1816
|
// provider/model rejection restores the exact image + literal prompt so the
|
|
1676
1817
|
// user can retry or remove without rereading the clipboard.
|
|
1677
|
-
if (image !== undefined)
|
|
1678
|
-
imageTurnInFlight.current = true;
|
|
1679
|
-
if (image !== undefined && queuedEntry === undefined) {
|
|
1680
|
-
clipboardReadGeneration.current += 1;
|
|
1681
|
-
setAttachedImage(undefined);
|
|
1682
|
-
}
|
|
1683
1818
|
const completed = await runTurn(toSend, text, image);
|
|
1684
1819
|
if (image !== undefined)
|
|
1685
1820
|
imageTurnInFlight.current = false;
|
|
@@ -1693,7 +1828,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1693
1828
|
severity: 'warn',
|
|
1694
1829
|
});
|
|
1695
1830
|
}
|
|
1696
|
-
}, [adoptBranchSuccessor, dispatch, exit, openRewindChooser, recordAction, returnQueuedToEditor, runtime, runTurn, setAttachedImage, setEditor, setQueued, setTangent, startNewSession, startRewind, status, writeToTerminal]);
|
|
1831
|
+
}, [adoptBranchSuccessor, dispatch, exit, openRewindChooser, recordAction, returnQueuedToEditor, runtime, runTurn, setAttachedImage, setDraftStash, setEditor, setQueued, setTangent, startNewSession, startRewind, status, writeToTerminal]);
|
|
1697
1832
|
// The drain (SER-027): when the session is idle and nothing owns the keyboard,
|
|
1698
1833
|
// the oldest queued entry goes back through the ordinary submit path — its own
|
|
1699
1834
|
// turn for a prompt, its own run for a `!`, its own `userInput` recorded at
|
|
@@ -1743,6 +1878,12 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1743
1878
|
* tool call they just approved.
|
|
1744
1879
|
*/
|
|
1745
1880
|
const answerPermission = useCallback((decision) => {
|
|
1881
|
+
// The queue may have withdrawn/replaced the rendered question before React
|
|
1882
|
+
// handles this key. Neither answer nor persistence may target its successor.
|
|
1883
|
+
if (pendingPermission === undefined || permissions.current !== pendingPermission || pendingPermission.withdrawn.aborted)
|
|
1884
|
+
return;
|
|
1885
|
+
renderedRuleReview.current = undefined;
|
|
1886
|
+
setRuleReview(undefined);
|
|
1746
1887
|
permissions.answer(decision);
|
|
1747
1888
|
const rule = decision.rule;
|
|
1748
1889
|
if (rule === undefined)
|
|
@@ -1761,7 +1902,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1761
1902
|
severity: 'warn',
|
|
1762
1903
|
});
|
|
1763
1904
|
});
|
|
1764
|
-
}, [permissions, runtime]);
|
|
1905
|
+
}, [pendingPermission, permissions, runtime]);
|
|
1765
1906
|
/** Any edit ends the walk: the draft is the user's again, not an entry from the record. */
|
|
1766
1907
|
const endRecall = useCallback(() => {
|
|
1767
1908
|
if (recallRef.current !== undefined)
|
|
@@ -1814,6 +1955,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1814
1955
|
// A recalled record entry replaces the draft: the recall walk keeps its own
|
|
1815
1956
|
// snapshot behavior, and undo must not cross into a different prompt's text.
|
|
1816
1957
|
undoStack.current = [];
|
|
1958
|
+
lastCut.current = '';
|
|
1817
1959
|
setEditor({ text, cursor: { offset: text.length, affinity: 'upstream' } });
|
|
1818
1960
|
preferredColumn.current = undefined;
|
|
1819
1961
|
// A recalled `/…` prompt reopens the command menu, so the selection has to start
|
|
@@ -1855,7 +1997,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1855
1997
|
const value = editorRef.current;
|
|
1856
1998
|
if (current === undefined) {
|
|
1857
1999
|
// Only from an empty draft: typed text is never replaced by a recalled prompt,
|
|
1858
|
-
//
|
|
2000
|
+
// independently of the explicit Ctrl+S stash.
|
|
1859
2001
|
if (direction !== 'older' || value.text !== '')
|
|
1860
2002
|
return false;
|
|
1861
2003
|
// A reading that a finished turn has marked stale — or one still arriving — opens a
|
|
@@ -1927,6 +2069,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1927
2069
|
// Escape-restore snapshot stays untouched, but undo must not reach
|
|
1928
2070
|
// back into the pre-search draft from a different text.
|
|
1929
2071
|
undoStack.current = [];
|
|
2072
|
+
lastCut.current = '';
|
|
1930
2073
|
setEditor(accepted);
|
|
1931
2074
|
setSelectedCompletion(0);
|
|
1932
2075
|
preferredColumn.current = undefined;
|
|
@@ -1969,6 +2112,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1969
2112
|
let next;
|
|
1970
2113
|
try {
|
|
1971
2114
|
next = await startRewind(selected);
|
|
2115
|
+
await adoptBranchSuccessor(next, 'rewind', selected, search.sourceSessionId);
|
|
1972
2116
|
}
|
|
1973
2117
|
catch (error) {
|
|
1974
2118
|
dispatch({
|
|
@@ -1981,7 +2125,6 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1981
2125
|
finally {
|
|
1982
2126
|
clearing.current = false;
|
|
1983
2127
|
}
|
|
1984
|
-
adoptBranchSuccessor(next, 'rewind', selected.prompt, search.sourceSessionId);
|
|
1985
2128
|
// A tangent bookmarked the conversation just left behind (SER-083): it ends
|
|
1986
2129
|
// with one notice, and the rewind the user chose is the only rewind performed.
|
|
1987
2130
|
if (tangentRef.current !== undefined) {
|
|
@@ -2083,17 +2226,40 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2083
2226
|
}
|
|
2084
2227
|
// Confirmations take the keyboard while one is pending.
|
|
2085
2228
|
if (pendingPermission !== undefined) {
|
|
2086
|
-
if (
|
|
2229
|
+
if (permissions.current !== pendingPermission || pendingPermission.withdrawn.aborted)
|
|
2230
|
+
return;
|
|
2231
|
+
// Ctrl+Y is a composer chord, never plain approval. y stays once-only even
|
|
2232
|
+
// during review; Esc still denies (b is the non-denying way back).
|
|
2233
|
+
if ((typed === 'y' || typed === 'Y') && !key.ctrl && !key.meta)
|
|
2087
2234
|
answerPermission({ allowed: true });
|
|
2088
2235
|
else if (typed === 'n' || typed === 'N' || key.escape)
|
|
2089
2236
|
answerPermission({ allowed: false });
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2237
|
+
else if (!key.ctrl && !key.meta && typed === 'b' && reviewing !== undefined) {
|
|
2238
|
+
renderedRuleReview.current = undefined;
|
|
2239
|
+
setRuleReview(undefined);
|
|
2240
|
+
}
|
|
2241
|
+
else if (!key.ctrl && !key.meta && key.return && reviewing !== undefined) {
|
|
2242
|
+
const shown = renderedRuleReview.current;
|
|
2243
|
+
if (shown === undefined || shown !== activeRuleReview)
|
|
2244
|
+
return;
|
|
2245
|
+
const page = ruleReviewLayout(shown.rule, columns, grants.prompt, shown.offset);
|
|
2246
|
+
if (!page.ready)
|
|
2247
|
+
return;
|
|
2248
|
+
renderedRuleReview.current = undefined;
|
|
2249
|
+
if (page.end < page.total)
|
|
2250
|
+
setRuleReview({ ...shown, offset: page.end });
|
|
2251
|
+
else
|
|
2252
|
+
answerPermission({ allowed: true, rule: shown.rule });
|
|
2253
|
+
}
|
|
2254
|
+
// Lowercase reviews the narrow offer; uppercase reviews the whole tool.
|
|
2255
|
+
// Selection alone never resolves the call or writes a rule.
|
|
2256
|
+
else if (!key.ctrl && !key.meta && (typed === 'a' || typed === 'A')) {
|
|
2093
2257
|
const suggestions = pendingPermission.suggestions;
|
|
2094
2258
|
const chosen = typed === 'a' ? suggestions[0] : suggestions[suggestions.length - 1];
|
|
2095
|
-
if (chosen !== undefined)
|
|
2096
|
-
|
|
2259
|
+
if (chosen !== undefined) {
|
|
2260
|
+
renderedRuleReview.current = undefined;
|
|
2261
|
+
setRuleReview({ request: pendingPermission, rule: chosen.rule, offset: 0, columns, maxRows: grants.prompt });
|
|
2262
|
+
}
|
|
2097
2263
|
}
|
|
2098
2264
|
return;
|
|
2099
2265
|
}
|
|
@@ -2121,6 +2287,29 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2121
2287
|
openHistorySearch();
|
|
2122
2288
|
return;
|
|
2123
2289
|
}
|
|
2290
|
+
// Explicit stash owns no automatic send/queue path. Raw-mode Ctrl+S arrives
|
|
2291
|
+
// here like the other composer chords, after every modal key owner.
|
|
2292
|
+
if (key.ctrl && typed === 's') {
|
|
2293
|
+
const result = toggleDraftStash({ editor: editorRef.current, image: attachedImageRef.current }, draftStashRef.current, imageTurnInFlight.current || hasQueuedImage(queuedRef.current));
|
|
2294
|
+
if (result.action === 'inert')
|
|
2295
|
+
return;
|
|
2296
|
+
if (result.action === 'refused') {
|
|
2297
|
+
dispatch({ type: 'notice', text: result.notice, severity: 'warn' });
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
clipboardReadGeneration.current += 1;
|
|
2301
|
+
undoStack.current = [];
|
|
2302
|
+
lastCut.current = '';
|
|
2303
|
+
preferredColumn.current = undefined;
|
|
2304
|
+
setRecall(undefined);
|
|
2305
|
+
setDismissedCompletion(undefined);
|
|
2306
|
+
setSelectedCompletion(0);
|
|
2307
|
+
setDraftStash(result.slot);
|
|
2308
|
+
setAttachedImage(result.composer.image);
|
|
2309
|
+
setEditor(result.composer.editor);
|
|
2310
|
+
dispatch({ type: 'notice', text: `draft ${result.action === 'stored' ? 'stashed' : 'restored'} — not sent` });
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2124
2313
|
// Clipboard image attachment is editor ownership, below permission,
|
|
2125
2314
|
// compaction and search modes. Ctrl+O toggles without editing draft text.
|
|
2126
2315
|
if (key.ctrl && typed === 'o') {
|
|
@@ -2129,6 +2318,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2129
2318
|
setAttachedImage(undefined);
|
|
2130
2319
|
dispatch({ type: 'notice', text: 'clipboard image removed from the next prompt' });
|
|
2131
2320
|
}
|
|
2321
|
+
else if (draftStashRef.current?.image !== undefined) {
|
|
2322
|
+
dispatch({ type: 'notice', text: 'one clipboard image is stashed — restore it before attaching another' });
|
|
2323
|
+
}
|
|
2132
2324
|
else if (imageTurnInFlight.current || hasQueuedImage(queuedRef.current)) {
|
|
2133
2325
|
dispatch({ type: 'notice', text: 'one clipboard image is already queued or sending — take it back or let it finish first' });
|
|
2134
2326
|
}
|
|
@@ -2191,6 +2383,17 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2191
2383
|
preferredColumn.current = undefined;
|
|
2192
2384
|
return;
|
|
2193
2385
|
}
|
|
2386
|
+
// Yank is insertion, not snapshot restoration: keep intervening edits and
|
|
2387
|
+
// the cut for repeated use, without changing SER-044's destructive-only undo.
|
|
2388
|
+
if (key.ctrl && typed === 'y') {
|
|
2389
|
+
if (lastCut.current !== '') {
|
|
2390
|
+
setEditor((current) => insertAtCursor(current, lastCut.current));
|
|
2391
|
+
preferredColumn.current = undefined;
|
|
2392
|
+
setSelectedCompletion(0);
|
|
2393
|
+
endRecall();
|
|
2394
|
+
}
|
|
2395
|
+
return;
|
|
2396
|
+
}
|
|
2194
2397
|
// Composer undo (SER-044). Most terminals send both Ctrl+_ and Ctrl+- as
|
|
2195
2398
|
// byte 0x1f, which Ink's legacy parser reports as the bare unit separator
|
|
2196
2399
|
// with no modifier flags; the kitty protocol reports a real ctrl chord.
|
|
@@ -2410,12 +2613,22 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2410
2613
|
const text = normalizeDraftText(pasted);
|
|
2411
2614
|
if (text === '')
|
|
2412
2615
|
return;
|
|
2616
|
+
// Ink delivers paste separately from keys. Use immediate owners/updates so
|
|
2617
|
+
// batched paste and key events filter the same query, never the held draft.
|
|
2618
|
+
if (rewindSearchRef.current !== undefined) {
|
|
2619
|
+
updateRewindSearch((current) => appendRewindSearchQuery(current, text));
|
|
2620
|
+
return;
|
|
2621
|
+
}
|
|
2622
|
+
if (historySearchRef.current !== undefined) {
|
|
2623
|
+
updateHistorySearch((current) => appendPromptHistorySearchQuery(current, text));
|
|
2624
|
+
return;
|
|
2625
|
+
}
|
|
2413
2626
|
setEditor((current) => insertAtCursor(current, text));
|
|
2414
2627
|
preferredColumn.current = undefined;
|
|
2415
2628
|
setSelectedCompletion(0);
|
|
2416
2629
|
endRecall();
|
|
2417
2630
|
});
|
|
2418
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame, tangent: tangent }) }), _jsx(MessageList, { history: state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsxs(Box, { ref: chromeRef, flexDirection: "column", children: [state.thinking && effectiveStatus === 'streaming' && (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: `thinking…${busyElapsedMs === undefined ? '' : busySuffix(busyElapsedMs, undefined, busyRetryWait)}` })), _jsx(ActiveToolCalls, { tools: state.activeTools, frame: frame, toolDetailsExpanded: state.toolDetailsExpanded, columns: columns, maxRows: grants.tools }), _jsx(PlanChecklist, { plan: state.livePlan, maxRows: grants.plan }), _jsx(QueuedMessages, { entries: queued, maxRows: grants.queued }), pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, completions: completions, completionKind: completionKind, completionNote: completionNote, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
|
|
2631
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame, tangent: tangent, runningTaskCount: runningTaskCount, draftStashed: statusHint === undefined && draftStash !== undefined }) }), _jsx(MessageList, { history: state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsxs(Box, { ref: chromeRef, flexDirection: "column", children: [state.thinking && effectiveStatus === 'streaming' && (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: `thinking…${busyElapsedMs === undefined ? '' : busySuffix(busyElapsedMs, undefined, busyRetryWait)}` })), _jsx(ActiveToolCalls, { tools: state.activeTools, frame: frame, toolDetailsExpanded: state.toolDetailsExpanded, columns: columns, maxRows: grants.tools }), _jsx(PlanChecklist, { plan: state.livePlan, maxRows: grants.plan }), _jsx(QueuedMessages, { entries: queued, maxRows: grants.queued }), activeRuleReview !== undefined ? _jsx(PermissionRulePreview, { review: activeRuleReview }) : pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, completions: completions, completionKind: completionKind, completionNote: completionNote, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
|
|
2419
2632
|
}
|
|
2420
2633
|
/** The hint row under the draft, or nothing when the session is idle. */
|
|
2421
2634
|
function hintForStatus(status, busyReadout, queuedCount = 0, queuedWakeCount = 0) {
|
|
@@ -2464,15 +2677,19 @@ function lastRetryOutcome(runtime) {
|
|
|
2464
2677
|
return undefined;
|
|
2465
2678
|
}
|
|
2466
2679
|
}
|
|
2467
|
-
export function Header({ runtime, status = 'idle', frame = 0, tangent, }) {
|
|
2680
|
+
export function Header({ runtime, status = 'idle', frame = 0, tangent, runningTaskCount = 0, draftStashed = false, }) {
|
|
2681
|
+
const { columns } = useWindowSize();
|
|
2468
2682
|
const info = runtime.info;
|
|
2469
2683
|
const instructions = info.projectInstructions;
|
|
2470
2684
|
// Live, not info.permissionMode: /mode moves it mid-session, and a header still
|
|
2471
2685
|
// naming the startup policy would be worse than no header — this row is the only
|
|
2472
2686
|
// place the effective mode is stated, and it must not gain a second one.
|
|
2473
2687
|
const mode = runtime.permissionMode;
|
|
2474
|
-
|
|
2475
|
-
|
|
2688
|
+
const stateLabel = status === 'streaming' ? 'working' : headerStatus(status);
|
|
2689
|
+
const tangentSuffix = tangentHeaderSuffix(tangent);
|
|
2690
|
+
const activity = runningTasksHeader(runningTaskCount, columns - `◆ DARWIN · ${stateLabel}${tangentSuffix}`.length, frame);
|
|
2691
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: visualColor.identity, bold: true, children: [visualMarker.identity, " DARWIN"] }), _jsxs(Text, { dimColor: true, children: [' · ', status === 'streaming' ? _jsx(WorkingStatus, { frame: frame }) : headerStatus(status), tangentSuffix] }), _jsx(Text, { color: visualColor.active, children: activity.label }), _jsx(Text, { dimColor: true, children: activity.hint })] }), _jsxs(Text, { dimColor: true, children: [runtime.config.provider, "/", runtime.config.model, " \u00B7 session ", info.sessionId, info.resumed ? ' (resumed)' : '', formatPromptCache(runtime.promptCache), formatThinking(runtime.thinking)] }), mode === 'yolo' ? (_jsxs(Text, { color: visualColor.warning, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })) : mode === 'plan' ? (_jsxs(Text, { color: visualColor.warning, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })) : (_jsxs(Text, { dimColor: true, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })), instructions !== undefined &&
|
|
2692
|
+
(instructions.truncated ? (_jsx(Text, { color: visualColor.warning, children: formatInstructionsLoadedRow(instructions) })) : (_jsx(Text, { dimColor: true, children: formatInstructionsLoadedRow(instructions) }))), info.projectInstructionsProblem !== undefined && (_jsx(Text, { color: visualColor.warning, children: formatInstructionsProblemRow(info.projectInstructionsProblemFile ?? AGENTS_FILENAME, info.projectInstructionsProblem) })), info.systemPromptSource === 'config' && (_jsxs(Text, { dimColor: true, children: ["system prompt: overridden by ", DARWIN_DIRNAME, "/", CONFIG_FILENAME] })), info.systemPromptSource === 'file' && (_jsxs(Text, { dimColor: true, children: ["system prompt: ", DARWIN_DIRNAME, "/", SYSTEM_PROMPT_FILENAME] })), info.systemPromptProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["system prompt: using the default \u2014 ", info.systemPromptProblem] })), info.workingContextProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["working context: no directory listing \u2014 ", info.workingContextProblem] })), info.promptCache.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["prompt cache: off \u2014 ", info.promptCache.problem] })), runtime.thinking.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["thinking: ", runtime.thinking.problem] })), hasCapabilities(info) && (_jsxs(Text, { dimColor: true, children: ["loaded: ", formatCapabilities(info), " \u00B7 type / for commands"] })), info.mcpIgnoredConfigPath !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["mcp: using ", DARWIN_DIRNAME, "/", MCP_CONFIG_FILENAME, " \u2014 ", info.mcpIgnoredConfigPath, " ignored"] })), info.hookShadowNotices.map((notice) => (_jsxs(Text, { color: visualColor.warning, wrap: "truncate-end", children: ["hooks: ", notice.layer, " ", notice.directory, " shadows ", notice.shadowed.join(', ')] }, notice.directory))), info.skillProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["skill skipped: ", problem.directory, " \u2014 ", problem.reason] }, problem.directory))), info.commandProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["command skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), info.agentProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["agent skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), _jsx(Text, { dimColor: true, children: stashHint('/ for actions · @ for paths · ctrl+c cancels · /exit quits', draftStashed, columns) })] }));
|
|
2476
2693
|
}
|
|
2477
2694
|
const WORKING_LABEL = 'working';
|
|
2478
2695
|
/** Highlights one letter in place, preserving the header's exact width and row count. */
|
|
@@ -2851,7 +3068,23 @@ export function formatPermissionRulesReport(entries, rulesFile, denyRules) {
|
|
|
2851
3068
|
*/
|
|
2852
3069
|
export function applyPermissionsCommand(runtime, text, dispatch) {
|
|
2853
3070
|
const argument = text.slice('/permissions'.length).trim();
|
|
2854
|
-
const usage = 'usage: /permissions — list allow- and deny-rules · /permissions revoke <n|rule|all> (allow-rules only)';
|
|
3071
|
+
const usage = 'usage: /permissions — list allow- and deny-rules · /permissions revoke <n|rule|all> (allow-rules only) · /permissions test <rule>';
|
|
3072
|
+
// Consume the remaining string intact; splitting/joining would change bash patterns.
|
|
3073
|
+
if (/^test(?:\s|$)/i.test(argument)) {
|
|
3074
|
+
const rule = argument.slice(4).trim();
|
|
3075
|
+
if (rule === '') {
|
|
3076
|
+
dispatch({ type: 'notice', text: `test needs a rule\n ${usage}` });
|
|
3077
|
+
return;
|
|
3078
|
+
}
|
|
3079
|
+
const status = runtime.trajectoryStatus;
|
|
3080
|
+
void permissionTestReport(rule, {
|
|
3081
|
+
projectRoot: runtime.info.projectRoot,
|
|
3082
|
+
sessionId: runtime.info.sessionId,
|
|
3083
|
+
denyRules: [...runtime.listDenyRules()],
|
|
3084
|
+
recording: status === undefined ? 'disabled' : status.active ? 'active' : 'stopped',
|
|
3085
|
+
}).then(text => dispatch({ type: 'notice', text }), () => dispatch({ type: 'notice', text: 'permissions test: evidence unavailable; no rules changed' }));
|
|
3086
|
+
return;
|
|
3087
|
+
}
|
|
2855
3088
|
if (argument === '') {
|
|
2856
3089
|
dispatch({
|
|
2857
3090
|
type: 'notice',
|