herdr-dashr 0.1.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/LICENSE +202 -0
- package/README.md +177 -0
- package/bin.js +99 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Roland Czinege
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# herdr-dashr
|
|
2
|
+
|
|
3
|
+
A [Herdr](https://github.com/herdrdev/herdr) plugin that opens an
|
|
4
|
+
**agent-built, live Grafana dashboard inside a Herdr pane**, with a coding
|
|
5
|
+
agent underneath to reshape it.
|
|
6
|
+
|
|
7
|
+
- **Real Grafana, in the terminal.** The top pane shows Grafana in kiosk mode
|
|
8
|
+
through [terminal-browser](https://github.com/zenbu-labs/terminal-browser);
|
|
9
|
+
without it, a text status view.
|
|
10
|
+
- **No model in the data path.** Grafana refreshes the data. The agent only
|
|
11
|
+
changes the dashboard, through an MCP server.
|
|
12
|
+
- **Privacy by construction.** The agent designs from schemas and masked
|
|
13
|
+
samples (`<email#1>`, `<ipv4#2>`); only you see real values.
|
|
14
|
+
- **Disposable.** A pane-owned Grafana container with a read-only root and
|
|
15
|
+
tmpfs storage on a loopback port, removed when the pane closes.
|
|
16
|
+
- **CodePipeline bootstrap.** Ctrl-click a CodePipeline URL: the plugin finds
|
|
17
|
+
the stacks it deployed and builds a first dashboard of their log groups,
|
|
18
|
+
queues and DLQs, state machines and Lambdas before the agent says a word.
|
|
19
|
+
- **Saved dashboards.** Name a dashboard you like and reopen it in any later
|
|
20
|
+
pane.
|
|
21
|
+
- **OpenTelemetry and live log checks.** One pane-owned container can also
|
|
22
|
+
receive OTLP logs, traces and metrics. Tell the agent which log messages
|
|
23
|
+
should fire (and which must not): the dashboard shows a tile per message
|
|
24
|
+
that turns green when it is logged, and a live log trail with the matches
|
|
25
|
+
highlighted.
|
|
26
|
+
|
|
27
|
+
`docs/PRD.md` is the authoritative specification and delivery ledger.
|
|
28
|
+
|
|
29
|
+
**Status:** v0.1.0, the first public release. All but one PRD requirement verified (the first npm publish comes with this release), most by an end-to-end
|
|
30
|
+
suite that runs a real Herdr, a real Grafana and terminal-browser in CI.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
herdr plugin install czinegeroland/herdr-dashr
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The build step installs the prebuilt `dashr` binary for your platform — from
|
|
39
|
+
npm (`herdr-dashr`), whose platform packages were verified against the
|
|
40
|
+
release's SHA-256 before they were packed; failing that from the GitHub
|
|
41
|
+
release, verified the same way; and only as a last resort with `cargo`. No
|
|
42
|
+
Rust toolchain is needed. `DASHR_INSTALL_SOURCE=npm|github|source` forces one. You need
|
|
43
|
+
Docker. terminal-browser (for the real Grafana UI; it refuses to run as root), Claude Code (the chat
|
|
44
|
+
pane) and the AWS CLI (CodePipeline, CloudWatch) are optional — run the
|
|
45
|
+
**Check dashr prerequisites** action to see what is missing.
|
|
46
|
+
|
|
47
|
+
### The CLI on its own
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx herdr-dashr@latest --version
|
|
51
|
+
npm install -g herdr-dashr # installs the `dashr` command
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
One npm package per platform carries the executable; npm installs only the
|
|
55
|
+
one that runs on your machine, with no postinstall script and no download
|
|
56
|
+
from GitHub.
|
|
57
|
+
|
|
58
|
+
## Use
|
|
59
|
+
|
|
60
|
+
| Action | What it does |
|
|
61
|
+
|---|---|
|
|
62
|
+
| **Open live dashboard** | New tab: Grafana on top, the agent underneath. |
|
|
63
|
+
| **Open dashboard for a CodePipeline** | Ctrl-click a CodePipeline console URL. |
|
|
64
|
+
| **Open live logs and traces (OpenTelemetry)** | Same tab, with an OTLP endpoint and a live log trail. |
|
|
65
|
+
| **Promote dashboard to persistent Grafana** | Copies the focused session's dashboard (needs `[promote]`). |
|
|
66
|
+
| **Check dashr prerequisites** | Doctor popup. |
|
|
67
|
+
|
|
68
|
+
Close the dashboard pane to stop Grafana; the container, runtime files and
|
|
69
|
+
browser profile are deleted. The sidebar token `$dashr` shows panel health
|
|
70
|
+
(`6 ok · 1 err · 1 alert`).
|
|
71
|
+
|
|
72
|
+
### Saved dashboards
|
|
73
|
+
|
|
74
|
+
Like a dashboard? Tell the agent *"save this as checkout debug"*. It is kept
|
|
75
|
+
on this machine (panels, queries and layout — never data). In any later pane,
|
|
76
|
+
*"load checkout debug"* brings it back; the agent is told which dashboards are
|
|
77
|
+
saved when it starts. From the command line:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
dashr dashboards save "checkout debug" # from the running session
|
|
81
|
+
dashr dashboards list
|
|
82
|
+
dashr dashboards load "checkout debug" # into the running session
|
|
83
|
+
dashr session start --load "checkout debug" # a new session showing it
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
A dashboard that uses a datasource the session lacks (say, the pipeline's
|
|
87
|
+
CloudWatch in an OpenTelemetry pane) is refused, naming what is missing.
|
|
88
|
+
|
|
89
|
+
### Live logs and log checks
|
|
90
|
+
|
|
91
|
+
The OpenTelemetry action (or `[otel] enabled = true`) runs
|
|
92
|
+
`grafana/otel-lgtm` instead of plain Grafana: still one container per pane,
|
|
93
|
+
with Loki, Tempo and Prometheus behind an OTLP endpoint on loopback. What you
|
|
94
|
+
send is queryable within about five seconds (traces in about two). Programs
|
|
95
|
+
started from the chat pane find it in `OTEL_EXPORTER_OTLP_ENDPOINT`; anything
|
|
96
|
+
else can be wrapped:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
dashr tail -- cargo run --bin checkout # output still on your terminal, exit code kept
|
|
100
|
+
./app 2>&1 | dashr tail --service app
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Then ask the agent: *"check that `order 42 created` and `payment captured` are
|
|
104
|
+
logged and no exception is"*. It arms them (`expect_logs`), the dashboard gains
|
|
105
|
+
a tile per message and a highlighted live trail, the pane notifies you as each
|
|
106
|
+
arrives and turns blocked on a forbidden one, and the agent reads back a
|
|
107
|
+
counts-only verdict. Without the agent:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
dashr expect -p 'order created = order \d+ created' -p 'payment captured' -a 'exception'
|
|
111
|
+
dashr expect --check # exit status 0 when every expectation holds
|
|
112
|
+
dashr expect --clear
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The agent gets these MCP tools: `list_datasources`, `probe_query`,
|
|
116
|
+
`apply_dashboard`, `panel_status`, `panel_data_sample`, `get_dashboard`,
|
|
117
|
+
`watch_panel`, `list_watches`, `remove_watch`, `screenshot` (non-personal
|
|
118
|
+
dashboards only), `open_for_pipeline`, `promote`.
|
|
119
|
+
|
|
120
|
+
## The agent skill
|
|
121
|
+
|
|
122
|
+
The plugin installs a **herdr-dashr skill** for Claude Code
|
|
123
|
+
(`~/.claude/skills/herdr-dashr/`) that teaches the agent to build dashboards
|
|
124
|
+
dynamically: turn the human's question into panels, probe the data, apply,
|
|
125
|
+
verify with `panel_status`, and keep evolving the dashboard as the
|
|
126
|
+
conversation goes. It carries dashboard-JSON rules, query models for every
|
|
127
|
+
supported datasource (Prometheus, Loki, Tempo, CloudWatch, SQL Server, Azure
|
|
128
|
+
Monitor, Zabbix, Seq, TestData) and debugging recipes (deploys, queue
|
|
129
|
+
backlogs, Step Functions failures, error spikes, latency).
|
|
130
|
+
|
|
131
|
+
- Installed by the plugin's build step, refreshed by the dashboard pane when
|
|
132
|
+
the binary is newer. A skill of the same name that you wrote is never
|
|
133
|
+
replaced (`--force` to override).
|
|
134
|
+
- Also served as MCP resources (`dashr://guide/...`), so any MCP agent gets it.
|
|
135
|
+
- `dashr skill files`, `dashr skill print reference/recipes.md`,
|
|
136
|
+
`dashr skill install --dir <skills-dir>`, `dashr skill uninstall`.
|
|
137
|
+
- Configure with `agent.install_skill` and `agent.skill_dirs` in `dashr.toml`.
|
|
138
|
+
|
|
139
|
+
## Configure
|
|
140
|
+
|
|
141
|
+
`dashr config example` prints a commented `dashr.toml`; put it in the
|
|
142
|
+
directory `herdr plugin config-dir herdr-dashr` prints. Datasources:
|
|
143
|
+
Prometheus, Loki, Tempo, CloudWatch, SQL Server, Azure Monitor, Zabbix and Seq
|
|
144
|
+
(the last two need `dashr image build`). Secrets are named by environment
|
|
145
|
+
variable, never written into the file. Every datasource is personal unless
|
|
146
|
+
you say `personal = false`.
|
|
147
|
+
|
|
148
|
+
## Privacy
|
|
149
|
+
|
|
150
|
+
- Every value an MCP tool returns passes through the masker: personal
|
|
151
|
+
field names are redacted; emails, IBANs, cards, IPs, phones, JWTs, AWS keys
|
|
152
|
+
and credentials inside other fields are replaced with stable pseudonyms.
|
|
153
|
+
- `panel_status` reports rows and errors, never values. Watches are evaluated
|
|
154
|
+
by the pane; the agent never sees what it alerts on.
|
|
155
|
+
- Grafana runs with a read-only root, tmpfs storage, no logs, no swap and no
|
|
156
|
+
capabilities, on loopback only. The browser profile lives in memory. In
|
|
157
|
+
OpenTelemetry mode, logs, traces and metrics are kept on disk in anonymous
|
|
158
|
+
Docker volumes that are deleted with the container.
|
|
159
|
+
|
|
160
|
+
## Develop
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
cargo test --workspace
|
|
164
|
+
cargo build && mkdir -p bin && cp target/debug/dashr bin/ && herdr plugin link "$PWD"
|
|
165
|
+
scripts/e2e/run.sh # real Herdr + real Grafana; needs Docker
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Releases: dispatch the **Release** workflow from `main`; it builds the four
|
|
169
|
+
platform archives with checksums and creates the `v<version>` tag. **Publish to
|
|
170
|
+
npm** then runs automatically: it verifies every archive, builds the packages
|
|
171
|
+
(`scripts/build-npm-packages.mjs`) and publishes them. It needs an
|
|
172
|
+
`NPM_TOKEN` repository secret (an npm automation token); it can be re-run for
|
|
173
|
+
any tag with a dry-run option.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
Apache-2.0
|
package/bin.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Resolves the prebuilt `dashr` for this platform and runs it.
|
|
3
|
+
//
|
|
4
|
+
// Ported from herdr-remote-channel's shim. The binary is not downloaded at
|
|
5
|
+
// install time: each platform's executable is published inside its own npm
|
|
6
|
+
// package, this package depends on all of them through
|
|
7
|
+
// `optionalDependencies` with `os` and `cpu` constraints, and npm installs
|
|
8
|
+
// exactly the one that can run here. npm serves the bytes under its own
|
|
9
|
+
// integrity hash, and `scripts/build-npm-packages.mjs` checked each
|
|
10
|
+
// executable against its published SHA-256 before packing it.
|
|
11
|
+
|
|
12
|
+
import { spawn } from 'node:child_process'
|
|
13
|
+
import { existsSync } from 'node:fs'
|
|
14
|
+
import { createRequire } from 'node:module'
|
|
15
|
+
import { fileURLToPath } from 'node:url'
|
|
16
|
+
import { dirname, join, sep } from 'node:path'
|
|
17
|
+
|
|
18
|
+
const require = createRequire(import.meta.url)
|
|
19
|
+
const binary = 'dashr'
|
|
20
|
+
|
|
21
|
+
// Keep in step with `scripts/build-npm-packages.mjs`, `scripts/install.sh`
|
|
22
|
+
// and the release matrix; `crates/dashr-cli/tests/distribution.rs` holds them
|
|
23
|
+
// together.
|
|
24
|
+
const PACKAGES = {
|
|
25
|
+
'linux x64': 'linux-x64',
|
|
26
|
+
'linux arm64': 'linux-arm64',
|
|
27
|
+
'darwin x64': 'darwin-x64',
|
|
28
|
+
'darwin arm64': 'darwin-arm64',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Run from `npm/dashr` inside a source checkout (a symlinked
|
|
32
|
+
// `node_modules/herdr-dashr`), this file uses the checkout's own build in
|
|
33
|
+
// `bin/`. An npm install never runs from `npm/dashr`: there it is a copy at
|
|
34
|
+
// the package root.
|
|
35
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
36
|
+
|
|
37
|
+
if (here.endsWith(`${sep}npm${sep}dashr`)) {
|
|
38
|
+
const local = join(here, '..', '..', 'bin', binary)
|
|
39
|
+
if (!existsSync(local)) {
|
|
40
|
+
console.error(
|
|
41
|
+
`dashr: this is a source checkout, but ${local} has not been built.\n` +
|
|
42
|
+
`Build it with: cargo build --release --locked --bin dashr && install -m 0755 target/release/dashr bin/dashr`,
|
|
43
|
+
)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
run(local)
|
|
47
|
+
} else {
|
|
48
|
+
run(published())
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// The prebuilt executable npm installed for this platform.
|
|
52
|
+
function published() {
|
|
53
|
+
const key = `${process.platform} ${process.arch}`
|
|
54
|
+
const suffix = PACKAGES[key]
|
|
55
|
+
if (!suffix) {
|
|
56
|
+
console.error(
|
|
57
|
+
`dashr: no prebuilt binary for ${key}.\n` +
|
|
58
|
+
`Supported: ${Object.keys(PACKAGES).join(', ')}.\n` +
|
|
59
|
+
`Build from source instead: cargo install --git https://github.com/czinegeroland/herdr-dashr dashr-cli`,
|
|
60
|
+
)
|
|
61
|
+
process.exit(1)
|
|
62
|
+
}
|
|
63
|
+
const pkg = `herdr-dashr-${suffix}`
|
|
64
|
+
try {
|
|
65
|
+
return require.resolve(`${pkg}/${binary}`)
|
|
66
|
+
} catch {
|
|
67
|
+
console.error(
|
|
68
|
+
`dashr: ${pkg} is not installed, so there is no binary for ${key}.\n` +
|
|
69
|
+
`If you installed with --no-optional, reinstall without it.`,
|
|
70
|
+
)
|
|
71
|
+
process.exit(1)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Runs the executable in the foreground and exits the way it did.
|
|
76
|
+
function run(resolved) {
|
|
77
|
+
// Asynchronous, so this process stays responsive to signals and forwards
|
|
78
|
+
// them: the dashboard pane stops its Grafana on SIGHUP, and a shim that
|
|
79
|
+
// swallowed it would leave the container running.
|
|
80
|
+
const child = spawn(resolved, process.argv.slice(2), { stdio: 'inherit' })
|
|
81
|
+
|
|
82
|
+
child.on('error', (error) => {
|
|
83
|
+
console.error(`dashr: could not run ${resolved}: ${error.message}`)
|
|
84
|
+
process.exit(1)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP']) {
|
|
88
|
+
process.on(signal, () => {
|
|
89
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
90
|
+
child.kill(signal)
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
child.on('exit', (status, signal) => {
|
|
96
|
+
const codes = { SIGHUP: 1, SIGINT: 2, SIGTERM: 15 }
|
|
97
|
+
process.exit(status === null ? 128 + (codes[signal] ?? 15) : status)
|
|
98
|
+
})
|
|
99
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "herdr-dashr",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agent-built, live Grafana dashboards in a Herdr pane, with masking between your data and the agent.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/czinegeroland/herdr-dashr.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/czinegeroland/herdr-dashr",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"herdr",
|
|
13
|
+
"herdr-plugin",
|
|
14
|
+
"grafana",
|
|
15
|
+
"dashboard",
|
|
16
|
+
"mcp",
|
|
17
|
+
"observability"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"bin": {
|
|
21
|
+
"dashr": "bin.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin.js",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"herdr-dashr-linux-x64": "0.1.0",
|
|
30
|
+
"herdr-dashr-linux-arm64": "0.1.0",
|
|
31
|
+
"herdr-dashr-darwin-x64": "0.1.0",
|
|
32
|
+
"herdr-dashr-darwin-arm64": "0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
}
|
|
37
|
+
}
|