Skip to content
sedulustechPublic

Latest commit

 

History

728 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jint

jint, an extensible semantic linter

jint constructs state with Treesitter, and classifies the state against a set of user defined rules using a provider. It then turns the classification values into actionable output via per-rule callbacks.

Read the blogpost!

Why

The best outcome is one where an agent can infer what you expect from the sources you give it, so you go from idea to code without reviewing every step or handholding the agent. jint is the first step: it verifies what a syntax check cannot see (naming, intent, error handling, comments), and an agent reads its findings to correct itself.

Results:

Install

Install through NPM:

npm install -g @sedulus/jint@rc   # or a devDependency
npx @sedulus/jint@rc --version

Or through an install script:

curl -fsSL https://raw.githubusercontent.com/sedulustech/jint/main/install.sh | bash

The script installs the beta build, the only channel for now, and checks it against its checksums.

To build from source, see Development.

No runtime needed

The binary ships with virtual modules and the Bun runtime: you do not need to have a JS runtime locally to write your own .ts rules.

On Linux the only system requirement is glibc (any mainstream distro). On musl-based images (Alpine), install a glibc layer first or use a glibc base image.

import { rules as comments } from "jint:rules/comments";
import { is_greppable } from "jint:rules/naming";

export default { rules: { use: [...comments, is_greppable] } };

Skill

Skills for agents live in skills/: following-rule-results (run jint, fix findings), writing-rules (write and calibrate rules), writing-captures (add the captures a rule needs) and propose-rules (turn what you expect into rules, so the agent can verify its own work). The CLI carries them: jint skills export <path> writes them into the directory you name, such as .claude/skills.

How to use

jint asks its questions of one endpoint. By default that is OpenAI's Decisions API with the model gpt-6-luna. To use another endpoint, set its url: the last segment names the protocol, /decisions for the OpenAI Decisions API or /v1/systemone for TypeSafe and Lemonade.

export OPENAI_API_KEY=...      # ask OpenAI directly (api.openai.com)
# or another endpoint
export JINT_API_URL=...        # its url (ends in /decisions or /v1/systemone)
export JINT_API_KEY=...        # its key (a server on this machine needs none)
export JINT_API_MODEL=...      # its model (required for /v1/systemone, except on TypeSafe's host)

A key is only ever sent to the url it is paired with: OPENAI_API_KEY goes to api.openai.com and nowhere else. A config holds none of these, because a config is committed. See models and endpoints for local models.

Caching. jint stores every answer on disk ($JINT_CACHE_DIR, else ~/.jint/cache), one per question. Asking the same question about the same code again sends nothing and reads the same. Edit one rule and only that rule's questions go out. jint run --no-cache asks everything.

The endpoint also caches repeated input on its side (an input of 1,024 tokens or more, for about 30 minutes). jint sends each element's code first and its questions after, so a question that does go out reuses the code at a lower cost. An element under 1,024 tokens never caches there.

jint run src/                             # a directory tree
jint run src/a.ts src/b.ts                # named files: scope-checked, the rules scope applies
cat snippet.ts | jint run str -           # piped stdin, one str unit (the only str form)
jint run paths - < list.txt               # a path LIST from a file, piped: scope-checked like named files
git diff --name-only HEAD~1 | jint run paths -  # a path LIST from your git pipeline
jint run                                  # no operand: input comes from auto-discovered config

jint capture src/a.ts                     # extraction only: grammar, kind, span, name - one line per element
jint capture src/ --queries wip.scm       # your own .scm drives extraction (--grammar <dir>: your own grammar)
jint capture src/a.ts --json              # the element array as one JSON document
jint capture                              # no target: walks the config's input, like run
jint capture --rule is_greppable          # preview: mark the population one rule will judge (nothing is classified)
jint ui serve                                # the run UI over the store's newest run, held (Ctrl+C to exit)

The first positional is the verb: run, ui, capture, reclassify, skills, or docs. There is no implicit verb - jint src/ is a usage error telling you to write jint run src/.

jint auto-discovers jint.config.ts or jint.config.json in the working directory. --config <path> overrides discovery.

capture loads the config through the same scope run does, so it measures the same population a run will classify: with no target it walks the config's input; with a target it walks that path under the config's still-applicable scoping (exclude, include, secretDenylist; the --exclude flag unions on top, as in run). A config run cannot load, capture cannot either - same error, same message.

capture --rule <name> previews one rule's population before any classification: the elements the rule's target and scope globs (include/exclude lists) would measure render with a leading * marker column (unmatched lines keep the column as a space), and carry "matches": true in --json - absent otherwise, never false. Shipped rules are addressed by name, config rules by theirs; an unknown name is run's own loud unknown rule error. Iterate on rules and scopes against this preview, then classify.

Every run records its requests to ~/.jint/runs/ (or what's set by JINT_RUNS_DIR). The custom grammar dir is ~/.jint/grammars (or what's set by JINT_GRAMMAR_DIR) - the bring-your-own-grammar seam, docs/byog.md.

Scope

rules: { include, exclude, use } in the config: use holds the rules, and include/exclude are the default scope of every rule - the files the walk reads, and the files a rule measures when it declares no include of its own. A rule's own include/exclude replaces them for that rule. How you name files decides whether that scope applies:

  • a directory is walked under the rules scope;
  • named files (jint run src/a.test.ts) and a piped path list (jint run paths -) are scope-checked: a file the rules scope excludes is skipped, with a note that names --unscoped;
  • --unscoped measures named files and a path list as given: the rules scope does not apply, but a rule's own include/exclude still scopes that rule.

