forked from github/copilot-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-pine-diagnostics-bounds.js
More file actions
100 lines (84 loc) · 5.09 KB
/
test-pine-diagnostics-bounds.js
File metadata and controls
100 lines (84 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env node
const assert = require('assert');
const path = require('path');
const { createMessageBuilder } = require(path.join(__dirname, '..', 'src', 'main', 'ai-service', 'message-builder.js'));
function createBuilder({ foreground } = {}) {
return createMessageBuilder({
getBrowserSessionState: () => ({ lastUpdated: null }),
getCurrentProvider: () => 'copilot',
getForegroundWindowInfo: async () => foreground || null,
getInspectService: () => ({ isInspectModeActive: () => false }),
getLatestVisualContext: () => null,
getPreferencesSystemContext: () => '',
getPreferencesSystemContextForApp: () => '',
getRecentConversationHistory: () => [],
getSemanticDOMContextText: () => '',
getUIWatcher: () => ({ isPolling: false, getCapabilitySnapshot: () => null, getContextForAI: () => '' }),
maxHistory: 0,
systemPrompt: 'base system prompt'
});
}
async function test(name, fn) {
try {
await fn();
console.log(`PASS ${name}`);
} catch (error) {
console.error(`FAIL ${name}`);
console.error(error.stack || error.message);
process.exitCode = 1;
}
}
async function buildPineEvidenceMessage(userMessage) {
const builder = createBuilder({
foreground: {
success: true,
processName: 'tradingview',
title: 'TradingView - Pine Editor'
}
});
const messages = await builder.buildMessages(userMessage, false);
return messages.find((entry) => entry.role === 'system' && entry.content.includes('## Pine Evidence Bounds'));
}
async function main() {
await test('pine compile-result prompt bounds compile success claims', async () => {
const evidenceMessage = await buildPineEvidenceMessage('open pine editor in tradingview and summarize the compile result');
assert(evidenceMessage, 'pine evidence block should be injected');
assert(evidenceMessage.content.includes('requestKind: compile-result'));
assert(evidenceMessage.content.includes('Rule: Prefer visible Pine Editor compiler/diagnostic text over screenshot interpretation for Pine compile and diagnostics requests.'));
assert(evidenceMessage.content.includes('compiler/editor evidence only, not proof of runtime correctness, strategy validity, profitability, or market insight'));
});
await test('pine diagnostics prompt bounds warning and runtime inferences', async () => {
const evidenceMessage = await buildPineEvidenceMessage('open pine editor in tradingview and check diagnostics');
assert(evidenceMessage, 'pine evidence block should be injected');
assert(evidenceMessage.content.includes('requestKind: diagnostics'));
assert(evidenceMessage.content.includes('Rule: Surface visible compiler errors and warnings as bounded diagnostics evidence; do not infer hidden causes or chart-state effects unless the visible text states them.'));
assert(evidenceMessage.content.includes('mention Pine execution-model caveats such as realtime rollback, confirmed vs unconfirmed bars, and indicator vs strategy recalculation differences'));
});
await test('pine provenance prompt bounds visible revision metadata inferences', async () => {
const evidenceMessage = await buildPineEvidenceMessage('open pine version history in tradingview and summarize the top visible revision metadata');
assert(evidenceMessage, 'pine evidence block should be injected');
assert(evidenceMessage.content.includes('requestKind: provenance-summary'));
assert(evidenceMessage.content.includes('Treat Pine Version History as bounded provenance evidence only'));
assert(evidenceMessage.content.includes('latest visible revision label, latest visible relative time, visible revision count, and visible recency signal'));
assert(evidenceMessage.content.includes('Do not infer hidden diffs, full script history, authorship, or runtime/chart behavior from the visible revision list alone.'));
});
await test('pine line-budget prompt bounds visible count-hint inferences', async () => {
const evidenceMessage = await buildPineEvidenceMessage('open pine editor in tradingview and check the line budget');
assert(evidenceMessage, 'pine evidence block should be injected');
assert(evidenceMessage.content.includes('requestKind: line-budget'));
assert(evidenceMessage.content.includes('Treat visible line-count hints as bounded editor evidence'));
assert(evidenceMessage.content.includes('do not infer hidden script size beyond what the editor text shows'));
});
await test('pine generic-status prompt keeps status-only claims bounded', async () => {
const evidenceMessage = await buildPineEvidenceMessage('open pine editor in tradingview and show the visible status text');
assert(evidenceMessage, 'pine evidence block should be injected');
assert(evidenceMessage.content.includes('requestKind: generic-status'));
assert(evidenceMessage.content.includes('bounded editor evidence only'));
assert(evidenceMessage.content.includes('do not turn generic status text into runtime, chart, or market claims'));
});
}
main().catch((error) => {
console.error('FAIL pine diagnostics bounds');
console.error(error.stack || error.message);
process.exit(1);
});