Skip to content

Build Tocharian AI from source

For developers. This page gets you a plugin zip for one Kibana version from this repository, and lists what to change for a new plugin version.

A Kibana plugin only loads into the exact Kibana version it was built for, and it is built inside a Kibana source checkout of that version. One code base serves every supported version from 8.17.0 to 9.5.7; the differences are in Kibana versions.

WhatDetail
Operating systemLinux or macOS, as a non-root user: newer Kibana tools refuse to run as root
Node.jsThe version in the Kibana checkout’s .nvmrc
Package managerpnpm from 8.19.22, 9.4.8 and 9.5.5 on, yarn before. Kibana’s package.json names it in packageManager (8.19.22: in engines).
Python3, for tools/apply_line.py
Disk and memoryA bootstrapped Kibana source tree takes several GB; the type check of recent versions needs about 6 GB of memory

The example builds for Kibana 9.5.7. Replace the version in every command.

  1. Check out Kibana at the version’s tag and bootstrap it:

    Terminal window
    git clone --depth 1 --branch v9.5.7 https://github.com/elastic/kibana.git
    cd kibana
    node scripts/kbn bootstrap
  2. Put the plugin into plugins/tocharian_ai:

    Terminal window
    git clone https://github.com/TocharianOU/tocharian-ai-kibana.git plugins/tocharian_ai
    cd plugins/tocharian_ai
  3. Apply the files for this Kibana version:

    Terminal window
    tools/apply_line.py 9.5.7
  4. Build:

    Terminal window
    NODE_OPTIONS="--require $PWD/tools/tests/quiet_build.cjs" \
    node ../../scripts/plugin_helpers build --kibana-version 9.5.7

    The zip is build/tocharianAi-9.5.7.zip.

  5. Check the result. The build log must not contain ERROR, and the zip must hold the browser code:

    Terminal window
    unzip -l build/tocharianAi-9.5.7.zip | grep target/public/tocharianAi.plugin.js

    A problem in the browser bundle stops Kibana’s bundler, and the build still reports success with a zip that has no UI. quiet_build.cjs drops one harmless warning line of baseline-browser-mapping that would otherwise stop the bundler on some versions.

tools/tests/matrix.sh <version> --stage build runs steps 3 to 5 with the type check and the unit tests, and checks the result the same way. See Testing.

From the root of the Kibana checkout:

Terminal window
node_modules/.bin/tsc -p plugins/tocharian_ai/tsconfig.json --noEmit --skipLibCheck
node scripts/jest --config plugins/tocharian_ai/jest.config.js

Errors in Kibana’s own files can be ignored; errors in plugin files cannot. The unit tests need no cluster and no model.

Code for newer Kibana versions: apply_line.py

Section titled “Code for newer Kibana versions: apply_line.py”

Some code needs a Kibana package that older versions do not have, so it cannot even be compiled there. Today that is the Elastic Workflows step, from Kibana 9.5 on.

ItemDetail
lines/<minor>/Files for that minor and later, in the same layout as the plugin (common/, public/, server/)
lines/<minor>/line.jsonfrom: the first Kibana minor, such as "9.5". optionalPlugins: plugins to add to kibana.json, such as ["workflowsExtensions"].
tools/apply_line.py <kibana version> [plugin dir]Copies every line whose from is at or below the version over the plugin, in order of from; files with the same name are replaced. Adds the line’s optional plugins to kibana.json. Prints the files it wrote. Running it again changes nothing.

apply_line.py changes files in place. Run it on a fresh clone or a CI checkout, not on a working tree with changes you want to keep. For versions below every line, it writes nothing.

To put version-specific code in the browser without a line, use public/compat.ts, and prefer detecting what Kibana offers over checking the version number.

Every release needs a new plugin version. The browser bundle URL contains it; without a bump, browsers keep the old UI from their cache.

Change the version in three places, to the same value:

FileField
kibana.jsonversion
package.jsonversion
common/index.tsPLUGIN_VERSION

python3 tools/ci/static_checks.py fails when they differ, and the release tag must be v followed by this version. Add the release to CHANGELOG.md.

Settings that belong to your machine, such as where to run the release check over ssh, go into tools/tests/local.env. Copy tools/tests/local.env.example and fill it in. The file is ignored by git and never copied to another machine. Never commit host names, addresses or credentials.