Developer-Dashboard
view release on metacpan or search on metacpan
Provide the local browser UI and the `d2` command line entry point over
the same runtime data.
- Skills and extensions
Add isolated commands, pages, configuration, and collectors that can be
layered with the shared and project runtimes.
The implementation modules are under the `Developer::Dashboard::` namespace.
The command guides below describe supported user-facing behaviour; module
references are most useful when embedding or extending the system.
## Environment Variables
The distribution supports these compatibility-style customisation variables:
- `DEVELOPER_DASHBOARD_BOOKMARKS`
Override the saved page root.
- `DEVELOPER_DASHBOARD_CHECKERS`
Filter enabled collector/checker names.
- `DEVELOPER_DASHBOARD_CONFIGS`
Override the config root.
- `DEVELOPER_DASHBOARD_ALLOW_TRANSIENT_URLS`
Allow browser execution of transient `/?token=...`, `/action?atoken=...`,
and older `/ajax?token=...` payloads. The default is off, so the web UI only
executes saved bookmark files unless this is set to a truthy value such as
`1`, `true`, `yes`, or `on`.
## Transient Web Token Policy
Transient page tokens still exist for CLI workflows such as `d2 page encode`
and `d2 page decode`, but browser routes that execute a transient payload
from `token=` or `atoken=` are disabled by default.
That means links such as:
- `http://127.0.0.1:7890/?token=...`
- `http://127.0.0.1:7890/action?atoken=...`
- `http://127.0.0.1:7890/ajax?token=...`
return a `403` unless `DEVELOPER_DASHBOARD_ALLOW_TRANSIENT_URLS` is enabled.
Saved bookmark-file routes such as `/app/index` and
`/app/index/action/...` continue to work without that flag.
Saved bookmark
editor pages also stay on their named `/app/<id>/edit` and
`/app/<id>` routes when you save from the browser, so editing an
existing bookmark file does not fall back to transient `token=` URLs under the
default deny policy.
`Ajax` helper calls inside saved bookmark `CODE*` blocks should use
an explicit `file => 'name.json'` argument. When a saved page supplies that
name, the helper stores the Ajax Perl code under the saved dashboard ajax tree and emits a
stable saved-bookmark endpoint such as
`/ajax/name.json?type=text`.
Skill pages use the same helper contract. Without
extra skill route metadata the generated saved endpoint is namespaced under the
longest matching skill route, for example
`/ajax/example-skill/name.json?type=text` or
`/ajax/example-skill/sub-skill/name.json?type=text`.
The runtime config tree
and installed skills can both ship `config/routes.json` to declare canonical
custom paths for normal saved app pages, skill-local app pages, Ajax handlers,
JavaScript assets, CSS assets, and other public assets. The schema is a JSON
object whose keys are the public custom paths and whose values are either one
smart local route string or an object with `to` plus an optional `type`, for
example
{
"/java" : "/app/learn.ai",
"/v1/status" : {
"to" : "/ajax/status",
"type" : "json"
},
"/hello/world" : "/app/hello/world",
"/main.css" : "/css/hello/world.css",
"/hey.js" : "/js/hey/how/are/you.js",
"/what/are/you" : "/others/hello/world/you.html"
}
When that file is present, skill pages emit the declared canonical
`ajax` path such as `/v1/status` instead of the default `/ajax/...` url,
and runtime-level aliases such as `/java` can point at normal saved bookmark
ids such as `/app/learn.ai` without treating the dot as skill notation. The
same manifest also makes the declared custom `/app`, `/js`, `/css`, and
`/others` paths requestable.
The smart longest-prefix routes remain the
parent resolvers:
`/app/example-skill/...`, `/ajax/example-skill/...`,
`/js/example-skill/...`, `/css/example-skill/...`, and
`/others/example-skill/...` are always checked first, and any declared custom
path is checked only after the normal smart route misses.
Runtime-level custom
paths from the active `config/routes.json` layer chain follow the same
fallback rule against the built-in `/app`, `/ajax`, `/js`, `/css`, and
`/others` route handlers. If neither the smart route nor the custom path
resolves, the request falls through to the normal `404` response.
Ajax custom
routes default to `json` when no explicit `type` is present, and the
optional `type` value can also be `html`,
`text`, or an arbitrary raw mime type such as
`application/vnd.example+json`. Those saved Ajax handlers run the stored file
as a real process, defaulting to Perl unless the file starts with a shebang,
and stream both `stdout` and `stderr` back to the browser as they happen.
That keeps bookmark Ajax workflows usable even while transient token URLs stay
disabled by default, and it means bookmark Ajax code can rely on normal
`print`, `warn`, `die`, `system`, and `exec` process behaviour instead of
a buffered JSON wrapper. The same layered runtime config chain and installed-skill config trees can now
ship `config/api.json` files that authorise selected `/ajax/...` routes for
machine-to-machine callers without forcing a helper login form.
The schema is a
show incremental output in the browser instead of stalling behind process
buffers.
If a saved handler also needs refresh-safe process reuse, pass
`singleton => 'NAME'` in the `Ajax` helper.
The generated URL carries the singleton name, and the worker runs as
`d2 ajax: NAME`. A refreshed request replaces the older matching
worker.
`d2 stop` and `d2 restart` also stop singleton Ajax workers.
Closing a browser tab sends a `pagehide` cleanup request to
`/ajax/singleton/stop?singleton=NAME`.
If `code => ...` is omitted, `Ajax(file => 'name')` targets the
existing executable at `dashboards/ajax/name` instead of rewriting it. Static files referenced by saved bookmarks are resolved from the effective
runtime public tree first and then from the saved bookmark root.
The web layer
also provides a built-in bundled `/js/jquery.js` asset that serves the local
copy of jQuery 4.0.0, with `/js/jquery-4.0.0.min.js` kept as a compatibility
alias for the same shipped payload even when no runtime file has been copied
into `dashboard/public/js` yet.
The bundled browser tab icon works the same
way: browsers request `/favicon.ico` on their own for every page load, so that
route is served outside the authorisation gate, on every trust tier and before
any helper login, from the bundled 16x16 icon. Dropping your own
`dashboard/public/others/favicon.ico` into any runtime layer overrides it.
Skills can ship the same classes of assets
under their own dashboard tree: `dashboards/ajax/*` resolves at
`/ajax/<repo-name>/...` or
`/ajax/<repo-name>/<sub-skill>/...`, and
`dashboards/public/js/*`, `dashboards/public/css/*`, and
`dashboards/public/others/*` resolve at
`/js/<repo-name>/...`, `/css/<repo-name>/...`, and
`/others/<repo-name>/...` with the same nested-skill extension,
for example `/js/<repo-name>/<sub-skill>/path/file.js`.
If a
request such as `/js/<repo-name>/foo/bar.js` or
`/js/<repo-name>/<sub-skill>/foo/bar.js` does not exist in the
skill-local public tree, the web layer falls back to the normal nested
saved-bookmark asset path `dashboards/public/js/...` or saved Ajax file path
`dashboards/ajax/...` instead of assuming the leading path segments must
belong to a skill.
Saved bookmark editor and view-source routes also protect literal inline
script content from breaking the browser bootstrap. If a bookmark body
contains HTML such as `/script`, the editor now escapes the inline JSON
assignment used to reload the source text, so the browser keeps the full
bookmark source inside the editor instead of spilling raw text below the page.
Saved browser workspaces can also show a request-specific token form above the
editor whenever the current request uses `{{token}}` placeholders, carrying
those token values across matching placeholders in the same workflow so later
requests can reuse the operator-supplied values without manual copy-and-paste.
Bookmark rendering now emits saved `set_chain_value()` bindings after
the bookmark body HTML, so pages that declare `var endpoints = {}` and then
call helpers from `$(document).ready(...)` receive their saved `/ajax/...`
endpoint URLs without throwing a play-route JavaScript `ReferenceError`.
Bookmark pages now also expose
`fetch_value(url, target, options, formatter)`,
`stream_value(url, target, options, formatter)`, and
`stream_data(url, target, options, formatter)` helpers so a bookmark can bind
saved Ajax endpoints into DOM targets without hand-writing the fetch and
render boilerplate. `stream_data()` and `stream_value()` now use
`XMLHttpRequest` progress events for browser-visible incremental updates, so
a saved `/ajax/...` endpoint that prints early output updates the DOM before
the request finishes.
Those helpers support plain text, JSON, and HTML output. Saved Ajax bindings
are available after the page declares its endpoint root, so
`$(document).ready(...)` callbacks can call helpers such as
`fetch_value(endpoints.foo, '#foo')` on first render.
For response inspection panels, place the Response Body and Response Headers
tabs below the response `pre` box. This keeps the main response visible while
the details remain accessible.
## User CLI Extensions
Unknown top-level subcommands can be provided by executable files under
the current working directory's `./.developer-dashboard/cli` first, then the
nearest git-backed project runtime `./.developer-dashboard/cli` when it is a
different directory, and then `~/.developer-dashboard/cli`. For example,
`d2 foobar a b` will exec the first matching
`cli/foobar` with `a b` as argv, while preserving stdin, stdout, and
stderr.
A direct custom command can also be stored as an executable
`cli/<command>.pl`, `cli/<command>.py`, `cli/<command>.js`, `cli/<command>.go`,
`cli/<command>.java`, `cli/<command>.sh`,
`cli/<command>.bash`, `cli/<command>.ps1`,
`cli/<command>.cmd`, or `cli/<command>.bat`, and
`d2 <command>` resolves the same logical command name to
those files.
Concrete source-backed examples:
d2 hi
d2 foo
If `cli/hi.go` is executable, `d2 hi` runs it through `go run`.
If `cli/report.py` is executable, `d2 report` runs it through `python`.
If `cli/webhook.js` is executable, `d2 webhook` runs it through `node`.
If `cli/foo.java` is executable, `d2 foo` compiles it with `javac`
into an isolated temp directory and then runs the declared main class with
`java`.
To demonstrate a custom `update` command with a hook, create both files in a
runtime CLI layer and then invoke the switchboard:
mkdir -p ~/.developer-dashboard/cli/update.d
printf '#!/usr/bin/env perl\nprint "custom update\\n";\n' > ~/.developer-dashboard/cli/update
chmod +x ~/.developer-dashboard/cli/update
printf '#!/bin/sh\nprintf "before update\\n"\n' > ~/.developer-dashboard/cli/update.d/01-log
chmod +x ~/.developer-dashboard/cli/update.d/01-log
perl -Ilib bin/d2 update
The command file is user-provided, not a built-in. The hook runs before it;
project-local runtime layers take precedence over the home layer.
If a user mistypes a command, dashboard now prints an explicit unknown-command
error together with the closest matching public command before the usual usage
summary. The same guidance also applies to dotted skill commands, so
`d2 alpha-skill.run-tset` suggests the nearest installed dotted skill
command instead of only dumping generic help.
## Built-in command help and completion
Every dashboard-managed built-in command and its public actions use one help
catalogue. Request help with `--help`, `-h`, or a trailing `help`, for
example `d2 api add --help`, `d2 api add help`, or the global form
( run in 0.732 second using v1.01-cache-2.11-cpan-eb134014566 )