Skip to content

Commit 084b0df

Browse files
committed
Polish repository for public release
1 parent 497df5c commit 084b0df

4 files changed

Lines changed: 140 additions & 92 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.11", "3.12", "3.13"]
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install project
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -e .
30+
31+
- name: Run tests
32+
run: python -m pytest -q

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Contributing
2+
3+
Thanks for contributing to `pine-script-validator`.
4+
5+
## Development Setup
6+
7+
```powershell
8+
python -m venv .venv
9+
.venv\Scripts\Activate.ps1
10+
pip install -e .
11+
python -m pytest -q
12+
```
13+
14+
## What Helps Most
15+
16+
- regression tests for real-world Pine edge cases
17+
- parser and validator fixes that reduce false positives
18+
- improved diagnostics for agent-driven debugging workflows
19+
- documentation improvements and practical examples
20+
21+
## Pull Request Guidelines
22+
23+
- keep changes focused
24+
- add or update tests for behavioral changes
25+
- preserve existing CLI behavior unless the change is intentional and documented
26+
- update README when user-facing functionality changes
27+
28+
## Diagnostics Philosophy
29+
30+
- errors should point to concrete breakage
31+
- warnings should indicate risky or consistency-sensitive behavior
32+
- hints should stay useful and avoid becoming noise
33+
34+
If you are unsure whether a diagnostic should be an error, warning, or hint, open an issue or describe the tradeoff in your pull request.

README.md

Lines changed: 61 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
# Pine Script Validator
22

