@causyne/agent 1.20.68 → 1.20.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agentLoop.js +26 -11
- package/src/agentLoop.ts +26 -11
- package/src/cliMode.js +8 -5
- package/src/providers/antigravity.js +52 -12
- package/src/providers/antigravity.ts +47 -16
- package/src/tui/consoleGuard.js +15 -0
- package/src/tui/consoleGuard.ts +15 -0
- package/src/tui/prompt.js +3 -0
- package/src/tui/stage.js +4 -2
- package/src/tui/stageSurface.js +35 -1
- package/src/tui/text.js +25 -2
- package/src/tui/text.ts +24 -2
package/package.json
CHANGED
package/src/agentLoop.js
CHANGED
|
@@ -54,6 +54,7 @@ import path from 'path';
|
|
|
54
54
|
import { analyzeFiles, formatFindings, isScannableFile } from './slopDetector.js';
|
|
55
55
|
import { suggestMovements, formatMovementBrief } from './designPalettes.js';
|
|
56
56
|
import { createProvider } from './providers/factory.js';
|
|
57
|
+
import { isNativeMutation } from './providers/antigravity.js';
|
|
57
58
|
import { resolveMentionedContext } from './promptMentions.js';
|
|
58
59
|
import { isLaunchOnlyPrompt, launchScopeError } from './launchIntent.js';
|
|
59
60
|
import { StreamingCodePreview, NativeCodeObserver, codeProgressFromAction } from './tui/codeProgress.js';
|
|
@@ -1890,6 +1891,7 @@ export class AgentLoop {
|
|
|
1890
1891
|
const recoveryPaths = new Set();
|
|
1891
1892
|
let modelCallIndex = 0;
|
|
1892
1893
|
let mediaExplorationRecoveries = 0;
|
|
1894
|
+
let taskMutationCount = 0;
|
|
1893
1895
|
let reasoningOnlyRecoveries = 0;
|
|
1894
1896
|
let planHandoffRecoveries = 0;
|
|
1895
1897
|
let incompleteTurnContinuations = 0;
|
|
@@ -2438,8 +2440,12 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2438
2440
|
auditLog.log({ event: 'native_action', taskId: this.taskId,
|
|
2439
2441
|
provider: this.config.provider || 'unknown', tool: action.name, status: action.status,
|
|
2440
2442
|
...(action.id ? { actionId: action.id } : {}) });
|
|
2441
|
-
if (action.status === 'completed' &&
|
|
2442
|
-
|
|
2443
|
+
if (action.status === 'completed' && !isChecklistTool) {
|
|
2444
|
+
const actionKey = action.id ? String(action.id) : `${action.name}:${completedNativeActionIds.size}`;
|
|
2445
|
+
if (!completedNativeActionIds.has(actionKey)) {
|
|
2446
|
+
completedNativeActionIds.add(actionKey);
|
|
2447
|
+
this.stepsCompleted++;
|
|
2448
|
+
}
|
|
2443
2449
|
}
|
|
2444
2450
|
const isCompleted = action.status === 'completed';
|
|
2445
2451
|
const isFailed = action.status === 'failed';
|
|
@@ -2501,8 +2507,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2501
2507
|
const lowerName = action.name.toLowerCase();
|
|
2502
2508
|
const rawDetail = String(action.detail || '');
|
|
2503
2509
|
const lowerDetail = rawDetail.toLowerCase();
|
|
2504
|
-
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2510
|
+
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2511
|
+
|| isNativeMutation(action.name, actionArgs)) {
|
|
2505
2512
|
nativeMutationCount++;
|
|
2513
|
+
taskMutationCount++;
|
|
2514
|
+
mediaExplorationRecoveries = 0;
|
|
2506
2515
|
if (nativeMutationCount === 1 && this._implementationPlanSeeded) {
|
|
2507
2516
|
this.advanceImplementationPlanProgress('mutation');
|
|
2508
2517
|
}
|
|
@@ -2793,7 +2802,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2793
2802
|
const hasExternalActions = completedExternalActions.length > 0;
|
|
2794
2803
|
const isIncompleteTurn = Boolean(response.incompleteTurn);
|
|
2795
2804
|
if (hasExternalActions) {
|
|
2796
|
-
this.stepsCompleted += completedExternalActions.length;
|
|
2805
|
+
this.stepsCompleted += Math.max(0, completedExternalActions.length - completedNativeActionIds.size);
|
|
2797
2806
|
for (const extAction of completedExternalActions) {
|
|
2798
2807
|
const extPlan = normalizePeerPlanEntries(extAction.parameters);
|
|
2799
2808
|
if (extPlan) {
|
|
@@ -4478,17 +4487,23 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4478
4487
|
}
|
|
4479
4488
|
if (e?.code === 'AGY_EXPLORATION_LOOP' || e?.code === 'AGENT_EXPLORATION_LOOP' || e?.code === 'STALL_EXPLORATION_LOOP') {
|
|
4480
4489
|
auditLog.log({ event: 'media_exploration_checkpoint', taskId: this.taskId,
|
|
4481
|
-
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries });
|
|
4490
|
+
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries, mutations: taskMutationCount });
|
|
4482
4491
|
if (mediaExplorationRecoveries++ === 0) {
|
|
4483
|
-
this.messages.push({ role: 'system', content:
|
|
4484
|
-
'
|
|
4485
|
-
'
|
|
4486
|
-
|
|
4492
|
+
this.messages.push({ role: 'system', content: taskMutationCount > 0
|
|
4493
|
+
? '[TASK RECOVERY] Repeated identical tool polling or inspection was paused after workspace edits. Do not repeat identical probes; verify the completed changes once and present the final result.'
|
|
4494
|
+
: '[TASK RECOVERY] Consecutive read-only inspections without workspace changes were paused. ' +
|
|
4495
|
+
'The user requested a concrete change. Reuse the observations already gathered; do not repeat probes. ' +
|
|
4496
|
+
'Make one targeted workspace edit now, then run one focused verification. ' +
|
|
4497
|
+
'If editing is blocked, report the exact blocker. Do not claim completion from inspection alone.' });
|
|
4487
4498
|
this.memoryManager.saveHistory(this.messages);
|
|
4488
|
-
this.emitEvent({ type: 'notice', message:
|
|
4499
|
+
this.emitEvent({ type: 'notice', message: taskMutationCount > 0
|
|
4500
|
+
? 'Repeated status probe paused; continuing from completed workspace edits.'
|
|
4501
|
+
: 'Repeated inspection paused; continuing once with a direct edit instruction.' });
|
|
4489
4502
|
continue;
|
|
4490
4503
|
}
|
|
4491
|
-
this.emitEvent({ type: 'error', message:
|
|
4504
|
+
this.emitEvent({ type: 'error', message: taskMutationCount > 0
|
|
4505
|
+
? 'The provider repeated an identical tool call after a recovery checkpoint. Workspace edits are preserved on disk.'
|
|
4506
|
+
: 'The provider continued read-only inspection after a corrective checkpoint. The task remains unfinished; no edit was verified.' });
|
|
4492
4507
|
break;
|
|
4493
4508
|
}
|
|
4494
4509
|
if (e?.code === 'PROVIDER_EMPTY_RESPONSE'
|
package/src/agentLoop.ts
CHANGED
|
@@ -95,6 +95,7 @@ import path from 'path';
|
|
|
95
95
|
import { analyzeFiles, formatFindings, isScannableFile } from './slopDetector.js';
|
|
96
96
|
import { suggestMovements, formatMovementBrief } from './designPalettes.js';
|
|
97
97
|
import { createProvider } from './providers/factory.js';
|
|
98
|
+
import { isNativeMutation } from './providers/antigravity.js';
|
|
98
99
|
import { resolveMentionedContext } from './promptMentions.js';
|
|
99
100
|
import { isLaunchOnlyPrompt, launchScopeError } from './launchIntent.js';
|
|
100
101
|
import { StreamingCodePreview, NativeCodeObserver, codeProgressFromAction } from './tui/codeProgress.js';
|
|
@@ -1976,6 +1977,7 @@ export class AgentLoop {
|
|
|
1976
1977
|
const recoveryPaths = new Set<string>();
|
|
1977
1978
|
let modelCallIndex = 0;
|
|
1978
1979
|
let mediaExplorationRecoveries = 0;
|
|
1980
|
+
let taskMutationCount = 0;
|
|
1979
1981
|
let reasoningOnlyRecoveries = 0;
|
|
1980
1982
|
let planHandoffRecoveries = 0;
|
|
1981
1983
|
let incompleteTurnContinuations = 0;
|
|
@@ -2544,8 +2546,12 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2544
2546
|
auditLog.log({ event: 'native_action', taskId: this.taskId,
|
|
2545
2547
|
provider: this.config.provider || 'unknown', tool: action.name, status: action.status,
|
|
2546
2548
|
...(action.id ? { actionId: action.id } : {}) });
|
|
2547
|
-
if (action.status === 'completed' &&
|
|
2548
|
-
|
|
2549
|
+
if (action.status === 'completed' && !isChecklistTool) {
|
|
2550
|
+
const actionKey = action.id ? String(action.id) : `${action.name}:${completedNativeActionIds.size}`;
|
|
2551
|
+
if (!completedNativeActionIds.has(actionKey)) {
|
|
2552
|
+
completedNativeActionIds.add(actionKey);
|
|
2553
|
+
this.stepsCompleted++;
|
|
2554
|
+
}
|
|
2549
2555
|
}
|
|
2550
2556
|
const isCompleted = action.status === 'completed';
|
|
2551
2557
|
const isFailed = action.status === 'failed';
|
|
@@ -2602,8 +2608,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2602
2608
|
const lowerName = action.name.toLowerCase();
|
|
2603
2609
|
const rawDetail = String(action.detail || '');
|
|
2604
2610
|
const lowerDetail = rawDetail.toLowerCase();
|
|
2605
|
-
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2611
|
+
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2612
|
+
|| isNativeMutation(action.name, actionArgs)) {
|
|
2606
2613
|
nativeMutationCount++;
|
|
2614
|
+
taskMutationCount++;
|
|
2615
|
+
mediaExplorationRecoveries = 0;
|
|
2607
2616
|
if (nativeMutationCount === 1 && this._implementationPlanSeeded) {
|
|
2608
2617
|
this.advanceImplementationPlanProgress('mutation');
|
|
2609
2618
|
} else if (nativeMutationCount % 2 === 0) {
|
|
@@ -2919,7 +2928,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2919
2928
|
const isIncompleteTurn = Boolean((response as any).incompleteTurn);
|
|
2920
2929
|
|
|
2921
2930
|
if (hasExternalActions) {
|
|
2922
|
-
this.stepsCompleted += completedExternalActions.length;
|
|
2931
|
+
this.stepsCompleted += Math.max(0, completedExternalActions.length - completedNativeActionIds.size);
|
|
2923
2932
|
for (const extAction of completedExternalActions) {
|
|
2924
2933
|
const extPlan = normalizePeerPlanEntries(extAction.parameters);
|
|
2925
2934
|
if (extPlan) {
|
|
@@ -4728,19 +4737,25 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4728
4737
|
}
|
|
4729
4738
|
if (e?.code === 'AGY_EXPLORATION_LOOP' || e?.code === 'AGENT_EXPLORATION_LOOP' || e?.code === 'STALL_EXPLORATION_LOOP') {
|
|
4730
4739
|
auditLog.log({ event: 'media_exploration_checkpoint', taskId: this.taskId,
|
|
4731
|
-
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries });
|
|
4740
|
+
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries, mutations: taskMutationCount });
|
|
4732
4741
|
if (mediaExplorationRecoveries++ === 0) {
|
|
4733
4742
|
this.messages.push({ role: 'system', content:
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4743
|
+
taskMutationCount > 0
|
|
4744
|
+
? '[TASK RECOVERY] Repeated identical tool polling or inspection was paused after workspace edits. Do not repeat identical probes; verify the completed changes once and present the final result.'
|
|
4745
|
+
: '[TASK RECOVERY] Consecutive read-only inspections without workspace changes were paused. ' +
|
|
4746
|
+
'The user requested a concrete change. Reuse the observations already gathered; do not repeat probes. ' +
|
|
4747
|
+
'Make one targeted workspace edit now, then run one focused verification. ' +
|
|
4748
|
+
'If editing is blocked, report the exact blocker. Do not claim completion from inspection alone.' });
|
|
4738
4749
|
this.memoryManager.saveHistory(this.messages);
|
|
4739
|
-
this.emitEvent({ type: 'notice', message:
|
|
4750
|
+
this.emitEvent({ type: 'notice', message: taskMutationCount > 0
|
|
4751
|
+
? 'Repeated status probe paused; continuing from completed workspace edits.'
|
|
4752
|
+
: 'Repeated inspection paused; continuing once with a direct edit instruction.' });
|
|
4740
4753
|
continue;
|
|
4741
4754
|
}
|
|
4742
4755
|
this.emitEvent({ type: 'error', message:
|
|
4743
|
-
|
|
4756
|
+
taskMutationCount > 0
|
|
4757
|
+
? 'The provider repeated an identical tool call after a recovery checkpoint. Workspace edits are preserved on disk.'
|
|
4758
|
+
: 'The provider continued read-only inspection after a corrective checkpoint. The task remains unfinished; no edit was verified.' });
|
|
4744
4759
|
break;
|
|
4745
4760
|
}
|
|
4746
4761
|
if (e?.code === 'PROVIDER_EMPTY_RESPONSE'
|
package/src/cliMode.js
CHANGED
|
@@ -637,16 +637,19 @@ export async function chatMode({ home = false } = {}) {
|
|
|
637
637
|
paint('muted', ' Run /setup or select setup from the home menu to configure your provider.\n'));
|
|
638
638
|
continue;
|
|
639
639
|
}
|
|
640
|
-
|
|
640
|
+
try {
|
|
641
|
+
await loop.run();
|
|
642
|
+
} finally {
|
|
643
|
+
conn.stopSpinner();
|
|
644
|
+
// Active skill remains persistent across turns until explicitly cleared via /skill clear or another skill is selected.
|
|
645
|
+
if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
|
|
646
|
+
conn.renderer.turnFooter(Date.now() - startedAt);
|
|
647
|
+
}
|
|
641
648
|
} finally {
|
|
642
649
|
// Must be released on the error path too, or one failed turn leaves the
|
|
643
650
|
// prompt permanently queueing and the chat looks hung.
|
|
644
651
|
if (prompt) prompt.setBusy(false);
|
|
645
652
|
}
|
|
646
|
-
conn.stopSpinner();
|
|
647
|
-
// Active skill remains persistent across turns until explicitly cleared via /skill clear or another skill is selected.
|
|
648
|
-
if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
|
|
649
|
-
conn.renderer.turnFooter(Date.now() - startedAt);
|
|
650
653
|
}
|
|
651
654
|
|
|
652
655
|
process.exit(0);
|
|
@@ -353,9 +353,13 @@ function nativeInspectionTarget(name, parameters) {
|
|
|
353
353
|
const normName = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
354
354
|
if (!/^(runcommand|command|sysrun|terminal|bash|shell)$/.test(normName)) {
|
|
355
355
|
if (/^(readfile|viewfile)$/.test(normName)) {
|
|
356
|
-
const p = String(parameters.AbsolutePath ?? parameters.filePath ?? parameters.path ?? parameters.file ?? '');
|
|
357
|
-
if (p)
|
|
358
|
-
return
|
|
356
|
+
const p = String(parameters.AbsolutePath ?? parameters.Path ?? parameters.filePath ?? parameters.path ?? parameters.file ?? '').trim().toLowerCase();
|
|
357
|
+
if (!p)
|
|
358
|
+
return null;
|
|
359
|
+
const start = parameters.StartLine ?? parameters.startLine ?? parameters.offset ?? parameters.line ?? '';
|
|
360
|
+
const end = parameters.EndLine ?? parameters.endLine ?? parameters.limit ?? '';
|
|
361
|
+
const byteOffset = parameters.ByteOffset ?? parameters.byteOffset ?? '';
|
|
362
|
+
return `${p}:${start}-${end}:${byteOffset}`;
|
|
359
363
|
}
|
|
360
364
|
return null;
|
|
361
365
|
}
|
|
@@ -390,6 +394,23 @@ function nativeInspectionTarget(name, parameters) {
|
|
|
390
394
|
}
|
|
391
395
|
return null;
|
|
392
396
|
}
|
|
397
|
+
export function isRepeatableNativeTool(name, parameters = {}) {
|
|
398
|
+
if (!name || typeof name !== 'string')
|
|
399
|
+
return false;
|
|
400
|
+
const action = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
401
|
+
if (/^(?:managetask|managesubagents|sendmessage|invokesubagent|definesubagent|schedule|tasksummary|todowrite|updateplan|askquestion|processlist|sysrunpoll|procterm|waitfortask|checkstatus)$/.test(action)) {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
if (/(?:poll|status|getresult|wait)$/.test(action)) {
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
if (/^(runcommand|command|sysrun|terminal|bash|shell)$/.test(action)) {
|
|
408
|
+
const command = cleanCommandString(parameters.CommandLine ?? parameters.command ?? parameters.cmd ?? '');
|
|
409
|
+
if (/^(?:ps\s+aux|pgrep|lsof|netstat|ss\s+-)\b/i.test(command))
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
393
414
|
export function isNativeMutation(name, parameters = {}) {
|
|
394
415
|
if (!name || typeof name !== 'string')
|
|
395
416
|
return false;
|
|
@@ -405,7 +426,7 @@ export function isNativeMutation(name, parameters = {}) {
|
|
|
405
426
|
return /\b(?:save_as_mainfile|save_mainfile|write_text|write_bytes|tee)\b/.test(command)
|
|
406
427
|
|| /(?:^|[;&|]\s*)(?:cp|mv|rm|install|patch|touch|mkdir|chmod|sed)\s/.test(command)
|
|
407
428
|
|| /(?:>|>>)/.test(command)
|
|
408
|
-
|| /\b(?:npm|yarn|pnpm|cargo|gradle|gradlew|mvn|dotnet|pip|pip3|pytest|vitest|jest|tsc|make|docker|git\s+(?:add|commit|checkout|merge|rebase|stash|pull|push))\b/i.test(command);
|
|
429
|
+
|| /\b(?:npm|npx|yarn|pnpm|bun|deno|cargo|gradle|gradlew|mvn|dotnet|pip|pip3|pytest|vitest|jest|tsc|make|cmake|ninja|docker|apktool|jadx|jarsigner|apksigner|zipalign|keytool|adb|kotlinc|javac|go|rustc|swift|xcodebuild|codesign|unzip|tar|brew|git\s+(?:add|commit|checkout|merge|rebase|stash|pull|push|restore|reset|clean|rm|mv|apply|cherry-pick|revert|tag|branch|init|clone))\b/i.test(command);
|
|
409
430
|
}
|
|
410
431
|
export function nativeToolSignature(name, parameters = {}) {
|
|
411
432
|
const normName = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
@@ -1007,6 +1028,7 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1007
1028
|
let lastToolSignature = '';
|
|
1008
1029
|
const recentSignatures = [];
|
|
1009
1030
|
const seenNativeActionSteps = new Set();
|
|
1031
|
+
const seenLoopCheckSteps = new Set();
|
|
1010
1032
|
const mediaInspectionCounts = new Map();
|
|
1011
1033
|
const pendingMediaMutations = new Set();
|
|
1012
1034
|
// Antigravity's result usage is cumulative across the conversation, but
|
|
@@ -1187,14 +1209,39 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1187
1209
|
(stepUpdate && typeof stepUpdate === 'object' && stepUpdate.parameters) ||
|
|
1188
1210
|
(toolInfo && typeof toolInfo === 'object' && toolInfo.input) ||
|
|
1189
1211
|
{};
|
|
1190
|
-
|
|
1212
|
+
const hasParams = Boolean(rawParams && typeof rawParams === 'object' && Object.keys(rawParams).length > 0);
|
|
1213
|
+
const readyForLoopCheck = state === 'DONE'
|
|
1214
|
+
|| (state === 'ACTIVE' && (hasParams || isNativeMutation(name || '', rawParams) || isRepeatableNativeTool(name || '', rawParams)));
|
|
1215
|
+
const shouldCheckLoop = Boolean(name) && readyForLoopCheck
|
|
1216
|
+
&& (!Number.isFinite(stepIndex) || !seenLoopCheckSteps.has(stepIndex));
|
|
1217
|
+
if (name && state === 'DONE' && !toolInfo?.error && isNativeMutation(name, rawParams)) {
|
|
1218
|
+
if (Number.isFinite(stepIndex))
|
|
1219
|
+
seenLoopCheckSteps.add(stepIndex);
|
|
1220
|
+
lastMutationActionIndex = nativeActionStarts + 1;
|
|
1221
|
+
progressiveActionsCount++;
|
|
1222
|
+
consecutiveIdenticalCount = 0;
|
|
1223
|
+
consecutiveInspections = 0;
|
|
1224
|
+
lastToolSignature = '';
|
|
1225
|
+
recentSignatures.length = 0;
|
|
1226
|
+
}
|
|
1227
|
+
else if (name && shouldCheckLoop) {
|
|
1228
|
+
if (Number.isFinite(stepIndex))
|
|
1229
|
+
seenLoopCheckSteps.add(stepIndex);
|
|
1191
1230
|
const mutating = isNativeMutation(name, rawParams);
|
|
1231
|
+
const repeatable = isRepeatableNativeTool(name, rawParams);
|
|
1192
1232
|
if (mutating) {
|
|
1193
1233
|
lastMutationActionIndex = nativeActionStarts + 1;
|
|
1194
1234
|
progressiveActionsCount++;
|
|
1195
1235
|
consecutiveIdenticalCount = 0;
|
|
1196
1236
|
consecutiveInspections = 0;
|
|
1197
1237
|
lastToolSignature = '';
|
|
1238
|
+
recentSignatures.length = 0;
|
|
1239
|
+
}
|
|
1240
|
+
else if (repeatable) {
|
|
1241
|
+
// Task/subagent polling, plan updates, and user questions are legitimate
|
|
1242
|
+
// coordination steps and must not count as aimless read-only loops.
|
|
1243
|
+
consecutiveIdenticalCount = 0;
|
|
1244
|
+
lastToolSignature = '';
|
|
1198
1245
|
}
|
|
1199
1246
|
else if (!desktopTask && options.taskArchetype !== 'media_3d_generation') {
|
|
1200
1247
|
consecutiveInspections++;
|
|
@@ -1224,13 +1271,6 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1224
1271
|
terminateChild();
|
|
1225
1272
|
return;
|
|
1226
1273
|
}
|
|
1227
|
-
// 3. Stagnant read-only inspection runaway without mutations on an editing task
|
|
1228
|
-
if (consecutiveInspections >= 30 && options.taskArchetype !== 'web_research_only') {
|
|
1229
|
-
const error = Object.assign(new Error(`Antigravity performed ${consecutiveInspections} consecutive read-only inspections without writing or modifying code. Halting exploration loop.`), { code: 'AGY_EXPLORATION_LOOP', inspectionCount: consecutiveInspections });
|
|
1230
|
-
safeReject(error);
|
|
1231
|
-
terminateChild();
|
|
1232
|
-
return;
|
|
1233
|
-
}
|
|
1234
1274
|
}
|
|
1235
1275
|
}
|
|
1236
1276
|
if (newNativeAction) {
|
|
@@ -357,8 +357,12 @@ function nativeInspectionTarget(name: string, parameters: Record<string, unknown
|
|
|
357
357
|
const normName = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
358
358
|
if (!/^(runcommand|command|sysrun|terminal|bash|shell)$/.test(normName)) {
|
|
359
359
|
if (/^(readfile|viewfile)$/.test(normName)) {
|
|
360
|
-
const p = String(parameters.AbsolutePath ?? parameters.filePath ?? parameters.path ?? parameters.file ?? '');
|
|
361
|
-
if (p) return
|
|
360
|
+
const p = String(parameters.AbsolutePath ?? parameters.Path ?? parameters.filePath ?? parameters.path ?? parameters.file ?? '').trim().toLowerCase();
|
|
361
|
+
if (!p) return null;
|
|
362
|
+
const start = parameters.StartLine ?? parameters.startLine ?? parameters.offset ?? parameters.line ?? '';
|
|
363
|
+
const end = parameters.EndLine ?? parameters.endLine ?? parameters.limit ?? '';
|
|
364
|
+
const byteOffset = parameters.ByteOffset ?? parameters.byteOffset ?? '';
|
|
365
|
+
return `${p}:${start}-${end}:${byteOffset}`;
|
|
362
366
|
}
|
|
363
367
|
return null;
|
|
364
368
|
}
|
|
@@ -396,6 +400,22 @@ function nativeInspectionTarget(name: string, parameters: Record<string, unknown
|
|
|
396
400
|
return null;
|
|
397
401
|
}
|
|
398
402
|
|
|
403
|
+
export function isRepeatableNativeTool(name: string, parameters: Record<string, unknown> = {}): boolean {
|
|
404
|
+
if (!name || typeof name !== 'string') return false;
|
|
405
|
+
const action = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
406
|
+
if (/^(?:managetask|managesubagents|sendmessage|invokesubagent|definesubagent|schedule|tasksummary|todowrite|updateplan|askquestion|processlist|sysrunpoll|procterm|waitfortask|checkstatus)$/.test(action)) {
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
if (/(?:poll|status|getresult|wait)$/.test(action)) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
if (/^(runcommand|command|sysrun|terminal|bash|shell)$/.test(action)) {
|
|
413
|
+
const command = cleanCommandString(parameters.CommandLine ?? parameters.command ?? parameters.cmd ?? '');
|
|
414
|
+
if (/^(?:ps\s+aux|pgrep|lsof|netstat|ss\s+-)\b/i.test(command)) return true;
|
|
415
|
+
}
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
|
|
399
419
|
export function isNativeMutation(name: string, parameters: Record<string, unknown> = {}): boolean {
|
|
400
420
|
if (!name || typeof name !== 'string') return false;
|
|
401
421
|
const action = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
@@ -408,7 +428,7 @@ export function isNativeMutation(name: string, parameters: Record<string, unknow
|
|
|
408
428
|
return /\b(?:save_as_mainfile|save_mainfile|write_text|write_bytes|tee)\b/.test(command)
|
|
409
429
|
|| /(?:^|[;&|]\s*)(?:cp|mv|rm|install|patch|touch|mkdir|chmod|sed)\s/.test(command)
|
|
410
430
|
|| /(?:>|>>)/.test(command)
|
|
411
|
-
|| /\b(?:npm|yarn|pnpm|cargo|gradle|gradlew|mvn|dotnet|pip|pip3|pytest|vitest|jest|tsc|make|docker|git\s+(?:add|commit|checkout|merge|rebase|stash|pull|push))\b/i.test(command);
|
|
431
|
+
|| /\b(?:npm|npx|yarn|pnpm|bun|deno|cargo|gradle|gradlew|mvn|dotnet|pip|pip3|pytest|vitest|jest|tsc|make|cmake|ninja|docker|apktool|jadx|jarsigner|apksigner|zipalign|keytool|adb|kotlinc|javac|go|rustc|swift|xcodebuild|codesign|unzip|tar|brew|git\s+(?:add|commit|checkout|merge|rebase|stash|pull|push|restore|reset|clean|rm|mv|apply|cherry-pick|revert|tag|branch|init|clone))\b/i.test(command);
|
|
412
432
|
}
|
|
413
433
|
|
|
414
434
|
export function nativeToolSignature(name: string, parameters: Record<string, unknown> = {}): string {
|
|
@@ -1049,6 +1069,7 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1049
1069
|
let lastToolSignature = '';
|
|
1050
1070
|
const recentSignatures: string[] = [];
|
|
1051
1071
|
const seenNativeActionSteps = new Set<number>();
|
|
1072
|
+
const seenLoopCheckSteps = new Set<number>();
|
|
1052
1073
|
const mediaInspectionCounts = new Map<string, number>();
|
|
1053
1074
|
const pendingMediaMutations = new Set<number>();
|
|
1054
1075
|
// Antigravity's result usage is cumulative across the conversation, but
|
|
@@ -1231,15 +1252,36 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1231
1252
|
(stepUpdate && typeof stepUpdate === 'object' && stepUpdate.parameters) ||
|
|
1232
1253
|
(toolInfo && typeof toolInfo === 'object' && toolInfo.input) ||
|
|
1233
1254
|
{};
|
|
1234
|
-
|
|
1235
|
-
|
|
1255
|
+
const hasParams = Boolean(rawParams && typeof rawParams === 'object' && Object.keys(rawParams).length > 0);
|
|
1256
|
+
const readyForLoopCheck = state === 'DONE'
|
|
1257
|
+
|| (state === 'ACTIVE' && (hasParams || isNativeMutation(name || '', rawParams) || isRepeatableNativeTool(name || '', rawParams)));
|
|
1258
|
+
const shouldCheckLoop = Boolean(name) && readyForLoopCheck
|
|
1259
|
+
&& (!Number.isFinite(stepIndex) || !seenLoopCheckSteps.has(stepIndex));
|
|
1260
|
+
|
|
1261
|
+
if (name && state === 'DONE' && !toolInfo?.error && isNativeMutation(name, rawParams)) {
|
|
1262
|
+
if (Number.isFinite(stepIndex)) seenLoopCheckSteps.add(stepIndex);
|
|
1263
|
+
lastMutationActionIndex = nativeActionStarts + 1;
|
|
1264
|
+
progressiveActionsCount++;
|
|
1265
|
+
consecutiveIdenticalCount = 0;
|
|
1266
|
+
consecutiveInspections = 0;
|
|
1267
|
+
lastToolSignature = '';
|
|
1268
|
+
recentSignatures.length = 0;
|
|
1269
|
+
} else if (name && shouldCheckLoop) {
|
|
1270
|
+
if (Number.isFinite(stepIndex)) seenLoopCheckSteps.add(stepIndex);
|
|
1236
1271
|
const mutating = isNativeMutation(name, rawParams);
|
|
1272
|
+
const repeatable = isRepeatableNativeTool(name, rawParams);
|
|
1237
1273
|
if (mutating) {
|
|
1238
1274
|
lastMutationActionIndex = nativeActionStarts + 1;
|
|
1239
1275
|
progressiveActionsCount++;
|
|
1240
1276
|
consecutiveIdenticalCount = 0;
|
|
1241
1277
|
consecutiveInspections = 0;
|
|
1242
1278
|
lastToolSignature = '';
|
|
1279
|
+
recentSignatures.length = 0;
|
|
1280
|
+
} else if (repeatable) {
|
|
1281
|
+
// Task/subagent polling, plan updates, and user questions are legitimate
|
|
1282
|
+
// coordination steps and must not count as aimless read-only loops.
|
|
1283
|
+
consecutiveIdenticalCount = 0;
|
|
1284
|
+
lastToolSignature = '';
|
|
1243
1285
|
} else if (!desktopTask && (options as any).taskArchetype !== 'media_3d_generation') {
|
|
1244
1286
|
consecutiveInspections++;
|
|
1245
1287
|
const sig = nativeToolSignature(name, rawParams);
|
|
@@ -1274,17 +1316,6 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1274
1316
|
terminateChild();
|
|
1275
1317
|
return;
|
|
1276
1318
|
}
|
|
1277
|
-
|
|
1278
|
-
// 3. Stagnant read-only inspection runaway without mutations on an editing task
|
|
1279
|
-
if (consecutiveInspections >= 30 && (options as any).taskArchetype !== 'web_research_only') {
|
|
1280
|
-
const error = Object.assign(
|
|
1281
|
-
new Error(`Antigravity performed ${consecutiveInspections} consecutive read-only inspections without writing or modifying code. Halting exploration loop.`),
|
|
1282
|
-
{ code: 'AGY_EXPLORATION_LOOP', inspectionCount: consecutiveInspections }
|
|
1283
|
-
);
|
|
1284
|
-
safeReject(error);
|
|
1285
|
-
terminateChild();
|
|
1286
|
-
return;
|
|
1287
|
-
}
|
|
1288
1319
|
}
|
|
1289
1320
|
}
|
|
1290
1321
|
|
package/src/tui/consoleGuard.js
CHANGED
|
@@ -7,6 +7,9 @@ const originalConsole = {
|
|
|
7
7
|
warn: console.warn.bind(console),
|
|
8
8
|
error: console.error.bind(console)
|
|
9
9
|
};
|
|
10
|
+
const originalStderrWrite = process.stderr?.write
|
|
11
|
+
? process.stderr.write.bind(process.stderr)
|
|
12
|
+
: null;
|
|
10
13
|
export function isAnyStageReservedOnStdout() {
|
|
11
14
|
if (stageMouseSessionDepth > 0 && process.stdout?.isTTY) {
|
|
12
15
|
return true;
|
|
@@ -35,6 +38,18 @@ function ensureConsoleGuardInstalled() {
|
|
|
35
38
|
console.info = wrap(originalConsole.info);
|
|
36
39
|
console.warn = wrap(originalConsole.warn);
|
|
37
40
|
console.error = wrap(originalConsole.error);
|
|
41
|
+
if (originalStderrWrite && process.stderr) {
|
|
42
|
+
process.stderr.write = ((chunk, encodingOrCb, cb) => {
|
|
43
|
+
if (isAnyStageReservedOnStdout()) {
|
|
44
|
+
if (typeof encodingOrCb === 'function')
|
|
45
|
+
encodingOrCb();
|
|
46
|
+
else if (typeof cb === 'function')
|
|
47
|
+
cb();
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return originalStderrWrite(chunk, encodingOrCb, cb);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
38
53
|
}
|
|
39
54
|
/**
|
|
40
55
|
* Track TUI Stage open/close lifecycle so raw console writes cannot corrupt the composer box.
|
package/src/tui/consoleGuard.ts
CHANGED
|
@@ -19,6 +19,10 @@ const originalConsole = {
|
|
|
19
19
|
error: console.error.bind(console)
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
const originalStderrWrite = process.stderr?.write
|
|
23
|
+
? process.stderr.write.bind(process.stderr)
|
|
24
|
+
: null;
|
|
25
|
+
|
|
22
26
|
export function isAnyStageReservedOnStdout(): boolean {
|
|
23
27
|
if (stageMouseSessionDepth > 0 && process.stdout?.isTTY) {
|
|
24
28
|
return true;
|
|
@@ -49,6 +53,17 @@ function ensureConsoleGuardInstalled(): void {
|
|
|
49
53
|
console.info = wrap(originalConsole.info);
|
|
50
54
|
console.warn = wrap(originalConsole.warn);
|
|
51
55
|
console.error = wrap(originalConsole.error);
|
|
56
|
+
|
|
57
|
+
if (originalStderrWrite && process.stderr) {
|
|
58
|
+
process.stderr.write = ((chunk: unknown, encodingOrCb?: unknown, cb?: unknown): boolean => {
|
|
59
|
+
if (isAnyStageReservedOnStdout()) {
|
|
60
|
+
if (typeof encodingOrCb === 'function') (encodingOrCb as () => void)();
|
|
61
|
+
else if (typeof cb === 'function') (cb as () => void)();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return (originalStderrWrite as (...a: unknown[]) => boolean)(chunk, encodingOrCb, cb);
|
|
65
|
+
}) as typeof process.stderr.write;
|
|
66
|
+
}
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
/**
|
package/src/tui/prompt.js
CHANGED
|
@@ -461,6 +461,7 @@ export class ChatPrompt {
|
|
|
461
461
|
openLayer(layer) {
|
|
462
462
|
this.closeLayer();
|
|
463
463
|
this.layer = layer;
|
|
464
|
+
if (this.surface?.stage) this.surface.stage.invalidate();
|
|
464
465
|
this.draw();
|
|
465
466
|
return layer;
|
|
466
467
|
}
|
|
@@ -473,6 +474,7 @@ export class ChatPrompt {
|
|
|
473
474
|
// is torn down without one would otherwise leave its promise pending forever
|
|
474
475
|
// and hang the turn.
|
|
475
476
|
if (typeof layer.answer === 'function') layer.answer(false);
|
|
477
|
+
if (this.surface?.stage) this.surface.stage.invalidate();
|
|
476
478
|
this.draw();
|
|
477
479
|
}
|
|
478
480
|
|
|
@@ -748,6 +750,7 @@ export class ChatPrompt {
|
|
|
748
750
|
this.busy = busy;
|
|
749
751
|
resetTurnInterruptState(this, busy);
|
|
750
752
|
if (busy) this.startTick(); else this.stopTick();
|
|
753
|
+
if (this.surface?.stage) this.surface.stage.invalidate();
|
|
751
754
|
this.draw();
|
|
752
755
|
}
|
|
753
756
|
|
package/src/tui/stage.js
CHANGED
|
@@ -44,6 +44,8 @@ export const MIN_STAGE_ROWS = 16;
|
|
|
44
44
|
// which is what stops a scroll from tearing.
|
|
45
45
|
const SYNC_ON = '\x1b[?2026h';
|
|
46
46
|
const SYNC_OFF = '\x1b[?2026l';
|
|
47
|
+
const NOWRAP_ON = '\x1b[?7l';
|
|
48
|
+
const NOWRAP_OFF = '\x1b[?7h';
|
|
47
49
|
const HIDE_CURSOR = '\x1b[?25l';
|
|
48
50
|
const SHOW_CURSOR = '\x1b[?25h';
|
|
49
51
|
const ERASE_LINE = '\x1b[K';
|
|
@@ -238,7 +240,7 @@ export class Stage {
|
|
|
238
240
|
// the same bet and calls it out as its main anti-flicker mechanism.
|
|
239
241
|
if (changed.length === 0 && !caretMoved) return 0;
|
|
240
242
|
|
|
241
|
-
this.write(SYNC_ON + HIDE_CURSOR);
|
|
243
|
+
this.write(SYNC_ON + HIDE_CURSOR + NOWRAP_ON);
|
|
242
244
|
for (const i of changed) {
|
|
243
245
|
this.moveTo(i);
|
|
244
246
|
this.write('\r' + next[i] + ERASE_LINE);
|
|
@@ -246,7 +248,7 @@ export class Stage {
|
|
|
246
248
|
this.moveTo(target.row);
|
|
247
249
|
this.write('\r');
|
|
248
250
|
if (target.col > 0) this.write(`\x1b[${target.col}C`);
|
|
249
|
-
this.write((target.hideCursor ? HIDE_CURSOR : SHOW_CURSOR + '\x1b[6 q') + SYNC_OFF);
|
|
251
|
+
this.write(NOWRAP_OFF + (target.hideCursor ? HIDE_CURSOR : SHOW_CURSOR + '\x1b[6 q') + SYNC_OFF);
|
|
250
252
|
|
|
251
253
|
this.prev = next;
|
|
252
254
|
this.caret = target;
|
package/src/tui/stageSurface.js
CHANGED
|
@@ -35,6 +35,7 @@ import { placeHome, placeDialog } from './homeView.js';
|
|
|
35
35
|
import { sidebarVisible, sessionMainWidth, sessionComposerWidth, sessionSidebarRows, joinSessionSidebar } from './sessionSidebar.js';
|
|
36
36
|
import { sessionStageHeight, alignTranscriptRows } from './sessionLayout.js';
|
|
37
37
|
import { hasSessionTurns, collectSessionTurns, buildTurnRailCells, renderTurnPreviewCard, overlayTurnPreviewCard, resolveActiveTurnIndex } from './turnRail.js';
|
|
38
|
+
import { registerStageConsoleGuard, setStageConsoleGuardActive } from './consoleGuard.js';
|
|
38
39
|
|
|
39
40
|
// Rows of evicted transcript held for the exit log. Eviction only happens after
|
|
40
41
|
// MAX_FRAMES, so this is a bound on a pathological session, not a working limit.
|
|
@@ -193,6 +194,9 @@ export class StageSurface {
|
|
|
193
194
|
this.lastPromptRows = [];
|
|
194
195
|
this.lastPromptCaret = null;
|
|
195
196
|
this.messageActionOverlay = null;
|
|
197
|
+
this.unregisterConsoleGuard = null;
|
|
198
|
+
this.wasModal = false;
|
|
199
|
+
this.lastBlockLength = 0;
|
|
196
200
|
}
|
|
197
201
|
|
|
198
202
|
get width() {
|
|
@@ -250,6 +254,9 @@ export class StageSurface {
|
|
|
250
254
|
// the user had typed anything, and 73 of the 77 claimed rows were empty.
|
|
251
255
|
// present() grows it to fit what there actually is.
|
|
252
256
|
if (!this.stage.reserve(1)) return false;
|
|
257
|
+
this.unregisterConsoleGuard?.();
|
|
258
|
+
this.unregisterConsoleGuard = registerStageConsoleGuard(this);
|
|
259
|
+
if (this.out === process.stdout) setStageConsoleGuardActive(true);
|
|
253
260
|
if (!this.homeInfo) this.enableMouse();
|
|
254
261
|
this.armTeardown();
|
|
255
262
|
return true;
|
|
@@ -304,6 +311,11 @@ export class StageSurface {
|
|
|
304
311
|
// Mouse first, unconditionally: it is the one piece of state that outlives
|
|
305
312
|
// the process and damages the terminal the user goes back to.
|
|
306
313
|
this.disableMouse();
|
|
314
|
+
if (this.unregisterConsoleGuard) {
|
|
315
|
+
this.unregisterConsoleGuard();
|
|
316
|
+
this.unregisterConsoleGuard = null;
|
|
317
|
+
if (this.out === process.stdout) setStageConsoleGuardActive(false);
|
|
318
|
+
}
|
|
307
319
|
if (!this.stage.reserved) { this.disarmTeardown(); return false; }
|
|
308
320
|
const rows = this.snapshot();
|
|
309
321
|
this.stage.collapse();
|
|
@@ -325,6 +337,11 @@ export class StageSurface {
|
|
|
325
337
|
suspend() {
|
|
326
338
|
if (!this.stage.reserved) return false;
|
|
327
339
|
this.disableMouse();
|
|
340
|
+
if (this.unregisterConsoleGuard) {
|
|
341
|
+
this.unregisterConsoleGuard();
|
|
342
|
+
this.unregisterConsoleGuard = null;
|
|
343
|
+
if (this.out === process.stdout) setStageConsoleGuardActive(false);
|
|
344
|
+
}
|
|
328
345
|
this.stage.collapse();
|
|
329
346
|
return true;
|
|
330
347
|
}
|
|
@@ -332,6 +349,9 @@ export class StageSurface {
|
|
|
332
349
|
resume() {
|
|
333
350
|
if (this.stage.reserved) return false;
|
|
334
351
|
if (!this.stage.reserve()) return false;
|
|
352
|
+
this.unregisterConsoleGuard?.();
|
|
353
|
+
this.unregisterConsoleGuard = registerStageConsoleGuard(this);
|
|
354
|
+
if (this.out === process.stdout) setStageConsoleGuardActive(true);
|
|
335
355
|
this.stage.invalidate();
|
|
336
356
|
this.enableMouse();
|
|
337
357
|
return true;
|
|
@@ -372,6 +392,9 @@ export class StageSurface {
|
|
|
372
392
|
* the contract in transcript.js.
|
|
373
393
|
*/
|
|
374
394
|
commit(kind, produce, meta = null) {
|
|
395
|
+
if (kind === 'error' || kind === 'turn' || kind === 'approval') {
|
|
396
|
+
this.stage.invalidate();
|
|
397
|
+
}
|
|
375
398
|
return this.transcript.append({ kind, produce, meta });
|
|
376
399
|
}
|
|
377
400
|
|
|
@@ -386,6 +409,12 @@ export class StageSurface {
|
|
|
386
409
|
this.lastPromptCaret = caret;
|
|
387
410
|
}
|
|
388
411
|
|
|
412
|
+
const isModal = Boolean(caret?.modal);
|
|
413
|
+
if (isModal !== this.wasModal) {
|
|
414
|
+
this.wasModal = isModal;
|
|
415
|
+
this.stage.invalidate();
|
|
416
|
+
}
|
|
417
|
+
|
|
389
418
|
if (this.homeInfo || (caret?.modal && !caret?.inline)) {
|
|
390
419
|
if (this.stage.height < this.stage.maxHeight) {
|
|
391
420
|
this.stage.grow(this.stage.maxHeight - this.stage.height);
|
|
@@ -429,6 +458,11 @@ export class StageSurface {
|
|
|
429
458
|
caretRow = Math.max(0, caretRow - cut);
|
|
430
459
|
}
|
|
431
460
|
|
|
461
|
+
if (this.lastBlockLength > 0 && this.lastBlockLength !== block.length) {
|
|
462
|
+
this.stage.invalidate();
|
|
463
|
+
}
|
|
464
|
+
this.lastBlockLength = block.length;
|
|
465
|
+
|
|
432
466
|
const budget = Math.max(0, height - block.length);
|
|
433
467
|
let rows = [];
|
|
434
468
|
if (budget > 0) {
|
|
@@ -685,7 +719,7 @@ export class StageSurface {
|
|
|
685
719
|
row = ` ${leftCell} ${row}`;
|
|
686
720
|
}
|
|
687
721
|
}
|
|
688
|
-
rows[i] = `${padEnd(row, contentWidth)} ${rightCell}`;
|
|
722
|
+
rows[i] = `${padEnd(truncate(row, contentWidth, ''), contentWidth)} ${rightCell}`;
|
|
689
723
|
}
|
|
690
724
|
return rows;
|
|
691
725
|
}
|
package/src/tui/text.js
CHANGED
|
@@ -32,14 +32,37 @@ export function stripAnsi(text) {
|
|
|
32
32
|
*/
|
|
33
33
|
function isWideCodePoint(code) {
|
|
34
34
|
return ((code >= 0x1100 && code <= 0x115f) || // Hangul Jamo
|
|
35
|
+
code === 0x231a || code === 0x231b || // Watch, Hourglass
|
|
36
|
+
(code >= 0x23e9 && code <= 0x23fa) || // Media control & clock symbols
|
|
37
|
+
code === 0x25fd || code === 0x25fe || // Medium small squares
|
|
38
|
+
code === 0x2614 || code === 0x2615 || // Umbrella with rain, Hot beverage
|
|
39
|
+
(code >= 0x2648 && code <= 0x2653) || // Zodiac symbols
|
|
40
|
+
code === 0x267f || code === 0x2693 || code === 0x26a1 || // Wheelchair, Anchor, High voltage (⚡)
|
|
41
|
+
code === 0x26aa || code === 0x26ab || code === 0x26bd || code === 0x26be ||
|
|
42
|
+
code === 0x26c4 || code === 0x26c5 || code === 0x26ce || code === 0x26d4 ||
|
|
43
|
+
code === 0x26ea || code === 0x26f2 || code === 0x26f3 || code === 0x26f5 ||
|
|
44
|
+
code === 0x26fa || code === 0x26fd ||
|
|
45
|
+
code === 0x2705 || code === 0x270a || code === 0x270b || code === 0x2728 || // ✅ ✊ ✋ ✨
|
|
46
|
+
code === 0x274c || code === 0x274e || (code >= 0x2753 && code <= 0x2755) ||
|
|
47
|
+
code === 0x2757 || (code >= 0x2795 && code <= 0x2797) || code === 0x27b0 || code === 0x27bf ||
|
|
48
|
+
code === 0x2b1b || code === 0x2b1c || code === 0x2b50 || code === 0x2b55 ||
|
|
35
49
|
(code >= 0x2e80 && code <= 0xa4cf) || // CJK radicals … Yi
|
|
36
50
|
(code >= 0xac00 && code <= 0xd7a3) || // Hangul syllables
|
|
37
51
|
(code >= 0xf900 && code <= 0xfaff) || // CJK compatibility ideographs
|
|
38
52
|
(code >= 0xfe30 && code <= 0xfe6f) || // CJK compatibility forms
|
|
39
53
|
(code >= 0xff00 && code <= 0xff60) || // Fullwidth forms
|
|
40
54
|
(code >= 0xffe0 && code <= 0xffe6) ||
|
|
41
|
-
|
|
42
|
-
(code >=
|
|
55
|
+
code === 0x1f004 || code === 0x1f0cf || code === 0x1f18e ||
|
|
56
|
+
(code >= 0x1f191 && code <= 0x1f19a) ||
|
|
57
|
+
(code >= 0x1f1e6 && code <= 0x1f251) ||
|
|
58
|
+
(code >= 0x1f300 && code <= 0x1f64f) || // Misc Symbols, Pictographs & Emoticons
|
|
59
|
+
(code >= 0x1f680 && code <= 0x1f6ff) || // Transport & Map Symbols
|
|
60
|
+
(code >= 0x1f700 && code <= 0x1f7ff) || // Alchemical & Geometric Shapes Extended
|
|
61
|
+
(code >= 0x1f800 && code <= 0x1f8ff) || // Supplemental Arrows-C
|
|
62
|
+
(code >= 0x1f900 && code <= 0x1f9ff) || // Supplemental Symbols & Pictographs
|
|
63
|
+
(code >= 0x1fa00 && code <= 0x1faff) || // Symbols & Pictographs Extended-A
|
|
64
|
+
(code >= 0x20000 && code <= 0x3ffff) // Supplementary Ideographic Planes
|
|
65
|
+
);
|
|
43
66
|
}
|
|
44
67
|
/**
|
|
45
68
|
* The East Asian AMBIGUOUS class (UAX #11).
|
package/src/tui/text.ts
CHANGED
|
@@ -37,14 +37,36 @@ export function stripAnsi(text: unknown): string {
|
|
|
37
37
|
function isWideCodePoint(code: number): boolean {
|
|
38
38
|
return (
|
|
39
39
|
(code >= 0x1100 && code <= 0x115f) || // Hangul Jamo
|
|
40
|
+
code === 0x231a || code === 0x231b || // Watch, Hourglass
|
|
41
|
+
(code >= 0x23e9 && code <= 0x23fa) || // Media control & clock symbols
|
|
42
|
+
code === 0x25fd || code === 0x25fe || // Medium small squares
|
|
43
|
+
code === 0x2614 || code === 0x2615 || // Umbrella with rain, Hot beverage
|
|
44
|
+
(code >= 0x2648 && code <= 0x2653) || // Zodiac symbols
|
|
45
|
+
code === 0x267f || code === 0x2693 || code === 0x26a1 || // Wheelchair, Anchor, High voltage (⚡)
|
|
46
|
+
code === 0x26aa || code === 0x26ab || code === 0x26bd || code === 0x26be ||
|
|
47
|
+
code === 0x26c4 || code === 0x26c5 || code === 0x26ce || code === 0x26d4 ||
|
|
48
|
+
code === 0x26ea || code === 0x26f2 || code === 0x26f3 || code === 0x26f5 ||
|
|
49
|
+
code === 0x26fa || code === 0x26fd ||
|
|
50
|
+
code === 0x2705 || code === 0x270a || code === 0x270b || code === 0x2728 || // ✅ ✊ ✋ ✨
|
|
51
|
+
code === 0x274c || code === 0x274e || (code >= 0x2753 && code <= 0x2755) ||
|
|
52
|
+
code === 0x2757 || (code >= 0x2795 && code <= 0x2797) || code === 0x27b0 || code === 0x27bf ||
|
|
53
|
+
code === 0x2b1b || code === 0x2b1c || code === 0x2b50 || code === 0x2b55 ||
|
|
40
54
|
(code >= 0x2e80 && code <= 0xa4cf) || // CJK radicals … Yi
|
|
41
55
|
(code >= 0xac00 && code <= 0xd7a3) || // Hangul syllables
|
|
42
56
|
(code >= 0xf900 && code <= 0xfaff) || // CJK compatibility ideographs
|
|
43
57
|
(code >= 0xfe30 && code <= 0xfe6f) || // CJK compatibility forms
|
|
44
58
|
(code >= 0xff00 && code <= 0xff60) || // Fullwidth forms
|
|
45
59
|
(code >= 0xffe0 && code <= 0xffe6) ||
|
|
46
|
-
|
|
47
|
-
(code >=
|
|
60
|
+
code === 0x1f004 || code === 0x1f0cf || code === 0x1f18e ||
|
|
61
|
+
(code >= 0x1f191 && code <= 0x1f19a) ||
|
|
62
|
+
(code >= 0x1f1e6 && code <= 0x1f251) ||
|
|
63
|
+
(code >= 0x1f300 && code <= 0x1f64f) || // Misc Symbols, Pictographs & Emoticons
|
|
64
|
+
(code >= 0x1f680 && code <= 0x1f6ff) || // Transport & Map Symbols
|
|
65
|
+
(code >= 0x1f700 && code <= 0x1f7ff) || // Alchemical & Geometric Shapes Extended
|
|
66
|
+
(code >= 0x1f800 && code <= 0x1f8ff) || // Supplemental Arrows-C
|
|
67
|
+
(code >= 0x1f900 && code <= 0x1f9ff) || // Supplemental Symbols & Pictographs
|
|
68
|
+
(code >= 0x1fa00 && code <= 0x1faff) || // Symbols & Pictographs Extended-A
|
|
69
|
+
(code >= 0x20000 && code <= 0x3ffff) // Supplementary Ideographic Planes
|
|
48
70
|
);
|
|
49
71
|
}
|
|
50
72
|
|