@sealant/mend 0.1.1 → 0.3.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 +17 -6
- package/dist/dashboard.js +30 -5
- package/dist/dotfiles.js +90 -0
- package/dist/env.js +17 -0
- package/dist/main.js +978 -12
- package/dist/service-init.js +227 -0
- package/dist/shared.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,14 +31,25 @@ mend sessions [--all] [--project p] [--json]
|
|
|
31
31
|
mend status active sessions (alias of mend sessions)
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
## Signing in
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
mend login # asks for the email + password of your Mend account, saves a token
|
|
38
|
+
mend login --url https://mend.example.com --email you@example.com
|
|
39
|
+
mend logout
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The token is stored 0600 in the CLI config below; every command uses it until `mend logout`. On a
|
|
43
|
+
dev instance with `MEND_STATIC_TOKEN` set, `MEND_TOKEN=<that value>` also works.
|
|
44
|
+
|
|
34
45
|
## Configuration
|
|
35
46
|
|
|
36
|
-
| Source
|
|
37
|
-
|
|
|
38
|
-
| `MEND_URL`
|
|
39
|
-
| `MEND_TOKEN`
|
|
40
|
-
| `MEND_DETACH_KEY`
|
|
41
|
-
| `~/.mend/cli.json` | `{ "url": ..., "token": ... }` — env vars win
|
|
47
|
+
| Source | What |
|
|
48
|
+
| ------------------------- | ----------------------------------------------------------------------------------------- |
|
|
49
|
+
| `MEND_URL` | The Mend server (default `http://localhost:3105`) |
|
|
50
|
+
| `MEND_TOKEN` | Bearer token for that server (normally written by `mend login`) |
|
|
51
|
+
| `MEND_DETACH_KEY` | Set to `none` when an outer multiplexer detaches |
|
|
52
|
+
| `~/.config/mend/cli.json` | `{ "url": ..., "token": ... }` — env vars win; a pre-XDG `~/.mend/cli.json` keeps working |
|
|
42
53
|
|
|
43
54
|
## Herdr
|
|
44
55
|
|
package/dist/dashboard.js
CHANGED
|
@@ -43,8 +43,21 @@ const timeAgo = (iso) => {
|
|
|
43
43
|
const WORKBENCH_KEY = ["workbench"];
|
|
44
44
|
const fetchWorkbench = async (ctx) => {
|
|
45
45
|
const projects = await ctx.api("GET", "/projects");
|
|
46
|
-
const fetched = await Promise.all(
|
|
47
|
-
|
|
46
|
+
const [fetched, services] = await Promise.all([
|
|
47
|
+
Promise.all(projects.map((project) => ctx.api("GET", `/projects/${project.id}`))),
|
|
48
|
+
ctx.api("GET", "/services"),
|
|
49
|
+
]);
|
|
50
|
+
const servicesBySession = new Map();
|
|
51
|
+
for (const service of services) {
|
|
52
|
+
const bucket = servicesBySession.get(service.sessionId) ?? [];
|
|
53
|
+
bucket.push(service);
|
|
54
|
+
servicesBySession.set(service.sessionId, bucket);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
projects,
|
|
58
|
+
details: new Map(fetched.map((detail) => [detail.project.id, detail])),
|
|
59
|
+
servicesBySession,
|
|
60
|
+
};
|
|
48
61
|
};
|
|
49
62
|
const itemKey = (item) => item.kind === "session"
|
|
50
63
|
? item.session.id
|
|
@@ -84,6 +97,7 @@ const deriveItems = (view, data) => {
|
|
|
84
97
|
kind: "session",
|
|
85
98
|
session,
|
|
86
99
|
annotation: detail.annotations.find((a) => a.sessionId === session.id),
|
|
100
|
+
services: data.servicesBySession.get(session.id) ?? [],
|
|
87
101
|
}));
|
|
88
102
|
}
|
|
89
103
|
const resuming = view.session;
|
|
@@ -100,7 +114,9 @@ const deriveItems = (view, data) => {
|
|
|
100
114
|
kind: "harness",
|
|
101
115
|
harness,
|
|
102
116
|
label: harness,
|
|
103
|
-
hint:
|
|
117
|
+
hint: harness === "shell"
|
|
118
|
+
? "a bash in the worktree — resume either agent from inside"
|
|
119
|
+
: "the conversation crosses as a distilled prompt",
|
|
104
120
|
})),
|
|
105
121
|
];
|
|
106
122
|
}
|
|
@@ -108,7 +124,9 @@ const deriveItems = (view, data) => {
|
|
|
108
124
|
kind: "harness",
|
|
109
125
|
harness,
|
|
110
126
|
label: harness,
|
|
111
|
-
hint:
|
|
127
|
+
hint: harness === "shell"
|
|
128
|
+
? "a plain bash session — new worktree, recorded"
|
|
129
|
+
: `mend ${harness} — new worktree, recorded session`,
|
|
112
130
|
}));
|
|
113
131
|
};
|
|
114
132
|
// ─── rows: JSX spans instead of StyledText chunks ───────────────────────────
|
|
@@ -122,13 +140,20 @@ const Facts = ({ facts }) => {
|
|
|
122
140
|
_jsxs("span", { children: [index > 0 ? _jsx("span", { fg: FAINT, children: " \u00B7 " }) : null, fact] }, index))) }));
|
|
123
141
|
};
|
|
124
142
|
const SessionRow = ({ item, selected, }) => {
|
|
125
|
-
const { session, annotation } = item;
|
|
143
|
+
const { session, annotation, services } = item;
|
|
126
144
|
const color = STATUS_COLOR[session.status] ?? MUTED;
|
|
127
145
|
const glyph = STATUS_GLYPH[session.status] ?? "·";
|
|
128
146
|
const facts = [];
|
|
129
147
|
const age = timeAgo(session.createdAt);
|
|
130
148
|
if (age !== "")
|
|
131
149
|
facts.push(_jsx("span", { fg: FAINT, children: age }));
|
|
150
|
+
// What runs right now: name :port → host port, observed state colored.
|
|
151
|
+
for (const service of services.slice(0, 2)) {
|
|
152
|
+
facts.push(_jsx("span", { fg: service.status === "reachable" ? GREEN : AMBER, children: `${service.label ?? service.id.slice(0, 6)} :${service.workspacePort ?? "?"}${service.protocol === "udp" ? "u" : ""}→${service.hostPort ?? "?"} ${service.status}` }));
|
|
153
|
+
}
|
|
154
|
+
if (services.length > 2) {
|
|
155
|
+
facts.push(_jsx("span", { fg: FAINT, children: `+${services.length - 2} services` }));
|
|
156
|
+
}
|
|
132
157
|
if (session.label !== null)
|
|
133
158
|
facts.push(_jsx("span", { fg: MUTED, children: session.label }));
|
|
134
159
|
if (annotation !== undefined && annotation.openComments > 0) {
|
package/dist/dotfiles.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Local dotfiles scanning for `mend dotfiles sync`. This runs on the machine that HAS the
|
|
5
|
+
* files — the whole point: the Mend server may be a VPS whose home directory is a service
|
|
6
|
+
* account's, so contents are captured here and streamed to the server's per-user dotfiles store.
|
|
7
|
+
*
|
|
8
|
+
* The candidate list mirrors the product's curated set (plain configuration only — never keys,
|
|
9
|
+
* credential stores, or histories). The CLI stays dependency-light by design, so the list is
|
|
10
|
+
* duplicated here rather than imported from a workspace package.
|
|
11
|
+
*/
|
|
12
|
+
export const DOTFILE_CANDIDATES = [
|
|
13
|
+
{
|
|
14
|
+
group: "shell",
|
|
15
|
+
paths: [
|
|
16
|
+
".zshrc",
|
|
17
|
+
".zshenv",
|
|
18
|
+
".zprofile",
|
|
19
|
+
".bashrc",
|
|
20
|
+
".bash_profile",
|
|
21
|
+
".profile",
|
|
22
|
+
".aliases",
|
|
23
|
+
".config/fish/config.fish",
|
|
24
|
+
".config/starship.toml",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
group: "git",
|
|
29
|
+
paths: [".gitconfig", ".gitignore_global", ".config/git/config", ".config/git/ignore"],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
group: "editors",
|
|
33
|
+
paths: [".vimrc", ".ideavimrc", ".editorconfig", ".config/helix/config.toml"],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
group: "terminal",
|
|
37
|
+
paths: [".tmux.conf", ".config/tmux/tmux.conf", ".inputrc", ".dir_colors"],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
group: "tools",
|
|
41
|
+
paths: [
|
|
42
|
+
".ripgreprc",
|
|
43
|
+
".config/bat/config",
|
|
44
|
+
".config/lazygit/config.yml",
|
|
45
|
+
".config/mise/config.toml",
|
|
46
|
+
".config/atuin/config.toml",
|
|
47
|
+
".config/zellij/config.kdl",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
/** The per-file cap the server enforces; checked here so a mistake fails before the upload. */
|
|
52
|
+
export const MAX_FILE_BYTES = 1024 * 1024;
|
|
53
|
+
const statFile = (home, relative) => {
|
|
54
|
+
try {
|
|
55
|
+
const stat = fs.statSync(path.join(home, relative));
|
|
56
|
+
return stat.isFile() ? stat : null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/** Probe the curated candidates under `home`; only existing regular files appear. */
|
|
63
|
+
export const scanDotfileCandidates = (home) => DOTFILE_CANDIDATES.flatMap(({ group, paths }) => paths.flatMap((relative) => {
|
|
64
|
+
const stat = statFile(home, relative);
|
|
65
|
+
return stat === null ? [] : [{ path: relative, group, bytes: stat.size }];
|
|
66
|
+
}));
|
|
67
|
+
/**
|
|
68
|
+
* Read the selected paths for upload. Explicitly requested paths must exist (a typo should fail,
|
|
69
|
+
* not silently sync nothing); oversized files fail with the server's own rule. Modes ride along
|
|
70
|
+
* so an executable script stays executable.
|
|
71
|
+
*/
|
|
72
|
+
export const readSyncFiles = (home, paths_) => {
|
|
73
|
+
const files = [];
|
|
74
|
+
for (const relative of paths_) {
|
|
75
|
+
const stat = statFile(home, relative);
|
|
76
|
+
if (stat === null) {
|
|
77
|
+
return { error: `${relative} is not a file under ${home}` };
|
|
78
|
+
}
|
|
79
|
+
if (stat.size > MAX_FILE_BYTES) {
|
|
80
|
+
return { error: `${relative} is over 1MB — dotfiles are text; trim the selection` };
|
|
81
|
+
}
|
|
82
|
+
files.push({
|
|
83
|
+
path: relative,
|
|
84
|
+
contentsBase64: fs.readFileSync(path.join(home, relative)).toString("base64"),
|
|
85
|
+
// eslint-disable-next-line no-bitwise -- permission bits are the point
|
|
86
|
+
mode: (stat.mode & 0o777).toString(8),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return { files };
|
|
90
|
+
};
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mend env`: load a dotenv file into the project's env store, and show what is stored. Parsing
|
|
3
|
+
* AND routing happen SERVER-SIDE (one parser for the CLI and the browser); the CLI ships the file
|
|
4
|
+
* text once and prints the per-name report. Values are never printed.
|
|
5
|
+
*/
|
|
6
|
+
/** Render the report as terse status lines — names, lanes, actions, reasons; never a value. */
|
|
7
|
+
export const formatLoadReport = (report, paint) => {
|
|
8
|
+
const width = Math.max(0, ...report.loaded.map((entry) => entry.name.length), ...report.rejected.map((entry) => entry.name.length));
|
|
9
|
+
const lines = [];
|
|
10
|
+
for (const entry of report.loaded) {
|
|
11
|
+
lines.push(` ${entry.name.padEnd(width)} ${entry.lane === "secret" ? "secret" : "configuration"} ${paint.dim(`· ${entry.action}${entry.lane === "configuration" ? " · plaintext" : ""}`)}`);
|
|
12
|
+
}
|
|
13
|
+
for (const entry of report.rejected) {
|
|
14
|
+
lines.push(` ${entry.name.padEnd(width)} ${paint.warn("rejected")} ${paint.dim(`· ${entry.reason}`)}`);
|
|
15
|
+
}
|
|
16
|
+
return lines;
|
|
17
|
+
};
|