ezhst 0.4.1 → 1.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/dist/commands/members.js +71 -0
- package/dist/commands/projects.js +1 -1
- package/dist/commands/skill.js +18 -5
- package/dist/index.js +17 -3
- package/package.json +1 -1
- package/skill/SKILL.md +4 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
import { json, request } from "../lib/api.js";
|
|
3
|
+
import { resolveProject } from "../lib/project.js";
|
|
4
|
+
import { confirmed, fail, log, output } from "../lib/ui.js";
|
|
5
|
+
const fetchMembers = async (options) => {
|
|
6
|
+
const project = await resolveProject(options);
|
|
7
|
+
const data = await request("/members", {}, project.id);
|
|
8
|
+
return { project, data };
|
|
9
|
+
};
|
|
10
|
+
const inviteToken = (value) => {
|
|
11
|
+
const trimmed = value.trim().replace(/\/+$/, "");
|
|
12
|
+
return trimmed.slice(trimmed.lastIndexOf("/") + 1);
|
|
13
|
+
};
|
|
14
|
+
export const listMembers = async (options) => {
|
|
15
|
+
const { data } = await fetchMembers(options);
|
|
16
|
+
output(data, () => {
|
|
17
|
+
log.info(`${pc.bold(data.owner.name.padEnd(24))} ${data.owner.email.padEnd(32)} ${pc.dim("owner")}`);
|
|
18
|
+
for (const member of data.members) {
|
|
19
|
+
log.info(`${pc.bold(member.name.padEnd(24))} ${member.email.padEnd(32)} ${pc.dim("member")}`);
|
|
20
|
+
}
|
|
21
|
+
for (const invite of data.invites) {
|
|
22
|
+
let status = `invited, expires ${invite.expiresAt}`;
|
|
23
|
+
if (invite.expired) {
|
|
24
|
+
status = "invite expired";
|
|
25
|
+
}
|
|
26
|
+
log.info(`${"".padEnd(24)} ${invite.email.padEnd(32)} ${pc.dim(status)}`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export const inviteMember = async (email, options) => {
|
|
31
|
+
const project = await resolveProject(options);
|
|
32
|
+
const result = await request("/members/invites", json("POST", { email }), project.id);
|
|
33
|
+
output(result, () => {
|
|
34
|
+
log.success(result.message);
|
|
35
|
+
log.info(`Invite link: ${result.url}`);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export const revokeInvite = async (email, options) => {
|
|
39
|
+
const { project, data } = await fetchMembers(options);
|
|
40
|
+
const invite = data.invites.find((item) => item.email === email.trim().toLowerCase());
|
|
41
|
+
if (!invite) {
|
|
42
|
+
return fail(`No pending invite for ${email}.`);
|
|
43
|
+
}
|
|
44
|
+
const result = await request(`/members/invites/${invite.id}`, { method: "DELETE" }, project.id);
|
|
45
|
+
output(result, () => log.success(result.message));
|
|
46
|
+
};
|
|
47
|
+
export const removeMember = async (email, options) => {
|
|
48
|
+
const { project, data } = await fetchMembers(options);
|
|
49
|
+
const member = data.members.find((item) => item.email.toLowerCase() === email.trim().toLowerCase());
|
|
50
|
+
if (!member) {
|
|
51
|
+
return fail(`${email} is not a member of this project.`);
|
|
52
|
+
}
|
|
53
|
+
confirmed(options.yes, `Removing ${member.email} takes away their access to ${project.name}.`);
|
|
54
|
+
const result = await request(`/members/${member.id}`, { method: "DELETE" }, project.id);
|
|
55
|
+
output(result, () => log.success(result.message));
|
|
56
|
+
};
|
|
57
|
+
export const leaveProject = async (options) => {
|
|
58
|
+
const project = await resolveProject(options);
|
|
59
|
+
const { user } = await request("/auth/me");
|
|
60
|
+
confirmed(options.yes, `Leaving ${project.name} removes your access until the owner invites you again.`);
|
|
61
|
+
const result = await request(`/members/${user.id}`, { method: "DELETE" }, project.id);
|
|
62
|
+
output(result, () => log.success(result.message));
|
|
63
|
+
};
|
|
64
|
+
export const acceptInvite = async (tokenOrUrl) => {
|
|
65
|
+
const token = inviteToken(tokenOrUrl);
|
|
66
|
+
const result = await request(`/invites/${token}/accept`, { method: "POST" });
|
|
67
|
+
output(result, () => {
|
|
68
|
+
log.success(result.message);
|
|
69
|
+
log.info(`Use it with \`--project ${result.project.slug}\` or \`ezhst link --project ${result.project.slug}\`.`);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
@@ -10,7 +10,7 @@ export const listProjects = async () => {
|
|
|
10
10
|
log.info("No projects yet. Create one with `ezhst projects create <name>`.");
|
|
11
11
|
}
|
|
12
12
|
for (const project of projects) {
|
|
13
|
-
log.info(`${pc.bold(project.slug.padEnd(40))} ${project.name}`);
|
|
13
|
+
log.info(`${pc.bold(project.slug.padEnd(40))} ${project.name.padEnd(28)} ${pc.dim(project.role ?? "")}`);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
};
|
package/dist/commands/skill.js
CHANGED
|
@@ -5,10 +5,23 @@ import path from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { fail, log, output, required } from "../lib/ui.js";
|
|
7
7
|
const SKILL_SOURCE = fileURLToPath(new URL("../../skill/SKILL.md", import.meta.url));
|
|
8
|
+
const AGENTS = {
|
|
9
|
+
claude: { name: "Claude Code", folder: ".claude" },
|
|
10
|
+
codex: { name: "Codex", folder: ".agents" },
|
|
11
|
+
cursor: { name: "Cursor", folder: ".cursor" },
|
|
12
|
+
};
|
|
8
13
|
export const installSkill = async (options) => {
|
|
14
|
+
if (options.agent !== undefined && !(options.agent in AGENTS)) {
|
|
15
|
+
return fail(`Unknown agent "${options.agent}". Use one of: ${Object.keys(AGENTS).join(", ")}.`);
|
|
16
|
+
}
|
|
9
17
|
if (options.global && options.local) {
|
|
10
18
|
return fail("Choose either --global or --local, not both.");
|
|
11
19
|
}
|
|
20
|
+
const agentKey = await required(options.agent, "--agent <claude|codex|cursor>", () => select({
|
|
21
|
+
message: "Which agent should get the skill?",
|
|
22
|
+
choices: Object.entries(AGENTS).map(([value, agent]) => ({ name: agent.name, value })),
|
|
23
|
+
}));
|
|
24
|
+
const agent = AGENTS[agentKey];
|
|
12
25
|
let scope;
|
|
13
26
|
if (options.global) {
|
|
14
27
|
scope = "global";
|
|
@@ -20,20 +33,20 @@ export const installSkill = async (options) => {
|
|
|
20
33
|
message: "Where should the skill be installed?",
|
|
21
34
|
default: "local",
|
|
22
35
|
choices: [
|
|
23
|
-
{ name:
|
|
24
|
-
{ name:
|
|
36
|
+
{ name: `Global (~/${agent.folder}/skills, all projects)`, value: "global" },
|
|
37
|
+
{ name: `Local (${agent.folder}/skills, current project)`, value: "local" },
|
|
25
38
|
],
|
|
26
39
|
}));
|
|
27
40
|
let base = process.cwd();
|
|
28
41
|
if (scope === "global") {
|
|
29
42
|
base = homedir();
|
|
30
43
|
}
|
|
31
|
-
const directory = path.join(base,
|
|
44
|
+
const directory = path.join(base, agent.folder, "skills", "easyhost");
|
|
32
45
|
const target = path.join(directory, "SKILL.md");
|
|
33
46
|
mkdirSync(directory, { recursive: true });
|
|
34
47
|
copyFileSync(SKILL_SOURCE, target);
|
|
35
|
-
output({ path: target }, () => {
|
|
36
|
-
log.success(`Installed the EasyHost skill at ${target}`);
|
|
48
|
+
output({ agent: agentKey, scope, path: target }, () => {
|
|
49
|
+
log.success(`Installed the EasyHost skill for ${agent.name} at ${target}`);
|
|
37
50
|
log.info('Ask your agent: "Deploy this app to EasyHost."');
|
|
38
51
|
});
|
|
39
52
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
3
4
|
import { forgotPassword, login, logout, register, resendVerification, whoami } from "./commands/auth.js";
|
|
4
5
|
import { createApp, deleteApp, listApps } from "./commands/apps.js";
|
|
5
6
|
import { createSchedule, deleteSchedule, listSchedules, scheduleLogs, setScheduleState, updateSchedule } from "./commands/schedules.js";
|
|
@@ -12,13 +13,18 @@ import { createStorage, deleteStorage, downloadStorage, listStorage, removeStora
|
|
|
12
13
|
import { createDatabase, databaseInfo, deleteDatabase, queryDatabase, resetDatabasePassword, tableRows } from "./commands/db.js";
|
|
13
14
|
import { createSender, deleteSender, emailInfo, emailLogs, sendEmail } from "./commands/email.js";
|
|
14
15
|
import { createKey, listKeys, revokeKey } from "./commands/keys.js";
|
|
16
|
+
import { acceptInvite, inviteMember, leaveProject, listMembers, removeMember, revokeInvite } from "./commands/members.js";
|
|
15
17
|
import { installSkill } from "./commands/skill.js";
|
|
16
18
|
import { fail, setJsonMode } from "./lib/ui.js";
|
|
19
|
+
const packageMetadata = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
20
|
+
if (!packageMetadata || typeof packageMetadata !== "object" || !("version" in packageMetadata) || typeof packageMetadata.version !== "string") {
|
|
21
|
+
throw new Error("CLI package version is missing or malformed");
|
|
22
|
+
}
|
|
17
23
|
const program = new Command();
|
|
18
24
|
program
|
|
19
25
|
.name("ezhst")
|
|
20
26
|
.description("EasyHost from the terminal: deploy apps and manage storage, databases, email and API keys")
|
|
21
|
-
.version(
|
|
27
|
+
.version(packageMetadata.version)
|
|
22
28
|
.option("--json", "Print machine-readable JSON")
|
|
23
29
|
.hook("preAction", (_command, action) => {
|
|
24
30
|
setJsonMode(!!action.optsWithGlobals().json);
|
|
@@ -138,12 +144,20 @@ const keys = program.command("keys").description("API keys for the HTTP API");
|
|
|
138
144
|
scoped(keys.command("list").description("List API keys")).action(listKeys);
|
|
139
145
|
scoped(keys.command("create").description("Create an API key").argument("<name>")).action(createKey);
|
|
140
146
|
scoped(keys.command("revoke").description("Revoke an API key").argument("<id>")).action(revokeKey);
|
|
147
|
+
const members = program.command("members").description("Project members and invites");
|
|
148
|
+
scoped(members.command("list").description("List the owner, members and pending invites")).action(listMembers);
|
|
149
|
+
scoped(members.command("invite").description("Invite someone by email (owner only)").argument("<email>")).action(inviteMember);
|
|
150
|
+
scoped(members.command("revoke").description("Revoke a pending invite (owner only)").argument("<email>")).action(revokeInvite);
|
|
151
|
+
scoped(members.command("remove").description("Remove a member (owner only)").argument("<email>").option("--yes", "Confirm")).action(removeMember);
|
|
152
|
+
scoped(members.command("leave").description("Leave a project you were invited to").option("--yes", "Confirm")).action(leaveProject);
|
|
153
|
+
program.command("accept-invite").description("Accept a project invite").argument("<token-or-url>", "Invite link or token from the email").action(acceptInvite);
|
|
141
154
|
const skill = program.command("skill").description("Agent skill");
|
|
142
155
|
skill
|
|
143
156
|
.command("install")
|
|
144
157
|
.description("Install the EasyHost agent skill")
|
|
145
|
-
.option("--
|
|
146
|
-
.option("--
|
|
158
|
+
.option("--agent <agent>", "Target agent: claude, codex or cursor")
|
|
159
|
+
.option("--global", "Install to the agent's home skills folder for all projects")
|
|
160
|
+
.option("--local", "Install to the agent's skills folder in the current project")
|
|
147
161
|
.action(installSkill);
|
|
148
162
|
program.parseAsync().catch((error) => {
|
|
149
163
|
if (error?.name === "ExitPromptError") {
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -99,6 +99,10 @@ Schedules (up to five per project, intervals in minutes):
|
|
|
99
99
|
API keys:
|
|
100
100
|
- `keys list | create <name> | revoke <id>` (a key is shown only once)
|
|
101
101
|
|
|
102
|
+
Members:
|
|
103
|
+
- `members list | invite <email> | revoke <email> | remove <email> --yes | leave --yes`. Only the owner can invite, revoke, remove, rename or delete the project. Members can do everything else.
|
|
104
|
+
- `accept-invite <link-or-token>` joins a project. The logged-in email must match the invited email.
|
|
105
|
+
|
|
102
106
|
Account:
|
|
103
107
|
- `whoami`, `logout`, `resend-verification`, `forgot-password --email <email>`
|
|
104
108
|
|