rvlib-shipkit 2.12.0 → 2.14.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 +75 -21
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/agent-time/store.ts +2 -2
- package/src/assets/run-assets.ts +2 -2
- package/src/assets/server/studio-server.ts +27 -23
- package/src/check.ts +4 -4
- package/src/checks/SK001-package-json-shape.check.ts +8 -4
- package/src/checks/SK002-contracts-fulfillness.check.ts +2 -2
- package/src/checks/SK003-claude-md-shape.check.ts +20 -13
- package/src/checks/SK004-gitignore-policy.check.ts +45 -6
- package/src/checks/SK005-rvlib-versions.check.ts +2 -2
- package/src/checks/SK006-npm-publish-safety.check.ts +3 -3
- package/src/checks/SK007-github-visibility.check.ts +2 -2
- package/src/checks/SK008-reviewer-agent.check.ts +3 -3
- package/src/checks/SK010-undeclared-unit.check.ts +2 -2
- package/src/checks/SK011-sibling-unit-ranges.check.ts +2 -2
- package/src/checks/SK012-config-barrel-import.check.ts +2 -2
- package/src/checks/SK013-one-way-in-policy.check.ts +2 -2
- package/src/checks/SK015-nested-repo.check.ts +3 -3
- package/src/checks/SK016-legacy-check-shapes.check.ts +2 -2
- package/src/checks/SK017-vscode-hub-task.check.ts +2 -2
- package/src/checks/SK018-test-files-run.check.ts +2 -2
- package/src/checks/SK019-tests-run-in-units.check.ts +2 -2
- package/src/checks/SK020-self-spawning-check.check.ts +2 -2
- package/src/checks/SK022-machine-runs-the-pin.check.ts +2 -2
- package/src/checks/SK024-identity-colors.check.ts +1 -1
- package/src/checks/SK025-release-drift.check.ts +2 -2
- package/src/checks/SK026-asks-autoclose.check.ts +2 -2
- package/src/checks/SK027-agent-wiki-links.check.ts +8 -2
- package/src/checks/SK028-readme.check.ts +2 -2
- package/src/checks/SK029-explicit-check-files.check.ts +3 -3
- package/src/checks/SK030-cache-audit.check.ts +7 -5
- package/src/checks/SK031-trace-audit.check.ts +7 -7
- package/src/checks/SK032-ignored-inputs.check.ts +3 -3
- package/src/checks/SK033-global-contribution.check.ts +11 -4
- package/src/checks/SK034-commit-gates-armed.check.ts +2 -2
- package/src/checks/SK035-public-clean.check.ts +46 -0
- package/src/checks/SK036-draft-media-size.check.ts +28 -0
- package/src/checks/SK037-keyword-additions.check.ts +43 -0
- package/src/cli/cmd_Backup.ts +152 -0
- package/src/cli/cmd_Ci.ts +8 -11
- package/src/cli/cmd_Commands.ts +4 -4
- package/src/cli/cmd_ConfigKeys.ts +2 -2
- package/src/cli/cmd_Drill.ts +145 -0
- package/src/cli/cmd_Home.ts +50 -3
- package/src/cli/cmd_Init.ts +1 -1
- package/src/cli/cmd_Media.ts +10 -8
- package/src/cli/cmd_Mv.ts +14 -7
- package/src/cli/cmd_Review.ts +6 -4
- package/src/cli/cmd_Shot.ts +5 -2
- package/src/cli/cmd_Smoke.ts +5 -2
- package/src/cli/cmd_Social.ts +226 -0
- package/src/cli/cmd_Sound.ts +1 -1
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_TraceAudit.ts +6 -6
- package/src/cli/cmd_Trailer.ts +7 -4
- package/src/cli/cmd_Veille.ts +173 -0
- package/src/cli/cmd_When.ts +2 -2
- package/src/cli/family-pages.ts +19 -16
- package/src/cli/registry.ts +13 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +1 -49
- package/src/collections/checks.ts +2 -1
- package/src/collections/collection-types.ts +12 -3
- package/src/collections/providers.ts +4 -4
- package/src/collections/review.ts +3 -2
- package/src/collections/tests.ts +19 -8
- package/src/comfy/comfy-panel.ts +2 -2
- package/src/contracts/apply-contracts.ts +1 -3
- package/src/contracts/contract-manifests.ts +2 -3
- package/src/contracts/contract-types.ts +0 -1
- package/src/contracts/contracts-engine.ts +0 -3
- package/src/contracts/manifests/discord.contract.ts +1 -1
- package/src/contracts/manifests/identity.contract.ts +1 -1
- package/src/contracts/manifests/itch.contract.ts +1 -1
- package/src/contracts/manifests/steam.contract.ts +1 -1
- package/src/core/agent-dir-at.ts +12 -0
- package/src/core/agent-dir.ts +16 -0
- package/src/core/app-icon.ts +9 -3
- package/src/core/budget.ts +1 -1
- package/src/core/bun-builtins.ts +2 -2
- package/src/core/canonical-scripts.ts +2 -2
- package/src/core/discover-checks.ts +38 -6
- package/src/core/fix-scope.ts +4 -2
- package/src/core/floor-resolve.ts +68 -48
- package/src/core/floor.ts +9 -0
- package/src/core/git-root.ts +24 -0
- package/src/core/global-contribution.ts +4 -1
- package/src/core/ignored-block.ts +1 -1
- package/src/core/ignored-inputs.ts +3 -2
- package/src/core/last-good.ts +3 -1
- package/src/core/layout.ts +8 -0
- package/src/core/log-stamp.ts +36 -0
- package/src/core/loop-watch.ts +93 -0
- package/src/core/machine-link.ts +134 -0
- package/src/core/memory-watch.ts +41 -0
- package/src/core/motherhome.ts +2 -2
- package/src/core/one-way-in-policy.ts +34 -26
- package/src/core/run-ci.ts +9 -11
- package/src/core/run-fixers.ts +9 -9
- package/src/core/runs-matrix.ts +1 -1
- package/src/core/slots.ts +30 -0
- package/src/core/trace-audit.ts +50 -9
- package/src/core/tree-rev.ts +60 -0
- package/src/core/unit-files.ts +42 -0
- package/src/drill/render.ts +140 -0
- package/src/drill/run.ts +269 -0
- package/src/fleet/scan-fleet.ts +6 -5
- package/src/home/daemon-jobs.ts +201 -0
- package/src/home/global-context.ts +44 -8
- package/src/home/gui-app/ShipkitGui.swift +91 -2
- package/src/home/home-routes.ts +22 -15
- package/src/home/hubs.ts +10 -3
- package/src/home/inbox-shape.ts +54 -5
- package/src/home/inbox.ts +17 -2
- package/src/home/lib-watch.ts +10 -3
- package/src/home/machine-stores.ts +15 -29
- package/src/home/pm-config.ts +4 -1
- package/src/home/pm-inputs.ts +2 -0
- package/src/home/resources.ts +7 -2
- package/src/home/run-daemon.ts +15 -18
- package/src/home/run-pm.ts +3 -1
- package/src/home/serve-daemon.ts +4 -3
- package/src/home/serve-web.ts +104 -1
- package/src/hooks/commit-message.ts +29 -20
- package/src/hooks/hook-gates.ts +1 -1
- package/src/hooks/leak-guard.ts +69 -9
- package/src/hooks/run-hooks.ts +18 -22
- package/src/identities/identities.ts +334 -0
- package/src/identities/machine-route.ts +126 -0
- package/src/identities/machine.ts +62 -0
- package/src/init-repo.ts +3 -3
- package/src/ledger/check-stats.ts +10 -9
- package/src/ledger/gate-checks.ts +32 -1
- package/src/ledger/record-kept.ts +112 -0
- package/src/ledger/repo-view.ts +10 -0
- package/src/ledger/run-log.ts +17 -12
- package/src/ledger/run-timeline.ts +8 -4
- package/src/ledger/store.ts +7 -0
- package/src/ledger/suite-log.ts +17 -13
- package/src/media-kinds.ts +3 -2
- package/src/media-store/backup/daemon.ts +73 -0
- package/src/media-store/backup/keys.ts +25 -0
- package/src/media-store/backup/manifest.ts +193 -0
- package/src/media-store/backup/restore.ts +192 -0
- package/src/media-store/backup/run.ts +278 -0
- package/src/media-store/backup/secret.ts +86 -0
- package/src/media-store/backup/snapshot.ts +64 -0
- package/src/media-store/backup/sources.ts +199 -0
- package/src/media-store/content.ts +1 -1
- package/src/media-store/daemon.ts +56 -70
- package/src/media-store/db.ts +1 -1
- package/src/media-store/fact.ts +1 -1
- package/src/media-store/hand.ts +1 -1
- package/src/media-store/kind.ts +1 -1
- package/src/media-store/purge.ts +1 -1
- package/src/media-store/put.ts +5 -3
- package/src/media-store/remote.ts +1 -1
- package/src/media-store/space.ts +24 -5
- package/src/mv/mv-md.ts +63 -22
- package/src/pages/forward.ts +35 -0
- package/src/pages/frame-client.ts +118 -0
- package/src/pages/routes.ts +29 -0
- package/src/pages/unit.ts +92 -0
- package/src/plan/planner.ts +12 -0
- package/src/plan/repo-source.ts +19 -5
- package/src/reflect/transcript.ts +35 -10
- package/src/release/public-clean.ts +319 -0
- package/src/release/published-here.ts +22 -0
- package/src/release/run-bump.ts +3 -2
- package/src/release/run-release.ts +7 -4
- package/src/repo-config.ts +71 -13
- package/src/review/anim.ts +1 -1
- package/src/review/auto.ts +1 -1
- package/src/review/cells.ts +15 -1
- package/src/review/format.ts +2 -2
- package/src/review/http.ts +16 -2
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +1 -1
- package/src/review/media-read.ts +1 -1
- package/src/review/model.ts +27 -6
- package/src/review/notes.ts +125 -0
- package/src/review/previews.ts +1 -1
- package/src/review/project.ts +7 -39
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +18 -14
- package/src/review/store.ts +42 -2
- package/src/review/threads.ts +1 -1
- package/src/review/trailer-desk.ts +3 -3
- package/src/review/trailer-media.ts +8 -5
- package/src/review/trailer-model.ts +1 -1
- package/src/review/trailer-routes.ts +1 -1
- package/src/review/trailer-shots.ts +22 -5
- package/src/review/unit.ts +2 -2
- package/src/scaffold/files/agent-handoff.md +3 -0
- package/src/scaffold/files/agent-index.md +4 -12
- package/src/scaffold/files/tsconfig.json +1 -1
- package/src/scaffold/project-scaffold.ts +6 -5
- package/src/serve/embed.ts +2 -2
- package/src/serve/hub-app/check-words.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +3 -17
- package/src/serve/hub-app/col-tables-view.tsx +2 -1
- package/src/serve/hub-app/cols-svc.ts +0 -13
- package/src/serve/hub-app/dock-st.ts +4 -2
- package/src/serve/hub-app/dock-view.tsx +2 -0
- package/src/serve/hub-app/frames-st.ts +35 -0
- package/src/serve/hub-app/hash-route.ts +64 -1
- package/src/serve/hub-app/home-st.ts +32 -8
- package/src/serve/hub-app/home-strip.css +9 -1
- package/src/serve/hub-app/home-strip.tsx +7 -6
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +51 -7
- package/src/serve/hub-app/hub.css +29 -11
- package/src/serve/hub-app/icons.tsx +16 -1
- package/src/serve/hub-app/identities-st.ts +210 -0
- package/src/serve/hub-app/identities-view.tsx +353 -0
- package/src/serve/hub-app/identities.css +48 -0
- package/src/serve/hub-app/identity-address.ts +52 -0
- package/src/serve/hub-app/inbox-st.ts +60 -7
- package/src/serve/hub-app/inbox-view.tsx +49 -7
- package/src/serve/hub-app/inbox.css +12 -1
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/kept-cols.tsx +30 -0
- package/src/serve/hub-app/keys.ts +10 -2
- package/src/serve/hub-app/list-walk.ts +89 -0
- package/src/serve/hub-app/machine-st.ts +12 -0
- package/src/serve/hub-app/media-svc.ts +1 -1
- package/src/serve/hub-app/media-view.tsx +2 -1
- package/src/serve/hub-app/pages-frames.tsx +134 -0
- package/src/serve/hub-app/pages-svc.ts +111 -0
- package/src/serve/hub-app/palette-st.ts +18 -3
- package/src/serve/hub-app/palette-view.tsx +9 -2
- package/src/serve/hub-app/planned-view.tsx +2 -1
- package/src/serve/hub-app/project-list.css +18 -14
- package/src/serve/hub-app/project-list.tsx +88 -49
- package/src/serve/hub-app/projects-svc.ts +33 -3
- package/src/serve/hub-app/repo-sections.ts +19 -2
- package/src/serve/hub-app/repo-st.ts +76 -20
- package/src/serve/hub-app/review/review-board.tsx +1 -1
- package/src/serve/hub-app/review/review-cells.tsx +6 -5
- package/src/serve/hub-app/review/review-kit.ts +30 -7
- package/src/serve/hub-app/review/review-page.tsx +6 -5
- package/src/serve/hub-app/review/review-st.ts +34 -15
- package/src/serve/hub-app/review/review-thread.tsx +63 -14
- package/src/serve/hub-app/review/review-views.tsx +133 -51
- package/src/serve/hub-app/review/thread-st.ts +80 -37
- package/src/serve/hub-app/review/trailer-page.tsx +7 -5
- package/src/serve/hub-app/review/trailer-st.ts +1 -1
- package/src/serve/hub-app/review.css +26 -9
- package/src/serve/hub-app/site/site-part.tsx +173 -0
- package/src/serve/hub-app/site/site-st.ts +157 -0
- package/src/serve/hub-app/site.css +35 -0
- package/src/serve/hub-app/social/calendar.tsx +182 -0
- package/src/serve/hub-app/social/comms-page.tsx +330 -0
- package/src/serve/hub-app/social/kit.tsx +244 -0
- package/src/serve/hub-app/social/post-card.tsx +456 -0
- package/src/serve/hub-app/social/problems.tsx +60 -0
- package/src/serve/hub-app/social/social-model.ts +154 -0
- package/src/serve/hub-app/social/social-page.tsx +681 -0
- package/src/serve/hub-app/social/social-st.ts +1014 -0
- package/src/serve/hub-app/social.css +289 -0
- package/src/serve/hub-app/stores/stores-page.tsx +312 -0
- package/src/serve/hub-app/stores/stores-st.ts +286 -0
- package/src/serve/hub-app/stores.css +54 -0
- package/src/serve/hub-app/timeline-geometry.ts +1 -1
- package/src/serve/hub-app/timeline-view.tsx +3 -2
- package/src/serve/hub-app/tree-build.ts +6 -0
- package/src/serve/hub-app/tree-row.tsx +27 -4
- package/src/serve/hub-app/tree-svc.ts +18 -49
- package/src/serve/hub-app/veille/veille-page.tsx +515 -0
- package/src/serve/hub-app/veille/veille-st.ts +443 -0
- package/src/serve/hub-app/veille.css +84 -0
- package/src/serve/hub-runtime.ts +20 -11
- package/src/serve/project-gutter-route.ts +44 -12
- package/src/serve/run-lanes.ts +7 -4
- package/src/serve/same-origin.ts +1 -1
- package/src/serve/serve-hub.ts +20 -12
- package/src/serve/tracked-watch.ts +24 -3
- package/src/serve/warm-cell.ts +5 -1
- package/src/shipkit-files.ts +15 -4
- package/src/shipkit.ts +0 -1
- package/src/shot/box.ts +160 -0
- package/src/shot/browser-slot.ts +74 -0
- package/src/shot/client.ts +42 -7
- package/src/shot/clip-encoder.ts +108 -24
- package/src/shot/film-box.ts +292 -0
- package/src/shot/shooter.ts +71 -17
- package/src/shot/shot-ask.ts +10 -2
- package/src/shot/stepped-clip.ts +5 -4
- package/src/site/desk.ts +242 -0
- package/src/site/routes.ts +66 -0
- package/src/site/unit.ts +62 -0
- package/src/social/brands.ts +22 -0
- package/src/social/card-drafts.ts +24 -0
- package/src/social/compose.ts +97 -0
- package/src/social/desk-index.ts +123 -0
- package/src/social/desk-wire.ts +64 -0
- package/src/social/drafts.ts +183 -0
- package/src/social/house.ts +24 -0
- package/src/social/load.ts +332 -0
- package/src/social/md.ts +70 -0
- package/src/social/media-facts.ts +53 -0
- package/src/social/media-kind.ts +189 -0
- package/src/social/media-limit.ts +42 -0
- package/src/social/media-of.ts +30 -0
- package/src/social/migrate.ts +123 -0
- package/src/social/open.ts +17 -0
- package/src/social/post-url.ts +158 -0
- package/src/social/presence.ts +332 -0
- package/src/social/public-read.ts +53 -0
- package/src/social/publish/bluesky.ts +168 -0
- package/src/social/publish/discord.ts +76 -0
- package/src/social/publish/index.ts +24 -0
- package/src/social/publish/secret.ts +13 -0
- package/src/social/push.ts +37 -0
- package/src/social/richtext.ts +37 -0
- package/src/social/routes.ts +186 -0
- package/src/social/stats.ts +134 -0
- package/src/social/text.ts +267 -0
- package/src/social/tracker-route.ts +39 -0
- package/src/social/tracker.ts +255 -0
- package/src/social/unit.ts +53 -0
- package/src/social/writes.ts +130 -0
- package/src/start-repo.ts +14 -9
- package/src/stores/collection.ts +27 -0
- package/src/stores/desk.ts +336 -0
- package/src/stores/model.ts +187 -0
- package/src/stores/routes.ts +126 -0
- package/src/stores/unit.ts +57 -0
- package/src/suite/calibrate.ts +127 -0
- package/src/suite/core-counters.ts +91 -0
- package/src/suite/judge-suites.ts +95 -35
- package/src/suite/suite-cli.ts +44 -10
- package/src/suite/suite-cpu-preload.ts +34 -9
- package/src/trace/tracer.ts +12 -5
- package/src/trailer/adapter.ts +5 -1
- package/src/trailer/build.ts +45 -12
- package/src/trailer/ffmpeg.ts +11 -0
- package/src/trailer/footage.ts +30 -13
- package/src/trailer/grammar.ts +18 -2
- package/src/trailer/graph.ts +28 -6
- package/src/trailer/holes.ts +1 -1
- package/src/trailer/passage.ts +18 -6
- package/src/trailer/plan.ts +74 -3
- package/src/trailer/prune.ts +1 -1
- package/src/trailer/states.ts +1 -1
- package/src/trailer/stitch.ts +67 -26
- package/src/trailer/url.ts +1 -1
- package/src/trailer/versions.ts +24 -0
- package/src/trailer/words.ts +1 -1
- package/src/ts/gate-typecheck.ts +32 -0
- package/src/ts/typecheck-cli.ts +9 -11
- package/src/tui/run-tui.ts +1 -1
- package/src/tui/tui-app.tsx +0 -1
- package/src/tui/tui-store.ts +1 -1
- package/src/veille/asks.ts +155 -0
- package/src/veille/auto.ts +31 -0
- package/src/veille/batch.ts +27 -0
- package/src/veille/chrome.ts +127 -0
- package/src/veille/collection.ts +28 -0
- package/src/veille/desk.ts +242 -0
- package/src/veille/identity.ts +80 -0
- package/src/veille/import.ts +68 -0
- package/src/veille/log.ts +183 -0
- package/src/veille/platforms.ts +118 -0
- package/src/veille/reads.ts +66 -0
- package/src/veille/replied.ts +110 -0
- package/src/veille/routes.ts +185 -0
- package/src/veille/service.ts +81 -0
- package/src/veille/watch.ts +116 -0
- package/src/veille/worth.ts +46 -0
- package/src/wiki/scan-md.ts +18 -0
- package/src/collections/posts.ts +0 -142
- package/src/contracts/manifests/social.contract.ts +0 -20
- package/src/scaffold/files/agent-coding.md +0 -35
- package/src/ts/typecheck-cache.ts +0 -11
package/src/review/cells.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// a thread read as one conversation (wiki
|
|
1
|
+
// a thread read as one conversation (wiki tools/shipkit/review.md, The thread): every version of a card, every verdict,
|
|
2
2
|
// reply, note and state change is one cell, in time order, built at read time from the store's files (a supersedes chain
|
|
3
3
|
// folds into one thread, nothing is rewritten). The paged list's rows and its query. Pure and browser safe: the routes
|
|
4
4
|
// send these shapes, the hub page draws them
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
moveOf,
|
|
11
11
|
partyOf,
|
|
12
12
|
reworkOf,
|
|
13
|
+
isPostSubject,
|
|
13
14
|
stateOf,
|
|
14
15
|
STATUS_LABEL,
|
|
15
16
|
thumbFileOf,
|
|
@@ -138,6 +139,10 @@ export interface ThreadView {
|
|
|
138
139
|
/** the media files a view names that the store no longer holds, `<item id>/<name>`: the page says so in place of a
|
|
139
140
|
* broken player (the routes fill it, the model never reads the disk) */
|
|
140
141
|
missing: string[]
|
|
142
|
+
/** the posts he asked from this card (« 📣 post »), oldest first, each with where it stands */
|
|
143
|
+
posts: { id: string; state: ItemState }[]
|
|
144
|
+
/** the social drafts naming this card in their `review:`, oldest first (the routes fill it, the model never reads the disk) */
|
|
145
|
+
drafts: { slug: string; title: string }[]
|
|
141
146
|
cells: Cell[]
|
|
142
147
|
}
|
|
143
148
|
|
|
@@ -300,6 +305,13 @@ export function threadOfId(id: string, threads: readonly Thread[]): Thread | nul
|
|
|
300
305
|
return holding.sort((a, b) => b.head.item.created.localeCompare(a.head.item.created))[0] ?? null
|
|
301
306
|
}
|
|
302
307
|
|
|
308
|
+
/** the post requests naming one of these items as their card */
|
|
309
|
+
const postsOf = (ids: ReadonlySet<string>, items: readonly ReviewItem[], followed: ReadonlySet<string>): ThreadView['posts'] =>
|
|
310
|
+
items
|
|
311
|
+
.filter((x) => isPostSubject(x.item.subject) && ids.has(x.item.subject.card))
|
|
312
|
+
.sort((a, b) => a.item.created.localeCompare(b.item.created))
|
|
313
|
+
.map((x) => ({ id: x.item.id, state: stateOf(x, followed.has(x.item.id)) }))
|
|
314
|
+
|
|
303
315
|
/** one thread for the per card api; `asked` the id the caller named (an old version opens at its cell) */
|
|
304
316
|
export function threadView(t: Thread, items: readonly ReviewItem[], threads: readonly Thread[], asked: string, now = new Date()): ThreadView {
|
|
305
317
|
const h = t.head
|
|
@@ -330,6 +342,8 @@ export function threadView(t: Thread, items: readonly ReviewItem[], threads: rea
|
|
|
330
342
|
.filter((x) => unreadBy(x, 'owner').length > 0)
|
|
331
343
|
.map((x) => x.item.id),
|
|
332
344
|
missing: [],
|
|
345
|
+
posts: postsOf(new Set(idsOf(t)), items, followed),
|
|
346
|
+
drafts: [],
|
|
333
347
|
cells: cellsOf(t, items),
|
|
334
348
|
}
|
|
335
349
|
}
|
package/src/review/format.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// what `sk review inbox`, `show`, `watch`, `next` and `board` print of an item and its answer (wiki
|
|
1
|
+
// what `sk review inbox`, `show`, `watch`, `next` and `board` print of an item and its answer (wiki tools/shipkit/review.md):
|
|
2
2
|
// one record per thread, rectangles normalized and in pixels, a frame note's cut, shot and time into it, and the lines the
|
|
3
3
|
// repo's unit adds (a kind's facts, a source's), handed in as `more` so this module stays pure
|
|
4
4
|
import { aboutText, isFrame, isGallery, isPair, NO_SPEC, placeText, stateOf, unreadBy, verdictOf, type Message, type Rect, type ReviewItem, type Spec, type Subject } from './model.ts'
|
|
@@ -130,7 +130,7 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
|
|
|
130
130
|
`${r.id} ${st.state.toUpperCase()}${st.why ? ` (${st.why})` : ''} raised by ${raisedBy(r.origin)} ${r.created}${r.commit ? ` at ${r.commit}` : ''}`,
|
|
131
131
|
head,
|
|
132
132
|
...sub,
|
|
133
|
-
...(r.
|
|
133
|
+
...(r.what ? r.what.split('\n').map((l) => ` ${l}`) : []),
|
|
134
134
|
...(st.topic ? [` topic ${st.topic}${st.worker ? `, claimed by ${st.worker}` : ''}${r.origin.by === 'owner' && r.origin.kind ? `, ${r.origin.kind}` : ''}`] : []),
|
|
135
135
|
...words.map((m) => ` ${m.who} ${m.at}${m.op ? ` ${m.op}${m.topic ? ` ${m.topic}` : ''}` : ''}: ${m.text ?? m.note ?? ''}${m.fix ? ` (${m.fix.commit})` : ''}`),
|
|
136
136
|
...(pins ? drawnText(pins) : []),
|
package/src/review/http.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
// the hub's http helpers the review and
|
|
1
|
+
// the hub's http helpers the review, trailer and social routes share: an error answer, the cache headers, a json
|
|
2
|
+
// answer under its ETag, a file with byte ranges
|
|
2
3
|
import { extname } from 'node:path'
|
|
3
4
|
|
|
4
|
-
export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.webm': 'video/webm', '.mp4': 'video/mp4' }
|
|
5
|
+
export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.webm': 'video/webm', '.mp4': 'video/mp4', '.ico': 'image/x-icon' }
|
|
5
6
|
export const NO_STORE = { 'Cache-Control': 'no-store' }
|
|
6
7
|
/** an item's files never change once written, nor a kept render under its version: a phone keeps what it fetched */
|
|
7
8
|
export const KEEP = { 'Cache-Control': 'private, max-age=86400' }
|
|
8
9
|
|
|
10
|
+
/** a json answer under its ETag: 304 when the page holds it, gzipped when the page takes it and it is worth it. A
|
|
11
|
+
* caller that keeps the answer passes `held`, the zip made once for every page that asks the same tag */
|
|
12
|
+
export function tagged(req: Request, tag: string, body: () => unknown, held?: { tag: string; text: string; zip?: Uint8Array<ArrayBuffer> }): Response {
|
|
13
|
+
const headers = { 'Content-Type': 'application/json', ETag: tag, 'Cache-Control': 'no-cache', Vary: 'Accept-Encoding' }
|
|
14
|
+
if (req.headers.get('If-None-Match') === tag) return new Response(null, { status: 304, headers: { ETag: tag } })
|
|
15
|
+
const kept = held?.tag === tag ? held : null
|
|
16
|
+
const text = kept?.text ?? JSON.stringify(body())
|
|
17
|
+
if (text.length < 4096 || !/\bgzip\b/.test(req.headers.get('Accept-Encoding') ?? '')) return new Response(text, { headers })
|
|
18
|
+
const zip = kept?.zip ?? Bun.gzipSync(new TextEncoder().encode(text))
|
|
19
|
+
if (kept) kept.zip = zip
|
|
20
|
+
return new Response(zip, { headers: { ...headers, 'Content-Encoding': 'gzip' } })
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
export const bad = (e: unknown, status = 400): Response => Response.json({ error: e instanceof Error ? e.message : String(e) }, { status, headers: NO_STORE })
|
|
10
24
|
|
|
11
25
|
/** a file with byte ranges: a player seeks through them */
|
package/src/review/marks.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the owner's marks kept in the store (wiki
|
|
1
|
+
// the owner's marks kept in the store (wiki tools/shipkit/review.md, Verbs on the store): a mark is a `rate` message of his
|
|
2
2
|
// on a subject (stars, a mark word, a part's stars, a note); the latest is the mark, the older ones its history. Pure
|
|
3
3
|
import { partyOf, subjectKey, type Message, type ReviewItem, type Spec } from './model.ts'
|
|
4
4
|
|
package/src/review/media-kind.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the review store as a kind of the media store (wiki
|
|
1
|
+
// the review store as a kind of the media store (wiki tools/shipkit/review.md, Media in the Space): each file a card's
|
|
2
2
|
// views name, by the facts its item.json keeps; kept on the disk while its thread is active or spoke in the window; an
|
|
3
3
|
// image's previews sent up before it goes
|
|
4
4
|
import { existsSync, statSync } from 'node:fs'
|
package/src/review/media-read.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the reads a route or a tool makes of a card's file (wiki
|
|
1
|
+
// the reads a route or a tool makes of a card's file (wiki tools/shipkit/review.md, Media in the Space): its key in the
|
|
2
2
|
// Space by the facts its item.json keeps, a URL signed for a file the disk let go, the file fetched back for its bytes
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs'
|
|
4
4
|
import { join } from 'node:path'
|
package/src/review/model.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// the one feedback store's model (wiki
|
|
1
|
+
// the one feedback store's model (wiki tools/shipkit/review.md): every record the owner, a player or an agent raises
|
|
2
2
|
// is an ITEM, a head (`item.json`: a typed subject, who raised it, the views) and an append only thread of messages
|
|
3
3
|
// (verdicts, replies, ratings, state changes, read marks). The state is derived from the thread, never stored, so the
|
|
4
4
|
// hub and every CLI write at once with no lost update. Pure and browser safe: the store, the routes and the hub page
|
|
5
|
-
// share it. The on disk shape is
|
|
5
|
+
// share it. The on disk shape is the one a project's own review store writes, verbatim, so either store opens in the other.
|
|
6
6
|
import type { MediaFact } from '../media-store/fact.ts'
|
|
7
7
|
|
|
8
8
|
/** WHAT is judged: `shot` (a plain image or clip), `screen`, `frame` (a frame of a trailer cut), or a kind a repo names
|
|
9
|
-
* for itself (
|
|
9
|
+
* for itself (a game's place, creature, song...), read as is */
|
|
10
10
|
export interface Subject {
|
|
11
11
|
kind: string
|
|
12
12
|
[k: string]: unknown
|
|
@@ -28,6 +28,23 @@ export interface FrameSubject extends Subject {
|
|
|
28
28
|
|
|
29
29
|
export const isFrame = (s: Subject): s is FrameSubject => s.kind === 'frame'
|
|
30
30
|
|
|
31
|
+
/** a thing of a store page (wiki tools/shipkit/stores.md): a picture by its repo path, or a field as `field:<heading>` */
|
|
32
|
+
export interface StoreSubject extends Subject {
|
|
33
|
+
kind: 'store'
|
|
34
|
+
store: string
|
|
35
|
+
asset: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const isStoreSubject = (s: Subject): s is StoreSubject => s.kind === 'store' && typeof s.store === 'string' && typeof s.asset === 'string'
|
|
39
|
+
|
|
40
|
+
/** a public post he asked for from a card: `card` the card's first version, so every later version asks the same */
|
|
41
|
+
export interface PostSubject extends Subject {
|
|
42
|
+
kind: 'post'
|
|
43
|
+
card: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const isPostSubject = (s: Subject): s is PostSubject => s.kind === 'post' && typeof s.card === 'string' && s.card !== ''
|
|
47
|
+
|
|
31
48
|
/** what a repo's `review({...})` unit says of one subject kind that the pure model reads (review/unit.ts holds the rest):
|
|
32
49
|
* its words, and on the server its key, its near rule and its problems. The hub gets the words alone */
|
|
33
50
|
export interface SpecKind {
|
|
@@ -57,7 +74,7 @@ export interface Spec {
|
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
/** the kinds every repo has, whatever its unit declares */
|
|
60
|
-
export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' } }
|
|
77
|
+
export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, store: { label: 'store pages', icon: '🏪' }, post: { label: 'post requests', icon: '📣' } }
|
|
61
78
|
|
|
62
79
|
export const NO_SPEC: Spec = { kinds: {}, topics: {}, dispatcher: false }
|
|
63
80
|
|
|
@@ -80,6 +97,8 @@ export type Origin =
|
|
|
80
97
|
export function subjectKey(s: Subject, spec: Spec = NO_SPEC): string | null {
|
|
81
98
|
if (isFrame(s)) return `frame:${s.trailer}/${s.cut}/${s.shot}`
|
|
82
99
|
const kind = spec.kinds[s.kind]
|
|
100
|
+
if (!kind && isStoreSubject(s)) return `store:${s.store}/${s.asset}`
|
|
101
|
+
if (!kind && isPostSubject(s)) return `post:${s.card}`
|
|
83
102
|
if (kind) {
|
|
84
103
|
const k = kind.key?.(s)
|
|
85
104
|
return k ? `${s.kind}:${k}` : null
|
|
@@ -106,7 +125,7 @@ export interface ReviewAudio {
|
|
|
106
125
|
waveBefore?: string
|
|
107
126
|
}
|
|
108
127
|
|
|
109
|
-
/** a ring a repo drew over its own shot (
|
|
128
|
+
/** a ring a repo drew over its own shot (a game's world tiles): its center normalized 0..1, its radius as a share of
|
|
110
129
|
* the image width; `side` only on a pair */
|
|
111
130
|
export interface ReviewMark {
|
|
112
131
|
tile: [number, number]
|
|
@@ -436,7 +455,7 @@ export const STATUS_LABEL: Record<ShownStatus, string> = {
|
|
|
436
455
|
rated: 'rated',
|
|
437
456
|
}
|
|
438
457
|
|
|
439
|
-
/** the lifecycle (wiki
|
|
458
|
+
/** the lifecycle (wiki tools/shipkit/review.md, The lifecycle) */
|
|
440
459
|
export type State = 'draft' | 'new' | 'question' | 'open' | 'claimed' | 'blocked' | 'asks' | 'closed'
|
|
441
460
|
type ClosedWhy = ReviewStatus | 'fixed' | 'wontfix' | 'dropped' | 'superseded' | 'withdrawn' | 'rated'
|
|
442
461
|
|
|
@@ -712,6 +731,8 @@ function subjectProblems(s: unknown, spec: Spec): string[] {
|
|
|
712
731
|
const declared = Object.keys(spec.kinds)
|
|
713
732
|
if (!kind && !BUILTIN_KINDS[s.kind] && declared.length > 0) return [`subject: kind « ${s.kind} » is none of ${[...declared, ...Object.keys(BUILTIN_KINDS)].join(', ')}`]
|
|
714
733
|
if (kind?.problems) return kind.problems(s as Subject).map((p) => `subject: ${p}`)
|
|
734
|
+
if (s.kind === 'store' && !kind) return isStoreSubject(s as Subject) && s.store !== '' && s.asset !== '' ? [] : ['subject: a store thing has its store and asset']
|
|
735
|
+
if (s.kind === 'post' && !kind) return isPostSubject(s as Subject) ? [] : ['subject: a post request names its card']
|
|
715
736
|
if (s.kind !== 'frame') return []
|
|
716
737
|
const str = (k: string): boolean => typeof s[k] === 'string' && s[k] !== ''
|
|
717
738
|
const num = (k: string): boolean => typeof s[k] === 'number' && Number.isFinite(s[k])
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// his notes on one thing a desk shows (a store page's picture or field, a draft): the first an item of the one store,
|
|
2
|
+
// its subject the thing, so the review page and `sk review inbox` hold it; the next ones, while that thread is open,
|
|
3
|
+
// his replies on it, never a second item. The one path for a note on a thing (wiki tools/shipkit/stores.md)
|
|
4
|
+
import { threadOfId } from './cells.ts'
|
|
5
|
+
import { isPostSubject, stateOf, subjectKey, type Origin, type PostSubject, type ReviewItem, type Subject } from './model.ts'
|
|
6
|
+
import { addMessage, raiseItem, readAll, specOf } from './store.ts'
|
|
7
|
+
import { followedIds, membersOf, threadsOf, type Thread } from './threads.ts'
|
|
8
|
+
|
|
9
|
+
/** one note as a desk shows it: the owner's words, where it stands, the agent's last word once answered */
|
|
10
|
+
export type SubjectNote = { id: string; at: string; text: string; state: string; answer?: string }
|
|
11
|
+
|
|
12
|
+
const keyIn = (dir: string) => {
|
|
13
|
+
const spec = specOf(dir)
|
|
14
|
+
return (s: Subject): string | null => subjectKey(s, spec)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** every word of his on the thing's threads, the first note and each reply, with the thread's state and last answer */
|
|
18
|
+
function notesOfThreads(threads: readonly Thread[]): SubjectNote[] {
|
|
19
|
+
const out: SubjectNote[] = []
|
|
20
|
+
for (const t of threads) {
|
|
21
|
+
const members = membersOf(t)
|
|
22
|
+
const state = stateOf(t.head, false).state
|
|
23
|
+
const answer = members
|
|
24
|
+
.flatMap((x) => x.thread)
|
|
25
|
+
.filter((m) => m.who !== 'owner' && m.text !== undefined && m.op === undefined)
|
|
26
|
+
.sort((a, b) => a.at.localeCompare(b.at))
|
|
27
|
+
.at(-1)?.text
|
|
28
|
+
for (const x of members)
|
|
29
|
+
for (const m of x.thread)
|
|
30
|
+
if (m.who === 'owner' && m.op === undefined && m.verdict === undefined && m.text !== undefined)
|
|
31
|
+
out.push({ id: x.item.id, at: m.at, text: m.text, state, ...(answer ? { answer } : {}) })
|
|
32
|
+
}
|
|
33
|
+
return out.sort((a, b) => b.at.localeCompare(a.at))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** the notes of any thing, the threads grouped once: a desk that shows many things reads the store's threads once */
|
|
37
|
+
export function notesBy(dir: string, items: readonly ReviewItem[]): (subject: Subject) => SubjectNote[] {
|
|
38
|
+
const key = keyIn(dir)
|
|
39
|
+
const by = new Map<string, Thread[]>()
|
|
40
|
+
for (const t of threadsOf(items))
|
|
41
|
+
for (const k of new Set(membersOf(t).map((x) => key(x.item.subject))))
|
|
42
|
+
if (k !== null) by.set(k, [...(by.get(k) ?? []), t])
|
|
43
|
+
return (subject) => {
|
|
44
|
+
const k = key(subject)
|
|
45
|
+
if (k === null) throw new Error(`notes: a ${subject.kind} names no one thing`)
|
|
46
|
+
return notesOfThreads(by.get(k) ?? [])
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** his note on the thing: a reply on its thread still open, else a new item titled `<name> : <first line>` */
|
|
51
|
+
export async function noteOn(
|
|
52
|
+
dir: string,
|
|
53
|
+
o: { subject: Subject; origin: Extract<Origin, { by: 'owner' }>; name: string; text: string; topic?: string; image?: string; what?: string },
|
|
54
|
+
): Promise<{ id: string }> {
|
|
55
|
+
const key = keyIn(dir)
|
|
56
|
+
const k = key(o.subject)
|
|
57
|
+
const text = o.text.trim()
|
|
58
|
+
if (k === null) throw new Error(`note: a ${o.subject.kind} names no one thing`)
|
|
59
|
+
if (!text) throw new Error('note: the text is empty')
|
|
60
|
+
const open = threadsOf(readAll(dir).items)
|
|
61
|
+
.filter((t) => membersOf(t).some((x) => key(x.item.subject) === k))
|
|
62
|
+
.filter((t) => stateOf(t.head, false).state !== 'closed')
|
|
63
|
+
.sort((a, b) => b.head.item.created.localeCompare(a.head.item.created))[0]?.head.item.id
|
|
64
|
+
if (open) {
|
|
65
|
+
addMessage(dir, open, 'owner', text)
|
|
66
|
+
return { id: open }
|
|
67
|
+
}
|
|
68
|
+
const head = `${o.name} : ${text.split('\n')[0] ?? ''}`
|
|
69
|
+
const x = await raiseItem(dir, {
|
|
70
|
+
subject: o.subject,
|
|
71
|
+
origin: o.origin,
|
|
72
|
+
...(o.topic ? { topic: o.topic } : {}),
|
|
73
|
+
title: head.length > 80 ? `${head.slice(0, 79).trimEnd()}…` : head,
|
|
74
|
+
text,
|
|
75
|
+
...(o.image ? { image: o.image } : {}),
|
|
76
|
+
...(o.what ? { what: o.what } : {}),
|
|
77
|
+
})
|
|
78
|
+
return { id: x.item.id }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** a post the owner asked from a card and no draft answers yet: what Communications lists on top of its drafts */
|
|
82
|
+
export type AskedPost = { id: string; at: string; card: string; title: string; text: string; state: string }
|
|
83
|
+
|
|
84
|
+
/** every post request not closed, oldest first: the card's title as it is now, the owner's words joined */
|
|
85
|
+
export function askedPosts(items: readonly ReviewItem[]): AskedPost[] {
|
|
86
|
+
const threads = threadsOf(items)
|
|
87
|
+
const followed = followedIds(items)
|
|
88
|
+
return items
|
|
89
|
+
.filter((x) => isPostSubject(x.item.subject))
|
|
90
|
+
.map((x) => ({ x, st: stateOf(x, followed.has(x.item.id)) }))
|
|
91
|
+
.filter(({ st }) => st.state !== 'closed')
|
|
92
|
+
.sort((a, b) => a.x.item.created.localeCompare(b.x.item.created))
|
|
93
|
+
.map(({ x, st }) => {
|
|
94
|
+
const card = (x.item.subject as PostSubject).card
|
|
95
|
+
const t = threadOfId(card, threads)
|
|
96
|
+
const words = x.thread.filter((m) => m.who === 'owner' && m.op === undefined && m.verdict === undefined && m.text !== undefined).map((m) => m.text as string)
|
|
97
|
+
return { id: x.item.id, at: x.item.created, card: t?.head.item.id ?? card, title: t?.head.item.title ?? card, text: words.join('\n'), state: st.state }
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** « 📣 post » on a card: a request for its own public post, keyed on the card's first version so every version asks
|
|
102
|
+
* the same one; `topic` the social unit's notes topic, left out where the store's topics lack it */
|
|
103
|
+
export async function askPost(dir: string, o: { card: string; text?: string; topic?: string }): Promise<{ id: string }> {
|
|
104
|
+
const t = threadOfId(o.card, threadsOf(readAll(dir).items))
|
|
105
|
+
if (!t) throw new Error(`post: no card ${o.card}`)
|
|
106
|
+
const head = t.head.item
|
|
107
|
+
if (isPostSubject(head.subject)) throw new Error('post: this card is itself a post request')
|
|
108
|
+
const first = t.versions.at(-1)?.item.id ?? head.id
|
|
109
|
+
const spec = specOf(dir)
|
|
110
|
+
const topic = o.topic !== undefined && (Object.keys(spec.topics).length === 0 || spec.topics[o.topic]) ? o.topic : undefined
|
|
111
|
+
const subject: PostSubject = { kind: 'post', card: first }
|
|
112
|
+
return noteOn(dir, {
|
|
113
|
+
subject,
|
|
114
|
+
origin: { by: 'owner', from: 'review' },
|
|
115
|
+
name: `post « ${head.title} »`,
|
|
116
|
+
text: o.text?.trim() || 'this card deserves its own post',
|
|
117
|
+
...(topic ? { topic } : {}),
|
|
118
|
+
what: [
|
|
119
|
+
`A public post from the card « ${head.title} » (${head.id}).`,
|
|
120
|
+
`- read the card: \`sk review show ${head.id}\`; its views are the post's media`,
|
|
121
|
+
`- write the draft: \`.shipkit/social/drafts/<YYYYMMDD-HHMMSS>-<topic>/draft.md\`, \`review: ${head.id}\` in its front matter, the media in its \`media/\` (wiki tools/shipkit/social.md)`,
|
|
122
|
+
'- close this request: `sk review fixed <this id> --note "draft <slug>"`',
|
|
123
|
+
].join('\n'),
|
|
124
|
+
})
|
|
125
|
+
}
|
package/src/review/previews.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// a view's image at the size the page draws it (wiki
|
|
1
|
+
// a view's image at the size the page draws it (wiki tools/shipkit/review.md, Previews): a webp made once per media
|
|
2
2
|
// file, kept in the repo's cache (`.shipkit/cache/review-previews/<id>/<name>.<size>.webp`, local, never in the store),
|
|
3
3
|
// made again only when its source is newer. The full file is fetched only on zoom
|
|
4
4
|
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync } from 'node:fs'
|
package/src/review/project.ts
CHANGED
|
@@ -1,48 +1,16 @@
|
|
|
1
|
-
// a repo's review unit at work (wiki
|
|
1
|
+
// a repo's review unit at work (wiki tools/shipkit/review.md, A project's parts): its file found by a walk cached on the
|
|
2
2
|
// walked dirs' times and its text, imported, its spec bound to the store; its sources pulled, its kinds' facts and data
|
|
3
3
|
// view computed on the server, so the hub never bundles project code
|
|
4
|
-
import { existsSync
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { existsSync } from 'node:fs'
|
|
5
|
+
import { unitFilesDeclaring } from '../core/unit-files.ts'
|
|
6
|
+
import { isAbsolute, relative, resolve } from 'node:path'
|
|
7
|
+
import { importFresh } from '../core/discover-checks.ts'
|
|
8
8
|
import type { ReviewItem } from './model.ts'
|
|
9
9
|
import { bindSpec, readAll, storeDir } from './store.ts'
|
|
10
10
|
import { specOfUnit, type Fact, type Link, type ReviewUnit, type ViewPart, type ViewText } from './unit.ts'
|
|
11
11
|
|
|
12
|
-
/** the
|
|
13
|
-
|
|
14
|
-
interface Found {
|
|
15
|
-
dirs: [string, number][]
|
|
16
|
-
files: [string, number, boolean][]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const foundFile = (root: string): string => join(root, LAYOUT.cache, 'review-unit.json')
|
|
20
|
-
const mtime = (p: string): number => statSync(p, { throwIfNoEntry: false })?.mtimeMs ?? -1
|
|
21
|
-
|
|
22
|
-
/** the unit files that declare a review unit, by a text test, never an import: the walk's dirs cached on their times */
|
|
23
|
-
export function reviewUnitFiles(root: string): string[] {
|
|
24
|
-
const cache = foundFile(root)
|
|
25
|
-
let found: Found | null = null
|
|
26
|
-
try {
|
|
27
|
-
found = JSON.parse(readFileSync(cache, 'utf8')) as Found
|
|
28
|
-
} catch {
|
|
29
|
-
found = null
|
|
30
|
-
}
|
|
31
|
-
const fresh = (f: Found): boolean => f.dirs.every(([d, t]) => mtime(d) === t) && f.files.every(([p, t]) => mtime(p) === t)
|
|
32
|
-
if (!found || !fresh(found)) {
|
|
33
|
-
const dirs: string[] = []
|
|
34
|
-
const files = repoUnitFiles(root, dirs).filter((f) => !f.endsWith('.check.shipkit.ts'))
|
|
35
|
-
found = { dirs: dirs.map((d) => [d, mtime(d)]), files: files.map((f) => [f, mtime(f), /\breview\s*\(/.test(readFileSync(f, 'utf8'))]) }
|
|
36
|
-
try {
|
|
37
|
-
mkdirSync(join(root, LAYOUT.cache), { recursive: true })
|
|
38
|
-
writeFileSync(`${cache}.${process.pid}.tmp`, JSON.stringify(found))
|
|
39
|
-
renameSync(`${cache}.${process.pid}.tmp`, cache)
|
|
40
|
-
} catch {
|
|
41
|
-
// a read only checkout: the next run walks again
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return found.files.filter(([, , has]) => has).map(([f]) => f)
|
|
45
|
-
}
|
|
12
|
+
/** the unit files that declare a review unit (core/unit-files.ts) */
|
|
13
|
+
export const reviewUnitFiles = (root: string): string[] => unitFilesDeclaring(root, 'review')
|
|
46
14
|
|
|
47
15
|
/** the repo's review unit, or null; two of them is an error naming both files */
|
|
48
16
|
export async function loadReviewUnit(root: string): Promise<ReviewUnit | null> {
|
package/src/review/role.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the dispatcher role (wiki
|
|
1
|
+
// the dispatcher role (wiki tools/shipkit/review.md, Raised items): one session routes what the owner, the players and
|
|
2
2
|
// the rules raise. Its file sits beside the store, out of the store's watch
|
|
3
3
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
4
4
|
import { join } from 'node:path'
|
package/src/review/routes.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the hub's review routes (wiki
|
|
1
|
+
// the hub's review routes (wiki tools/shipkit/review.md, The hub): the store's list, an item's images and clips, the
|
|
2
2
|
// owner's verdicts, replies and read marks appended to its thread. The trailer view's routes: trailer-routes.ts. Paths are
|
|
3
3
|
// relative to the repo hub's base. null: not a path of these
|
|
4
4
|
import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
@@ -6,8 +6,9 @@ import { tmpdir } from 'node:os'
|
|
|
6
6
|
import { dirname, extname, join } from 'node:path'
|
|
7
7
|
import { isAnimFormat, isAnimLabels, isAnimMode, pairAnimation } from './anim.ts'
|
|
8
8
|
import { startAuto } from './auto.ts'
|
|
9
|
-
import { bad, KEEP, NO_STORE, ranged, TYPES } from './http.ts'
|
|
9
|
+
import { bad, KEEP, NO_STORE, ranged, tagged, TYPES } from './http.ts'
|
|
10
10
|
import { viewFilesOf, type Rect, type ReviewItem, type Subject } from './model.ts'
|
|
11
|
+
import { askPost } from './notes.ts'
|
|
11
12
|
import { pasteHosts } from './paste.ts'
|
|
12
13
|
import { openReview, partFile, viewOfItem } from './project.ts'
|
|
13
14
|
import { isPreviewSize, previewOrRemote, warmPreviews } from './previews.ts'
|
|
@@ -20,6 +21,9 @@ import { remoteUrl, reviewKey } from './media-read.ts'
|
|
|
20
21
|
import { trailerRoutes } from './trailer-routes.ts'
|
|
21
22
|
import { specData, type ReviewUnit } from './unit.ts'
|
|
22
23
|
import { liveWatchers } from './watchers.ts'
|
|
24
|
+
import { autoRulesOf } from '../veille/auto.ts'
|
|
25
|
+
import { loadSocialUnit } from '../social/unit.ts'
|
|
26
|
+
import { draftsOfCard } from '../social/card-drafts.ts'
|
|
23
27
|
|
|
24
28
|
// ── each repo's review unit, read again at most every 5 s; its auto rules scheduled in this server while it serves ──
|
|
25
29
|
|
|
@@ -40,7 +44,7 @@ async function project(root: string): Promise<{ dir: string; unit: ReviewUnit |
|
|
|
40
44
|
return { dir, unit }
|
|
41
45
|
}
|
|
42
46
|
held?.auto?.stop()
|
|
43
|
-
const rules = unit
|
|
47
|
+
const rules = autoRulesOf(root, unit)
|
|
44
48
|
opened.set(root, { at: Date.now(), unit, auto: rules.length > 0 ? startAuto(dir, rules, () => readAllCached(dir).items) : null })
|
|
45
49
|
return { dir, unit }
|
|
46
50
|
}
|
|
@@ -113,15 +117,6 @@ function missingOf(dir: string, members: readonly ReviewItem[]): string[] {
|
|
|
113
117
|
/** a file the disk let go, answered by the Space: the signed URL lives an hour, the browser keeps the redirect half of it */
|
|
114
118
|
const toSpace = (url: string): Response => new Response(null, { status: 302, headers: { Location: url, 'Cache-Control': 'private, max-age=1800' } })
|
|
115
119
|
|
|
116
|
-
/** a json answer with its ETag, 304 when the page holds it; gzipped when the page takes it */
|
|
117
|
-
function tagged(req: Request, tag: string, body: () => unknown): Response {
|
|
118
|
-
const headers = { 'Content-Type': 'application/json', ETag: tag, 'Cache-Control': 'no-cache', Vary: 'Accept-Encoding' }
|
|
119
|
-
if (req.headers.get('If-None-Match') === tag) return new Response(null, { status: 304, headers: { ETag: tag } })
|
|
120
|
-
const text = JSON.stringify(body())
|
|
121
|
-
if (text.length < 4096 || !/\bgzip\b/.test(req.headers.get('Accept-Encoding') ?? '')) return new Response(text, { headers })
|
|
122
|
-
return new Response(Bun.gzipSync(new TextEncoder().encode(text)), { headers: { ...headers, 'Content-Encoding': 'gzip' } })
|
|
123
|
-
}
|
|
124
|
-
|
|
125
120
|
async function reviewRoute(req: Request, path: string, dir: string, unit: ReviewUnit | null): Promise<Response | null> {
|
|
126
121
|
if (path === '/api/review' && req.method === 'GET') {
|
|
127
122
|
// the page polls this list: it is read from disk and sent again only when a file of it changed
|
|
@@ -150,7 +145,10 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
150
145
|
}
|
|
151
146
|
const t = threadOfId(id, x.threads)
|
|
152
147
|
if (!t) return bad(`no item ${ref}`, 404)
|
|
153
|
-
return tagged(req, x.tag, () =>
|
|
148
|
+
return tagged(req, x.tag, () => {
|
|
149
|
+
const members = membersOf(t)
|
|
150
|
+
return { ...threadView(t, readAllCached(dir).items, x.threads, id), missing: missingOf(dir, members), drafts: draftsOfCard(dirname(dirname(dir)), new Set(members.map((m) => m.item.id))) }
|
|
151
|
+
})
|
|
154
152
|
}
|
|
155
153
|
if (path === '/api/review/board' && req.method === 'GET') {
|
|
156
154
|
const x = indexOf(dir)
|
|
@@ -162,7 +160,7 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
162
160
|
// where a card lives, for the paste that hands it to another agent session; a config that does not load leaves it out
|
|
163
161
|
const where = await pasteHosts(dirname(dirname(dir))).catch(() => null)
|
|
164
162
|
return Response.json(
|
|
165
|
-
{ ...specData(specOf(dir)), role: roleOf(dir), sources: (unit?.sources ?? []).map((s) => s.id), auto: (unit
|
|
163
|
+
{ ...specData(specOf(dir)), role: roleOf(dir), sources: (unit?.sources ?? []).map((s) => s.id), auto: autoRulesOf(dirname(dirname(dir)), unit).map((r) => ({ id: r.id, every: r.every })), where },
|
|
166
164
|
{ headers: NO_STORE },
|
|
167
165
|
)
|
|
168
166
|
}
|
|
@@ -232,6 +230,12 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
232
230
|
const r = writeVerdict(dir, id, await req.json())
|
|
233
231
|
return r.ok ? Response.json(r.message, { headers: NO_STORE }) : Response.json({ error: r.errors.join('\n'), errors: r.errors }, { status: 400, headers: NO_STORE })
|
|
234
232
|
}
|
|
233
|
+
if (name === 'post') {
|
|
234
|
+
const b = (await req.json().catch(() => ({}))) as { text?: unknown }
|
|
235
|
+
const social = await loadSocialUnit(dirname(dirname(dir)))
|
|
236
|
+
const text = typeof b.text === 'string' ? b.text : undefined
|
|
237
|
+
return Response.json(await askPost(dir, { card: id, topic: social?.notes ?? 'social', ...(text ? { text } : {}) }), { headers: NO_STORE })
|
|
238
|
+
}
|
|
235
239
|
if (name === 'reply') return Response.json(addMessage(dir, id, 'owner', ((await req.json()) as { text?: unknown }).text), { headers: NO_STORE })
|
|
236
240
|
if (name === 'read') {
|
|
237
241
|
// the page names the words it drew: a word that came after them stays unread
|
package/src/review/store.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
// the one feedback store on disk (wiki
|
|
1
|
+
// the one feedback store on disk (wiki tools/shipkit/review.md): `.shipkit/review/<id>/`, gitignored: `item.json`, the
|
|
2
2
|
// media, and `thread/`, one file per message, never rewritten. An item is built in a dot folder and renamed, every file
|
|
3
|
-
// written beside its place and renamed, so no reader sees half of one. The format is
|
|
3
|
+
// written beside its place and renamed, so no reader sees half of one. The format is a project's own store's, verbatim. A folder of
|
|
4
4
|
// the old shape (request.json, feedback.json, a message with `seen`) fails loud
|
|
5
5
|
import * as fs from 'node:fs'
|
|
6
6
|
import { existsSync, readdirSync, readFileSync, statSync, watch } from 'node:fs'
|
|
7
7
|
import { basename, dirname, extname, join, resolve } from 'node:path'
|
|
8
8
|
import { LAYOUT } from '../core/layout.ts'
|
|
9
|
+
import { yieldLoop } from '../core/loop-watch.ts'
|
|
9
10
|
import { ffmpeg } from '../trailer/ffmpeg.ts'
|
|
10
11
|
import { probe, sizeOf, stillAt } from './media.ts'
|
|
11
12
|
import { factsOf } from '../media-store/content.ts'
|
|
@@ -592,8 +593,31 @@ const used = new Set<string>()
|
|
|
592
593
|
/** a code that read no store for this long: its reads go */
|
|
593
594
|
const CODE_KEEP_MS = 7 * 24 * 3600_000
|
|
594
595
|
|
|
596
|
+
/** items a step of a read covers before it gives the loop back (readRawsAsync) */
|
|
597
|
+
const READ_STEP = 250
|
|
598
|
+
|
|
595
599
|
/** every item of the store, through the machine index (space/db.ts): an item whose stamp moved is read again */
|
|
596
600
|
function readRaws(dir: string): ReadAll {
|
|
601
|
+
const steps = readRawsSteps(dir)
|
|
602
|
+
for (;;) {
|
|
603
|
+
const r = steps.next()
|
|
604
|
+
if (r.done) return r.value
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** the same read, the loop given back every READ_STEP items: a cold store of thousands of items is seconds of parsing
|
|
609
|
+
* (wiki tools/shipkit/home.md, Nothing heavy on the daemon's loop) */
|
|
610
|
+
async function readRawsAsync(dir: string): Promise<ReadAll> {
|
|
611
|
+
const steps = readRawsSteps(dir)
|
|
612
|
+
for (;;) {
|
|
613
|
+
const r = steps.next()
|
|
614
|
+
if (r.done) return r.value
|
|
615
|
+
await yieldLoop()
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/** the one read, in steps: it yields between two of them, and returns the store */
|
|
620
|
+
function* readRawsSteps(dir: string): Generator<void, ReadAll, void> {
|
|
597
621
|
const out: ReadAll = { items: [], broken: [] }
|
|
598
622
|
if (!existsSync(dir)) return out
|
|
599
623
|
const store = resolve(dir)
|
|
@@ -612,8 +636,10 @@ function readRaws(dir: string): ReadAll {
|
|
|
612
636
|
}
|
|
613
637
|
const moved: { id: string; stamp: string; read: Read }[] = []
|
|
614
638
|
const seen = new Set<string>()
|
|
639
|
+
let n = 0
|
|
615
640
|
for (const id of readdirSync(dir).sort()) {
|
|
616
641
|
if (id.startsWith('.')) continue
|
|
642
|
+
if (++n % READ_STEP === 0) yield
|
|
617
643
|
seen.add(id)
|
|
618
644
|
const stamp = stampOf(join(dir, id))
|
|
619
645
|
const held = was.get(id)
|
|
@@ -1010,6 +1036,20 @@ function watchOf(dir: string): Watched | null {
|
|
|
1010
1036
|
}
|
|
1011
1037
|
}
|
|
1012
1038
|
|
|
1039
|
+
/** a watched store read whole before a page asks, the loop given back between two steps: the first read after a boot
|
|
1040
|
+
* is the only whole one, every later one reads the items that moved */
|
|
1041
|
+
export async function warmStore(dir: string): Promise<void> {
|
|
1042
|
+
if (!existsSync(dir)) return
|
|
1043
|
+
const w = watchOf(dir)
|
|
1044
|
+
if (!w || (w.held && w.all)) return
|
|
1045
|
+
// what moved before the read is in it; what moves during it stays dirty, read again by the next reader
|
|
1046
|
+
w.dirty.clear()
|
|
1047
|
+
const all = await readRawsAsync(dir)
|
|
1048
|
+
if (w.held && w.all) return
|
|
1049
|
+
w.held = new Map<string, Read>([...all.items.map((x) => [x.item.id, { x }] as const), ...all.broken.map((b) => [b.id, { error: b.error }] as const)])
|
|
1050
|
+
w.all = all
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1013
1053
|
/** changes when anything the list is built from changes: watched, a count of writes; else a scan. The list's ETag */
|
|
1014
1054
|
export function storeStamp(dir: string): string {
|
|
1015
1055
|
if (!existsSync(dir)) return 'none'
|
package/src/review/threads.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the threads of the store (wiki
|
|
1
|
+
// the threads of the store (wiki tools/shipkit/review.md): a card's versions, each superseding the last, and the raised
|
|
2
2
|
// items (a report, his note) the card answers, read as one thread per bug; their status, conversation and order, and
|
|
3
3
|
// the active thread a new card already covers. Pure, over the items of review/model.ts
|
|
4
4
|
import {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the trailer view's cuts, renders and timelines (wiki
|
|
1
|
+
// the trailer view's cuts, renders and timelines (wiki tools/trailer/index.md, Frame notes), and the still a note on a frame
|
|
2
2
|
// is raised with: the note itself is an item of the one store, its subject the frame, anchored on its shot's name, so it
|
|
3
3
|
// survives a new render of the cut. A cut is a `trailer/<id>/<cut>.trailer` and its render `out/<name>.mp4` (`<name>`
|
|
4
4
|
// its `trailer` line), or a render with no file beside it. The trailer core (src/trailer/) is read, never changed
|
|
@@ -83,7 +83,7 @@ const versionFile = (dir: string, v: string, end: string): string | null => {
|
|
|
83
83
|
return f ? join(d, f) : null
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/** a trailer's kept versions (wiki
|
|
86
|
+
/** a trailer's kept versions (wiki tools/trailer/index.md, Versions): each `versions/<v>.trailer`, its render in its folder
|
|
87
87
|
* when the machine still holds it */
|
|
88
88
|
function versionsOf(dir: string): CutFiles[] {
|
|
89
89
|
const vd = join(dir, 'versions')
|
|
@@ -147,7 +147,7 @@ const SETTLE_MS = 2500
|
|
|
147
147
|
const settled = (mtime: number, now: number): boolean => now - mtime > SETTLE_MS
|
|
148
148
|
|
|
149
149
|
/** where each finished render is recorded as the page plays it: its json, and an APFS clone of its video and strip
|
|
150
|
-
* (free, untouched by the next render) until the media store holds them (wiki
|
|
150
|
+
* (free, untouched by the next render) until the media store holds them (wiki tools/trailer/index.md, Frame notes) */
|
|
151
151
|
export const viewDir = (root: string): string => join(root, LAYOUT.cache, 'trailer-view')
|
|
152
152
|
|
|
153
153
|
/** a render's files by their content, filled by the media store's scan (src/review/trailer-media.ts) */
|