Skip to content

Commit 0dff6a7

Browse files
committed
Post-plan: extend Pine evidence to Editor status
1 parent 69acfcb commit 0dff6a7

6 files changed

Lines changed: 130 additions & 6 deletions

File tree

docs/CHAT_CONTINUITY_IMPLEMENTATION_PLAN.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,10 @@ node scripts/test-windows-observation-flow.js
14991499
- extended `src/main/tradingview/pine-workflows.js` so Pine Logs evidence-gathering requests can stay verification-first while preserving or auto-appending bounded `get_text` readback
15001500
- extended `src/main/tradingview/pine-workflows.js` so Pine Profiler evidence-gathering requests can also stay verification-first while preserving or auto-appending bounded `get_text` readback
15011501
- extended `src/main/tradingview/pine-workflows.js` so Pine Version History provenance requests can stay verification-first while preserving or auto-appending bounded `get_text` readback
1502+
- extended `src/main/tradingview/pine-workflows.js` so Pine Editor visible status/output requests can stay verification-first while preserving or auto-appending bounded `get_text` readback
15021503
- added dedicated Pine data-workflow regressions in `scripts/test-tradingview-pine-data-workflows.js`
1503-
- extended `scripts/test-windows-observation-flow.js` with verified Pine Logs, Pine Profiler, and Pine Version History readback coverage that gathers text without re-entering a screenshot loop
1504-
- updated `src/main/ai-service/system-prompt.js` so TradingView Pine output/error/provenance requests prefer verified Pine surfaces plus `get_text` over screenshot-only inference
1504+
- extended `scripts/test-windows-observation-flow.js` with verified Pine Logs, Pine Profiler, Pine Version History, and Pine Editor status/output readback coverage that gathers text without re-entering a screenshot loop
1505+
- updated `src/main/ai-service/system-prompt.js` so TradingView Pine output/error/provenance requests prefer verified Pine surfaces plus `get_text`, including Pine Editor visible status/output, over screenshot-only inference
15051506

15061507
**Why this track exists**
15071508
- Current Pine support is surface-oriented:
@@ -1562,7 +1563,7 @@ node scripts/test-windows-observation-flow.js
15621563
- Pine workflows strengthen analysis honesty instead of bypassing it
15631564

15641565
**Next best slice from here**
1565-
- extend the same bounded evidence-gathering pattern beyond Pine Version History into broader visible Pine status/output surfaces without implying chart-state insight
1566+
- refine Pine Editor status/output readback into more structured visible compile-result / diagnostics summaries without implying chart-state insight
15661567

15671568
### Track E — Honest drawing capability framing
15681569

scripts/test-bug-fixes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ test('ai-service gates TradingView follow-up typing on post-key observation chec
333333
assert(tradingViewPineContent.includes("type: 'get_text'"), 'TradingView Pine workflows should support bounded Pine Logs readback');
334334
assert(tradingViewPineContent.includes("text: 'Pine Profiler'"), 'TradingView Pine workflows should support bounded Pine Profiler readback');
335335
assert(tradingViewPineContent.includes("text: 'Pine Version History'"), 'TradingView Pine workflows should support bounded Pine Version History readback');
336+
assert(tradingViewPineContent.includes("text: 'Pine Editor'"), 'TradingView Pine workflows should support bounded Pine Editor status/output readback');
336337
assert(tradingViewPineContent.includes('wantsEvidenceReadback'), 'TradingView Pine workflows should detect Pine evidence-gathering requests');
337338
assert(tradingViewPaperContent.includes("target: 'paper-trading-panel'"), 'TradingView Paper workflows should encode paper-trading-panel verification metadata');
338339
assert(tradingViewPaperContent.includes('paper account'), 'TradingView Paper workflows should ground paper-assist keywords');
@@ -348,6 +349,7 @@ test('system prompt guides Pine evidence gathering toward get_text over screensh
348349

349350
assert(content.includes('TradingView Pine evidence rule'), 'System prompt should include explicit TradingView Pine evidence guidance');
350351
assert(content.includes('Pine Logs / Profiler / Version History text'), 'System prompt should point the model toward Pine text and provenance evidence');
352+
assert(content.includes('Pine Editor visible status/output'), 'System prompt should mention Pine Editor status/output as bounded evidence');
351353
assert(content.includes('get_text'), 'System prompt should mention get_text for Pine evidence gathering');
352354
});
353355

