feat: lift shell read restrictions and page bash/read tool outputs to 200 lines

This commit is contained in:
Agent committed 2026-10-12 22:33:11 +00:00
1 parent ee78e6d3a8
commit de37af4b8c
7 files changed
+213 -32

No files matched your search

+62 -6
View File
@@ -340,15 +340,71 @@ window.__ModuleLoader__.load({
return preparing ? h(PreparingEditRow, props) : h(StartedEditRow, props);
}
/** `[first, last]` file lines a read call covers: from the result window once settled, else from the arguments. */
function readRange(block) {
if (!block) return null;
const done = 'kind' in block;
if (done && block.isError) return null;
const lines = done && block.meta && Array.isArray(block.meta.lines) ? block.meta.lines : null;
if (lines) {
if (!lines.length) return null;
const a = lines[0]?.number; const b = lines[lines.length - 1]?.number;
return Number.isInteger(a) && Number.isInteger(b) ? [a, b] : null;
}
let args = {};
try { args = JSON.parse((done ? block.call?.argsRaw : block.argsRaw) || '{}') || {}; } catch { return null; }
const pos = (v) => (Number.isInteger(v) && v >= 1 ? v : undefined);
const start = pos(args.offset) ?? 1;
const limit = Math.min(pos(args.limit) ?? PAGE_LINES, PAGE_LINES);
return [start, start + limit - 1];
}
const PAGE_LINES = 200;
/** The stock read row (priority 0 entry of the same slot); looked up at render time so load order doesn't matter. */
let stockRead;
function findStockRead(ctx, self) {
if (stockRead) return stockRead;
try {
const entries = typeof ctx.slots.entries === 'function' ? ctx.slots.entries('tool.call.toolview') : [];
const hit = entries.find((e) => e.options?.key === 'read' && e.component !== self);
if (hit) stockRead = hit.component;
} catch { /* slot service without entry access */ }
return stockRead;
}
/** Stock read row with the title changed to "Read lines A–B". */
function makeReadRow(ctx) {
function ReadRow(props) {
const stock = findStockRead(ctx, ReadRow);
if (!stock) return null;
const range = readRange(props.block);
if (!range) return h(stock, props);
const base = tr(props.t, 'tool.title.read', 'Read');
const title = `${base} lines ${range[0]}–${range[1]}`;
const t = (key, params) => (key === 'tool.title.read' ? title : props.t(key, params));
return h(stock, { ...props, t });
}
return ReadRow;
}
return {
inject: ['slots'],
apply(ctx) {
ctx.slots.inject('tool.call.toolview', () => ctx.slots.register({
name: 'tool.call.toolview',
key: 'edit',
locale: 'conversation',
priority: -1,
}, EditRow));
ctx.slots.inject('tool.call.toolview', function* () {
yield ctx.slots.register({
name: 'tool.call.toolview',
key: 'edit',
locale: 'conversation',
priority: -1,
}, EditRow);
yield ctx.slots.register({
name: 'tool.call.toolview',
key: 'read',
locale: 'conversation',
priority: -1,
}, makeReadRow(ctx));
});
},
};
},