dark apps — a daemon / foreground / ui launch model#5669
Draft
StachuDotNet wants to merge 1 commit into
Draft
Conversation
`dark apps` is one surface over a registry of Apps. An App is a thin package VALUE
declaring how it launches:
daemon a backgrounded long-runner, pidfile-tracked — start/stop/status/logs
foreground a normal `dark run <entrypoint>` that finishes
ui a full-screen TUI that runs attached
$ dark apps
Apps:
heartbeat [daemon] A demo daemon: log a heartbeat every interval (stopped)
outliner [ui] Interactive tree outliner (full-screen TUI)
review [ui] Review branch changesets
views [ui] Browse and preview CLI views
ui-demo [foreground] Render the UI component gallery (a visual check)
$ dark apps start heartbeat # detached, survives CLI exit
$ dark apps status # heartbeat: running (pid 48213)
$ dark apps stop heartbeat
## Generic CLI daemon management — `Darklang.Cli.Daemons`
The daemon lifecycle is a standalone, app-agnostic module: a daemon is a DETACHED `dark`
process tracked by a pidfile (`~/.darklang/run/<name>.pid`), with a signal-0 liveness check,
SIGTERM stop, and tailable logs. Built on the POSIX stdlib. It manages ANY named daemon — the
caller supplies the entrypoint — so `dark apps` is just one client (the heartbeat app proves it).
## Install (preview)
`apps install <name>` plans the PATH shim (`~/.darklang/bin/<name>` -> `dark run <entrypoint>`).
The write step needs a live env. (Capability-scoped install — restricting what an installed app
may spawn — waits for the capability model and is not part of this PR.)
## Tests
`testfiles/execution/cli/apps.dark`: the kind tags + the install-string builders. The daemon
lifecycle (detached process, pidfile, SIGTERM) is exercised live via `dark apps start/stop`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The one surface that lists, installs, and runs Apps — covering both background daemons and interactive UI apps, so the same
dark appsmanages the sync daemon, a print-md run, and the outliner TUI alike. An App is a package VALUE, so the manifest syncs like any other value.The thin manifest + the three kinds
start/stop/status/logsmanage it via a pidfile (sync daemon, heartbeat). Detached, survives CLI exit.dark runthat finishes (print-md).Install surface
apps installwrites a one-line shell shim (~/.darklang/bin/<app>→dark run <entrypoint>) and grants the app'sspawnAllowListasCli(spawn: …). One dir on PATH, so uninstall is one file.Tests
testfiles/execution/pre-s-and-s/apps.dark— 6/6:kindTag(×3),aliasPath,spawnGrantSummary(empty / non-empty). (findByNamereads theallpackage-VALUE registry, which the.darktest harness can't resolve, so it's exercised viadark apps listat the CLI.) Build + reload clean.Deferred
Type-discovery of Apps via the synced value index (this PR lists a static
all);dark apps fork(later). Files:apps.dark,apps-daemon.dark,apps-examples.dark,…/cli/commands/apps.dark,core.dark, the testfile.