codeint provides Wave 1 client SDKs in three languages so tools and scripts can call codeint directly without parsing terminal text (ADR 0038):
- JavaScript and TypeScript (
codeinton npm,npm/codeint): dual ESM and CommonJS package with TypeScript declarations, zero runtime dependencies, and per-platform native binaryoptionalDependencies(@avidian/codeint-{os}-{arch}). - Rust (
codeinton crates.io,crates/cli): in-process typed Rust library and CLI binary crate (cargo install codeint/cargo add codeint). - Dart (
codeinton pub.dev,sdks/dart): pure Dart package (sdk: ^3.6.0, zero Flutter dependency) with a 4-step SHA-256-verified binary resolver anddart run codeintCLI forwarding.
Every Wave 1 client SDK exposes all 19 non-interactive operations across 18 commands: check, diff, trend, impact, trace, init (with format and adopt), guard, schema, config, report, doctor, agent status, agent install, churn, coupling, ratchet update, baseline update, state check, and plugin test.
codeint mcp and codeint update remain CLI-only.
All three client SDKs share the same failure model:
- Gated operations (
check,diff,state check,doctor, andplugin test) return a structured pass/fail outcome on both exit0(passed) and exit1(Budget, Ratchet, Regression, state-check violation,doctorblocking error, orplugin testfailure).- TypeScript/JavaScript resolves to
GatedResult<TReport>({ passed, exitCode, failures, report, rendered? }, withrenderedpopulated bydiffwhenformatis set). - Rust returns
Ok(GatedOutcome<T>)(passed,failures,report, and optionalrenderedpopulated bydiffwhenDiffOptions.formatis set). - Dart resolves to
GatedOutcome<T>(passed,exitCode,failures,report, and optionalrenderedpopulated bydiffwhenDiffOptions.formatis set).
- TypeScript/JavaScript resolves to
- Operational errors (exit
2, such as an invalid configuration file, a missing folder, an unknown Git ref, a directory outside Git, or a binary-resolution failure) fail loudly:- TypeScript/JavaScript rejects asynchronously with
CodeintError(message,exitCode,stderr, andcause), including when binary resolution fails on an unsupported platform, a missing optional platform package, or a missing binary file. - Rust returns
Err(CodeintError)withmessage()andremedy(). - Dart throws
CodeintErrorwithmessage,exitCode,stderr, andcause.
- TypeScript/JavaScript rejects asynchronously with
Every client SDK accepts full CLI option parity for every exposed operation. See docs/reference.md for the exact semantics of each command and flag.
| CLI command | TypeScript / JS | Rust (codeint) |
Dart (CodeintClient) |
Gated | Key options |
|---|---|---|---|---|---|
check |
check(options?) |
check(folder, &CheckOptions) |
check([CheckOptions]) |
Yes | path, all, package, owner, coverageReports / coverage_reports, ignoreBaseline / ignore_baseline |
diff |
diff(baseRef, options?) |
diff(folder, base_ref, &DiffOptions) |
diff(baseRef, [DiffOptions]) |
Yes | headRef / head_ref, renameThreshold / rename_threshold, format, all, package, owner, output (TypeScript, Dart), resultCache / result_cache |
trend |
trend(options?) |
trend(folder, &TrendOptions) |
trend([TrendOptions]) |
No | since, commits (CLI, TypeScript) / last (Dart) / range (Rust), resultCache / result_cache |
impact |
impact(options) |
impact(folder, &ImpactOptions) |
impact([ImpactOptions]) |
No | paths, changed, depth, package |
trace |
trace(from, to, options?) |
trace(folder, from, to, &TraceOptions) |
trace(from, to, [TraceOptions]) |
No | all, maxPaths / max_paths, package |
init |
init(options?) |
init(folder, &InitOptions) |
init([InitOptions]) |
No | format (jsonc, json, toml, yaml), adopt |
guard |
guard(targetPath, options?) |
guard(folder, target) |
guard(path) |
No | targetPath / target / path |
schema |
schema(options?) |
schema() |
schema() |
No | output (TypeScript) |
config |
config(options?) |
resolved_config(folder, &ConfigOverrides) |
config([ConfigOptions]) |
No | path, budgets, sourceSets / source_sets, pluginMemoryMb / plugin_memory_mb, pluginTimeoutMs / plugin_timeout_ms |
report |
report(input, options?) |
rerender_report(folder, input, &RerenderReportOptions) |
report(input, [ReportOptions]) |
No | format (toon, text, json, sarif, markdown), all, output |
doctor |
doctor(options?) |
doctor(folder, &PluginHostConfig) |
doctor([DoctorOptions]) |
Yes | path (TypeScript, Dart), plugin_host (Rust) |
agent status |
agentStatus(options?) |
agent_status(config_root, client) |
agentStatus([AgentStatusOptions]) |
No | client (claude-code, cursor, codex), configRoot / config_root |
agent install |
agentInstall(options?) |
agent_install(config_root, client, dry_run) |
agentInstall([AgentInstallOptions]) |
No | client, configRoot / config_root, dryRun / dry_run |
churn |
churn(options?) |
churn(folder, &ChurnOptions) |
churn([ChurnOptions]) |
No | since, commits / window, all / findings |
coupling |
coupling(options?) |
coupling(folder, &CouplingOptions) |
coupling([CouplingOptions]) |
No | since, commits, all, maxCommitFiles / max_commit_files, minCoChanges / min_co_changes, minRatio / min_ratio, includeTests / include_tests |
ratchet update |
ratchetUpdate(options?) |
ratchet_update(folder, &RatchetUpdateOptions) |
ratchetUpdate([RatchetUpdateOptions]) |
No | path, reset, coverageReports / coverage_reports |
baseline update |
baselineUpdate(options?) |
baseline_update(folder, &BaselineUpdateOptions) |
baselineUpdate([BaselineUpdateOptions]) |
No | path, reset, coverageReports / coverage_reports |
state check |
stateCheck(baseRef, options?) |
state_check(folder, base_ref, &StateCheckOptions) |
stateCheck(baseRef, [StateCheckOptions]) |
Yes | path (TypeScript, Dart), headRef / head_ref, renameThreshold / rename_threshold, output (TypeScript, Dart) |
plugin test |
pluginTest(pluginPath, options?) |
plugin_test(path, &PluginTestOptions) |
pluginTest(wasmPath, [PluginTestOptions]) |
Yes | kind (language, metric), sources, pluginMemoryMb / limits.memory_mb, pluginTimeoutMs / limits.timeout_ms |
Subprocess SDKs also accept common execution options:
- TypeScript/JavaScript accepts
cwdandbinaryPathon every options object, plusoutputon report-producing operations (check,diff,trend,impact,trace,schema,report,churn,coupling,stateCheck). - Dart configures
cwd,binaryPath,allowDownload,releaseBaseUrl,cacheDir, andenvironmentonCodeintClient. - When
reportreceives a non-emptyoutputpath in TypeScript/JavaScript or Dart, relative paths resolve againstcwd, the client reads back and returns the written report text instead of empty stdout, and reading failures throwCodeintErrorwith the original cause. - Rust accepts
PluginHostConfigon measurement options (check,diff,trend,impact,trace,init,doctor,churn,coupling,ratchet_update,baseline_update). trendaccepts eithersinceor a positive commit count (--commits <COUNT>on the CLI,trend({ commits: N })in TypeScript,TrendOptions(last: N)in Dart, defaulting to 20; passing a non-positive count or combiningsincewith a commit count fails with exit code 2 orCodeintError).
Typed report models in TypeScript and Dart, and serialized JSON reports rendered by Rust (Report::render, DiffReport::render, TrendReport::render), expose all 13 built-in Metrics:
- Per Source set (
source_sets.<name>):erosion,cognitive_complexity,duplication,verbosity,import_cycles,boundaries,orphan_files,test_gap,file_size, andhazards.file_sizeis present only whenfile_size.max_source_linesis set, and only for the Production Source set. - Top-level Dependency hygiene (
dependencies):unused_dependencies,unlisted_dependencies, anddev_in_production_dependencies.
External WebAssembly Metric plugins appear alongside built-in Metrics in an extensible custom-Metric map:
- TypeScript/JavaScript exposes custom Metric keys through
[customMetric: string]index signatures onSourceSetReport(ExternalMetricSection),SourceSetChanges(ExternalMetricChanges), andTrendRow(number). - Rust emits custom Metric plugin keys in serialized report output from
.render(...)(such asReportFormat::JsonorTrendFormat::Json), matching the exported report JSON Schemas. - Dart exposes
externalMetricsgetters onSourceSetReport,SourceSetChanges, andTrendRow.
codeint exports 17 JSON Schemas for all JSON report payloads from codeint-report (all_report_schemas(), report_schema(), schema_for()):
- schema/codeint-report.schema.json for
codeint check. - 16 command schemas under
schema/reports/: diff.schema.json, trend.schema.json, impact.schema.json, trace.schema.json, guard.schema.json, schema.schema.json, config.schema.json, doctor.schema.json, agent-status.schema.json, agent-install.schema.json, churn.schema.json, coupling.schema.json, ratchet-update.schema.json, baseline-update.schema.json, state-check.schema.json, and plugin-test.schema.json.
Install the codeint npm package, which ships dual ESM and CommonJS modules, TypeScript declarations, and the native platform binary with zero runtime dependencies:
npm install --save-dev codeintThe package exports all 19 operations (check, diff, trend, impact, trace, init, guard, schema, config, report, doctor, agentStatus, agentInstall, churn, coupling, ratchetUpdate, baselineUpdate, stateCheck, and pluginTest), plus CodeintError and resolveBinary.
Pass format ("toon", "text", "json", "sarif", or "markdown") to diff to populate result.rendered alongside the typed result.report, and pass renameThreshold (0 to 100) to diff or stateCheck to control rename detection.
import {
CodeintError,
agentStatus,
baselineUpdate,
check,
churn,
config,
coupling,
diff,
doctor,
guard,
impact,
init,
pluginTest,
ratchetUpdate,
report,
resolveBinary,
schema,
stateCheck,
trace,
trend,
} from "codeint";
try {
const checked = await check({
cwd: process.cwd(),
all: false,
coverageReports: ["coverage/lcov.info"],
});
if (!checked.passed) {
console.error("Budget or Ratchet failures:", checked.failures);
}
console.log("Production erosion:", checked.report.source_sets.production?.erosion.ratio);
const diffed = await diff("origin/main", {
cwd: process.cwd(),
package: "packages/web",
renameThreshold: 50,
format: "markdown",
});
if (!diffed.passed) {
console.error("Regressions:", diffed.failures);
}
if (diffed.rendered) {
console.log(diffed.rendered);
}
const stateChecked = await stateCheck("origin/main", {
cwd: process.cwd(),
renameThreshold: 50,
});
if (!stateChecked.passed) {
console.error("State violations:", stateChecked.report.violations);
}
const diagnosed = await doctor({ cwd: process.cwd() });
if (!diagnosed.passed) {
console.error("Doctor failures:", diagnosed.failures);
}
const tested = await pluginTest("dist/plugin.wasm", {
cwd: process.cwd(),
kind: "language",
sources: ["fixtures/sample.mini"],
});
if (!tested.passed) {
console.error("Plugin failures:", tested.failures);
}
const history = await trend({ cwd: process.cwd(), since: "2026-01-01" });
const blastRadius = await impact({ cwd: process.cwd(), paths: ["src/domain/order.ts"] });
const importPaths = await trace("src/api/index.ts", "src/domain/order.ts", { cwd: process.cwd() });
const boundary = await guard("src/domain/order.ts", { cwd: process.cwd() });
const manifest = await schema({ cwd: process.cwd() });
const resolved = await config({ cwd: process.cwd() });
const markdown = await report("check.json", { cwd: process.cwd(), format: "markdown" });
const agents = await agentStatus({ cwd: process.cwd() });
const hotFiles = await churn({ cwd: process.cwd(), commits: 50 });
const coupled = await coupling({ cwd: process.cwd(), minCoChanges: 3 });
const ratchet = await ratchetUpdate({ cwd: process.cwd() });
const baseline = await baselineUpdate({ cwd: process.cwd() });
const created = await init({ cwd: process.cwd(), format: "jsonc", adopt: false });
console.log({
commits: history.commits,
dependents: blastRadius.summary.total_dependents,
connected: importPaths.connected,
boundaryExists: boundary.exists,
cliVersion: manifest.version,
configFile: resolved.config_file,
markdownLength: markdown.length,
agents: agents.agents.length,
churnCommits: hotFiles.commits_analyzed,
coupledPairs: coupled.pairs.length,
ratchetEntries: ratchet.total_entries,
baselinedFindings: baseline.total_findings,
configPath: created.configPath,
binary: resolveBinary(),
});
} catch (error) {
if (error instanceof CodeintError) {
console.error(`Operational error (exit ${error.exitCode}):`, error.message);
console.error(error.stderr);
}
throw error;
}CommonJS callers can import the same functions with require("codeint").
Pass binaryPath in any options object to override the native executable path.
codeint (crates/cli) is both the codeint CLI binary (cargo install codeint) and the in-process Rust library crate (cargo add codeint).
Import the typed library functions directly:
use std::path::Path;
use codeint::{
BaselineUpdateOptions, CheckOptions, ChurnOptions, ConfigOverrides, CouplingOptions,
DiffOptions, ImpactOptions, InitFormat, InitOptions, PluginHostConfig, PluginKind,
PluginTestOptions, RatchetUpdateOptions, ReportFormat, ReportRenderFormat,
RerenderReportOptions, StateCheckOptions, TraceOptions, TrendOptions, agent_install,
agent_status, baseline_update, check, churn, coupling, diff, doctor, guard, impact, init,
plugin_test, ratchet_update, rerender_report, resolved_config, schema, state_check, trace,
trend,
};
fn run(folder: &Path) -> Result<(), Box<dyn std::error::Error>> {
let checked = check(folder, &CheckOptions::default())?;
if !checked.passed {
for failure in &checked.failures {
eprintln!("{failure}");
}
}
let _json = checked.report.render(ReportFormat::Json)?;
let diffed = diff(
folder,
"origin/main",
&DiffOptions {
format: Some(ReportRenderFormat::Markdown),
rename_threshold: 50,
..DiffOptions::default()
},
)?;
let _diff_markdown = diffed.rendered.as_deref();
let _state = state_check(folder, "origin/main", &StateCheckOptions::default())?;
let _history = trend(folder, &TrendOptions::default())?;
let _blast_radius = impact(
folder,
&ImpactOptions {
paths: vec!["src/domain/order.ts".to_string()],
..ImpactOptions::default()
},
)?;
let _paths = trace(
folder,
"src/api/index.ts",
"src/domain/order.ts",
&TraceOptions::default(),
)?;
let _boundary = guard(folder, Path::new("src/domain/order.ts"))?;
let _manifest = schema();
let _resolved = resolved_config(folder, &ConfigOverrides::default())?;
let _markdown = rerender_report(
folder,
Path::new("check.json"),
&RerenderReportOptions {
format: Some(ReportRenderFormat::Markdown),
all: false,
},
)?;
let _diagnosed = doctor(folder, &PluginHostConfig::default())?;
let _agents = agent_status(folder, None)?;
let _installed = agent_install(folder, None, true)?;
let _hot_files = churn(folder, &ChurnOptions::default())?;
let _coupled = coupling(folder, &CouplingOptions::default())?;
let _ratchet = ratchet_update(folder, &RatchetUpdateOptions::default())?;
let _baseline = baseline_update(folder, &BaselineUpdateOptions::default())?;
let _tested = plugin_test(
Path::new("dist/plugin.wasm"),
&PluginTestOptions::new(PluginKind::Language),
)?;
let _created = init(
folder,
&InitOptions {
format: InitFormat::Jsonc,
adopt: false,
..InitOptions::default()
},
)?;
Ok(())
}Operational errors return Err(CodeintError), which exposes message() and remedy().
Use SavedReport::from_json from codeint to re-render a JSON report in memory without reading from disk.
See crates/cli/HOW-TO.md for internal call contracts.
Install the pure Dart codeint package from pub.dev (sdk: ^3.6.0, zero Flutter dependency):
dart pub add --dev codeintRun the CLI directly through Dart with dart run codeint:
dart run codeint check
dart run codeint diff origin/maindart run codeint resolves the native binary, forwards all arguments and stdio directly to it, and exits with the binary's exact exit code (0, 1, or 2).
CodeintClient exposes all 19 operations with typed option classes and typed report models:
import 'package:codeint/codeint.dart';
Future<void> main() async {
const client = CodeintClient(cwd: '.');
try {
final checked = await client.check(
const CheckOptions(
all: false,
coverageReports: <String>['coverage/lcov.info'],
),
);
if (!checked.passed) {
print('Budget or Ratchet failures: ${checked.failures.join(', ')}');
}
final production = checked.report.sourceSets['production'];
print('Production erosion: ${production?.erosion.ratio}');
print('Custom metrics: ${production?.externalMetrics.keys.join(', ')}');
final diffed = await client.diff(
'origin/main',
const DiffOptions(
format: ReportRenderFormat.markdown,
renameThreshold: 50,
),
);
if (!diffed.passed) {
print('Regressions: ${diffed.failures.join(', ')}');
}
print('Diff markdown length: ${diffed.rendered?.length}');
final stateChecked = await client.stateCheck('origin/main');
if (!stateChecked.passed) {
print('State violations: ${stateChecked.report.violations.length}');
}
final diagnosed = await client.doctor();
if (!diagnosed.passed) {
print('Doctor failures: ${diagnosed.failures.join(', ')}');
}
final tested = await client.pluginTest(
'dist/plugin.wasm',
const PluginTestOptions(
kind: PluginKind.language,
sources: <String>['fixtures/sample.mini'],
),
);
if (!tested.passed) {
print('Plugin failures: ${tested.failures.join(', ')}');
}
final history = await client.trend(const TrendOptions(since: '2026-01-01'));
final blastRadius = await client.impact(
const ImpactOptions(paths: <String>['lib/domain/order.dart']),
);
final importPaths = await client.trace('lib/api/index.dart', 'lib/domain/order.dart');
final boundary = await client.guard('lib/domain/order.dart');
final manifest = await client.schema();
final resolved = await client.config();
final markdown = await client.report(
'check.json',
const ReportOptions(format: ReportRenderFormat.markdown),
);
final agents = await client.agentStatus();
final hotFiles = await client.churn(const ChurnOptions(commits: 50));
final coupled = await client.coupling(const CouplingOptions(minCoChanges: 3));
final ratchet = await client.ratchetUpdate();
final baseline = await client.baselineUpdate();
final created = await client.init(
const InitOptions(format: InitFormat.jsonc, adopt: false),
);
print(
'commits=${history.commits} dependents=${blastRadius.summary.totalDependents} '
'connected=${importPaths.connected} boundaryExists=${boundary.exists} '
'version=${manifest.version} config=${resolved.configFile} '
'markdownLen=${markdown.length} agents=${agents.agents.length} '
'churn=${hotFiles.commitsAnalyzed} pairs=${coupled.pairs.length} '
'ratchet=${ratchet.totalEntries} baseline=${baseline.totalFindings} '
'init=${created.configPath}',
);
} on CodeintError catch (error) {
print('Operational error (exit ${error.exitCode}): ${error.message}');
if (error.stderr.isNotEmpty) {
print(error.stderr);
}
rethrow;
}
}Because pub.dev caps package archives at 100 MB and does not support per-platform optional dependencies, ensureBinary() resolves the native codeint executable in deterministic order:
- Explicit
binaryPath: usesCodeintClient(binaryPath: ...)orBinaryResolverOptions(binaryPath: ...)when set. CODEINT_BINenvironment variable: uses the executable path inCODEINT_BINwhen set.- Verified local cache: reuses the verified native
codeintbinary in the local user cache (cacheDir,CODEINT_CACHE_DIR,%LOCALAPPDATA%\codeint,$XDG_CACHE_HOME/codeint, or~/.cache/codeint) when already populated. - Version-matching
PATH: searchesPATHfor a nativecodeint(orcodeint.exeon Windows) whose boundedcodeint --versionprobe matchescodeintVersion, skipping the Dart launcher itself. - Verified GitHub Release download: downloads the platform archive and
SHA256SUMSfromhttps://github.com/avidianity/codeint/releases/download/v<codeintVersion>(orreleaseBaseUrl/CODEINT_RELEASE_BASE_URL), verifies the SHA-256 digest before extracting, rejects unsafe archive paths and links, and installs atomically into the local user cache.
For offline or air-gapped CI environments:
- Set
allowDownload: falseonCodeintClientorBinaryResolverOptionsso resolution fails fast withCodeintErrorinstead of attempting a network download. - Point
CODEINT_BIN(orbinaryPath) at a pre-installedcodeintbinary, or pre-warm the verified cache during an online image-build step withdart run codeint:installorawait ensureBinary()(await client.ensureBinary()):
dart run codeint:installimport 'package:codeint/codeint.dart';
Future<void> main() async {
// Pre-warm during image build (online):
final cachedPath = await ensureBinary();
print('Cached binary: $cachedPath');
// Run strictly offline in air-gapped CI:
const offlineClient = CodeintClient(
cwd: '.',
allowDownload: false,
);
final checked = await offlineClient.check();
print('Passed: ${checked.passed}');
}