Every run prints a header with the config it used, its rules scope, and which of these applied. Use the path list to measure exactly a changeset: git diff --name-only | jint run paths -.

Rules

// jint.config.ts
export default {
  input: "src/",
  rules: {
    use: [
      {
        name: "is_cognitively_complex",
        kind: "score",
        instructions:
          "How much EFFORT does a reader need to follow this code's logic - effort caused by structure the author chose, not by the problem itself? Ignore length alone: a long linear unit with one job reads as easy. Ignore inherent complexity: cases the data or the domain genuinely force are not this failure. Judge how hard the code's own structure makes it to read top-to-bottom.",
        criteria: [
          "Easy: the logic reads top-to-bottom. A single pass suffices. Any difficulty present is inherent to the problem, not to the structure.",
          "Moderate: the reader must pause once or twice - hold a small amount of state across a few lines, or re-check an outer condition - but the structure is otherwise linear and the full flow is recoverable by re-reading one or two spots.",
          "Hard: following the code requires actively reconstructing its flow - a stack of nested conditions to track, several unrelated concerns fused into one unit, state held across many lines, or an order that forces jumps instead of top-to-bottom reading. The structural difficulty could be removed without changing what the code does.",
        ],
        target: "definitions",
        handle: { map: ["pass", "warn", "error"] },
      },
    ],
  },
};

target names what the rule judges, as one value or a list:

target what it judges
files the whole file as one unit
functions each function or method
classes each class-like unit
methods each member function
types interfaces, structs, enums, aliases
bindings each name bound to a non-callable, non-type value
definitions every declaration except comments and imports
comments the comment pair frame (a definition judged together with its owned comments)
loose-comments comments with no definition frame
imports the file's imports as one merged unit

Beyond the shared targets, a grammar-scoped capture address <lang>:<capture> reaches a grammar's own emitted captures (e.g. markdown:h2 - the grammar's queries.scm is the single source; unknown grammar or unemitted capture is a setup error).

Full table: docs/targets.md (generated from the live resolution).

Handles carry an optional per-tier message - an instruction to the caller fixing the finding: severity says whether, message says how. In the declarative form it sits beside the threshold; it renders beneath the finding line and rides the report as finding.message.

// a noul rule's handle with author guidance on the error tier only
"handle": {
  "warn":  { "greater_than": 0.55 },
  "error": {
    "greater_than": 0.7,
    "message": "Delete the comment if it only pins a name. Keep it only if it teaches something the code cannot."
  }
}

A TS config rule may also carry a callback handle: (results, ctx) => decisions, called once after classification with one decision per classification: { severity: "error" | "warn" | null, message? }. null severity is silent (classification only).

Rule domains

jint runs only the rules a config names. There is no default set: a run with no config, or a config with no rules, fails with the list of domains and the rules in each, so an agent can read the error and write the config for the codebase it is in.

Rules are grouped by domain, one package each, imported as jint:rules/<domain>:

  • comments: narration, readability patches, drift.
  • complexity: cognitive complexity, single responsibility.
  • errors: error handling that loses its cause.
  • naming: vocabulary, casing, greppability, file names that match their bodies.
  • security: a secret or personal value in plain text in a json, toml or yaml file.

A domain exports each rule under its own name and the whole domain as rules. A technology is a domain too (typescript, react), and a domain may nest subdomains (comments/typescript). The shipped rules were calibrated and dogfooded against jint's own src/ and other repositories; treat them as a starting point.

A rule name that appears twice in a config is an error naming both entries. To replace a rule, spread it, change it, and set override: true: { ...is_greppable, include: ["src/**"], override: true }.

The rules live in packages/rules/<domain>/src/index.ts.

Custom grammars

Any tree-sitter grammar works through the bring-your-own-grammar seam: one directory named for the grammar id, holding three artifacts - <id>.wasm, extensions.json, queries.scm - under ~/.jint/grammars (or what JINT_GRAMMAR_DIR points to). The queries assign the shared capture vocabulary (@function, @class, @type, ...), so every rule target works on your language the moment the queries speak it. The full contract, validation errors, and a worked verilog example: docs/byog.md.

UI

jint ui serve opens a local dashboard useful for rule calibrations, over the newest recorded run (the fix loop: measure with jint run, then look with jint ui serve). It binds loopback only (127.0.0.1); override via JINT_UI_HOST - a non-loopback bind is your trust decision, nothing authenticates the served data. JINT_UI_HOST names a host, not host:port (the port is JINT_UI_PORT; a port suffix is rejected). Wildcards are not usable: 0.0.0.0 binds wide, but the Host guard still rejects browser requests (their Host header is the LAN address) - bind the concrete host you intend. It polls the run directory for new runs and displays useful information to verify the applicability of a rule to a lexical unit. It shows, among other things:

  • tokens used
  • duration
  • requests made
  • summary of the run
  • warning and errors grouped by rule and files

Development

bun install
bun run validate        # schema -> typecheck -> lint
bun test                # full suite
bun run cli:build      # builds the CLI binary

Glossary

The canonical vocabulary to understand the codebase lives in GLOSSARY.md. It is the constraint the code and docs are held to, so it is maintained there rather than copied here.