Skip to content

About

Avalanche Assets & Spend by PickBits: asset register, spend ledger, AI-usage import and total cost per service for a small company. Zero dependencies, SQLite, local desk. Apache-2.0.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

How do I track what my small company owns, what it costs each month, and what each service really costs to run, including AI subscriptions and the hardware under my desk? Avalanche Assets & Spend keeps an asset register, a monthly spend ledger and service cost estimates in a local database you own. You and your AI agents use the same functions through a CLI or a local desk.

What it does

Version 0.1.0 is a ServiceNow-shaped asset and cost module for a small company. Node 22.13+ (Node 22 LTS or newer), ESM, node:sqlite, zero runtime dependencies, Apache-2.0.

  • Numbers assets, tracks owners, vendors, renewals, status, purchase costs and amortization periods.
  • Records monthly spend by asset and source, with vendor, class and trailing-year summaries.
  • Allocates recurring costs to technical services using free-text ci_key identifiers and percentages totaling at most 100% per asset.
  • Imports generic AI usage JSON, inventories environment names only, and optionally measures Windows processes, GPU memory and disk use.
  • Estimates service TCO from hardware, modeled electricity and storage, subscription allocations, usage snapshots and manual ledger entries.
  • Attributes every change to an actor in an append-only event journal. The desk and CLI call the same libraries.

What it does not do

No bank feeds, vendor account connections, payments, invoice extraction, tax calculation, currency conversion or accounting reconciliation. No agent credentials are collected. No remote discovery, telemetry, analytics, scheduled jobs, runtime CDNs or external fonts. Estate job/start descriptions are displayed as data and never executed.

Hardware figures are estimates. Two saved passes are required; PID reuse and short observation windows can distort attribution. GPU memory is an activity hint, not a utilization meter. Power assumes 730 hours per month and configured operating points. TCO is USD-only and skips other currencies with warnings. A latest usage window is not normalized to a monthly bill. Subscription commitments and manual ledger entries are additive: enter only incremental charges in the manual ledger if you use that asset's recurring commitment in TCO. This module does not deduplicate an invoice against a commitment.

A five-minute start

npm ci
npm run demo

Open http://127.0.0.1:4181. Juniper Trail Studio is a fictional two-person software and content shop in Flagstaff, Arizona. Founders Priya Natarajan and Owen Castellanos work with agent:scout, agent:builder and agent:scribe across eight services. All demo people, businesses and numbers are synthetic. The DEMO banner remains visible.

The demo seeds two months relative to today into .test-tmp/demo/, with assets, renewals, costs, allocations, usage, environment-name changes and metering fixtures. It never calls external inventory modules or measures your machine. Stop with Ctrl+C. npm run demo -- --reset reseeds; --data-dir PATH chooses another dedicated demo directory. Reset refuses a non-demo database or a running desk. See DEMO.md.

Real configuration and data isolation

node bin/avalanche-assets.mjs --help
node bin/avalanche-assets.mjs init
node bin/avalanche-assets.mjs desk

The package exposes the avalanche-assets bin (also usable through npm exec -- avalanche-assets). Data resolution is --data-dir PATH, then AVALANCHE_ASSETS_DATA_DIR, then the Windows system-drive folder new/avalanche-data/assets-and-spend, or ~/.local/share/avalanche/assets-and-spend elsewhere using the OS home directory. Help and desk startup print the resolved path. The directory is created when opening a writable store, initializing an instance or seeding a demo. Help does not load private config or create directories; dry runs and argument validation errors do not create a store. Repository paths are rejected except dedicated .test-tmp/ subdirectories for tests and demo; symlinks and junctions are resolved before checking.

init copies config.example.mjs to <dataDir>/config.mjs without overwriting a config, and creates <dataDir>/assets.sqlite. Edit that private config before enabling sources. AVALANCHE_ASSETS_CONFIG selects another private config file; all relative source paths resolve from that file's directory. If the config is absent, the CLI prints a one-line notice and uses the example. Invalid config keys report a clear error. JavaScript config and optional inventory modules are trusted executable owner inputs.

Database, WAL files, real config, event exports, reports, logs and caches belong in the private data directory outside this checkout. JSON/text reports go to stdout, so redirect them only to your private directory. Back up the entire data directory with the desk and other writers stopped. No instance data needs to be moved into the public repo to run your own copy. Test and demo directories are ignored; the externally built root index.html is ignored and the desk uses its own page.

