@x-tech-laboratories/x-app 0.117.0 → 0.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -8
- package/dist/agent/claude_stream.d.ts +22 -0
- package/dist/agent/claude_stream.js +85 -0
- package/dist/agent/git.d.ts +37 -0
- package/dist/agent/git.js +121 -0
- package/dist/agent/github.d.ts +81 -0
- package/dist/agent/github.js +185 -0
- package/dist/agent/programs.d.ts +17 -0
- package/dist/agent/programs.js +62 -0
- package/dist/agent/worktree_files.d.ts +20 -0
- package/dist/agent/worktree_files.js +69 -0
- package/dist/agent_transcript.d.ts +83 -0
- package/dist/agent_transcript.js +267 -0
- package/dist/app/daemon.js +2 -2
- package/dist/app/define.d.ts +7 -2
- package/dist/app/define.js +13 -0
- package/dist/app/desktop.js +2 -2
- package/dist/app/protocol.d.ts +3 -1
- package/dist/app/protocol.js +1 -0
- package/dist/app/server.d.ts +1 -0
- package/dist/app/server.js +13 -2
- package/dist/app/web/android.js +8 -1
- package/dist/app/web/hosts.d.ts +1 -1
- package/dist/app/web/hosts.js +5 -4
- package/dist/connection_protocol.d.ts +1 -0
- package/dist/connection_protocol.js +11 -0
- package/dist/daemon_router.d.ts +2 -2
- package/dist/daemon_router.js +3 -2
- package/dist/diff_rows.d.ts +78 -0
- package/dist/diff_rows.js +158 -0
- package/dist/frontmatter.d.ts +10 -0
- package/dist/frontmatter.js +57 -0
- package/dist/frontmatter_folder.d.ts +24 -0
- package/dist/frontmatter_folder.js +54 -0
- package/dist/history.js +14 -1
- package/dist/server/config.d.ts +2 -0
- package/dist/server/config.js +15 -1
- package/dist/server/events.d.ts +2 -0
- package/dist/server/events.js +3 -1
- package/dist/server/github_webhook.d.ts +30 -0
- package/dist/server/github_webhook.js +146 -0
- package/dist/sync_engine.d.ts +5 -0
- package/dist/sync_engine.js +63 -9
- package/dist/sync_protocol.d.ts +4 -0
- package/dist/sync_protocol.js +11 -0
- package/dist/test_helpers.d.ts +7 -0
- package/dist/test_helpers.js +44 -0
- package/dist/web/react/accounts.js +2 -1
- package/dist/web/react/controls.d.ts +3 -2
- package/dist/web/react/controls.js +6 -4
- package/dist/web/react/copy_button.d.ts +11 -0
- package/dist/web/react/copy_button.js +44 -0
- package/dist/web/react/dialog.js +2 -2
- package/dist/web/react/diff.d.ts +26 -0
- package/dist/web/react/diff.js +79 -0
- package/dist/web/react/file_tree.d.ts +26 -0
- package/dist/web/react/file_tree.js +46 -0
- package/dist/web/react/local_mcp_settings.js +2 -1
- package/dist/web/react/transcript.d.ts +24 -0
- package/dist/web/react/transcript.js +100 -0
- package/dist/web/tree.d.ts +3 -1
- package/dist/web/tree.js +38 -10
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
9
9
|
|
|
10
10
|
| Import | What it holds |
|
|
11
11
|
| ---------------------------------------- | ----------------------------------------------------------------------------- |
|
|
12
|
-
| `app/define` | The base app: `define_app` puts an X-app's name, ports, files, its own settings and its `define_feature` features (tables, migrations, calls, `api_spec`, settings, histories) together into one store every device keeps (`open_store` calling each feature's `on_open`, `needs_upgrade`, `bind_methods(database, on_change, caller)` running each call as its `caller`, calling each feature's `after_write`, recording versions and announcing writes, `is_read_only`), `page_only` (the specs' `page_only` calls and the writes of `user_only` settings, refused with `page_only_refusal`), its sync engine, its backups' names and schedule, and its bridges named after the app; `AppMethodsOf<typeof app>` types the app's calls. `history_days` sets how far an app's history reaches back until the user chooses (365 unless set); what opening changed is recorded as this device's version, and old versions are pruned on opening and after a write once a day. `settings_knows(key)` lets an import take keys without a spec of their own, such as `diet.target_protein`; `upgrade_layout: { needed, run }` brings a database an older version laid out its own way, such as a versions table keyed another way, in line before any migration, backed up first; `adopt_backup_schedule(database, saved)` moves a schedule an older version kept elsewhere into the setting once. `tools`, a feature of the app's own, is what MCP offers in place of the page's calls, such as tools that take names rather than ids, each run as the `program` caller (`app.mcp`). Sync's and history's triggers come off while migrations run, so a step may drop a column they name. `synced_theme` keeps the light, dark or system theme as a synced setting, `theme`, so every device shows the one picked last. |
|
|
12
|
+
| `app/define` | The base app: `define_app` puts an X-app's name, ports, files, its own settings and its `define_feature` features (tables, migrations, calls, `api_spec`, settings, histories) together into one store every device keeps (`open_store` calling each feature's `on_open`, `needs_upgrade`, `bind_methods(database, on_change, caller)` running each call as its `caller`, calling each feature's `after_write`, recording versions and announcing writes, `is_read_only`), `page_only` (the specs' `page_only` calls and the writes of `user_only` settings, refused with `page_only_refusal`), its sync engine, its backups' names and schedule, and its bridges named after the app; `AppMethodsOf<typeof app>` types the app's calls. `history_days` sets how far an app's history reaches back until the user chooses (365 unless set); what opening changed is recorded as this device's version, and old versions are pruned on opening and after a write once a day. `settings_knows(key)` lets an import take keys without a spec of their own, such as `diet.target_protein`; `upgrade_layout: { needed, run }` brings a database an older version laid out its own way, such as a versions table keyed another way, in line before any migration, backed up first; `adopt_backup_schedule(database, saved)` moves a schedule an older version kept elsewhere into the setting once. `tools`, a feature of the app's own, is what MCP offers in place of the page's calls, such as tools that take names rather than ids, each run as the `program` caller (`app.mcp`). Sync's and history's triggers come off while migrations run, so a step may drop a column they name. `take_data_change(database)` names the synced tables written since the last call for that connection (null on its first call and after a restore); the server and daemon send it with each change, so a page's `on_change(listener)` hears `{ tables }` and fetches only what it shows from them, or everything on null. `synced_theme` keeps the light, dark or system theme as a synced setting, `theme`, so every device shows the one picked last. |
|
|
13
13
|
| `app/server`, `app/daemon` | `run_server(app, { web_folder })`: the web server from `<PREFIX>_CONFIG` with accounts in `accounts.db` (moved there once from the data's own file, tokens starting with the app's `token_prefix`), the calls, OpenAPI, MCP, the server's backups and its sync peer, a token or MCP client refused the app's `page_only` calls and the `user_only_backup_calls` (restore, remove, schedule) and its calls run as the `program` caller; `run_daemon(app)`: the desktop daemon from `<PREFIX>_DB` with sync, letting devices connect, backups, certificates and the desktop settings; Both take the app's `services` (see `app/services`), `run_daemon(app, env, { services })`. A `backup-schedule.json` an older version kept beside the database moves into this device's setting on opening. Both tell every page when another program, such as an older build, writes the database file (`watch_outside_changes`, on SQLite's `data_version`). `build_server`, `start_daemon`, `open_app_database` (with `on_restore` hooks) and `register_app_calls` for tests and apps that add their own. |
|
|
14
14
|
| `app/services` | An app's own work beside its calls, run by both hosts: `StartServices` gets a `HostContext` (`kind`, `database()`, `profile`, `device_name`, the server's raw `config`, `plugins_folder`, `declared_file` from `<PREFIX>_DECLARED_FILE` or `/etc/<id>/declared.json`, `announce`, `emit(event, data)` for the page's `on_event`, `side_database(name)` for a never-backed-up file such as `<base>-index.db`, `back_up`) and returns `HostServices` (`before_restore`, `after_restore`, `stop`), stopped before sync and the database. |
|
|
15
15
|
| `app/links` | `app_link(scheme, route)` and `route_of_link(scheme, link)`: an app's links such as `x-notes://note/<id>` and the page route they open. |
|
|
@@ -26,6 +26,9 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
26
26
|
| `recurrence` | iCalendar recurrence (RFC 5545) on rrule.js, ported from recurrence-input: `parse_rule` and `format_rule` for a rule without its `RRULE:` prefix, every `BY` part a list, unknown parts such as `X-` kept and an `RSCALE` calendar (RFC 7529) kept first; `parse_recurrence` and `format_recurrence` for `RRULE`, `EXDATE` and `RDATE` lines, folded lines read and `TZID` lines kept as written; `UNTIL` and dates written as plain dates, floating or UTC to match the event's start; `describe_rule` in plain English with times and `BYSETPOS`; `next_occurrence` with `COUNT` lowered in the value to keep; `next_from_now`; `parse_rule_part` naming the values a `BY` part allows. |
|
|
27
27
|
| `python_text` | Text as Python writes and reads it, for apps ported from Python: `python_repr`, `python_str`, `python_dumps` (json.dumps with its separators and escapes, keys sorted when asked), `python_format` with `apply_format_spec`, `format_fixed` and `format_grouped` ("{:.1f}" rounding an exact tie to even, "{:,.1f}"), `round_half_even`, `python_float_repr`, `split_lines`, `split_words`, `partition`, `parse_int`, `parse_float` and their `_or_null` forms, `fnmatch` and `python_regex` for `(?P<name>...)`. |
|
|
28
28
|
| `csv` | CSV as RFC 4180 writes it: `parse_csv` into rows, a byte-order mark and blank rows dropped, `csv_records` by the header's names, `tsv_records` for unquoted tab-separated text such as LibraryThing's export, and `csv_field`, `write_csv` and `write_csv_records`, which quote only the cells that need it. Written in-house, as it is a page of code and the libraries add streaming and type guessing no app uses. |
|
|
29
|
+
| `diff_rows` | A change to text files laid out for reading, the same in a page, a phone and Node: `parse_unified_diff` reads git's unified diff into files (added, removed, renamed or changed, with the old path) and hunks of lines numbered on both sides, through parse-diff (MIT); `split_rows` lays a file out old beside new and `unified_rows` in one column, each removed line paired with the added line at its place so `word_parts` marks the words that changed, through jsdiff (BSD-3-Clause), a line changed through left whole; `fold_rows` cuts each long unchanged stretch to `context_lines` beside its changes unless opened; `edit_lines` diffs a before and after text, such as one edit; `diff_totals` and `diff_within_limit`, which cuts a long diff at its last whole file. Both libraries were chosen because they read git's format and mark words exactly as the hand-written readers they replace did. |
|
|
30
|
+
| `frontmatter`, `frontmatter_folder` | Markdown files that start with YAML frontmatter, such as agent definitions: `parse_frontmatter` reads the frontmatter as a YAML document and the body, refusing in plain words a file without one, broken YAML or frontmatter that is not a set of keys; `frontmatter_values`, `frontmatter_text` and `frontmatter_list` (a YAML list or a comma-separated line); `write_frontmatter` sets the app's keys, drops the empty ones and keeps every other key and comment as written. `create_frontmatter_folder`: a folder of such files named by id, read with a problem per file that does not parse, each written beside itself and moved over, removed, and followed for changes made by other programs. On `yaml`, an optional peer the app installs. |
|
|
31
|
+
| `test_helpers` | For an app's tests that reach servers and repositories on this machine: `free_port` on the loopback address, `temp_folder`, `make_checkout`, a git checkout with one commit, and `self_signed_certificate` for localhost and 127.0.0.1, made by openssl. |
|
|
29
32
|
| `zip` | Several text files as one zip, such as an export of a few CSV tables: `zip_text_files`, `unzip_text_files` (folders left out, a file that is no zip refused in plain words) and `is_zip`, on fflate, chosen over JSZip because it works synchronously in a browser, on Node and in a phone's page with no dependencies, at a tenth the size. |
|
|
30
33
|
| `text_index` | A local search index's text helpers, for SQLite FTS5 beside stored vectors: `text_hash` (cyrb53, to tell changed text, not for security), `chunk_text(text, size, overlap)` cut at a space near the end so a sentence across a cut is in both pieces, `unit`, `dot`, `to_blob` and `from_blob` for vectors kept as blobs, `fts_query(text, "AND" | "OR")` quoting each word as a prefix so none is read as an operator, and `fuse_ranks`, reciprocal rank fusion of several rankings. |
|
|
31
34
|
| `html_text` | `html_to_text(html, base)`: a web page's title and readable text, a block to a line, scripts, styles and drawings left out, each link kept as plain text with its address made whole after it, or with `{ blank_lines: true }` a blank line between blocks, as for a note's paragraphs; `unescape_html` for character references. Runs anywhere, with no DOM. |
|
|
@@ -52,7 +55,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
52
55
|
| `email_links` | `bare_message_id` and `email_uri`: an email linked by its Message-ID as an RFC 2392 `mid:` link, which mail programs such as Thunderbird open wherever the message was filed. |
|
|
53
56
|
| `snippets` | `shorten(text, length = 200)`: text put on one line and cut with an ellipsis, for an excerpt under a title. |
|
|
54
57
|
| `drizzle`, `drizzle_migrations` | Typed SQLite on Drizzle ORM 1.0.0-rc.5, chosen over Kysely and hand-written SQL because it types rows from one schema in TypeScript, writes the migration SQL from it with drizzle-kit and runs synchronously: `open_drizzle` over any `SqlDatabase`, and `drizzle_of`, which the stores call, making it once per connection, so the same queries run on node:sqlite and in a phone's page, `synced_tables` reading the sync list from the schema's primary keys, `migrate_drizzle` per owner, the schema builders and query operators so an app never imports Drizzle, with `AnySQLiteColumn` for a table whose rows point at its own, and `x-app-bundle-migrations <folder>`, which turns drizzle-kit's migration folders into an `index.ts` a server running .ts files can import. |
|
|
55
|
-
| `sync_engine`, `sync_peer`, `sync_protocol`, `sync_seal`, `server/sync_peer_routes`, `sync_peer_discovery`, `sync_peer_listening` | SQLite kept alike on every device with no server: `create_sync_engine` stamps each value of the tables it is given through triggers, so the app's own writes need no change, and the newest write of each value wins, each key of a table's `map_columns` (JSON objects such as ids from many sources) counting as a value of its own so two devices adding different keys keep both. Every copy is a peer: `create_sync_peer` pairs with another device through a one-time code (`create_pairing_code`, `pair_device`), the two copies merging with nothing asked, then sends each paired device its changes within seconds, takes theirs in the same round trip, holds a waiting call open to hear of theirs at once, and passes on what it took from the others, so devices that never reach each other still end up alike; the group's list of devices travels too, so a new device is introduced to the rest and a removed one (`remove_device`) is refused by all. Each call is sealed with both devices' keys on tweetnacl's box (`sync_seal`), chosen over TLS with pinned certificates because it runs alike on Node and in a phone's page; calls still travel over https only. After a restore (`forget_history`) each peer is made to match the restored copy once, keeping a copy of its own first. `register_sync_peer_routes` answers other devices at `sync/peer` under a daemon's prefix, `listen_for_peers` opens a desktop daemon's own port for them, `discover_peers` finds paired devices on the local network by mDNS, on bonjour-service, and `keep_listening_for_peers` (`sync_peer_listening`) is a desktop daemon's "Let other devices connect" setting, kept in a file beside the database, which answers over https with a self-signed certificate made once (`peer_certificate`, on selfsigned, chosen because it makes one with Node's own crypto) and whose `PeerListeningMethods`, its fingerprint included, the page shows with `PeerListeningSettings`; `SyncSettings` given `certificates` asks to review and trust that certificate when pairing fails over it, and pairs again. |
|
|
58
|
+
| `sync_engine`, `sync_peer`, `sync_protocol`, `sync_seal`, `server/sync_peer_routes`, `sync_peer_discovery`, `sync_peer_listening` | SQLite kept alike on every device with no server: `create_sync_engine` stamps each value of the tables it is given through triggers, so the app's own writes need no change, and the newest write of each value wins, each key of a table's `map_columns` (JSON objects such as ids from many sources) counting as a value of its own so two devices adding different keys keep both; a table marked `rows_never_change`, such as saved versions, keeps one version per row instead of one per column, its older per-column versions folded into it on opening. `changed_tables_since(database, cursor)` names the synced tables written after a point. Every copy is a peer: `create_sync_peer` pairs with another device through a one-time code (`create_pairing_code`, `pair_device`), the two copies merging with nothing asked, then sends each paired device its changes within seconds, takes theirs in the same round trip, holds a waiting call open to hear of theirs at once, and passes on what it took from the others, so devices that never reach each other still end up alike; the group's list of devices travels too, so a new device is introduced to the rest and a removed one (`remove_device`) is refused by all. Each call is sealed with both devices' keys on tweetnacl's box (`sync_seal`), chosen over TLS with pinned certificates because it runs alike on Node and in a phone's page; calls still travel over https only. After a restore (`forget_history`) each peer is made to match the restored copy once, keeping a copy of its own first. `register_sync_peer_routes` answers other devices at `sync/peer` under a daemon's prefix, `listen_for_peers` opens a desktop daemon's own port for them, `discover_peers` finds paired devices on the local network by mDNS, on bonjour-service, and `keep_listening_for_peers` (`sync_peer_listening`) is a desktop daemon's "Let other devices connect" setting, kept in a file beside the database, which answers over https with a self-signed certificate made once (`peer_certificate`, on selfsigned, chosen because it makes one with Node's own crypto) and whose `PeerListeningMethods`, its fingerprint included, the page shows with `PeerListeningSettings`; `SyncSettings` given `certificates` asks to review and trust that certificate when pairing fails over it, and pairs again. |
|
|
56
59
|
| `sync_files`, `node_file_store`, `electron/file_protocol` | Files that sync beside the rows that name them, such as covers or photos, so a large picture never travels with every change: each is named by the sha256 of its bytes (`hash_bytes`, `put_file`, `is_file_name`) and kept in a `SyncFileStore`, a folder on Node (`folder_file_store`, written through a rename) or IndexedDB on a phone (`indexed_db_files`); given `files: { store, referenced }`, the sync peer sends each paired device the named files it lacks and fetches those this device lacks after each exchange, a few at a time, trying a file neither has yet again next round, and keeps the ones it is sent, refusing bytes that do not match their name; `register_file_scheme` and `serve_files` show them in a desktop page as `<scheme>://<name>`. |
|
|
57
60
|
| `app_android` | `x-app-android [app folder]`: the app's Capacitor project in `android/`, made from Capacitor's template when it is missing, given X-App's `config/android/release.gradle` and, where it has none of its own, a network rule allowing plain http only to the phone itself (`network_security_config`), for `adb reverse` while testing, (the version CI hands each build, and signing when the release key is in the environment), its launcher icons from `x-app-icons`, then `cap sync android`. Run after the Android page is built; the app keeps `android/` out of git. |
|
|
58
61
|
| `app_android_key` | `x-app-android-key [app folder] [key folder]` or `x-app-android-key --org <org> [key folder]`: an Android release key, made once with keytool in `~/.local/share/<name>/signing` (or the given folder) and never replaced, and stored with gh as the `ANDROID_KEYSTORE_BASE64`, `ANDROID_KEYSTORE_PASSWORD` and `ANDROID_KEY_ALIAS` secrets `app-android` signs with, handed over on stdin so nothing prints it. `--org` makes one key for every app, kept as organization secrets every repository reads; a repository's own secrets of those names win. Run it in the app's Android shell. |
|
|
@@ -69,7 +72,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
69
72
|
| `phone_sockets` | `phone_sockets()`: UDP and TCP sockets for a `phone_service` worker, answered by X-App's Android side: `udp_open` (with `broadcast`, holding Android's multicast lock), `tcp_listen`, `tcp_connect` and `list_interfaces`; a TCP socket reads nothing until `read_line` takes one line or `start_reading` everything after, so `start_tls` can follow plain text in either TLS role, as KDE Connect's identity line does, with the app's PEM certificate and key, letting any peer through and handing back its certificate for the worker to pin; `pause` and `resume` for a slow reader, and `write` settling once sent. Events that arrive before a listener are kept for it. Needs `CHANGE_WIFI_MULTICAST_STATE` and `WAKE_LOCK` in the app's manifest; each event keeps the phone awake a few seconds so the worker can answer. |
|
|
70
73
|
| `app/item_history`, `app/web/item_history` | A history for each kind of item made of rows across tables, such as a workout with its exercises and sets: `item_history_feature(kinds)` keeps each kind's versions (an `ItemLevel` list read by `read_snapshot` and put back by `apply_snapshot`, a deleted item coming back whole) and adds `list_item_history`, `list_recent_changes` and `restore_item_version` with their specs; on the page, `HistoryView` lists the latest changes, `HistoryButton` and `open_item_history` open one item's versions, each restorable after a confirm. |
|
|
71
74
|
| `api_schemas` | The argument shapes many calls share as JSON Schema: `text(description)`, `number(description)`, `id_of("workout")`, a local `day`, a `moment`, a `json_file`'s text and a `step` of -1 or 1. |
|
|
72
|
-
| `history` | Every change to an app's items kept as versions in SQLite: `create_history` sets triggers on the tables that change an item, `record` saves one version of each item touched, and `restore` brings a version back, a deleted item with what was deleted under it; the versions table syncs, `read_changed_since` gives the newest version of each item changed after a moment, oldest first, and `history_methods` are the page's calls. Its tables are made only where missing, so an app with its own older versions table keeps it, naming its item column with `item_column`. A table that reaches its item only through another, such as a workout's sets through its exercises, names it with `item_lookup`, a query from the row. |
|
|
75
|
+
| `history` | Every change to an app's items kept as versions in SQLite: `create_history` sets triggers on the tables that change an item, `record` saves one version of each item touched, and `restore` brings a version back, a deleted item with what was deleted under it; the versions table syncs as rows that never change, an app's own index on the same columns as its item index is dropped, `read_changed_since` gives the newest version of each item changed after a moment, oldest first, and `history_methods` are the page's calls. Its tables are made only where missing, so an app with its own older versions table keeps it, naming its item column with `item_column`. A table that reaches its item only through another, such as a workout's sets through its exercises, names it with `item_lookup`, a query from the row. |
|
|
73
76
|
| `items` | The four read-only calls every app answers about its items for other apps ([Items for other apps](#items-for-other-apps)): `item_calls` turns the app's own kinds, search, get and changes into `list_item_kinds`, `search_items`, `get_items` and `list_item_changes` with their `api_spec` entries, every item in one shape (`Item`, `DeletedItem`, `ItemChange`) with its snippet clipped to 200 characters, limits defaulted and capped, and changes oldest first; `item_link` and `parse_item_link` for `x-<app>://<kind>/<id>` links with the id percent-encoded; `history_item_changes` answers the changes from `create_history` versions; a source with `text` adds the optional `get_item_texts`, each item's full text (`ItemText`) as plain text or Markdown cut to 256 KB by `clip_item_text`, and `has_text` on each kind. |
|
|
74
77
|
| `item_client` | Reading another app through its item calls: `item_client(app)` makes `list_item_kinds`, `search_items`, `get_items`, `list_item_changes` and `get_item_texts` at `POST /api/call/<method>`, falling back to the older `/api/<method>` and remembering which answered, ids sent a page at a time, `get_item_texts` null for an app that does not answer it (`ItemCallMissing`), and failures in plain words that never hold the token. |
|
|
75
78
|
| `plugins` | `create_plugin_host`: plugins bundled with the app or loaded at run time, each a manifest and a `start(context)`, started in the order their `requires` need and refused when meant for another app or app version; through the context a plugin adds hooks the app calls (on hookable, chosen for its typed, ordered and parallel calls with nothing of its own to style), providers the app picks one of by id, commands with keys, slot contents and settings fields, all taken back when it stops, is turned off or fails to start; one plugin's failing hook is reported and the rest still run; on/off and settings kept through `json_plugin_storage`, stored values that no longer fit falling back to their defaults; a text field marked `secret`, such as an API key, drawn hidden, replaced by `hidden_secret` in what `hide_secrets` gives other programs and given back its stored value by `keep_secrets` when those records are written; versions checked with semver. |
|
|
@@ -85,15 +88,20 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
85
88
|
| `electron/fetch` | `create_main_fetch` and `create_page_fetch`: the page's requests sent from the main process past cross-origin rules, to an allow-list of hosts, with headers such as `Origin` pinned; `create_main_stream_fetch` and `create_page_stream_fetch` carry the body chunk by chunk over an events channel into a `ReadableStream` body, for a player that reads as it lands, cancelled by the request's signal. |
|
|
86
89
|
| `electron/mcp`, `local_mcp_protocol`, `web/react/local_mcp_settings` | A desktop app's own MCP endpoint, for AI clients on the same computer: `create_local_mcp` serves an `api_spec`'s calls as tools through `server/mcp` on 127.0.0.1 only, leaving out page-only calls and refusing the uses its `page_only` rule names, since the window reaches those over the daemon's socket, refusing any request whose Host or Origin is not a local name, turned on and given a port by `LocalMcpMethods` and kept in a settings file; with `require_token` on it also refuses any request without its token as `Authorization: Bearer`, the token made by the daemon and kept in `token_file` (`mcp-token` beside the settings unless set, mode 0600), kept across restarts and forgotten when the setting is turned off, and the status then carries `token` and `token_file`; `local_mcp_client_config` gives the `mcpServers` entry with its `headers`, and `local_mcp_add_command` the `claude mcp add` line reading the token from its file; `LocalMcpSettings` is the Settings rows to turn it on, pick the port, require a token, copy the `claude mcp add` command and show or copy the client config. |
|
|
87
90
|
| `agent/commands` | `run_command` and `stream_command`: one shell command, in its own process group. |
|
|
88
|
-
| `agent/programs` | `run_program`: one program with its arguments and no shell, each stream shown to a sink, kept, both or dropped, stopped by an abort signal and, in a process group of its own, with all it started; 127 when it is not installed; `BoundedBuffer`, `signal_group` and `on_path`; `whole_lines(sink)` passes on only whole lines, decoding characters split across chunks, with `flush()` for the rest, so programs printing side by side into one output never split each other's lines. |
|
|
91
|
+
| `agent/programs` | `run_program`: one program with its arguments and no shell, each stream shown to a sink, kept, both or dropped, stopped by an abort signal and, in a process group of its own, with all it started; 127 when it is not installed; `start_line_program`, a program talked to in lines both ways while it runs, each whole line it prints handed on as it arrives (a character split across chunks kept whole), lines written to it until `end_input`, its group stopped by the signal; `BoundedBuffer`, `signal_group` and `on_path`; `whole_lines(sink)` passes on only whole lines, decoding characters split across chunks, with `flush()` for the rest, so programs printing side by side into one output never split each other's lines. |
|
|
89
92
|
| `agent/firefox_bookmarks` | Firefox's bookmarks on this computer: `firefox_profile(set_folder)` (the folder set, with `~`, or the default profile from `profiles.ini`, read by `default_profile_of`), `read_firefox_bookmarks(profile)` from a copy of `places.sqlite` with its write-ahead log, since Firefox keeps it locked, read again only once either changes, tags left out; `bookmark_folders` by path, `bookmark_folder_path`, `bookmarks_in_folder` with every folder inside, `search_bookmarks` by every word of the title or address, `bookmarks_by_guid` and `is_page_bookmark`. |
|
|
93
|
+
| `agent/claude_stream` | `start_claude_stream`: a Claude Code session driven over its stream-json protocol (`claude -p --input-format stream-json --output-format stream-json`) on `start_line_program`: `send_user` writes a message with the id the session echoes once it has read it, `control` sends a control request such as an interrupt or a change of permission mode and settles with the answer, a refusal or a timeout, the session's own requests such as `can_use_tool` go to `on_request` and are answered with `respond` (`allow_tool`, `deny_tool`), any not taken refused, and every other line is handed on with its JSON; `user_message_line`. |
|
|
94
|
+
| `agent/git` | Git through `run_program`, never a shell: `git` throws git's own last words on an exit code not allowed; `default_branch` from origin's HEAD; `add_worktree` makes a worktree once at a path on its own branch, from the freshly fetched default branch or a `base`, or takes the branch when it exists; `list_worktrees`, the main checkout first with each head and branch; `reset_worktree` back to a commit, new files cleaned; `remove_worktree`, forced or not, with its branch; `read_raw_changes` and `read_numstat` for `git diff --raw -z` and `--numstat -z` (renames by their new path, binary files as null), `sum_numstat` and `untracked_files`. |
|
|
95
|
+
| `agent/worktree_files` | A worktree's files for a page to browse read-only: `list_worktree_files`, what git tracks or would track, ignored files and skipped folders (`.git`, `node_modules`) left out, cut at a count; `read_worktree_file`, one file's text, or none for a binary or too large one, saying whether it came through a symlink; `confined_path` refuses an empty, absolute or `..` path, a skipped folder, and a symlink that leads out of the worktree or into a skipped folder. |
|
|
96
|
+
| `agent/github` | `github_cli`: GitHub through the `gh` program the user is signed into, so the app holds no token: `account`, `start_sign_in` with the device code and `sign_out`; `find_or_open_issue`, the open issue whose title is close enough (`best_title_match`, `title_likeness`) or a new one; `view_issue`, `ensure_labels` making only the missing ones, `edit_issue`, `post_comment`, `update_comment` (false once the comment is gone) and `close_issue`; `find_pull_request` for a branch, `view_pull_request` and `read_checks` by bucket, while checks still run too; `register_hook` adding or updating a repository's webhook. Bodies and the hook's secret go on gh's standard input, never its command line. |
|
|
97
|
+
| `agent_transcript` | An agent session's transcript, the same in a daemon, a page and a phone: `fold_stream_message` folds each stream-json line into steps (thinking, text, tool calls with their input and result, notices for an interrupt or a failed turn, the model and permission mode), partial blocks merged as they end; `add_user_message` is pending until the stream echoes it (`pending_messages`); `add_permission` and `waiting_permissions` for tool calls waiting on the user, denied by `close_open_blocks` when the session ends first; `stored_transcript` keeps it within a size, dropping the earliest steps but the starting input, and `read_transcript` reads it back; `tool_summary`, `edit_of` for the change an editing tool makes, and `permission_rule`, `rule_covers` and `rule_words` for allowing a tool, or a command's program, for the rest of the session. |
|
|
90
98
|
| `mpv` | Media played through mpv, run as a program of its own and driven over its JSON IPC socket: `MpvEngine` plays one file at a time behind `PlaybackEngine` (load with a start, an end, a gain in decibels and mpv's own per-file options, the next file appended for a gapless join, play, pause, stop, seek, volume, and `state`, `position` and `ended` events), sound only unless `video`; `MpvProcess` is mpv itself, found by `find_mpv` (each override in turn, then the PATH, through `on_path`) and started on the first command, its socket moved to /tmp when the temporary folder's path is too long for one, a start that fails or times out refused with why and mpv's last log line, started again by the next command after a failure or an exit, with `observe` for properties kept across restarts, `on_event`, `on_stop` and `close`, which waits until mpv has gone; `NullEngine` for testing an app's player without mpv. |
|
|
91
99
|
| `agent/wake` | `magic_packet` and `send_magic_packet`: Wake-on-LAN, a few copies of the packet broadcast to a port, sent by a server or by an agent on the sleeping machine's network; `parse_mac` takes colons, dashes, dots or none, a SecureOn `password` follows the packet (`parse_password`), `send_wake_packet` sends a ready packet, and `remote_send_command` is the shell line that sends it from another host with python3 or socat. |
|
|
92
100
|
| `agent/desktop_notify` | `Notifier`: desktop notifications through notify-send in the agent's own session, with a Dismiss button, a link opened by xdg-open on a click, a timeout the agent enforces even for critical ones, and keys, so a newer notification for a key replaces the old and dismissing the key closes it; the app names itself and maps its own icon names to files. |
|
|
93
101
|
| `agent/scheduled_notices` | `keep_giving_scheduled_notices`: notices that fall due at set moments, such as reminders, shown through a `Notifier` by a daemon with or without a window; each check shows what fell due since the last, and the moment reached is kept so one missed while stopped still shows, up to half a day late. |
|
|
94
102
|
| `agent/inhibit` | `IdleInhibitor`: keeps the host from idling into suspend while anything holds it, through one systemd-inhibit lock shared by every holder and let go a moment after the last; the lock dies with the agent, and a suspend the user asks for still goes ahead. |
|
|
95
103
|
| `local_daemon`, `autostart` | A desktop app's daemon and window, as the Application Standard sets out: `daemon_socket_path` is `$XDG_RUNTIME_DIR/<app>/daemon.sock`, or a socket of its own for any other data file, such as a test database; `listen_on_socket` serves a server there for its user alone, removes a socket a dead daemon left and refuses with `DaemonRunningError` while another answers; `start_daemon` starts the daemon apart from the window unless one answers, on Electron's own binary as Node, without the descriptors Electron leaves open (`covered_descriptors`), its output in `daemon_log_path`, and waits until it answers or says why it died, or with `replace_other_build` first stops a daemon of another build, which `listen_on_socket` records beside the socket (`read_daemon_build`, `daemon_build_id`, a hash of the entry file), so a window opened after an upgrade does not use the old daemon; `call_daemon` posts a call with its arguments as a JSON array; `follow_daemon_events` follows its server-sent events, reconnecting when the daemon comes back. `autostart`: an XDG autostart entry (`set_autostart`, `is_autostart_on`, counting one the desktop hid as off), with `launch_command` starting the app again from Flatpak, an AppImage, the packaged binary or Electron and the app's folder. |
|
|
96
|
-
| `connections`, `connection_protocol`, `connection_file_storage`, `web/connection_storage`, `daemon_link` | The daemons a desktop or phone app connects to, like Deluge's connection manager: `create_connections` keeps "This computer" where the app offers a local daemon (`offers_local`, false for a portal app such as X-Nix and on a phone) and daemons on other hosts, each signed in once as the device (`device_name`) for a token of its own that the page never sees, a second sign-in by the same user only renewing it and removing one giving it back; the chosen daemon falls back to this computer, then the first remote one, and `subscribe` hears when it changes; its `methods` (`ConnectionMethods`, named by `connection_method_names`) are the bridge's calls, and `connection_address` makes a typed address whole. The list is kept by `connection_file_storage` in a file only its owner can read,
|
|
104
|
+
| `connections`, `connection_protocol`, `connection_file_storage`, `web/connection_storage`, `daemon_link` | The daemons a desktop or phone app connects to, like Deluge's connection manager: `create_connections` keeps "This computer" where the app offers a local daemon (`offers_local`, false for a portal app such as X-Nix and on a phone) and daemons on other hosts, each signed in once as the device (`device_name`) for a token of its own that the page never sees, a second sign-in by the same user only renewing it and removing one giving it back; the chosen daemon falls back to this computer, then the first remote one, and `subscribe` hears when it changes; its `methods` (`ConnectionMethods`, named by `connection_method_names`) are the bridge's calls, and `connection_address` makes a typed address whole. The list is kept by `connection_file_storage` in a file only its owner can read, `local_connection_storage` in a phone page's local storage, or `memory_connection_storage` in memory alone, such as for a test. `create_daemon_link` sends the main process's calls to the chosen daemon, over the local socket through `call_daemon` or to a remote one over http(s) with the token, and `follow_events` follows its change events, moving to the new daemon by itself; `follow_remote_events` is `follow_daemon_events` over http(s). |
|
|
97
105
|
| `daemon_router` | A desktop app's main process as a portal onto its daemon: `create_daemon_router` sends each of the page's calls (`call`, or a whole table with `forwarded`, its prefix fixed or worked out per call) to the daemon `connections` has chosen through `daemon_link`, except the tables that stay on this computer whichever daemon is in use (`local_tables`, `default_local_tables` unless given: its sync, certificates, MCP and own settings), sent to its socket by `call_local`; it follows the chosen daemon's events (`changed`, `sync_status`, the app's own through `on_event`, a reconnect counted as a change), keeps the client id the daemon gives in `hello` so a window is not told of its own changes, starts this computer's daemon again through `restart_local` when it went away, and calls `on_switch` when another daemon is chosen; a portal app gives no `call_local`. |
|
|
98
106
|
| `electron/tray` | `create_app_tray`: a desktop app's tray icon, shown or taken away by a setting (`set_shown`), its tooltip and menu read from the app as plain rows (`TrayView`) on a timer and on `refresh`, a failed read keeping the last menu; `app_rows` gives the Show, Quit and Quit completely rows every app ends with, and `tray_groups` rules groups of rows off from each other. |
|
|
99
107
|
| `agent/local_socket` | `LineServer` and `follow_lines`: JSON messages, one per line, handed from one local process to every follower of a unix socket, the follower reconnecting whenever the socket is not there, such as a desktop agent following a system agent's notifications. |
|
|
@@ -120,13 +128,14 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
120
128
|
| `server/password_sign_in` | For apps not yet on `server/account_sign_in`. `register_password_sign_in`: names and passwords from the accounts file open a session the server keeps (on @fastify/session) through `/api/login`, with `/api/logout` and `/api/me`; a wrong name takes as long as a wrong password, an address gets a few tries whatever names it gives before it waits (on @fastify/rate-limit), passwords are checked in `password_hashes` (`shared_password_hashes` unless set), and other API paths but the open ones answer 401 as JSON. |
|
|
121
129
|
| `server/forge_webhook` | A forge's pushes: `is_signed` for GitHub's HMAC, Gitea's and Forgejo's signatures, a bearer token or GitLab's token; `event_of`, `parse_payload` and `read_push`, which names the branch and the repository URLs through the app's own normaliser; `AddressLockout` for an address that keeps failing to sign; `SeenDeliveries`, whose `is_replay` notices a signed body sent again within a day; `Debouncer` so a burst of pushes starts one run; `register_webhook_route`, which keeps the raw body the signature covers. |
|
|
122
130
|
| `server/poller`, `server/runs` | `CyclePoller`: each watched item's cycle on its own timer, every `interval` or every `job_poll` while busy, with `refresh` and `soon`; `follow_run`: a long run's new output copied to a sink and the run finished once it has ended, with `describe` and `translate` hooks, an unreachable agent, a malformed or stuck poll reply, or a failing sink leaving it as `unreachable` to be followed again and only an agent that no longer knows the run ending it early, each follow taking at most `most_polls_per_follow` polls and about `most_output_per_follow_in_bytes`, and a `translate` that throws keeping the raw output. |
|
|
131
|
+
| `server/github_webhook` | GitHub's webhooks on `forge_webhook`: `create_github_receiver` is a `register_webhook_route` receive that counts a delivery only when signed with X-Hub-Signature-256 under the app's secret (never a bearer token or another forge's header), turns away an address that keeps failing, answers a replayed delivery id without passing it on again, answers a ping and passes on only the repository and the pull requests, branches and issues an event names (`targets_of`, for `github_target_events`), each checked for shape and a fork's branch left out; `read_targets` for stored ones, `delivery_id_of`, `repository_of`, `is_repository_name`, `read_public_url` and `payload_url_of`. |
|
|
123
132
|
| `server/events` | `EventStream`: server-sent events with a client id per page, a heartbeat, `announce_change(except_client_id)` so the page that made a change is not told, nameless or named events to all or chosen clients, headers set before the stream opens (such as `register_open_cors`'s) sent with it, and every stream ended with the app; `leading_cooldown` sends the first change at once and a burst's rest once per cooldown. |
|
|
124
133
|
| `server/call_table` | `register_call_table`: a table of calls served as POST `<path>/<method>` with the arguments as a JSON list, as a desktop app's daemon and a web server both answer them, and by name as a JSON object for the calls whose argument names `params` gives, such as the app's `api_spec` (`api_spec`'s `NamedParams` is all it needs); a name the table lacks (its prototype's included) is refused, every answer goes as JSON so a string stays a string, a read is sent uncached, and `on_change` runs after any call `is_read_only` does not pass, with the caller's client id. |
|
|
125
134
|
| `server/leases` | `Leases`: what a page holds open while it shows something costly, such as fast polling of a running job while its log is open, each lease ending when closed or once it goes unrenewed for a while. |
|
|
126
135
|
| `server/security_headers` | `register_security_headers`: every answer carries a content security policy that runs only the app's own scripts (`default_content_security_policy`, with directives the app replaces through `content_security_policy`, or none with null), `X-Frame-Options` and `frame-ancestors` refusing framing unless `allow_same_origin_frames`, `nosniff`, a same-origin referrer policy and opener policy; headers a route sets itself are kept. |
|
|
127
136
|
| `server/web_folder` | `register_web_folder`: the built page from a folder, tuned for the Nix store (no etag or date, hashed `/assets/` kept a year, the page fetched fresh), a warning, error or nothing when the folder is missing, and the page for unknown paths when it routes itself. |
|
|
128
137
|
| `server/replies` | `register_error_replies`: errors and unknown paths answered in plain text or as `{ error }`; `register_lenient_json_body`: an empty body as no arguments and bad JSON as `BAD_JSON`, for the route to refuse in its own words, or refused with 400 before any route runs with `refuse_bad_json`; `send_text`. |
|
|
129
|
-
| `server/config` | `read_server_config`: host, port, web folder and the app's options from flags, then the environment, then defaults, with usage text for `--help`, the secret from `<PREFIX>_TOKEN_FILE` or `<PREFIX>_TOKEN`, and no listening beyond this machine without one; `read_secret_file`; a secret printed by a command, such as a password manager's, so a setting names the program and never holds the secret: `command_words` splits the setting as a shell would without expanding anything, `secret_command_reader({ what, secret })` runs it without a shell and keeps its first line, refusing a failure, an empty or an overlong line (`max_secret_chars`) in words that never hold what it printed, `read_secret_command` with the default words, and `secret_from_command(line, read)`, `""` when no command is set. |
|
|
138
|
+
| `server/config` | `read_server_config`: host, port, web folder and the app's options from flags, then the environment, then defaults, with usage text for `--help`, the secret from `<PREFIX>_TOKEN_FILE` or `<PREFIX>_TOKEN`, and no listening beyond this machine without one; `read_secret_file`; `create_secret_file`, a new random secret, such as a webhook's, in a file only its owner reads (mode 0600, tightened over an older file), read back only when the app is asked for it, and `has_secret_file`, whether there is one without reading it out; a secret printed by a command, such as a password manager's, so a setting names the program and never holds the secret: `command_words` splits the setting as a shell would without expanding anything, `secret_command_reader({ what, secret })` runs it without a shell and keeps its first line, refusing a failure, an empty or an overlong line (`max_secret_chars`) in words that never hold what it printed, `read_secret_command` with the default words, and `secret_from_command(line, read)`, `""` when no command is set. |
|
|
130
139
|
| `server/declared_tokens` | Tokens declared in the app's config, so a scraper's token can live in a NixOS config: `read_declared_tokens` reads each entry's name, its `token_hash` (`sha256:<hex>` from `token_hash`), `token_file` or plain `token`, and a scope the app maps onto a role, read-only or not, or onto no role for a token only the app's own routes check, optionally limited to some of the app's items; bad entries are skipped and explained. Given to `AccountStore` as `declared_tokens` (or `set_declared_tokens` after a reload), they sign in with `server/account_sign_in` as their scope's role, cannot be revoked from the page, and `check_declared_token` finds the role-less ones. |
|
|
131
140
|
| `config_watch` | `watch_config`: re-reads a config file when it changes, checking a fingerprint of what its path points at (symlinks followed, inode, change time, size) every few seconds, waiting one more check for it to hold still, and reloading only when the content's sha256 differs from what was loaded; a failed reload is reported and the watch goes on. |
|
|
132
141
|
| `server/prometheus` | `render_metrics`: metric families in Prometheus' text format, with HELP and TYPE lines, labels in order, names made valid, label values and help escaped and infinities written as the format asks; `metrics_content_type`. |
|
|
@@ -144,7 +153,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
144
153
|
| `web/files` | `read_picked`: a file picker's text, the picker cleared so the same file can be picked again; `save_text(file_name, text, type)` offers text as a download, such as a settings export. |
|
|
145
154
|
| `web/states`, `web/tables`, `web/menus`, `web/split`, `web/errors` | `LoginNeeded`; sorting by several columns, trees and column order; for rows of plain objects, the same on a server and in the page, `sort_rows` (numbers before text, natural order, empty cells last), `filter_rows` on every typed word, `next_sort_keys` for header clicks, `keyed_rows` from contents and `tree_rows` by a parent field; menu items, placement and keys; pane sizing; `describe_error` for anything thrown, such as shaka's coded objects, and `describe_call_error`, the same without Electron's remote-method prefix, for a failed call shown to the user. |
|
|
146
155
|
| `web/api`, `web/events` | `create_api`: JSON calls whose 401 throws `LoginNeeded` except on open paths such as the login, whose refusals throw `ApiError` in the server's words (a proxy's HTML error page, such as a 504, in plain ones), with headers read afresh per call and `{ keepalive: true }` letting a call outlive the page while its body fits under the browser's 64 KiB; `follow_changes`: the page's side of `EventStream`, a watch bumped on each change and after a reconnect, and the client id to send back. |
|
|
147
|
-
| `web/tree` | Rows with `parent_id` and `position`: nesting, subtrees, tree order, paths, and where a dropped or keyed row lands, its siblings ordered by position or, with `by_list_order`, as the list gives them. |
|
|
156
|
+
| `web/tree` | Rows with `parent_id` and `position`: nesting, subtrees, tree order, paths, and where a dropped or keyed row lands, its siblings ordered by position or, with `by_list_order`, as the list gives them; `item_by_id` and `with_ancestors` look items up through an index made once per list, which `subtree_ids` and `path_names` share, so a list's items are copied rather than edited in place. |
|
|
148
157
|
| `web/watch`, `web/react/watch` | `create_watch`: a change counter a store bumps; `use_watch` redraws only the components that read that store; `coalesce_bumps` lands a bump at most once per interval, for streamed tokens. |
|
|
149
158
|
| `web/store`, `web/react/store` | `create_store`: a value with a watch, set or updated, redrawing at a steady pace when `coalesce_in_milliseconds` is given; `use_store` reads it. |
|
|
150
159
|
| `web/prefs`, `web/react/prefs` | Remembered view settings that read as their default when stored corrupt, stale or of the wrong shape; `use_pref` keeps one as component state. |
|
|
@@ -167,11 +176,15 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
167
176
|
| `web/react/test_stubs` | Stands in for `showPopover`, `hidePopover`, `showModal`, `close`, `matchMedia`, `scrollTo`, `ResizeObserver` and text's `getClientRects`, which jsdom lacks; an app's widget tests import it for its side effects, and a node test's shared setup may import it too. |
|
|
168
177
|
| `web/react/list_picker` | `pick_list_dialog`: adds one thing to any of the app's lists, such as a video to playlists, ticking the lists that hold it and making a new one. |
|
|
169
178
|
| `web/react/emoji_picker` | `EmojiPicker` on Frimousse, searchable, grouped and worked by keyboard, its Emojibase list bundled in a chunk of its own so it works offline; `EmojiField`, a button showing the chosen emoji that opens the picker under itself, with a clear button. |
|
|
170
|
-
| `web/react/controls`, `table` | Segmented choices, button groups, switches with their label beside them on `show_label`, search boxes that hand on typing as it pauses, submit on Enter or a button, clear on Escape, can take a paste whole, take focus and follow a value cleared from outside, selects with option groups, `CommitInput`, `NumberField` stepped with − and + or the arrow keys, typed with a phone's number keys and kept within its limits, `DateTimeField`, `PeriodStepper` stepping a day or month back and forward, picking one or returning to the current one, `PathInput` with a Browse button on the app's picker, `ColorPicker`, `TreeSelect` opening an indented card that shows the picked path, `TreePicker` searching a tree as it is typed into, matches shown under their parents, offering the typed text as a new item with `on_create`; `DataTable` on TanStack Table, sorting by several columns, filtering by typed words, grouping by a column's values and hiding columns from a Columns button on its own unless the app takes them over (`column_hiding={false}` leaves the button out), with columns to move, resize, hide and filter from buttons pinned over the heading band, a `header` such as an icon shown in place of a column's label, tree rows, groups under headings, rows the app drags and styles, rows that come sorted from a database, rows worked by keyboard, rows that draw again only when they change, `virtual` rows drawn only where they show, spaced by a drawn row's measured height when the app gives none, a last column that fills the room left, group headings that hide when the filter empties them, a `wrap_class` for Halon's `scroll`, `fit` and `sticky-head`, `single_line` rows one line high with an ellipsis, and cards on phones, under the table's buttons on a line of their own; a pager. |
|
|
179
|
+
| `web/react/controls`, `table` | Segmented choices, button groups, switches with their label beside them on `show_label`, search boxes that hand on typing as it pauses, submit on Enter or a button, clear on Escape, can take a paste whole, take focus and follow a value cleared from outside, selects with option groups and a `disabled` state, `CommitInput`, `NumberField` stepped with − and + or the arrow keys, typed with a phone's number keys and kept within its limits, `DateTimeField`, `PeriodStepper` stepping a day or month back and forward, picking one or returning to the current one, `PathInput` with a Browse button on the app's picker, or typed alone without one, `ColorPicker`, `TreeSelect` opening an indented card that shows the picked path, `TreePicker` searching a tree as it is typed into, matches shown under their parents, offering the typed text as a new item with `on_create`; `DataTable` on TanStack Table, sorting by several columns, filtering by typed words, grouping by a column's values and hiding columns from a Columns button on its own unless the app takes them over (`column_hiding={false}` leaves the button out), with columns to move, resize, hide and filter from buttons pinned over the heading band, a `header` such as an icon shown in place of a column's label, tree rows, groups under headings, rows the app drags and styles, rows that come sorted from a database, rows worked by keyboard, rows that draw again only when they change, `virtual` rows drawn only where they show, spaced by a drawn row's measured height when the app gives none, a last column that fills the room left, group headings that hide when the filter empties them, a `wrap_class` for Halon's `scroll`, `fit` and `sticky-head`, `single_line` rows one line high with an ellipsis, and cards on phones, under the table's buttons on a line of their own; a pager. |
|
|
171
180
|
| `web/react/facet_pane` | `FacetPane`: the values of one field with how many items hold each and an All row, picked to narrow a list by plain, Ctrl and Shift clicks or by keyboard as a listbox (arrows, Home, End and pages walk it, Space or Enter picks, Shift stretches from the anchor, Ctrl+A takes every value, Escape goes back to All), one at a time unless `multiple`, its loading, failure and empty states, and `virtual` rows for long lists such as every artist, laid out as Halon's `scroll-pane` filling the height it is given with the head kept in view; `facet_pick` is the picking rule alone. |
|
|
172
181
|
| `web/react/board`, `phone` | `Board`: a board of fixed-width columns under small caps heads with their counts, plain like a kanban or split into `lanes`, each with a head that stays in view sideways and an outlined `current` column, grouped by `group_items` under headings that fold; each cell holds the app's `render_cell` content or its `cards` (many per cell, opened by a click or Enter, with the app's class, style and context menu), moved between columns by dragging (the card lifting for the browser's picture, a dashed outline only where `can_move` and the column's `accepts_drop` allow) or with Alt and the arrow keys; worked as a grid by keyboard (arrows walk heads, cells and cards, Home and End, Ctrl for the board's ends, Enter opens, Left and Right fold a group), a skeleton, failure with Retry or empty state in place of an empty board, and on phones a list of lanes with their filled cells under the column names, or a plain board's columns one under another, those holding nothing left out with `phone_hide_empty`, whose cards still drag onto the columns or cells that take them (an empty one showing while a card is dragged) or out of the board, and move to the previous or next column with Alt and any arrow key; a `class_name` for its box, such as Halon's `fills`, or `inset` for a board that is its own surface. Drag and drop is the browser's own, as in `Tree` and `DataTable`, so a phone's touch does not drag cards. `use_phone`: whether the page is phone-sized, as the widgets' phone layouts go by, and `use_media_query` for any other media query, both read again as the window changes. |
|
|
173
182
|
| `web/react/card_grid` | `CardGrid`: cards in a grid the reader arranges, each dragged by its handle or moved with the arrow keys on it and resized from its corner or with Shift and the arrows, the others moving out of the way and every card floating up to fill the gaps; the places are plain data (`CardPlace`: column, row, width and height in cells) the app saves from `on_places_change`, a card without one placed in rows below the rest by `place_cards`, and a phone shows the cards in a column in reading order. On react-grid-layout (MIT), chosen over Gridstack because it is React through and through and keeps the layout as plain data, matching dragging, resizing and compacting feature by feature; X-App adds the keyboard path (`step_card`, `step_of_key`), the phone layout, placing new cards and Halon's markup. |
|
|
174
183
|
| `dashboard`, `web/react/dashboard` | Dashboards a person builds from the data an app offers, like a small Grafana: the app describes its data sets (`DataSet`, plain rows with text, number and time fields, their order, names, colours and number formats) and `run_card` works a `ChartCard` out in memory, narrowed by a `filter` tree and a period, grouped by a field or by hours, days, weeks or months, split by a second field and measured as a count, sum, average, lowest, highest, distinct count or latest value; `fitting_views`, `card_problem`, `settle_card`, `flat_filter` and `clean_dashboards` for saved ones read back from anywhere. `Dashboards` draws them: named dashboards as tabs that are added, renamed, copied, reset to the app's `new_dashboard` and deleted; each a `CardGrid` arranged once Arrange is on, with an Add card menu of a chart and the app's ready-made cards (`ReadyCardKind`), each card's menu to edit, copy, remove and on a phone move it up or down; a chart editor with plain conditions joined by all or any of them, grouping, measure, order and only the views that fit, over a live preview; a chart drawn as a number, bars, stacked bars, lines, a donut, meters (each a share of the largest group), a treemap or a table, in a field's own colours or Halon's series; each data set (`DataSource`) loaded once from the earliest moment its cards need and again on `refresh`, each card with its own loading, empty, failed and problem states and a card that throws kept in its place. The dashboards are plain JSON the app saves from `on_change`. |
|
|
184
|
+
| `web/react/diff` | `FileDiff`: one file's change from `diff_rows`, side by side with old on the left (`layout="split"`) or in one column with both line numbers (`"unified"`), removed and added lines tinted and their changed words marked again with Halon's `diff-removed`, `diff-added` and `diff-word`, a hunk's heading between hunks, and each long unchanged stretch behind a "Show N more unchanged lines" button; a file with no lines says so. `FileContent`, a file's text with numbered lines; `EditDiff`, the lines one edit takes out and puts in from its before and after, cut short past a `limit`; `DiffCounts`, "+3 −1" read out as added and removed; `diff_status_words`, each status's label, letter and tone. |
|
|
185
|
+
| `web/react/file_tree` | `FileTree`: files as a folder tree on `Tree`, folders first and folding by click or the arrow keys, each changed file with its counts and a lettered badge for how it changed, an app's own `extra` beside them such as a reviewed mark, `folded` folders to start shut, and a filter box keeping the folders of the files it matches; `file_tree_rows` and `file_tree_folders` are its rows and folders alone. |
|
|
186
|
+
| `web/react/transcript` | `TranscriptView`: an `agent_transcript` drawn as a log of steps, thinking folded to its last line, text as Markdown, each tool call a row naming the tool and what it works on that opens to its input and result, an edit as an `EditDiff`, a failure edged in red, the user's messages marked while not yet read, and each tool call waiting for approval with Allow, Allow for the session (`allow_for_session`, its words in `permission_words`) and Deny with a reason; it follows the newest step while `live` until the reader scrolls up, with Jump to Latest. `TranscriptMessageBox`: a box to write to the agent, sent by its button or Ctrl+Enter and emptied once sent. |
|
|
187
|
+
| `web/react/copy_button` | `CopyButton`: copies its text, or what a function gives back when pressed, such as a secret fetched only then, with a "Copied." toast, and says so when the browser will not copy; `copy_text` does the same from anywhere. |
|
|
175
188
|
| `web/react/merge_grid` | `MergeGrid`: records to merge into one side by side, a column each with its heading, a Survivor button and Take all from this, a row per field and a Result column; the survivor's column marked with Halon's `picked-column`; where the records disagree each value is a `cell-button` that wins the field, a field with `combine` offers Keep all and keeps all by default, the rest go to the survivor, the arrow keys move between the buttons and `only_differences` hides the fields that agree; `merged_values` gives what each field ends up with for the app to save. |
|
|
176
189
|
| `web/react/outcome_log` | `OutcomeLog`: what happened to each item of a run, such as each file of a scan or each row of an import, on `DataTable` with `virtual` rows: a `StateBadge` per outcome, the item and why on one line each, cut off with an ellipsis and whole in their hover text, a filter of the outcomes that happened with their tallies, held by the log or the app, and a Follow switch keeping the newest in view while entries arrive until the reader scrolls up; its scrolling box takes Halon's `following-output` height unless `wrap_class` gives another. |
|
|
177
190
|
| `web/react/shortcuts` | `use_shortcuts` for keys such as `"mod+z"`, quiet while typing or while a dialog or popover is open; `describe_keys` for help text. |
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type LineProgramExit } from "./programs.ts";
|
|
2
|
+
export type StreamMessage = Record<string, unknown>;
|
|
3
|
+
export interface ClaudeStreamOptions {
|
|
4
|
+
cwd?: string;
|
|
5
|
+
env?: NodeJS.ProcessEnv;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
on_line: (line: string, message: StreamMessage | null) => void;
|
|
8
|
+
on_request?: (request_id: string, request: StreamMessage) => boolean;
|
|
9
|
+
control_timeout_in_milliseconds?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ClaudeStream {
|
|
12
|
+
send_user: (text: string, id: string) => void;
|
|
13
|
+
control: (request: StreamMessage) => Promise<StreamMessage>;
|
|
14
|
+
respond: (request_id: string, response: StreamMessage) => void;
|
|
15
|
+
end_input: () => void;
|
|
16
|
+
is_open: () => boolean;
|
|
17
|
+
finished: Promise<LineProgramExit>;
|
|
18
|
+
}
|
|
19
|
+
export declare function user_message_line(text: string, id: string): string;
|
|
20
|
+
export declare function allow_tool(input: StreamMessage): StreamMessage;
|
|
21
|
+
export declare function deny_tool(message: string): StreamMessage;
|
|
22
|
+
export declare function start_claude_stream(argv: readonly string[], options: ClaudeStreamOptions): ClaudeStream;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// A Claude Code session driven over its stream-json protocol, as `claude -p --input-format stream-json
|
|
2
|
+
// --output-format stream-json` speaks it: user messages written to its input at any time, control requests such as an
|
|
3
|
+
// interrupt or a change of permission mode answered by id, the session's own requests, such as asking whether a tool
|
|
4
|
+
// may run, answered back, and every other line it prints handed on whole and parsed.
|
|
5
|
+
// ── Imports ──────────────────────────────────────────────────────────────────
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { start_line_program } from "./programs.js";
|
|
8
|
+
const default_control_timeout_in_milliseconds = 30_000;
|
|
9
|
+
// ── Messages ─────────────────────────────────────────────────────────────────
|
|
10
|
+
// The line that writes a user message to the session.
|
|
11
|
+
export function user_message_line(text, id) {
|
|
12
|
+
return JSON.stringify({ type: "user", message: { role: "user", content: [{ type: "text", text }] }, parent_tool_use_id: null, uuid: id });
|
|
13
|
+
}
|
|
14
|
+
// The answer allowing a tool call the session asked about, with the input it may run with.
|
|
15
|
+
export function allow_tool(input) {
|
|
16
|
+
return { behavior: "allow", updatedInput: input };
|
|
17
|
+
}
|
|
18
|
+
// The answer refusing a tool call, with the reason the agent is given.
|
|
19
|
+
export function deny_tool(message) {
|
|
20
|
+
return { behavior: "deny", message: message || "The user refused this tool call." };
|
|
21
|
+
}
|
|
22
|
+
// ── Session ──────────────────────────────────────────────────────────────────
|
|
23
|
+
export function start_claude_stream(argv, options) {
|
|
24
|
+
const waiting = new Map();
|
|
25
|
+
const timeout = options.control_timeout_in_milliseconds ?? default_control_timeout_in_milliseconds;
|
|
26
|
+
function on_line(line) {
|
|
27
|
+
if (!line.trim())
|
|
28
|
+
return;
|
|
29
|
+
let message = null;
|
|
30
|
+
try {
|
|
31
|
+
message = JSON.parse(line);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
message = null;
|
|
35
|
+
}
|
|
36
|
+
if (message?.type === "control_response") {
|
|
37
|
+
const response = (message.response ?? {});
|
|
38
|
+
const waiter = waiting.get(String(response.request_id ?? ""));
|
|
39
|
+
if (!waiter)
|
|
40
|
+
return;
|
|
41
|
+
waiting.delete(String(response.request_id));
|
|
42
|
+
clearTimeout(waiter.timer);
|
|
43
|
+
if (response.subtype === "error")
|
|
44
|
+
waiter.reject(new Error(String(response.error ?? "the session refused the request")));
|
|
45
|
+
else
|
|
46
|
+
waiter.resolve((response.response ?? {}));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (message?.type === "control_request") {
|
|
50
|
+
const request_id = String(message.request_id ?? "");
|
|
51
|
+
const taken = options.on_request?.(request_id, (message.request ?? {})) ?? false;
|
|
52
|
+
if (!taken)
|
|
53
|
+
program.write_line(JSON.stringify({ type: "control_response", response: { subtype: "error", request_id, error: "This program does not answer this request" } }));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
options.on_line(line, message);
|
|
57
|
+
}
|
|
58
|
+
const program = start_line_program(argv, { cwd: options.cwd, env: options.env, signal: options.signal, on_line });
|
|
59
|
+
const finished = program.finished.then((exit) => {
|
|
60
|
+
for (const [id, waiter] of waiting) {
|
|
61
|
+
clearTimeout(waiter.timer);
|
|
62
|
+
waiter.reject(new Error("the session ended before it answered"));
|
|
63
|
+
waiting.delete(id);
|
|
64
|
+
}
|
|
65
|
+
return exit;
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
send_user: (text, id) => program.write_line(user_message_line(text, id)),
|
|
69
|
+
control: (request) => new Promise((resolve, reject) => {
|
|
70
|
+
if (!program.is_open())
|
|
71
|
+
return reject(new Error("the session is no longer taking requests"));
|
|
72
|
+
const request_id = randomUUID();
|
|
73
|
+
const timer = setTimeout(() => {
|
|
74
|
+
waiting.delete(request_id);
|
|
75
|
+
reject(new Error("the session did not answer in time"));
|
|
76
|
+
}, timeout);
|
|
77
|
+
waiting.set(request_id, { resolve, reject, timer });
|
|
78
|
+
program.write_line(JSON.stringify({ type: "control_request", request_id, request }));
|
|
79
|
+
}),
|
|
80
|
+
respond: (request_id, response) => program.write_line(JSON.stringify({ type: "control_response", response: { subtype: "success", request_id, response } })),
|
|
81
|
+
end_input: program.end_input,
|
|
82
|
+
is_open: program.is_open,
|
|
83
|
+
finished,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DiffFileStatus } from "../diff_rows.ts";
|
|
2
|
+
export declare function git(args: string[], cwd: string, allowed_exit_codes?: number[]): Promise<string>;
|
|
3
|
+
export declare function default_branch(repository: string): Promise<string>;
|
|
4
|
+
export interface WorktreeRequest {
|
|
5
|
+
path: string;
|
|
6
|
+
branch: string;
|
|
7
|
+
base?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Worktree {
|
|
10
|
+
path: string;
|
|
11
|
+
head: string;
|
|
12
|
+
branch: string;
|
|
13
|
+
main: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function add_worktree(repository: string, { path, branch, base }: WorktreeRequest): Promise<string>;
|
|
16
|
+
export declare function list_worktrees(repository: string): Promise<Worktree[]>;
|
|
17
|
+
export declare function reset_worktree(path: string, commit: string): Promise<void>;
|
|
18
|
+
export declare function remove_worktree(repository: string, path: string, options?: {
|
|
19
|
+
force?: boolean;
|
|
20
|
+
delete_branch?: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
export interface RawChange {
|
|
23
|
+
path: string;
|
|
24
|
+
old_path: string;
|
|
25
|
+
status: DiffFileStatus;
|
|
26
|
+
blob: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function read_raw_changes(text: string): RawChange[];
|
|
29
|
+
export declare function read_numstat(text: string): Map<string, {
|
|
30
|
+
additions: number;
|
|
31
|
+
deletions: number;
|
|
32
|
+
} | null>;
|
|
33
|
+
export declare function sum_numstat(text: string): {
|
|
34
|
+
additions: number;
|
|
35
|
+
deletions: number;
|
|
36
|
+
};
|
|
37
|
+
export declare function untracked_files(worktree: string): Promise<string[]>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Git through `run_program`, never a shell: one git command whose failure throws git's own words, a repository's default
|
|
2
|
+
// branch, worktrees made on their own branch, listed, reset and removed, and readers for what `git diff --raw` and
|
|
3
|
+
// `--numstat` print, so an app can list a branch's changed files with their status and line counts.
|
|
4
|
+
// ── Imports ──────────────────────────────────────────────────────────────────
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { run_program } from "./programs.js";
|
|
7
|
+
// ── Running ──────────────────────────────────────────────────────────────────
|
|
8
|
+
// Runs git in a folder and gives back what it printed, throwing its last words when it ends with an exit code not allowed.
|
|
9
|
+
export async function git(args, cwd, allowed_exit_codes = [0]) {
|
|
10
|
+
const result = await run_program(["git", ...args], { cwd, stdout: "keep", stderr: "keep" });
|
|
11
|
+
if (!allowed_exit_codes.includes(result.exit_code))
|
|
12
|
+
throw new Error(`git ${args[0]} failed: ${result.stderr.trim() || `exit ${result.exit_code}`}`);
|
|
13
|
+
return result.stdout;
|
|
14
|
+
}
|
|
15
|
+
// The branch origin's HEAD names, such as "origin/main", or "HEAD" when the repository has no origin.
|
|
16
|
+
export async function default_branch(repository) {
|
|
17
|
+
try {
|
|
18
|
+
return (await git(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], repository)).trim();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return "HEAD";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// The worktree at the path, made the first time on its own branch, the branch taken when it already exists.
|
|
25
|
+
export async function add_worktree(repository, { path, branch, base }) {
|
|
26
|
+
if (existsSync(path))
|
|
27
|
+
return path;
|
|
28
|
+
if (base === undefined)
|
|
29
|
+
await git(["fetch", "--quiet", "origin"], repository).catch(() => undefined);
|
|
30
|
+
const has_branch = await git(["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`], repository).then(() => true, () => false);
|
|
31
|
+
if (has_branch)
|
|
32
|
+
await git(["worktree", "add", path, branch], repository);
|
|
33
|
+
else
|
|
34
|
+
await git(["worktree", "add", "-b", branch, path, base ?? (await default_branch(repository))], repository);
|
|
35
|
+
return path;
|
|
36
|
+
}
|
|
37
|
+
// The repository's worktrees, its main checkout first, as `git worktree list --porcelain` names them.
|
|
38
|
+
export async function list_worktrees(repository) {
|
|
39
|
+
const text = await git(["worktree", "list", "--porcelain", "-z"], repository);
|
|
40
|
+
const worktrees = [];
|
|
41
|
+
let current = null;
|
|
42
|
+
for (const field of text.split("\0")) {
|
|
43
|
+
if (field.startsWith("worktree ")) {
|
|
44
|
+
current = { path: field.slice("worktree ".length), head: "", branch: "", main: worktrees.length === 0 };
|
|
45
|
+
worktrees.push(current);
|
|
46
|
+
}
|
|
47
|
+
else if (current && field.startsWith("HEAD "))
|
|
48
|
+
current.head = field.slice("HEAD ".length);
|
|
49
|
+
else if (current && field.startsWith("branch "))
|
|
50
|
+
current.branch = field.slice("branch ".length).replace(/^refs\/heads\//, "");
|
|
51
|
+
}
|
|
52
|
+
return worktrees;
|
|
53
|
+
}
|
|
54
|
+
// Puts the worktree back to a commit, throwing away every change and new file since, ignored files kept.
|
|
55
|
+
export async function reset_worktree(path, commit) {
|
|
56
|
+
await git(["reset", "--hard", commit], path);
|
|
57
|
+
await git(["clean", "-fd"], path);
|
|
58
|
+
}
|
|
59
|
+
// Removes a worktree, even with changes in it when `force`, and its branch too when `delete_branch` and it is merged or forced.
|
|
60
|
+
export async function remove_worktree(repository, path, options = {}) {
|
|
61
|
+
await git(["worktree", "remove", ...(options.force ? ["--force"] : []), path], repository);
|
|
62
|
+
if (options.delete_branch)
|
|
63
|
+
await git(["branch", options.force ? "-D" : "-d", options.delete_branch], repository);
|
|
64
|
+
}
|
|
65
|
+
// ── Reading changes ──────────────────────────────────────────────────────────
|
|
66
|
+
const status_letters = { A: "added", D: "removed", R: "renamed", C: "added", M: "changed", T: "changed" };
|
|
67
|
+
// `git diff --raw --no-abbrev -z` output read into changes; a rename or copy names its old path first.
|
|
68
|
+
export function read_raw_changes(text) {
|
|
69
|
+
const parts = text.split("\0");
|
|
70
|
+
const changes = [];
|
|
71
|
+
for (let index = 0; index < parts.length - 1;) {
|
|
72
|
+
const fields = parts[index].replace(/^:/, "").split(" ");
|
|
73
|
+
const letter = fields[4]?.[0] ?? "M";
|
|
74
|
+
const blob = fields[3] ?? "";
|
|
75
|
+
if (letter === "R" || letter === "C") {
|
|
76
|
+
changes.push({ old_path: parts[index + 1], path: parts[index + 2], status: status_letters[letter], blob });
|
|
77
|
+
index += 3;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
changes.push({ old_path: parts[index + 1], path: parts[index + 1], status: status_letters[letter] ?? "changed", blob });
|
|
81
|
+
index += 2;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return changes;
|
|
85
|
+
}
|
|
86
|
+
// `git diff --numstat -z` output as each path's added and removed lines, null for a binary file.
|
|
87
|
+
export function read_numstat(text) {
|
|
88
|
+
const parts = text.split("\0");
|
|
89
|
+
const counts = new Map();
|
|
90
|
+
for (let index = 0; index < parts.length - 1;) {
|
|
91
|
+
const [added, removed, path] = parts[index].split("\t");
|
|
92
|
+
const value = added === "-" ? null : { additions: Number(added) || 0, deletions: Number(removed) || 0 };
|
|
93
|
+
// A rename leaves the path empty and names the old and new paths after it.
|
|
94
|
+
if (path === "") {
|
|
95
|
+
counts.set(parts[index + 2], value);
|
|
96
|
+
index += 3;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
counts.set(path, value);
|
|
100
|
+
index += 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return counts;
|
|
104
|
+
}
|
|
105
|
+
// The lines plain `git diff --numstat` output counts as added and removed, binary files left out.
|
|
106
|
+
export function sum_numstat(text) {
|
|
107
|
+
let additions = 0;
|
|
108
|
+
let deletions = 0;
|
|
109
|
+
for (const line of text.split("\n")) {
|
|
110
|
+
const [added, removed] = line.split("\t");
|
|
111
|
+
if (!added || added === "-")
|
|
112
|
+
continue;
|
|
113
|
+
additions += Number(added) || 0;
|
|
114
|
+
deletions += Number(removed) || 0;
|
|
115
|
+
}
|
|
116
|
+
return { additions, deletions };
|
|
117
|
+
}
|
|
118
|
+
// Files git does not track yet and does not ignore, which a diff against a commit leaves out.
|
|
119
|
+
export async function untracked_files(worktree) {
|
|
120
|
+
return (await git(["ls-files", "--others", "--exclude-standard", "-z"], worktree)).split("\0").filter(Boolean);
|
|
121
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface GitHubAccount {
|
|
2
|
+
signed_in: boolean;
|
|
3
|
+
account: string;
|
|
4
|
+
problem: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GitHubSignIn {
|
|
7
|
+
code: string;
|
|
8
|
+
url: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IssueRequest {
|
|
11
|
+
repository: string;
|
|
12
|
+
title: string;
|
|
13
|
+
body: string;
|
|
14
|
+
}
|
|
15
|
+
export interface IssueLink {
|
|
16
|
+
number: number;
|
|
17
|
+
opened: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface IssueState {
|
|
20
|
+
open: boolean;
|
|
21
|
+
labels: string[];
|
|
22
|
+
body: string;
|
|
23
|
+
}
|
|
24
|
+
export interface IssueEdit {
|
|
25
|
+
add_labels?: string[];
|
|
26
|
+
remove_labels?: string[];
|
|
27
|
+
body?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface LabelStyle {
|
|
30
|
+
search?: string;
|
|
31
|
+
colour?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
export type PullRequestState = "open" | "closed" | "merged";
|
|
35
|
+
export interface PullRequestFound {
|
|
36
|
+
number: number;
|
|
37
|
+
url: string;
|
|
38
|
+
state: PullRequestState;
|
|
39
|
+
draft: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare const check_buckets: readonly ["pass", "fail", "pending", "skipping", "cancel"];
|
|
42
|
+
export type CheckBucket = (typeof check_buckets)[number];
|
|
43
|
+
export interface PullRequestCheck {
|
|
44
|
+
name: string;
|
|
45
|
+
workflow: string;
|
|
46
|
+
bucket: CheckBucket;
|
|
47
|
+
link: string;
|
|
48
|
+
}
|
|
49
|
+
export interface HookConfig {
|
|
50
|
+
url: string;
|
|
51
|
+
secret: string;
|
|
52
|
+
events: readonly string[];
|
|
53
|
+
}
|
|
54
|
+
export interface GitHubCli {
|
|
55
|
+
account: () => Promise<GitHubAccount>;
|
|
56
|
+
start_sign_in: (on_done: (signed_in: boolean) => void) => Promise<GitHubSignIn>;
|
|
57
|
+
sign_out: (account: string) => Promise<void>;
|
|
58
|
+
find_or_open_issue: (request: IssueRequest) => Promise<IssueLink>;
|
|
59
|
+
view_issue: (repository: string, number: number) => Promise<IssueState>;
|
|
60
|
+
ensure_labels: (repository: string, names: string[], style?: LabelStyle) => Promise<void>;
|
|
61
|
+
edit_issue: (repository: string, number: number, edit: IssueEdit) => Promise<void>;
|
|
62
|
+
post_comment: (repository: string, number: number, body: string) => Promise<number>;
|
|
63
|
+
update_comment: (repository: string, id: number, body: string) => Promise<boolean>;
|
|
64
|
+
close_issue: (repository: string, number: number) => Promise<void>;
|
|
65
|
+
find_pull_request: (repository: string, branch: string) => Promise<PullRequestFound | null>;
|
|
66
|
+
view_pull_request: (repository: string, number: number) => Promise<PullRequestFound>;
|
|
67
|
+
read_checks: (repository: string, number: number) => Promise<PullRequestCheck[]>;
|
|
68
|
+
register_hook: (repository: string, hook: HookConfig) => Promise<"added" | "updated">;
|
|
69
|
+
}
|
|
70
|
+
export interface GitHubCliOptions {
|
|
71
|
+
program?: string;
|
|
72
|
+
host?: string;
|
|
73
|
+
code_wait_in_milliseconds?: number;
|
|
74
|
+
}
|
|
75
|
+
export declare function title_likeness(first: string, second: string): number;
|
|
76
|
+
export declare const same_issue_likeness = 0.6;
|
|
77
|
+
export declare function best_title_match(title: string, issues: {
|
|
78
|
+
number: number;
|
|
79
|
+
title: string;
|
|
80
|
+
}[], least?: number): number | null;
|
|
81
|
+
export declare function github_cli({ program, host, code_wait_in_milliseconds }?: GitHubCliOptions): GitHubCli;
|