@amartinr/pi-ts-prelint
Pre-write TypeScript linting for pi — non-blocking tsc check on .ts/.tsx files with error injection
Package details
Install @amartinr/pi-ts-prelint from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@amartinr/pi-ts-prelint- Package
@amartinr/pi-ts-prelint- Version
0.1.0-rc.1- Published
- Jun 3, 2026
- Downloads
- 1,176/mo · 28/wk
- Author
- amartinr
- License
- MIT
- Types
- extension
- Size
- 51.7 KB
- Dependencies
- 1 dependency · 1 peer
Pi manifest JSON
{
"extensions": [
"./dist"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-ts-prelint
⚠️ Experimental — untested hypothesis
This extension is based on an unproven idea: that catching TypeScript compilation errors early improves code quality and saves tokens. No data supports this claim yet. It is in early development. APIs, configuration, and behavior may change without notice.
What it does
Intercepts write and edit tool calls on .ts/.tsx files and runs tsc --noEmit to check for compilation errors. If compilation fails, the change is still applied (so the model sees the modified file), but the structured error messages are injected into the tool result so the model can fix them in the next turn.
This is an experiment. We don't yet know whether it actually helps.
How it works
The extension intercepts write and edit tool calls for TypeScript files:
- Intercepts
writeandedittool calls for TypeScript files. - Writes the candidate content to a temp file (prefixed with
~) to calculate the diff with the existing file. - Computes the change complexity (modified lines / total lines) to decide whether linting is worth the cost.
- If the change is large enough, runs
tsc --noEmiton the real file (already modified by the original tool) using a minimal temp tsconfig that copies compiler options from the project. - If compilation fails, stores the errors and lets the change proceed (the file is modified).
- After the tool executes, injects the compilation errors into the tool result — optionally including a diff of what changed, so the model can correlate errors with specific modifications.
- Cleans up the temp file.
The model always sees the modified file state, avoiding the confusion that arises when edits are blocked and the model tries to re-apply changes on stale file content.
Limitations
- Only covers
.tsand.tsxfiles. - Requires
npxand a localtypescriptinstallation in the project. - If
tscthrows unexpectedly, the change is allowed to proceed as a fail-safe. - Compilation errors are not blocking — the model must notice and fix them on its own.
- Only checks the affected file, not the entire project — cross-file dependency errors may be missed.
Configuration
Configuration is loaded from two sources, merged with project-level taking priority:
| Scope | Path |
|---|---|
| Global | ~/.pi/agent/extensions/pi-ts-prelint/config.json |
| Project | .pi/pi-ts-prelint.json |
Config file format
{
"changeComplexity": {
"minAbsoluteLines": 15,
"minPercentage": 10
},
"diffThreshold": {
"minErrorsToShow": 3,
"maxAbsoluteLines": 50,
"maxPercentage": 50
}
}
Options
| Option | Default | Description |
|---|---|---|
changeComplexity.minAbsoluteLines |
15 |
Minimum modified lines to trigger linting (AND with percentage) |
changeComplexity.minPercentage |
10 |
Minimum modified % of existing file to trigger linting |
diffThreshold.minErrorsToShow |
3 |
Minimum compilation errors to include diff in error message |
diffThreshold.maxAbsoluteLines |
50 |
Maximum modified lines to include diff in error message |
diffThreshold.maxPercentage |
50 |
Maximum modified % of new file to include diff in error message |
Examples
Skip linting on smaller edits (project-level):
.pi/pi-ts-prelint.json
{
"changeComplexity": {
"minAbsoluteLines": 3,
"minPercentage": 2
}
}
Show diff only for 2+ errors (lower threshold):
.pi/pi-ts-prelint.json
{
"diffThreshold": {
"minErrorsToShow": 2
}
}
Merging behavior
Global config is loaded first, then project config is deep-merged on top. You only need to specify the keys you want to override:
~/.pi/agent/extensions/pi-ts-prelint/config.json (global defaults)
{
"changeComplexity": {
"minAbsoluteLines": 15,
"minPercentage": 10
}
}
.pi/pi-ts-prelint.json (project overrides only)
{
"changeComplexity": {
"minAbsoluteLines": 3
}
}
Result: minAbsoluteLines=3, minPercentage=10 (unchanged from global).
Installation
⚠️ This is an experimental extension based on an untested hypothesis. Use at your own discretion.
Global (all projects)
Copy the extension to your global extensions directory:
mkdir -p ~/.pi/agent/extensions/pi-ts-prelint
# The extension is loaded automatically as a pi package
Project-local
Add to your .pi/settings.json:
{
"packages": ["npm:pi-ts-prelint"]
}
Or place a .pi/pi-ts-prelint.json in your project root to customize thresholds.
Design
The full design document, including the hypothesis and implementation details, is available in docs/DESIGN.md.
License
MIT