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.
Requirements
Section titled “Requirements”| What | Detail |
|---|---|
| Operating system | Linux or macOS, as a non-root user: newer Kibana tools refuse to run as root |
| Node.js | The version in the Kibana checkout’s .nvmrc |
| Package manager | pnpm 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). |
| Python | 3, for tools/apply_line.py |
| Disk and memory | A bootstrapped Kibana source tree takes several GB; the type check of recent versions needs about 6 GB of memory |
Build a zip
Section titled “Build a zip”The example builds for Kibana 9.5.7. Replace the version in every command.
-
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.gitcd kibananode scripts/kbn bootstrap -
Put the plugin into
plugins/tocharian_ai:Terminal window git clone https://github.com/TocharianOU/tocharian-ai-kibana.git plugins/tocharian_aicd plugins/tocharian_ai -
Apply the files for this Kibana version:
Terminal window tools/apply_line.py 9.5.7 -
Build:
Terminal window NODE_OPTIONS="--require $PWD/tools/tests/quiet_build.cjs" \node ../../scripts/plugin_helpers build --kibana-version 9.5.7The zip is
build/tocharianAi-9.5.7.zip. -
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.jsA problem in the browser bundle stops Kibana’s bundler, and the build still reports success with a zip that has no UI.
quiet_build.cjsdrops one harmless warning line ofbaseline-browser-mappingthat 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.
Type check and unit tests
Section titled “Type check and unit tests”From the root of the Kibana checkout:
node_modules/.bin/tsc -p plugins/tocharian_ai/tsconfig.json --noEmit --skipLibChecknode scripts/jest --config plugins/tocharian_ai/jest.config.jsErrors 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.
| Item | Detail |
|---|---|
lines/<minor>/ | Files for that minor and later, in the same layout as the plugin (common/, public/, server/) |
lines/<minor>/line.json | from: 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.
Bump the version
Section titled “Bump the version”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:
| File | Field |
|---|---|
kibana.json | version |
package.json | version |
common/index.ts | PLUGIN_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.
Machine settings
Section titled “Machine settings”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.