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/cli/cmd_Review.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// what he, a player or a rule raised, a worker claims and closes it (review/store.ts, wiki tools/shipkit/threads.md).
|
|
3
3
|
// Every module loads inside execute: the cli registers this file on every `sk` call
|
|
4
4
|
import { Command, Option } from 'clipanion'
|
|
5
|
+
import type { AnswerKind } from '../review/model.ts'
|
|
5
6
|
|
|
6
|
-
const DETAILS = `threads, the one exchange with the owner
|
|
7
|
+
const DETAILS = `threads, the one exchange with the owner (wiki tools/shipkit/threads.md): one thread per subject, found by its address <kind>:<key>, for its whole life. sk thread post <address> sends a version into it, linked by the tool; ask, propose, reply and update write in it, and start it when no thread owns the address. He answers in the hub's threads page; you read his answer with watch, inbox or the inbox hook, then mark it seen. What he, a player or a rule raises is an item of the same store with its own state, closed with sk thread fixed. The store: .shipkit/review/ of each repo, or the daemon's rows (sk thread move). SK_AGENT names your lane.`
|
|
7
8
|
|
|
8
9
|
type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
|
|
9
10
|
type Unit = import('../review/unit.ts').ReviewUnit
|
|
@@ -37,7 +38,13 @@ async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o:
|
|
|
37
38
|
const argv = process.argv.slice(2)
|
|
38
39
|
if (argv[0] === 'review' && !argv.includes('--hook') && !argv.includes('--json')) err(`sk review is now sk thread: sk thread ${argv.slice(1).map((a) => (/^[\w./=,@:+#-]+$/.test(a) ? a : JSON.stringify(a))).join(' ')}`)
|
|
39
40
|
const root = await reviewRoot(process.cwd())
|
|
40
|
-
if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo (no repo.config.ts at its git root), so no hub would ever show what is stored here: run it from inside the repo the
|
|
41
|
+
if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo (no repo.config.ts at its git root), so no hub would ever show what is stored here: run it from inside the repo the thread is for`)
|
|
42
|
+
// a repo where an agent writes in a thread needs a next session that hears it; the gate's repair wires the hook
|
|
43
|
+
if (WRITING_VERBS.has(argv[1] ?? '')) {
|
|
44
|
+
const { inboxHookLacks } = await import('../review/inbox-read.ts')
|
|
45
|
+
const lacks = inboxHookLacks(root)
|
|
46
|
+
if (lacks.length > 0) err(`review: no inbox hook runs here on ${lacks.join(' and ')}, so the next session may not hear his answer: sk ci --only SK049 wires it (wiki tools/shipkit/threads-how-it-fits.md)`)
|
|
47
|
+
}
|
|
41
48
|
if (o.unit === false) {
|
|
42
49
|
const { storeDir } = await import('../review/store.ts')
|
|
43
50
|
return await body({ dir: storeDir(root), unit: null, say: { spec: (await import('../review/model.ts')).NO_SPEC, more: () => [] }, out, err })
|
|
@@ -56,6 +63,9 @@ async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o:
|
|
|
56
63
|
|
|
57
64
|
const isHelp = (a: string): boolean => a === '--help' || a === '-h'
|
|
58
65
|
|
|
66
|
+
/** the verbs that write an agent's act in a thread */
|
|
67
|
+
const WRITING_VERBS = new Set(['post', 'add', 'add-view', 'ask', 'propose', 'reply', 'update', 'take', 'assign', 'working', 'fixed', 'done', 'attach', 'ready'])
|
|
68
|
+
|
|
59
69
|
/** the agent that acts: --as, else SK_AGENT; `need` refuses an unnamed one */
|
|
60
70
|
function actor(as: string | undefined, need: boolean, verb: string): string {
|
|
61
71
|
const n = as?.trim() || process.env.SK_AGENT?.trim()
|
|
@@ -69,11 +79,12 @@ function actor(as: string | undefined, need: boolean, verb: string): string {
|
|
|
69
79
|
* thread that owns it, or the one above it) to its item id */
|
|
70
80
|
async function idOf(dir: string, ref: string): Promise<string> {
|
|
71
81
|
const { itemOfRef, readAll, specOf } = await import('../review/store.ts')
|
|
72
|
-
const {
|
|
73
|
-
if (!ID_RE.test(ref) &&
|
|
82
|
+
const { addressOrThrow, ID_RE } = await import('../review/model.ts')
|
|
83
|
+
if (!ID_RE.test(ref) && ref.includes(':') && !/^\w+#\d+$/.test(ref)) {
|
|
84
|
+
const a = addressOrThrow(ref)
|
|
74
85
|
const { threadOfAddress } = await import('../review/threads.ts')
|
|
75
|
-
const t = threadOfAddress(
|
|
76
|
-
if (!t) throw new Error(`no thread owns ${
|
|
86
|
+
const t = threadOfAddress(a, readAll(dir).items, specOf(dir), { up: true })
|
|
87
|
+
if (!t) throw new Error(`no thread owns ${a}: sk thread post ${a} --title "…" --what "…" starts it`)
|
|
77
88
|
return t.head.item.id
|
|
78
89
|
}
|
|
79
90
|
const x = itemOfRef(dir, ref)
|
|
@@ -81,6 +92,44 @@ async function idOf(dir: string, ref: string): Promise<string> {
|
|
|
81
92
|
return x.item.id
|
|
82
93
|
}
|
|
83
94
|
|
|
95
|
+
/** an address an agent starts a thread on or links: its kind word must be one a kind declares (the repo's or the
|
|
96
|
+
* house's, `sk thread kinds`), so one subject never becomes two threads under two words */
|
|
97
|
+
async function declaredOrThrow(h: Here, a: string): Promise<void> {
|
|
98
|
+
const { readAll } = await import('../review/store.ts')
|
|
99
|
+
const { addressRefusal } = await import('../review/threads.ts')
|
|
100
|
+
const why = addressRefusal(a, readAll(h.dir).items, h.say.spec)
|
|
101
|
+
if (why !== null) throw new Error(why)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** the item an act on `ref` goes on: an id's, or the newest version of the thread its address has; an address no
|
|
105
|
+
* thread owns gets its thread opened with words first, `title` its title, so a question needs no picture */
|
|
106
|
+
|
|
107
|
+
/** an urgent word of an agent: it brings back a thread he set aside (wiki tools/shipkit/threads-asks.md, Snooze) */
|
|
108
|
+
async function urgentOn(dir: string, id: string, who: string): Promise<void> {
|
|
109
|
+
const { appendMessage } = await import('../review/store.ts')
|
|
110
|
+
appendMessage(dir, id, { who, urgent: true })
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function idOrOpen(h: Here, ref: string, title: string, as: string | undefined): Promise<string> {
|
|
114
|
+
const { addressOrThrow, ID_RE } = await import('../review/model.ts')
|
|
115
|
+
if (ID_RE.test(ref) || !ref.includes(':') || /^\w+#\d+$/.test(ref)) return idOf(h.dir, ref)
|
|
116
|
+
const a = addressOrThrow(ref)
|
|
117
|
+
const { openThread, readAll, specOf } = await import('../review/store.ts')
|
|
118
|
+
const { threadOfAddress } = await import('../review/threads.ts')
|
|
119
|
+
const t = threadOfAddress(a, readAll(h.dir).items, specOf(h.dir), { up: true })
|
|
120
|
+
if (t) return t.head.item.id
|
|
121
|
+
await declaredOrThrow(h, a)
|
|
122
|
+
const lane = laneOfCaller(as)
|
|
123
|
+
const x = await openThread(h.dir, a, { title, ...(lane ? { lane } : {}) })
|
|
124
|
+
h.err(`${a}: no thread owned it, this one starts it: ${x.id}`)
|
|
125
|
+
return x.id
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** why a version that names no subject is refused: a thread is found by its address, so a version without one would
|
|
129
|
+
* start a thread nobody finds again */
|
|
130
|
+
const NO_ADDRESS =
|
|
131
|
+
'a version names the subject he judges, so it goes into that subject\'s one thread: sk thread post <kind>:<key> --title "…" --what "…" <media> (screen:<screen>, asset:<asset>, page:<page>, or a kind this repo\'s review unit declares; --trailer and --draft name their own). Page: wiki tools/shipkit/threads.md, The model'
|
|
132
|
+
|
|
84
133
|
/** the sources pulled before a read: a line per source down, said once a process */
|
|
85
134
|
const downSaid = new Set<string>()
|
|
86
135
|
async function pull(h: Here): Promise<void> {
|
|
@@ -150,6 +199,16 @@ export function takeViews(args: readonly string[]): { views: ViewInput[]; rest:
|
|
|
150
199
|
|
|
151
200
|
const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"] [--keep]'
|
|
152
201
|
const MEDIA_FILE = /\.(png|jpe?g|webp|gif|mp4|webm|mov|wav|mp3|flac|ogg|opus|m4a)$/i
|
|
202
|
+
|
|
203
|
+
/** one `--option` of a question: words, a media file, `<label>=<file>` or `<label>=<before>,<after>` (a gallery tile's
|
|
204
|
+
* form); the part after the last `=` is media only when each of its files is one */
|
|
205
|
+
export function askOption(a: string): { label: string; files?: string[] } {
|
|
206
|
+
const eq = a.lastIndexOf('=')
|
|
207
|
+
const tail = eq >= 0 ? a.slice(eq + 1).split(',').map((f) => f.trim()) : [a.trim()]
|
|
208
|
+
const media = tail.length <= 2 && tail.every((f) => MEDIA_FILE.test(f))
|
|
209
|
+
if (!media) return { label: a }
|
|
210
|
+
return { label: eq >= 0 ? a.slice(0, eq).trim() : '', files: tail }
|
|
211
|
+
}
|
|
153
212
|
const quoted = (a: string): string => (/^[\w./=,@:+-]+$/.test(a) ? a : `"${a.replace(/"/g, '\\"')}"`)
|
|
154
213
|
|
|
155
214
|
/** add-view's args: the positional form, or the view flags of add; a flag is never a label, `own` are the repo unit's flags */
|
|
@@ -220,7 +279,7 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
|
|
|
220
279
|
on.add(name)
|
|
221
280
|
continue
|
|
222
281
|
}
|
|
223
|
-
if (!values.includes(name) && !repeat.includes(name)) throw new Error(`${a}: no such flag (sk thread
|
|
282
|
+
if (!values.includes(name) && !repeat.includes(name)) throw new Error(`${a}: no such flag (sk thread post --help)`)
|
|
224
283
|
const v = args[i + 1]
|
|
225
284
|
if (v === undefined) throw new Error(`${a}: needs a value`)
|
|
226
285
|
i++
|
|
@@ -231,37 +290,37 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
|
|
|
231
290
|
}
|
|
232
291
|
|
|
233
292
|
const ADD_FLAGS = `flags:
|
|
234
|
-
--title "<title>" one short line: what he looks at (a lone "<title>" after
|
|
293
|
+
--title "<title>" one short line: what he looks at (a lone "<title>" after the address is the same)
|
|
235
294
|
--what "<what>" what changed and why, short markdown: one line, then - bullets
|
|
236
295
|
--post "<line>" the public line for a post of it, what a user gets (the repo's guard reads it)
|
|
237
|
-
--changelog "<category>: <line>" its change in the release being filled: on his approval it lands in .shipkit/releases/next.md with the
|
|
296
|
+
--changelog "<category>: <line>" its change in the release being filled: on his approval it lands in .shipkit/releases/next.md with the version's after picture (the repo's guard reads it)
|
|
238
297
|
--rating <safe|mild|explicit> with --changelog: what its media shows at full size, the rating its picture lands with; unset, unrated (reads explicit: no SFW venue shows it)
|
|
298
|
+
--verdict words with no media wait for the owner's verdict like a version (a version asks it always)
|
|
239
299
|
--image <a.png> the subject; a clip (webm, mp4) goes anywhere an image goes
|
|
240
300
|
--video <clip.mp4> a clip
|
|
241
301
|
--audio <sound.wav> a sound: a waveform and a player (wav, mp3, flac, ogg, opus, m4a)
|
|
242
302
|
--before <a.png> --after <b.png> a before and after: two images, two clips of one size, or two sounds
|
|
243
303
|
--label "<label>" the first view's label
|
|
244
304
|
--view "<label>" <a.png> [<b.png>] another view of the same subject (repeat it); --note "<text>" right after it: a line on that view
|
|
245
|
-
--choice
|
|
246
|
-
--pick <
|
|
305
|
+
--choice the older form of a question: posts sk thread ask with each --view an option, and prints that form
|
|
306
|
+
--pick <n> with --choice: the option you suggest, by its number from 1 (a letter or a label works too); the « my pick » pill
|
|
247
307
|
--gallery "<label>" <a.png> … a grid he rates tile by tile (stars, OK, fix or no, a word), alone or beside other views; a tile is "[<row>/]<label>=[<before>,]<after>": a redraw carries its before, a row holds one asset's variants
|
|
248
|
-
--trailer <cut.trailer> a trailer cut, played in the
|
|
308
|
+
--trailer <cut.trailer> a trailer cut, played in the thread by the trailer entry's player, never a compiled clip; his notes land on its shots
|
|
249
309
|
--version v<n> with --trailer: a kept version of that cut, else the cut's own render
|
|
250
310
|
--before v<m> | <cut> with --trailer: the render he switches to on the same shot
|
|
251
311
|
--shots <a,b> with --trailer: the shots the change touched (else, with --before, the shots whose block differs)
|
|
252
|
-
--draft <slug> a post draft of
|
|
312
|
+
--draft <slug> a post draft of the repo's social store (its slug or its topic), shown itself in the thread, read live: a block a place, each with its own OK, fix or no and his word; no image is made
|
|
253
313
|
--topic <topic> what part of the project it is about (sk thread topics)
|
|
254
314
|
--subject <kind> what is judged (default shot; the repo's unit names its kinds)
|
|
255
315
|
--commit <sha> the commit it shows
|
|
256
316
|
--lane <id> the lane that made it; else SK_AGENT
|
|
257
|
-
--wip "<what is still wrong>" a
|
|
317
|
+
--wip "<what is still wrong>" a version sent in work: « in progress », no verdict asked; each step after: sk thread update <id> <broken|better|fixed> "<line>" <file>
|
|
258
318
|
--on <address> the version's own address (page:review/lightbox, trailer:<name>/<cut>): it goes into the thread that owns it, one thread per address; a trailer or a draft names its own
|
|
259
319
|
--about <address> another object it is about, a link that finds it (repeat it); never its thread
|
|
260
|
-
--supersedes <id> the version it follows; with an address the tool links it, only a wrong link is refused
|
|
261
320
|
--answers <id | live#3> the item it answers (a note he raised, a player's report), one thread (repeat it)
|
|
262
|
-
--keeps "<what stays>"
|
|
263
|
-
--new --why "<reason>" a
|
|
264
|
-
--keep every picture as given; otherwise a png lands as a lossless webp, its pixels checked exact, and the
|
|
321
|
+
--keeps "<what stays>" on a new version of an approved look: what of it stays
|
|
322
|
+
--new --why "<reason>" a version with no address of its own whose title reads like an active thread's: why it is another subject
|
|
323
|
+
--keep every picture as given; otherwise a png lands as a lossless webp, its pixels checked exact, and the version keeps that webp alone (a jpeg always lands as given)`
|
|
265
324
|
|
|
266
325
|
/** the help of add or add-view, then the flags this repo's review unit adds (any kind's, then each kind's under
|
|
267
326
|
* `--subject <kind>`); a repo with no unit, or one that does not load, says so on one line */
|
|
@@ -288,7 +347,7 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
|
|
|
288
347
|
return null
|
|
289
348
|
}
|
|
290
349
|
const clash = ['image', 'video', 'audio', 'after', 'live'].filter((k) => o[k] !== undefined)
|
|
291
|
-
if (clash.length > 0 || others) throw new Error(`--trailer: the
|
|
350
|
+
if (clash.length > 0 || others) throw new Error(`--trailer: the version plays the cut; no ${clash.length > 0 ? clash.map((k) => `--${k}`).join(', ') : '--view, --gallery, --choice or --wip'} beside it`)
|
|
292
351
|
const { mkdtempSync, rmSync } = await import('node:fs')
|
|
293
352
|
const { tmpdir } = await import('node:os')
|
|
294
353
|
const { join } = await import('node:path')
|
|
@@ -312,26 +371,29 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
|
|
|
312
371
|
export async function draftOfFlags(o: Record<string, string>, others: boolean, cwd: string = process.cwd()): Promise<import('../review/model.ts').DraftCard | null> {
|
|
313
372
|
if (o.draft === undefined) return null
|
|
314
373
|
const clash = ['image', 'video', 'audio', 'before', 'after', 'label', 'live', 'trailer'].filter((k) => o[k] !== undefined)
|
|
315
|
-
if (clash.length > 0 || others) throw new Error(`--draft: the
|
|
374
|
+
if (clash.length > 0 || others) throw new Error(`--draft: the version shows the draft itself; no ${clash.length > 0 ? clash.map((k) => `--${k}`).join(', ') : '--view, --gallery or --choice'} beside it`)
|
|
316
375
|
const [{ findRepoRoot }, { openDesk }, { draftCardOf }] = await Promise.all([import('../ts/config.ts'), import('../social/open.ts'), import('../review/draft-card.ts')])
|
|
317
376
|
return draftCardOf((await openDesk(findRepoRoot(cwd))).desk, o.draft, cwd).card
|
|
318
377
|
}
|
|
319
378
|
|
|
320
379
|
export class ReviewAddCommand extends Command {
|
|
321
|
-
static override paths = [['review', 'add']]
|
|
380
|
+
static override paths = [['thread', 'post'], ['review', 'add']]
|
|
322
381
|
static essential = {}
|
|
382
|
+
/** the flags its proxy reads, as its help lists them: what a doc may name (RV019) */
|
|
383
|
+
static proxyFlags = [...new Set(ADD_FLAGS.match(/--[a-z][a-z0-9-]*/g) ?? [])]
|
|
323
384
|
static override usage = Command.Usage({
|
|
324
385
|
category: 'Review',
|
|
325
|
-
description:
|
|
326
|
-
details: `${DETAILS}\n\n${ADD_FLAGS}`,
|
|
386
|
+
description: "a version in the thread of its subject, by its address; it starts the thread; no media: words",
|
|
387
|
+
details: `${DETAILS}\n\nsk thread post [<address> | <id>] <flags>. The address is the version's own (screen:<screen>, asset:<asset>, page:<page>, a kind of the repo's unit); --trailer and --draft name theirs, so it may be left out. An id names its thread. With no media, --title and --what are words: they start the thread, or are a reply in it. sk thread add is its older name.\n\n${ADD_FLAGS}`,
|
|
327
388
|
examples: [
|
|
328
|
-
['one image', 'sk thread
|
|
329
|
-
['a before and after', 'sk thread
|
|
330
|
-
['
|
|
331
|
-
['a pick among three voices, yours on the second', 'sk thread
|
|
332
|
-
['icons he rates one by one', 'sk thread
|
|
333
|
-
['a trailer cut against its last kept version', 'sk thread
|
|
334
|
-
['a post draft, each place answered on its own', 'sk thread
|
|
389
|
+
['one image', 'sk thread post screen:menu --title "the new menu" --what "the menu, bigger" --image shots/menu.png'],
|
|
390
|
+
['a before and after', 'sk thread post asset:lamps --title "lamps lit" --what "..." --before a.png --after b.png'],
|
|
391
|
+
['the next version: the same address, the tool links it', 'sk thread post asset:lamps --title "lamps lit, warmer" --what "..." --image c.png'],
|
|
392
|
+
['a pick among three voices, yours on the second', 'sk thread post asset:narrator --choice --pick 2 --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
|
|
393
|
+
['icons he rates one by one', 'sk thread post asset:buff-icons --title "buff icons" --what "..." --gallery "icons" vitality=a.png haste=b.png greed=c.png'],
|
|
394
|
+
['a trailer cut against its last kept version', 'sk thread post --trailer trailer/demo/main.trailer --version v4 --before v3 --title "the drop, recut" --what "..."'],
|
|
395
|
+
['a post draft, each place answered on its own', 'sk thread post --draft 20261119-174922-trailer --title "the trailer post" --what "..."'],
|
|
396
|
+
['words, no picture', 'sk thread post messages:tui/u1 --title "the hook line" --what "three phrasings tested, the second wins"'],
|
|
335
397
|
],
|
|
336
398
|
})
|
|
337
399
|
args = Option.Proxy()
|
|
@@ -342,6 +404,7 @@ export class ReviewAddCommand extends Command {
|
|
|
342
404
|
}
|
|
343
405
|
return run(this.context, async (h) => {
|
|
344
406
|
const { addItem, postUpdate, agentName } = await import('../review/store.ts')
|
|
407
|
+
if (this.path[1] === 'add') h.err('sk thread add is now sk thread post [<address>]: the same flags')
|
|
345
408
|
// `--wip "<what is still wrong>"`: a card sent in work, its first update still broken; a bare --wip goes with --live
|
|
346
409
|
const w = this.args.indexOf('--wip')
|
|
347
410
|
const wipLine = w >= 0 && this.args[w + 1] !== undefined && !this.args[w + 1]!.startsWith('--') ? this.args[w + 1] : undefined
|
|
@@ -350,23 +413,50 @@ export class ReviewAddCommand extends Command {
|
|
|
350
413
|
const kindName = rest[rest.indexOf('--subject') + 1]
|
|
351
414
|
const kind = rest.includes('--subject') && kindName ? h.unit?.kinds?.[kindName] : undefined
|
|
352
415
|
const own = [...Object.keys(kind?.flags ?? {}), ...Object.keys(h.unit?.flags ?? {})]
|
|
353
|
-
const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick', 'draft', 'on'], ['answers', 'about', ...own], ['new', 'wip', 'choice', 'keep'])
|
|
416
|
+
const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick', 'draft', 'on'], ['answers', 'about', ...own], ['new', 'wip', 'choice', 'keep', 'verdict'])
|
|
354
417
|
const o = f.one
|
|
418
|
+
// the first word names the thread: an address (the version's own), or an id (its thread)
|
|
419
|
+
const { addressOrThrow, canonicalAddress, ID_RE } = await import('../review/model.ts')
|
|
420
|
+
const first = f.positionals[0]
|
|
421
|
+
// post names its thread first; add's lone word is a title, unless it reads as an address
|
|
422
|
+
const named = first !== undefined && (ID_RE.test(first) || canonicalAddress(first) !== null || (this.path[1] === 'post' && !MEDIA_FILE.test(first)))
|
|
423
|
+
const target = named ? f.positionals.shift() : undefined
|
|
424
|
+
if (target !== undefined && ID_RE.test(target)) {
|
|
425
|
+
const { readAll } = await import('../review/store.ts')
|
|
426
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
427
|
+
const { ownAddressOf } = await import('../review/model.ts')
|
|
428
|
+
const t = threadOfItem((await idOf(h.dir, target)), threadsOf(readAll(h.dir).items, h.say.spec))
|
|
429
|
+
if (!t) throw new Error(`no thread holds ${target}`)
|
|
430
|
+
const head = t.head.item
|
|
431
|
+
const own = ownAddressOf(head, h.say.spec)
|
|
432
|
+
if (head.origin.by === 'agent') o.supersedes ??= head.id
|
|
433
|
+
else if (own !== null) o.on ??= own
|
|
434
|
+
else f.many.answers = [...(f.many.answers ?? []), head.id]
|
|
435
|
+
} else if (target !== undefined) {
|
|
436
|
+
const a = addressOrThrow(target)
|
|
437
|
+
if (o.on !== undefined && addressOrThrow(o.on) !== a) throw new Error(`${a} and --on ${o.on}: one address a version`)
|
|
438
|
+
o.on = a
|
|
439
|
+
}
|
|
440
|
+
if (o.on !== undefined) await declaredOrThrow(h, addressOrThrow(o.on))
|
|
441
|
+
for (const a of f.many.about ?? []) await declaredOrThrow(h, addressOrThrow(a))
|
|
355
442
|
// a lone word is the title, as `sk ask <title>` takes it; a media file never is
|
|
356
443
|
const [lone, ...more] = f.positionals
|
|
357
444
|
if (lone !== undefined && more.length === 0 && o.title === undefined && !MEDIA_FILE.test(lone)) o.title = lone
|
|
358
|
-
else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk thread
|
|
445
|
+
else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk thread post --help)`)
|
|
446
|
+
if (f.on.has('choice') && f.on.has('verdict')) throw new Error("--choice --verdict: a choice is a question, its pick is the owner's answer; post it without --verdict")
|
|
447
|
+
if (f.on.has('choice')) return choiceAsQuestion(h, o, views, f.many)
|
|
448
|
+
const states = await statesOfFlags(h, o, views.length > 0)
|
|
359
449
|
const trailer = await trailerOfFlags(o, views.length > 0 || f.on.has('wip') || f.on.has('choice'))
|
|
360
450
|
const draft = await draftOfFlags(o, views.length > 0 || f.on.has('choice'))
|
|
361
451
|
const repoFlags = Object.fromEntries(own.flatMap((k) => (f.many[k] ? [[k, f.many[k]]] : [])))
|
|
362
452
|
const parsed = kind?.parse ? kind.parse(Object.fromEntries(Object.keys(kind.flags ?? {}).map((k) => [k, f.many[k] ?? []]))) : null
|
|
363
|
-
if (wipLine !== undefined && o.live !== undefined) throw new Error('--wip "<line>" sends a
|
|
453
|
+
if (wipLine !== undefined && o.live !== undefined) throw new Error('--wip "<line>" sends a version in work; --wip --live <name> a draft on a live shot: one of the two')
|
|
364
454
|
if (wipLine === undefined && f.on.has('wip') !== (o.live !== undefined))
|
|
365
|
-
throw new Error('--wip "<what is still wrong>" sends a
|
|
455
|
+
throw new Error('--wip "<what is still wrong>" sends a version in work (sk thread update as it moves); --wip --live <name> a draft on a live shot')
|
|
366
456
|
let wipViews: ViewInput[] = []
|
|
367
457
|
if (o.live !== undefined) {
|
|
368
458
|
if (!h.unit?.live) throw new Error("--live: the repo's review unit declares no live shots (live: { frames })")
|
|
369
|
-
if (o.image || o.video || o.audio || o.before || o.after || views.length > 0) throw new Error('--wip: the
|
|
459
|
+
if (o.image || o.video || o.audio || o.before || o.after || views.length > 0) throw new Error('--wip: the version shows the live shot alone, no --image, --video, pair or --view beside it')
|
|
370
460
|
const fr = h.unit.live.frames(o.live)
|
|
371
461
|
wipViews = [{ label: '', image: fr.image }, ...(fr.history.length > 0 ? [{ label: 'history', gallery: fr.history }] : [])]
|
|
372
462
|
}
|
|
@@ -408,6 +498,7 @@ export class ReviewAddCommand extends Command {
|
|
|
408
498
|
...(topic ? { topic } : {}),
|
|
409
499
|
...(trailer ? { image: trailer.image, trailer: trailer.card } : {}),
|
|
410
500
|
...(draft ? { draft } : {}),
|
|
501
|
+
...(states ? { states } : {}),
|
|
411
502
|
...(o.image ? { image: o.image } : {}),
|
|
412
503
|
...(o.video ? { video: o.video } : {}),
|
|
413
504
|
...(o.audio ? { audio: o.audio } : {}),
|
|
@@ -428,12 +519,21 @@ export class ReviewAddCommand extends Command {
|
|
|
428
519
|
...(o.pick !== undefined ? { agentPick: o.pick } : {}),
|
|
429
520
|
...(o.live !== undefined ? { image: wipViews[0]?.image ?? '', views: wipViews.slice(1), wip: { live: o.live } } : { views }),
|
|
430
521
|
}
|
|
522
|
+
const media = [o.image, o.video, o.audio, o.before, o.after, o.live, o.trailer, o.draft].some((v) => v !== undefined) || views.length > 0 || states !== null
|
|
523
|
+
if (!media && input.on !== undefined) return postWords(h, input.on, input.title, input.what, input.lane, f.on.has('verdict'))
|
|
524
|
+
// a version asks the owner's verdict always: the field says it, the flag changes nothing else
|
|
525
|
+
if (f.on.has('verdict')) input = { ...input, asksVerdict: true }
|
|
431
526
|
if (h.unit?.add) input = await h.unit.add(input, repoFlags)
|
|
527
|
+
const { ownAddressOf } = await import('../review/model.ts')
|
|
528
|
+
const address = ownAddressOf({ subject: input.subject ?? { kind: 'shot' }, ...(input.on ? { on: input.on } : {}), ...(input.trailer ? { trailer: input.trailer } : {}), origin: { by: 'agent' }, views: [] } as unknown as import('../review/model.ts').Item, h.say.spec)
|
|
529
|
+
if (address === null && input.supersedes === undefined && (input.answers ?? []).length === 0) {
|
|
530
|
+
trailer?.drop()
|
|
531
|
+
throw new Error(NO_ADDRESS)
|
|
532
|
+
}
|
|
432
533
|
const item = await addItem(h.dir, input).finally(() => trailer?.drop())
|
|
433
534
|
h.out(item.id)
|
|
434
535
|
// on stderr: a script reads the id alone on stdout
|
|
435
|
-
|
|
436
|
-
else if ((item.answers ?? []).some((a) => !answers.includes(a))) h.err(`into its thread: it answers the notes ${(item.answers ?? []).join(', ')}`)
|
|
536
|
+
await saidIntoThread(h, item, o.supersedes !== undefined)
|
|
437
537
|
if (wipLine !== undefined) {
|
|
438
538
|
const who = item.origin.by === 'agent' ? (item.origin.lane ?? agentName()) : agentName()
|
|
439
539
|
await postUpdate(h.dir, item.id, { who, state: 'broken', text: wipLine })
|
|
@@ -441,14 +541,14 @@ export class ReviewAddCommand extends Command {
|
|
|
441
541
|
}
|
|
442
542
|
// on stderr: a script reads the id alone on stdout
|
|
443
543
|
for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item)) h.err(line)
|
|
444
|
-
if (item.trailer) h.out(`trailer
|
|
544
|
+
if (item.trailer) h.out(`trailer version: ${item.trailer.trailer}/${item.trailer.after.cut}${item.trailer.before ? ` against ${item.trailer.before.cut}` : ''}${item.trailer.shots.length > 0 ? `, shots ${item.trailer.shots.join(', ')}` : ''}`)
|
|
445
545
|
// a cut shown on a card is a version from then on: the next edit of its file makes the one after it
|
|
446
546
|
if (item.trailer && o.trailer !== undefined && o.version === undefined) {
|
|
447
547
|
try {
|
|
448
548
|
const [b, { keepShown, thumbnailKept, versionVideo }, { findRepoRoot }] = await Promise.all([import('../trailer/build.ts'), import('../trailer/passage.ts'), import('../ts/config.ts')])
|
|
449
549
|
const root = findRepoRoot(process.cwd())
|
|
450
550
|
const l = await b.load(b.trailerFile(o.trailer, root, process.cwd()), root)
|
|
451
|
-
if ((await import('node:fs')).existsSync(b.mockMark(l))) h.err('the cut this
|
|
551
|
+
if ((await import('node:fs')).existsSync(b.mockMark(l))) h.err('the cut this version shows is a MOCK (sk trailer --mock built it last): its --what must say so; for the filmed cut, sk trailer first')
|
|
452
552
|
// a version is a video a post may use: a cut that may not render (no thumbnail word) keeps none
|
|
453
553
|
if (l.errors.length > 0) throw new Error(`${l.errors[0]!.message} (line ${l.errors[0]!.line})`)
|
|
454
554
|
const lines: string[] = []
|
|
@@ -462,12 +562,12 @@ export class ReviewAddCommand extends Command {
|
|
|
462
562
|
h.err(`WARN ${v} is kept, its thumbnail is not: ${(e as Error).message}`),
|
|
463
563
|
)
|
|
464
564
|
} catch (e) {
|
|
465
|
-
h.err(`WARN the
|
|
565
|
+
h.err(`WARN the version is sent, the cut was not kept as a version: ${(e as Error).message}`)
|
|
466
566
|
}
|
|
467
567
|
}
|
|
468
|
-
if (item.draft) h.out(`draft
|
|
469
|
-
if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the
|
|
470
|
-
if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk thread pick ${item.id} <view> (or --pick on
|
|
568
|
+
if (item.draft) h.out(`draft version: ${item.draft.slug}, ${item.draft.posts.length} place${item.draft.posts.length > 1 ? 's' : ''}: ${item.draft.posts.map((p) => p.name).join(', ')}`)
|
|
569
|
+
if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the version: pass --lane <id> (or SK_AGENT), so the hub colours it')
|
|
570
|
+
if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk thread pick ${item.id} <view> (or --pick on post)`)
|
|
471
571
|
const { unheardLine } = await import('../review/model.ts')
|
|
472
572
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
473
573
|
const unheard = unheardLine(item, liveWatchers(h.dir))
|
|
@@ -477,6 +577,120 @@ export class ReviewAddCommand extends Command {
|
|
|
477
577
|
}
|
|
478
578
|
}
|
|
479
579
|
|
|
580
|
+
/** what a version that went into a thread says on stderr: the version it follows (and that one's verdict, which only the
|
|
581
|
+
* newest version takes), the way out for a subject of its own, and his notes it leaves open */
|
|
582
|
+
/** `post <address> --before <state> --after <state>` on an object of a kind (threads-how-it-fits.md, Kinds): each side
|
|
583
|
+
* a json file (`{ json, files? }` or bare json), or a git ref (`.` the working tree) the kind's `read` turns into one;
|
|
584
|
+
* null when the flags are a picture's before and after. The flags it takes are cleared, so no media reads them */
|
|
585
|
+
async function statesOfFlags(h: Here, o: Record<string, string>, views: boolean): Promise<{ before?: import('../review/model.ts').StoredState; after: import('../review/model.ts').StoredState } | null> {
|
|
586
|
+
if (o.on === undefined || o.after === undefined) return null
|
|
587
|
+
const word = o.on.slice(0, o.on.indexOf(':'))
|
|
588
|
+
const key = o.on.slice(o.on.indexOf(':') + 1)
|
|
589
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
590
|
+
const root = findRepoRoot(process.cwd())
|
|
591
|
+
const kind = (await import('../review/house-kind-defs.ts')).serverKindOf(root, h.unit, word)
|
|
592
|
+
const json = (v: string): boolean => /\.json$/i.test(v)
|
|
593
|
+
if (!kind?.read && !json(o.after)) return null
|
|
594
|
+
if (views || o.image || o.video || o.audio) throw new Error(`${o.on}: a version of an object shows its two states alone, no picture beside them`)
|
|
595
|
+
const { existsSync, readFileSync } = await import('node:fs')
|
|
596
|
+
const side = async (flag: string, v: string): Promise<import('../review/model.ts').StoredState> => {
|
|
597
|
+
if (json(v)) {
|
|
598
|
+
if (!existsSync(v)) throw new Error(`--${flag} ${v}: no such file`)
|
|
599
|
+
const parsed = JSON.parse(readFileSync(v, 'utf8')) as unknown
|
|
600
|
+
return typeof parsed === 'object' && parsed !== null && 'json' in parsed ? (parsed as import('../review/model.ts').StoredState) : { json: parsed }
|
|
601
|
+
}
|
|
602
|
+
if (!kind?.read) throw new Error(`--${flag} ${v}: a json file, or a git ref the kind reads; the kind ${word} declares no read`)
|
|
603
|
+
let at: string | undefined
|
|
604
|
+
if (v !== '.') {
|
|
605
|
+
const p = Bun.spawnSync(['git', '-C', root, 'rev-parse', '--verify', '--quiet', `${v}^{commit}`], { stdout: 'pipe', stderr: 'ignore' })
|
|
606
|
+
at = p.stdout.toString().trim()
|
|
607
|
+
if (p.exitCode !== 0 || at === '') throw new Error(`--${flag} ${v}: no commit of this repo by that name (a json file, a git ref, or . for the working tree)`)
|
|
608
|
+
}
|
|
609
|
+
const st = await kind.read(key, at)
|
|
610
|
+
if (st === null) throw new Error(`--${flag} ${v}: the kind ${word} reads no ${key} there`)
|
|
611
|
+
return { ...st, ...(at ? { at } : {}) }
|
|
612
|
+
}
|
|
613
|
+
const after = await side('after', o.after)
|
|
614
|
+
const before = o.before !== undefined ? await side('before', o.before) : undefined
|
|
615
|
+
delete o.before
|
|
616
|
+
delete o.after
|
|
617
|
+
return { ...(before ? { before } : {}), after }
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/** `post --choice`, the older form of a question with media options: each view an option (its note after its label),
|
|
621
|
+
* the title and what its words, posted as the question into the address's thread; it prints the `ask` form */
|
|
622
|
+
async function choiceAsQuestion(h: Here, o: Record<string, string>, views: readonly ViewInput[], many: Record<string, string[]>): Promise<number> {
|
|
623
|
+
const versionOnly = ['changelog', 'rating', 'post', 'keeps', 'supersedes', 'trailer', 'draft', 'live', 'why'].filter((k) => o[k] !== undefined)
|
|
624
|
+
if (many.answers?.length) versionOnly.push('answers')
|
|
625
|
+
if (versionOnly.length > 0) throw new Error(`--choice is a question now, and a question takes no ${versionOnly.map((k) => `--${k}`).join(', ')}: ask, then post the version once he picked`)
|
|
626
|
+
if (views.some((v) => v.gallery)) throw new Error('--choice: a gallery is no option; a set he rates one by one stays a gallery version, a row per asset')
|
|
627
|
+
if (o.on === undefined) throw new Error(NO_ADDRESS)
|
|
628
|
+
const first = o.image ?? o.video ?? o.audio
|
|
629
|
+
const all: ViewInput[] = [...(first !== undefined ? [{ label: o.label ?? 'option 1', image: first }] : o.before !== undefined && o.after !== undefined ? [{ label: o.label ?? 'option 1', before: o.before, after: o.after }] : []), ...views]
|
|
630
|
+
const options = all.map((v) => ({ label: v.note?.trim() ? `${v.label}: ${v.note.trim()}` : v.label, files: v.before !== undefined && v.after !== undefined ? [v.before, v.after] : [v.image ?? v.video ?? v.audio ?? ''] }))
|
|
631
|
+
const { viewIndexOf } = await import('../review/model.ts')
|
|
632
|
+
const pick = o.pick === undefined ? undefined : /^\d+$/.test(o.pick) ? Number(o.pick) - 1 : viewIndexOf(all, o.pick)
|
|
633
|
+
const text = [o.title, o.what].filter((x) => x?.trim()).join('\n') || 'which one ?'
|
|
634
|
+
const form = `sk thread ask ${o.on} ${quoted(text.split('\n')[0]!)} ${options.map((x) => `--option ${quoted(`${x.label}=${x.files.join(',')}`)}`).join(' ')}${pick !== undefined ? ` --pick ${pick + 1}` : ''}`
|
|
635
|
+
h.err(`post --choice is now a question: ${form}`)
|
|
636
|
+
if (pick === undefined) h.err('no --pick: the house rule wants your pick on every question')
|
|
637
|
+
const { postAsk } = await import('../review/store.ts')
|
|
638
|
+
const as = o.lane
|
|
639
|
+
const id = await idOrOpen(h, o.on, o.title ?? text, as)
|
|
640
|
+
const m = await postAsk(h.dir, id, { who: actor(as, false, 'ask'), text, options, ...(pick !== undefined ? { pick } : {}) })
|
|
641
|
+
h.out(`${id} asked: ${m.ask?.options.map((x, i) => `${i + 1} ${x}${m.ask?.pick === i ? ' (your pick)' : ''}`).join(' · ')}`)
|
|
642
|
+
return 0
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
async function saidIntoThread(h: Here, item: import('../review/model.ts').Item, typed: boolean): Promise<void> {
|
|
646
|
+
const { readAll } = await import('../review/store.ts')
|
|
647
|
+
const { ownAddressOf, stateOf, verdictOf } = await import('../review/model.ts')
|
|
648
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
649
|
+
const items = readAll(h.dir).items
|
|
650
|
+
const t = threadOfItem(item.id, threadsOf(items, h.say.spec))
|
|
651
|
+
const own = ownAddressOf(item, h.say.spec)
|
|
652
|
+
const before = item.supersedes === undefined ? undefined : items.find((x) => x.item.id === item.supersedes)
|
|
653
|
+
if (before && !typed) {
|
|
654
|
+
const waited = verdictOf(before) === null && before.item.views.length > 0
|
|
655
|
+
h.err(`into its thread ${own ?? ''}: the next version after ${before.item.id} "${before.item.title}"${waited ? ', which waited on his answer: only this one takes his marks now' : ''}. A subject he judges on its own takes its own address: --on ${own ?? '<kind>:<key>'}/<part>`)
|
|
656
|
+
}
|
|
657
|
+
const notes = t ? [...(t.head.item.origin.by === 'agent' ? [] : [t.head]), ...t.answers.filter((x) => t.joined.has(x.item.id))] : []
|
|
658
|
+
const open = notes.filter((x) => stateOf(x, false).state !== 'closed' && !(item.answers ?? []).includes(x.item.id))
|
|
659
|
+
if (open.length > 0) h.err(`his notes in the thread stay open: ${open.map((x) => `${x.item.id} "${x.item.title}"`).join('; ')}. Close one once done: sk thread fixed <id> "<what was done>"; or name it on the version: --answers <id>`)
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** `post <address>` with no media: words that start the address's thread, or a reply in the thread it has */
|
|
663
|
+
async function postWords(h: Here, address: string, title: string, what: string, lane: string | undefined, verdict = false): Promise<number> {
|
|
664
|
+
const { agentName, openThread, readAll, specOf } = await import('../review/store.ts')
|
|
665
|
+
const { threadOfAddress } = await import('../review/threads.ts')
|
|
666
|
+
if (!title.trim() && !what.trim()) throw new Error('--title "<words>" (and --what): with no media, a post is words')
|
|
667
|
+
const t = threadOfAddress(address, readAll(h.dir).items, specOf(h.dir), { up: true })
|
|
668
|
+
if (t) {
|
|
669
|
+
const m = await wordsIn(h.dir, t.head.item.id, lane?.trim() || agentName(), [title.trim(), what.trim()].filter(Boolean).join('\n'), verdict)
|
|
670
|
+
h.out(`${t.head.item.id}: ${m.id}`)
|
|
671
|
+
h.err(`a word in the thread of ${address}${verdict ? ", waiting for the owner's verdict" : ''}`)
|
|
672
|
+
return 0
|
|
673
|
+
}
|
|
674
|
+
const x = await openThread(h.dir, address, { title: title.trim() || what.trim(), ...(what.trim() ? { what } : {}), ...(lane?.trim() ? { lane: lane.trim() } : {}), ...(verdict ? { asksVerdict: true as const } : {}) })
|
|
675
|
+
h.out(x.id)
|
|
676
|
+
h.err(`${address}: the thread starts with these words`)
|
|
677
|
+
return 0
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/** an agent's words in a thread, its image beside them; `verdict`: they wait for the owner's verdict (review/verdict-items.ts) */
|
|
681
|
+
async function wordsIn(dir: string, id: string, who: string, text: string, verdict: boolean, image?: string): Promise<import('../review/model.ts').Message> {
|
|
682
|
+
const { addMessage, appendMessage, readItem } = await import('../review/store.ts')
|
|
683
|
+
if (!verdict) return addMessage(dir, id, who, text, image)
|
|
684
|
+
const { textOf } = await import('../review/model.ts')
|
|
685
|
+
if (!readItem(dir, id)) throw new Error(`no card ${id}`)
|
|
686
|
+
const t = textOf(text)
|
|
687
|
+
if ('error' in t) throw new Error(t.error)
|
|
688
|
+
return appendMessage(dir, id, { who, text: t.text, asksVerdict: true }, image !== undefined ? { image } : {})
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/** `--verdict` on a posting verb: it waits for the owner's verdict (wiki tools/shipkit/threads-how-it-fits.md, The model) */
|
|
692
|
+
const VERDICT_FLAG = "it waits for the owner's verdict (approve, fix, reject on it in the hub, « judge » in the inbox): a thing made that the owner approves before it ships or lands; a choice of what to do is a question, a visible change a version, never on a progress line"
|
|
693
|
+
|
|
480
694
|
export class ReviewAddViewCommand extends Command {
|
|
481
695
|
static override paths = [['review', 'add-view']]
|
|
482
696
|
static essential = {}
|
|
@@ -556,7 +770,11 @@ export class ReviewLsCommand extends Command {
|
|
|
556
770
|
for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
557
771
|
const threads = orderedThreads(all.items).filter((t) => every || isActive(t))
|
|
558
772
|
if (threads.length === 0) h.out(every ? 'review: the store is empty' : 'review: nothing active (--all shows every thread)')
|
|
559
|
-
|
|
773
|
+
const { ownAddressesOf, threadTitle } = await import('../review/threads.ts')
|
|
774
|
+
for (const t of threads) {
|
|
775
|
+
const at = ownAddressesOf(t)[0]
|
|
776
|
+
h.out(`${statusOf(t.head, all.items).padEnd(17)} ${t.head.item.id} ${threadTitle(t)}${t.versions.length > 1 ? ` (v${t.versions.length})` : ''}${at ? ` ${at}` : ''}`)
|
|
777
|
+
}
|
|
560
778
|
return all.broken.length > 0 ? 1 : 0
|
|
561
779
|
},
|
|
562
780
|
{ unit: false },
|
|
@@ -566,14 +784,14 @@ export class ReviewLsCommand extends Command {
|
|
|
566
784
|
|
|
567
785
|
export class ReviewShowCommand extends Command {
|
|
568
786
|
static override paths = [['review', 'show']]
|
|
569
|
-
static essential = { args: '<id>' }
|
|
787
|
+
static essential = { args: '<address | id>' }
|
|
570
788
|
static override usage = Command.Usage({
|
|
571
789
|
category: 'Review',
|
|
572
790
|
description: 'one item and its thread: the verdict, rectangles, reactions, the whole conversation',
|
|
573
|
-
details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). --paste prints the short block that hands the
|
|
574
|
-
examples: [['hand a
|
|
791
|
+
details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). --paste prints the short block that hands the thread to another agent session (the hub's copy button gives the same).`,
|
|
792
|
+
examples: [['hand a thread to another session', 'sk thread show <id> --paste']],
|
|
575
793
|
})
|
|
576
|
-
id = Option.String()
|
|
794
|
+
id = Option.String({ name: 'address | id' })
|
|
577
795
|
paste = Option.Boolean('--paste', false, { description: 'the block another agent session acts on: title, repo, this command, the links' })
|
|
578
796
|
|
|
579
797
|
async execute(): Promise<number> {
|
|
@@ -622,7 +840,7 @@ export class ReviewInboxCommand extends Command {
|
|
|
622
840
|
category: 'Review',
|
|
623
841
|
description: 'every answer not marked seen and every open item he raised, frame notes included',
|
|
624
842
|
details: DETAILS,
|
|
625
|
-
examples: [['what waits on you', 'sk thread inbox'], ['his notes on trailer frames', 'sk thread inbox --subject frame'], ['the
|
|
843
|
+
examples: [['what waits on you', 'sk thread inbox'], ['his notes on trailer frames', 'sk thread inbox --subject frame'], ['the threads this session holds', 'sk thread inbox --mine'], ['as a Claude Code hook, on UserPromptSubmit and on Stop', 'sk thread inbox --hook']],
|
|
626
844
|
})
|
|
627
845
|
mine = Option.Boolean('--mine', false, { description: "only the threads this Claude Code session holds" })
|
|
628
846
|
session = Option.String('--session', { description: "only the threads that session holds" })
|
|
@@ -631,97 +849,193 @@ export class ReviewInboxCommand extends Command {
|
|
|
631
849
|
hook = Option.Boolean('--hook', false, { description: 'run as a Claude Code hook (UserPromptSubmit, Stop): the hook input on stdin, its json answer on stdout. The unseen answers join a prompt as context, and a turn does not end while one is unseen' })
|
|
632
850
|
|
|
633
851
|
async execute(): Promise<number> {
|
|
634
|
-
const {
|
|
852
|
+
const { hookPasses, hookSession, parseHookInput } = await import('../review/inbox-hook.ts')
|
|
635
853
|
// the hook input is one small json on stdin; a terminal has none
|
|
636
854
|
const input = this.hook ? parseHookInput(process.stdin.isTTY === true ? '' : await new Response(Bun.stdin.stream()).text().catch(() => '')) : null
|
|
637
855
|
if (input != null && hookPasses(input)) return 0
|
|
638
|
-
return run(this.context, async (
|
|
639
|
-
|
|
640
|
-
const unseenLines: string[] = []
|
|
641
|
-
const h = input == null ? hh : { ...hh, out: (l: string) => void unseenLines.push(l) }
|
|
642
|
-
const { liveWatchers } = await import('../review/watchers.ts')
|
|
643
|
-
const { readAll } = await import('../review/store.ts')
|
|
644
|
-
const { BUILTIN_KINDS, moveOf, stateOf, unreadBy, untakenOf, verdictOf } = await import('../review/model.ts')
|
|
645
|
-
const { followedIds, threadOfItem, threadsOf, unseen } = await import('../review/threads.ts')
|
|
646
|
-
const { detail, threadDetail, untakenLine } = await import('../review/format.ts')
|
|
856
|
+
return run(this.context, async (h) => {
|
|
857
|
+
const { BUILTIN_KINDS, untakenOf } = await import('../review/model.ts')
|
|
647
858
|
const kinds = [...Object.keys(h.say.spec.kinds), ...Object.keys(BUILTIN_KINDS)]
|
|
648
859
|
if (this.subject !== undefined && Object.keys(h.say.spec.kinds).length > 0 && !kinds.includes(this.subject)) throw new Error(`--subject: one of ${kinds.join(', ')}`)
|
|
649
|
-
const
|
|
860
|
+
const { selectInbox, selectedText, hookReply } = await import('../review/inbox-read.ts')
|
|
861
|
+
const { followedIds, hears, listenersOf, sinceHeLeft, threadByItem, threadsOf } = await import('../review/threads.ts')
|
|
862
|
+
const { untakenLine } = await import('../review/format.ts')
|
|
863
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
650
864
|
await pull(h)
|
|
651
|
-
const
|
|
652
|
-
for (const b of
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
return v?.status === 'approved' && !v.seen && !v.comment && v.rects.length === 0 && !v.reactions && v.pick === undefined && unreadBy(x, 'agent').length === 0
|
|
665
|
-
}
|
|
666
|
-
// as a hook: a raised item a lane claimed is in that lane's hands until it closes it, so it never blocks a turn
|
|
667
|
-
const inHand = (x: (typeof news)[number]): boolean => input != null && x.item.origin.by !== 'agent' && stateOf(x, followed.has(x.item.id)).state === 'claimed'
|
|
668
|
-
const shown = [...(this.all ? news : news.filter((x) => !plain(x))), ...open].filter((x) => !inHand(x))
|
|
669
|
-
if (shown.length === 0 && news.length === 0) h.out('review: no unseen feedback or reply')
|
|
670
|
-
const threads = threadsOf(all.items)
|
|
671
|
-
const printed = new Set<string>()
|
|
672
|
-
for (const x of shown) {
|
|
673
|
-
const t = threadOfItem(x.item.id, threads)
|
|
674
|
-
if (t && printed.has(t.head.item.id)) continue
|
|
675
|
-
if (t) printed.add(t.head.item.id)
|
|
676
|
-
h.out(`${t ? threadDetail(t, h.dir, false, h.say) : detail(x, h.dir, false, false, h.say)}\n`)
|
|
865
|
+
const here = await hereStore(h)
|
|
866
|
+
for (const b of here.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
867
|
+
if (input != null) {
|
|
868
|
+
// as a hook: what this session hears, in its own repo and in every store it or its lanes wrote in
|
|
869
|
+
const session = hookSession(input)
|
|
870
|
+
const { noteHanded, noteSession } = await import('../agent-time/registry.ts')
|
|
871
|
+
if (session !== null) noteSession(h.dir)
|
|
872
|
+
const stores = [here, ...(session === null ? [] : await storesOf(session, h.dir))]
|
|
873
|
+
const parties = await partiesFor(stores, session)
|
|
874
|
+
const me = { lane: null, session }
|
|
875
|
+
const answer = hookReply({ input, me, stores, parties, onHanded: noteHanded })
|
|
876
|
+
if (answer != null) h.out(answer)
|
|
877
|
+
return 0
|
|
677
878
|
}
|
|
678
|
-
|
|
679
|
-
const
|
|
680
|
-
const
|
|
879
|
+
const session = await sessionOf(this.mine, this.session)
|
|
880
|
+
const lane = this.mine ? laneOfCaller(undefined) : null
|
|
881
|
+
const parties = session === null && lane === null ? null : await partiesFor([here], session)
|
|
882
|
+
const since = sinceHeLeft(here.items)
|
|
883
|
+
if (since && since.moved > 0) h.out(`since you left (${since.at}): ${since.moved} moved, ${since.yours} yours\n`)
|
|
884
|
+
// his requests for a lane first: the orchestrator's (review/lane-ask.ts)
|
|
885
|
+
const { laneAsksFor } = await import('../review/inbox-read.ts')
|
|
886
|
+
for (const l of laneAsksFor(here, { session, lane }, parties ?? { sessions: [], lanes: [] })) h.out(`${l}\n`)
|
|
887
|
+
const sel = selectInbox(here, (x, byItem) => hears({ session, lane }, x, byItem, parties), { all: this.all, subject: this.subject })
|
|
888
|
+
if (sel.threads.length === 0 && sel.news.length === 0) h.out('review: no unseen feedback or reply')
|
|
889
|
+
for (const g of sel.threads) h.out(`${selectedText(here, g)}\n`)
|
|
890
|
+
const { ownAddressOf, verdictOf } = await import('../review/model.ts')
|
|
891
|
+
const owedLine = (t: (typeof sel.owed)[number]): string => {
|
|
892
|
+
const x = t.head
|
|
681
893
|
const fix = verdictOf(x)?.status === 'approved-with-fix'
|
|
682
|
-
const close = fix ? `sk thread
|
|
894
|
+
const close = fix ? `sk thread fixed ${x.item.id} "<what changed>"` : `its next version, sk thread post ${ownAddressOf(x.item, h.say.spec) ?? x.item.id} …`
|
|
683
895
|
return ` ${x.item.id} ${fix ? 'ok with a fix' : 'rejected'} "${x.item.title}": ${close}, or sk thread wontfix ${x.item.id} --note "<why>"`
|
|
684
896
|
}
|
|
685
|
-
if (
|
|
686
|
-
const approvals = news.filter(plain)
|
|
687
|
-
if (approvals.length > 0) h.out(`${approvals.length} plain approval(s), nothing to do: sk thread seen ${approvals.map((x) => x.item.id).join(' ')}`)
|
|
688
|
-
const said = unseenLines.filter((l) => l !== 'review: no unseen feedback or reply').join('\n').trim()
|
|
689
|
-
const answer = hookAnswer(input, said, owed.map((t) => t.head.item.id))
|
|
690
|
-
if (answer != null) hh.out(answer)
|
|
691
|
-
return 0
|
|
692
|
-
}
|
|
693
|
-
if (owed.length > 0) h.out(`owed, read and not done:\n${owed.map((t) => owedLine(t.head)).join('\n')}\n`)
|
|
897
|
+
if (sel.owed.length > 0) h.out(`owed, read and not done:\n${sel.owed.map(owedLine).join('\n')}\n`)
|
|
694
898
|
const watchers = liveWatchers(h.dir)
|
|
695
|
-
const
|
|
696
|
-
|
|
899
|
+
const byItem = threadByItem(threadsOf(here.items, h.say.spec))
|
|
900
|
+
const followed = followedIds(here.items)
|
|
901
|
+
const untaken = here.items.flatMap((x) => {
|
|
902
|
+
const why = untakenOf(x, followed.has(x.item.id), listenersOf(watchers, x, byItem).length > 0, new Date(), h.say.spec.dispatcher)
|
|
697
903
|
return why === null ? [] : [untakenLine(x, why, null)]
|
|
698
904
|
})
|
|
699
905
|
if (untaken.length > 0) h.out(`not taken:\n${untaken.join('\n')}\n`)
|
|
700
|
-
|
|
701
|
-
if (
|
|
702
|
-
|
|
703
|
-
return all.broken.length > 0 ? 1 : 0
|
|
906
|
+
if (sel.plain.length > 0) h.out(`review: ${sel.plain.length} plain approval(s), nothing to do: sk thread seen ${sel.plain.map((x) => x.item.id).join(' ')}`)
|
|
907
|
+
if (sel.threads.length > 0) h.out('mark each handled: sk thread seen <id>; close a raised one: sk thread fixed <id> --note "<what was done>"')
|
|
908
|
+
return here.broken.length > 0 ? 1 : 0
|
|
704
909
|
})
|
|
705
910
|
}
|
|
706
911
|
}
|
|
707
912
|
|
|
913
|
+
/** the store the verb stands in, read for the inbox */
|
|
914
|
+
async function hereStore(h: Here): Promise<import('../review/inbox-read.ts').StoreRead> {
|
|
915
|
+
const { readAll } = await import('../review/store.ts')
|
|
916
|
+
const { repoNameOf } = await import('../agent-time/registry.ts')
|
|
917
|
+
const { dirname } = await import('node:path')
|
|
918
|
+
const root = dirname(dirname(h.dir))
|
|
919
|
+
return { repo: repoNameOf(root), root, dir: h.dir, here: true, ...readAll(h.dir), say: h.say }
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/** every other store this session or its lanes wrote in (agent-time/registry.ts), each with its repo's unit bound */
|
|
923
|
+
async function storesOf(session: string, hereDir: string): Promise<import('../review/inbox-read.ts').StoreRead[]> {
|
|
924
|
+
const { forgetStores, readSessionRecords, repoNameOf } = await import('../agent-time/registry.ts')
|
|
925
|
+
const { existsSync } = await import('node:fs')
|
|
926
|
+
const { dirname, resolve } = await import('node:path')
|
|
927
|
+
const dirs: string[] = []
|
|
928
|
+
const gone: string[] = []
|
|
929
|
+
// only a store its commands run in: `sk thread seen` there refuses a folder that is no shipkit repo
|
|
930
|
+
for (const d of (readSessionRecords().find((r) => r.session === session)?.stores ?? []).filter((x) => resolve(x) !== resolve(hereDir)))
|
|
931
|
+
(existsSync(d) && (await reviewRoot(dirname(dirname(d)))) !== null ? dirs : gone).push(d)
|
|
932
|
+
forgetStores(session, gone)
|
|
933
|
+
const out: import('../review/inbox-read.ts').StoreRead[] = []
|
|
934
|
+
for (const dir of dirs) {
|
|
935
|
+
const root = dirname(dirname(dir))
|
|
936
|
+
try {
|
|
937
|
+
const { openReview, factLines } = await import('../review/project.ts')
|
|
938
|
+
const { readAll, specOf } = await import('../review/store.ts')
|
|
939
|
+
const { unit } = await openReview(root)
|
|
940
|
+
out.push({ repo: repoNameOf(root), root, dir, here: false, ...readAll(dir), say: { spec: specOf(dir), more: (x) => factLines(unit, x) } })
|
|
941
|
+
} catch {
|
|
942
|
+
// a store that does not read now: its own repo's hook and inbox say why
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return out
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/** the parties these stores' threads name: their holders' sessions and the caller's, with each store's live watches */
|
|
949
|
+
async function partiesFor(stores: readonly import('../review/inbox-read.ts').StoreRead[], self: string | null): Promise<import('../review/parties.ts').Parties> {
|
|
950
|
+
const { readParties } = await import('../agent-time/registry.ts')
|
|
951
|
+
const { holderOf, threadsOf } = await import('../review/threads.ts')
|
|
952
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
953
|
+
const ids = new Set<string>()
|
|
954
|
+
for (const s of stores) for (const t of threadsOf(s.items, s.say.spec)) {
|
|
955
|
+
const hs = holderOf(t)?.session
|
|
956
|
+
if (hs) ids.add(hs)
|
|
957
|
+
}
|
|
958
|
+
return readParties({ sessions: [...ids], watchers: stores.flatMap((s) => liveWatchers(s.dir)), self })
|
|
959
|
+
}
|
|
960
|
+
|
|
708
961
|
/** the lane that acts on a reply or a seen: --as, else SK_AGENT, else none */
|
|
709
962
|
const laneOfCaller = (as: string | undefined): string | null => as?.trim() || process.env.SK_AGENT?.trim() || null
|
|
710
963
|
|
|
711
|
-
/** why the caller may not
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
const {
|
|
964
|
+
/** why the caller may not mark his answer on this item seen (review/threads.ts seenRefusal, rule 4: the holder or its
|
|
965
|
+
* session), null when it may */
|
|
966
|
+
async function seenRefused(dir: string, id: string, as: string | undefined): Promise<string | null> {
|
|
967
|
+
const { readAll } = await import('../review/store.ts')
|
|
968
|
+
const { seenRefusal, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
969
|
+
const items = readAll(dir).items
|
|
970
|
+
const x = items.find((y) => y.item.id === id)
|
|
971
|
+
if (x === undefined) return null
|
|
972
|
+
const t = threadOfItem(id, threadsOf(items))
|
|
973
|
+
const { me, parties } = await callerParties(dir, t, as)
|
|
974
|
+
return seenRefusal(x, t, me, parties)
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/** the caller and the parties its thread's holder names */
|
|
978
|
+
async function callerParties(dir: string, t: import('../review/threads.ts').Thread | null, as: string | undefined): Promise<{ me: import('../review/parties.ts').Me; parties: import('../review/parties.ts').Parties }> {
|
|
979
|
+
const { sessionId } = await import('../review/store.ts')
|
|
980
|
+
const { holderOf } = await import('../review/threads.ts')
|
|
981
|
+
const { readParties } = await import('../agent-time/registry.ts')
|
|
715
982
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
716
|
-
const
|
|
717
|
-
|
|
983
|
+
const me = { lane: laneOfCaller(as), session: sessionId() }
|
|
984
|
+
const hs = t ? holderOf(t)?.session : undefined
|
|
985
|
+
return { me, parties: await readParties({ sessions: hs ? [hs] : [], watchers: liveWatchers(dir), self: me.session }) }
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/** the caller holds the item's thread, or is the session of the lane that does (rule 4, review/parties.ts maySee): it
|
|
989
|
+
* may close what that lane claimed, as itself */
|
|
990
|
+
async function callerHolds(dir: string, id: string, as: string | undefined): Promise<boolean> {
|
|
991
|
+
const { readAll } = await import('../review/store.ts')
|
|
992
|
+
const { holderOf, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
993
|
+
const { maySee } = await import('../review/parties.ts')
|
|
994
|
+
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
995
|
+
if (t === null) return false
|
|
996
|
+
const h = holderOf(t)
|
|
997
|
+
if (h === null) return false
|
|
998
|
+
const { me, parties } = await callerParties(dir, t, as)
|
|
999
|
+
return maySee(me, h, parties)
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/** `--replaces <object>`: the thread item `id` is in, and the message id the new object supersedes, once the caller may
|
|
1003
|
+
* (review/supersede.ts replaceRefusal: the holder or its session, an agent's object not superseded yet); thrown
|
|
1004
|
+
* before anything is written. A cell id the hub copies (`<item>/<message>`) names its message */
|
|
1005
|
+
async function replacing(dir: string, ref: string, target: string, as: string | undefined): Promise<{ id: string; replaces: string }> {
|
|
1006
|
+
const id = await idOf(dir, ref)
|
|
1007
|
+
const { readAll } = await import('../review/store.ts')
|
|
1008
|
+
const { membersOf, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1009
|
+
const { replaceRefusal } = await import('../review/supersede.ts')
|
|
1010
|
+
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
1011
|
+
if (t === null) throw new Error(`--replaces ${target}: ${id} reads in no thread`)
|
|
1012
|
+
const replaces = target.includes('/') ? target.slice(target.lastIndexOf('/') + 1) : target
|
|
1013
|
+
const no = replaceRefusal(membersOf(t), replaces, { holds: await mayHold(dir, t, as) })
|
|
1014
|
+
if (no !== null) throw new Error(no)
|
|
1015
|
+
return { id, replaces }
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/** the caller may act as the thread's holder: it holds it, or is the session of the lane that does, or nobody holds it */
|
|
1019
|
+
async function mayHold(dir: string, t: import('../review/threads.ts').Thread, as: string | undefined): Promise<boolean> {
|
|
1020
|
+
const { holderOf } = await import('../review/threads.ts')
|
|
1021
|
+
const { maySee } = await import('../review/parties.ts')
|
|
1022
|
+
const { me, parties } = await callerParties(dir, t, as)
|
|
1023
|
+
return maySee(me, holderOf(t), parties)
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** mayHold for the thread item `id` is in, false when it reads in none */
|
|
1027
|
+
export async function mayHoldItem(dir: string, id: string, as?: string): Promise<boolean> {
|
|
1028
|
+
const { readAll } = await import('../review/store.ts')
|
|
1029
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1030
|
+
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
1031
|
+
return t !== null && mayHold(dir, t, as)
|
|
718
1032
|
}
|
|
719
1033
|
|
|
720
1034
|
export class ReviewSeenCommand extends Command {
|
|
721
1035
|
static override paths = [['review', 'seen']]
|
|
722
|
-
static essential = { args: '<ids>' }
|
|
723
|
-
static override usage = Command.Usage({ category: 'Review', description: 'mark his
|
|
724
|
-
ids = Option.Rest({ required: 1 })
|
|
1036
|
+
static essential = { args: '<address | ids>' }
|
|
1037
|
+
static override usage = Command.Usage({ category: 'Review', description: 'mark his new words read as you read them: by id, or a whole thread by its address', details: DETAILS })
|
|
1038
|
+
ids = Option.Rest({ required: 1, name: 'address | id' })
|
|
725
1039
|
as = Option.String('--as', { description: 'the lane that read it (else SK_AGENT)' })
|
|
726
1040
|
|
|
727
1041
|
async execute(): Promise<number> {
|
|
@@ -729,8 +1043,23 @@ export class ReviewSeenCommand extends Command {
|
|
|
729
1043
|
const { markSeen } = await import('../review/store.ts')
|
|
730
1044
|
// every id checked before any is marked: his answer on another lane's card stays unread for that lane
|
|
731
1045
|
const ids: [string, string][] = []
|
|
732
|
-
|
|
733
|
-
|
|
1046
|
+
const { ID_RE } = await import('../review/model.ts')
|
|
1047
|
+
for (const ref of this.ids) {
|
|
1048
|
+
// an address: every item of its thread with an answer not marked seen
|
|
1049
|
+
if (!ID_RE.test(ref) && ref.includes(':')) {
|
|
1050
|
+
const { readAll } = await import('../review/store.ts')
|
|
1051
|
+
const { membersOf, threadOfItem, threadsOf, unseen } = await import('../review/threads.ts')
|
|
1052
|
+
const items = readAll(h.dir).items
|
|
1053
|
+
const t = threadOfItem(await idOf(h.dir, ref), threadsOf(items, h.say.spec))
|
|
1054
|
+
const members = new Set(t ? membersOf(t).map((x) => x.item.id) : [])
|
|
1055
|
+
const open = unseen(items).filter((x) => members.has(x.item.id))
|
|
1056
|
+
if (open.length === 0) h.out(`${ref}: nothing of his unseen`)
|
|
1057
|
+
for (const x of open) ids.push([x.item.id, x.item.id])
|
|
1058
|
+
continue
|
|
1059
|
+
}
|
|
1060
|
+
ids.push([ref, await idOf(h.dir, ref).catch(() => ref)])
|
|
1061
|
+
}
|
|
1062
|
+
const refused = (await Promise.all(ids.map(([, id]) => seenRefused(h.dir, id, this.as)))).filter((w) => w !== null)
|
|
734
1063
|
if (refused.length > 0) throw new Error(`nothing marked: ${refused.join('; ')}`)
|
|
735
1064
|
let bad = 0
|
|
736
1065
|
for (const [ref, id] of ids) {
|
|
@@ -745,22 +1074,141 @@ export class ReviewSeenCommand extends Command {
|
|
|
745
1074
|
}
|
|
746
1075
|
}
|
|
747
1076
|
|
|
1077
|
+
/** the longest « what I do now » line: a glance in his thread, never a report */
|
|
1078
|
+
const WORKING_MAX = 200
|
|
1079
|
+
|
|
1080
|
+
export class ThreadWorkingCommand extends Command {
|
|
1081
|
+
static override paths = [['thread', 'working']]
|
|
1082
|
+
static essential = { args: '<address | id> "<what I do now>"' }
|
|
1083
|
+
static override usage = Command.Usage({
|
|
1084
|
+
category: 'Review',
|
|
1085
|
+
description: 'say you are on his new words in a thread, one line of what you do now; your next act there ends it',
|
|
1086
|
+
details: `${DETAILS}\n\nMark his new words seen as you read them (sk thread seen), then, for work longer than your next call, say what you do with them here: he sees « L29 is on it: <line> » in the thread, its head and its row. It ends with the next act in the thread, yours or another agent's (a version, an update, a reply, a question, a change, a close, a take, a newer working), or once nothing moved for 2 h. A read with no act after it keeps his word owed: a turn's end holds on it. Never written for you: no watch, beat or hook says it (wiki tools/shipkit/threads-how-it-fits.md, Read and on it).`,
|
|
1087
|
+
examples: [['on it', 'SK_AGENT=L29 sk thread working page:backup "backing up the key in OpenBao"']],
|
|
1088
|
+
})
|
|
1089
|
+
ref = Option.String({ name: 'address | id' })
|
|
1090
|
+
line = Option.String()
|
|
1091
|
+
as = Option.String('--as', { description: 'the lane on it (else SK_AGENT)' })
|
|
1092
|
+
|
|
1093
|
+
async execute(): Promise<number> {
|
|
1094
|
+
return run(this.context, async (h) => {
|
|
1095
|
+
const line = this.line.trim()
|
|
1096
|
+
if (line === '') throw new Error('say what you do now: sk thread working <address> "<line>"')
|
|
1097
|
+
if (line.length > WORKING_MAX) throw new Error(`one short line: at most ${WORKING_MAX} characters, ${line.length} given`)
|
|
1098
|
+
const { appendMessage, readAll } = await import('../review/store.ts')
|
|
1099
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1100
|
+
const id = await idOf(h.dir, this.ref)
|
|
1101
|
+
const t = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1102
|
+
const who = laneOfCaller(this.as) ?? 'agent'
|
|
1103
|
+
appendMessage(h.dir, t?.head.item.id ?? id, { who, op: 'working', note: line })
|
|
1104
|
+
h.out(`${this.ref}: ${who} is on it: ${line} (your next act in this thread ends it)`)
|
|
1105
|
+
return 0
|
|
1106
|
+
})
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
export class ThreadTakeCommand extends Command {
|
|
1111
|
+
static override paths = [['thread', 'take']]
|
|
1112
|
+
static essential = { args: '<address | id>' }
|
|
1113
|
+
static override usage = Command.Usage({
|
|
1114
|
+
category: 'Review',
|
|
1115
|
+
description: 'hold a thread from now on: his answers on it reach you, and you mark them seen',
|
|
1116
|
+
details: `${DETAILS}\n\nWho holds a thread is the agent of its newest act in it; a take is that act with no words, its state left as it is. A thread whose agent ended, or one nobody hears (the inbox hook lists those at a session's prompt), becomes yours. Writing in a thread (reply, update, post) takes it too. A session takes its own ended lane's thread only to keep it when it cannot resume that lane: a resumed lane takes back what it held, and a session marks its lane's thread seen with no take (wiki tools/shipkit/threads-how-it-fits.md, The parties).`,
|
|
1117
|
+
examples: [['a thread its ended session left', 'sk thread take asset:start'], ['as a lane', 'SK_AGENT=L4 sk thread take screen:orders/list']],
|
|
1118
|
+
})
|
|
1119
|
+
ref = Option.String({ name: 'address | id' })
|
|
1120
|
+
as = Option.String('--as', { description: 'the lane that takes it (else SK_AGENT)' })
|
|
1121
|
+
|
|
1122
|
+
async execute(): Promise<number> {
|
|
1123
|
+
return run(this.context, async (h) => {
|
|
1124
|
+
const { appendMessage, readAll } = await import('../review/store.ts')
|
|
1125
|
+
const { holderOf, hearingOfThread, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1126
|
+
const { sessionLabel } = await import('../review/parties.ts')
|
|
1127
|
+
const id = await idOf(h.dir, this.ref)
|
|
1128
|
+
const before = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1129
|
+
const head = before?.head.item.id ?? id
|
|
1130
|
+
const was = before ? holderOf(before) : null
|
|
1131
|
+
const { dropHanded, readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
1132
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
1133
|
+
const { sessionId } = await import('../review/store.ts')
|
|
1134
|
+
const lane = laneOfCaller(this.as)
|
|
1135
|
+
appendMessage(h.dir, head, { who: lane ?? 'agent', op: 'take' })
|
|
1136
|
+
// taken here: the ended lane, resumed later, leaves it to its taker
|
|
1137
|
+
const self = sessionId()
|
|
1138
|
+
if (self) dropHanded(self, h.dir, head, lane)
|
|
1139
|
+
const after = threadOfItem(head, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1140
|
+
const now = after ? holderOf(after) : null
|
|
1141
|
+
const parties = await readParties({ sessions: [...new Set([was?.session, now?.session].filter((x): x is string => !!x))], watchers: liveWatchers(h.dir), self: sessionId() })
|
|
1142
|
+
const { dirname } = await import('node:path')
|
|
1143
|
+
const hearing = after ? hearingOfThread(after, parties, repoNameOf(dirname(dirname(h.dir)))) : null
|
|
1144
|
+
const wasText = was === null ? 'nobody held it' : `it was held by ${was.lane ?? sessionLabel(was.session, parties)}`
|
|
1145
|
+
h.out(`${this.ref}: yours now (${hearing?.chip ?? lane ?? 'this session'}), ${wasText}; ${hearing?.words ?? ''}`)
|
|
1146
|
+
if (hearing && hearing.light !== 'hears') h.err(`review: no watch of yours hears it now: sk thread watch --mine under a monitor`)
|
|
1147
|
+
return 0
|
|
1148
|
+
})
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
export class ThreadAssignCommand extends Command {
|
|
1153
|
+
static override paths = [['thread', 'assign']]
|
|
1154
|
+
static override usage = Command.Usage({
|
|
1155
|
+
category: 'Review',
|
|
1156
|
+
description: 'give a thread to a lane: it holds it, a trace line names who gave it',
|
|
1157
|
+
details: `${DETAILS}\n\nThe orchestrator's answer to the owner's « start a lane »: on a thread nobody holds, sk thread take it first; then SendMessage to a live lane, or start a sub-agent with the thread as its brief (nothing starts a process for you); then assign the thread to that lane. The lane holds it (a take under its name, the state left as it is), and its trace line reads « L65 took the thread: assigned by app main ». The request clears at the lane's first act there: tell it to say \`sk thread working <address> "…"\` first (wiki tools/shipkit/threads-how-it-fits.md, A lane he asks for).`,
|
|
1158
|
+
examples: [['a lane for the thread he asked one on', 'sk thread assign screen:orders/list L65']],
|
|
1159
|
+
})
|
|
1160
|
+
ref = Option.String({ name: 'address | id' })
|
|
1161
|
+
lane = Option.String()
|
|
1162
|
+
|
|
1163
|
+
async execute(): Promise<number> {
|
|
1164
|
+
return run(this.context, async (h) => {
|
|
1165
|
+
const { AGENT_RE } = await import('../review/model.ts')
|
|
1166
|
+
const lane = this.lane.trim()
|
|
1167
|
+
if (!AGENT_RE.test(lane) || lane === 'agent' || lane === 'owner' || lane === 'player') throw new Error(`« ${lane} » is no lane name: sk thread assign <address> L<n>`)
|
|
1168
|
+
const { appendMessage, readAll, sessionId } = await import('../review/store.ts')
|
|
1169
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1170
|
+
const { sessionLabel } = await import('../review/parties.ts')
|
|
1171
|
+
const { dropHanded, readParties } = await import('../agent-time/registry.ts')
|
|
1172
|
+
const id = await idOf(h.dir, this.ref)
|
|
1173
|
+
const head = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))?.head.item.id ?? id
|
|
1174
|
+
const self = sessionId()
|
|
1175
|
+
const by = laneOfCaller(undefined) ?? (self ? sessionLabel(self, await readParties({ sessions: [], self })) : 'a terminal')
|
|
1176
|
+
appendMessage(h.dir, head, { who: lane, op: 'take', note: `assigned by ${by}` })
|
|
1177
|
+
if (self) dropHanded(self, h.dir, head, lane)
|
|
1178
|
+
h.out(`${this.ref}: given to ${lane} (assigned by ${by}): its first act there (sk thread working ${this.ref} "…") clears his request`)
|
|
1179
|
+
return 0
|
|
1180
|
+
})
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
748
1184
|
export class ReviewReplyCommand extends Command {
|
|
749
1185
|
static override paths = [['review', 'reply']]
|
|
750
|
-
static essential = { args: '<id> <text>' }
|
|
1186
|
+
static essential = { args: '<address | id> <text>' }
|
|
751
1187
|
static override usage = Command.Usage({ category: 'Review', description: "your message in a thread: what you changed, the answer to his question", details: DETAILS })
|
|
752
|
-
id = Option.String()
|
|
1188
|
+
id = Option.String({ name: 'address | id' })
|
|
753
1189
|
text = Option.String()
|
|
754
1190
|
image = Option.String('--image', { description: 'an image beside the words' })
|
|
755
1191
|
as = Option.String('--as', { description: 'the lane that answers (else SK_AGENT)' })
|
|
1192
|
+
urgent = Option.Boolean('--urgent', false, { description: 'brings back a thread he set aside, at once: only under the bar of a ping (an incident, a hard block, a deadline before it comes back)' })
|
|
1193
|
+
replaces = Option.String('--replaces', { description: 'the id of your earlier words (or question, or change) these supersede: it folds to one line « superseded by … » and leaves the dock, its answers kept' })
|
|
1194
|
+
verdict = Option.Boolean('--verdict', false, { description: VERDICT_FLAG })
|
|
756
1195
|
|
|
757
1196
|
async execute(): Promise<number> {
|
|
758
1197
|
return run(this.context, async (h) => {
|
|
759
|
-
const {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
1198
|
+
const { agentName, appendMessage } = await import('../review/store.ts')
|
|
1199
|
+
if (this.replaces !== undefined) {
|
|
1200
|
+
if (this.image !== undefined) throw new Error('--replaces with --image: post the image as its own reply')
|
|
1201
|
+
const { textOf } = await import('../review/model.ts')
|
|
1202
|
+
const r = await replacing(h.dir, this.id, this.replaces, this.as)
|
|
1203
|
+
const t = textOf(this.text)
|
|
1204
|
+
if ('error' in t) throw new Error(t.error)
|
|
1205
|
+
const m = appendMessage(h.dir, r.id, { who: laneOfCaller(this.as) ?? agentName(), text: t.text, replaces: r.replaces, ...(this.verdict ? { asksVerdict: true as const } : {}) })
|
|
1206
|
+
h.out(`${r.id}: ${m.id} supersedes ${r.replaces}`)
|
|
1207
|
+
return 0
|
|
1208
|
+
}
|
|
1209
|
+
const id = await idOrOpen(h, this.id, this.text, this.as)
|
|
1210
|
+
const m = await wordsIn(h.dir, id, laneOfCaller(this.as) ?? agentName(), this.text, this.verdict, this.image)
|
|
1211
|
+
if (this.urgent) await urgentOn(h.dir, id, laneOfCaller(this.as) ?? agentName())
|
|
764
1212
|
h.out(`${id}: ${m.id}`)
|
|
765
1213
|
return 0
|
|
766
1214
|
})
|
|
@@ -769,11 +1217,11 @@ export class ReviewReplyCommand extends Command {
|
|
|
769
1217
|
|
|
770
1218
|
export class ReviewUpdateCommand extends Command {
|
|
771
1219
|
static override paths = [['review', 'update']]
|
|
772
|
-
static essential = { args: '<id>
|
|
1220
|
+
static essential = { args: '<address | id> [state] <text>' }
|
|
773
1221
|
static override usage = Command.Usage({
|
|
774
1222
|
category: 'Review',
|
|
775
|
-
description: "where a thread's work stands, no answer needed: broken, better or
|
|
776
|
-
details: `${DETAILS}\n\nsk thread update <id> <broken|better|fixed> "<one line>" [<file> | <before> <after>]: the file (an image, a clip or a sound, as it is: no special file) becomes the
|
|
1223
|
+
description: "where a thread's work stands, no answer needed: broken, better, fixed or a plain line; a file",
|
|
1224
|
+
details: `${DETAILS}\n\nsk thread update <id> <broken|better|fixed> "<one line>" [<file> | <before> <after>]: the file (an image, a clip or a sound, as it is: no special file) becomes the version's next view, the line and the state go on its thread in time order. Two files make that view a before and after pair, as add --before --after does: two images of one size, two clips of one size and length, or two sounds, never one of each; the owner picks how he compares them (side by side, wipe, fade). broken or better holds the version « in progress » (not waiting on the owner's verdict, still new in the list), fixed asks the owner's verdict again on the same thread, even after an answer. The owner's hint on an update reaches watch and inbox as a reply « on update <k> ». Posted on the thread's newest version.`,
|
|
777
1225
|
examples: [
|
|
778
1226
|
['still broken, the take as it is', 'SK_AGENT=L2 sk thread update <id> broken "her arm still crosses her leg at 2 s" take.mp4'],
|
|
779
1227
|
['better, not done', 'SK_AGENT=L2 sk thread update <id> better "the crossing is gone, the landing still snaps" take.mp4'],
|
|
@@ -781,29 +1229,46 @@ export class ReviewUpdateCommand extends Command {
|
|
|
781
1229
|
['better, as a before and after he compares his way', 'SK_AGENT=L2 sk thread update <id> better "the snap is half as deep" before.mp4 after.mp4'],
|
|
782
1230
|
],
|
|
783
1231
|
})
|
|
784
|
-
id = Option.String()
|
|
1232
|
+
id = Option.String({ name: 'address | id' })
|
|
785
1233
|
state = Option.String()
|
|
786
|
-
|
|
787
|
-
|
|
1234
|
+
// the line and the files are one rest: clipanion never fills an optional positional that a rest follows
|
|
1235
|
+
rest = Option.Rest()
|
|
1236
|
+
get text(): string | undefined {
|
|
1237
|
+
return this.rest[0]
|
|
1238
|
+
}
|
|
1239
|
+
get files(): string[] {
|
|
1240
|
+
return this.rest.slice(1)
|
|
1241
|
+
}
|
|
788
1242
|
as = Option.String('--as', { description: 'the lane that posts (else SK_AGENT)' })
|
|
789
|
-
keep = Option.Boolean('--keep', false, { description: 'its pictures as given: a png lands as a lossless webp otherwise, its pixels checked exact, and the
|
|
1243
|
+
keep = Option.Boolean('--keep', false, { description: 'its pictures as given: a png lands as a lossless webp otherwise, its pixels checked exact, and the version keeps only the webp' })
|
|
1244
|
+
verdict = Option.Boolean('--verdict', false, { description: `on a plain line only: ${VERDICT_FLAG}` })
|
|
790
1245
|
|
|
791
1246
|
async execute(): Promise<number> {
|
|
792
1247
|
return run(this.context, async (h) => {
|
|
793
1248
|
const { postUpdate, agentName, readAll } = await import('../review/store.ts')
|
|
794
1249
|
const { threadsOf } = await import('../review/threads.ts')
|
|
795
1250
|
const { threadOfId } = await import('../review/cells.ts')
|
|
796
|
-
const
|
|
1251
|
+
const { UPDATE_STATES } = await import('../review/model.ts')
|
|
1252
|
+
// fixed asks the version's verdict again, broken and better hold it in work: a verdict of their own would be two answers on one cell
|
|
1253
|
+
if (this.verdict && this.text !== undefined) throw new Error(`update ${this.state} --verdict: ${this.state === 'fixed' ? "fixed already asks the owner's verdict on the version" : `${this.state} holds the version in work, its hint box is the owner's answer`}; --verdict goes on a plain line`)
|
|
1254
|
+
// no state: a plain progress line, a reply on the newest version
|
|
1255
|
+
if (this.text === undefined) {
|
|
1256
|
+
if ((UPDATE_STATES as readonly string[]).includes(this.state)) throw new Error(`update <address | id> ${this.state} "<one line>": the line is missing`)
|
|
1257
|
+
const at = await idOrOpen(h, this.id, this.state, this.as)
|
|
1258
|
+
const on = threadOfId(at, threadsOf(readAll(h.dir).items))?.head.item.id ?? at
|
|
1259
|
+
const m = await wordsIn(h.dir, on, laneOfCaller(this.as) ?? agentName(), this.state, this.verdict)
|
|
1260
|
+
h.out(`${on}: ${m.id}, a line, no state`)
|
|
1261
|
+
return 0
|
|
1262
|
+
}
|
|
1263
|
+
const asked = await idOrOpen(h, this.id, this.text, this.as)
|
|
797
1264
|
// an update goes where he reads: the thread's newest version
|
|
798
1265
|
const id = threadOfId(asked, threadsOf(readAll(h.dir).items))?.head.item.id ?? asked
|
|
799
|
-
const refused = await answererRefusal(h.dir, id, this.as, 'reply')
|
|
800
|
-
if (refused !== null) throw new Error(refused)
|
|
801
1266
|
const r = await postUpdate(h.dir, id, { who: laneOfCaller(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files, ...(this.keep ? { keep: true } : {}) })
|
|
802
1267
|
const { viewNo, stateOf } = await import('../review/model.ts')
|
|
803
1268
|
const { readItem } = await import('../review/store.ts')
|
|
804
1269
|
const x = readItem(h.dir, id)
|
|
805
1270
|
const now = x && stateOf(x, false).state === 'asks' ? "waits for the owner's verdict" : x && stateOf(x, false).state === 'draft' ? 'in progress, no verdict asked' : 'in work'
|
|
806
|
-
h.out(`${id}: ${r.tag}${r.view !== null ? `, view ${viewNo(r.view)}` : ''}${id !== asked ? ` (on the newest version, ${asked} is older)` : ''}; the
|
|
1271
|
+
h.out(`${id}: ${r.tag}${r.view !== null ? `, view ${viewNo(r.view)}` : ''}${id !== asked ? ` (on the newest version, ${asked} is older)` : ''}; the version ${now}`)
|
|
807
1272
|
if (r.view !== null) for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, r.item, r.view)) h.err(line)
|
|
808
1273
|
const { unheardLine } = await import('../review/model.ts')
|
|
809
1274
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
@@ -816,18 +1281,37 @@ export class ReviewUpdateCommand extends Command {
|
|
|
816
1281
|
|
|
817
1282
|
export class ReviewWithdrawCommand extends Command {
|
|
818
1283
|
static override paths = [['review', 'withdraw']]
|
|
819
|
-
static override usage = Command.Usage({
|
|
1284
|
+
static override usage = Command.Usage({
|
|
1285
|
+
category: 'Review',
|
|
1286
|
+
description: 'take back an unanswered version, or one open question or change by its message id, with the reason',
|
|
1287
|
+
details: `${DETAILS}\n\nA version (or a thread's card) withdrawn asks nothing more: its open questions and changes wait on nobody with it. A message id (sk thread show prints them) takes back that one question or change alone. --chat "<the owner's words>": the owner answered it in chat; the words are the reason, quoted, so it never stays open in the hub.`,
|
|
1288
|
+
examples: [
|
|
1289
|
+
['a version taken back', 'sk thread withdraw 20261120-101500-the-logo --why "a newer one follows"'],
|
|
1290
|
+
['he answered the question in chat', 'sk thread withdraw 20261120-223154-747-agent-vg49 --chat "B only, keep both kill matrices"'],
|
|
1291
|
+
],
|
|
1292
|
+
})
|
|
820
1293
|
ids = Option.Rest({ required: 1 })
|
|
821
|
-
why = Option.String('--why,--note', { required:
|
|
1294
|
+
why = Option.String('--why,--note', { required: false, description: 'why it goes (--note says the same, as on fixed, wontfix, blocked and drop)' })
|
|
1295
|
+
chat = Option.String('--chat', { required: false, description: 'the owner answered it in chat: the words become the reason, quoted' })
|
|
822
1296
|
|
|
823
1297
|
async execute(): Promise<number> {
|
|
824
1298
|
return run(this.context, async (h) => {
|
|
825
|
-
const { withdraw } = await import('../review/store.ts')
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
1299
|
+
const { answeredInChat, withdraw, withdrawObject } = await import('../review/store.ts')
|
|
1300
|
+
const { MESSAGE_RE } = await import('../review/model.ts')
|
|
1301
|
+
const why = this.chat?.trim() ? answeredInChat(this.chat) : this.why?.trim()
|
|
1302
|
+
if (!why) throw new Error('--why "<why it goes>", or --chat "<the owner\'s words>" when the owner answered it in chat')
|
|
1303
|
+
for (const ref of this.ids) {
|
|
1304
|
+
const msg = ref.includes('/') ? ref.slice(ref.indexOf('/') + 1) : ref
|
|
1305
|
+
if (MESSAGE_RE.test(msg)) {
|
|
1306
|
+
const r = withdrawObject(h.dir, msg, why)
|
|
1307
|
+
if ('refused' in r) throw new Error(r.refused)
|
|
1308
|
+
h.out(`${msg}: withdrawn (${why}); it waits on nobody now`)
|
|
1309
|
+
continue
|
|
1310
|
+
}
|
|
1311
|
+
const id = await idOf(h.dir, ref)
|
|
1312
|
+
const r = withdraw(h.dir, id, why)
|
|
829
1313
|
if ('refused' in r) throw new Error(r.refused)
|
|
830
|
-
h.out(r.already ? `${id}: withdrawn already (${r.already}), nothing to do` : `${id}: withdrawn`)
|
|
1314
|
+
h.out(r.already ? `${id}: withdrawn already (${r.already}), nothing to do` : `${id}: withdrawn, its open questions and changes with it`)
|
|
831
1315
|
}
|
|
832
1316
|
return 0
|
|
833
1317
|
})
|
|
@@ -847,7 +1331,7 @@ export class ReviewReopenCommand extends Command {
|
|
|
847
1331
|
for (const ref of this.ids) {
|
|
848
1332
|
const id = await idOf(h.dir, ref)
|
|
849
1333
|
const v = reopen(h.dir, id)
|
|
850
|
-
if (!v) throw new Error(`${id}: no such
|
|
1334
|
+
if (!v) throw new Error(`${id}: no such version, or no answer to reopen`)
|
|
851
1335
|
await followAnswer(dirname(dirname(h.dir)), id, v.status)
|
|
852
1336
|
}
|
|
853
1337
|
h.out(`review: ${this.ids.length} reopened`)
|
|
@@ -858,10 +1342,12 @@ export class ReviewReopenCommand extends Command {
|
|
|
858
1342
|
|
|
859
1343
|
export class ReviewPickCommand extends Command {
|
|
860
1344
|
static override paths = [['review', 'pick']]
|
|
1345
|
+
/** for an older choice version: a question's pick is fixed when it is asked */
|
|
1346
|
+
static older = true
|
|
861
1347
|
static override usage = Command.Usage({
|
|
862
1348
|
category: 'Review',
|
|
863
1349
|
description: "the option you suggest on a choice he has not answered: the hub's « my pick » pill on it",
|
|
864
|
-
details: `${DETAILS}\n\nsk thread pick <id> <view>: the view by its letter (B) or its label; one pick a
|
|
1350
|
+
details: `${DETAILS}\n\nsk thread pick <id> <view>: the view by its letter (B) or its label; one pick a version, a new one replaces it; for an older choice version (a question's pick is fixed at ask).`,
|
|
865
1351
|
examples: [['suggest the second option', 'sk thread pick <id> B'], ['by its label', 'sk thread pick <id> "Zen Garden"']],
|
|
866
1352
|
})
|
|
867
1353
|
id = Option.String({ required: true })
|
|
@@ -886,27 +1372,89 @@ type ActOp = 'fixed' | 'wontfix' | 'claim' | 'release' | 'blocked' | 'done' | 'd
|
|
|
886
1372
|
function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'optional'; text?: string; topic?: 'required' | 'optional'; named: boolean; examples: [string, string][] }) {
|
|
887
1373
|
return class extends Command {
|
|
888
1374
|
static override paths = [['review', op]]
|
|
889
|
-
static essential = op === '
|
|
1375
|
+
static essential = op === 'ask' ? { args: '<address | id> "<question>" --option … --pick <n>' } : undefined
|
|
1376
|
+
static gloss = op === 'done' ? 'the old name of fixed' : undefined
|
|
1377
|
+
static older = op === 'done' ? true : undefined
|
|
890
1378
|
static override usage = Command.Usage({ category: 'Review', description, details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). ${o.named ? 'Who acts: --as <name>, else SK_AGENT.' : 'Who acts: --as, else SK_AGENT, else agent.'}`, examples: o.examples })
|
|
891
|
-
id = Option.String()
|
|
1379
|
+
id = Option.String({ name: 'address | id' })
|
|
892
1380
|
words = o.text !== undefined || o.topic !== undefined ? Option.String({ required: false, name: o.text ?? 'topic' }) : undefined
|
|
893
1381
|
note = o.note === 'required' ? Option.String('--note', { required: true, description: 'what was done, why not, or what is needed' }) : Option.String('--note', { description: 'what was done, or the reason' })
|
|
894
1382
|
commit = Option.String('--commit', { description: 'the commit that holds the fix' })
|
|
895
1383
|
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
896
|
-
options = op === 'ask' ? Option.Array('--option', { description: 'a question he answers in one click: each option (two or more); any agent asks this way, the dispatcher asks without' }) : undefined
|
|
1384
|
+
options = op === 'ask' ? Option.Array('--option', { description: 'a question he answers in one click: each option (two or more), words, a file (a picture, a clip, a sound: its name the label), "<label>=<file>" or "<label>=<before>,<after>"; any agent asks this way, the dispatcher asks without' }) : undefined
|
|
897
1385
|
pick = op === 'ask' ? Option.String('--pick', { description: 'with --option: the option you pick, by its number from 1 (the house rule: a pick on every question)' }) : undefined
|
|
1386
|
+
checklist = op === 'ask' ? Option.Array('--checklist', { description: 'a checklist he ticks, line by line, over days: each line a step, words on one line (markdown: bold, a link, code)' }) : undefined
|
|
1387
|
+
confirm = op === 'ask' ? Option.Boolean('--confirm', false, { description: 'one step he does in the real world: he answers « done »' }) : undefined
|
|
1388
|
+
text = op === 'ask' ? Option.Boolean('--text', false, { description: 'a value he types: a line or a paragraph' }) : undefined
|
|
1389
|
+
url = op === 'ask' ? Option.Boolean('--url', false, { description: 'a link he pastes (a proof, a listing): the hub opens it once and says its status' }) : undefined
|
|
1390
|
+
secret = op === 'ask' ? Option.String('--secret', { description: 'a key he types into the vault under this name: the thread keeps « stored as <name> », you use it as $(sk secret get <name>) inside the command that needs it; typed in the hub on the Mac that runs it or on his phone over the tailnet' }) : undefined
|
|
1391
|
+
after = op === 'ask' ? Option.String('--after', { description: 'set the thread aside until then (2h, tomorrow, next-week, YYYY-MM-DD[THH:MM]): your question waits for that day; only when you post it' }) : undefined
|
|
1392
|
+
urgent = op === 'ask' ? Option.Boolean('--urgent', false, { description: 'brings back a thread he set aside, at once: only under the bar of a ping (an incident, a hard block, a deadline before it comes back)' }) : undefined
|
|
1393
|
+
login = op === 'ask' ? Option.Boolean('--login', false, { description: 'with --secret: a login, its account (the email or user name) typed and stored beside it' }) : undefined
|
|
1394
|
+
replaces = op === 'ask' ? Option.String('--replaces', { description: 'the id of your earlier question (or words) this one supersedes: it folds to one line « superseded by … » and leaves the dock, his answers on it kept' }) : undefined
|
|
1395
|
+
verdict = op === 'ask' ? Option.Boolean('--verdict', false, { description: "refused: a question waits for the owner's answer already, his answer is its verdict" }) : undefined
|
|
1396
|
+
|
|
1397
|
+
/** the thread item the question goes on and what it supersedes: never a new thread when it supersedes */
|
|
1398
|
+
async target(h: Here): Promise<{ id: string; replaces?: string }> {
|
|
1399
|
+
if (this.replaces === undefined) return { id: await idOrOpen(h, this.id, this.words ?? '', this.as) }
|
|
1400
|
+
return replacing(h.dir, this.id, this.replaces, this.as)
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** after a question: set aside until --after, or brought back by --urgent */
|
|
1404
|
+
async later(h: Here, id: string): Promise<void> {
|
|
1405
|
+
if (this.urgent) await urgentOn(h.dir, id, actor(this.as, false, op))
|
|
1406
|
+
if (this.after === undefined) return
|
|
1407
|
+
const { asideAt, snoozeThread } = await import('../review/snooze.ts')
|
|
1408
|
+
const until = asideAt(this.after)
|
|
1409
|
+
if (until === null) throw new Error(`--after ${this.after}: 2h, tomorrow, next-week, or YYYY-MM-DD[THH:MM]`)
|
|
1410
|
+
snoozeThread(h.dir, id, { until, who: actor(this.as, false, op) })
|
|
1411
|
+
h.out(` set aside until ${until.toLocaleString()}: out of his turn until then`)
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/** the answer kind the flags name, null for none (a choice through --option, or the dispatcher's question) */
|
|
1415
|
+
kindFlags(): { kind: AnswerKind; label: string } | null {
|
|
1416
|
+
const named = [
|
|
1417
|
+
...((this.checklist?.length ?? 0) > 0 ? [{ kind: 'checklist' as const, label: '--checklist' }] : []),
|
|
1418
|
+
...(this.confirm ? [{ kind: 'confirm' as const, label: '--confirm' }] : []),
|
|
1419
|
+
...(this.text ? [{ kind: 'text' as const, label: '--text' }] : []),
|
|
1420
|
+
...(this.url ? [{ kind: 'url' as const, label: '--url' }] : []),
|
|
1421
|
+
...(this.secret !== undefined ? [{ kind: 'secret' as const, label: '--secret' }] : []),
|
|
1422
|
+
]
|
|
1423
|
+
if (named.length > 1 || (named.length === 1 && this.options !== undefined)) throw new Error(`one answer kind a question: ${[...named.map((k) => k.label), ...(this.options !== undefined ? ['--option'] : [])].join(' and ')} together; ask twice`)
|
|
1424
|
+
if (this.login && this.secret === undefined) throw new Error('--login goes with --secret <name>')
|
|
1425
|
+
return named[0] ?? null
|
|
1426
|
+
}
|
|
898
1427
|
|
|
899
1428
|
async execute(): Promise<number> {
|
|
900
1429
|
return run(this.context, async (h) => {
|
|
901
1430
|
const { act, readItem } = await import('../review/store.ts')
|
|
1431
|
+
if (op === 'done') h.err(`sk thread done is now sk thread fixed ${this.id} "<what changed>"`)
|
|
1432
|
+
if (this.verdict) throw new Error("ask --verdict: a question waits for the owner's answer already, his answer is its verdict; a thing made he approves goes in a reply --verdict")
|
|
1433
|
+
const k = op === 'ask' ? this.kindFlags() : null
|
|
1434
|
+
if (k !== null) {
|
|
1435
|
+
const { postAsk } = await import('../review/store.ts')
|
|
1436
|
+
const { askStateText } = await import('../review/answer-kinds.ts')
|
|
1437
|
+
if (!this.words?.trim()) throw new Error(`ask <address | id> "<what you ask>" ${k.label}`)
|
|
1438
|
+
if (k.kind === 'secret' && this.secret) {
|
|
1439
|
+
const who = await (await import('../secrets/who-reads.ts')).whoReads([this.secret], process.cwd())
|
|
1440
|
+
if (who[this.secret]?.registered !== true) throw new Error(`--secret ${this.secret}: no row in the secret registry, so the vault would refuse the value he types. Add its row first (the name, what it is for, its scope: wiki identities/_common/secrets-registry.md), then ask again`)
|
|
1441
|
+
}
|
|
1442
|
+
const { id, replaces } = await this.target(h)
|
|
1443
|
+
const m = await postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, kind: k.kind, ...(k.kind === 'checklist' ? { options: this.checklist ?? [] } : {}), ...(k.kind === 'secret' ? { secret: { name: this.secret ?? '', login: this.login === true } } : {}), ...(replaces ? { replaces } : {}) })
|
|
1444
|
+
h.out(`${id} asked: ${askStateText(readItem(h.dir, id)?.thread ?? [m], m)}`)
|
|
1445
|
+
await this.later(h, id)
|
|
1446
|
+
if (k.kind === 'secret') h.out(` his answer reads « stored as ${m.ask?.secret?.name} »; then: sk secret get ${m.ask?.secret?.name}`)
|
|
1447
|
+
return 0
|
|
1448
|
+
}
|
|
902
1449
|
if (op === 'ask' && this.options !== undefined) {
|
|
903
1450
|
const { postAsk } = await import('../review/store.ts')
|
|
904
1451
|
if (!this.words?.trim()) throw new Error('ask <address | id> "<question>" --option "<a>" --option "<b>" --pick <n>')
|
|
905
|
-
const id = await
|
|
1452
|
+
const { id, replaces } = await this.target(h)
|
|
906
1453
|
const pick = this.pick === undefined ? undefined : Number(this.pick) - 1
|
|
907
1454
|
if (pick === undefined) h.err('no --pick: the house rule wants your pick on every question')
|
|
908
|
-
const m = postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, options: this.options, ...(pick !== undefined ? { pick } : {}) })
|
|
909
|
-
h.out(`${id} asked: ${m.ask?.options.map((o, i) => `${i + 1} ${o}${m.ask?.pick === i ? ' (your pick)' : ''}`).join(' · ')}`)
|
|
1455
|
+
const m = await postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, options: this.options.map(askOption), ...(pick !== undefined ? { pick } : {}), ...(replaces ? { replaces } : {}) })
|
|
1456
|
+
h.out(`${id} asked: ${m.ask?.options.map((o, i) => `${i + 1} ${o}${m.ask?.views?.[i] != null ? ' [media]' : ''}${m.ask?.pick === i ? ' (your pick)' : ''}`).join(' · ')}`)
|
|
1457
|
+
await this.later(h, id)
|
|
910
1458
|
return 0
|
|
911
1459
|
}
|
|
912
1460
|
const { stateOf } = await import('../review/model.ts')
|
|
@@ -916,6 +1464,19 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
916
1464
|
if (o.topic === 'required' && !this.words) throw new Error(`${op} <id> <topic> (sk thread topics)`)
|
|
917
1465
|
const id = await idOf(h.dir, this.id)
|
|
918
1466
|
const who = actor(this.as, o.named, op)
|
|
1467
|
+
if (op === 'wontfix') {
|
|
1468
|
+
// an ask's thread closes by its ask (wiki tools/shipkit/threads-page.md, Close and reopen), as the hub's close does
|
|
1469
|
+
const { isAskItem } = await import('../review/model.ts')
|
|
1470
|
+
const was = readItem(h.dir, id)
|
|
1471
|
+
if (was && isAskItem(was.item)) {
|
|
1472
|
+
const { moveAsk, rootOfStore } = await import('../review/close.ts')
|
|
1473
|
+
const { findAsk } = await import('../asks/ask-store.ts')
|
|
1474
|
+
const moved = moveAsk(h.dir, was.item.on!, 'wontfix', this.note ?? '')
|
|
1475
|
+
const a = findAsk(rootOfStore(h.dir), was.item.on!)
|
|
1476
|
+
h.out(`${a.address} ${moved ? 'declined' : `${a.status} already`}${a.why ? `: ${a.why}` : ''}`)
|
|
1477
|
+
return 0
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
919
1480
|
if (op === 'done') {
|
|
920
1481
|
// done is asked of a card he answered « fix »: closed already is the goal reached, unanswered is withdraw's
|
|
921
1482
|
const { readAll } = await import('../review/store.ts')
|
|
@@ -924,14 +1485,16 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
924
1485
|
const followed = followedIds(readAll(h.dir).items).has(id)
|
|
925
1486
|
const st = was ? stateOf(was, followed) : null
|
|
926
1487
|
if (st?.state === 'closed') {
|
|
927
|
-
h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer
|
|
1488
|
+
h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer version follows it' : ''}), nothing to close`)
|
|
928
1489
|
if (this.words || this.note) h.err(`your words are not posted: sk thread reply ${id} "<text>"`)
|
|
929
1490
|
return 0
|
|
930
1491
|
}
|
|
931
1492
|
if (st?.state === 'asks' || st?.state === 'draft')
|
|
932
|
-
throw new Error(`${id}: done closes a
|
|
1493
|
+
throw new Error(`${id}: done closes a version the owner answered « fix »; this one ${st.state === 'asks' ? "waits on the owner's verdict" : 'is in progress'}: sk thread withdraw ${id} --why "<why>" takes it back`)
|
|
933
1494
|
}
|
|
1495
|
+
const holds = op === 'done' || op === 'wontfix' || op === 'release' || op === 'blocked' || op === 'fixed' ? await callerHolds(h.dir, id, this.as) : false
|
|
934
1496
|
act(h.dir, id, op, who, {
|
|
1497
|
+
holds,
|
|
935
1498
|
...(this.note ? { note: this.note } : {}),
|
|
936
1499
|
...(op === 'ask' && this.words ? { text: this.words } : {}),
|
|
937
1500
|
...(op === 'done' && this.words ? { note: this.words } : {}),
|
|
@@ -948,14 +1511,63 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
948
1511
|
}
|
|
949
1512
|
}
|
|
950
1513
|
|
|
951
|
-
export const ReviewFixedCommand = actCommand('fixed', 'close an item he raised as done: the note says what was done (and --commit where)', { note: 'optional', named: false, examples: [['done, with its commit', 'sk thread fixed <id> --note "the lamp lit" --commit abc1234']] })
|
|
952
1514
|
export const ReviewWontfixCommand = actCommand('wontfix', 'close an item he raised as not done, with the reason', { note: 'required', named: false, examples: [['not done', 'sk thread wontfix <id> --note "the room is gone"']] })
|
|
953
1515
|
export const ReviewClaimCommand = actCommand('claim', 'take an item to work on it: the hub shows the thread in work by your lane', { named: true, examples: [['take it', 'sk thread claim <id> --as L12']] })
|
|
954
1516
|
export const ReviewReleaseCommand = actCommand('release', 'give back an item you claimed', { note: 'optional', named: true, examples: [['give it back', 'sk thread release <id> --as L12']] })
|
|
955
1517
|
export const ReviewBlockedCommand = actCommand('blocked', 'an item you claimed goes back to the owner with what is needed', { note: 'required', named: true, examples: [['his decision is needed', 'sk thread blocked <id> --note "which of the two doors?" --as L12']] })
|
|
956
|
-
export const ReviewDoneCommand = actCommand('done', '
|
|
1518
|
+
export const ReviewDoneCommand = actCommand('done', 'the older name of sk thread fixed on a version he answered « ok with a fix »', { text: 'what changed', named: false, examples: [['the fix made', 'sk thread fixed <id> "the sign moved one tile up"']] })
|
|
1519
|
+
|
|
1520
|
+
/** `fixed <address | id> ["<what was done>"]`: the one way to say it is fixed (review/threads.ts fixedPlan) */
|
|
1521
|
+
export class ReviewFixedCommand extends Command {
|
|
1522
|
+
static override paths = [['review', 'fixed']]
|
|
1523
|
+
static essential = { args: '<address | id> [what was done]' }
|
|
1524
|
+
static override usage = Command.Usage({
|
|
1525
|
+
category: 'Review',
|
|
1526
|
+
description: 'it is fixed: closes an open note of the owner, an « ok with a fix », or asks the verdict again',
|
|
1527
|
+
details: `${DETAILS}\n\nOn a note of the owner (its id): closes it. On a thread (its address or a version's id): the owner's one open note in it closes (two or more are named: give the note's id); else its version he answered « ok with a fix » closes; else a version he rejected or in work asks the owner's verdict again, as sk thread update <id> fixed "<line>" does (with a file, use that).`,
|
|
1528
|
+
examples: [
|
|
1529
|
+
["the owner's note, with its commit", 'sk thread fixed page:threads/lightbox "the bar is half as tall" --commit abc1234'],
|
|
1530
|
+
['an « ok with a fix » made with no new version', 'sk thread fixed <id> "the sign moved one tile up"'],
|
|
1531
|
+
],
|
|
1532
|
+
})
|
|
1533
|
+
id = Option.String({ name: 'address | id' })
|
|
1534
|
+
words = Option.String({ required: false, name: 'what was done' })
|
|
1535
|
+
note = Option.String('--note', { description: 'what was done (the same as the words)' })
|
|
1536
|
+
commit = Option.String('--commit', { description: 'the commit that holds the fix' })
|
|
1537
|
+
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
1538
|
+
|
|
1539
|
+
async execute(): Promise<number> {
|
|
1540
|
+
return run(this.context, async (h) => {
|
|
1541
|
+
const { act, postUpdate, readAll } = await import('../review/store.ts')
|
|
1542
|
+
const { stateOf } = await import('../review/model.ts')
|
|
1543
|
+
const { fixedPlan, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1544
|
+
const id = await idOf(h.dir, this.id)
|
|
1545
|
+
const items = readAll(h.dir).items
|
|
1546
|
+
const x = items.find((y) => y.item.id === id)
|
|
1547
|
+
const t = threadOfItem(id, threadsOf(items, h.say.spec))
|
|
1548
|
+
if (!x || !t) throw new Error(`no item ${this.id}`)
|
|
1549
|
+
const { ID_RE } = await import('../review/model.ts')
|
|
1550
|
+
const plan = fixedPlan(t, x, { byAddress: !ID_RE.test(this.id) && this.id.includes(':') && !/^\w+#\d+$/.test(this.id) })
|
|
1551
|
+
if ('error' in plan) throw new Error(plan.error)
|
|
1552
|
+
const said = (this.words ?? this.note)?.trim()
|
|
1553
|
+
const who = actor(this.as, false, 'fixed')
|
|
1554
|
+
if (plan.op === 'update') {
|
|
1555
|
+
const r = await postUpdate(h.dir, plan.id, { who, state: 'fixed', text: said || 'fixed' })
|
|
1556
|
+
const { isOpening } = await import('../review/model.ts')
|
|
1557
|
+
h.out(`${plan.id}: ${r.tag}; ${isOpening(r.item) ? 'its work is done, nothing waits on the owner' : "the owner's verdict is asked again"}`)
|
|
1558
|
+
return 0
|
|
1559
|
+
}
|
|
1560
|
+
const holds = await callerHolds(h.dir, plan.id, this.as)
|
|
1561
|
+
act(h.dir, plan.id, plan.op, who, { ...(said ? { note: said } : {}), ...(this.commit ? { commit: this.commit } : {}), holds })
|
|
1562
|
+
const after = readAll(h.dir).items.find((y) => y.item.id === plan.id)
|
|
1563
|
+
const st = after ? stateOf(after, false) : null
|
|
1564
|
+
h.out(`${plan.id} ${plan.op === 'done' ? 'closed, « ok with a fix » done' : 'fixed'}: ${st ? `${st.state}${st.why ? ` (${st.why})` : ''}` : 'gone'}`)
|
|
1565
|
+
return 0
|
|
1566
|
+
})
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
957
1569
|
export const ReviewDispatchCommand = actCommand('dispatch', 'the dispatcher sends a raised item to a topic', { note: 'optional', topic: 'required', named: true, examples: [['to a topic', 'sk thread dispatch <id> lieux --as orchestrator']] })
|
|
958
|
-
export const ReviewAskCommand = actCommand('ask', '
|
|
1570
|
+
export const ReviewAskCommand = actCommand('ask', 'a question he answers in one click, with your pick; it starts the thread when none owns the address', { text: 'question', named: true, examples: [['one click, your pick on the second', 'sk thread ask messages:tui/u1 "which hook line ?" --option "Run any workflow" --option "Your workflow, one command" --pick 2'], ["the dispatcher's question on a raised item (no --option)", 'sk thread ask <id> "which tower?" --as orchestrator']] })
|
|
959
1571
|
export const ReviewDropCommand = actCommand('drop', 'the dispatcher closes a raised item with the reason (a duplicate, already fixed)', { note: 'required', named: true, examples: [['a duplicate', 'sk thread drop <id> --note "same as <other id>" --as orchestrator']] })
|
|
960
1572
|
export const ReviewReassignCommand = actCommand('reassign', 'the dispatcher takes a claim back, or sends the item to another topic', { note: 'optional', topic: 'optional', named: true, examples: [['a stale claim', 'sk thread reassign <id> --as orchestrator']] })
|
|
961
1573
|
|
|
@@ -1174,7 +1786,7 @@ export class ReviewAnimCommand extends Command {
|
|
|
1174
1786
|
mode = Option.String('--mode', 'fade', { description: 'cut, fade or wipe' })
|
|
1175
1787
|
format = Option.String('--format', 'mp4', { description: 'mp4 or gif' })
|
|
1176
1788
|
labels = Option.String('--labels', 'en', { description: 'the corner labels: en, fr or none' })
|
|
1177
|
-
before = Option.String('--before', { description: 'an image, with --after: no
|
|
1789
|
+
before = Option.String('--before', { description: 'an image, with --after: no thread' })
|
|
1178
1790
|
after = Option.String('--after', { description: 'an image, with --before' })
|
|
1179
1791
|
out = Option.String('--out', { description: 'where it goes' })
|
|
1180
1792
|
|
|
@@ -1207,8 +1819,8 @@ export class ReviewStageCommand extends Command {
|
|
|
1207
1819
|
static override paths = [['review', 'stage']]
|
|
1208
1820
|
static override usage = Command.Usage({
|
|
1209
1821
|
category: 'Review',
|
|
1210
|
-
description: "one media of a version staged as a post: a draft
|
|
1211
|
-
details: `${DETAILS}\n\nThe media copied in with its metadata left out, the repo's guard run first, the draft committed by its paths. Without --view, the newest version's first media. Without --kind, iteration: feature, a change users can use now, is picked by hand. --dry prints the draft as it would be written, then each account, its place, its count, what it skips. It never publishes: Publish stays his, in Communications. Page: wiki tools/shipkit/threads-raised-notes.md, A post staged from a
|
|
1822
|
+
description: "one media of a version staged as a post: a draft group of the repo's social store, never posted",
|
|
1823
|
+
details: `${DETAILS}\n\nThe media copied in with its metadata left out, the repo's guard run first, the draft committed by its paths. Without --view, the newest version's first media. Without --kind, iteration: feature, a change users can use now, is picked by hand. --dry prints the draft as it would be written, then each account, its place, its count, what it skips. It never publishes: Publish stays his, in Communications. Page: wiki tools/shipkit/threads-raised-notes.md, A post staged from a version`,
|
|
1212
1824
|
examples: [
|
|
1213
1825
|
['the first media, a safe post', 'sk thread stage <id> --text "Hands now pinch and lift." --rating safe'],
|
|
1214
1826
|
["the second view's wipe, polished by an agent", 'sk thread stage <id> --view B --side wipe --text "…" --rating mild --polish'],
|
|
@@ -1335,7 +1947,7 @@ export class ReviewWatchCommand extends Command {
|
|
|
1335
1947
|
category: 'Review',
|
|
1336
1948
|
description: 'one line per verdict, reply or raised note as it lands; every unseen one first; ends with its owner',
|
|
1337
1949
|
details: `${DETAILS}\n\nRun it under a monitor, unfiltered (a grep holds a burst's last line). It registers itself, so the hub shows who listens. It exits within 2 s once a process above it at start is gone or nothing reads its output. An item nobody takes prints 2 minutes after its last message, then every 2 hours.`,
|
|
1338
|
-
examples: [['the
|
|
1950
|
+
examples: [['the threads this session holds', 'sk thread watch --mine'], ["one lane's items", 'sk thread watch --lane interaction']],
|
|
1339
1951
|
})
|
|
1340
1952
|
mine = Option.Boolean('--mine', false, { description: "only the threads this Claude Code session holds" })
|
|
1341
1953
|
session = Option.String('--session', { description: "only the threads that session holds" })
|
|
@@ -1351,19 +1963,42 @@ export class ReviewWatchCommand extends Command {
|
|
|
1351
1963
|
const { raisedLine, untakenLine, watchLines } = await import('../review/format.ts')
|
|
1352
1964
|
const { exitWithOwner, liveWatchers, registerWatch } = await import('../review/watchers.ts')
|
|
1353
1965
|
const session = await sessionOf(this.mine, this.session)
|
|
1354
|
-
|
|
1966
|
+
// --mine under SK_AGENT is that lane's watch: a lane shares its session's id, its name tells them apart
|
|
1967
|
+
const lane = this.lane?.trim() || (this.mine ? laneOfCaller(undefined) : null)
|
|
1355
1968
|
if (lane !== null && !AGENT_RE.test(lane)) throw new Error(`--lane: « ${lane} » is no lane id (${AGENT_RE.source})`)
|
|
1356
|
-
const { hears, threadByItem, threadsOf } = await import('../review/threads.ts')
|
|
1969
|
+
const { hears, holderOf, listenersOf, threadByItem, threadsOf } = await import('../review/threads.ts')
|
|
1357
1970
|
let byItem = new Map<string, import('../review/threads.ts').Thread>()
|
|
1358
|
-
|
|
1971
|
+
// who hears what: the registry, read again every 30 s, so a lane's threads reach its session's watch once it ends
|
|
1972
|
+
const { noteHanded, readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
1973
|
+
const { laneAsksFor, resumeOf } = await import('../review/inbox-read.ts')
|
|
1974
|
+
const { dirname } = await import('node:path')
|
|
1975
|
+
const { sessionId } = await import('../review/store.ts')
|
|
1976
|
+
const by = sessionId()
|
|
1977
|
+
let parties: import('../review/parties.ts').Parties | null = null
|
|
1978
|
+
const mine = (x: Parameters<typeof coversCard>[1]): boolean => hears({ session, lane }, x, byItem, parties)
|
|
1359
1979
|
if (session === null && lane === null) {
|
|
1360
1980
|
const { bareWatchTaken } = await import('../review/model.ts')
|
|
1361
1981
|
const taken = bareWatchTaken(liveWatchers(h.dir), process.pid)
|
|
1362
1982
|
if (taken !== null) throw new Error(taken)
|
|
1363
1983
|
}
|
|
1364
|
-
registerWatch(h.dir, { session, lane })
|
|
1984
|
+
const beat = registerWatch(h.dir, { session, lane }, new Date(), by)
|
|
1365
1985
|
// before any await: a pull that hangs never keeps a watch alive past its owner
|
|
1366
1986
|
exitWithOwner()
|
|
1987
|
+
setInterval(() => beat(), 10_000)
|
|
1988
|
+
const known = async (): Promise<void> => {
|
|
1989
|
+
if (session === null && lane === null) return
|
|
1990
|
+
const all = readAll(h.dir)
|
|
1991
|
+
const ids = new Set(threadsOf(all.items, h.say.spec).flatMap((t) => [...(t.head.item.origin.by === 'agent' && t.head.item.origin.session ? [t.head.item.origin.session] : []), ...(holderOf(t)?.session ?? [])]))
|
|
1992
|
+
parties = await readParties({ sessions: [...ids, ...(session ? [session] : [])], watchers: liveWatchers(h.dir), self: by })
|
|
1993
|
+
// a lane's watch ends with its lane: its threads pass to its session, whose hook or watch hears them
|
|
1994
|
+
const me = lane !== null && by !== null ? parties.lanes.filter((l) => l.name === lane && l.session === by) : []
|
|
1995
|
+
if (me.length > 0 && !me.some((l) => l.live)) {
|
|
1996
|
+
h.err(`review watch: exits, its lane ${lane} ended: its threads pass to its session`)
|
|
1997
|
+
process.exit(0)
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
await known().catch(() => {})
|
|
2001
|
+
setInterval(() => void known().catch(() => {}), 30_000)
|
|
1367
2002
|
const shown = new Set<string>()
|
|
1368
2003
|
// a store refused for a while (a fold or a way back of the daemon file walks): one line, and the next poll
|
|
1369
2004
|
// reads again; never a watch that dies and hears nothing more
|
|
@@ -1388,12 +2023,28 @@ export class ReviewWatchCommand extends Command {
|
|
|
1388
2023
|
if (!shown.has(key)) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
1389
2024
|
shown.add(key)
|
|
1390
2025
|
}
|
|
1391
|
-
for (
|
|
1392
|
-
|
|
1393
|
-
|
|
2026
|
+
// his request for a lane, first: a session's watch (or a bare one) is the orchestrator's ear
|
|
2027
|
+
if (lane === null && (parties !== null || session === null)) {
|
|
2028
|
+
for (const l of laneAsksFor({ repo: repoNameOf(dirname(dirname(h.dir))), root: dirname(dirname(h.dir)), dir: h.dir, here: true, ...all, say: h.say }, { session, lane: null }, parties ?? { sessions: [], lanes: [] })) {
|
|
2029
|
+
if (shown.has(l)) continue
|
|
2030
|
+
shown.add(l)
|
|
2031
|
+
h.out(l)
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
for (const x of unseen(all.items).filter(mine)) {
|
|
2035
|
+
const fresh = watchLines(x, all.items).filter((l) => !shown.has(l.key))
|
|
2036
|
+
for (const l of fresh) {
|
|
1394
2037
|
shown.add(l.key)
|
|
1395
2038
|
h.out(l.text)
|
|
1396
2039
|
}
|
|
2040
|
+
// a session's watch, his message on its ended lane's thread: the way back to that lane
|
|
2041
|
+
const t = byItem.get(x.item.id)
|
|
2042
|
+
const r = fresh.length > 0 && lane === null && t && parties ? resumeOf(h, t, parties) : null
|
|
2043
|
+
if (r) {
|
|
2044
|
+
h.out(` ${r.line}`)
|
|
2045
|
+
noteHanded(r.lane, r.session, r.thread)
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
1397
2048
|
for (const x of all.items.filter(mine)) {
|
|
1398
2049
|
const l = raisedLine(x)
|
|
1399
2050
|
if (l === null || shown.has(l.key)) continue
|
|
@@ -1406,7 +2057,7 @@ export class ReviewWatchCommand extends Command {
|
|
|
1406
2057
|
const watchers = liveWatchers(h.dir)
|
|
1407
2058
|
for (const x of all.items) {
|
|
1408
2059
|
if (lane !== null && laneOf(x) !== lane) continue
|
|
1409
|
-
const why = untakenOf(x, followed.has(x.item.id), watchers, now, h.say.spec.dispatcher)
|
|
2060
|
+
const why = untakenOf(x, followed.has(x.item.id), listenersOf(watchers, x, byItem).length > 0, now, h.say.spec.dispatcher)
|
|
1410
2061
|
if (why === null) continue
|
|
1411
2062
|
const round = Math.floor((now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created)) / UNTAKEN_AGAIN_MS)
|
|
1412
2063
|
const key = `untaken ${x.item.id} ${why} ${round}`
|
|
@@ -1488,14 +2139,14 @@ export class ReviewMoveCommand extends Command {
|
|
|
1488
2139
|
static override paths = [['review', 'move']]
|
|
1489
2140
|
static override usage = Command.Usage({
|
|
1490
2141
|
category: 'Review',
|
|
1491
|
-
description: "this machine's
|
|
2142
|
+
description: "this machine's threads into the daemon's database, or back into files",
|
|
1492
2143
|
details:
|
|
1493
|
-
"The machine db switch cards-in-db picks where every
|
|
2144
|
+
"The machine db switch cards-in-db picks where every thread of this machine is read and written: its repo's files (`.shipkit/review/<id>/`, off, the default), or the rows of the daemon's database (on). `--go` imports every version file of every house repo the rows lack (by id and rev), proves each is in the rows, turns the switch on, then reads the files once more after a second for a writer that had not seen it. With the switch hq-cards on, it first asks the hq: the hq and the files must hold the same cards, else nothing moves. The files stay where they are, untouched: the way back. `--back` is a look of the way back, `--back --go` first fetches from the Space any media file the spool let go (or refuses, naming how many it would lack), then writes every version of the rows into the files (the versions made since included), turns the switch off, and writes them out again after a second. During a move's lag (7 s) a reader in another process can miss a version a writer made on the side the move left; the second pass carries it, and none stays missed. Both keep the later of two heads and every message by its id, so a move stopped half way runs again. A version's media files stay in its folder. `--tidy` (a look, `--tidy --go` acts) removes a version's files from its repo only while the switch is on and once its rows hold all of them, the hq holds them (hq-cards on) and the Space each of its media files; a version whose rows differ stays, named; after it, `--back --go` writes the files again from the rows. It moves every house repo of the home it runs in, worktrees resolved to their checkout: a test names a scratch HOME. Page: wiki tools/shipkit/threads-store.md",
|
|
1494
2145
|
examples: [['what the tidy would remove', 'sk thread move --tidy'], ['what a move would do', 'sk thread move'], ['move this machine', 'sk thread move --go'], ['what the way back would do', 'sk thread move --back'], ['go back to the files', 'sk thread move --back --go']],
|
|
1495
2146
|
})
|
|
1496
2147
|
go = Option.Boolean('--go', false, { description: 'do it: the move, or with --back the way back' })
|
|
1497
2148
|
back = Option.Boolean('--back', false, { description: 'the way back: the rows into the files, the switch off' })
|
|
1498
|
-
tidy = Option.Boolean('--tidy', false, { description: 'remove the
|
|
2149
|
+
tidy = Option.Boolean('--tidy', false, { description: 'remove the thread files the rows, the hq and the Space all hold' })
|
|
1499
2150
|
|
|
1500
2151
|
async execute(): Promise<number> {
|
|
1501
2152
|
const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
@@ -1509,7 +2160,7 @@ export class ReviewMoveCommand extends Command {
|
|
|
1509
2160
|
const { cardsLease } = await import('../hq/cards.ts')
|
|
1510
2161
|
const { leaseHolder, tryLease } = await import('../core/locked-write.ts')
|
|
1511
2162
|
const lease = dry ? null : tryLease(cardsLease(), 'review move')
|
|
1512
|
-
if (!dry && lease == null) throw new Error(`a look of the
|
|
2163
|
+
if (!dry && lease == null) throw new Error(`a look of the hq threads job or another move runs (pid ${leaseHolder(cardsLease())?.pid ?? '?'}): run it again once it ended`)
|
|
1513
2164
|
try {
|
|
1514
2165
|
const r = this.tidy ? await tidyFiles(stores, { dry, proof: await tidyProof(stores) }) : this.back ? await moveBack(stores, { dry }) : await moveGo(stores, { dry, hqDiff: hqDiffOf(stores) })
|
|
1515
2166
|
for (const l of r.lines) (l.startsWith('WARN') ? err : out)(l)
|
|
@@ -1548,7 +2199,7 @@ async function tidyProof(stores: readonly string[]): Promise<import('../review/m
|
|
|
1548
2199
|
hqLacks: async (dir) => {
|
|
1549
2200
|
const set = byRepo.get(repoIdOf(dir))
|
|
1550
2201
|
if (set != null) return set
|
|
1551
|
-
return { refused: left.some((l) => dir.startsWith(l)) ? 'a repo with no remote: the hq carries none of its
|
|
2202
|
+
return { refused: left.some((l) => dir.startsWith(l)) ? 'a repo with no remote: the hq carries none of its threads' : 'the hq holds no threads of this repo' }
|
|
1552
2203
|
},
|
|
1553
2204
|
up,
|
|
1554
2205
|
}
|
|
@@ -1575,19 +2226,19 @@ export class ReviewExportCommand extends Command {
|
|
|
1575
2226
|
static override paths = [['review', 'export']]
|
|
1576
2227
|
static override usage = Command.Usage({
|
|
1577
2228
|
category: 'Review',
|
|
1578
|
-
description: '
|
|
1579
|
-
details: `${DETAILS}\n\nWith the switch cards-in-db on,
|
|
1580
|
-
examples: [['one
|
|
2229
|
+
description: 'threads of this repo written as their files, one folder an item, into a folder',
|
|
2230
|
+
details: `${DETAILS}\n\nWith the switch cards-in-db on, an item is rows of the daemon's database; export writes it as the folder the files backend keeps (\`<to>/<id>/item.json\`, \`thread/<message>.json\`, and each media file this machine still holds; a file the disk let go is named, its key in the head's media). Nothing in the store changes.`,
|
|
2231
|
+
examples: [['one item', 'sk thread export 20261118-210000-the-gate --to /tmp/threads'], ['every item of the repo', 'sk thread export --all --to /tmp/threads']],
|
|
1581
2232
|
})
|
|
1582
|
-
all = Option.Boolean('--all', false, { description: 'every
|
|
1583
|
-
to = Option.String('--to', { required: true, description: 'the folder the
|
|
2233
|
+
all = Option.Boolean('--all', false, { description: 'every item of the repo' })
|
|
2234
|
+
to = Option.String('--to', { required: true, description: 'the folder the items are written into' })
|
|
1584
2235
|
ids = Option.Rest()
|
|
1585
2236
|
|
|
1586
2237
|
async execute(): Promise<number> {
|
|
1587
2238
|
return run(this.context, async (h) => {
|
|
1588
2239
|
const { cardsInDb } = await import('../hq/switch.ts')
|
|
1589
2240
|
const { resolve } = await import('node:path')
|
|
1590
|
-
if (this.all === this.ids.length > 0) throw new Error('give
|
|
2241
|
+
if (this.all === this.ids.length > 0) throw new Error('give item ids or --all')
|
|
1591
2242
|
const to = resolve(this.to)
|
|
1592
2243
|
if (to === resolve(h.dir)) throw new Error(`--to ${this.to}: the store itself; sk thread move --back --go writes the rows into the store`)
|
|
1593
2244
|
const ids = this.all ? undefined : await Promise.all(this.ids.map((r) => idOf(h.dir, r)))
|
|
@@ -1602,7 +2253,7 @@ export class ReviewExportCommand extends Command {
|
|
|
1602
2253
|
for (const id of want) if (!existsSync(join(to, id))) cpSync(join(h.dir, id), join(to, id), { recursive: true })
|
|
1603
2254
|
r = { dir: h.dir, cards: want.length, heads: want.length, msgs: 0, gone: 0, same: 0, files: 0, kept: [], broken: [], read: [] }
|
|
1604
2255
|
}
|
|
1605
|
-
h.out(`review: ${r.cards}
|
|
2256
|
+
h.out(`review: ${r.cards} items written into ${to} (${r.heads} heads, ${r.msgs} messages${r.media ? `, ${r.media.copied} media files` : ''})`)
|
|
1606
2257
|
for (const k of r.kept) h.out(` kept: ${k}`)
|
|
1607
2258
|
for (const b of r.broken) h.err(` does not read: ${b}`)
|
|
1608
2259
|
if (r.media && r.media.missing.length > 0) h.out(` ${r.media.missing.length} media files this machine no longer holds (the Space has them by their key in the head): ${r.media.missing.slice(0, 5).join(', ')}`)
|
|
@@ -1611,71 +2262,110 @@ export class ReviewExportCommand extends Command {
|
|
|
1611
2262
|
}
|
|
1612
2263
|
}
|
|
1613
2264
|
|
|
1614
|
-
/** `
|
|
1615
|
-
*
|
|
1616
|
-
export
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
const { storeDir, readAll } = await import('../review/store.ts')
|
|
1635
|
-
const root = await reviewRoot(process.cwd())
|
|
1636
|
-
if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo`)
|
|
1637
|
-
const { openReview } = await import('../review/project.ts')
|
|
1638
|
-
const { dir } = await openReview(root)
|
|
1639
|
-
const id = await idOf(dir ?? storeDir(root), t)
|
|
1640
|
-
const { threadOfId } = await import('../review/cells.ts')
|
|
1641
|
-
const { threadsOf } = await import('../review/threads.ts')
|
|
1642
|
-
const head = threadOfId(id, threadsOf(readAll(dir).items))?.head.item
|
|
1643
|
-
if (!head) throw new Error(`no thread holds ${t}`)
|
|
1644
|
-
link = head.origin.by === 'agent' ? ['--supersedes', head.id] : ['--answers', head.id]
|
|
2265
|
+
/** what `propose` was typed with: its positionals, the thread it goes in, who acts, and its fields in the order typed:
|
|
2266
|
+
* `--field <key>` opens a field, the value flags after it are that field's; with no `--field`, one field */
|
|
2267
|
+
export function proposeArgs(args: readonly string[], read: (file: string) => string): { positionals: string[]; into?: string; as?: string; replaces?: string; fields: import('../review/store.ts').ProposeInput[] } {
|
|
2268
|
+
const positionals: string[] = []
|
|
2269
|
+
const fields: { key?: string; before?: string; after?: string; type?: string }[] = []
|
|
2270
|
+
let into: string | undefined
|
|
2271
|
+
let as: string | undefined
|
|
2272
|
+
let replaces: string | undefined
|
|
2273
|
+
const cur = (flag: string): (typeof fields)[number] => {
|
|
2274
|
+
if (fields.length === 0) fields.push({})
|
|
2275
|
+
const f = fields.at(-1)!
|
|
2276
|
+
const name = flag.replace(/-file$/, '') as 'before' | 'after' | 'type'
|
|
2277
|
+
if (f[name] !== undefined) throw new Error(`--${flag} twice on ${f.key ? `--field ${f.key}` : 'one field'}: a change of several names each with --field <key>`)
|
|
2278
|
+
return f
|
|
2279
|
+
}
|
|
2280
|
+
for (let i = 0; i < args.length; i++) {
|
|
2281
|
+
const a = args[i]!
|
|
2282
|
+
if (!a.startsWith('--')) {
|
|
2283
|
+
positionals.push(a)
|
|
2284
|
+
continue
|
|
1645
2285
|
}
|
|
1646
|
-
|
|
2286
|
+
if (a === '--verdict') throw new Error("--verdict: a proposed change waits for the owner's answer already, the owner's apply or the owner's words are its verdict")
|
|
2287
|
+
const v = args[++i]
|
|
2288
|
+
if (v === undefined) throw new Error(`${a}: needs a value`)
|
|
2289
|
+
const flag = a.slice(2)
|
|
2290
|
+
if (flag === 'field') fields.push({ key: v })
|
|
2291
|
+
else if (flag === 'in') into = v
|
|
2292
|
+
else if (flag === 'as') as = v
|
|
2293
|
+
else if (flag === 'replaces') replaces = v
|
|
2294
|
+
else if (flag === 'before' || flag === 'after' || flag === 'type') cur(flag)[flag] = v
|
|
2295
|
+
else if (flag === 'before-file' || flag === 'after-file') cur(flag)[flag === 'before-file' ? 'before' : 'after'] = read(v)
|
|
2296
|
+
else throw new Error(`${a}: no such flag (sk thread propose --help)`)
|
|
2297
|
+
}
|
|
2298
|
+
return {
|
|
2299
|
+
positionals,
|
|
2300
|
+
...(into !== undefined ? { into } : {}),
|
|
2301
|
+
...(as !== undefined ? { as } : {}),
|
|
2302
|
+
...(replaces !== undefined ? { replaces } : {}),
|
|
2303
|
+
fields: fields.map((f) => {
|
|
2304
|
+
const at = f.key ? `--field ${f.key}: ` : ''
|
|
2305
|
+
if (f.after === undefined) throw new Error(`${at}--after "<value>" (or --after-file): the value you propose`)
|
|
2306
|
+
const [type, lang] = f.type === undefined ? [] : f.type.split(':', 2)
|
|
2307
|
+
if (lang !== undefined && type !== 'code') throw new Error(`${at}--type ${f.type}: a language goes with code alone, code:<lang>`)
|
|
2308
|
+
return { after: f.after, ...(f.key !== undefined ? { key: f.key } : {}), ...(f.before !== undefined ? { before: f.before } : {}), ...(type !== undefined ? { type: type as import('../review/model.ts').DiffType } : {}), ...(lang ? { lang } : {}) }
|
|
2309
|
+
}),
|
|
1647
2310
|
}
|
|
1648
2311
|
}
|
|
1649
2312
|
|
|
1650
|
-
|
|
2313
|
+
const PROPOSE_USAGE = `sk thread propose <address> ["<why>"] --before "<value>" --after "<value>"
|
|
2314
|
+
sk thread propose <address> ["<why>"] --field <key> --before … --after … [--field <key> …]
|
|
2315
|
+
|
|
2316
|
+
--before, --after the value as it is and as you propose it (--before-file, --after-file read a file)
|
|
2317
|
+
--field <key> opens one field of a change of several: the value flags after it are its own; he applies each alone
|
|
2318
|
+
--type <text|color|sound|code[:<lang>]> how the field draws (code:ts, code:glsl: its syntax colours, none for a language it does not know); else the repo's unit declares it for that kind, else its values say
|
|
2319
|
+
--in <id | address> the thread to post it in, when it is not the address's own
|
|
2320
|
+
--as <name> who acts (else SK_AGENT)
|
|
2321
|
+
--replaces <id> your earlier change (or question) this one supersedes: it folds, its answers kept`
|
|
2322
|
+
|
|
2323
|
+
/** `propose <address> --after "<value>"`: a change of an object, one field or several, he applies in one click a field */
|
|
1651
2324
|
export class ThreadProposeCommand extends Command {
|
|
1652
2325
|
static override paths = [['thread', 'propose']]
|
|
2326
|
+
static essential = { args: '<address> ["<why>"] --before … --after …' }
|
|
1653
2327
|
static override usage = Command.Usage({
|
|
1654
2328
|
category: 'Review',
|
|
1655
|
-
description:
|
|
1656
|
-
details: `${DETAILS}\n\nIt goes into the thread that owns the address, or the one above it
|
|
1657
|
-
examples: [
|
|
2329
|
+
description: 'a change he applies a field at a click: words, a colour, code, a sound; you land it',
|
|
2330
|
+
details: `${DETAILS}\n\n${PROPOSE_USAGE}\n\nIt goes into the thread that owns the address, or the one above it. Each field draws by its type: words as a word diff, a colour (#rrggbb) as its swatch beside the old one, code as a hunk in syntax colours, a sound (two files) as an A/B player; several fields as one table. His « apply » reaches your watch as one line a field, \`<id> applied <field> of <address>: land <value>\`: you write it where the object lives and say so in the thread. Page: wiki tools/shipkit/threads.md, A proposed change`,
|
|
2331
|
+
examples: [
|
|
2332
|
+
['a phrasing', 'SK_AGENT=L12 sk thread propose messages:tui/u1 --before "Run any workflow" --after "Run your workflow from the terminal" "shorter, and says where"'],
|
|
2333
|
+
['a colour and a label, each applied alone', 'SK_AGENT=L12 sk thread propose screen:home/button "warmer, and says what it does" --field accent --before "#3a7bd5" --after "#e0569b" --field label --before "Run" --after "Run it now"'],
|
|
2334
|
+
['a snippet of code', 'SK_AGENT=L12 sk thread propose asset:shader/water --type code:glsl --before-file old.glsl --after-file new.glsl "calmer waves"'],
|
|
2335
|
+
['a sound, A/B', 'SK_AGENT=L12 sk thread propose asset:sfx/clash --before sfx/clash.flac --after sfx/clash-v2.flac "less harsh"'],
|
|
2336
|
+
],
|
|
1658
2337
|
})
|
|
1659
2338
|
address = Option.String()
|
|
1660
2339
|
words = Option.String({ required: false })
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
2340
|
+
field = Option.Array('--field', { description: 'opens one field of a change of several: the value flags after it are its own; he applies each alone' })
|
|
2341
|
+
before = Option.Array('--before', { description: 'the value as it is' })
|
|
2342
|
+
after = Option.Array('--after', { description: 'the value you propose' })
|
|
2343
|
+
beforeFile = Option.Array('--before-file', { description: 'the value as it is, from a file' })
|
|
2344
|
+
afterFile = Option.Array('--after-file', { description: 'the value you propose, from a file' })
|
|
2345
|
+
type = Option.Array('--type', { description: 'how the field draws: text, color, code[:<lang>], sound, image, clip (else the unit or its values say)' })
|
|
1665
2346
|
into = Option.String('--in', { description: 'the thread to post it in, by an id or an address, when it is not the address own' })
|
|
1666
2347
|
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
2348
|
+
replaces = Option.String('--replaces', { description: 'the id of your earlier change (or question) this one supersedes: it folds to one line « superseded by … » and leaves the dock' })
|
|
1667
2349
|
|
|
1668
2350
|
async execute(): Promise<number> {
|
|
2351
|
+
// the flags are declared for the help; the fields are read in the order typed, since --field opens each
|
|
2352
|
+
const raw = process.argv.slice(2)
|
|
2353
|
+
const at = raw.indexOf('propose')
|
|
2354
|
+
const args = at >= 0 ? raw.slice(at + 1) : [this.address, ...(this.words !== undefined ? [this.words] : [])]
|
|
1669
2355
|
return run(this.context, async (h) => {
|
|
1670
2356
|
const { readFileSync } = await import('node:fs')
|
|
1671
2357
|
const { postPropose } = await import('../review/store.ts')
|
|
1672
|
-
const
|
|
1673
|
-
const
|
|
1674
|
-
if (
|
|
1675
|
-
|
|
1676
|
-
const
|
|
1677
|
-
|
|
1678
|
-
|
|
2358
|
+
const p = proposeArgs(args, (f) => readFileSync(f, 'utf8'))
|
|
2359
|
+
const [address, words, ...more] = p.positionals
|
|
2360
|
+
if (address === undefined) throw new Error(`the address of the object first:\n${PROPOSE_USAGE}`)
|
|
2361
|
+
if (more.length > 0) throw new Error(`unexpected ${more.map(quoted).join(' ')}: one address, then the words in quotes`)
|
|
2362
|
+
const { addressOrThrow } = await import('../review/model.ts')
|
|
2363
|
+
await declaredOrThrow(h, addressOrThrow(address))
|
|
2364
|
+
const r = p.replaces !== undefined ? await replacing(h.dir, p.into ?? address, p.replaces, p.as) : null
|
|
2365
|
+
const id = r !== null ? r.id : p.into !== undefined ? await idOf(h.dir, p.into) : await idOrOpen(h, address, words ?? `a change of ${address}`, p.as)
|
|
2366
|
+
const m = await postPropose(h.dir, id, { who: actor(p.as, false, 'propose'), text: words ?? `a change of ${address}`, on: address, fields: p.fields, ...(r !== null ? { replaces: r.replaces } : {}) })
|
|
2367
|
+
const fields = m.propose?.fields ?? [{ key: '', type: m.propose?.type }]
|
|
2368
|
+
h.out(`${id} proposed ${m.propose?.on}${fields.length > 1 ? ` (${fields.map((f) => `${f.key}${f.type ? ` ${f.type}` : ''}`).join(', ')})` : m.propose?.type ? ` (${m.propose.type})` : ''}: he applies it in the hub, a field at a time`)
|
|
1679
2369
|
return 0
|
|
1680
2370
|
})
|
|
1681
2371
|
}
|
|
@@ -1693,13 +2383,23 @@ export class ThreadAttachCommand extends Command {
|
|
|
1693
2383
|
thread = Option.String()
|
|
1694
2384
|
address = Option.String()
|
|
1695
2385
|
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
2386
|
+
verdict = Option.Boolean('--verdict', false, { description: `the linked object waits for the owner's verdict (a draft, a text, a diff): ${VERDICT_FLAG}` })
|
|
1696
2387
|
|
|
1697
2388
|
async execute(): Promise<number> {
|
|
1698
2389
|
return run(this.context, async (h) => {
|
|
1699
|
-
const { attachTo } = await import('../review/store.ts')
|
|
2390
|
+
const { attachTo, specOf } = await import('../review/store.ts')
|
|
1700
2391
|
const id = await idOf(h.dir, this.thread)
|
|
1701
|
-
|
|
1702
|
-
|
|
2392
|
+
const { addressOrThrow } = await import('../review/model.ts')
|
|
2393
|
+
const a = addressOrThrow(this.address)
|
|
2394
|
+
await declaredOrThrow(h, a)
|
|
2395
|
+
if (this.verdict) {
|
|
2396
|
+
// a kind with actions of its own (a reflection: accept, rework, discard): they are the owner's answer on the link
|
|
2397
|
+
const { HOUSE_KINDS } = await import('../review/kinds.ts')
|
|
2398
|
+
const k = a.slice(0, a.indexOf(':'))
|
|
2399
|
+
if (Object.keys((specOf(h.dir).kinds[k] ?? HOUSE_KINDS[k])?.actions ?? {}).length > 0) throw new Error(`attach ${a} --verdict: the kind ${k} declares its own actions, which are the owner's answer on the link; attach it without --verdict`)
|
|
2400
|
+
}
|
|
2401
|
+
attachTo(h.dir, id, actor(this.as, false, 'attach'), this.address, new Date(), this.verdict ? { asksVerdict: true } : {})
|
|
2402
|
+
h.out(`${id} links ${this.address}${this.verdict ? ", waiting for the owner's verdict" : ''}`)
|
|
1703
2403
|
return 0
|
|
1704
2404
|
})
|
|
1705
2405
|
}
|
|
@@ -1801,9 +2501,11 @@ export const REVIEW_COMMANDS = [
|
|
|
1801
2501
|
ReviewMoveCommand,
|
|
1802
2502
|
ReviewExportCommand,
|
|
1803
2503
|
ReviewMigrateCommand,
|
|
1804
|
-
ThreadPostCommand,
|
|
1805
2504
|
ThreadProposeCommand,
|
|
1806
2505
|
ThreadAttachCommand,
|
|
2506
|
+
ThreadTakeCommand,
|
|
2507
|
+
ThreadAssignCommand,
|
|
2508
|
+
ThreadWorkingCommand,
|
|
1807
2509
|
]
|
|
1808
2510
|
|
|
1809
2511
|
// every verb is `sk thread <verb>`, and `sk review <verb>` its older name (run() says the new form on stderr)
|