@dench.com/cli 3.12.11-staging.1243 → 3.12.12-staging.1261
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/app-sdk.d.ts +103 -0
- package/dench.ts +6 -2
- package/lib/api-schemas.ts +121 -0
- package/lib/app-sdk-catalog.generated.ts +3 -0
- package/lib/command-registry.ts +50 -0
- package/lib/references.generated.json +8 -8
- package/package.json +1 -1
- package/settings.ts +221 -2
package/package.json
CHANGED
package/settings.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `dench settings <subcommand>` — workspace settings from the command line.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Settings → Sync: the eight switches that decide what Dench
|
|
5
5
|
* does on its own with the workspace's email, calendar, Slack and LinkedIn
|
|
6
6
|
* (docs/agent-notes/account-context-ingestion.md §12). All on by default;
|
|
7
7
|
* turning one off stops NEW work and never removes anything already created.
|
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
* dench settings sync [--json] the eight switches
|
|
10
10
|
* dench settings sync set <key> on|off [--json] admin-only
|
|
11
11
|
*
|
|
12
|
+
* Settings → Dench in Slack → Announcements: the saved channel groups and
|
|
13
|
+
* the channels in each right now, and making, changing and deleting one
|
|
14
|
+
* (DENCH-81). Admin-only. Nothing here sends an announcement: that is a
|
|
15
|
+
* person's click in that screen.
|
|
16
|
+
*
|
|
17
|
+
* dench settings announcement-groups [name] [--json]
|
|
18
|
+
* dench settings announcement-groups save <name> [--rule <pattern>]
|
|
19
|
+
* [--channels a,b] [--add a,b] [--remove a,b] [--rename <new name>]
|
|
20
|
+
* dench settings announcement-groups delete <name>
|
|
21
|
+
*
|
|
12
22
|
* Reads `functions/organizations:getMySyncSettings` and writes
|
|
13
23
|
* `functions/organizations:updateMyOrganizationSyncSettings` with a one-key
|
|
14
24
|
* patch, forwarding the same bearer every other CLI surface uses. The
|
|
@@ -20,7 +30,12 @@
|
|
|
20
30
|
*/
|
|
21
31
|
import type { ConvexHttpClient } from "convex/browser";
|
|
22
32
|
import { makeFunctionReference } from "convex/server";
|
|
23
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
assertNoUnknownFlags,
|
|
35
|
+
CliArgError,
|
|
36
|
+
getFlag,
|
|
37
|
+
hasFlag,
|
|
38
|
+
} from "./lib/cli-args";
|
|
24
39
|
|
|
25
40
|
class SettingsCliError extends Error {}
|
|
26
41
|
|
|
@@ -55,6 +70,15 @@ const api = {
|
|
|
55
70
|
updateSync: makeFunctionReference<"mutation">(
|
|
56
71
|
"functions/organizations:updateMyOrganizationSyncSettings",
|
|
57
72
|
),
|
|
73
|
+
announcementGroups: makeFunctionReference<"action">(
|
|
74
|
+
"functions/slackAnnouncementsNode:listGroupsForCaller",
|
|
75
|
+
),
|
|
76
|
+
saveAnnouncementGroup: makeFunctionReference<"action">(
|
|
77
|
+
"functions/slackAnnouncementsNode:saveGroupForCaller",
|
|
78
|
+
),
|
|
79
|
+
deleteAnnouncementGroup: makeFunctionReference<"mutation">(
|
|
80
|
+
"functions/slackAnnouncements:deleteGroupForCaller",
|
|
81
|
+
),
|
|
58
82
|
};
|
|
59
83
|
|
|
60
84
|
const HELP = `dench settings — workspace settings
|
|
@@ -65,6 +89,19 @@ const HELP = `dench settings — workspace settings
|
|
|
65
89
|
dench settings sync set <key> on|off [--json]
|
|
66
90
|
Flip one switch (workspace admins only). Off stops new work; nothing
|
|
67
91
|
already created is removed.
|
|
92
|
+
dench settings announcement-groups [name] [--json]
|
|
93
|
+
The Slack announcement channel groups and the channels in each right
|
|
94
|
+
now (workspace admins only). Give a group's name to see only that
|
|
95
|
+
group, with every channel in it.
|
|
96
|
+
dench settings announcement-groups save <name> [--rule <pattern>]
|
|
97
|
+
[--channels a,b] [--add a,b] [--remove a,b] [--rename <new name>] [--json]
|
|
98
|
+
Make or change a group (workspace admins only). --rule makes it a rule
|
|
99
|
+
on channel names (dench-* starts with, *-acme ends with, a word is
|
|
100
|
+
found anywhere, a comma means or). --channels makes it exactly those
|
|
101
|
+
channels. --add and --remove put single channels in or take them out
|
|
102
|
+
without restating the group. It sends nothing.
|
|
103
|
+
dench settings announcement-groups delete <name> [--json]
|
|
104
|
+
Delete a group (workspace admins only).
|
|
68
105
|
|
|
69
106
|
Keys:
|
|
70
107
|
${SYNC_SETTING_KEYS.map((key) => ` ${key.padEnd(22)} ${SYNC_SETTING_LABELS[key]}`).join("\n")}
|
|
@@ -160,6 +197,9 @@ export async function runSettingsCommand(opts: {
|
|
|
160
197
|
console.log(HELP);
|
|
161
198
|
return;
|
|
162
199
|
}
|
|
200
|
+
if (subcommand === "announcement-groups") {
|
|
201
|
+
return await runAnnouncementGroups(ctx);
|
|
202
|
+
}
|
|
163
203
|
if (subcommand !== "sync") {
|
|
164
204
|
throw new SettingsCliError(
|
|
165
205
|
`Unknown settings subcommand: ${subcommand}. Run \`dench settings help\`.`,
|
|
@@ -227,3 +267,182 @@ async function runSyncSet(ctx: Ctx): Promise<void> {
|
|
|
227
267
|
console.log("");
|
|
228
268
|
console.log(formatSyncSettingsTable(settings));
|
|
229
269
|
}
|
|
270
|
+
|
|
271
|
+
type AnnouncementGroupChannel = {
|
|
272
|
+
name: string;
|
|
273
|
+
isPrivate?: true;
|
|
274
|
+
isShared?: true;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export type AnnouncementGroupsAnswer = {
|
|
278
|
+
slack: "connected" | "not_connected" | "account_not_linked";
|
|
279
|
+
groups: Array<{
|
|
280
|
+
name: string;
|
|
281
|
+
kind: "rule" | "picked";
|
|
282
|
+
rule?: string;
|
|
283
|
+
channelCount?: number;
|
|
284
|
+
channels?: AnnouncementGroupChannel[];
|
|
285
|
+
privateChannelsNotNamed?: number;
|
|
286
|
+
channelsNotListed?: number;
|
|
287
|
+
leftOutCount?: number;
|
|
288
|
+
leftOut?: AnnouncementGroupChannel[];
|
|
289
|
+
}>;
|
|
290
|
+
notes: string[];
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
function channelLabel(channel: AnnouncementGroupChannel): string {
|
|
294
|
+
const name = `${channel.isPrivate ? "🔒 " : "#"}${channel.name}`;
|
|
295
|
+
return channel.isShared ? `${name} (shared with another company)` : name;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** The groups as a person reads them: one block per group, then the notes. */
|
|
299
|
+
export function formatAnnouncementGroups(
|
|
300
|
+
answer: AnnouncementGroupsAnswer,
|
|
301
|
+
): string {
|
|
302
|
+
const blocks = answer.groups.map((group) => {
|
|
303
|
+
const what =
|
|
304
|
+
group.kind === "rule"
|
|
305
|
+
? `channels named ${group.rule || "(any name)"}`
|
|
306
|
+
: "channels picked by hand";
|
|
307
|
+
const count =
|
|
308
|
+
group.channelCount === undefined
|
|
309
|
+
? ""
|
|
310
|
+
: ` · ${group.channelCount} ${group.channelCount === 1 ? "channel" : "channels"}`;
|
|
311
|
+
const lines = [`${group.name}: ${what}${count}`];
|
|
312
|
+
for (const channel of group.channels ?? [])
|
|
313
|
+
lines.push(` ${channelLabel(channel)}`);
|
|
314
|
+
if (group.privateChannelsNotNamed)
|
|
315
|
+
lines.push(` and ${group.privateChannelsNotNamed} private, not named`);
|
|
316
|
+
if (group.channelsNotListed)
|
|
317
|
+
lines.push(` and ${group.channelsNotListed} more`);
|
|
318
|
+
if (group.leftOutCount) {
|
|
319
|
+
const named = (group.leftOut ?? []).map(channelLabel).join(", ");
|
|
320
|
+
lines.push(
|
|
321
|
+
` left out (${group.leftOutCount})${named ? `: ${named}` : ""}`,
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
return lines.join("\n");
|
|
325
|
+
});
|
|
326
|
+
return [
|
|
327
|
+
...(blocks.length ? [blocks.join("\n\n")] : []),
|
|
328
|
+
...(answer.notes.length ? [answer.notes.join("\n")] : []),
|
|
329
|
+
].join("\n\n");
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** `a, #b,c` → `["a", "#b", "c"]`; an absent flag stays absent. */
|
|
333
|
+
function channelList(value: string | undefined): string[] | undefined {
|
|
334
|
+
return value
|
|
335
|
+
?.split(",")
|
|
336
|
+
.map((name) => name.trim())
|
|
337
|
+
.filter(Boolean);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async function runAnnouncementGroupSave(ctx: Ctx): Promise<void> {
|
|
341
|
+
let rule: string | undefined;
|
|
342
|
+
let channels: string[] | undefined;
|
|
343
|
+
let add: string[] | undefined;
|
|
344
|
+
let remove: string[] | undefined;
|
|
345
|
+
let rename: string | undefined;
|
|
346
|
+
try {
|
|
347
|
+
rule = getFlag(ctx.args, "--rule");
|
|
348
|
+
channels = channelList(getFlag(ctx.args, "--channels"));
|
|
349
|
+
add = channelList(getFlag(ctx.args, "--add"));
|
|
350
|
+
remove = channelList(getFlag(ctx.args, "--remove"));
|
|
351
|
+
rename = getFlag(ctx.args, "--rename");
|
|
352
|
+
assertNoUnknownFlags(ctx.args, "settings announcement-groups save");
|
|
353
|
+
} catch (error) {
|
|
354
|
+
throw toCliError(error);
|
|
355
|
+
}
|
|
356
|
+
const name = ctx.args.join(" ").trim();
|
|
357
|
+
if (!name)
|
|
358
|
+
throw new SettingsCliError(
|
|
359
|
+
"Give the group's name: dench settings announcement-groups save <name> --rule dench-*",
|
|
360
|
+
);
|
|
361
|
+
let answer: AnnouncementGroupsAnswer & { outcome: "created" | "changed" };
|
|
362
|
+
try {
|
|
363
|
+
answer = (await ctx.convex.action(
|
|
364
|
+
api.saveAnnouncementGroup,
|
|
365
|
+
withToken(ctx, {
|
|
366
|
+
...(rename ? { group: name, name: rename } : { name }),
|
|
367
|
+
...(rule !== undefined ? { rule } : {}),
|
|
368
|
+
...(channels ? { channels } : {}),
|
|
369
|
+
...(add ? { addChannels: add } : {}),
|
|
370
|
+
...(remove ? { removeChannels: remove } : {}),
|
|
371
|
+
}) as never,
|
|
372
|
+
)) as typeof answer;
|
|
373
|
+
} catch (error) {
|
|
374
|
+
throw toCliError(error);
|
|
375
|
+
}
|
|
376
|
+
if (ctx.jsonOutput) {
|
|
377
|
+
console.log(JSON.stringify(answer, null, 2));
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
console.log(
|
|
381
|
+
`${answer.outcome === "created" ? "Created" : "Changed"} the group.`,
|
|
382
|
+
);
|
|
383
|
+
console.log("");
|
|
384
|
+
console.log(formatAnnouncementGroups(answer));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async function runAnnouncementGroupDelete(ctx: Ctx): Promise<void> {
|
|
388
|
+
try {
|
|
389
|
+
assertNoUnknownFlags(ctx.args, "settings announcement-groups delete");
|
|
390
|
+
} catch (error) {
|
|
391
|
+
throw toCliError(error);
|
|
392
|
+
}
|
|
393
|
+
const name = ctx.args.join(" ").trim();
|
|
394
|
+
if (!name)
|
|
395
|
+
throw new SettingsCliError(
|
|
396
|
+
"Give the group's name: dench settings announcement-groups delete <name>",
|
|
397
|
+
);
|
|
398
|
+
let result: { deleted: string };
|
|
399
|
+
try {
|
|
400
|
+
result = (await ctx.convex.mutation(
|
|
401
|
+
api.deleteAnnouncementGroup,
|
|
402
|
+
withToken(ctx, { name }) as never,
|
|
403
|
+
)) as typeof result;
|
|
404
|
+
} catch (error) {
|
|
405
|
+
throw toCliError(error);
|
|
406
|
+
}
|
|
407
|
+
if (ctx.jsonOutput) {
|
|
408
|
+
console.log(JSON.stringify(result, null, 2));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
console.log(`Deleted the group "${result.deleted}".`);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
async function runAnnouncementGroups(ctx: Ctx): Promise<void> {
|
|
415
|
+
// A group that is itself called "save", "delete" or "list" is read with
|
|
416
|
+
// --group.
|
|
417
|
+
const verb = ctx.args[0];
|
|
418
|
+
if (verb === "save" || verb === "delete") {
|
|
419
|
+
ctx.args.shift();
|
|
420
|
+
return verb === "save"
|
|
421
|
+
? await runAnnouncementGroupSave(ctx)
|
|
422
|
+
: await runAnnouncementGroupDelete(ctx);
|
|
423
|
+
}
|
|
424
|
+
if (verb === "list") ctx.args.shift();
|
|
425
|
+
let group: string | undefined;
|
|
426
|
+
try {
|
|
427
|
+
group = getFlag(ctx.args, "--group");
|
|
428
|
+
assertNoUnknownFlags(ctx.args, "settings announcement-groups");
|
|
429
|
+
} catch (error) {
|
|
430
|
+
throw toCliError(error);
|
|
431
|
+
}
|
|
432
|
+
// A name may be several words: `announcement-groups All Dench Channels`.
|
|
433
|
+
const name = (group ?? ctx.args.join(" ")).trim();
|
|
434
|
+
let answer: AnnouncementGroupsAnswer;
|
|
435
|
+
try {
|
|
436
|
+
answer = (await ctx.convex.action(
|
|
437
|
+
api.announcementGroups,
|
|
438
|
+
withToken(ctx, name ? { group: name } : {}) as never,
|
|
439
|
+
)) as AnnouncementGroupsAnswer;
|
|
440
|
+
} catch (error) {
|
|
441
|
+
throw toCliError(error);
|
|
442
|
+
}
|
|
443
|
+
if (ctx.jsonOutput) {
|
|
444
|
+
console.log(JSON.stringify(answer, null, 2));
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
console.log(formatAnnouncementGroups(answer));
|
|
448
|
+
}
|