Skip to content

Contributing and Design Notes

kurokyuu edited this page Nov 19, 2026 · 3 revisions

Contributing and design notes

How the checkout is laid out, how to write a script that lives here, and what does not belong.

Keeping this manual current

The README is the overview and this wiki is the manual, and the two live apart: a wiki is its own repository and takes no pull requests. So a change to what a script does, to a project.toml key, a hook or a skill is not finished until the page that describes it says the same. Change the code and the page in the same sitting, and name the page in the pull request.

The wiki is cloned with git clone git@github.com:Istarlabs/devscripts.wiki.git. Its default branch is master, and a push goes straight to it. The README links the pages and does not repeat them.

Layout

devscripts/
├── install.py  system.py                            typed by hand, so they stay at the top
├── script_args.py                                    imported by scripts outside the checkout (`import script_args`)
├── shared/                                           what a project's shims point at
│   ├── lib/      project.py  gitdiff.py  servicemenu.py  android.py     imported, never run
│   ├── build/    dotnet.py  rust.py  cpp.py  godot.py  php.py  web.py  browser_extension.py  deploy.py  rpm.py
│   ├── repo/     repo.py  find.py  spdx.py  graph.py  logs.py
│   ├── data/     db.py  gen_db_init_delta.py  verify_db_init.py
│   └── l10n/     i18n.py  gen_resx.py  translations.py
├── ops/          server.py                           a server over ssh, not a project
└── hooks/  skills/  claude/  templates/  Scripts/

A shim finds its script by name in the folders of shared/ and puts all of them (and the checkout itself) on sys.path, which is why the scripts import each other flat (from project import project). A new shared script goes into the folder of its concern and into SHAREABLE in install.py; a *.test.py lives next to the script it checks.

Writing a script that lives here

A second language script shares what is not about the language. gitdiff.py holds "which lines did this branch change, and which of these warnings sit on them" — rust.py and cpp.py both report warnings that way, and two copies of it would have drifted exactly the way this checkout exists to stop.

Two scripts for localization, on purpose. translations.py generates .resx out of JSON; i18n.py drives xgettext/msgmerge over .po files. They share the word and nothing else — in a Qt/KDE program the English text is the i18n() argument, so there is no source file to generate and no base language directory. Folding both behind [localization] would be one script doing two unrelated things, which is the logs.py mistake below. Hence the separate [i18n] block, which is also how install.py knows not to put a .po shim in a .NET project.

What i18n.py is actually worth is its xgettext call: KDE's i18n() family is twenty-odd functions, and a string is extracted only if the function it sits in is named with a -k flag. Miss one and those strings never reach a translator, silently.

flavour = "rust" swaps that call for xgettext --language=Rust over .rs files — gettext 0.26 parses Rust itself and its default keywords already name gettext-rs' functions, so there is no list to keep there. The other half a Rust project misses is ki18n_install(po): cargo installs a binary and nothing else, so rust.py install compiles each .po into <install_root>/share/locale/<lang>/LC_MESSAGES/<domain>.mo.

cpp.py verify builds clean by default. A compiler replays nothing: an incremental build that recompiles nothing prints no warnings, and "0 warnings" out of a build that did no work is the kind of green that hides a red. --incremental opts out where the honest answer costs too much.

cpp.py tidy is not part of verify. clang-tidy takes a few seconds per file and a project that was never run through it starts with dozens of findings, so it is asked for, not imposed. It builds first (clang-tidy needs the compile database and the generated moc/kcfg headers), checks only the project's own translation units, counts a header's finding once rather than once per includer, and says how many NOLINT it honoured — a wrong file pattern and a clean tree both print nothing from run-clang-tidy itself, and only the counts tell them apart.

Never sys.path.insert(0, SCRIPTS) to reach a sibling script. In a project that uses this checkout Scripts/ holds shims, so that import runs one as __main__ against the current command's argv — rust.py verify died on spdx.py: invalid choice: 'verify' exactly that way. The shim has already put this directory on the path, so a plain import spdx finds the real one.

What does not belong here

A script about one project's domain. unused.py, gen_project_map.py, the importers and the fetch_*.py stay in the repository they serve. The test: could a second project use it without knowing what the first one is for?

Two that failed it and stayed behind, for the record:

  • An audit subcommand in db.py that queried one application's own tables. It is a .sql file in that repository now, run by the generic db.py query --file.
  • A second logs.py in a desktop tool. Same command-line surface as the shared one, on purpose, and a different implementation underneath: one file under $XDG_STATE_HOME against a directory per day discovered through NLog's configuration, and a different line format. What differs is the strategy, not a value, and folding both behind configuration would produce one script doing two unrelated things. If a third project wants the same, share the entry-filtering half and leave "where is the log" to each of them.

Clone this wiki locally