scripts/test-tradingview-pine-data-workflows.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ test('pine workflow recognizes pine logs evidence-gathering requests', () => {
3030
assert.strictEqual(intent.wantsEvidenceReadback, true);
3131
});
3232

33+
test('pine workflow recognizes pine editor status-output requests', () => {
34+
const intent = inferTradingViewPineIntent('open pine editor in tradingview and read the visible compiler status', [
35+
{ type: 'key', key: 'ctrl+e' }
36+
]);
37+
38+
assert(intent, 'intent should be inferred');
39+
assert.strictEqual(intent.surfaceTarget, 'pine-editor');
40+
assert.strictEqual(intent.wantsEvidenceReadback, true);
41+
});
42+
3343
test('pine workflow recognizes pine profiler evidence-gathering requests', () => {
3444
const intent = inferTradingViewPineIntent('open pine profiler in tradingview and summarize the metrics', [
3545
{ type: 'key', key: 'ctrl+shift+p' }
@@ -69,6 +79,25 @@ test('open pine logs and read output stays verification-first', () => {
6979
assert.strictEqual(rewritten[4].text, 'Pine Logs');
7080
});
7181

82+
test('open pine editor and read visible status stays verification-first', () => {
83+
const rewritten = buildTradingViewPineWorkflowActions({
84+
appName: 'TradingView',
85+
surfaceTarget: 'pine-editor',
86+
verifyKind: 'panel-visible',
87+
openerIndex: 0,
88+
wantsEvidenceReadback: true,
89+
requiresObservedChange: false
90+
}, [
91+
{ type: 'key', key: 'ctrl+e', reason: 'Open Pine Editor' }
92+
]);
93+
94+
assert.strictEqual(rewritten[0].type, 'bring_window_to_front');
95+
assert.strictEqual(rewritten[2].type, 'key');
96+
assert.strictEqual(rewritten[2].verify.target, 'pine-editor');
97+
assert.strictEqual(rewritten[4].type, 'get_text');
98+
assert.strictEqual(rewritten[4].text, 'Pine Editor');
99+
});
100+
72101
test('open pine profiler and summarize metrics stays verification-first', () => {
73102
const rewritten = buildTradingViewPineWorkflowActions({
74103
appName: 'TradingView',
@@ -122,6 +151,21 @@ test('pine evidence-gathering workflow preserves trailing get_text read step', (
122151
assert.strictEqual(rewritten[2].verify.target, 'pine-logs');
123152
});
124153

154+
test('pine editor evidence workflow preserves trailing get_text read step', () => {
155+
const rewritten = maybeRewriteTradingViewPineWorkflow([
156+
{ type: 'key', key: 'ctrl+e' },
157+
{ type: 'get_text', text: 'Pine Editor', reason: 'Read visible Pine Editor status text' }
158+
], {
159+
userMessage: 'open pine editor in tradingview and summarize the visible compiler status'
160+
});
161+
162+
assert(Array.isArray(rewritten), 'workflow should rewrite');
163+
const readSteps = rewritten.filter((action) => action?.type === 'get_text');
164+
assert.strictEqual(readSteps.length, 1, 'explicit pine editor readback step should be preserved without duplication');
165+
assert.strictEqual(readSteps[0].text, 'Pine Editor');
166+
assert.strictEqual(rewritten[2].verify.target, 'pine-editor');
167+
});
168+
125169
test('pine profiler evidence workflow preserves trailing get_text read step', () => {
126170
const rewritten = maybeRewriteTradingViewPineWorkflow([
127171
{ type: 'key', key: 'ctrl+shift+p' },

scripts/test-windows-observation-flow.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,21 @@ async function run() {
265265
assert.strictEqual(rewritten[4].text, 'plot(close)');
266266
});
267267

268+
await testAsync('low-signal TradingView Pine Editor status request rewrites to panel verification plus get_text', async () => {
269+
const rewritten = aiService.rewriteActionsForReliability([
270+
{ type: 'key', key: 'ctrl+e' }
271+
], {
272+
userMessage: 'open pine editor in tradingview and read the visible compiler status'
273+
});
274+
275+
assert(Array.isArray(rewritten), 'pine editor status rewrite should return an action array');
276+
assert.strictEqual(rewritten[0].type, 'bring_window_to_front');
277+
assert.strictEqual(rewritten[2].type, 'key');
278+
assert.strictEqual(rewritten[2].verify.target, 'pine-editor');
279+
assert.strictEqual(rewritten[4].type, 'get_text');
280+
assert.strictEqual(rewritten[4].text, 'Pine Editor');
281+
});
282+
268283
await testAsync('low-signal TradingView Pine Logs evidence request rewrites to panel verification plus get_text', async () => {
269284
const rewritten = aiService.rewriteActionsForReliability([
270285
{ type: 'key', key: 'ctrl+shift+l' }
@@ -466,6 +481,58 @@ async function run() {
466481
});
467482
});
468483

484+
await testAsync('verified pine editor workflow allows bounded visible status gathering without screenshot loop', async () => {
485+
const executed = [];
486+
const foregroundSequence = [
487+
{ success: true, hwnd: 777, title: 'TradingView', processName: 'tradingview', windowKind: 'main' },
488+
{ success: true, hwnd: 892, title: 'Pine Editor - TradingView', processName: 'tradingview', windowKind: 'owned' },
489+
{ success: true, hwnd: 892, title: 'Pine Editor - TradingView', processName: 'tradingview', windowKind: 'owned' },
490+
{ success: true, hwnd: 892, title: 'Pine Editor - TradingView', processName: 'tradingview', windowKind: 'owned' }
491+
];
492+
493+
await withPatchedSystemAutomation({
494+
resolveWindowHandle: async (action) => action?.processName === 'tradingview' ? 777 : 0,
495+
getForegroundWindowHandle: async () => 777,
496+
getForegroundWindowInfo: async () => {
497+
return foregroundSequence.shift() || { success: true, hwnd: 892, title: 'Pine Editor - TradingView', processName: 'tradingview', windowKind: 'owned' };
498+
},
499+
focusWindow: async () => ({ success: true }),
500+
getRunningProcessesByNames: async () => ([{ pid: 4242, processName: 'tradingview', mainWindowTitle: 'TradingView', startTime: '2026-03-23T00:00:00Z' }])
501+
}, async () => {
502+
const execResult = await aiService.executeActions({
503+
thought: 'Open Pine Editor and summarize the visible compiler status',
504+
verification: 'TradingView should show Pine Editor before text is read',
505+
actions: [
506+
{ type: 'focus_window', title: 'TradingView', processName: 'tradingview' },
507+
{ type: 'key', key: 'ctrl+e', reason: 'Open Pine Editor', verify: { kind: 'panel-visible', appName: 'TradingView', target: 'pine-editor', keywords: ['pine editor', 'pine'] } },
508+
{ type: 'get_text', text: 'Pine Editor', reason: 'Read visible Pine Editor status/output text' }
509+
]
510+
}, null, null, {
511+
userMessage: 'open pine editor in tradingview and summarize the visible compiler status',
512+
actionExecutor: async (action) => {
513+
executed.push(action.type);
514+
if (action.type === 'get_text') {
515+
return {
516+
success: true,
517+
action: action.type,
518+
text: 'Compiler: no errors. Status: strategy loaded.',
519+
method: 'TextPattern',
520+
message: 'Got text via TextPattern: "Compiler: no errors. Status: strategy loaded."'
521+
};
522+
}
523+
return { success: true, action: action.type, message: 'executed' };
524+
}
525+
});
526+
527+
assert.strictEqual(execResult.success, true, 'Execution should proceed after Pine Editor is observed');
528+
assert.deepStrictEqual(executed, ['focus_window', 'key', 'get_text'], 'Bounded Pine Editor status gathering should continue to read text after panel verification');
529+
assert.strictEqual(execResult.observationCheckpoints.length, 1, 'A post-key observation checkpoint should be returned');
530+
assert.strictEqual(execResult.observationCheckpoints[0].verified, true, 'Pine Editor panel observation should pass');
531+
assert.strictEqual(execResult.results[2].text, 'Compiler: no errors. Status: strategy loaded.', 'Pine Editor status text should be preserved on the get_text result');
532+
assert(!execResult.screenshotCaptured, 'Pine Editor status gathering should not require a screenshot loop');
533+
});
534+
});
535+
469536
await testAsync('low-signal TradingView DOM request wraps the opener with bounded panel verification', async () => {
470537
const rewritten = aiService.rewriteActionsForReliability([
471538
{ type: 'key', key: 'ctrl+d' },

src/main/ai-service/system-prompt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Format: \`- [Index] Type: "Name" at (x, y)\`
125125
### Visual Honesty Rule (CRITICAL)
126126
- If you do NOT have a screenshot AND the user did NOT provide a Live UI State list, you MUST NOT claim you can see any windows, panels, or elements.
127127
- In that situation, either use keyboard-only deterministic steps or ask the user to run \`/capture\`.
128-
- For TradingView requests that ask for concrete output, profiler-style evidence, or script provenance, prefer verified Pine surfaces plus \`get_text\` (for example Pine Logs / Profiler / Version History text) over screenshot-only indicator guesses.
128+
- For TradingView requests that ask for concrete output, profiler-style evidence, visible Pine Editor status/output, or script provenance, prefer verified Pine surfaces plus \`get_text\` (for example Pine Logs / Profiler / Version History text or Pine Editor visible status/output) over screenshot-only indicator guesses.
129129
130130
**TO LIST ELEMENTS**: Read the Live UI State section and list what's there.
131131
@@ -223,7 +223,7 @@ When the user asks you to DO something, respond with a JSON action block:
223223
3) perform deterministic selection action,
224224
4) request screenshot only if all non-visual attempts fail.
225225
- **Continuity rule**: if the active page title or recent action output indicates the requested browser objective is already achieved, acknowledge completion and avoid proposing additional screenshot steps.
226-
- **TradingView Pine evidence rule**: if the user wants concrete Pine output, errors, profiler-style evidence, or visible revision/provenance details, prefer \`open/show Pine Logs, Profiler, or Version History\` + verified panel opening + \`get_text\` before relying on screenshot analysis.
226+
- **TradingView Pine evidence rule**: if the user wants concrete Pine output, errors, profiler-style evidence, visible Pine Editor status/output, or visible revision/provenance details, prefer \`open/show Pine Editor, Logs, Profiler, or Version History\` + verified panel opening + \`get_text\` before relying on screenshot analysis.
227227
- **If you need to interact with web content inside an app** (like VS Code panels, browser tabs): Use keyboard shortcuts or coordinate-based clicks since web UI may not appear in UIA tree
228228
229229
**Common Task Patterns**:

src/main/tradingview/pine-workflows.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ function inferPineEvidenceReadIntent(raw = '', surfaceTarget = '') {
3535
}
3636

3737
function buildPineReadbackStep(surfaceTarget) {
38+
if (surfaceTarget === 'pine-editor') {
39+
return {
40+
type: 'get_text',
41+
text: 'Pine Editor',
42+
reason: 'Read visible Pine Editor status/output text for bounded evidence gathering'
43+
};
44+
}
45+
3846
if (surfaceTarget === 'pine-logs') {
3947
return {
4048
type: 'get_text',
@@ -126,7 +134,9 @@ function inferTradingViewPineIntent(userMessage = '', actions = []) {
126134
? 'Open TradingView Pine Profiler with verification'
127135
: surface.target === 'pine-version-history'
128136
? 'Open TradingView Pine version history with verification'
129-
: 'Open TradingView Pine Editor with verification'
137+
: wantsEvidenceReadback
138+
? 'Open TradingView Pine Editor with verification and read visible status/output'
139+
: 'Open TradingView Pine Editor with verification'
130140
};
131141
}
132142

0 commit comments

Comments
 (0)