Key Meaning
name CLI product name.
actors.default Default actor, or null for the OS username. Precedence: --actor, AVALANCHE_ASSETS_USER, config, human: plus OS username.
assetNumbers.prefix, .width, .startsAt Number prefix, minimum padding (1–12), first positive sequence value. Keep stable after first use.
usageAsset.name, .class, .vendor, .owner Usage ledger asset identity; class must be api_service. The importer matches by name.
hardware.name, .vendor, .owner, .purchaseCost, .amortizationMonths Fictional demo hardware defaults. Production hardware is entered in the asset register; these are not automatic production purchases.
desk.port, .title Allocated port 4181 and UI title. An explicit AVALANCHE_ASSETS_DESK_PORT override takes precedence over the configured port. No scanning or fallback ports. Demo always uses 4181. The host is always 127.0.0.1.
sources.estate.path Optional registry JSON; absent/null disables. A relative registry path is resolved from the private config directory.
sources.estate.root Optional estate root used to resolve engine dir values. Absent/null defaults to the registry file's directory. An explicit relative root is resolved from the private config directory; absolute roots and absolute engine dirs are supported.
sources.usage.path Optional generic AI usage JSON; absent/null disables.
sources.envInventory.module Optional local enView-compatible module; absent/null disables the inventory provider. No installed-package or sibling-checkout search.
envScan.enabled, .root, .maxDepth Explicit opt-in, scan root, and descent depth 0–20. Off by default. Root is required when enabled; depth 0 means root only.
metering.enabled, .skipDirs Explicit opt-in for machine measurements, plus excluded directory names. Off by default.
dataStores[] Optional extra {ci_key, path, note} stores. note is optional. Paths are config-relative; avoid overlap with engine dirs or other stores to avoid double counting.
rates.electricityPerKwh Non-negative modeled USD/kWh.
rates.machineWatts.idle, .cpuLoaded, .gpuLoaded Non-negative increasing whole-machine power estimates.
rates.storagePerGbMonth Non-negative USD per GiB-month (legacy key spelling preserved).
slugMap Each key is a usage project slug and each value a free-text CI key, e.g. engine:trail-notes. Unmapped usage remains shared/unallocated.

The only runtime environment settings are AVALANCHE_ASSETS_DATA_DIR, AVALANCHE_ASSETS_CONFIG, AVALANCHE_ASSETS_USER and AVALANCHE_ASSETS_DESK_PORT. No .env file is automatically loaded. Example paths, owners, fictional vendors, hardware, rates and slug mappings are documented in the example config, not embedded as production business facts in libraries.

Optional source schemas

examples/estate.example.json has eight engines on fictional ports 4301–4308, plus a satellite. Its top-level shape is { "engines": [...], "satellites": [...] }; satellites may be omitted. Each engine requires only nonempty string id, owner, dir, name, and servers: [{port, what, start}] (an empty array is valid). Server port is an integer from 1–65535; what and start are strings. Engine IDs must be unique. Engine note and url are optional strings. Satellites are objects with optional note, url and top-level port; { "url": "http://127.0.0.1:4381" } is valid. A supplied satellite port must be an integer from 1–65535. Missing or null optional metadata is accepted, and other registry fields are preserved.

Engine dir values are relative to sources.estate.root, which defaults to the registry file's directory. For example, a registry at ./registry/engines.json and root ./studio in private config resolve dir: "trail-notes" under ./studio/trail-notes, not under ./registry. An absolute engine dir is used as-is. Optional jobs: [{name, schedule, actor, command}] describe scheduled work only. No registry URL is fetched. The module still runs when the registry is absent, unreadable or malformed, with a source status message. Use avalanche-assets estate [--json] to inspect the registry and resolved engine paths without opening a database or running metering.

examples/usage.example.json documents the generic shape:

{
  "generatedAt": "2026-08-15T12:00:00.000Z",
  "windowDays": 30,
  "entries": [
    { "date": "2026-08-14", "model": "canyon-code-2", "project": "trail-notes", "inputTokens": 1600, "outputTokens": 400, "cost": 10 }
  ]
}

generatedAt is an ISO timestamp with timezone. windowDays is 1–366. entries is nonempty; date is a real UTC calendar date in the inclusive window ending at the snapshot date, model a nonempty string, token counts non-negative integers, and cost non-negative USD. project is optional and defaults to unallocated. Each entry counts as one message in the preserved schema. Tokens/costs aggregate by project into a snapshot; per-entry model/date detail remains in your source file. Keep that file if you need audit detail.

Reimporting the same snapshot is idempotent. Correcting it replaces its project totals and records an event. The usage-import monthly ledger slot is replaced by the totals supplied for that month; imports are complete totals for their covered month portions, not additive daily batches. Import chronologically and avoid overlapping partial feeds. TCO uses only the latest snapshot, while the ledger keeps monthly totals. Missing paths skip cleanly even with --apply; malformed usage fails before writing. No private tool format or integration is required.

