Intract
AI Cost Tracking
This project uses AI-generated code. Total cost: $3.1500 with 21 AI commits.
Generated on 2026-06-29 using openrouter/qwen/qwen3-coder-next
Intract is an intent-contract layer for codebases and software delivery artifacts.
It lets you describe, validate and monitor intent across:
code
functions
classes
files
project manifests
API endpoints
Dockerfiles
CI/CD workflows
Kubernetes manifests
DevOps artifacts
Intract is not primarily a programming language. It is a contract system for short, portable intent declarations.
Quick example
# Comment form (all supported languages)
# @intract.v1 scope:function intent:validate:user_permission priority:1 domain:security input:user,resource output:allowed effect:none forbid:write,network validate:input_presence,return_value,no_forbidden_effect meaning:"check whether user can modify resource without changing state"
def can_update_resource(user, resource):
return user.is_admin or resource.owner_id == user.id
Decorator form (same contract model, no comment prefix):
@intract.v1 id:safe-decoder scope:function intent:decode:header domain:security forbid:unsafe
pub fn decode_header(raw_data: &[u8]) -> Header {
// ...
}
Rust attributes are also accepted: #[intract.v1 id:safe-decoder intent:decode:header forbid:unsafe].
Run:
python -m intract scan .
python -m intract validate .
Practical usage (small and large projects)
Poniżej gotowe wzorce użycia, które możesz pokazać zespołowi jako „jak to działa w praktyce”.
1) Mały projekt (1 repo, 1-3 usług)
Cel: szybko pilnować intencji funkcji i nie spowalniać developmentu.
Przykładowe technologie:
- Python API (
@intract.v1nad funkcjami serwisowymi) - TypeScript frontend (kontrakty
ui.*,validate.*) - Dockerfile (kontrakty deploy, np.
forbid:root_user)
Workflow:
# lokalnie podczas developmentu
python -m intract validate .
python -m intract check --staged --hunks
# szybki podgląd pokrycia i duplikatów intencji
python -m intract coverage .
python -m intract duplicates . --threshold 0.8
2) Duży projekt (monorepo, wiele zespołów)
Cel: rozdzielić intencje na domeny i mieć osobne bramki jakości.
Przykładowe technologie w 1 monorepo:
- Backend: Python + Java + Go
- Frontend: TypeScript
- Platforma: Dockerfile, Kubernetes, GitHub Actions/OpenAPI
Workflow:
# pełna walidacja release branch
python -m intract validate . --manifest intract.yaml
# raport do security/code scanning
python -m intract check . --format sarif --output intract.sarif
# graf zależności intencji i braków require
python -m intract graph . --format mermaid
Fokus na kategorie intencji (dev vs CI/CD)
Najpraktyczniej mieć osobne manifesty lub sekcje dla różnych etapów pracy:
intract.dev.yaml→ fokus na poprawność funkcji (domain:app,domain:logic)intract.ci.security.yaml→ fokus na bezpieczeństwo (domain:security,forbid:network/write/unsafe)
Przykład uruchamiania:
# development: sprawdzamy głównie intencje funkcji
python -m intract validate . --manifest intract.dev.yaml
# CI/CD: sprawdzamy głównie bezpieczeństwo i artefakty dostarczeniowe
python -m intract validate . --manifest intract.ci.security.yaml
python -m intract scan . --all-artifacts --json
W praktyce daje to możliwość „przełączania radaru”:
- dev: czy funkcja robi to, co obiecuje (
intent,input/output,return) - CI/CD: czy release spełnia polityki bezpieczeństwa (network, secrets, root, workflow)
Automatyczne generowanie intencji
Intract wspiera generowanie kontraktów automatycznie (LLM i engine):
# 1) propozycje kontraktów z konkretnego pliku (LLM)
python -m intract propose llm --file src/auth.py --goal "RBAC without network side effects"
# 2) sugestie engine dla projektu
python -m intract engine suggest .
# 3) walidacja po zaakceptowaniu propozycji
python -m intract validate .
Wskazówka: zacznij od małej liczby kontraktów (kluczowe funkcje), potem rozszerzaj obszary.
Greenfield demo: NLP -> Intract -> Code
Poniższy scenariusz pokazuje start od zera dla nowej aplikacji.
Krok 1: Nowy projekt
mkdir my-app && cd my-app
python -m venv .venv
source .venv/bin/activate
pip install intract
python -m intract init .
Krok 2: Opis celu językiem naturalnym (NLP)
Przykład celu:
"Zbuduj API do zarządzania zadaniami. Endpoint create-task ma walidować input, nie może robić zewnętrznych wywołań sieciowych i ma zwracać jawny status."
Krok 3: Wygeneruj kontrakty z NLP na kod
Tworzysz szkic pliku (src/tasks.py) i prosisz Intract/LLM o propozycje:
python -m intract propose llm --file src/tasks.py --goal "task API: validate input, no network, explicit status"
Wynik to linie @intract.v1 ..., które możesz wkleić nad funkcje lub przenieść do manifestu Toon/YAML.
Krok 4: Implementuj kod pod kontrakty
Implementujesz funkcje zgodnie z intencją, np.:
intent:create:taskforbid:networkvalidate:input_presence,return_value
Krok 5: Pętla deweloperska i CI
# lokalnie
python -m intract check --staged --hunks
# w CI
python -m intract validate .
python -m intract check . --format sarif --output intract.sarif
Efekt: flow przechodzi od wymagań NLP, przez kontrakty intencji, do kodu i automatycznej walidacji jakości.
External Target Addressing (Toon Manifests)
In addition to inline annotations, Intract supports two ways of defining quality gates and intent contracts:
- Inline Comments: Using
@intract.v1in source files (with#,//,--, or HTML comment prefixes). - Inline Decorators: Bare
@intract.v1 ...lines or Rust#[intract.v1 ...]attributes on the line above the governed block. - External manifests (Toon Manifests): Decoupled files (
.toonorintract.toon.yaml) that specify precise coordinates (targets) for files, functions, lines, and XPaths.
1. Płaski format URI linia po linii (.toon)
Pliki .toon używają struktury URI do prostego i przejrzystego przypisywania kontraktów na poziomie konkretnych linii, funkcji lub selektorów:
# Flat target-based URI rules
intract://src/calc.py?func=add#id=pure-addition&intent=pure-add&forbid=write
intract://src/calc.py?func=write_to_log&line=13#id=log-write&intent=write-log&require=write
2. Manifest YAML z targetowaniem (intract.toon.yaml)
Możesz również zdefiniować zasady w formacie YAML, podając sekcję target:
version: intract.v1
contracts:
- id: addition-check
intent: pure:addition
forbid: [write]
target:
file: src/calc.py
function: add
Więcej informacji i pełne przykłady znajdziesz w katalogu examples/toon/.
Documentation
Start here:
- Docs index
- Getting Started
- Commands Reference
- Contract Format
- Manifest
intract.yaml - Architecture
- Validation Model
- Watch & Engine
- Plugins
- Integrations
- Roadmap
- SUMD Descriptor
SUMD-based operational view
Dokument SUMD.md jest źródłem opisu operacyjnego projektu (workflow, pipeline jakości, interfejsy, env).
Architecture flow:
SUMD (description) -> DOQL/source (code) -> taskfile (automation) -> testql (verification)
Interfaces:
- CLI entry points:
intract,intract-mcp - testql scenarios:
testql-scenarios/generated-cli-tests.testql.toon.yaml
Quality pipeline (pyqual.yaml) — najważniejsze etapy:
test(python -m pytest -q --tb=short)intract_contracts(validate,check,duplicatesnaexamples/full-stack)intract_artifacts(scan --all-artifacts --jsondo.pyqual/artifacts.json)intract_web_app(validateiscandlaexamples/web-app/iterations/v1-pass+run-demo.sh)intract_demo_ci(bash scripts/ci-full-stack.sh)
Environment variables (.env.example) używane w automatyzacji:
OPENROUTER_API_KEYLLM_MODELPFIX_AUTO_APPLY,PFIX_AUTO_INSTALL_DEPS,PFIX_AUTO_RESTARTPFIX_MAX_RETRIES,PFIX_DRY_RUN,PFIX_ENABLEDPFIX_GIT_COMMIT,PFIX_GIT_PREFIX,PFIX_CREATE_BACKUPS
Release and build references:
goal.yaml(semver, conventional commits, changelog)Makefiletargets:install,test,lint,format- analysis artifacts:
project/map.toon.yaml,project/context.md,project/prompt.txt
Important project locations
Core:
src/intract/src/intract/models.pysrc/intract/parser.pysrc/intract/signature.pysrc/intract/validation.py
Operational modules:
src/intract/cli.pysrc/intract/config.pysrc/intract/policy.pysrc/intract/git.pysrc/intract/watch.py
Analysis engine:
src/intract/engine/src/intract/engine/scanner.pysrc/intract/engine/analyzer.pysrc/intract/engine/assigner.pysrc/intract/engine/drift.pysrc/intract/engine/monitor.py
Plugins and integrations:
src/intract/plugins/src/intract/integrations/src/intract/integrations/planfile.pysrc/intract/artifacts.pysrc/intract/reporters/sarif.py
Schemas and templates:
schemas/intract.schema.jsontemplates/templates/intract.yamltemplates/pyproject-intract.tomltemplates/openapi.intract.yamltemplates/Dockerfile.intract
Examples:
examples/README.md— indeks wszystkich przykładówexamples/web-app/— aplikacja webowa: iteracje v1/v2 + mock UIexamples/full-stack/— graf, duplikaty intencjiexamples/integration_tests/
SDKs:
CI / packaging:
Installation
pip install -e .[dev]
Main commands
python -m intract scan .
python -m intract validate .
python -m intract check .
python -m intract check --staged
python -m intract check --changed --base main
python -m intract check . --format sarif --output intract.sarif
python -m intract check-manifest intract.yaml
python -m intract coverage .
python -m intract duplicates .
python -m intract graph . --format mermaid
python -m intract watch .
python -m intract tickets .
python -m intract artifact Dockerfile
python -m intract artifact openapi.yaml
python -m intract engine suggest .
python -m intract engine drift .
python -m intract engine run .
Run examples
python examples/integration_tests/run_examples.py
Expected:
example_01: pass
example_02: violation + planfile-compatible ticket
example_03: watch/engine/drift works
Project manifest
Generate:
python -m intract init .
Validate:
python -m intract check-manifest intract.yaml
python -m intract validate . --manifest intract.yaml
Pre-commit
Example .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: intract
name: intract intent contracts
entry: intract check --staged
language: system
pass_filenames: false
SARIF / GitHub Code Scanning
python -m intract check . --format sarif --output intract.sarif
GitHub workflow:
License
Licensed under Apache-2.0.
Metadata
Release files for intract 0.5.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| intract-0.5.14.tar.gz | 2.5 MB | Without provenance | Details for intract-0.5.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| intract-0.5.14-py3-none-any.whl | Python 3 | none | any | Details for intract-0.5.14-py3-none-any.whl |
Total release size: 2.6 MB
Release files / intract-0.5.14.tar.gz
| Download URL | intract-0.5.14.tar.gz |
|---|---|
| Size | 2.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2271f15d199f269443d9d75ed93fe331798b04106240821ecb23edeeaa13708
|
|
BLAKE2b-256 checksum How to use checksums |
4ea22a457d85dbeae22162dac5183dabf65583e100d5b15f206312c5773ce3e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / intract-0.5.14-py3-none-any.whl
| Download URL | intract-0.5.14-py3-none-any.whl |
|---|---|
| Size | 95.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fef9dca9a8967d10db636bfbf078b591e6274d6c6b2e65384b4777c7ce45c6af
|
|
BLAKE2b-256 checksum How to use checksums |
0b53b433f6e47ea24b8ade0f53b2e9381946dc6e0d4cf26a0359a2ccbe48ab5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for intract 0.5.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.