opioidpolicy
v1.0.5
Published
A real terminal companion to the OPI browser CLI — opioid settlement spending rules, the F.I.T. test, decision matrices, transparency standards, projects, and whitepapers, from your shell.
Downloads
937
Maintainers
Readme
opioidpolicy — Opioid Policy Institute CLI
A real terminal companion to the browser terminal. Run opi in your shell to query OPI's accountability data: the WFAM database (waste / fraud / abuse / mismanagement), AG accountability by state, settlement-spending rules, the F.I.T. test, decision matrices, transparency standards, projects, and whitepapers — the same content the website serves.
Zero dependencies. Node 18+ (built-in fetch). Static content ships inside the package (instant + offline); live data is fetched from data.opioidpolicy.org.
Install / run
# run without installing
npx opioidpolicy help
# or install once, then use `opi`
npm i -g opioidpolicy
opiRunning opi with no command opens an interactive terminal (boot banner + prompt, ↑/↓ history, clear to reset, exit / Ctrl+C to leave).
Updating
npm i -g opioidpolicy # update a global install to the newest version
npx opioidpolicy@latest # or skip installs entirely — npx always runs the newestopi version checks npm and tells you if a newer version is out. The CLI does not auto-install updates (that would be slow and surprising); it just lets you know.
Cheat sheet
Help & meta
| Command | What it does |
|---|---|
| opi help | list every command |
| opi help <command> | a command's options + examples |
| opi <command> --help | same as opi help <command> |
| opi examples | copy-paste example commands |
| opi version | print the version |
Opioid settlement guidance — opi opioid-settlement (bundled, offline)
| Command | What it does |
|---|---|
| opi opioid-settlement --quick-rules | OPI's 8 rules for spending settlement funds well |
| opi opioid-settlement --fit-test | the F.I.T. test — summary of all three letters |
| opi opioid-settlement --fit-test --functional | just Functional (also --impactful, --trackable) |
| opi opioid-settlement --fit-test --all | all three letters in full |
| opi opioid-settlement --decision-matrix | cost×impact & urgency×importance grids |
| opi opioid-settlement --transparency-best-practices | the 8 transparency standards |
| opi opioid-settlement --policy-briefs | where to read OPI policy briefs |
Projects & research (bundled, offline)
| Command | What it does |
|---|---|
| opi projects | list every OPI project |
| opi whitepapers | OPI research papers (PDFs) |
WFAM database — opi wfam (live · waste / fraud / abuse / mismanagement)
| Command | What it does |
|---|---|
| opi wfam MI | records for one state (2-letter code) |
| opi wfam all | every record (700+) |
| opi wfam stats | totals — dollars documented + record count |
| opi wfam --state "New York" | full state name (flag form for multi-word names) |
| opi wfam --year 2024 | filter by spend year |
| opi wfam --domain "Law Enforcement" | filter by spending domain |
| opi wfam --search "drone" | free-text search across records |
| opi wfam --per-page 50 | rows to display (default 20) |
| opi wfam MI --year 2024 --total | filters combine |
Unallowable / restricted spending — opi unallowable-spending (live, WFAM-backed)
| Command | What it does |
|---|---|
| opi unallowable-spending MI | flagged spending in one state |
| opi unallowable-spending MI law-enforcement | law-enforcement only |
| opi unallowable-spending non-law-enforcement | everything except law enforcement |
| opi unallowable-spending all | every flagged record |
Flag forms also work: --state MI · --law-enforcement · --non-law-enforcement · --all.
AG accountability — opi accountability (live)
| Command | What it does |
|---|---|
| opi accountability MI | a state's AG opioid-settlement reporting path (2-letter code) |
| opi accountability --state "New York" | full state name |
Interactive terminal (run opi with no command)
| Key / word | Action |
|---|---|
| ↑ / ↓ | command history |
| clear | reset the screen |
| exit / quit / Ctrl+C | leave |
Global options
| Option | Effect |
|---|---|
| --base <url> / OPI_API_BASE | fetch the static content from another host (e.g. local dev) |
| NO_COLOR=1 | disable ANSI colour (auto-off when output is piped) |
How the data works
- Static content (rules, F.I.T. test, transparency, projects, whitepapers) ships inside the package → instant and offline. It's generated from the website's single sources (
projects-data.js,whitepapers-data.js, and the authored JSON) via_dev/sync/gen-cli-data.mjs; re-run that and republish to update. - Live data (
wfam,unallowable-spending,accountability) is fetched fromhttps://data.opioidpolicy.org/cli/and filtered locally — no server query API, no PHP. - State filters accept a 2-letter code (
MI, which maps to the exact state — so it never matches Missouri/Mississippi) or a full name via--state(--state "New York").
Publishing
Lives in the website repo under _dev/cli-tool/ (excluded from the web upload) and is mirrored to its own repo at https://codeberg.org/opioidpolicy/opi-cli. To ship a new version: bump version in package.json, then npm publish from this folder.
License
MIT © Opioid Policy Institute. See LICENSE.