3-
Agent-friendly validation and debugging toolkit for TradingView Pine Script.
3+
[![CI](https://github.com/Poryaei/pine-script-validator/actions/workflows/ci.yml/badge.svg)](https://github.com/Poryaei/pine-script-validator/actions/workflows/ci.yml)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
5+
[![Python](https://img.shields.io/badge/Python-3.11%2B-blue.svg)](https://www.python.org/)
46

5-
`Pine Script Validator` helps humans and coding agents inspect `.pine` files locally, catch syntax and semantic problems, and turn raw diagnostics into actionable debugging output. The project is built for workflows where an agent needs to read a Pine script, understand what failed, and decide what to fix next.
7+
Static validator, audit CLI, and agent-debugging toolkit for TradingView Pine Script.
68

7-
## What It Solves
9+
`Pine Script Validator` helps humans and coding agents inspect `.pine` files locally, catch syntax and semantic issues early, and turn raw diagnostics into actionable debugging output. It is designed for real-world local workflows where an agent or developer needs to validate, interpret, and iterate on Pine code outside TradingView.
810

9-
Debugging Pine Script outside TradingView is awkward, especially for automated workflows. Agents typically need:
11+
Current metadata coverage and built-in validation are focused on Pine Script v6.
12+
13+
## Highlights
14+
15+
- Pure Python lexer and parser for Pine Script
16+
- Validation of built-in functions and namespaces using bundled Pine Script v6 metadata
17+
- Human-readable diagnostics with line and column locations
18+
- `--json` output for tooling and automation
19+
- `--agent-json` output with excerpts, pointers, suggestions, and next steps
20+
- Severity ordering and filtering controls
21+
- Batch validation for files, directories, and glob patterns
22+
- `--sarif` output for CI and code scanning workflows
23+
- Audit mode for large Pine corpora
24+
25+
## Why This Project Exists
26+
27+
Pine Script tooling outside TradingView is limited, especially for automated debugging workflows. Agents usually need:
1028

1129
- a local parser they can run repeatedly
1230
- machine-readable diagnostics
@@ -15,29 +33,11 @@ Debugging Pine Script outside TradingView is awkward, especially for automated w
1533

1634
This project focuses on exactly that.
1735

18-
## Core Capabilities
19-
20-
- Parse Pine Script with a pure Python lexer and parser
21-
- Validate built-in functions and namespaces using bundled Pine v6 metadata
22-
- Report syntax, semantic, warning, and hint diagnostics with source positions
23-
- Emit standard JSON diagnostics for tooling integration
24-
- Emit agent-oriented JSON reports with:
25-
- per-diagnostic line excerpts
26-
- visual pointers to the failing span
27-
- suggested remediation guidance
28-
- summary counts and next-step hints
29-
- Validate multiple files or directories in one command
30-
- Emit SARIF output for CI pipelines, review bots, and code scanning tools
31-
- Audit large script corpora and generate JSON and Markdown reports
32-
- Control which severities are emitted with professional CLI toggles
33-
34-
## Best Fit Use Cases
35-
36-
- letting agents debug Pine scripts inside local coding workflows
37-
- validating generated Pine code before shipping it elsewhere
38-
- regression testing parser support against real-world scripts
39-
- scanning Pine corpora to find unsupported syntax patterns
40-
- building higher-level Pine tooling on top of Python
36+
## Pine Version
37+
38+
This project currently targets Pine Script v6 for built-in metadata coverage, namespace validation, and most real-world compatibility expectations.
39+
40+
If a script relies on older undocumented behavior or version-specific quirks outside the current validator rules, additional parser or semantic support may still be needed.
4141

4242
## Installation
4343

@@ -49,7 +49,7 @@ pip install -e .
4949

5050
## Quick Start
5151

52-
Validate a file in human-readable mode:
52+
Validate a file in text mode:
5353

5454
```powershell
5555
pine-validator path\to\script.pine
@@ -67,7 +67,7 @@ Emit agent-oriented debugging output:
6767
pine-validator path\to\script.pine --agent-json
6868
```
6969

70-
Validate an entire directory of Pine files:
70+
Validate an entire directory:
7171

7272
```powershell
7373
pine-validator path\to\pine-scripts --agent-json
@@ -79,54 +79,48 @@ Emit SARIF for CI or review tooling:
7979
pine-validator path\to\pine-scripts --sarif
8080
```
8181

82-
Show only errors and warnings:
83-
84-
```powershell
85-
pine-validator path\to\script.pine --no-hints --no-information
86-
```
87-
88-
Show only hints during cleanup:
89-
90-
```powershell
91-
pine-validator path\to\script.pine --no-errors --no-warnings --hints
92-
```
93-
9482
Validate from stdin:
9583

9684
```powershell
9785
Get-Content path\to\script.pine | python -m pinescript_validator.cli - --agent-json
9886
```
9987

100-
## Agent Debugging Workflow
88+
## Agent Workflow
10189

10290
Recommended loop for an agent:
10391

104-
1. Run `pine-validator script.pine --agent-json`
105-
2. Read `summary.error` first and fix hard failures before hints
106-
3. Use each diagnostic's `excerpt`, `pointer`, and `suggestion` fields to prepare the next code edit
107-
4. Re-run validation after every edit until `ok` becomes `true`
92+
1. Run `pine-validator script.pine --agent-json --no-hints --no-information`
93+
2. Fix hard failures first
94+
3. Re-run until `summary.error` becomes `0`
95+
4. Re-run with warnings and hints enabled for cleanup
10896

109-
The `--agent-json` mode is designed to reduce guesswork in automated debugging loops.
97+
For larger agent workflows, point the CLI at a directory and process the batch report file by file.
11098

111-
For larger agent workflows, you can point the CLI at a directory and let the agent process the batch report file by file.
99+
## Severity Controls
112100

113-
## Example Agent Output
101+
Diagnostics are ordered by severity first, then by source location. By default the CLI prints:
114102

115-
Input:
103+
1. errors
104+
2. warnings
105+
3. information
106+
4. hints
116107

117-
```pine
118-
indicator("Example")
119-
value = close
120-
plot(close, invalid_param=true)
121-
```
122-
123-
Command:
108+
Each level can be toggled independently:
124109

125110
```powershell
126-
pine-validator example.pine --agent-json
111+
pine-validator script.pine --no-hints --no-information
112+
pine-validator script.pine --no-errors --no-warnings --hints
113+
pine-validator scripts\*.pine --agent-json --warnings --hints --no-information
127114
```
128115

129-
Output shape:
116+
Supported toggles:
117+
118+
- `--errors` / `--no-errors`
119+
- `--warnings` / `--no-warnings`
120+
- `--information` / `--no-information`
121+
- `--hints` / `--no-hints`
122+
123+
## Example Agent Output
130124

131125
```json
132126
{
@@ -160,19 +154,11 @@ Output shape:
160154

161155
## CLI Modes
162156

163-
`pine-validator` currently supports:
164-
165157
- default text output for humans
166158
- `--json` for plain machine-readable diagnostics
167159
- `--agent-json` for richer debugging output intended for agents and automation
168160
- directory and multi-file batch validation
169161
- `--sarif` for CI, code scanning, and external review integrations
170-
- `--errors/--no-errors`
171-
- `--warnings/--no-warnings`
172-
- `--information/--no-information`
173-
- `--hints/--no-hints`
174-
175-
Diagnostics are ordered by severity first, then by source location. By default the CLI prints errors first, then warnings, then information messages, and finally hints.
176162

177163
Exit codes:
178164

@@ -183,15 +169,8 @@ Exit codes:
183169

184170
The audit command scans one or more script roots, compares observed Pine usage against bundled metadata and local documentation, and writes report files for broader maintenance work.
185171

186-
Run with default paths:
187-
188172
```powershell
189173
python -m pinescript_validator.audit
190-
```
191-
192-
Run with explicit roots:
193-
194-
```powershell
195174
python -m pinescript_validator.audit --scripts-root ..\ExternalScripts --docs-root ..\PineTool\pinescript_docs
196175
```
197176

@@ -200,8 +179,6 @@ Generated outputs:
200179
- `smart_audit_report.json`
201180
- `smart_audit_report.md`
202181

203-
Audit mode is useful when you want to improve the validator itself, not just debug one script.
204-
205182
## Development
206183

207184
Run the tests:
@@ -213,27 +190,20 @@ python -m pytest -q
213190
Project layout:
214191

215192
```text
216-
src/pinescript_validator/ Parser, validator, CLI, audit, and agent-report modules
193+
src/pinescript_validator/ Parser, validator, CLI, audit, agent-report, and SARIF modules
217194
tests/ Regression and feature tests
218195
pyproject.toml Packaging and pytest configuration
219196
```
220197

221-
## Current Scope
222-
223-
This project is a validator and static analysis tool, not a Pine runtime.
224-
225-
It currently focuses on:
226-
227-
- practical parser coverage for real Pine scripts
228-
- useful diagnostics for local debugging
229-
- machine-readable output for agents and tooling
230-
- ongoing reduction of false positives and noisy hints
198+
Contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md)
231199

232-
## Limitations
200+
## Scope And Limitations
233201

234-
- It does not execute Pine Script or simulate TradingView runtime behavior
235-
- Some undocumented or rare Pine patterns may still need parser support
236-
- Suggested remediation text in `--agent-json` is heuristic guidance, not a guaranteed autofix
202+
- This is a validator and static analysis tool, not a Pine runtime
203+
- The current compatibility target is Pine Script v6
204+
- It does not simulate TradingView execution behavior
205+
- Some rare or undocumented Pine patterns may still need parser support
206+
- `--agent-json` suggestions are heuristic guidance, not guaranteed autofixes
237207
- Validation quality depends on the bundled metadata and implemented semantic rules
238208

239209
## Roadmap

pyproject.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "pinescript-validator"
77
version = "0.1.0"
8-
description = "Agent-friendly Pine Script validator and audit toolkit for TradingView scripts."
8+
description = "Static validator, audit CLI, and agent-debugging toolkit for TradingView Pine Script v6."
99
readme = "README.md"
1010
requires-python = ">=3.11"
1111
dependencies = []
@@ -14,10 +14,22 @@ authors = [
1414
]
1515
license = "MIT"
1616
keywords = ["pine-script", "tradingview", "validator", "parser", "lint", "agents", "debugging"]
17+
classifiers = [
18+
"Development Status :: 4 - Beta",
19+
"Intended Audience :: Developers",
20+
"License :: OSI Approved :: MIT License",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
"Topic :: Software Development :: Compilers",
26+
"Topic :: Software Development :: Quality Assurance",
27+
]
1728

1829
[project.urls]
1930
Homepage = "https://github.com/Poryaei/pine-script-validator"
2031
Repository = "https://github.com/Poryaei/pine-script-validator"
32+
Issues = "https://github.com/Poryaei/pine-script-validator/issues"
2133

2234
[project.scripts]
2335
pine-validator = "pinescript_validator.cli:main"

0 commit comments

Comments
 (0)