The optional environment module exports scanProjects([root], {maxDepth}), synchronously or asynchronously, returning [{name?, path, files: [{keys: ["APP_MODE", "CACHE_DIR"]}]}]. Paths identify projects; only validated variable identifiers are saved. Assignment-shaped strings are reduced to names. Values and file contents never enter inventory snapshots. The module controls discovery and is trusted to honor the root/depth policy. Missing modules, missing roots and failed scans skip with a message. Configure both a module and envScan.enabled: true to use it.

Metering is Windows-only in 0.1. On other platforms it reports not available; assets, spend, imports and TCO still work. PowerShell listener/process collection and nvidia-smi are optional and independently report missing tools. Missing or unreadable directories produce warnings rather than false zero-byte readings. Disk walks skip symlinks and configured directory names. Collection occurs only when you run meter; nothing is scheduled automatically.

CLI workflow

node bin/avalanche-assets.mjs add --name "Shared editor" --class local_tool --owner "Owen Castellanos" --cost 12 --actor human:owen
node bin/avalanche-assets.mjs allocate AST0001 engine:mesa-media 100
node bin/avalanche-assets.mjs list --json
node bin/avalanche-assets.mjs show AST0001
node bin/avalanche-assets.mjs spend AST0001 --month 2026-08 --amount 4 --note "Extra render credits"
node bin/avalanche-assets.mjs report --year 2026
node bin/avalanche-assets.mjs tco
node bin/avalanche-assets.mjs due --days 45
node bin/avalanche-assets.mjs estate
node bin/avalanche-assets.mjs import-usage
node bin/avalanche-assets.mjs scan-env
node bin/avalanche-assets.mjs meter
node bin/avalanche-assets.mjs events --json

Imports, scans and metering are dry-run unless --apply is given. Help includes set, retire, allocation and hardware fields. Read commands open the existing database read-only; run init first. JSON lists/exports use {data, stamp}; reports keep their named fields and add stamp. Text reports and the desk footer carry “Made with Avalanche Assets & Spend by PickBits”.

How it fits the suite

Avalanche Service Desk, Avalanche Roadmap, Avalanche Customer Cases, Avalanche Estate Map, Avalanche Assets & Spend and Avalanche Service Catalog can run independently. Optional estate data and free-text service keys connect cost records without importing sibling code. lib/panel.mjs retains id, title, nav, collect, stat, render and the stable itam panel ID for existing dashboard consumers. collect({settings: {db, now?}}) opens read-only and returns null when the database is missing or unreadable. No cross-module endpoints are required.

Security model

The desk binds 127.0.0.1 only, has no authentication, and must not be exposed to a network or reverse proxy. Everyone able to use the local machine account can read its data. Actor strings are attribution, not verified identities. Only exact 127.0.0.1:<port> and localhost:<port> Hosts are accepted. Every POST needs a per-process token and a same-origin Origin header; an absent or null Origin is rejected. Bodies are capped at 1 MiB. There are no CORS allowances, inline scripts, third-party assets or telemetry. CSP, nosniff, same-origin referrer policy and frame denial apply to all responses.

The desk serves only its allowlisted HTML, script and stylesheet. Config, source inputs and the database are private local files; protect them with filesystem permissions and private backups. A .desk.lock prevents a second desk or demo reset while running. After a crash, verify the recorded PID has exited before removing a stale lock. SQLite uses WAL, a busy timeout and guarded rollback. Events are append-only through database triggers, but a machine administrator can edit or replace the database. See SECURITY.md.

Checks

npm test
npm run leakscan
node test/consumer-install.mjs
npm run preflight

Tests use .test-tmp/, fake HTTP request streams and injected metering adapters. A guard prohibits networking and port binds. Preflight runs tests, leakscan and a consumer copy built from git ls-files --cached --others --exclude-standard. The consumer installs offline using the normal npm cache, exercises the actual bin, initializes config, seeds a demo and runs read commands without serving a port. Leakscan has generic path, credential, email and phone rules; private-name scanning belongs outside this public repo.

Apache-2.0. Copyright 2026 Mark Pickering and PICKBITS LLC. LICENSE, NOTICE.

Questions and bugs: open a GitHub issue.

About

Avalanche Assets & Spend by PickBits: asset register, spend ledger, AI-usage import and total cost per service for a small company. Zero dependencies, SQLite, local desk. Apache-2.0.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages