@skillcdn/console 0.6.2 → 0.6.4
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 +16 -9
- package/SKILLCDN.md +3 -2
- package/dist/agent-page.d.ts +2 -0
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +46 -5
- package/dist/agent-page.js.map +1 -1
- package/dist/agent-state.d.ts +9 -0
- package/dist/agent-state.d.ts.map +1 -0
- package/dist/agent-state.js +28 -0
- package/dist/agent-state.js.map +1 -0
- package/dist/api.d.ts +6 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -4
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +948 -252
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +44 -7
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +168 -13
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +82 -9
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +855 -331
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/pack.d.ts +13 -12
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +33 -45
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/plugin-cli.d.ts.map +1 -1
- package/dist/cli/plugin-cli.js +8 -5
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/runner-files.d.ts +16 -0
- package/dist/cli/runner-files.d.ts.map +1 -0
- package/dist/cli/runner-files.js +125 -0
- package/dist/cli/runner-files.js.map +1 -0
- package/dist/cli/runner-host.d.ts +7 -0
- package/dist/cli/runner-host.d.ts.map +1 -1
- package/dist/cli/runner-host.js +40 -2
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/cli/skill-path.d.ts +11 -0
- package/dist/cli/skill-path.d.ts.map +1 -0
- package/dist/cli/skill-path.js +44 -0
- package/dist/cli/skill-path.js.map +1 -0
- package/dist/client.d.ts +32 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +93 -6
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +202 -10
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts +6 -6
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +16 -9
- package/dist/components/agents.js.map +1 -1
- package/dist/components/people.d.ts.map +1 -1
- package/dist/components/people.js +7 -2
- package/dist/components/people.js.map +1 -1
- package/dist/components/picker.d.ts +16 -0
- package/dist/components/picker.d.ts.map +1 -1
- package/dist/components/picker.js +69 -4
- package/dist/components/picker.js.map +1 -1
- package/dist/console.css +40 -0
- package/dist/console.js +2 -2
- package/dist/console.js.map +1 -1
- package/dist/feed-words.d.ts.map +1 -1
- package/dist/feed-words.js +12 -1
- package/dist/feed-words.js.map +1 -1
- package/dist/i18n/en.d.ts +64 -6
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +59 -10
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +49 -9
- package/dist/i18n/ko.js.map +1 -1
- package/dist/limits.d.ts +26 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +26 -0
- package/dist/limits.js.map +1 -1
- package/dist/onboarding.d.ts +18 -6
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +42 -7
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/args.d.ts +24 -2
- package/dist/plugin/args.d.ts.map +1 -1
- package/dist/plugin/args.js +20 -2
- package/dist/plugin/args.js.map +1 -1
- package/dist/plugin/context.d.ts +39 -7
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/define.d.ts.map +1 -1
- package/dist/plugin/define.js +12 -3
- package/dist/plugin/define.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +2 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +1 -0
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/routes.d.ts +2 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +2 -0
- package/dist/routes.js.map +1 -1
- package/dist/rules.d.ts +4 -1
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +5 -2
- package/dist/rules.js.map +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +9 -3
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +53 -1
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +18 -3
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +18 -0
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +77 -1
- package/dist/runner/config.js.map +1 -1
- package/dist/runner/desk.d.ts +7 -0
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +14 -4
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/message.d.ts +16 -22
- package/dist/runner/message.d.ts.map +1 -1
- package/dist/runner/message.js +72 -120
- package/dist/runner/message.js.map +1 -1
- package/dist/runner/runner.d.ts +41 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +557 -23
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack-status.d.ts +19 -0
- package/dist/runner/slack-status.d.ts.map +1 -0
- package/dist/runner/slack-status.js +332 -0
- package/dist/runner/slack-status.js.map +1 -0
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +258 -59
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +128 -15
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js.map +1 -1
- package/dist/runner/usage.d.ts +6 -1
- package/dist/runner/usage.d.ts.map +1 -1
- package/dist/runner/usage.js +9 -2
- package/dist/runner/usage.js.map +1 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +635 -6
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +197 -15
- package/dist/schemas.js.map +1 -1
- package/dist/secret-file.d.ts +21 -0
- package/dist/secret-file.d.ts.map +1 -0
- package/dist/secret-file.js +59 -0
- package/dist/secret-file.js.map +1 -0
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +3 -2
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +2 -2
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +6 -5
- package/dist/setup-guide.js.map +1 -1
- package/dist/vocabulary.d.ts +17 -2
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +15 -2
- package/dist/vocabulary.js.map +1 -1
- package/dist/wake-text.d.ts +43 -0
- package/dist/wake-text.d.ts.map +1 -0
- package/dist/wake-text.js +115 -0
- package/dist/wake-text.js.map +1 -0
- package/docs/specs/cli.md +39 -25
- package/docs/specs/plugins.md +10 -9
- package/docs/specs/rest.md +34 -15
- package/docs/specs/runner.md +108 -25
- package/docs/start.md +28 -6
- package/package.json +3 -3
- package/skills/building-a-plugin/SKILL.md +2 -2
- package/skills/deploying-a-console/SKILL.md +3 -3
- package/skills/deploying-a-console/references/access.md +15 -1
- package/skills/deploying-a-console/references/resources.md +2 -2
- package/skills/deploying-a-console/scripts/github-app.mjs +593 -0
- package/skills/keeping-the-pack/SKILL.md +87 -0
- package/skills/planning-the-board/SKILL.md +6 -6
- package/skills/planning-the-board/references/a-task.md +1 -1
- package/skills/planning-the-board/references/setting-up.md +9 -5
- package/skills/running-an-agent/SKILL.md +21 -17
- package/skills/running-an-agent/references/preparing-the-machine.md +4 -3
- package/skills/running-an-agent/references/several-tasks.md +8 -2
- package/skills/running-an-agent/references/slack-app.md +31 -8
- package/skills/running-an-agent/references/the-account-and-the-invitation.md +1 -1
- package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -1
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +4 -4
- package/skills/running-an-agent/references/your-first-task.md +11 -5
- package/skills/trying-a-console/SKILL.md +136 -0
- package/skills/trying-a-console/references/when-it-does-not-go.md +30 -0
- package/skills/working-the-board/SKILL.md +6 -6
- package/skills/working-the-board/references/terms.md +3 -1
- package/skills/working-the-board/references/the-pack.md +14 -7
- package/skills/working-the-board/references/what-they-were-told.md +1 -1
- package/src/agent-page.tsx +111 -4
- package/src/agent-state.ts +33 -0
- package/src/api.ts +43 -0
- package/src/cli/cli.ts +1190 -313
- package/src/cli/format.ts +207 -13
- package/src/cli/help.ts +991 -372
- package/src/cli/pack.ts +55 -62
- package/src/cli/plugin-cli.ts +8 -5
- package/src/cli/runner-files.ts +137 -0
- package/src/cli/runner-host.ts +48 -2
- package/src/cli/skill-path.ts +51 -0
- package/src/client.ts +103 -0
- package/src/components/agent-page.tsx +446 -20
- package/src/components/agents.tsx +27 -28
- package/src/components/people.tsx +7 -3
- package/src/components/picker.tsx +79 -5
- package/src/console.tsx +1 -1
- package/src/feed-words.ts +14 -1
- package/src/i18n/en.ts +64 -11
- package/src/i18n/ko.ts +55 -9
- package/src/limits.ts +26 -0
- package/src/onboarding.ts +60 -21
- package/src/plugin/args.ts +29 -3
- package/src/plugin/context.ts +40 -7
- package/src/plugin/define.ts +18 -3
- package/src/plugin/rest-schemas.ts +3 -0
- package/src/routes.ts +2 -0
- package/src/rules.ts +5 -2
- package/src/runner/acp.ts +9 -3
- package/src/runner/claude.ts +58 -1
- package/src/runner/codex.ts +18 -3
- package/src/runner/config.ts +114 -1
- package/src/runner/desk.ts +15 -4
- package/src/runner/message.ts +88 -126
- package/src/runner/runner.ts +682 -27
- package/src/runner/slack-status.ts +423 -0
- package/src/runner/slack.ts +310 -67
- package/src/runner/types.ts +124 -13
- package/src/runner/usage.ts +16 -3
- package/src/runner.ts +4 -0
- package/src/schemas.ts +245 -13
- package/src/secret-file.ts +76 -0
- package/src/services.ts +3 -2
- package/src/setup-guide.ts +6 -5
- package/src/styles/README.md +1 -1
- package/src/styles/pages/agents.css +40 -0
- package/src/vocabulary.ts +21 -2
- package/src/wake-text.ts +133 -0
- package/dist/cli/command-words.d.ts +0 -20
- package/dist/cli/command-words.d.ts.map +0 -1
- package/dist/cli/command-words.js +0 -51
- package/dist/cli/command-words.js.map +0 -1
- package/src/cli/command-words.ts +0 -56
package/src/cli/format.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { reasonMoment } from "../agent-state.js";
|
|
2
3
|
import { usageNear, usageSaidTogether, usageStanding, usedHundredths } from "../agent-usage.js";
|
|
3
4
|
import { describeEvent } from "../feed-words.js";
|
|
4
5
|
import { NOTIFICATION_KINDS, type NotificationKind } from "../notifications.js";
|
|
@@ -7,6 +8,7 @@ import type {
|
|
|
7
8
|
RestAgent,
|
|
8
9
|
RestAgentRunner,
|
|
9
10
|
RestAgentSecret,
|
|
11
|
+
RestAgentSecretOffer,
|
|
10
12
|
RestArtifact,
|
|
11
13
|
RestCategory,
|
|
12
14
|
RestComment,
|
|
@@ -23,6 +25,9 @@ import type {
|
|
|
23
25
|
RestNotificationSettings,
|
|
24
26
|
RestNotifications,
|
|
25
27
|
RestOwnWake,
|
|
28
|
+
RestPackNote,
|
|
29
|
+
RestPackNoteLeft,
|
|
30
|
+
RestPackNotes,
|
|
26
31
|
RestPerson,
|
|
27
32
|
RestPersonWork,
|
|
28
33
|
RestPlugin,
|
|
@@ -214,7 +219,7 @@ export function formatAgent(agent: RestAgent, now: number): string {
|
|
|
214
219
|
...(runner.product === null
|
|
215
220
|
? []
|
|
216
221
|
: [
|
|
217
|
-
`product: ${runner.product.name} ${runner.product.version ?? "of a version it did not say"}
|
|
222
|
+
`product: ${runner.product.name} ${runner.product.version ?? "of a version it did not say"}`,
|
|
218
223
|
]),
|
|
219
224
|
`set to: model ${runner.settings.model ?? OWN_CHOICE}, effort ${runner.settings.effort ?? OWN_CHOICE}`,
|
|
220
225
|
...(runner.running === null
|
|
@@ -290,21 +295,28 @@ export function formatOwnWakeLine(wake: RestOwnWake): string {
|
|
|
290
295
|
}
|
|
291
296
|
|
|
292
297
|
/**
|
|
293
|
-
* How an agent account stands (ADR-0085), in a few words: the state,
|
|
294
|
-
* where its runner said, as when a usage limit resets (ADR-0150), and when its runner was
|
|
295
|
-
* heard from.
|
|
298
|
+
* How an agent account stands (ADR-0085), in a few words: the state, since when, until when
|
|
299
|
+
* where its runner said, as when a usage limit resets (ADR-0150), why, and when its runner was
|
|
300
|
+
* last heard from. The moment after `since` is the state's alone, and the reason stands apart
|
|
301
|
+
* from it, after `why:`: with when it was said where that is another moment than the state's,
|
|
302
|
+
* a turn that completed or a new conversation under a state that stayed, and with none where
|
|
303
|
+
* it came with the state or the console keeps no moment for it.
|
|
296
304
|
*/
|
|
297
305
|
export function formatAgentState(agent: RestAgent): string {
|
|
298
306
|
const state = agent.state ?? null;
|
|
299
307
|
if (state === null) {
|
|
300
308
|
return "no runner has been heard from yet";
|
|
301
309
|
}
|
|
302
|
-
const
|
|
310
|
+
const said = reasonMoment(state);
|
|
303
311
|
const until =
|
|
304
312
|
state.until === undefined || state.until === null ? "" : `, until ${moment(state.until)}`;
|
|
313
|
+
const why =
|
|
314
|
+
state.reason === null
|
|
315
|
+
? ""
|
|
316
|
+
: `; why: ${state.reason.replaceAll("_", " ")}${said === undefined ? "" : `, said ${moment(said)}`}`;
|
|
305
317
|
const heard =
|
|
306
318
|
state.heardAt === null ? "" : `; its runner was last heard from ${moment(state.heardAt)}`;
|
|
307
|
-
return `${state.state}
|
|
319
|
+
return `${state.state} since ${moment(state.since)}${until}${why}${heard}`;
|
|
308
320
|
}
|
|
309
321
|
|
|
310
322
|
/**
|
|
@@ -341,6 +353,32 @@ export function formatSecretLine(secret: RestAgentSecret): string {
|
|
|
341
353
|
return `${secret.name} (${facts.join(", ")})`;
|
|
342
354
|
}
|
|
343
355
|
|
|
356
|
+
/**
|
|
357
|
+
* One secret offered to an agent account (ADR-0169): the offer's id, the name proposed, who
|
|
358
|
+
* offers it and through which agent, and how it stands; and, on a line of its own, what the
|
|
359
|
+
* offerer said it is for, as their words. Never its value.
|
|
360
|
+
*/
|
|
361
|
+
export function formatSecretOffer(offer: RestAgentSecretOffer): string {
|
|
362
|
+
const who = offer.by === null ? "someone who is gone" : calledOf(offer.by);
|
|
363
|
+
const ended = moment(offer.decidedAt ?? offer.endsAt);
|
|
364
|
+
const stands =
|
|
365
|
+
offer.state === "waiting"
|
|
366
|
+
? `waits until ${moment(offer.endsAt)}`
|
|
367
|
+
: offer.state === "taken"
|
|
368
|
+
? `taken ${ended}${offer.takenAs === null || offer.takenAs === offer.name ? "" : ` as ${offer.takenAs}`}`
|
|
369
|
+
: offer.state === "left"
|
|
370
|
+
? `left ${ended}`
|
|
371
|
+
: `ran out ${ended}`;
|
|
372
|
+
const facts = [
|
|
373
|
+
`from ${who}${offer.agent === null ? "" : ` through ${offer.agent}`}`,
|
|
374
|
+
`offered ${moment(offer.at)}`,
|
|
375
|
+
stands,
|
|
376
|
+
...(offer.expiresOn === null ? [] : [`ends on ${offer.expiresOn}`]),
|
|
377
|
+
];
|
|
378
|
+
const line = `${offer.id} ${offer.name} (${facts.join(", ")})`;
|
|
379
|
+
return offer.note === null ? line : `${line}\n ${who} says of it: ${offer.note}`;
|
|
380
|
+
}
|
|
381
|
+
|
|
344
382
|
/** The provider a listing names, as people call it. */
|
|
345
383
|
const HOST_NAMES = { gh: "GitHub", google: "Google" } as const;
|
|
346
384
|
|
|
@@ -349,8 +387,52 @@ export function formatListingLine(listing: RestListing): string {
|
|
|
349
387
|
return `${listing.login} (let in at ${HOST_NAMES[listing.host]}, not signed in yet)`;
|
|
350
388
|
}
|
|
351
389
|
|
|
352
|
-
/** The
|
|
353
|
-
export
|
|
390
|
+
/** The member who keeps the skills, as the command looked them up: what they are called, and whether they are out. */
|
|
391
|
+
export interface KeeperCalled {
|
|
392
|
+
readonly called: string;
|
|
393
|
+
/** Out of the workspace for now: the notes wait for the administrators until they are back. */
|
|
394
|
+
readonly away: boolean;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Who keeps the organization's skills (ADR-0178), as the workspace says it: the keeper as they
|
|
399
|
+
* are called, where the command looked them up, with the hour of their round; that the keeper
|
|
400
|
+
* is out, when the notes wait for the administrators as they do with nobody named; or that
|
|
401
|
+
* nobody keeps them. Nothing for a console that answers none of it.
|
|
402
|
+
*/
|
|
403
|
+
function keeperLine(workspace: RestWorkspace, keeper: KeeperCalled | undefined): string[] {
|
|
404
|
+
const { keeperId, roundAt } = workspace.skills;
|
|
405
|
+
if (keeperId === undefined) {
|
|
406
|
+
return [];
|
|
407
|
+
}
|
|
408
|
+
if (keeperId === null) {
|
|
409
|
+
return [
|
|
410
|
+
"skills kept by: nobody (the notes on the skills wait for the administrators: console skills --notes; console workspace pack-keeper <login> names a keeper)",
|
|
411
|
+
];
|
|
412
|
+
}
|
|
413
|
+
if (keeper?.away === true) {
|
|
414
|
+
return [
|
|
415
|
+
`skills kept by: ${keeper.called}, who is out (the notes on the skills wait for the administrators until they are back: console skills --notes; console workspace pack-keeper <login> names another)`,
|
|
416
|
+
];
|
|
417
|
+
}
|
|
418
|
+
const round =
|
|
419
|
+
roundAt == null
|
|
420
|
+
? "no round is kept"
|
|
421
|
+
: `an agent account that keeps them is woken for its round at ${roundAt}, where a note is new`;
|
|
422
|
+
return [
|
|
423
|
+
`skills kept by: ${keeper?.called ?? "a member"} (the notes on the skills wait for them: console skills --notes; ${round})`,
|
|
424
|
+
];
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* The workspace as its Settings page shows it: what it is called, who sees whom, the week, the
|
|
429
|
+
* time zone, where the skills come from and who keeps them, and what tokens may last. `keeper`
|
|
430
|
+
* is the member who keeps the skills, where the command looked them up.
|
|
431
|
+
*/
|
|
432
|
+
export function formatWorkspace(
|
|
433
|
+
workspace: RestWorkspace,
|
|
434
|
+
keeper?: KeeperCalled | undefined,
|
|
435
|
+
): string {
|
|
354
436
|
const visibility = workspace.peopleVisibility ?? "everyone";
|
|
355
437
|
const zone = workspace.timeZone ?? null;
|
|
356
438
|
const token = workspace.skills.packToken ?? null;
|
|
@@ -372,15 +454,127 @@ export function formatWorkspace(workspace: RestWorkspace): string {
|
|
|
372
454
|
].join(", ")}`,
|
|
373
455
|
)),
|
|
374
456
|
`people visibility: ${visibility} (${visibility === "everyone" ? "everyone sees everyone" : "a member sees only the people they share a project with; an administrator sees everyone"})`,
|
|
375
|
-
`
|
|
457
|
+
// What `auto` means is said where the week is left to it, and not beside a day that was chosen.
|
|
458
|
+
`week begins on: ${
|
|
459
|
+
(workspace.weekStart ?? "auto") === "auto"
|
|
460
|
+
? "auto (the system default, as each device has it)"
|
|
461
|
+
: workspace.weekStart
|
|
462
|
+
}`,
|
|
376
463
|
`time zone: ${zone ?? "none"} (${zone === null ? "moments are printed as the API gives them, in UTC" : "moments are printed in it, as ISO 8601 with its offset"})`,
|
|
377
464
|
`language: ${workspace.language ?? "none"} (${workspace.language == null ? "whoever has not chosen a language reads English, and the plugins write to them in it" : "whoever has not chosen a language reads it, and the plugins write to them in it"})`,
|
|
378
465
|
`skills: ${workspace.skills.address ?? "no address of the organization's"} at ${workspace.skills.source}`,
|
|
466
|
+
...keeperLine(workspace, keeper),
|
|
379
467
|
`SkillCDN token: ${token === null ? "none" : `set ${moment(token.setAt)}`} (${token === null ? "the organization's pack is read with none" : "the organization's pack is read with it by a project with no address and no token of its own"})`,
|
|
380
468
|
`token days at most: ${workspace.tokenDaysAtMost ?? "a person chooses"}`,
|
|
381
469
|
].join("\n");
|
|
382
470
|
}
|
|
383
471
|
|
|
472
|
+
/** A note's text under its line: each line of it set in, so that a list of notes reads as one. */
|
|
473
|
+
const setIn = (text: string): string =>
|
|
474
|
+
text
|
|
475
|
+
.split("\n")
|
|
476
|
+
.map((line) => ` ${line}`)
|
|
477
|
+
.join("\n");
|
|
478
|
+
|
|
479
|
+
/** What a note is on, as a list groups it: the skill or the page, or that no skill fit. */
|
|
480
|
+
const NO_SKILL_FIT = "No skill fit";
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Who left a note and from where: the member, the agent they left it through, the project. A
|
|
484
|
+
* member the console did not name, since the reader may not see them, is a member and no more.
|
|
485
|
+
*/
|
|
486
|
+
function noteLine(note: RestPackNote): string {
|
|
487
|
+
const by = note.by === null ? "a member" : calledOf(note.by);
|
|
488
|
+
const through = note.agent === null ? "" : ` through ${note.agent}`;
|
|
489
|
+
const from = note.project === null ? "" : `, from ${note.project}`;
|
|
490
|
+
const standing = note.state === "open" ? "" : ` ${note.state}`;
|
|
491
|
+
return ` ${note.id} ${moment(note.at).slice(0, 10)} ${by}${through}${from}${standing}`;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/** One note in a list: its line, what it says, and, once closed, what became of it. */
|
|
495
|
+
function formatPackNote(note: RestPackNote): string {
|
|
496
|
+
return [
|
|
497
|
+
noteLine(note),
|
|
498
|
+
setIn(note.body),
|
|
499
|
+
...(note.outcome === null ? [] : [setIn(`-> ${note.outcome}`)]),
|
|
500
|
+
].join("\n");
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Whom the notes wait for, in a few words: the keeper as they are called, a keeper the console
|
|
505
|
+
* did not name to this reader, or the administrators where nobody keeps the skills.
|
|
506
|
+
*/
|
|
507
|
+
const waitsFor = (kept: boolean, keeper: RestPerson | null): string =>
|
|
508
|
+
keeper !== null
|
|
509
|
+
? `kept by ${calledOf(keeper)}`
|
|
510
|
+
: kept
|
|
511
|
+
? "kept by a member"
|
|
512
|
+
: "nobody keeps the organization's skills, so they wait for the administrators";
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* The notes on the pack as `console skills --notes` lists them (ADR-0178): under a line that
|
|
516
|
+
* says whose they are, how many are open and whom they wait for, each skill or page with its
|
|
517
|
+
* notes, the oldest first, then the jobs no skill fit. `closing` is what the command says after
|
|
518
|
+
* them: to whoever keeps the pack, how one is closed and where a keeper's work is written.
|
|
519
|
+
*/
|
|
520
|
+
export function formatPackNotes(
|
|
521
|
+
notes: RestPackNotes,
|
|
522
|
+
page: { readonly limit: number; readonly offset: number; readonly all: boolean },
|
|
523
|
+
closing: readonly string[],
|
|
524
|
+
): string {
|
|
525
|
+
const whose = notes.everyones ? "everyone's" : "your own";
|
|
526
|
+
const head = `Notes on the skills, ${whose}: ${notes.open} open; ${waitsFor(notes.kept, notes.keeper)}.`;
|
|
527
|
+
if (notes.items.length === 0) {
|
|
528
|
+
return [
|
|
529
|
+
head,
|
|
530
|
+
page.offset > 0
|
|
531
|
+
? "No more on this page."
|
|
532
|
+
: page.all
|
|
533
|
+
? "None was left."
|
|
534
|
+
: "None is open here.",
|
|
535
|
+
...closing,
|
|
536
|
+
].join("\n");
|
|
537
|
+
}
|
|
538
|
+
const groups = new Map<string, RestPackNote[]>();
|
|
539
|
+
for (const note of notes.items) {
|
|
540
|
+
const key = note.path ?? NO_SKILL_FIT;
|
|
541
|
+
groups.set(key, [...(groups.get(key) ?? []), note]);
|
|
542
|
+
}
|
|
543
|
+
// The jobs no skill fit come last: they ask for a skill that is not there, which is a person's to say.
|
|
544
|
+
const ordered = [...groups].sort(
|
|
545
|
+
([a], [b]) => Number(a === NO_SKILL_FIT) - Number(b === NO_SKILL_FIT),
|
|
546
|
+
);
|
|
547
|
+
return (
|
|
548
|
+
[
|
|
549
|
+
head,
|
|
550
|
+
...ordered.flatMap(([key, items]) => [
|
|
551
|
+
`${key} (${items.length})`,
|
|
552
|
+
...items.map(formatPackNote),
|
|
553
|
+
]),
|
|
554
|
+
...closing,
|
|
555
|
+
].join("\n") + formatMore(notes.items.length === page.limit, page.limit, page.offset)
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* What leaving a note answers: its id, what it is on and whom it waits for. Where nobody keeps
|
|
561
|
+
* the skills, that is said as something to pass on: a note nobody reads mends nothing.
|
|
562
|
+
*/
|
|
563
|
+
export function formatPackNoteLeft(left: RestPackNoteLeft): string {
|
|
564
|
+
const on = left.note.path === null ? "that no skill fit" : `on ${left.note.path}`;
|
|
565
|
+
if (left.keeper !== null) {
|
|
566
|
+
return `Noted ${on} (note ${left.note.id}), for ${calledOf(left.keeper)}, who keeps the organization's skills.`;
|
|
567
|
+
}
|
|
568
|
+
return left.kept
|
|
569
|
+
? `Noted ${on} (note ${left.note.id}), for the member who keeps the organization's skills.`
|
|
570
|
+
: `Noted ${on} (note ${left.note.id}). Nobody keeps the organization's skills, so it waits for an administrator, who reads it with console skills --notes: where you report this work, say that a note waits and nobody keeps the skills.`;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** What closing a note answers: how it ended, and what was said of it. */
|
|
574
|
+
export function formatPackNoteClosed(note: RestPackNote): string {
|
|
575
|
+
return `Note ${note.id} is ${note.state}: ${note.outcome ?? ""}`;
|
|
576
|
+
}
|
|
577
|
+
|
|
384
578
|
/** One member of a project: their login, what they are in it, and since when. */
|
|
385
579
|
export function formatMemberLine(member: RestMember): string {
|
|
386
580
|
return `${calledOf(member.person)} ${member.role} (since ${moment(member.addedAt).slice(0, 10)})`;
|
|
@@ -639,7 +833,7 @@ const charactersOf = (text: string | null): string => `${(text ?? "").trimEnd().
|
|
|
639
833
|
|
|
640
834
|
/**
|
|
641
835
|
* The rules that hold, under a first line that says what follows (ADR-0119): the mark, which
|
|
642
|
-
* parts there are and how long each is, and how a
|
|
836
|
+
* parts there are and how long each is, and how a take in this session leaves them out.
|
|
643
837
|
* What differs stands first and what always holds last (ADR-0120): what the project adds with
|
|
644
838
|
* the plugins' lines, then what the organization adds, then the console's rules. An agent that
|
|
645
839
|
* had read the long part once cut every later print at its head, and never saw what stood
|
|
@@ -684,7 +878,7 @@ export function formatRules(
|
|
|
684
878
|
}
|
|
685
879
|
// The mark ends the line bare, so that it is copied as it is.
|
|
686
880
|
const later = parts.named
|
|
687
|
-
? `
|
|
881
|
+
? ` Now that they are read, a take in this session leaves them out: console take <number> --rules ${mark}`
|
|
688
882
|
: "";
|
|
689
883
|
return [
|
|
690
884
|
`Rules ${mark}: ${follows}${later}`,
|
|
@@ -1358,8 +1552,8 @@ export function formatTaskFollow(
|
|
|
1358
1552
|
): string {
|
|
1359
1553
|
const named = `Notifications of #${task.number} ${task.title} are ${follow.on ? "on" : "off"}`;
|
|
1360
1554
|
const other = follow.on
|
|
1361
|
-
? `Turn them off: console mute ${task.number}`
|
|
1362
|
-
: `Turn them on: console follow ${task.number}`;
|
|
1555
|
+
? `Turn them off: console task mute ${task.number}`
|
|
1556
|
+
: `Turn them on: console task follow ${task.number}`;
|
|
1363
1557
|
if (follow.on ? !follow.all : !follow.usual) {
|
|
1364
1558
|
return `${named}, as your settings have it${follow.on ? ": you are told of it by the kinds you have on (console notify)" : ""}. ${other}`;
|
|
1365
1559
|
}
|