rvlib-shipkit 2.27.0 → 2.28.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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/agent-time/hooks.ts +10 -3
- package/src/agent-time/live.ts +11 -5
- package/src/agent-time/registry.ts +289 -0
- package/src/agent-time/store.ts +2 -2
- package/src/annex/born.ts +2 -2
- package/src/annex/offload.ts +12 -11
- package/src/asks/ask-after.ts +6 -2
- package/src/asks/ask-bar-fold.ts +57 -0
- package/src/asks/ask-migrate.ts +280 -0
- package/src/asks/ask-steps-fold.ts +166 -0
- package/src/asks/ask-store.ts +586 -0
- package/src/assets/kits/identity-kit.ts +106 -38
- package/src/assets/kits/poster-thumbnail.ts +282 -0
- package/src/checks/SK003-claude-md-shape.check.ts +92 -25
- package/src/checks/SK004-gitignore-policy.check.ts +8 -4
- package/src/checks/SK013-one-way-in-policy.check.ts +10 -0
- package/src/checks/SK026-asks-autoclose.check.ts +9 -23
- package/src/checks/SK038-speaks-as.check.ts +3 -3
- package/src/checks/SK042-post-kinds.check.ts +26 -24
- package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
- package/src/checks/SK050-retired-commands.check.ts +127 -0
- package/src/cli/cmd_Asks.ts +204 -53
- package/src/cli/cmd_Backup.ts +151 -8
- package/src/cli/cmd_Calls.ts +1 -0
- package/src/cli/cmd_Commands.ts +140 -34
- package/src/cli/cmd_Contracts.ts +1 -0
- package/src/cli/cmd_Keys.ts +1 -0
- package/src/cli/cmd_Lanes.ts +15 -4
- package/src/cli/cmd_Messages.ts +152 -1
- package/src/cli/cmd_Needs.ts +1 -0
- package/src/cli/cmd_Review.ts +931 -229
- package/src/cli/cmd_Secret.ts +255 -34
- package/src/cli/cmd_Social.ts +36 -33
- package/src/cli/cmd_SocialDrafts.ts +235 -0
- package/src/cli/cmd_Sound.ts +22 -1
- package/src/cli/cmd_Start.ts +3 -2
- package/src/cli/cmd_ThreadHolds.ts +34 -0
- package/src/cli/cmd_ThreadKinds.ts +146 -0
- package/src/cli/cmd_ThreadReflect.ts +83 -0
- package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
- package/src/cli/cmd_Vault.ts +1 -1
- package/src/cli/cmd_When.ts +1 -0
- package/src/cli/family-help.ts +2 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/kit/builtins.ts +1 -0
- package/src/cli/kit/verb.ts +6 -2
- package/src/cli/registry.ts +21 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +25 -74
- package/src/collections/collection-types.ts +9 -5
- package/src/collections/md-body.ts +5 -3
- package/src/collections/pings.ts +13 -6
- package/src/collections/providers.ts +53 -61
- package/src/collections/reflections.ts +9 -4
- package/src/core/discover-checks.ts +18 -3
- package/src/core/git.ts +31 -0
- package/src/core/house-layout.ts +17 -0
- package/src/core/layout.ts +10 -5
- package/src/core/locked-write.ts +4 -1
- package/src/core/machine-db.ts +5 -3
- package/src/core/migrate-layout.ts +8 -10
- package/src/home/activity.ts +8 -15
- package/src/home/daemon-jobs.ts +13 -1
- package/src/home/home-paths.ts +6 -3
- package/src/home/home-routes.ts +8 -0
- package/src/home/inbox-shape.ts +233 -100
- package/src/home/inbox.ts +26 -71
- package/src/home/machine-fold.ts +10 -15
- package/src/home/machine-host.ts +19 -1
- package/src/home/other-macs.ts +2 -2
- package/src/home/serve-web.ts +6 -5
- package/src/home/space-page.ts +1 -1
- package/src/home/vault-page.ts +51 -17
- package/src/home/vault-words.ts +2 -2
- package/src/hooks/one-way-in-guard.ts +24 -2
- package/src/hq/files-send.ts +27 -28
- package/src/hq/hq-db.ts +4 -1
- package/src/hq/hq-local.ts +37 -4
- package/src/hq/hq-routes.ts +10 -2
- package/src/hq/hq-store.ts +6 -2
- package/src/hq/kinds/ask.ts +6 -6
- package/src/hq/outbox.ts +5 -3
- package/src/hq/replica.ts +1 -2
- package/src/hq/vault-route.ts +112 -0
- package/src/identities/collection.ts +2 -2
- package/src/identities/identities.ts +9 -8
- package/src/identities/machine-route.ts +8 -3
- package/src/ledger/db.ts +8 -1
- package/src/media-store/backup/daemon.ts +48 -8
- package/src/media-store/backup/keys.ts +1 -1
- package/src/media-store/backup/manifest.ts +20 -2
- package/src/media-store/backup/prune.ts +365 -0
- package/src/media-store/backup/retention.ts +122 -0
- package/src/media-store/backup/run.ts +14 -8
- package/src/media-store/backup/sources.ts +18 -17
- package/src/media-store/backup/thread-copy.ts +340 -0
- package/src/media-store/copy/config.ts +3 -4
- package/src/media-store/copy/store.ts +2 -2
- package/src/media-store/db.ts +2 -2
- package/src/media-store/forget.ts +118 -0
- package/src/media-store/purge.ts +3 -2
- package/src/media-store/space-listing.ts +20 -4
- package/src/media-store/space.ts +6 -5
- package/src/messages/guard.ts +49 -0
- package/src/messages/model.ts +1 -1
- package/src/messages/objects.ts +201 -0
- package/src/messages/routes.ts +2 -2
- package/src/messages/score.ts +1 -1
- package/src/messages/write.ts +285 -0
- package/src/pages/frame-client.ts +181 -4
- package/src/reflections/reflections-queue.ts +1 -1
- package/src/release/gate-checkout.ts +2 -1
- package/src/release/git-facts.ts +3 -2
- package/src/release/public-clean.ts +3 -2
- package/src/repo-config.ts +40 -18
- package/src/review/anim.ts +1 -1
- package/src/review/answer-kinds.ts +131 -0
- package/src/review/band.ts +53 -0
- package/src/review/branch-hold.ts +84 -0
- package/src/review/card-db.ts +16 -6
- package/src/review/card-rows.ts +4 -3
- package/src/review/cells.ts +297 -65
- package/src/review/close.ts +92 -0
- package/src/review/draft-card.ts +8 -16
- package/src/review/draft-model.ts +2 -2
- package/src/review/events.ts +171 -0
- package/src/review/format.ts +128 -14
- package/src/review/glyphs.ts +63 -0
- package/src/review/gone.ts +1 -1
- package/src/review/holds-sync.ts +62 -0
- package/src/review/holds.ts +85 -0
- package/src/review/house-kind-defs.ts +41 -0
- package/src/review/inbox-hook.ts +22 -9
- package/src/review/inbox-read.ts +201 -0
- package/src/review/instructions.ts +199 -0
- package/src/review/kind-apply.ts +61 -0
- package/src/review/kind-catalog.ts +96 -0
- package/src/review/kinds.ts +278 -0
- package/src/review/lane-ask.ts +109 -0
- package/src/review/model.ts +396 -86
- package/src/review/move.ts +3 -3
- package/src/review/need-address.ts +15 -0
- package/src/review/need-threads.ts +93 -0
- package/src/review/object-card.ts +48 -0
- package/src/review/object-read.ts +31 -0
- package/src/review/owner-verdict.ts +36 -0
- package/src/review/parties.ts +182 -0
- package/src/review/previews.ts +3 -1
- package/src/review/projections.ts +235 -0
- package/src/review/referring.ts +54 -0
- package/src/review/reflection-object.ts +195 -0
- package/src/review/routes.ts +137 -32
- package/src/review/secret-route.ts +80 -0
- package/src/review/snooze.ts +38 -0
- package/src/review/stage-card.ts +4 -4
- package/src/review/store.ts +366 -85
- package/src/review/supersede.ts +116 -0
- package/src/review/take-back.ts +52 -0
- package/src/review/thread-fold.ts +20 -7
- package/src/review/threads.ts +236 -39
- package/src/review/traces.ts +218 -0
- package/src/review/trailer-card.ts +2 -2
- package/src/review/unit.ts +71 -5
- package/src/review/verdict-items.ts +73 -0
- package/src/review/verdict-write.ts +15 -0
- package/src/review/wait.ts +85 -0
- package/src/review/watchers.ts +22 -9
- package/src/scaffold/files/claude-settings-local.json +2 -0
- package/src/secrets/archive-mark.ts +52 -0
- package/src/secrets/archive.ts +83 -0
- package/src/secrets/copy.ts +14 -14
- package/src/secrets/keychain-write.ts +48 -0
- package/src/secrets/keychain.ts +8 -5
- package/src/secrets/lapse-mark.ts +33 -0
- package/src/secrets/lapse.ts +60 -0
- package/src/secrets/list.ts +16 -22
- package/src/secrets/manager.ts +31 -16
- package/src/secrets/read.ts +161 -33
- package/src/secrets/tail.ts +31 -0
- package/src/serve/hub-app/asks-page.tsx +2 -1
- package/src/serve/hub-app/auto-text.tsx +14 -6
- package/src/serve/hub-app/benign-errors.ts +15 -1
- package/src/serve/hub-app/card-head.tsx +49 -0
- package/src/serve/hub-app/check-view.tsx +3 -2
- package/src/serve/hub-app/code-copy.ts +35 -0
- package/src/serve/hub-app/col-card.tsx +31 -40
- package/src/serve/hub-app/col-list-page.tsx +5 -2
- package/src/serve/hub-app/col-tables-view.tsx +7 -4
- package/src/serve/hub-app/col-tables.ts +5 -5
- package/src/serve/hub-app/cols-svc.ts +4 -79
- package/src/serve/hub-app/commands/commands-page.tsx +2 -1
- package/src/serve/hub-app/controls.css +83 -0
- package/src/serve/hub-app/frames-st.ts +17 -1
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/home-st.ts +57 -6
- package/src/serve/hub-app/home-strip.css +1 -6
- package/src/serve/hub-app/home-strip.tsx +2 -1
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/house-wiki-view.tsx +20 -0
- package/src/serve/hub-app/hub-app.tsx +48 -32
- package/src/serve/hub-app/hub-types.ts +2 -0
- package/src/serve/hub-app/hub.css +50 -61
- package/src/serve/hub-app/icons.tsx +14 -4
- package/src/serve/hub-app/identities-view.tsx +4 -3
- package/src/serve/hub-app/inbox-st.ts +203 -42
- package/src/serve/hub-app/inbox-view.tsx +189 -101
- package/src/serve/hub-app/inbox.css +47 -44
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/instructions.css +30 -0
- package/src/serve/hub-app/keys.ts +5 -3
- package/src/serve/hub-app/machine-st.ts +2 -2
- package/src/serve/hub-app/machines-view.tsx +4 -11
- package/src/serve/hub-app/machines.css +0 -9
- package/src/serve/hub-app/markdown.css +51 -0
- package/src/serve/hub-app/md-copy.tsx +18 -40
- package/src/serve/hub-app/md.ts +25 -9
- package/src/serve/hub-app/media-view.tsx +2 -2
- package/src/serve/hub-app/messages/messages-page.tsx +2 -1
- package/src/serve/hub-app/messages/messages-st.ts +1 -1
- package/src/serve/hub-app/messages.css +0 -1
- package/src/serve/hub-app/objects.css +51 -0
- package/src/serve/hub-app/page-keys.ts +1 -1
- package/src/serve/hub-app/pages-frames.tsx +11 -1
- package/src/serve/hub-app/palette-st.ts +4 -4
- package/src/serve/hub-app/pane-boundary.tsx +72 -0
- package/src/serve/hub-app/pane-errors.ts +54 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/planned-view.tsx +3 -3
- package/src/serve/hub-app/planned.css +0 -4
- package/src/serve/hub-app/processes-view.tsx +3 -2
- package/src/serve/hub-app/project-list.css +5 -13
- package/src/serve/hub-app/project-list.tsx +3 -6
- package/src/serve/hub-app/projects-svc.ts +6 -2
- package/src/serve/hub-app/readme.css +9 -15
- package/src/serve/hub-app/reflections-page.tsx +54 -1
- package/src/serve/hub-app/releases/releases-page.tsx +3 -2
- package/src/serve/hub-app/releases.css +0 -1
- package/src/serve/hub-app/review/code-colors.ts +30 -0
- package/src/serve/hub-app/review/diff-view.tsx +75 -0
- package/src/serve/hub-app/review/dock.tsx +104 -0
- package/src/serve/hub-app/review/draft-card.tsx +2 -2
- package/src/serve/hub-app/review/group-block.tsx +209 -0
- package/src/serve/hub-app/review/instructions-view.tsx +116 -0
- package/src/serve/hub-app/review/item-verdict.tsx +38 -0
- package/src/serve/hub-app/review/kind-states.tsx +193 -0
- package/src/serve/hub-app/review/kind-view.tsx +1 -37
- package/src/serve/hub-app/review/kit.tsx +57 -54
- package/src/serve/hub-app/review/lane-bar.tsx +64 -0
- package/src/serve/hub-app/review/object-card.tsx +62 -0
- package/src/serve/hub-app/review/object-panel.tsx +179 -0
- package/src/serve/hub-app/review/question-views.tsx +385 -0
- package/src/serve/hub-app/review/review-cells.tsx +86 -105
- package/src/serve/hub-app/review/review-list.tsx +104 -47
- package/src/serve/hub-app/review/review-page.tsx +5 -4
- package/src/serve/hub-app/review/review-st.ts +68 -28
- package/src/serve/hub-app/review/review-thread.tsx +171 -40
- package/src/serve/hub-app/review/review-views.tsx +35 -31
- package/src/serve/hub-app/review/thread-close.tsx +124 -0
- package/src/serve/hub-app/review/thread-control.tsx +4 -4
- package/src/serve/hub-app/review/thread-st.ts +222 -22
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
- package/src/serve/hub-app/review.css +216 -57
- package/src/serve/hub-app/section-head.tsx +51 -0
- package/src/serve/hub-app/social/calendar.tsx +5 -11
- package/src/serve/hub-app/social/comms-page.tsx +23 -10
- package/src/serve/hub-app/social/kit.tsx +8 -15
- package/src/serve/hub-app/social/next-release.tsx +3 -5
- package/src/serve/hub-app/social/post-card.tsx +3 -0
- package/src/serve/hub-app/social/post-page.tsx +80 -0
- package/src/serve/hub-app/social/problems.tsx +5 -9
- package/src/serve/hub-app/social/social-model.ts +13 -5
- package/src/serve/hub-app/social/social-page.tsx +1 -1
- package/src/serve/hub-app/social/social-st.ts +42 -5
- package/src/serve/hub-app/social.css +7 -17
- package/src/serve/hub-app/space.css +1 -1
- package/src/serve/hub-app/stores/stores-page.tsx +6 -2
- package/src/serve/hub-app/thread-row.tsx +101 -0
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-view.tsx +2 -1
- package/src/serve/hub-app/time.css +2 -5
- package/src/serve/hub-app/tree-row.tsx +1 -9
- package/src/serve/hub-app/vault-view.tsx +4 -4
- package/src/serve/hub-app/veille/veille-page.tsx +2 -11
- package/src/serve/hub-app/veille.css +0 -1
- package/src/serve/hub-app/waiting-svc.ts +4 -4
- package/src/serve/hub-app/when-view.tsx +6 -3
- package/src/serve/hub-app/wiki-st.ts +30 -4
- package/src/serve/hub-app/wikis-view.tsx +4 -3
- package/src/serve/hub-runtime.ts +20 -6
- package/src/serve/project-gutter-route.ts +16 -6
- package/src/serve/project-gutter.ts +6 -53
- package/src/serve/same-origin.ts +3 -0
- package/src/serve/secret-gate.ts +21 -0
- package/src/serve/serve-hub.ts +29 -20
- package/src/serve/tailnet-caller.ts +117 -0
- package/src/shipkit.ts +2 -2
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -4
- package/src/social/brands.ts +4 -0
- package/src/social/card-drafts.ts +11 -19
- package/src/social/desk-index.ts +34 -13
- package/src/social/drafts.ts +4 -4
- package/src/social/import-drafts.ts +244 -0
- package/src/social/kind-pages.ts +3 -3
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +89 -64
- package/src/social/media-kind.ts +68 -161
- package/src/social/media-of.ts +5 -4
- package/src/social/open.ts +3 -2
- package/src/social/post-object.ts +120 -0
- package/src/social/post-sources.ts +136 -0
- package/src/social/post-text.ts +103 -0
- package/src/social/posts.ts +378 -0
- package/src/social/presence.ts +7 -5
- package/src/social/publish/index.ts +17 -5
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +58 -57
- package/src/social/routes.ts +64 -24
- package/src/social/stage.ts +42 -57
- package/src/social/text.ts +4 -3
- package/src/social/thumbnail.ts +135 -43
- package/src/social/tracker.ts +1 -1
- package/src/social/writes.ts +12 -29
- package/src/stores/desk.ts +16 -11
- package/src/stores/unit.ts +2 -2
- package/src/trailer/sound/eleven.ts +33 -3
- package/src/urls/rows.ts +1 -1
- package/src/vault/vault-http.ts +11 -3
- package/src/vault/vault-import.ts +6 -1
- package/src/veille/identity.ts +2 -2
- package/src/wiki/graph-pages.ts +13 -1
- package/src/wiki/scan-md.ts +1 -1
- package/src/asks/asks-queue.ts +0 -424
- package/src/messages/suggest.ts +0 -96
- package/src/social/migrate.ts +0 -123
package/src/review/model.ts
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
// hub and every CLI write at once with no lost update. Pure and browser safe: the store, the routes and the hub page
|
|
5
5
|
// share it. The on disk shape is the one a project's own review store writes, verbatim, so either store opens in the other.
|
|
6
6
|
import type { MediaFact } from '../media-store/fact.ts'
|
|
7
|
+
import type { KindColor } from './glyphs.ts'
|
|
8
|
+
import type { HoldsOpen } from './holds.ts'
|
|
9
|
+
import type { StepChoice } from './instructions.ts'
|
|
7
10
|
import { versionOf } from '../trailer/versions.ts'
|
|
11
|
+
import { SECRET_NAME } from '../secrets/name.ts'
|
|
8
12
|
|
|
9
13
|
/** WHAT is judged: `shot` (a plain image or clip), `screen`, `frame` (a frame of a trailer cut), or a kind a repo names
|
|
10
14
|
* for itself (a game's place, creature, song...), read as is */
|
|
@@ -46,17 +50,59 @@ export interface PostSubject extends Subject {
|
|
|
46
50
|
|
|
47
51
|
export const isPostSubject = (s: Subject): s is PostSubject => s.kind === 'post' && typeof s.card === 'string' && s.card !== ''
|
|
48
52
|
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
53
|
+
/** how two states of an object of a kind draw (wiki tools/shipkit/threads-how-it-fits.md, Kinds): its view twice, one
|
|
54
|
+
* shared state (one camera), or a table of its json fields; `diff.page` wins over both */
|
|
55
|
+
export const DIFF_DRAWS = ['views', 'fields'] as const
|
|
56
|
+
export type DiffDraw = (typeof DIFF_DRAWS)[number]
|
|
57
|
+
|
|
58
|
+
/** a question a kind asks of the owner: its words, and its answer: one of its options, or words */
|
|
59
|
+
export interface KindQuestion {
|
|
60
|
+
text: string
|
|
61
|
+
options?: readonly string[]
|
|
62
|
+
answer?: 'option' | 'words'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** a button the owner clicks on an object of a kind: a message the thread holds, which the holder's watch prints */
|
|
66
|
+
export interface KindAction {
|
|
67
|
+
label: string
|
|
68
|
+
icon?: string
|
|
69
|
+
/** what the holder does on it, one line, shown as the button's tooltip */
|
|
70
|
+
what?: string
|
|
71
|
+
/** the click opens a word box: the owner's words ride with the action */
|
|
72
|
+
words?: boolean
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** one kind of object a thread is about, declared once (wiki tools/shipkit/threads-how-it-fits.md, Kinds): the house's
|
|
76
|
+
* (review/kinds.ts) and a repo's `review({ kinds })` the same way. The pure part the model, the store and the hub read;
|
|
77
|
+
* review/unit.ts adds what runs on the server (read, apply, the data view) */
|
|
51
78
|
export interface SpecKind {
|
|
79
|
+
/** the word the threads list filters by */
|
|
52
80
|
label: string
|
|
81
|
+
/** its icon: SVG path data on the hub's 20 unit grid, one stroke (review/glyphs.ts); none, a neutral square */
|
|
53
82
|
icon?: string
|
|
83
|
+
/** its icon's colour, one of the kind hues (review/glyphs.ts KIND_HUES); none, the muted text colour */
|
|
84
|
+
color?: KindColor
|
|
85
|
+
/** the key's shape as an agent types it after `<kind>:` (`<species>`, `<screen>[/<part>]`): a kind with one, or with
|
|
86
|
+
* a `key`, names objects; one with neither is a subject kind only */
|
|
87
|
+
address?: string
|
|
54
88
|
/** what names one subject of this kind exactly, the kind left out; null names nothing */
|
|
55
89
|
key?(s: Subject): string | null
|
|
56
90
|
/** two subjects of this kind, in one topic, close enough to be one card */
|
|
57
91
|
near?(a: Subject, b: Subject): boolean
|
|
58
92
|
/** what is wrong with a subject of this kind; empty: nothing */
|
|
59
93
|
problems?(s: Subject): string[]
|
|
94
|
+
/** a page of the repo that draws ONE object from its state; its frame keys: threads-how-it-fits.md, The frame keys */
|
|
95
|
+
view?: { page: string }
|
|
96
|
+
/** how a change of an object of this kind draws: `draw` (`views` by default when the kind has a view, else `fields`),
|
|
97
|
+
* each json field's house value kind (`fields`: `color`, `code:<lang>`…), or a page of the repo that draws the whole
|
|
98
|
+
* change, which wins */
|
|
99
|
+
diff?: { draw?: DiffDraw; fields?: Record<string, string>; page?: string }
|
|
100
|
+
/** the questions this kind asks, by name */
|
|
101
|
+
questions?: Record<string, KindQuestion>
|
|
102
|
+
/** the buttons on an object of this kind, by name */
|
|
103
|
+
actions?: Record<string, KindAction>
|
|
104
|
+
/** an object of this kind attached to a thread holds it open until its condition is met (review/holds.ts) */
|
|
105
|
+
holdsOpen?: HoldsOpen
|
|
60
106
|
}
|
|
61
107
|
|
|
62
108
|
/** an area raised items are routed to, and the pages its worker reads first */
|
|
@@ -75,7 +121,9 @@ export interface Spec {
|
|
|
75
121
|
}
|
|
76
122
|
|
|
77
123
|
/** the kinds every repo has, whatever its unit declares */
|
|
78
|
-
|
|
124
|
+
/** the house kinds: review/kinds.ts owns them, the one registry */
|
|
125
|
+
export { HOUSE_KINDS as BUILTIN_KINDS } from './kinds.ts'
|
|
126
|
+
import { HOUSE_KINDS as BUILTIN_KINDS } from './kinds.ts'
|
|
79
127
|
|
|
80
128
|
export const NO_SPEC: Spec = { kinds: {}, topics: {}, dispatcher: false }
|
|
81
129
|
|
|
@@ -98,14 +146,56 @@ export type Origin =
|
|
|
98
146
|
/** an object's address (wiki tools/shipkit/threads-store.md, Addresses): one thread per address, for its whole life */
|
|
99
147
|
export const ADDRESS_RE = /^[a-z][a-z0-9-]*:[^\n]+$/
|
|
100
148
|
|
|
149
|
+
const canonical = new Map<string, string | null>()
|
|
150
|
+
|
|
151
|
+
/** an address in its one form, null when it is none (wiki tools/shipkit/threads-store.md, Addresses): trimmed and
|
|
152
|
+
* lowercased, no space around the colon, no empty or trailing `/`; a cut's file is its cut, a bare kept version the main
|
|
153
|
+
* cut (`trailer:x/v15`); `page:review` is `page:threads`. Every address written, read or compared goes through it */
|
|
154
|
+
export function canonicalAddress(raw: string): string | null {
|
|
155
|
+
const held = canonical.get(raw)
|
|
156
|
+
if (held !== undefined) return held
|
|
157
|
+
let a = raw.trim()
|
|
158
|
+
const file = /^trailer\/([^/\s]+)\/([^\s]+?)(?:\.trailer)?$/i.exec(a)
|
|
159
|
+
if (file) a = `trailer:${file[1]}/${file[2]}`
|
|
160
|
+
const colon = a.indexOf(':')
|
|
161
|
+
const kind = colon > 0 ? a.slice(0, colon).trim().toLowerCase() : ''
|
|
162
|
+
// a file's path and a branch's name keep their case: git and the disk read them case sensitive
|
|
163
|
+
const typed = colon > 0 ? a.slice(colon + 1).trim() : ''
|
|
164
|
+
let key = (kind === 'file' || kind === 'branch' ? typed : typed.toLowerCase()).replace(/\/+/g, '/').replace(/^\/|\/$/g, '')
|
|
165
|
+
if (kind === 'trailer') {
|
|
166
|
+
const parts = key.replace(/\.trailer$/, '').split('/')
|
|
167
|
+
if (parts.length >= 2 && /^v\d+$/.test(parts[1] ?? '')) parts[1] = versionOf(parts[1] ?? '')?.cut ?? parts[1] ?? ''
|
|
168
|
+
key = parts.join('/')
|
|
169
|
+
}
|
|
170
|
+
// an ask is named by its file: `ask:<id>.md` and `ask:<id>` are one thread
|
|
171
|
+
if (kind === 'ask') key = key.replace(/\.md$/, '')
|
|
172
|
+
let out: string | null = `${kind}:${key}`
|
|
173
|
+
if (out === 'page:review' || out.startsWith('page:review/')) out = `page:threads${out.slice('page:review'.length)}`
|
|
174
|
+
if (!/^[a-z][a-z0-9-]*$/.test(kind) || key === '' || /\s/.test(key) || !ADDRESS_RE.test(out)) out = null
|
|
175
|
+
canonical.set(raw, out)
|
|
176
|
+
return out
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** an address as typed, in its one form, or a one line refusal that names the form */
|
|
180
|
+
export function addressOrThrow(raw: string): string {
|
|
181
|
+
const a = canonicalAddress(raw)
|
|
182
|
+
if (a !== null) return a
|
|
183
|
+
const colon = raw.indexOf(':')
|
|
184
|
+
if (colon > 0 && /\s/.test(raw.slice(colon + 1).trim())) throw new Error(`« ${raw.trim()} »: an address has no space: ${raw.trim().replace(/\s*:\s*/, ':').replace(/\s+/g, '-').toLowerCase()} ?`)
|
|
185
|
+
throw new Error(`« ${raw.trim()} » is no address: <kind>:<key>, like screen:orders/list, asset:sword or trailer:<name>/<cut>`)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** an address as stored, in its one form; a stored one that reads as none stays as it was */
|
|
189
|
+
const canon = (a: string): string => canonicalAddress(a) ?? a
|
|
190
|
+
|
|
101
191
|
/** a trailer's cut as an address: a kept version names the cut it was kept from, so every version is one thread. A
|
|
102
192
|
* card names its cut itself; a name alone (an older card, a frame note) is read as a kept version when it reads as one */
|
|
103
|
-
export const cutAddress = (trailer: string, cut: string, of?: string): string => `trailer:${trailer}/${of ?? versionOf(cut)?.cut ?? cut}`
|
|
193
|
+
export const cutAddress = (trailer: string, cut: string, of?: string): string => canon(`trailer:${trailer}/${of ?? versionOf(cut)?.cut ?? cut}`)
|
|
104
194
|
|
|
105
195
|
/** the address that is an item's own: the one its agent named, else its subject's (a trailer card or a frame note: the
|
|
106
196
|
* cut); null when it names none (a plain shot). One thread per own address */
|
|
107
197
|
export function ownAddressOf(i: Item, spec: Spec = NO_SPEC): string | null {
|
|
108
|
-
if (i.on !== undefined) return i.on
|
|
198
|
+
if (i.on !== undefined) return canon(i.on)
|
|
109
199
|
if (i.trailer) return cutAddress(i.trailer.trailer, i.trailer.after.cut, i.trailer.cut)
|
|
110
200
|
if (isFrame(i.subject)) return cutAddress(i.subject.trailer, i.subject.cut)
|
|
111
201
|
return subjectKey(i.subject, spec)
|
|
@@ -120,10 +210,15 @@ export function parentAddress(a: string): string | null {
|
|
|
120
210
|
/** every address one item names: its own, then the objects it is about */
|
|
121
211
|
export function addressesOf(i: Item, spec: Spec = NO_SPEC): string[] {
|
|
122
212
|
const own = ownAddressOf(i, spec)
|
|
123
|
-
return [...new Set([...(own !== null ? [own] : []), ...(i.about ?? [])])]
|
|
213
|
+
return [...new Set([...(own !== null ? [own] : []), ...(i.about ?? []).map(canon)])]
|
|
124
214
|
}
|
|
125
215
|
|
|
126
216
|
export function subjectKey(s: Subject, spec: Spec = NO_SPEC): string | null {
|
|
217
|
+
const k = subjectKeyRaw(s, spec)
|
|
218
|
+
return k === null ? null : canon(k)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function subjectKeyRaw(s: Subject, spec: Spec): string | null {
|
|
127
222
|
// any object the hub shows, by its address: his note from its thread control
|
|
128
223
|
if (s.kind === 'object') return typeof s.address === 'string' && ADDRESS_RE.test(s.address) ? s.address : null
|
|
129
224
|
if (isFrame(s)) return `frame:${s.trailer}/${s.cut}/${s.shot}`
|
|
@@ -177,6 +272,8 @@ export interface MediaView {
|
|
|
177
272
|
marks?: ReviewMark[]
|
|
178
273
|
/** a line on this view alone (an option's description on a choice card) */
|
|
179
274
|
note?: string
|
|
275
|
+
/** a message holds it (an update, a question's option, a proposed sound): it draws in that message's cell */
|
|
276
|
+
message?: true
|
|
180
277
|
}
|
|
181
278
|
|
|
182
279
|
/** one image of a gallery view, a file of the folder (`v<n>-g<k>.<ext>`) */
|
|
@@ -269,8 +366,70 @@ export interface Item {
|
|
|
269
366
|
trailer?: TrailerCard
|
|
270
367
|
/** a draft card: its body shows this post draft read live, a block a message, never a picture of it */
|
|
271
368
|
draft?: DraftCard
|
|
369
|
+
/** a version of an object of a kind (its `on`): the object's two states as its kind read them when it was posted,
|
|
370
|
+
* drawn by the kind's diff (wiki tools/shipkit/threads-how-it-fits.md, Kinds) */
|
|
371
|
+
states?: { before?: StoredState; after: StoredState }
|
|
272
372
|
/** each media file the views name, by its name: what the Space keeps it under once the disk lets it go */
|
|
273
373
|
media?: Record<string, MediaFact>
|
|
374
|
+
/** an ask's facts, on the head of its thread `ask:<id>` (asks/ask-store.ts): its status and closed day are the
|
|
375
|
+
* thread's askState messages, its later day the thread's snooze, its body `what` */
|
|
376
|
+
ask?: AskHead
|
|
377
|
+
/** it waits for the owner's verdict: set by `--verdict`; an agent's version asks it always, an opening of words only with it */
|
|
378
|
+
asksVerdict?: true
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** a thread head that is an ask: on `ask:<id>` with its facts. The one test of « is an ask », for every reader */
|
|
382
|
+
export const isAskItem = (i: Pick<Item, 'on' | 'ask'>): boolean => i.ask !== undefined && (i.on ?? '').startsWith('ask:')
|
|
383
|
+
|
|
384
|
+
/** what an ask asks of the owner's hands; `answer` a question only he answers */
|
|
385
|
+
export const ASK_KINDS = ['action', 'purchase', 'credential', 'decision', 'answer'] as const
|
|
386
|
+
export type AskKind = (typeof ASK_KINDS)[number]
|
|
387
|
+
/** the other spellings a kind was written with, read as the one kind */
|
|
388
|
+
export const ASK_KIND_ALIASES: Readonly<Record<string, AskKind>> = { cred: 'credential', token: 'credential' }
|
|
389
|
+
/** the kind a word names, null for none */
|
|
390
|
+
export const askKindOf = (w: string): AskKind | null => ((ASK_KINDS as readonly string[]).includes(w) ? (w as AskKind) : (ASK_KIND_ALIASES[w] ?? null))
|
|
391
|
+
|
|
392
|
+
/** a warning an ask holds: the check that prints it and words of that one line */
|
|
393
|
+
export interface AskWait {
|
|
394
|
+
check: string
|
|
395
|
+
says: string
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** an ask's facts that its thread's messages do not already say */
|
|
399
|
+
export interface AskHead {
|
|
400
|
+
kind: AskKind
|
|
401
|
+
/** the day it was made, YYYY-MM-DD */
|
|
402
|
+
created: string
|
|
403
|
+
/** what it blocks, `-` for nothing named */
|
|
404
|
+
blocks: string
|
|
405
|
+
/** the shell probe that exits 0 once it is done */
|
|
406
|
+
check?: string
|
|
407
|
+
waits?: AskWait[]
|
|
408
|
+
/** the secret names a credential ask stores */
|
|
409
|
+
secrets?: string[]
|
|
410
|
+
/** those of its secrets stored with an account beside the value */
|
|
411
|
+
logins?: string[]
|
|
412
|
+
/** the day its one ping went, YYYY-MM-DD: never a second */
|
|
413
|
+
pinged?: string
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const DAY_RE = /^\d{4}-\d{2}-\d{2}$/
|
|
417
|
+
|
|
418
|
+
/** every reason a value is not an ask's head; empty, it is one */
|
|
419
|
+
export function askHeadProblems(v: unknown): string[] {
|
|
420
|
+
if (!obj(v)) return ['ask: { kind, created, blocks, … }']
|
|
421
|
+
const out: string[] = []
|
|
422
|
+
if (!(ASK_KINDS as readonly unknown[]).includes(v.kind)) out.push(`ask.kind: one of ${ASK_KINDS.join(', ')}`)
|
|
423
|
+
if (typeof v.created !== 'string' || !DAY_RE.test(v.created)) out.push('ask.created: YYYY-MM-DD')
|
|
424
|
+
if (typeof v.blocks !== 'string' || v.blocks === '') out.push('ask.blocks: a text, - for none')
|
|
425
|
+
if (v.check !== undefined && (typeof v.check !== 'string' || v.check.trim() === '')) out.push('ask.check: a shell line')
|
|
426
|
+
if (v.pinged !== undefined && (typeof v.pinged !== 'string' || !DAY_RE.test(v.pinged))) out.push('ask.pinged: YYYY-MM-DD')
|
|
427
|
+
const names = (x: unknown): boolean => Array.isArray(x) && x.every((n) => typeof n === 'string' && n !== '')
|
|
428
|
+
if (v.secrets !== undefined && !names(v.secrets)) out.push('ask.secrets: a list of secret names')
|
|
429
|
+
if (v.logins !== undefined && !(names(v.logins) && (v.logins as string[]).every((l) => Array.isArray(v.secrets) && v.secrets.includes(l)))) out.push('ask.logins: names among its secrets')
|
|
430
|
+
if (v.waits !== undefined && !(Array.isArray(v.waits) && v.waits.every((w) => obj(w) && typeof w.check === 'string' && w.check !== '' && typeof w.says === 'string' && w.says.trim() !== '')))
|
|
431
|
+
out.push('ask.waits: a list of { check, says }, the words required')
|
|
432
|
+
return out
|
|
274
433
|
}
|
|
275
434
|
|
|
276
435
|
/** one render a trailer card plays: the cut, and the render pinned by its mtime in ms */
|
|
@@ -447,8 +606,10 @@ export interface ReviewReaction {
|
|
|
447
606
|
picked?: true
|
|
448
607
|
}
|
|
449
608
|
|
|
450
|
-
/** a state change,
|
|
451
|
-
|
|
609
|
+
/** a state change, a read mark (`seen`, with the ids it read in `of`), a take (`take`: an agent holds the thread
|
|
610
|
+
* from now on, its state unchanged; review/parties.ts), or an agent on it (`working`, its line in `note`, none ends
|
|
611
|
+
* it; review/traces.ts) */
|
|
612
|
+
export const OPS = ['dispatch', 'ask', 'answer', 'reassign', 'claim', 'release', 'blocked', 'fixed', 'done', 'wontfix', 'drop', 'withdraw', 'reopen', 'ready', 'seen', 'take', 'working'] as const
|
|
452
613
|
export type Op = (typeof OPS)[number]
|
|
453
614
|
|
|
454
615
|
/** what an agent's update says of the work, at a glance: still broken, better, or fixed (it asks the owner's verdict again) */
|
|
@@ -497,26 +658,145 @@ export interface Message {
|
|
|
497
658
|
about?: string[]
|
|
498
659
|
/** a question to the owner: its words in `text`, its options, the option the agent picks */
|
|
499
660
|
ask?: MessageAsk
|
|
661
|
+
/** a question that is a field inside a step of an ask's instructions (`of`: their message id, `i`: the step): drawn
|
|
662
|
+
* in that step, never beside it; the step counts ticked once its every field is answered (review/instructions.ts) */
|
|
663
|
+
step?: { of: string; i: number }
|
|
500
664
|
/** a change the agent proposes on an object's text: its words in `text` */
|
|
501
665
|
propose?: MessagePropose
|
|
666
|
+
/** the owner clicked one of the kind's actions on the thread's object */
|
|
667
|
+
action?: MessageAction
|
|
668
|
+
/** an ask's thread: its ask closed (done, declined) or opened again; a closed ask asks nothing more */
|
|
669
|
+
askState?: { state: 'open' | 'done' | 'declined'; why?: string }
|
|
670
|
+
/** a thread set aside until `until` (an ISO time), his from the hub or an agent's when it posts; null brings it back */
|
|
671
|
+
snooze?: { until: string | null }
|
|
672
|
+
/** an agent's message that brings back a thread set aside (wiki tools/shipkit/threads-asks.md, Snooze) */
|
|
673
|
+
urgent?: true
|
|
502
674
|
/** his answer to the question or the proposal `re` names: the option he clicked, or « apply » (an edit his `text`) */
|
|
503
675
|
answer?: MessageAnswer
|
|
504
|
-
|
|
505
|
-
|
|
676
|
+
/** the agent's object of the same thread (a question, a change, its words) this newer one supersedes, by its message
|
|
677
|
+
* id (wiki tools/shipkit/threads-asks.md, Superseded objects) */
|
|
678
|
+
replaces?: string
|
|
679
|
+
/** an ask's questions that its bar answers (« done ✓ », « I will not do this », the proof url), by their message ids:
|
|
680
|
+
* drawn nowhere, docked nowhere, waiting on nobody (wiki tools/shipkit/threads-asks.md, The ask bar) */
|
|
681
|
+
askBar?: string[]
|
|
682
|
+
/** an ask's instructions after its first, superseding the ones before it in the store's order: its words in `text`,
|
|
683
|
+
* its title, its facts as they stand now (its day and its ping stay the head's), and the questions it folds */
|
|
684
|
+
instructions?: { title: string; ask: Omit<AskHead, 'created' | 'pinged'>; folds: string[] }
|
|
685
|
+
/** an agent's message that waits for the owner's verdict; the owner's answer is the owner's message with `verdict` and `re` naming it
|
|
686
|
+
* (review/verdict-items.ts) */
|
|
687
|
+
asksVerdict?: true
|
|
688
|
+
/** the machine's: an attached object's hold flipped (review/holds.ts), its words in `text` */
|
|
689
|
+
hold?: { address: string; held: boolean; sha?: string; ahead?: number }
|
|
690
|
+
/** the owner's close of a held thread: the holds it releases, by address */
|
|
691
|
+
unhold?: string[]
|
|
692
|
+
/** the owner asks for a lane on the thread (review/lane-ask.ts): the owner's words in `text`, the orchestrator it
|
|
693
|
+
* waited on when asked; no reply, the thread's holder never hears it as one */
|
|
694
|
+
laneAsk?: { for: string; session?: string }
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** what a question asks him for (wiki tools/shipkit/threads-asks.md, Answer kinds); absent on a question, a choice */
|
|
698
|
+
export const ANSWER_KINDS = ['choice', 'checklist', 'confirm', 'text', 'url', 'secret', 'file'] as const
|
|
699
|
+
export type AnswerKind = (typeof ANSWER_KINDS)[number]
|
|
700
|
+
|
|
701
|
+
/** `options`: a choice's options, a checklist's lines, empty for the other kinds */
|
|
506
702
|
export interface MessageAsk {
|
|
703
|
+
kind?: AnswerKind
|
|
507
704
|
options: string[]
|
|
508
705
|
pick?: number
|
|
706
|
+
/** option i's media: the item's view that holds it, null for words alone */
|
|
707
|
+
views?: (number | null)[]
|
|
708
|
+
/** a checklist's lines done before he looked, ticked from the start */
|
|
709
|
+
done?: number[]
|
|
710
|
+
/** an ask's instructions: each step's choice, its options as markdown lines and the agent's pick, null a step with
|
|
711
|
+
* none (review/instructions.ts); his pick rides on his tick of that step */
|
|
712
|
+
choices?: (StepChoice | null)[]
|
|
713
|
+
/** a secret's name in the house secret manager; `login`: an account goes with it */
|
|
714
|
+
secret?: { name: string; login?: true }
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/** how one field of a proposed change draws: a house kind (review/kinds.ts) */
|
|
718
|
+
export { DIFF_TYPES, type DiffType } from './kinds.ts'
|
|
719
|
+
import { DIFF_TYPES, sniffKind, type DiffType } from './kinds.ts'
|
|
720
|
+
|
|
721
|
+
/** one field of a proposed change: its value before and after, how it draws; a sound's pair is a view of the item */
|
|
722
|
+
export interface ProposeField {
|
|
723
|
+
key: string
|
|
724
|
+
before?: string
|
|
725
|
+
after: string
|
|
726
|
+
type?: DiffType
|
|
727
|
+
lang?: string
|
|
728
|
+
view?: number
|
|
509
729
|
}
|
|
510
730
|
|
|
511
|
-
|
|
731
|
+
/** one field flat (`key` empty), or several in `fields`, `after` then their lines for an older reader */
|
|
732
|
+
export interface MessagePropose extends Omit<ProposeField, 'key'> {
|
|
512
733
|
on: string
|
|
513
|
-
|
|
514
|
-
|
|
734
|
+
fields?: ProposeField[]
|
|
735
|
+
/** the repo's page that draws the change, its kind's `diff.page` when it was proposed */
|
|
736
|
+
page?: string
|
|
515
737
|
}
|
|
516
738
|
|
|
517
739
|
export interface MessageAnswer {
|
|
518
740
|
option?: number
|
|
519
741
|
apply?: true
|
|
742
|
+
/** the one field it applies; none only on a change of one field */
|
|
743
|
+
field?: string
|
|
744
|
+
/** the value he applied, the owner's edit or the agent's as it is; `text` keeps the owner's words, else the value; a
|
|
745
|
+
* text or a url question's answer */
|
|
746
|
+
value?: string
|
|
747
|
+
/** a checklist's line (`option`) ticked or unticked; a confirm's « done » */
|
|
748
|
+
tick?: boolean
|
|
749
|
+
/** on a tick of a choice step of an ask's instructions: the option he clicked */
|
|
750
|
+
pick?: number
|
|
751
|
+
/** a url answer: the status it opened with, 0 when it did not open */
|
|
752
|
+
opens?: number
|
|
753
|
+
/** a secret answer: the name its value went under; the value is never in the store */
|
|
754
|
+
stored?: string
|
|
755
|
+
/** a file answer: the item's view that holds the file */
|
|
756
|
+
view?: number
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** the fields of a proposed change as a list, one for the flat form */
|
|
760
|
+
export const proposeFields = (p: MessagePropose): ProposeField[] =>
|
|
761
|
+
p.fields ?? [{ key: '', after: p.after, ...(p.before !== undefined ? { before: p.before } : {}), ...(p.type ? { type: p.type } : {}), ...(p.lang ? { lang: p.lang } : {}), ...(p.view !== undefined ? { view: p.view } : {}) }]
|
|
762
|
+
|
|
763
|
+
/** each field of the proposal `m` he applied, by its key: the value he applied and when. An apply that names no field
|
|
764
|
+
* is a change of one field, or an older one that applied every field as proposed */
|
|
765
|
+
export function appliedFields(thread: readonly Message[], m: Message): Map<string, { text: string; at: string }> {
|
|
766
|
+
const out = new Map<string, { text: string; at: string }>()
|
|
767
|
+
if (!m.propose) return out
|
|
768
|
+
const fields = proposeFields(m.propose)
|
|
769
|
+
for (const y of thread) {
|
|
770
|
+
if (y.re !== m.id || y.answer?.apply !== true || partyOf(y.who) !== 'owner') continue
|
|
771
|
+
const named = y.answer.field
|
|
772
|
+
for (const f of fields) {
|
|
773
|
+
if (out.has(f.key) || (named !== undefined && named !== f.key)) continue
|
|
774
|
+
out.set(f.key, { text: y.answer.value ?? (named !== undefined || fields.length === 1 ? (y.text ?? f.after) : f.after), at: y.at })
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return out
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/** a proposal waits on him until each of its fields is applied, or a message of the owner's with words names it */
|
|
781
|
+
export function proposeOpen(thread: readonly Message[], m: Message): boolean {
|
|
782
|
+
if (!m.propose) return false
|
|
783
|
+
if (thread.some((y) => y.re === m.id && y.answer === undefined && partyOf(y.who) === 'owner')) return false
|
|
784
|
+
return appliedFields(thread, m).size < proposeFields(m.propose).length
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/** how a field draws when nothing names it: the first house kind that takes its values, words otherwise */
|
|
788
|
+
export const diffTypeOf = sniffKind
|
|
789
|
+
|
|
790
|
+
/** an object as one side of a change: its json and its files (repo relative), and the git ref it was read at */
|
|
791
|
+
export interface StoredState {
|
|
792
|
+
json: unknown
|
|
793
|
+
files?: Record<string, string>
|
|
794
|
+
at?: string
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** an owner's click on a kind's action (wiki tools/shipkit/threads-how-it-fits.md, Kinds): its name, the owner's words in `text` */
|
|
798
|
+
export interface MessageAction {
|
|
799
|
+
name: string
|
|
520
800
|
}
|
|
521
801
|
|
|
522
802
|
/** what the store reads of one folder, what the list sends */
|
|
@@ -531,10 +811,14 @@ export type Party = 'agent' | 'owner'
|
|
|
531
811
|
export const partyOf = (who: string): Party => (who === 'owner' || who === 'player' ? 'owner' : 'agent')
|
|
532
812
|
|
|
533
813
|
/** a message one party says to the other: a reply, a verdict, a rating, a question and its answer; never another op */
|
|
534
|
-
const isTalk = (m: Message): boolean => m.op === undefined || ((m.op === 'ask' || m.op === 'answer') && m.text !== undefined)
|
|
814
|
+
const isTalk = (m: Message): boolean => m.laneAsk === undefined && (m.op === undefined || ((m.op === 'ask' || m.op === 'answer') && m.text !== undefined))
|
|
815
|
+
|
|
816
|
+
/** the owner's verdict on the version itself; one that names `re` judges that message (review/verdict-items.ts) */
|
|
817
|
+
export const isVersionVerdict = (m: Pick<Message, 'verdict' | 're'>): boolean => m.verdict !== undefined && m.re === undefined
|
|
535
818
|
|
|
536
|
-
/** a reply: talk with words that is no verdict and no rating (a message moving a pin alone is no reply)
|
|
537
|
-
|
|
819
|
+
/** a reply: talk with words that is no verdict on the version and no rating (a message moving a pin alone is no reply);
|
|
820
|
+
* the owner's verdict on a message is the answer the agent reads, words or none */
|
|
821
|
+
export const isReply = (m: Message): boolean => isTalk(m) && !isVersionVerdict(m) && m.rate === undefined && (m.text !== undefined || m.verdict !== undefined)
|
|
538
822
|
|
|
539
823
|
export const MESSAGE_RE = /^\d{8}-\d{6}-\d{3}-(agent|owner|player)(-[a-z0-9]+)*$/
|
|
540
824
|
export const MESSAGE_FILE_RE = /^\d{8}-\d{6}-\d{3}-(agent|owner|player)(-[a-z0-9]+)*\.(png|jpe?g|webp)$/
|
|
@@ -571,9 +855,12 @@ const readBy = (x: ReviewItem, party: Party): Set<string> =>
|
|
|
571
855
|
const isTakeBack = (x: ReviewItem, m: Message): boolean => m.op === 'reopen' && m.who === 'owner' && x.item.origin.by === 'agent'
|
|
572
856
|
|
|
573
857
|
/** the talk of the other party that `party` has not read: replies, verdicts, ratings, his verdicts taken back */
|
|
858
|
+
/** the owner's close or reopen of a whole thread from the hub: heard by its holder and acknowledged like the owner's words */
|
|
859
|
+
const isOwnerClose = (m: Message): boolean => partyOf(m.who) === 'owner' && (m.op === 'fixed' || m.op === 'done' || m.op === 'wontfix' || m.op === 'reopen')
|
|
860
|
+
|
|
574
861
|
const unreadTalk = (x: ReviewItem, party: Party): Message[] => {
|
|
575
862
|
const read = readBy(x, party)
|
|
576
|
-
return x.thread.filter((m) => (isTalk(m) || isTakeBack(x, m)) && partyOf(m.who) !== party && !read.has(m.id))
|
|
863
|
+
return x.thread.filter((m) => (isTalk(m) || isTakeBack(x, m) || isOwnerClose(m)) && partyOf(m.who) !== party && !read.has(m.id))
|
|
577
864
|
}
|
|
578
865
|
|
|
579
866
|
/** each verdict the owner took back that no agent marked seen: his reopen and the verdict it took back */
|
|
@@ -582,7 +869,7 @@ export function takenBackOf(x: ReviewItem): { m: Message; took: ReviewStatus; gi
|
|
|
582
869
|
const out: { m: Message; took: ReviewStatus; given: string }[] = []
|
|
583
870
|
let v: Message | undefined
|
|
584
871
|
for (const n of x.thread) {
|
|
585
|
-
if (n
|
|
872
|
+
if (isVersionVerdict(n)) v = n
|
|
586
873
|
else if (n.op === 'reopen' || isFixedUpdate(n)) {
|
|
587
874
|
if (v?.verdict && isTakeBack(x, n) && unread.has(n.id)) out.push({ m: n, took: v.verdict, given: v.at })
|
|
588
875
|
v = undefined
|
|
@@ -630,7 +917,7 @@ export function verdictOf(x: ReviewItem): Verdict | null {
|
|
|
630
917
|
let rects: Rect[] | undefined
|
|
631
918
|
for (const n of x.thread) {
|
|
632
919
|
if (n.op === 'reopen' || isFixedUpdate(n)) [m, text, rects] = [undefined, undefined, undefined]
|
|
633
|
-
else if (n
|
|
920
|
+
else if (isVersionVerdict(n)) {
|
|
634
921
|
if (m?.verdict !== n.verdict) [text, rects] = [undefined, undefined]
|
|
635
922
|
m = n
|
|
636
923
|
if (n.text !== undefined) text = n.text
|
|
@@ -663,7 +950,7 @@ export const STATUS_LABEL: Record<ShownStatus, string> = {
|
|
|
663
950
|
approved: 'approved',
|
|
664
951
|
'approved-with-fix': 'ok with a fix',
|
|
665
952
|
rejected: 'rejected',
|
|
666
|
-
archived: '
|
|
953
|
+
archived: 'not doing it',
|
|
667
954
|
superseded: 'replaced',
|
|
668
955
|
withdrawn: 'withdrawn',
|
|
669
956
|
raised: 'open',
|
|
@@ -691,13 +978,16 @@ export type Move = 'owner' | 'agents' | 'none'
|
|
|
691
978
|
export const moveOf = (s: State): Move =>
|
|
692
979
|
s === 'asks' || s === 'question' || s === 'blocked' ? 'owner' : s === 'new' || s === 'open' || s === 'claimed' ? 'agents' : 'none'
|
|
693
980
|
|
|
694
|
-
export const MOVE_LABEL: Record<Move, string> = { owner: 'mine', agents:
|
|
981
|
+
export const MOVE_LABEL: Record<Move, string> = { owner: 'mine', agents: "an agent's", none: 'done' }
|
|
982
|
+
|
|
983
|
+
/** a thread an agent opened with words (a question, a proposed change, a line): nothing to judge, so no verdict waits */
|
|
984
|
+
export const isOpening = (i: Item): boolean => i.origin.by === 'agent' && i.on !== undefined && i.views.every((v) => !isGallery(v) && v.message === true) && i.draft === undefined && i.states === undefined
|
|
695
985
|
|
|
696
986
|
/** where an item starts: an agent's card asks for the owner's verdict (a draft waits); what he raises from a tool that named
|
|
697
987
|
* its topic (the trailer view: `film`) is open, else it waits on a dispatcher; an auto rule's item is open */
|
|
698
988
|
const startOf = (i: Item): ItemState =>
|
|
699
989
|
i.origin.by === 'agent'
|
|
700
|
-
? { state: i.wip ? 'draft' : 'asks' }
|
|
990
|
+
? { state: i.wip || (isOpening(i) && i.asksVerdict !== true) ? 'draft' : 'asks' }
|
|
701
991
|
: i.topic || i.origin.by === 'auto'
|
|
702
992
|
? { state: 'open', ...(i.topic ? { topic: i.topic } : {}) }
|
|
703
993
|
: { state: 'new' }
|
|
@@ -712,7 +1002,7 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
|
|
|
712
1002
|
let given: ItemState = s
|
|
713
1003
|
for (const m of x.thread) {
|
|
714
1004
|
const keep = s.topic ? { topic: s.topic } : {}
|
|
715
|
-
if (m.verdict !== undefined) {
|
|
1005
|
+
if (m.verdict !== undefined && isVersionVerdict(m)) {
|
|
716
1006
|
const v = m.verdict
|
|
717
1007
|
// « fix » and « no » owe the lane work: reading the verdict is never doing it (done, wontfix or a new version closes it)
|
|
718
1008
|
if (v === 'approved' || v === 'archived') s = { ...keep, state: 'closed', why: v }
|
|
@@ -727,7 +1017,9 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
|
|
|
727
1017
|
// an agent's update on its card: still broken or better holds it in work, fixed asks the owner's verdict again
|
|
728
1018
|
if (m.update !== undefined && i.origin.by === 'agent' && partyOf(m.who) === 'agent') {
|
|
729
1019
|
if (m.update.state === 'fixed') {
|
|
730
|
-
|
|
1020
|
+
// a thread opened with words holds nothing to judge: fixed ends its work, never asks a verdict
|
|
1021
|
+
if (isOpening(i)) s = { ...keep, state: 'closed', why: 'fixed' }
|
|
1022
|
+
else if (s.state === 'draft' || s.state === 'claimed' || s.state === 'closed') s = { ...keep, state: 'asks' }
|
|
731
1023
|
given = s
|
|
732
1024
|
} else if (s.state === 'asks') s = { ...keep, state: 'draft' }
|
|
733
1025
|
continue
|
|
@@ -794,7 +1086,7 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
|
|
|
794
1086
|
export const inWork = (x: ReviewItem): boolean => stateOf(x, false).state === 'draft'
|
|
795
1087
|
|
|
796
1088
|
/** the states each op leaves from */
|
|
797
|
-
const FROM: Record<Exclude<Op, 'seen'>, readonly State[]> = {
|
|
1089
|
+
const FROM: Record<Exclude<Op, 'seen' | 'take' | 'working'>, readonly State[]> = {
|
|
798
1090
|
dispatch: ['new', 'blocked'],
|
|
799
1091
|
ask: ['new', 'blocked'],
|
|
800
1092
|
answer: ['question'],
|
|
@@ -815,9 +1107,10 @@ const WORKER_OPS = new Set<Op>(['release', 'blocked', 'fixed', 'done', 'wontfix'
|
|
|
815
1107
|
|
|
816
1108
|
/** null when `who` may do `op` on an item in state `s`, else why not. The dispatcher (null: nobody holds the role)
|
|
817
1109
|
* routes, a worker acts on its own claim, the owner answers and may act over a claim. `routed` false: the repo has no
|
|
818
|
-
* dispatcher, so a worker takes a new item as it is
|
|
819
|
-
|
|
820
|
-
|
|
1110
|
+
* dispatcher, so a worker takes a new item as it is; `holds`: the caller holds the item's thread or is the session of
|
|
1111
|
+
* the lane that does */
|
|
1112
|
+
export function allowed(s: ItemState, op: Op, who: string, dispatcher: string | null, routed = true, holds = false): string | null {
|
|
1113
|
+
if (op === 'seen' || op === 'take' || op === 'working') return op !== 'seen' && who === 'owner' ? `an agent ${op === 'take' ? 'takes a thread' : 'says it is on it'}, never the owner` : null
|
|
821
1114
|
if (op === 'answer' && who !== 'owner') return 'only the owner answers a question'
|
|
822
1115
|
if (DISPATCHER_OPS.has(op)) {
|
|
823
1116
|
if (!routed) return 'this repo routes nothing: its review unit declares no dispatcher'
|
|
@@ -826,7 +1119,9 @@ export function allowed(s: ItemState, op: Op, who: string, dispatcher: string |
|
|
|
826
1119
|
}
|
|
827
1120
|
if (!routed && s.state === 'new' && (op === 'claim' || op === 'fixed' || op === 'wontfix')) return op === 'claim' && who === 'owner' ? 'a worker claims, never the owner' : null
|
|
828
1121
|
if (op === 'claim' && (who === 'owner' || who === dispatcher)) return `a worker claims, never ${who === 'owner' ? 'the owner' : 'the dispatcher'}`
|
|
829
|
-
|
|
1122
|
+
// `holds`: the caller holds the thread or is its holder's session (review/parties.ts maySee), so a lane's claim never
|
|
1123
|
+
// locks its session out of its own thread
|
|
1124
|
+
if (WORKER_OPS.has(op) && who !== 'owner' && !holds && s.worker !== undefined && s.worker !== who) return `claimed by ${s.worker}, not by ${who}`
|
|
830
1125
|
if (op === 'claim' && s.state === 'claimed' && s.since !== undefined && s.worker !== who) return `already claimed by ${s.worker}: release it first (--as ${s.worker})`
|
|
831
1126
|
if (op === 'claim' && s.state === 'blocked' && s.worker !== undefined && s.worker !== who) return `blocked by ${s.worker}, who takes it back (--as ${s.worker}); the dispatcher routes it to another`
|
|
832
1127
|
if (op === 'claim' && s.state === 'closed' && s.why !== 'rejected' && s.why !== 'approved-with-fix')
|
|
@@ -871,56 +1166,16 @@ export interface WatchFilter {
|
|
|
871
1166
|
export interface Watcher extends WatchFilter {
|
|
872
1167
|
pid: number
|
|
873
1168
|
started: string
|
|
1169
|
+
/** the session that runs it (CLAUDE_CODE_SESSION_ID), whatever it filters on */
|
|
1170
|
+
by?: string
|
|
1171
|
+
/** its heartbeat, rewritten every few seconds while it reads */
|
|
1172
|
+
beat?: string
|
|
874
1173
|
}
|
|
875
1174
|
|
|
876
1175
|
/** a watch with this filter reads his answers on `x` */
|
|
877
1176
|
export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
|
|
878
1177
|
(f.session === null || (x.item.origin.by === 'agent' && x.item.origin.session === f.session)) && (f.lane === null || laneOf(x) === f.lane)
|
|
879
1178
|
|
|
880
|
-
/** who answers an agent's card, its reply or its seen: the worker of a live claim on it, else the lane that made it,
|
|
881
|
-
* else (a card with no lane) the session that sent it. null when `me` is that one, else why not and the way out.
|
|
882
|
-
* Another session hearing the verdict (a bare watch) is refused, so it never answers over the maker; a plain approval,
|
|
883
|
-
* which owes nothing, anyone marks seen. So does anyone once the maker stopped listening: `heardBy` is the live
|
|
884
|
-
* watches of the store, and when none of a lane or of a session covers the card (the lane ended), whoever reads the
|
|
885
|
-
* answer marks it seen; a reply stays the maker's. An item he raised, a player's or an auto one: the claim rules decide */
|
|
886
|
-
export function notAnswererOf(x: ReviewItem, me: { lane: string | null; session: string | null }, op: 'reply' | 'seen', heardBy?: readonly WatchFilter[]): string | null {
|
|
887
|
-
const o = x.item.origin
|
|
888
|
-
if (o.by !== 'agent') return null
|
|
889
|
-
const s = stateOf(x, false)
|
|
890
|
-
if (op === 'seen' && s.state === 'closed' && s.why === 'approved') return null
|
|
891
|
-
// a bare watch hears every card and is nobody's own: only a watch of a lane or of a session says the maker listens
|
|
892
|
-
if (op === 'seen' && heardBy !== undefined && !heardBy.some((w) => (w.lane !== null || w.session !== null) && coversCard(w, x))) return null
|
|
893
|
-
const id = x.item.id
|
|
894
|
-
// the way out names claim only where claim takes it
|
|
895
|
-
const noClaim = allowed(s, 'claim', me.lane ?? 'agent', null, false)
|
|
896
|
-
const takeOver =
|
|
897
|
-
noClaim === null
|
|
898
|
-
? `another lane takes it over with sk thread claim ${id} --as <lane>`
|
|
899
|
-
: s.state === 'asks' || s.state === 'draft'
|
|
900
|
-
? 'no other lane takes it over before the verdict'
|
|
901
|
-
: `no takeover: ${noClaim}`
|
|
902
|
-
const claimed = s.state === 'claimed' && s.since !== undefined ? s.worker : undefined
|
|
903
|
-
const lane = claimed ?? o.lane
|
|
904
|
-
if (lane) return me.lane === lane ? null : `${id} is answered by lane ${lane} (${claimed ? 'its claim' : 'it made the card'}): as that lane, SK_AGENT=${lane} or --as ${lane}; ${takeOver}`
|
|
905
|
-
if (!o.session || me.session === o.session) return null
|
|
906
|
-
return `${id} is answered by the session that sent it (${o.session.slice(0, 8)}): ${takeOver}`
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
/** the live watchers that will read his answer on any of these cards */
|
|
910
|
-
export const listenersOf = (cards: readonly ReviewItem[], watchers: readonly Watcher[]): Watcher[] => watchers.filter((w) => cards.some((x) => coversCard(w, x)))
|
|
911
|
-
|
|
912
|
-
/** who listens, in plain words: one lane's watch by its lane, any other by « an agent », several by their count */
|
|
913
|
-
export function listenWords(ws: readonly Watcher[]): string {
|
|
914
|
-
if (ws.length === 0) return 'nobody listens'
|
|
915
|
-
// a filtered watch is the card's own (its session or its lane); a bare one hears every card, for the dispatcher
|
|
916
|
-
const own = ws.filter((w) => w.lane !== null || w.session !== null)
|
|
917
|
-
const bare = ws.length - own.length
|
|
918
|
-
if (own.length === 0) return 'only a watch of every card hears it'
|
|
919
|
-
const lane = own.find((w) => w.lane !== null)?.lane
|
|
920
|
-
const head = lane ? `the ${lane} lane is listening` : 'its agent is listening'
|
|
921
|
-
return bare === 0 ? head : `${head} · ${bare} more ${bare === 1 ? 'watches' : 'watch'} every card`
|
|
922
|
-
}
|
|
923
|
-
|
|
924
1179
|
/** why a bare watch may not start: another one lives in the repo, so a verdict would reach two sessions. null when
|
|
925
1180
|
* none does. A repo keeps one, the dispatcher's; every other session watches its own cards or its lane's */
|
|
926
1181
|
export function bareWatchTaken(live: readonly Watcher[], self: number): string | null {
|
|
@@ -934,9 +1189,9 @@ export function unheardLine(item: Item, watchers: readonly Watcher[]): string |
|
|
|
934
1189
|
const o = item.origin
|
|
935
1190
|
if (o.by !== 'agent') return null
|
|
936
1191
|
const own = o.session || o.lane ? watchers.filter((w) => (o.session && w.session === o.session) || (o.lane && w.lane === o.lane)) : watchers
|
|
937
|
-
if (
|
|
1192
|
+
if (own.some((w) => coversCard(w, { item, thread: [] }))) return null
|
|
938
1193
|
const watch = o.session ? 'sk thread watch --mine' : o.lane ? `sk thread watch --lane ${o.lane}` : 'sk thread watch'
|
|
939
|
-
return `no watch hears this
|
|
1194
|
+
return `no watch hears this thread: run \`${watch}\` under a monitor now, so his answer reaches you as it lands`
|
|
940
1195
|
}
|
|
941
1196
|
|
|
942
1197
|
/** a card's own session has this long after its last message to claim it before a watch calls it untaken */
|
|
@@ -944,8 +1199,9 @@ export const UNTAKEN_GRACE_MS = 2 * 60 * 1000
|
|
|
944
1199
|
/** a card nobody takes is told again this often */
|
|
945
1200
|
export const UNTAKEN_AGAIN_MS = STALE_CLAIM_MS
|
|
946
1201
|
|
|
947
|
-
/** why an item waits on the agents and nobody holds it, else null; `superseded`: a later card follows it
|
|
948
|
-
|
|
1202
|
+
/** why an item waits on the agents and nobody holds it, else null; `superseded`: a later card follows it; `heard`: a
|
|
1203
|
+
* live watch hears its thread's holder (threads.ts listenersOf) */
|
|
1204
|
+
export function untakenOf(x: ReviewItem, superseded: boolean, heard: boolean, now: Date, routed = true): string | null {
|
|
949
1205
|
if (superseded) return null
|
|
950
1206
|
const quiet = now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created)
|
|
951
1207
|
if (quiet < UNTAKEN_GRACE_MS) return null
|
|
@@ -956,7 +1212,7 @@ export function untakenOf(x: ReviewItem, superseded: boolean, watchers: readonly
|
|
|
956
1212
|
if (s.since !== undefined) return quiet > STALE_CLAIM_MS ? `${s.worker ?? 'its'} claim went stale` : null
|
|
957
1213
|
// an agent read the verdict: the work it owes is taken, only not done yet
|
|
958
1214
|
if (verdictOf(x)?.seen) return null
|
|
959
|
-
return
|
|
1215
|
+
return !heard ? `the owner's verdict went back to ${s.worker ?? 'its author'}, and no watch reads it` : null
|
|
960
1216
|
}
|
|
961
1217
|
|
|
962
1218
|
export const ID_RE = /^\d{8}-\d{6}-[a-z0-9-]+$/
|
|
@@ -1024,7 +1280,7 @@ function subjectProblems(s: unknown, spec: Spec): string[] {
|
|
|
1024
1280
|
if (!obj(s) || typeof s.kind !== 'string' || s.kind === '') return ['subject: { kind }']
|
|
1025
1281
|
const kind = spec.kinds[s.kind]
|
|
1026
1282
|
const declared = Object.keys(spec.kinds)
|
|
1027
|
-
if (!kind && !BUILTIN_KINDS[s.kind] && declared.length > 0) return [`subject: kind « ${s.kind} » is none of ${[...declared, ...Object.keys(BUILTIN_KINDS)].join(', ')}`]
|
|
1283
|
+
if (!kind && !BUILTIN_KINDS[s.kind] && declared.length > 0) return [`subject: kind « ${s.kind} » is none of ${[...new Set([...declared, ...Object.keys(BUILTIN_KINDS)])].join(', ')}`]
|
|
1028
1284
|
if (kind?.problems) return kind.problems(s as Subject).map((p) => `subject: ${p}`)
|
|
1029
1285
|
if (s.kind === 'store' && !kind) return isStoreSubject(s as Subject) && s.store !== '' && s.asset !== '' ? [] : ['subject: a store thing has its store and asset']
|
|
1030
1286
|
if (s.kind === 'post' && !kind) return isPostSubject(s as Subject) ? [] : ['subject: a post request names its card']
|
|
@@ -1087,8 +1343,8 @@ export function itemProblems(v: unknown): string[] {
|
|
|
1087
1343
|
out.push(...subjectProblems(v.subject, NO_SPEC), ...originProblems(v.origin))
|
|
1088
1344
|
if (v.topic !== undefined && typeof v.topic !== 'string') out.push('topic: a text')
|
|
1089
1345
|
const agent = obj(v.origin) && v.origin.by === 'agent'
|
|
1090
|
-
// a draft card holds no picture: its body is the draft, read live
|
|
1091
|
-
const needsView = agent && v.draft === undefined
|
|
1346
|
+
// a draft card holds no picture: its body is the draft, read live; a thread opened with words names its address
|
|
1347
|
+
const needsView = agent && v.draft === undefined && v.on === undefined && v.states === undefined
|
|
1092
1348
|
if (!Array.isArray(v.views) || (needsView && v.views.length === 0)) out.push(`views: a list${needsView ? ' of one view or more' : ''}`)
|
|
1093
1349
|
else
|
|
1094
1350
|
v.views.forEach((w: unknown, i: number) => {
|
|
@@ -1097,6 +1353,8 @@ export function itemProblems(v: unknown): string[] {
|
|
|
1097
1353
|
else out.push(...viewProblems(obj(w) ? w : {}, `views[${i}].`))
|
|
1098
1354
|
})
|
|
1099
1355
|
if (v.about !== undefined && !addressList(v.about)) out.push('about: a list of addresses <kind>:<key>')
|
|
1356
|
+
const stateOk = (x: unknown): boolean => obj(x) && 'json' in x && (x.at === undefined || typeof x.at === 'string') && (x.files === undefined || (obj(x.files) && Object.values(x.files).every((f) => typeof f === 'string')))
|
|
1357
|
+
if (v.states !== undefined && !(obj(v.states) && stateOk(v.states.after) && (v.states.before === undefined || stateOk(v.states.before)) && typeof v.on === 'string')) out.push('states: { before?, after }, each { json, files?, at? }, on a version that names its object (on)')
|
|
1100
1358
|
if (v.on !== undefined && !(typeof v.on === 'string' && ADDRESS_RE.test(v.on))) out.push('on: an address <kind>:<key>')
|
|
1101
1359
|
if (v.answers !== undefined && !(Array.isArray(v.answers) && v.answers.length > 0 && v.answers.every((a) => typeof a === 'string' && ID_RE.test(a))))
|
|
1102
1360
|
out.push('answers: a list of item ids')
|
|
@@ -1110,6 +1368,10 @@ export function itemProblems(v: unknown): string[] {
|
|
|
1110
1368
|
if (v.choice !== undefined && !(v.choice === true && Array.isArray(v.views) && v.views.length >= 2)) out.push('choice: true on a card of two views or more, or absent')
|
|
1111
1369
|
if (v.agentPick !== undefined && !(v.choice === true && Number.isInteger(v.agentPick) && Array.isArray(v.views) && (v.agentPick as number) >= 0 && (v.agentPick as number) < v.views.length))
|
|
1112
1370
|
out.push('agentPick: the index of one of its views, on a choice card, or absent')
|
|
1371
|
+
if (v.ask !== undefined) {
|
|
1372
|
+
out.push(...askHeadProblems(v.ask))
|
|
1373
|
+
if (!(typeof v.on === 'string' && v.on.startsWith('ask:'))) out.push('ask: on the head of a thread ask:<id>')
|
|
1374
|
+
}
|
|
1113
1375
|
if (v.media !== undefined) {
|
|
1114
1376
|
if (!obj(v.media)) out.push('media: { <file name>: { sha, size, type } }, or absent')
|
|
1115
1377
|
else
|
|
@@ -1139,25 +1401,72 @@ export function messageProblems(v: unknown, name: string): string[] {
|
|
|
1139
1401
|
if (typeof v.text !== 'string') out.push('update: its line in text')
|
|
1140
1402
|
}
|
|
1141
1403
|
if (v.re !== undefined && !(typeof v.re === 'string' && MESSAGE_RE.test(v.re))) out.push('re: the id of a message of the thread')
|
|
1404
|
+
if (v.step !== undefined && !(obj(v.step) && typeof v.step.of === 'string' && MESSAGE_RE.test(v.step.of) && Number.isInteger(v.step.i) && (v.step.i as number) >= 0 && v.ask !== undefined))
|
|
1405
|
+
out.push("step: { of: an instructions message id, i: its step }, on a question")
|
|
1142
1406
|
if (v.session !== undefined && typeof v.session !== 'string') out.push('session: a text')
|
|
1143
1407
|
if (v.about !== undefined && !addressList(v.about)) out.push('about: a list of addresses <kind>:<key>')
|
|
1144
1408
|
if (v.ask !== undefined) {
|
|
1145
1409
|
const a = v.ask
|
|
1146
|
-
|
|
1147
|
-
|
|
1410
|
+
const index = (x: unknown): boolean => Number.isInteger(x) && (x as number) >= 0
|
|
1411
|
+
const kind = obj(a) ? (a.kind ?? 'choice') : null
|
|
1412
|
+
const texts = obj(a) && Array.isArray(a.options) && a.options.every((o) => typeof o === 'string' && o.trim() !== '')
|
|
1413
|
+
if (!obj(a) || !ANSWER_KINDS.includes(kind as AnswerKind)) out.push(`ask: kind, one of ${ANSWER_KINDS.join(', ')}`)
|
|
1414
|
+
else if (kind === 'choice') {
|
|
1415
|
+
if (!texts || (a.options as unknown[]).length < 2 || (a.pick !== undefined && !(index(a.pick) && (a.pick as number) < (a.options as unknown[]).length)))
|
|
1416
|
+
out.push('ask: { options: two texts or more, pick?: an option index }')
|
|
1417
|
+
else if (a.views !== undefined && !(Array.isArray(a.views) && a.views.length === (a.options as unknown[]).length && a.views.every((x) => x === null || index(x)))) out.push('ask: views, one view index or null an option')
|
|
1418
|
+
} else if (kind === 'checklist') {
|
|
1419
|
+
if (!texts || (a.options as unknown[]).length < 1 || (a.done !== undefined && !(Array.isArray(a.done) && a.done.every((x) => index(x) && (x as number) < (a.options as unknown[]).length))))
|
|
1420
|
+
out.push('ask: a checklist, { options: its lines, one or more, done?: line indexes }')
|
|
1421
|
+
else if (a.choices !== undefined && !(Array.isArray(a.choices) && a.choices.length === (a.options as unknown[]).length && v.instructions !== undefined && a.choices.every((c) => c === null || (obj(c) && Array.isArray(c.options) && c.options.length >= 2 && c.options.every((o) => typeof o === 'string' && o.trim() !== '') && (c.pick === undefined || (index(c.pick) && (c.pick as number) < c.options.length))))))
|
|
1422
|
+
out.push("ask: choices, an instructions' steps only, one { options: two texts or more, pick? } or null a step")
|
|
1423
|
+
} else if (!(Array.isArray(a.options) && a.options.length === 0)) out.push(`ask: a ${kind} question holds no options`)
|
|
1424
|
+
if (kind === 'secret' && !(obj(a) && obj(a.secret) && typeof a.secret.name === 'string' && SECRET_NAME.test(a.secret.name) && (a.secret.login === undefined || a.secret.login === true)))
|
|
1425
|
+
out.push('ask: a secret question names its secret, { secret: { name, login? } }')
|
|
1148
1426
|
if (typeof v.text !== 'string') out.push('ask: its question in text')
|
|
1149
1427
|
}
|
|
1150
1428
|
if (v.propose !== undefined) {
|
|
1151
1429
|
const p = v.propose
|
|
1152
|
-
|
|
1430
|
+
const field = (f: unknown, flat: boolean): boolean =>
|
|
1431
|
+
obj(f) &&
|
|
1432
|
+
(flat || (typeof f.key === 'string' && f.key.trim() !== '')) &&
|
|
1433
|
+
typeof f.after === 'string' &&
|
|
1434
|
+
(f.before === undefined || typeof f.before === 'string') &&
|
|
1435
|
+
(f.type === undefined || DIFF_TYPES.includes(f.type as DiffType)) &&
|
|
1436
|
+
(f.lang === undefined || typeof f.lang === 'string') &&
|
|
1437
|
+
(f.view === undefined || (Number.isInteger(f.view) && (f.view as number) >= 0))
|
|
1438
|
+
const keys = obj(p) && Array.isArray(p.fields) ? p.fields.map((f) => (obj(f) ? f.key : null)) : []
|
|
1439
|
+
if (!obj(p) || typeof p.on !== 'string' || !ADDRESS_RE.test(p.on) || !field(p, true) || (p.page !== undefined && typeof p.page !== 'string')) out.push('propose: { on: an address, before?, after, type?, lang?, view?, page? }')
|
|
1440
|
+
else if (p.fields !== undefined && !(Array.isArray(p.fields) && p.fields.length >= 1 && (p.fields.length >= 2 || keys[0] !== '') && p.fields.every((f) => field(f, false)) && new Set(keys).size === keys.length))
|
|
1441
|
+
out.push('propose: fields, one named or two or more, each { key, before?, after, type?, lang?, view? }, each key once')
|
|
1153
1442
|
if (typeof v.text !== 'string') out.push('propose: its words in text')
|
|
1154
1443
|
}
|
|
1444
|
+
if (v.askState !== undefined && !(obj(v.askState) && ['open', 'done', 'declined'].includes(v.askState.state as string) && (v.askState.why === undefined || typeof v.askState.why === 'string'))) out.push("askState: { state: open, done or declined, why? }")
|
|
1445
|
+
if (v.snooze !== undefined && !(obj(v.snooze) && (v.snooze.until === null || (typeof v.snooze.until === 'string' && !Number.isNaN(Date.parse(v.snooze.until)))))) out.push('snooze: { until: an ISO time, or null }')
|
|
1446
|
+
if (v.urgent !== undefined && v.urgent !== true) out.push('urgent: true')
|
|
1447
|
+
if (v.action !== undefined && !(obj(v.action) && typeof v.action.name === 'string' && /^[a-z][a-z0-9-]*$/.test(v.action.name))) out.push('action: { name: a lowercase word }')
|
|
1155
1448
|
if (v.answer !== undefined) {
|
|
1156
1449
|
const a = v.answer
|
|
1157
|
-
|
|
1450
|
+
const says = obj(a) && (a.option !== undefined || a.apply === true || typeof a.value === 'string' || typeof a.stored === 'string' || a.view !== undefined)
|
|
1451
|
+
if (!obj(a) || !says || (a.option !== undefined && !(Number.isInteger(a.option) && (a.option as number) >= 0)) || (a.apply !== undefined && a.apply !== true) || (a.field !== undefined && typeof a.field !== 'string') || (a.value !== undefined && typeof a.value !== 'string')
|
|
1452
|
+
|| (a.tick !== undefined && !(typeof a.tick === 'boolean' && a.option !== undefined)) || (a.pick !== undefined && !(Number.isInteger(a.pick) && (a.pick as number) >= 0 && a.tick === true)) || (a.opens !== undefined && !(Number.isInteger(a.opens) && (a.opens as number) >= 0)) || (a.stored !== undefined && !(typeof a.stored === 'string' && SECRET_NAME.test(a.stored))) || (a.view !== undefined && !(Number.isInteger(a.view) && (a.view as number) >= 0)))
|
|
1453
|
+
out.push('answer: { option, tick? }, { apply: true, field?, value? }, { value, opens? }, { stored } or { view }')
|
|
1158
1454
|
if (typeof v.re !== 'string') out.push('answer: the question or proposal it answers in re')
|
|
1159
1455
|
}
|
|
1160
|
-
if (v.
|
|
1456
|
+
if (v.replaces !== undefined && !(typeof v.replaces === 'string' && MESSAGE_RE.test(v.replaces))) out.push('replaces: the id of a message of the thread')
|
|
1457
|
+
if (v.hold !== undefined && !(obj(v.hold) && typeof v.hold.address === 'string' && typeof v.hold.held === 'boolean' && (v.hold.sha === undefined || typeof v.hold.sha === 'string') && (v.hold.ahead === undefined || typeof v.hold.ahead === 'number') && typeof v.text === 'string')) out.push('hold: { address, held, sha?, ahead? } and its words in text')
|
|
1458
|
+
if (v.laneAsk !== undefined && !(obj(v.laneAsk) && typeof v.laneAsk.for === 'string' && (v.laneAsk.session === undefined || typeof v.laneAsk.session === 'string') && v.who === 'owner')) out.push("laneAsk: { for, session? }, the owner's")
|
|
1459
|
+
if (v.unhold !== undefined && !(Array.isArray(v.unhold) && v.unhold.length > 0 && v.unhold.every((a) => typeof a === 'string'))) out.push('unhold: the addresses it releases')
|
|
1460
|
+
if (v.askBar !== undefined && !(Array.isArray(v.askBar) && v.askBar.length > 0 && v.askBar.every((f) => typeof f === 'string' && MESSAGE_RE.test(f)))) out.push('askBar: the ids of messages of the thread')
|
|
1461
|
+
if (v.instructions !== undefined) {
|
|
1462
|
+
const i = v.instructions
|
|
1463
|
+
if (!obj(i) || typeof i.title !== 'string' || i.title.trim() === '' || !(Array.isArray(i.folds) && i.folds.every((f) => typeof f === 'string' && MESSAGE_RE.test(f)))) out.push('instructions: { title, ask, folds: message ids }')
|
|
1464
|
+
else if (!obj(i.ask) || 'created' in i.ask || 'pinged' in i.ask) out.push("instructions.ask: the facts, never the head's day or ping")
|
|
1465
|
+
else out.push(...askHeadProblems({ ...i.ask, created: '2000-01-01' }).map((p) => `instructions.${p}`))
|
|
1466
|
+
if (typeof v.text !== 'string') out.push('instructions: its words in text')
|
|
1467
|
+
if (v.replaces !== undefined) out.push('instructions: superseded by order, never by replaces')
|
|
1468
|
+
}
|
|
1469
|
+
if (v.op === undefined && v.verdict === undefined && v.rate === undefined && typeof v.text !== 'string' && !Array.isArray(v.rects) && v.snooze === undefined && v.askState === undefined && v.urgent === undefined && v.askBar === undefined && v.unhold === undefined && v.laneAsk === undefined)
|
|
1161
1470
|
out.push('a message says something: text, rects, verdict, rate or op')
|
|
1162
1471
|
return out
|
|
1163
1472
|
}
|
|
@@ -1182,6 +1491,7 @@ function viewProblems(v: Record<string, unknown>, at: string): string[] {
|
|
|
1182
1491
|
const out: string[] = []
|
|
1183
1492
|
if (typeof v.label !== 'string') out.push(`${at}label: a text`)
|
|
1184
1493
|
if (v.note !== undefined && typeof v.note !== 'string') out.push(`${at}note: a text`)
|
|
1494
|
+
if (v.message !== undefined && v.message !== true) out.push(`${at}message: true or absent`)
|
|
1185
1495
|
const f = v.files
|
|
1186
1496
|
const okImage = (n: unknown): boolean => typeof n === 'string' && FILE_RE.test(n) && !isClipFile(n) && !isAudioFile(n)
|
|
1187
1497
|
const okClip = (n: unknown): boolean => typeof n === 'string' && FILE_RE.test(n) && isClipFile(n)
|