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
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// sk social drafts import, sk social draft <verb>, sk thread events: the posts and their groups as events of the thread
|
|
2
|
+
// store, the one truth (wiki tools/shipkit/social.md, Posts and their groups; wiki tools/shipkit/threads-events.md). Every
|
|
3
|
+
// module loads inside execute: the cli registers this file on every `sk` call
|
|
4
|
+
import { Command, Option } from 'clipanion'
|
|
5
|
+
|
|
6
|
+
type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
|
|
7
|
+
const say = (c: Ctx) => (l: string): void => void c.stdout.write(`${l}\n`)
|
|
8
|
+
|
|
9
|
+
async function guarded(c: Ctx, what: string, body: () => Promise<number>): Promise<number> {
|
|
10
|
+
try {
|
|
11
|
+
return await body()
|
|
12
|
+
} catch (e) {
|
|
13
|
+
c.stderr.write(`FAIL: ${what}: ${e instanceof Error ? e.message : String(e)}\n`)
|
|
14
|
+
return 1
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const sender = (): string => process.env.SK_AGENT?.trim() || 'agent'
|
|
19
|
+
const textOf = async (v: string): Promise<string> => (v === '-' ? await new Response(Bun.stdin.stream()).text() : (await import('node:fs')).readFileSync(v, 'utf8'))
|
|
20
|
+
|
|
21
|
+
class SocialDraftsImportCommand extends Command {
|
|
22
|
+
static override paths = [['social', 'drafts', 'import']]
|
|
23
|
+
static override usage = Command.Usage({
|
|
24
|
+
category: 'Social',
|
|
25
|
+
description: 'the old drafts folders into the database: a look, or the write after a backup',
|
|
26
|
+
details:
|
|
27
|
+
"Reads each folder through the desk's own builder: its group, one post per account it reaches (a group heading becomes one post per account), every file. A look by default: each repo's groups, posts by state, files on the disk, in the Space, named and missing. --go runs sk backup, pins that run 30 days (sk backup pin), sk backup threads and sk backup threads drill first and stops when one fails, then keeps every file by its key (a file the Space holds already is never sent again), writes the events with each posted link's moment as the timeline gave it, makes a thread refer to each new group (the version it was staged from, else one opened on it), then loads the desk from the database and compares it with the folders' desk, every draft and post field by field: any difference fails. Re-runnable: what did not move writes nothing. It never writes in the folders. --all: every house repo. Page: wiki tools/shipkit/social.md, The verbs, the thread's block, the import",
|
|
28
|
+
examples: [
|
|
29
|
+
['a look in this repo', 'sk social drafts import'],
|
|
30
|
+
['every house repo, after the backups', 'sk social drafts import --all --go'],
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
all = Option.Boolean('--all', false, { description: 'every house repo' })
|
|
34
|
+
go = Option.Boolean('--go', false, { description: 'write, after the backups and the drill' })
|
|
35
|
+
override async execute(): Promise<number> {
|
|
36
|
+
return guarded(this.context, 'social drafts import', async () => {
|
|
37
|
+
const out = say(this.context)
|
|
38
|
+
const { houseRepoRoots } = await import('../social/house.ts')
|
|
39
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
40
|
+
const { existsSync } = await import('node:fs')
|
|
41
|
+
const { draftsDir } = await import('../social/load.ts')
|
|
42
|
+
const { loadIdentities } = await import('../identities/identities.ts')
|
|
43
|
+
const { loadRepoConfig } = await import('../repo-config.ts')
|
|
44
|
+
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
45
|
+
const { importRepo } = await import('../social/import-drafts.ts')
|
|
46
|
+
const roots = (this.all ? (await houseRepoRoots(process.cwd())).map((r) => r.path) : [findRepoRoot(process.cwd())]).filter((r) => existsSync(draftsDir(r)))
|
|
47
|
+
if (this.go)
|
|
48
|
+
for (const argv of [['sk', 'backup'], ['sk', 'backup', 'pin', '--days', '30', '--why', 'before the social migration'], ['sk', 'backup', 'threads'], ['sk', 'backup', 'threads', 'drill']]) {
|
|
49
|
+
out(`first: ${argv.join(' ')}`)
|
|
50
|
+
const b = Bun.spawnSync(argv, { stdout: 'pipe', stderr: 'pipe' })
|
|
51
|
+
for (const l of `${b.stdout?.toString() ?? ''}${b.stderr?.toString() ?? ''}`.trim().split('\n').slice(-3)) out(` ${l}`)
|
|
52
|
+
if (b.exitCode !== 0) throw new Error(`${argv.join(' ')} failed: nothing written`)
|
|
53
|
+
}
|
|
54
|
+
let bad = 0
|
|
55
|
+
for (const root of roots) {
|
|
56
|
+
const [config, ids, unit] = await Promise.all([loadRepoConfig(root, { fresh: true }).catch(() => null), loadIdentities({ cwd: root }), loadSocialUnit(root)])
|
|
57
|
+
const r = await importRepo(root, ids, { ...(config?.speaksAs ? { speaksAs: config.speaksAs } : {}), unit, go: this.go, sender: 'machine' })
|
|
58
|
+
out(`${root}: ${r.groups} groups, posts ${r.posts.draft} draft, ${r.posts.posted} posted, ${r.posts.dropped} dropped; files ${r.files.local} on the disk, ${r.files.space} in the Space only, ${r.files.missing} named with no file`)
|
|
59
|
+
if (r.facts.entries > 0) out(` the media facts record: ${r.facts.entries} entries, ${r.facts.used} of folders read${r.facts.orphans.length > 0 ? `, ${r.facts.entries - r.facts.used} of no folder (${r.facts.orphans.join(', ')}): left in the record, which the backup keeps` : ''}`)
|
|
60
|
+
for (const m of r.missing) out(` NOT LOADED ${m}: the builder left it out (sk social shows why)`)
|
|
61
|
+
bad += r.missing.length
|
|
62
|
+
if (!this.go) continue
|
|
63
|
+
out(` wrote ${r.wrote.groups} group events, ${r.wrote.posts} post events; ${r.created.length} new groups; ${r.threads} threads refer to new groups`)
|
|
64
|
+
for (const d of r.differs.slice(0, 30)) out(` DIFFERS ${d.slug} ${d.field}: folder ${JSON.stringify(d.folder)?.slice(0, 100)}, database ${JSON.stringify(d.db)?.slice(0, 100)}`)
|
|
65
|
+
out(` ${r.differs.length} field${r.differs.length === 1 ? '' : 's'} differ between the folders and the database`)
|
|
66
|
+
bad += r.differs.length
|
|
67
|
+
}
|
|
68
|
+
out(this.go ? 'then: sk thread events --check, sk backup threads drill' : `a look: nothing written. sk social drafts import${this.all ? ' --all' : ''} --go backs up, then writes`)
|
|
69
|
+
return bad > 0 ? 1 : 0
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
class SocialDraftsWhyCommand extends Command {
|
|
75
|
+
static override paths = [['social', 'drafts', 'why']]
|
|
76
|
+
static override usage = Command.Usage({
|
|
77
|
+
category: 'Social',
|
|
78
|
+
description: "each custom post group's reason (kindWhy): a reason that comes back is a kind",
|
|
79
|
+
details: 'One line a post group whose kind is custom: its repo, its slug, its kindWhy. A repo once, whatever checkout reads it (worktrees share its groups). --all: every house repo. Page: wiki guides/post-kinds/post-kind-custom.md',
|
|
80
|
+
examples: [['every house repo', 'sk social drafts why --all']],
|
|
81
|
+
})
|
|
82
|
+
all = Option.Boolean('--all', false, { description: 'every house repo' })
|
|
83
|
+
override async execute(): Promise<number> {
|
|
84
|
+
return guarded(this.context, 'social drafts why', async () => {
|
|
85
|
+
const out = say(this.context)
|
|
86
|
+
const { houseRepoRoots } = await import('../social/house.ts')
|
|
87
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
88
|
+
const { groupsNow } = await import('../social/post-sources.ts')
|
|
89
|
+
const { eventsRepo } = await import('../review/events.ts')
|
|
90
|
+
const { storeDir } = await import('../review/store.ts')
|
|
91
|
+
const roots = this.all ? (await houseRepoRoots(process.cwd())).map((r) => r.path) : [findRepoRoot(process.cwd())]
|
|
92
|
+
const seen = new Set<string>()
|
|
93
|
+
let n = 0
|
|
94
|
+
for (const root of roots) {
|
|
95
|
+
const repo = eventsRepo(storeDir(root))
|
|
96
|
+
if (seen.has(repo)) continue
|
|
97
|
+
seen.add(repo)
|
|
98
|
+
for (const g of groupsNow(repo))
|
|
99
|
+
if (g.group.meta['kind'] === 'custom') {
|
|
100
|
+
out(`${repo} ${g.group.slug}: ${g.group.meta['kindWhy'] ?? '(no kindWhy)'}`)
|
|
101
|
+
n++
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (n === 0) out('no custom post group')
|
|
105
|
+
return 0
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const VERBS = ['show', 'save', 'text', 'article', 'media', 'posted', 'clear', 'drop', 'undrop', 'discard', 'restore', 'thread'] as const
|
|
111
|
+
|
|
112
|
+
class SocialDraftCommand extends Command {
|
|
113
|
+
static override paths = [['social', 'draft']]
|
|
114
|
+
static override usage = Command.Usage({
|
|
115
|
+
category: 'Social',
|
|
116
|
+
description: 'one act on a post group or a post: its text, files, posted, dropped, thread',
|
|
117
|
+
details:
|
|
118
|
+
"show prints the group's text form (front matter, angle, one heading a post, the posted links). save <file|-> writes a text back: words, options, facts and angle, a new heading a new post (a group heading, one post per account it reaches); a new topic makes a new group, linked into the thread your lane holds, else one opened on it; --media <name>=<file> adds a file under that name. text <key> <file|-> rewrites one post's words, a new version of it. article <file|-|none> writes its long devlog post. media <file> --name <name> adds or replaces a file of the group. posted <key> <url> is his word that the post is posted there (checked against the account's hosts), clear <key> takes the link back. drop <key> and undrop <key>: he will not post it there, or will. discard drops each post still in draft, restore takes back what a discard dropped. thread prints the thread opened on the group, made when none is. A post's state moves only by these verbs. Page: wiki tools/shipkit/social.md, The verbs, the thread's block, the import",
|
|
119
|
+
examples: [
|
|
120
|
+
['its text', 'sk social draft show arena-face-lift'],
|
|
121
|
+
['a new group from a text', 'sk social draft save arena-crowns draft.md --media media/crowns.png=out/crowns.png'],
|
|
122
|
+
["one post's words", 'sk social draft text arena-face-lift bluesky - <<< "The arena, at dusk."'],
|
|
123
|
+
['he says it is posted', 'sk social draft posted arena-face-lift x https://x.com/somestudio/status/1'],
|
|
124
|
+
['not on Bluesky', 'sk social draft drop arena-face-lift bluesky'],
|
|
125
|
+
],
|
|
126
|
+
})
|
|
127
|
+
verb = Option.String({ required: true })
|
|
128
|
+
draft = Option.String({ required: true })
|
|
129
|
+
rest = Option.Rest()
|
|
130
|
+
media = Option.Array('--media', { description: 'save: <name>=<file>, a file kept under that name' })
|
|
131
|
+
name = Option.String('--name', { description: 'media: the name the posts give the file (media/<file> by default)' })
|
|
132
|
+
force = Option.Boolean('--force', false, { description: 'save: write though the builder names a problem' })
|
|
133
|
+
override async execute(): Promise<number> {
|
|
134
|
+
return guarded(this.context, `social draft ${this.verb}`, async () => {
|
|
135
|
+
const out = say(this.context)
|
|
136
|
+
if (!(VERBS as readonly string[]).includes(this.verb)) throw new Error(`${this.verb}: one of ${VERBS.join(', ')}`)
|
|
137
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
138
|
+
const { resolve, basename } = await import('node:path')
|
|
139
|
+
const root = findRepoRoot(process.cwd())
|
|
140
|
+
if (this.verb === 'show') {
|
|
141
|
+
const { showText } = await import('../social/post-text.ts')
|
|
142
|
+
this.context.stdout.write(showText(root, this.draft))
|
|
143
|
+
return 0
|
|
144
|
+
}
|
|
145
|
+
if (this.verb === 'save') {
|
|
146
|
+
const { saveText } = await import('../social/post-text.ts')
|
|
147
|
+
const { contextOf } = await import('../social/stage.ts')
|
|
148
|
+
const from = this.rest[0]
|
|
149
|
+
if (from == null) throw new Error('save <draft|topic> <file|->')
|
|
150
|
+
const files = (this.media ?? []).map((m) => {
|
|
151
|
+
const i = m.indexOf('=')
|
|
152
|
+
if (i < 1) throw new Error(`--media ${m}: <name>=<file>`)
|
|
153
|
+
return { name: m.slice(0, i), file: resolve(process.cwd(), m.slice(i + 1)) }
|
|
154
|
+
})
|
|
155
|
+
const r = await saveText(root, this.draft, await textOf(from), files, await contextOf(root, {}), { sender: sender(), force: this.force })
|
|
156
|
+
out(`${r.slug}: ${r.created ? 'made' : 'saved'}; ${r.group ? 'its facts moved' : 'its facts as they were'}; ${r.posts.length} post${r.posts.length === 1 ? '' : 's'} written${r.posts.length ? ` (${r.posts.join(', ')})` : ''}`)
|
|
157
|
+
for (const t of r.threads) out(` referred to by the thread ${t}`)
|
|
158
|
+
for (const e of r.errors) out(` WARN ${e}`)
|
|
159
|
+
return 0
|
|
160
|
+
}
|
|
161
|
+
const { openDesk } = await import('../social/open.ts')
|
|
162
|
+
const { findDraft } = await import('../social/load.ts')
|
|
163
|
+
const { desk } = await openDesk(root)
|
|
164
|
+
const d = findDraft(desk, this.draft)
|
|
165
|
+
const posts = await import('../social/posts.ts')
|
|
166
|
+
const [key, arg] = this.rest
|
|
167
|
+
if (this.verb === 'thread') {
|
|
168
|
+
out(`${d.slug}: sk thread show ${await posts.groupThread(root, d.slug, d.title, process.env.SK_AGENT ? { lane: process.env.SK_AGENT } : {})}`)
|
|
169
|
+
return 0
|
|
170
|
+
}
|
|
171
|
+
if (this.verb === 'text') {
|
|
172
|
+
if (key == null || arg == null) throw new Error('text <draft> <key> <file|->')
|
|
173
|
+
out(posts.setPostText(root, d.slug, key, await textOf(arg), { sender: sender() }) ? `${d.slug} ${key}: a new version of its words` : `${d.slug} ${key}: its words as they were`)
|
|
174
|
+
return 0
|
|
175
|
+
}
|
|
176
|
+
if (this.verb === 'article') {
|
|
177
|
+
if (key == null) throw new Error('article <draft> <file|-|none>: its long devlog post, front matter and markdown')
|
|
178
|
+
await posts.setGroup(root, d.slug, { article: key === 'none' ? null : await textOf(key) }, { why: 'article', sender: sender() })
|
|
179
|
+
out(`${d.slug}: ${key === 'none' ? 'holds no article' : 'its article written'}`)
|
|
180
|
+
return 0
|
|
181
|
+
}
|
|
182
|
+
if (this.verb === 'media') {
|
|
183
|
+
if (key == null) throw new Error('media <draft> <file> [--name <name>]')
|
|
184
|
+
const name = this.name ?? `media/${basename(key)}`
|
|
185
|
+
await posts.setGroup(root, d.slug, { files: [{ file: resolve(process.cwd(), key), name }] }, { why: 'media', sender: sender() })
|
|
186
|
+
out(`${d.slug}: holds ${name}`)
|
|
187
|
+
return 0
|
|
188
|
+
}
|
|
189
|
+
if (this.verb === 'posted' || this.verb === 'clear') {
|
|
190
|
+
if (key == null || (this.verb === 'posted' && arg == null)) throw new Error(`${this.verb} <draft> <key>${this.verb === 'posted' ? ' <url>' : ''}`)
|
|
191
|
+
posts.setPosted(desk, d.slug, key, this.verb === 'posted' ? arg! : null, { sender: sender() })
|
|
192
|
+
} else posts.postVerb(root, d.slug, this.verb as (typeof posts.POST_VERBS)[number], key, sender())
|
|
193
|
+
const g = posts.postsIndex(root).find((x) => x.slug === d.slug)
|
|
194
|
+
out(`${d.slug}: ${g?.drafts ?? 0} in draft, ${g?.posted ?? 0} posted, ${g?.dropped ?? 0} dropped`)
|
|
195
|
+
return 0
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
class ThreadEventsCommand extends Command {
|
|
201
|
+
static override paths = [['thread', 'events']]
|
|
202
|
+
static override usage = Command.Usage({
|
|
203
|
+
category: 'Review',
|
|
204
|
+
description: "the threads' events: how many, and the projections checked against them or rebuilt",
|
|
205
|
+
details: 'With no flag: the events by type, the post groups and the posts by state. --check folds every event again in memory and compares each projection row with it (a drift names the row, exit 1); --rebuild writes every projection again from the events in one transaction. Page: wiki tools/shipkit/threads-events.md',
|
|
206
|
+
examples: [
|
|
207
|
+
['where they stand', 'sk thread events'],
|
|
208
|
+
['the projections against the events', 'sk thread events --check'],
|
|
209
|
+
],
|
|
210
|
+
})
|
|
211
|
+
check = Option.Boolean('--check', false, { description: 'compare each projection with its events' })
|
|
212
|
+
rebuild = Option.Boolean('--rebuild', false, { description: 'write every projection again from the events' })
|
|
213
|
+
override async execute(): Promise<number> {
|
|
214
|
+
return guarded(this.context, 'thread events', async () => {
|
|
215
|
+
const out = say(this.context)
|
|
216
|
+
const { cardsDb } = await import('../review/card-db.ts')
|
|
217
|
+
const { projectionDrift, rebuildProjections } = await import('../review/projections.ts')
|
|
218
|
+
const db = cardsDb()
|
|
219
|
+
if (this.rebuild) {
|
|
220
|
+
const r = rebuildProjections(db)
|
|
221
|
+
out(`rebuilt: ${r.groups} groups, ${r.posts} posts`)
|
|
222
|
+
}
|
|
223
|
+
for (const r of db.query('select type, count(*) as n from thread_events group by type order by type').all() as { type: string; n: number }[]) out(`${r.type}: ${r.n} events`)
|
|
224
|
+
out(`post groups: ${(db.query('select count(*) as n from thread_post_groups').get() as { n: number }).n}`)
|
|
225
|
+
for (const r of db.query('select state, count(*) as n from thread_posts group by state order by state').all() as { state: string; n: number }[]) out(`posts ${r.state}: ${r.n}`)
|
|
226
|
+
if (!this.check) return 0
|
|
227
|
+
const drift = projectionDrift(db)
|
|
228
|
+
for (const d of drift.slice(0, 20)) out(`DRIFT ${d}`)
|
|
229
|
+
out(drift.length === 0 ? 'ok: every projection is what its events make' : `FAIL: ${drift.length} rows drift: sk thread events --rebuild`)
|
|
230
|
+
return drift.length === 0 ? 0 : 1
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export const SOCIAL_DRAFT_COMMANDS = [SocialDraftsImportCommand, SocialDraftsWhyCommand, SocialDraftCommand, ThreadEventsCommand]
|
package/src/cli/cmd_Sound.ts
CHANGED
|
@@ -219,4 +219,25 @@ export class SoundGmCommand extends Command {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
export
|
|
222
|
+
export class SoundCreditsCommand extends Command {
|
|
223
|
+
static override paths = [['sound', 'credits']]
|
|
224
|
+
static override usage = Command.Usage({
|
|
225
|
+
category: 'Sound',
|
|
226
|
+
description: 'the ElevenLabs characters left this period, or why the key is refused: free',
|
|
227
|
+
details: `one GET /v1/user/subscription. The key: ELEVENLABS_API_KEY, else the brand's trailer.elevenKey, else the house secret rv/elevenlabs/api-key, read in the process and never printed. A key without the « User: Access » permission is refused, and the line names it. ${PAGE}`,
|
|
228
|
+
examples: [['what is left', 'sk sound credits']],
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
execute(): Promise<number> {
|
|
232
|
+
return run(this.context, async (say, root) => {
|
|
233
|
+
const [{ elevenAccount, elevenKey, creditsLine, ELEVEN_SECRET }, { readSecretValue }] = await Promise.all([import('../trailer/sound/eleven.ts'), import('../secrets/read.ts')])
|
|
234
|
+
const argv = (await brandSound(root))?.elevenKey
|
|
235
|
+
const key = (process.env.ELEVENLABS_API_KEY?.trim() || argv?.length) ? elevenKey(argv) : await readSecretValue(ELEVEN_SECRET, 'get', root)
|
|
236
|
+
const a = await elevenAccount(key)
|
|
237
|
+
if (!a.ok) throw new Error(creditsLine(a))
|
|
238
|
+
say(creditsLine(a))
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export const SOUND_COMMANDS = [SoundVoiceCommand, SoundSfxCommand, SoundMusicCommand, SoundMidiCommand, SoundMeasureCommand, SoundGmCommand, SoundCreditsCommand]
|
package/src/cli/cmd_Start.ts
CHANGED
|
@@ -5,13 +5,14 @@ import { Command, Option } from 'clipanion'
|
|
|
5
5
|
|
|
6
6
|
export class StartCommand extends Command {
|
|
7
7
|
static override paths = [['start']]
|
|
8
|
+
static gloss = 'a new repo in ~/dev, on GitHub'
|
|
8
9
|
|
|
9
10
|
static override usage = Command.Usage({
|
|
10
11
|
category: 'Setup',
|
|
11
12
|
description: 'create or enter ~/dev/<name>, ready to work in: a private github repo and a push unless --no-github',
|
|
12
|
-
details: 'create (or enter) ~/dev/<name> from ANY cwd, READY to work in. On any dir with no commit history it writes the day-one shape (package.json + src/index.ts + the project CLI on the kit (src/cli.ts, src/cli/cmd_Dev.ts, the cli script and a bin of the repo name) + lint/fmt/typecheck, tsconfig, .vscode tasks + settings, the verify skill, an agent/ wiki, .shipkit/reflections), installs the toolchain, wires shipkit (repo.config.ts via init), and runs the whole bootstrap chain: git init, first commit, PRIVATE github repo, push. Loose files ride in that first commit, and only a repo with real history is left as it is. Writes are create-only for files, additive for package.json scripts and .gitignore. CLAUDE.md is the
|
|
13
|
+
details: 'create (or enter) ~/dev/<name> from ANY cwd, READY to work in. On any dir with no commit history it writes the day-one shape (package.json + src/index.ts + the project CLI on the kit (src/cli.ts, src/cli/cmd_Dev.ts, the cli script and a bin of the repo name) + lint/fmt/typecheck, tsconfig, .vscode tasks + settings, the verify skill, an agent/ wiki, .shipkit/reflections), installs the toolchain, wires shipkit (repo.config.ts via init), and runs the whole bootstrap chain: git init, first commit, PRIVATE github repo, push. Loose files ride in that first commit, and only a repo with real history is left as it is. Writes are create-only for files, additive for package.json scripts and .gitignore. CLAUDE.md is the house template on its own (its identity line comes at the first gate, SK003) (HOUSE_INCLUDE in src/start-repo.ts: the base wiki include, then `@./agent/index.md`, and --include overrides it), applied only on a machine where the house index exists, and the agent route lands last whenever the repo has agent/index.md. The house lines also opt the repo into the .claude/ policy files (a pre-approved shell allowlist + the attribution silencer), so a start with no house widens no agent permissions. Prints the dir on stdout so a shell alias can cd there. cwd-only sibling: `shipkit init`',
|
|
13
14
|
examples: [
|
|
14
|
-
['create or enter ~/dev/pong: dir, package.json, shipkit wiring, git, first commit, private github repo, push, the
|
|
15
|
+
['create or enter ~/dev/pong: dir, package.json, shipkit wiring, git, first commit, private github repo, push, the CLAUDE.md include lines', 'sk start pong'],
|
|
15
16
|
['another house: replace the include lines', "sk start pong --include '@~/wiki/index.md' --include '@./agent/index.md'"],
|
|
16
17
|
['adopt a pre-existing repo from anywhere', 'sk start my-old-project'],
|
|
17
18
|
['force the private github repo for a folder that was already there', 'sk start old-notes --github'],
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// `sk thread holds`: every object that holds a thread of this repo open, checked now (wiki
|
|
2
|
+
// tools/shipkit/threads-how-it-fits.md, The model). The hub runs the same pass once a minute; a flip writes the
|
|
3
|
+
// machine's message in its thread, so a re-run on unmoved objects writes nothing
|
|
4
|
+
import { Command } from 'clipanion'
|
|
5
|
+
|
|
6
|
+
export class ThreadHoldsCommand extends Command {
|
|
7
|
+
static override paths = [['thread', 'holds']]
|
|
8
|
+
static override usage = Command.Usage({
|
|
9
|
+
category: 'Review',
|
|
10
|
+
description: 'every object that holds a thread of this repo open (a branch until merged), checked now',
|
|
11
|
+
details: 'An object whose kind declares holdsOpen, attached to a thread (sk thread attach <address> branch:<repo>/<name>), holds it open until its condition is met: a branch until merged into its release branch, read from local refs, never a fetch. This checks each one now and prints each thread it holds; a hold that flipped writes its line in the thread. Page: wiki tools/shipkit/threads-how-it-fits.md, The model',
|
|
12
|
+
examples: [['check the holds of this repo now', 'sk thread holds']],
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
async execute(): Promise<number> {
|
|
16
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
17
|
+
const { syncHolds } = await import('../review/holds-sync.ts')
|
|
18
|
+
const { holdsOf } = await import('../review/holds.ts')
|
|
19
|
+
const { readAll, specOf, storeDir } = await import('../review/store.ts')
|
|
20
|
+
const { membersOf, threadTitle, threadsOf } = await import('../review/threads.ts')
|
|
21
|
+
const root = findRepoRoot(process.cwd())
|
|
22
|
+
const s = await syncHolds(root)
|
|
23
|
+
const dir = storeDir(root)
|
|
24
|
+
const spec = specOf(dir)
|
|
25
|
+
let n = 0
|
|
26
|
+
for (const t of threadsOf(readAll(dir).items, spec))
|
|
27
|
+
for (const h of holdsOf(membersOf(t), spec).filter((x) => x.held)) {
|
|
28
|
+
n++
|
|
29
|
+
this.context.stdout.write(`held: ${threadTitle(t)} (${t.head.item.id}): ${h.words}\n`)
|
|
30
|
+
}
|
|
31
|
+
this.context.stdout.write(`ok: ${s.checked} checked, ${s.flipped} flipped, ${n} still holding\n`)
|
|
32
|
+
return 0
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// `sk thread kinds`: the kinds a thread's address may name in this repo, the repo's own then the house's, each with its
|
|
2
|
+
// key's shape and what it declares (wiki tools/shipkit/threads-how-it-fits.md, Kinds). The one place an agent reads
|
|
3
|
+
// which word to type, so one subject never becomes two threads under two words
|
|
4
|
+
import { Command, Option } from 'clipanion'
|
|
5
|
+
|
|
6
|
+
export class ThreadKindsCommand extends Command {
|
|
7
|
+
static override paths = [['thread', 'kinds']]
|
|
8
|
+
static override usage = Command.Usage({
|
|
9
|
+
category: 'Review',
|
|
10
|
+
description: "the kinds an address may name here, each with its key's shape, the repo's own first",
|
|
11
|
+
details: 'An address is <kind>:<key>. The repo declares its own kinds in its review({ kinds }) unit; the house kinds (screen, asset, file, page…) exist in every repo. An agent writes no other word: post, ask, propose and attach refuse it. --values lists the kinds a field of a proposed change holds (--type). Page: wiki tools/shipkit/threads-how-it-fits.md, Kinds',
|
|
12
|
+
examples: [
|
|
13
|
+
['which word for my object', 'sk thread kinds'],
|
|
14
|
+
['as json', 'sk thread kinds --json'],
|
|
15
|
+
['the house catalog, for the page every session loads', 'sk thread kinds --out wiki/tools/shipkit/thread-kinds.md'],
|
|
16
|
+
['every object with its icon, the page read on demand', 'sk thread kinds --objects wiki/tools/shipkit/thread-objects.md'],
|
|
17
|
+
],
|
|
18
|
+
})
|
|
19
|
+
json = Option.Boolean('--json', false, { description: 'one json object: the address kinds and the value kinds' })
|
|
20
|
+
values = Option.Boolean('--values', false, { description: 'the value kinds a field of a proposed change holds' })
|
|
21
|
+
out = Option.String('--out', { description: 'a page with the shipkit:thread-kinds markers: the house catalog (every kind, its widget, one command) is rewritten between them' })
|
|
22
|
+
objects = Option.String('--objects', { description: 'a page with the shipkit:thread-objects markers: every kind, value kind and message type as a table with its icon in its colour, rewritten between them; the icons as SVG files in references/<page name>/ beside it' })
|
|
23
|
+
check = Option.Boolean('--check', false, { description: 'with --out or --objects: exit 1 when a page or an icon is stale or a kind has no widget, write nothing' })
|
|
24
|
+
|
|
25
|
+
async execute(): Promise<number> {
|
|
26
|
+
if (this.out !== undefined || this.objects !== undefined) {
|
|
27
|
+
const a = this.out === undefined ? 0 : await this.catalog(this.out)
|
|
28
|
+
const b = this.objects === undefined ? 0 : await this.objectsPage(this.objects)
|
|
29
|
+
return Math.max(a, b)
|
|
30
|
+
}
|
|
31
|
+
if (this.check) {
|
|
32
|
+
this.context.stderr.write('FAIL: --check compares a page with the registry: name it with --out <page>\n')
|
|
33
|
+
return 1
|
|
34
|
+
}
|
|
35
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
36
|
+
const { openReview } = await import('../review/project.ts')
|
|
37
|
+
const { specOf } = await import('../review/store.ts')
|
|
38
|
+
const { addressKinds, DIFF_TYPES, HOUSE_KINDS, kindOfValue } = await import('../review/kinds.ts')
|
|
39
|
+
let dir: string
|
|
40
|
+
try {
|
|
41
|
+
dir = (await openReview(findRepoRoot(process.cwd()))).dir
|
|
42
|
+
} catch (e) {
|
|
43
|
+
this.context.stderr.write(`FAIL: review: ${e instanceof Error ? e.message : String(e)}\n`)
|
|
44
|
+
return 1
|
|
45
|
+
}
|
|
46
|
+
const spec = specOf(dir)
|
|
47
|
+
const kinds = addressKinds(spec).map((k) => {
|
|
48
|
+
const d = spec.kinds[k.word] ?? HOUSE_KINDS[k.word]
|
|
49
|
+
const has = [d?.view ? `view ${d.view.page}` : '', d?.diff?.page ? `diff page ${d.diff.page}` : d?.diff?.draw ? `diff ${d.diff.draw}` : '', d?.questions ? `questions ${Object.keys(d.questions).join(' ')}` : '', d?.actions ? `actions ${Object.keys(d.actions).join(' ')}` : '']
|
|
50
|
+
return { ...k, has: has.filter(Boolean) }
|
|
51
|
+
})
|
|
52
|
+
const values = DIFF_TYPES.map((t) => ({ word: t, label: kindOfValue(t).label }))
|
|
53
|
+
if (this.json) {
|
|
54
|
+
this.context.stdout.write(`${JSON.stringify({ kinds, values })}\n`)
|
|
55
|
+
return 0
|
|
56
|
+
}
|
|
57
|
+
const out: string[] = []
|
|
58
|
+
if (this.values) out.push(...values.map((v) => `${v.word.padEnd(8)} ${v.label}`))
|
|
59
|
+
else {
|
|
60
|
+
const w = Math.max(...kinds.map((k) => `${k.word}:${k.address}`.length))
|
|
61
|
+
for (const own of [true, false]) {
|
|
62
|
+
const rows = kinds.filter((k) => k.own === own)
|
|
63
|
+
if (rows.length === 0) continue
|
|
64
|
+
out.push(own ? "this repo's kinds" : 'house kinds')
|
|
65
|
+
for (const k of rows) out.push(` ${`${k.word}:${k.address}`.padEnd(w)} ${k.label}${k.has.length ? ` (${k.has.join(', ')})` : ''}`)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.context.stdout.write(`${out.join('\n')}\n`)
|
|
69
|
+
return 0
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** the house catalog into its page: refused while a kind has no widget */
|
|
73
|
+
private async catalog(page: string): Promise<number> {
|
|
74
|
+
const { existsSync, readFileSync, writeFileSync } = await import('node:fs')
|
|
75
|
+
const { BEGIN, END, catalogProblems, renderCatalog } = await import('../review/kind-catalog.ts')
|
|
76
|
+
const { spliceMarkedBlock } = await import('../core/doc-block.ts')
|
|
77
|
+
const say = (s: string): void => void this.context.stdout.write(`${s}\n`)
|
|
78
|
+
const problems = catalogProblems()
|
|
79
|
+
if (problems.length > 0) {
|
|
80
|
+
say(`FAIL: ${problems.length} kind(s) with no widget, in review/kinds.ts or review/kind-catalog.ts:`)
|
|
81
|
+
for (const p of problems) say(` ${p}`)
|
|
82
|
+
return 1
|
|
83
|
+
}
|
|
84
|
+
if (!existsSync(page)) {
|
|
85
|
+
say(`FAIL: ${page} does not exist`)
|
|
86
|
+
return 1
|
|
87
|
+
}
|
|
88
|
+
const host = readFileSync(page, 'utf8')
|
|
89
|
+
const next = spliceMarkedBlock(host, renderCatalog(), BEGIN, END)
|
|
90
|
+
if (next === null) {
|
|
91
|
+
say(`FAIL: ${page} has no ${BEGIN} / ${END} markers`)
|
|
92
|
+
return 1
|
|
93
|
+
}
|
|
94
|
+
if (next === host) {
|
|
95
|
+
say(`ok: ${page} thread kinds current`)
|
|
96
|
+
return 0
|
|
97
|
+
}
|
|
98
|
+
if (this.check) {
|
|
99
|
+
say(`FAIL: ${page} is STALE: a kind, its widget or its command moved in the registry\n fix: sk thread kinds --out ${page}`)
|
|
100
|
+
return 1
|
|
101
|
+
}
|
|
102
|
+
writeFileSync(page, next)
|
|
103
|
+
say(`ok: ${page} thread kinds rewritten`)
|
|
104
|
+
return 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** the objects page and its icons: the table between its markers, one SVG a kind, value kind or message type in the
|
|
108
|
+
* folder named like the page; an icon no row names any more is removed */
|
|
109
|
+
private async objectsPage(page: string): Promise<number> {
|
|
110
|
+
const { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } = await import('node:fs')
|
|
111
|
+
const { basename, dirname, join } = await import('node:path')
|
|
112
|
+
const { OBJECTS_BEGIN, OBJECTS_END, renderObjects } = await import('../review/kind-catalog.ts')
|
|
113
|
+
const { spliceMarkedBlock } = await import('../core/doc-block.ts')
|
|
114
|
+
const say = (s: string): void => void this.context.stdout.write(`${s}\n`)
|
|
115
|
+
if (!existsSync(page)) {
|
|
116
|
+
say(`FAIL: ${page} does not exist`)
|
|
117
|
+
return 1
|
|
118
|
+
}
|
|
119
|
+
const name = basename(page).replace(/\.md$/, '')
|
|
120
|
+
// a topic folder holds its pages and its references/ (RV008): the icons are references of the page
|
|
121
|
+
const dir = join(dirname(page), 'references', name)
|
|
122
|
+
const { md, files } = renderObjects(`references/${name}`)
|
|
123
|
+
const host = readFileSync(page, 'utf8')
|
|
124
|
+
const next = spliceMarkedBlock(host, md, OBJECTS_BEGIN, OBJECTS_END)
|
|
125
|
+
if (next === null) {
|
|
126
|
+
say(`FAIL: ${page} has no ${OBJECTS_BEGIN} / ${OBJECTS_END} markers`)
|
|
127
|
+
return 1
|
|
128
|
+
}
|
|
129
|
+
const had = existsSync(dir) ? readdirSync(dir).filter((f) => f.endsWith('.svg')) : []
|
|
130
|
+
const stale = [...Object.entries(files).filter(([f, svg]) => !had.includes(f) || readFileSync(join(dir, f), 'utf8') !== svg).map(([f]) => f), ...had.filter((f) => files[f] === undefined)]
|
|
131
|
+
if (next === host && stale.length === 0) {
|
|
132
|
+
say(`ok: ${page} thread objects current`)
|
|
133
|
+
return 0
|
|
134
|
+
}
|
|
135
|
+
if (this.check) {
|
|
136
|
+
say(`FAIL: ${page} is STALE: ${next === host ? '' : 'its table, '}${stale.length > 0 ? `${stale.length} icon(s) in ${dir}/` : ''} moved in the registry\n fix: sk thread kinds --objects ${page}`)
|
|
137
|
+
return 1
|
|
138
|
+
}
|
|
139
|
+
mkdirSync(dir, { recursive: true })
|
|
140
|
+
for (const f of had) if (files[f] === undefined) rmSync(join(dir, f))
|
|
141
|
+
for (const [f, svg] of Object.entries(files)) writeFileSync(join(dir, f), svg)
|
|
142
|
+
if (next !== host) writeFileSync(page, next)
|
|
143
|
+
say(`ok: ${page} thread objects rewritten, ${Object.keys(files).length} icons in ${dir}/`)
|
|
144
|
+
return 0
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// `sk thread reflect` and `sk thread fold-reflections`: a reflection is an object, never a thread of its own (wiki
|
|
2
|
+
// tools/shipkit/threads-how-it-fits.md, The model). The first writes one and links it into the thread the agent holds,
|
|
3
|
+
// in one call; the second folds the reflection threads the machine opened before, re-runnable
|
|
4
|
+
import { Command, Option } from 'clipanion'
|
|
5
|
+
|
|
6
|
+
export class ThreadReflectCommand extends Command {
|
|
7
|
+
static override paths = [['thread', 'reflect']]
|
|
8
|
+
static override usage = Command.Usage({
|
|
9
|
+
category: 'Review',
|
|
10
|
+
description: 'log friction with the house system: a reflection file, linked into the thread you hold',
|
|
11
|
+
details:
|
|
12
|
+
"Writes .shipkit/reflections/<YYYYMMDD>-<slug>.md (the slug from the title; never over an existing file) and links reflection:<repo>/<file> into the thread you hold in this repo (your lane's by SK_AGENT, else your session's), or the one --in names. He sees it there as a box with accept, ask to rework, discard, and on the repo's reflections page. Holding none, it shows on that page alone. --body - reads stdin. A body with no heading gets the title as its heading. Page: wiki tools/shipkit/threads-how-it-fits.md, The model",
|
|
13
|
+
examples: [
|
|
14
|
+
['a note from a file', 'sk thread reflect "the guard refuses a monitor" --body note.md'],
|
|
15
|
+
['from stdin, into a named thread', 'sk thread reflect "the gate cries wolf" --body - --in page:threads/richer'],
|
|
16
|
+
],
|
|
17
|
+
})
|
|
18
|
+
title = Option.String()
|
|
19
|
+
body = Option.String('--body', { required: true, description: 'the markdown: a file, or - for stdin' })
|
|
20
|
+
into = Option.String('--in', { description: 'the thread to link it into, by its address or an item id (else the one you hold)' })
|
|
21
|
+
|
|
22
|
+
async execute(): Promise<number> {
|
|
23
|
+
const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
24
|
+
try {
|
|
25
|
+
const { readFileSync } = await import('fs')
|
|
26
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
27
|
+
const { loadRepoConfig } = await import('../repo-config.ts')
|
|
28
|
+
const { writeReflection } = await import('../review/reflection-object.ts')
|
|
29
|
+
const root = findRepoRoot(process.cwd())
|
|
30
|
+
const repo = (await loadRepoConfig(root)).name
|
|
31
|
+
const body = this.body === '-' ? await new Response(Bun.stdin.stream()).text() : readFileSync(this.body, 'utf8')
|
|
32
|
+
let into: string | undefined
|
|
33
|
+
if (this.into !== undefined) {
|
|
34
|
+
const { readAll, specOf, storeDir } = await import('../review/store.ts')
|
|
35
|
+
const { threadOfAddress } = await import('../review/threads.ts')
|
|
36
|
+
const dir = storeDir(root)
|
|
37
|
+
const t = threadOfAddress(this.into, readAll(dir).items, specOf(dir))
|
|
38
|
+
into = t?.head.item.id ?? this.into
|
|
39
|
+
}
|
|
40
|
+
const w = writeReflection(root, repo, { title: this.title, body, ...(into !== undefined ? { into } : {}) })
|
|
41
|
+
out(`ok: .shipkit/reflections/${w.file} written, ${w.address}`)
|
|
42
|
+
out(w.linked === null ? 'note: you hold no thread here, so it shows on the reflections page alone (--in <thread> links it)' : `ok: linked into ${w.linked}: the owner sees it there with accept, ask to rework, discard`)
|
|
43
|
+
return 0
|
|
44
|
+
} catch (e) {
|
|
45
|
+
this.context.stderr.write(`FAIL: reflect: ${(e as Error).message}\n`)
|
|
46
|
+
return 1
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class ThreadFoldReflectionsCommand extends Command {
|
|
52
|
+
static override paths = [['thread', 'fold-reflections']]
|
|
53
|
+
static override usage = Command.Usage({
|
|
54
|
+
category: 'Review',
|
|
55
|
+
description: 'the reflection threads the machine opened, folded into their objects; a look unless --go',
|
|
56
|
+
details:
|
|
57
|
+
"A reflection is an object read from its file; a thread opens on it only when someone discusses it. Each reflection:<repo>/<file> thread with none of the owner's words or acts (a read mark is no act) gets a machine fixed, « folded into its object »: done, kept, never deleted. One where the owner spoke or acted stays, referring to the object. Re-runnable: a folded one is counted, never written again. Run sk backup and sk backup pin first. Page: wiki tools/shipkit/threads-how-it-fits.md, The model",
|
|
58
|
+
examples: [
|
|
59
|
+
['what it would fold in every house store', 'sk thread fold-reflections --all'],
|
|
60
|
+
['fold them', 'sk thread fold-reflections --all --go'],
|
|
61
|
+
],
|
|
62
|
+
})
|
|
63
|
+
go = Option.Boolean('--go', false, { description: 'write the folds' })
|
|
64
|
+
all = Option.Boolean('--all', false, { description: 'every house store of this machine, not only this repo' })
|
|
65
|
+
|
|
66
|
+
async execute(): Promise<number> {
|
|
67
|
+
const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
68
|
+
const { homedir } = await import('os')
|
|
69
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
70
|
+
const { houseRepos } = await import('../serve/project-gutter.ts')
|
|
71
|
+
const { foldReflectionThreads } = await import('../review/reflection-object.ts')
|
|
72
|
+
const root = findRepoRoot(process.cwd())
|
|
73
|
+
const stores = this.all ? houseRepos(root, homedir()).repos.map((r) => ({ name: r.name, path: r.path })) : [{ name: root.split('/').at(-1) ?? root, path: root }]
|
|
74
|
+
const total = { threads: 0, folded: 0, kept: 0, already: 0 }
|
|
75
|
+
for (const s of stores) {
|
|
76
|
+
const f = await foldReflectionThreads(s.path, { go: this.go })
|
|
77
|
+
for (const k of Object.keys(total) as (keyof typeof total)[]) total[k] += f[k]
|
|
78
|
+
if (f.threads > 0) out(`${s.name}: ${f.threads} reflection threads: ${f.folded} ${this.go ? 'folded' : 'to fold'}, ${f.kept} kept (the owner's words or acts), ${f.already} folded already`)
|
|
79
|
+
}
|
|
80
|
+
out(`${this.go ? 'ok' : 'look'}: ${stores.length} stores, ${total.threads} reflection threads: ${total.folded} ${this.go ? 'folded' : 'to fold (--go)'}, ${total.kept} kept, ${total.already} folded already`)
|
|
81
|
+
return 0
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// `sk thread sync-needs`: the checks' threads of every house repo made to match its hub's needs now,
|
|
2
|
+
// the same pass the hub runs with its ping (wiki tools/shipkit/threads-how-it-fits.md, The model). Re-runnable: what
|
|
3
|
+
// already stands writes nothing. It reads the needs from the home, so a repo whose hub is down is named and skipped
|
|
4
|
+
import { Command, Option } from 'clipanion'
|
|
5
|
+
|
|
6
|
+
export class ThreadSyncNeedsCommand extends Command {
|
|
7
|
+
static override paths = [['thread', 'sync-needs']]
|
|
8
|
+
static override usage = Command.Usage({
|
|
9
|
+
category: 'Review',
|
|
10
|
+
description: "the checks' threads of every house repo, made to match its hub's needs now",
|
|
11
|
+
details: "One thread per check that fails or warns (check:<repo>/<id>), written by the machine: nobody holds it, it is an agent's move, waiting for an agent until one takes it, and a need gone writes fixed. A reflection opens no thread: it is an object its repo's reflections page lists, and a thread opened on one is fixed once its file is gone. The hub runs the same pass once a minute; this runs it now, re-runnable, and prints each repo's threads by who acts now before and after. Page: wiki tools/shipkit/threads-how-it-fits.md, The model",
|
|
12
|
+
examples: [['every house repo', 'sk thread sync-needs'], ['one repo', 'sk thread sync-needs --repo orchard']],
|
|
13
|
+
})
|
|
14
|
+
repo = Option.Array('--repo', [], { description: 'only these repos (else every repo the home serves)' })
|
|
15
|
+
|
|
16
|
+
async execute(): Promise<number> {
|
|
17
|
+
const { homePort } = await import('../home/home-paths.ts')
|
|
18
|
+
const { syncNeedThreads } = await import('../review/need-threads.ts')
|
|
19
|
+
const { NEED_KINDS } = await import('../review/need-address.ts')
|
|
20
|
+
const { readAll, storeDir } = await import('../review/store.ts')
|
|
21
|
+
const { orderedThreads, turnOf } = await import('../review/threads.ts')
|
|
22
|
+
const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
23
|
+
const home = `http://127.0.0.1:${homePort()}`
|
|
24
|
+
const get = async <T>(path: string): Promise<T> => {
|
|
25
|
+
const r = await fetch(`${home}${path}`, { signal: AbortSignal.timeout(60_000) })
|
|
26
|
+
if (!r.ok) throw new Error(`${path}: ${r.status} ${(await r.text()).slice(0, 120)}`)
|
|
27
|
+
return (await r.json()) as T
|
|
28
|
+
}
|
|
29
|
+
let repos: string[]
|
|
30
|
+
try {
|
|
31
|
+
repos = (await get<{ repos: string[] }>('/api/home/repos.json')).repos
|
|
32
|
+
} catch (e) {
|
|
33
|
+
this.context.stderr.write(`FAIL: the home does not answer at ${home} (${(e as Error).message}): sk pm status\n`)
|
|
34
|
+
return 1
|
|
35
|
+
}
|
|
36
|
+
if (this.repo.length > 0) repos = repos.filter((r) => this.repo.includes(r))
|
|
37
|
+
const kinds = Object.values(NEED_KINDS).map((k) => `${k}:`)
|
|
38
|
+
const turns = (root: string): string => {
|
|
39
|
+
const by: Record<string, number> = {}
|
|
40
|
+
for (const t of orderedThreads(readAll(storeDir(root)).items)) if (kinds.some((k) => t.head.item.on?.startsWith(k))) by[turnOf(t)] = (by[turnOf(t)] ?? 0) + 1
|
|
41
|
+
return Object.entries(by).map(([k, n]) => `${n} ${k}`).join(', ') || 'none'
|
|
42
|
+
}
|
|
43
|
+
let failed = 0
|
|
44
|
+
const total = { opened: 0, broken: 0, fixed: 0, same: 0 }
|
|
45
|
+
for (const repo of repos) {
|
|
46
|
+
const base = `/r/${encodeURIComponent(repo)}`
|
|
47
|
+
try {
|
|
48
|
+
const { root } = await get<{ root: string }>(`${base}/hub.json`)
|
|
49
|
+
const { needs } = await get<{ needs: Parameters<typeof syncNeedThreads>[2] }>(`${base}/api/needs.json`)
|
|
50
|
+
const before = turns(root)
|
|
51
|
+
const s = await syncNeedThreads(root, repo, needs)
|
|
52
|
+
for (const k of Object.keys(total) as (keyof typeof total)[]) total[k] += s[k]
|
|
53
|
+
out(`ok: ${repo}: ${s.opened} opened, ${s.broken} broken again, ${s.fixed} fixed, ${s.same} as they were; threads before: ${before}; after: ${turns(root)}`)
|
|
54
|
+
} catch (e) {
|
|
55
|
+
failed++
|
|
56
|
+
out(`WARN ${repo}: not synced: ${(e as Error).message}`)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
out(`${failed === 0 ? 'ok' : 'WARN'}: ${repos.length - failed} of ${repos.length} repos: ${total.opened} opened, ${total.broken} broken again, ${total.fixed} fixed, ${total.same} as they were`)
|
|
60
|
+
return failed === 0 ? 0 : 1
|
|
61
|
+
}
|
|
62
|
+
}
|
package/src/cli/cmd_Vault.ts
CHANGED
|
@@ -259,7 +259,7 @@ async function placedHere(): Promise<{ placed: Placed[]; minter: VaultApi; url:
|
|
|
259
259
|
const minter = minterOf(vaultPlace())
|
|
260
260
|
if (minter == null) return { refused: 'this machine holds no minter token: its vault is not initialised here (sk vault status)' }
|
|
261
261
|
const w = await secretsWhere(process.cwd())
|
|
262
|
-
const rows = (w.house?.creds ?? []).map((c) => ({ name: c.name, for: c.for }))
|
|
262
|
+
const rows = (w.house?.creds ?? []).map((c) => ({ name: c.name, for: c.for, ...(c.archived != null ? { archived: c.archived } : {}) }))
|
|
263
263
|
const placed = await placeNames({ rows, held: keychainReader().names(), keyOf: keyOfFrom(await houseKeys(root)) })
|
|
264
264
|
return { placed, minter, url: vaultUrl(vaultPlace()) }
|
|
265
265
|
}
|