@joiner-platform/cli 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/bundled-resources/poe-tile-templates/base/CLAUDE.md +72 -0
- package/bundled-resources/poe-tile-templates/base/README.md +7 -0
- package/bundled-resources/poe-tile-templates/base/_bunfig.toml +8 -0
- package/bundled-resources/poe-tile-templates/base/_gitignore +18 -0
- package/bundled-resources/poe-tile-templates/base/client.ts +12 -0
- package/bundled-resources/poe-tile-templates/base/package.json +36 -0
- package/bundled-resources/poe-tile-templates/base/playwright.config.ts +38 -0
- package/bundled-resources/poe-tile-templates/base/scripts/check-source.ts +148 -0
- package/bundled-resources/poe-tile-templates/base/scripts/dev.ts +19 -0
- package/bundled-resources/poe-tile-templates/base/scripts/doctor.sh +29 -0
- package/bundled-resources/poe-tile-templates/base/scripts/visual-check.ts +64 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/backend-config.ts +9 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/client-config.ts +8 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/data/items.ts +16 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/index.ts +10 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/remove-todo.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/set-todo.ts +20 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/types.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators.test.ts +138 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/schema.ts +40 -0
- package/bundled-resources/poe-tile-templates/base/tests/e2e.test.playwright.ts +92 -0
- package/bundled-resources/poe-tile-templates/base/tests/mobile-viewport.test.playwright.ts +111 -0
- package/bundled-resources/poe-tile-templates/base/tests/render-check.test.playwright.ts +128 -0
- package/bundled-resources/poe-tile-templates/base/tests/screenshot.test.playwright.ts +86 -0
- package/bundled-resources/poe-tile-templates/base/tests/setup-dom.ts +70 -0
- package/bundled-resources/poe-tile-templates/base/tile/src/backend.ts +3 -0
- package/bundled-resources/poe-tile-templates/base/tile/styles.css +47 -0
- package/bundled-resources/poe-tile-templates/base/tsconfig.json +13 -0
- package/bundled-resources/poe-tile-templates/coverage.config.json +6 -0
- package/bundled-resources/poe-tile-templates/index.ts +27 -0
- package/bundled-resources/poe-tile-templates/package.json +31 -0
- package/bundled-resources/poe-tile-templates/phaserjs/package.partial.json +6 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.test.happydom.tsx +98 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.ts +180 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/phaser-scene.ts +174 -0
- package/bundled-resources/poe-tile-templates/phaserjs/vite.config.ts +28 -0
- package/bundled-resources/poe-tile-templates/preact/package.partial.json +9 -0
- package/bundled-resources/poe-tile-templates/preact/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/preact/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/preact/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/preact/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/preact/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.test.happydom.tsx +69 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.tsx +116 -0
- package/bundled-resources/poe-tile-templates/preact/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/react/package.partial.json +12 -0
- package/bundled-resources/poe-tile-templates/react/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/react/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/react/tile/src/entry.tsx +38 -0
- package/bundled-resources/poe-tile-templates/react/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/react/tsconfig.json +14 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.test.happydom.tsx +71 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.tsx +110 -0
- package/bundled-resources/poe-tile-templates/react/vite.config.ts +21 -0
- package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +10 -0
- package/bundled-resources/poe-tile-templates/scripts/generate.ts +57 -0
- package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +52 -0
- package/bundled-resources/poe-tile-templates/scripts/paths.ts +7 -0
- package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +288 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +132 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +30 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +397 -0
- package/bundled-resources/poe-tile-templates/solidjs/_bunfig.toml +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/package.partial.json +13 -0
- package/bundled-resources/poe-tile-templates/solidjs/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/solidjs/tests/solid-plugin.ts +49 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/solidjs/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.test.happydom.tsx +70 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.tsx +129 -0
- package/bundled-resources/poe-tile-templates/solidjs/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +131 -0
- package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +166 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +106 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +103 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +69 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +73 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +54 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +70 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +278 -0
- package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +27 -0
- package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +99 -0
- package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +23 -0
- package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +84 -0
- package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +56 -0
- package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +129 -0
- package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +90 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/package.partial.json +3 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.test.happydom.tsx +96 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.ts +113 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/vite.config.ts +17 -0
- package/cli.ts +134 -0
- package/index.ts +96 -0
- package/package.json +48 -5
- package/skills/audio-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/audio-generation/SKILL.md +125 -0
- package/skills/finish-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/finish-prototype/SKILL.md +22 -0
- package/skills/help-me-build/.generated-by-poe-templated-docs +0 -0
- package/skills/help-me-build/SKILL.md +56 -0
- package/skills/image-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/image-generation/SKILL.md +128 -0
- package/skills/one-shot/.generated-by-poe-templated-docs +0 -0
- package/skills/one-shot/SKILL.md +22 -0
- package/skills/platform-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-prototype/SKILL.md +60 -0
- package/skills/platform-subagent/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-subagent/SKILL.md +16 -0
- package/skills/poe-tiles-cli/.generated-by-poe-templated-docs +0 -0
- package/skills/poe-tiles-cli/SKILL.md +609 -0
- package/skills/poe-tiles-cli/references/device-motion.md +40 -0
- package/skills/poe-tiles-cli/references/player-updates.md +41 -0
- package/skills/prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/prototype/SKILL.md +149 -0
- package/skills/publish/.generated-by-poe-templated-docs +0 -0
- package/skills/publish/SKILL.md +73 -0
- package/skills/synced-store/.generated-by-poe-templated-docs +0 -0
- package/skills/synced-store/SKILL.md +583 -0
- package/skills/synced-store/references/actions.md +85 -0
- package/skills/synced-store/references/api-patterns.md +245 -0
- package/skills/synced-store/references/architecture-scaling-and-performance.md +280 -0
- package/skills/synced-store/references/client-api-reference.md +263 -0
- package/skills/synced-store/references/data-visibility.md +95 -0
- package/skills/synced-store/references/external-stores.md +162 -0
- package/skills/synced-store/references/file-uploads.md +216 -0
- package/skills/synced-store/references/getting-user-info-of-members.md +228 -0
- package/skills/synced-store/references/limitations.md +72 -0
- package/skills/synced-store/references/live-data-limit-hook.md +131 -0
- package/skills/synced-store/references/mutator-rules.md +169 -0
- package/skills/synced-store/references/platform.md +49 -0
- package/skills/synced-store/references/schema-and-bindings.md +85 -0
- package/skills/synced-store/references/schema-libraries.md +57 -0
- package/skills/synced-store/references/schema-migrations.md +119 -0
- package/skills/synced-store/references/searchable-tables.md +27 -0
- package/skills/synced-store/references/server-forking.md +115 -0
- package/skills/synced-store/references/singleton-tables.md +61 -0
- package/skills/synced-store/references/sort-keys.md +253 -0
- package/skills/synced-store/references/ui-patterns.md +95 -0
- package/skills/tile-creator/.generated-by-poe-templated-docs +0 -0
- package/skills/tile-creator/SKILL.md +197 -0
- package/skills/tile-creator/references/assets.md +124 -0
- package/skills/tile-creator/references/backend-api.md +354 -0
- package/skills/tile-creator/references/cli-limitations.md +64 -0
- package/skills/tile-creator/references/cli.md +604 -0
- package/skills/tile-creator/references/client-api.md +2407 -0
- package/skills/tile-creator/references/composing-apps.md +166 -0
- package/skills/tile-creator/references/e2e-tests.md +55 -0
- package/skills/tile-creator/references/game-ux-best-practices.md +57 -0
- package/skills/tile-creator/references/migrating-pre-rename-tiles.md +79 -0
- package/skills/tile-creator/references/multiplayer-api-recipe.md +205 -0
- package/skills/tile-creator/references/native-results.md +100 -0
- package/skills/tile-creator/references/platform-integration.md +201 -0
- package/skills/tile-creator/references/power-report.md +199 -0
- package/skills/tile-creator/references/publish-rollout.md +166 -0
- package/skills/tile-creator/references/publishing.md +33 -0
- package/skills/tile-creator/references/push-notification-guidelines.md +58 -0
- package/skills/tile-creator/references/render-check.md +266 -0
- package/skills/tile-creator/references/running-the-client-api-on-a-server-owned-by-the-user.md +95 -0
- package/skills/tile-creator/references/safe-area-insets.md +79 -0
- package/skills/tile-creator/references/sandbox-limitations.md +32 -0
- package/skills/tile-creator/references/scaffolded-tile-folder-structure.md +48 -0
- package/skills/tile-creator/references/scaffolding-a-new-app.md +202 -0
- package/skills/tile-creator/references/simulations.md +125 -0
- package/skills/tile-creator/references/synced-store-client-reference.md +92 -0
- package/skills/tile-creator/references/troubleshooting.md +22 -0
- package/skills/tile-creator/references/turn-based-mutator.md +43 -0
- package/skills/tile-creator/references/user-erasure.md +14 -0
- package/skills/tile-creator/references/vite-plugin.md +166 -0
- package/skills/tile-creator/references/workspace-retention.md +72 -0
- package/src/admin-conversions-client.ts +28 -0
- package/src/admin-reviews-client.ts +36 -0
- package/src/api.generated.ts +1527 -0
- package/src/auth-token.ts +198 -0
- package/src/bounded-read.ts +35 -0
- package/src/bun-version.ts +33 -0
- package/src/checkout-base.ts +207 -0
- package/src/cli-bun-version.ts +16 -0
- package/src/cli-env.ts +28 -0
- package/src/cli-name.ts +23 -0
- package/src/client.ts +2474 -0
- package/src/collect-files.ts +226 -0
- package/src/commands/accounts.ts +55 -0
- package/src/commands/admin-abandon-conversion.ts +60 -0
- package/src/commands/admin-reviews.ts +66 -0
- package/src/commands/admin.ts +219 -0
- package/src/commands/auth.ts +89 -0
- package/src/commands/checkout-prototype.ts +67 -0
- package/src/commands/creator-source-capability.ts +11 -0
- package/src/commands/doctor-bun.ts +145 -0
- package/src/commands/doctor-command.ts +64 -0
- package/src/commands/doctor-package-json.ts +47 -0
- package/src/commands/doctor-sdk-pin.ts +156 -0
- package/src/commands/doctor-store-keys-lexer.ts +213 -0
- package/src/commands/doctor-store-keys-scan.ts +262 -0
- package/src/commands/doctor-store-keys.ts +196 -0
- package/src/commands/doctor.ts +371 -0
- package/src/commands/init/blank-scaffold-templates.ts +397 -0
- package/src/commands/init/index.ts +170 -0
- package/src/commands/init/internal-toolchain.ts +49 -0
- package/src/commands/init/manager-test-template.ts +107 -0
- package/src/commands/init/multiplayer-test-template.ts +217 -0
- package/src/commands/init/name-input.tsx +167 -0
- package/src/commands/init/no-store-scaffold-templates.ts +281 -0
- package/src/commands/init/no-store-scaffold.ts +134 -0
- package/src/commands/init/package-json-scripts.ts +72 -0
- package/src/commands/init/scaffold.ts +960 -0
- package/src/commands/init/sdk-tarball-url.generated.ts +4 -0
- package/src/commands/init/sdk-tarball-url.ts +31 -0
- package/src/commands/init/template-picker.tsx +147 -0
- package/src/commands/inspect-child-entry.ts +107 -0
- package/src/commands/inspect-contract.ts +87 -0
- package/src/commands/inspect-freshness.ts +217 -0
- package/src/commands/inspect-lock.ts +201 -0
- package/src/commands/inspect-options.ts +360 -0
- package/src/commands/inspect-orchestrate.ts +375 -0
- package/src/commands/inspect-process.ts +172 -0
- package/src/commands/inspect-ready.ts +65 -0
- package/src/commands/inspect-report.ts +235 -0
- package/src/commands/inspect-run-state.ts +296 -0
- package/src/commands/inspect-run.ts +157 -0
- package/src/commands/inspect-watchdog.ts +74 -0
- package/src/commands/install-joiner.ts +208 -0
- package/src/commands/login.ts +308 -0
- package/src/commands/models.ts +40 -0
- package/src/commands/parse-options.ts +36 -0
- package/src/commands/remix-package-json.ts +64 -0
- package/src/commands/remix.ts +379 -0
- package/src/commands/sdk-url.ts +141 -0
- package/src/commands/simulations.ts +133 -0
- package/src/commands/skills.ts +108 -0
- package/src/commands/store-files.ts +92 -0
- package/src/commands/stores.ts +703 -0
- package/src/commands/tiles-channel-commands.ts +115 -0
- package/src/commands/tiles-checkout.ts +351 -0
- package/src/commands/tiles-gallery-command.ts +95 -0
- package/src/commands/tiles-get-helpers.ts +27 -0
- package/src/commands/tiles-inspect.ts +276 -0
- package/src/commands/tiles-power-command.ts +308 -0
- package/src/commands/tiles-power-format.ts +396 -0
- package/src/commands/tiles-power-versions.ts +299 -0
- package/src/commands/tiles-publish-helpers.ts +145 -0
- package/src/commands/tiles-upload-command.ts +277 -0
- package/src/commands/tiles-version-commands.ts +201 -0
- package/src/commands/tiles-visibility-command.ts +103 -0
- package/src/commands/tiles.ts +257 -0
- package/src/commands/upgrade.ts +307 -0
- package/src/commit-in-progress.ts +42 -0
- package/src/creator-source-context.ts +97 -0
- package/src/creator-source-publish.ts +52 -0
- package/src/deferred-assets.ts +125 -0
- package/src/distribution.ts +28 -0
- package/src/errors.ts +61 -0
- package/src/install-command.ts +43 -0
- package/src/output.ts +62 -0
- package/src/poe-tile-config-files.ts +100 -0
- package/src/poe-tile-config-players.ts +168 -0
- package/src/poe-tile-config-remix.ts +166 -0
- package/src/poe-tile-config.ts +831 -0
- package/src/power-report-client.ts +55 -0
- package/src/prototype-startup.ts +21 -0
- package/src/publish-change-summary.ts +55 -0
- package/src/publish-overrides-validation.ts +49 -0
- package/src/publish-pack.ts +167 -0
- package/src/publish-phases.ts +57 -0
- package/src/publish-retry.ts +51 -0
- package/src/publish-tile-from-config.ts +434 -0
- package/src/recorder-stream.ts +169 -0
- package/src/remix-provenance.ts +156 -0
- package/src/resolve-client-credential.ts +71 -0
- package/src/resolve-media-uploads.ts +147 -0
- package/src/sdk-dependency.ts +54 -0
- package/src/sdk-skills.ts +85 -0
- package/src/should-skip-client-setup.ts +20 -0
- package/src/simulation-snapshot.ts +123 -0
- package/src/simulation-types.ts +74 -0
- package/src/simulations-client.ts +112 -0
- package/src/source-bundle.ts +466 -0
- package/src/staged-publish-cleanup.ts +44 -0
- package/src/staged-publish-deferred.ts +160 -0
- package/src/staged-publish.ts +401 -0
- package/src/store-file-upload.ts +268 -0
- package/src/store-request.ts +168 -0
- package/src/tar-canonical.ts +41 -0
- package/src/tar-extensions.ts +159 -0
- package/src/tar-extract.ts +193 -0
- package/src/tar-parse.ts +224 -0
- package/src/tar.ts +231 -0
- package/src/template-check-scripts.ts +18 -0
- package/src/tile-gallery-client.ts +82 -0
- package/src/types.ts +258 -0
- package/src/upload-concurrency.ts +54 -0
- package/src/whole-tile.ts +52 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Prepare creator metadata in a freshly-extracted source tree's
|
|
4
|
+
* `.poe-tile.json`.
|
|
5
|
+
*
|
|
6
|
+
* `poe-tiles remix` unpacks someone else's published source. The extracted
|
|
7
|
+
* config is *their* config — same handle, same metadata — so the first publish
|
|
8
|
+
* from that directory needs a new handle anyway. This module writes the one
|
|
9
|
+
* field the creator can't reconstruct by hand: which app, and which exact
|
|
10
|
+
* publish of it, the copy came from.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately best-effort and never fatal. A remix whose config can't be
|
|
13
|
+
* stamped (no `.poe-tile.json`, unreadable JSON, a server too old to return
|
|
14
|
+
* the provenance headers) must still produce a working local checkout — the
|
|
15
|
+
* creator loses attribution, not their source. Every skip returns a reason the
|
|
16
|
+
* command surfaces, so a silent drop is impossible.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { lstatSync, readFileSync, writeFileSync } from "node:fs";
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
import {
|
|
22
|
+
POE_TILE_CONFIG_FILENAME,
|
|
23
|
+
POE_TILE_CONFIG_SCHEMA_URL,
|
|
24
|
+
validatePoeTileConfig,
|
|
25
|
+
} from "./poe-tile-config.js";
|
|
26
|
+
import { LEGACY_PUBLISH_CONFIG_FILENAME } from "./poe-tile-config-files.js";
|
|
27
|
+
import type { PoeTileConfigRemixOf } from "./poe-tile-config-remix.js";
|
|
28
|
+
|
|
29
|
+
export type RemixProvenanceResult =
|
|
30
|
+
| { stamped: true; remixOf: PoeTileConfigRemixOf }
|
|
31
|
+
| { stamped: false; reason: string };
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The branch-point facts, as returned by `client.downloadSourceBundle`. Both
|
|
35
|
+
* ids are nullable because an older server omits the headers; the caller must
|
|
36
|
+
* not invent values.
|
|
37
|
+
*/
|
|
38
|
+
export type RemixProvenanceInput = {
|
|
39
|
+
tileId: string;
|
|
40
|
+
sourceBundleId: string | null;
|
|
41
|
+
versionNumber: number | null;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function sourceProvenance(
|
|
45
|
+
input: RemixProvenanceInput | null,
|
|
46
|
+
): RemixProvenanceResult {
|
|
47
|
+
if (input === null) {
|
|
48
|
+
return { stamped: false, reason: "no remix source was supplied" };
|
|
49
|
+
}
|
|
50
|
+
if (input.sourceBundleId === null || input.versionNumber === null) {
|
|
51
|
+
return {
|
|
52
|
+
stamped: false,
|
|
53
|
+
reason:
|
|
54
|
+
"the server did not report the source bundle id and publish version for this download",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
stamped: true,
|
|
59
|
+
remixOf: {
|
|
60
|
+
tileId: input.tileId,
|
|
61
|
+
versionNumber: input.versionNumber,
|
|
62
|
+
sourceBundleId: input.sourceBundleId.toLowerCase(),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function configErrorMessage(error: unknown): string {
|
|
68
|
+
return error instanceof Error ? error.message : String(error);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function readCopiedConfig(
|
|
72
|
+
configPath: string,
|
|
73
|
+
filename: string,
|
|
74
|
+
): Record<string, unknown> {
|
|
75
|
+
let parsed: unknown;
|
|
76
|
+
try {
|
|
77
|
+
parsed = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`${filename} is not valid JSON (${configErrorMessage(error)})`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
84
|
+
throw new Error(`${filename} is not a JSON object`);
|
|
85
|
+
}
|
|
86
|
+
if (filename === LEGACY_PUBLISH_CONFIG_FILENAME)
|
|
87
|
+
validatePoeTileConfig(parsed);
|
|
88
|
+
return parsed as Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Remove obsolete creator categories from a copied canonical config, then stamp
|
|
93
|
+
* remix provenance when known. Canonical Edit copies and old-server downloads
|
|
94
|
+
* lose categories without inventing attribution or changing their schema URL.
|
|
95
|
+
* Stamped copies use v10; unrelated and unknown fields remain untouched.
|
|
96
|
+
* A sole legacy config is validated first and keeps its filename and fields.
|
|
97
|
+
* Adjacent configs remain untouched rather than diverging. Stored source
|
|
98
|
+
* archives are never rewritten.
|
|
99
|
+
*/
|
|
100
|
+
export function prepareCopiedTileConfig(
|
|
101
|
+
targetDir: string,
|
|
102
|
+
input: RemixProvenanceInput | null,
|
|
103
|
+
): RemixProvenanceResult {
|
|
104
|
+
let filename = POE_TILE_CONFIG_FILENAME;
|
|
105
|
+
let configPath = join(targetDir, filename);
|
|
106
|
+
let config: Record<string, unknown>;
|
|
107
|
+
try {
|
|
108
|
+
const hasCurrent = Boolean(
|
|
109
|
+
lstatSync(configPath, { throwIfNoEntry: false }),
|
|
110
|
+
);
|
|
111
|
+
const hasLegacy = Boolean(
|
|
112
|
+
lstatSync(join(targetDir, LEGACY_PUBLISH_CONFIG_FILENAME), {
|
|
113
|
+
throwIfNoEntry: false,
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
if (hasLegacy && hasCurrent) {
|
|
117
|
+
return {
|
|
118
|
+
stamped: false,
|
|
119
|
+
reason: `the copied source has ${LEGACY_PUBLISH_CONFIG_FILENAME}; publish config files were preserved; resolve the legacy config before preparing metadata`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
filename = hasLegacy
|
|
123
|
+
? LEGACY_PUBLISH_CONFIG_FILENAME
|
|
124
|
+
: POE_TILE_CONFIG_FILENAME;
|
|
125
|
+
configPath = join(targetDir, filename);
|
|
126
|
+
if (!hasLegacy && !hasCurrent) {
|
|
127
|
+
return {
|
|
128
|
+
stamped: false,
|
|
129
|
+
reason: `the remixed source has no ${filename}`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
config = readCopiedConfig(configPath, filename);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
return {
|
|
135
|
+
stamped: false,
|
|
136
|
+
reason: configErrorMessage(error).replaceAll(
|
|
137
|
+
POE_TILE_CONFIG_FILENAME,
|
|
138
|
+
filename,
|
|
139
|
+
),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const hadCategories = "categories" in config;
|
|
144
|
+
delete config["categories"];
|
|
145
|
+
const provenance = sourceProvenance(input);
|
|
146
|
+
if (provenance.stamped) {
|
|
147
|
+
config["$schema"] = POE_TILE_CONFIG_SCHEMA_URL;
|
|
148
|
+
config["remixOf"] = provenance.remixOf;
|
|
149
|
+
}
|
|
150
|
+
// Tab-indent to match the formatting `writePoeTileConfig` uses, so a
|
|
151
|
+
// remixed app doesn't fail its own `biome format` check on first commit.
|
|
152
|
+
if (hadCategories || provenance.stamped) {
|
|
153
|
+
writeFileSync(configPath, `${JSON.stringify(config, null, "\t")}\n`);
|
|
154
|
+
}
|
|
155
|
+
return provenance;
|
|
156
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Resolves which credential the CLI client should authenticate with.
|
|
4
|
+
* Extracted from `cli.ts` (which cannot be imported for tests — it runs
|
|
5
|
+
* `main()` at module load) so the priority order is directly unit-testable.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { PoeApiKeyFileSystem } from "./auth-token.js";
|
|
9
|
+
import {
|
|
10
|
+
missingPoeCliCredentialMessage,
|
|
11
|
+
resolvePoeApiKey,
|
|
12
|
+
resolvePoeTilesSessionToken,
|
|
13
|
+
} from "./auth-token.js";
|
|
14
|
+
import { readCliEnv } from "./cli-env.js";
|
|
15
|
+
import { CliError } from "./errors.js";
|
|
16
|
+
|
|
17
|
+
export type ClientCredential =
|
|
18
|
+
| { apiKey: string; sessionToken?: never }
|
|
19
|
+
| { apiKey?: never; sessionToken: string };
|
|
20
|
+
|
|
21
|
+
export interface ResolveClientCredentialOptions {
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
env: Record<string, string | undefined>;
|
|
24
|
+
fileSystem?: PoeApiKeyFileSystem;
|
|
25
|
+
homeDir?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Priority order: an explicit `--api-key` flag is a one-time, in-command
|
|
30
|
+
* override, so it wins over everything else. Explicit session/publish credentials
|
|
31
|
+
* take priority over saved logins. JOINER_SESSION_TOKEN/POE_TILES_SESSION_TOKEN
|
|
32
|
+
* still wins over JOINER_PUBLISH_TOKEN/POE_TILES_PUBLISH_TOKEN and POE_API_KEY
|
|
33
|
+
* (each `JOINER_` name before its `POE_TILES_` name; see `readCliEnv`) —
|
|
34
|
+
* a leftover POE_API_KEY in the shell environment should not silently
|
|
35
|
+
* override a session token the caller deliberately set up (e.g. for a
|
|
36
|
+
* preview/dev-login identity).
|
|
37
|
+
*/
|
|
38
|
+
export function resolveClientCredential({
|
|
39
|
+
apiKey,
|
|
40
|
+
env,
|
|
41
|
+
fileSystem,
|
|
42
|
+
homeDir,
|
|
43
|
+
}: ResolveClientCredentialOptions): ClientCredential {
|
|
44
|
+
const explicitApiKey = apiKey?.trim();
|
|
45
|
+
if (explicitApiKey) return { apiKey: explicitApiKey };
|
|
46
|
+
|
|
47
|
+
const sessionToken = readCliEnv(env, "SESSION_TOKEN");
|
|
48
|
+
if (sessionToken) return { sessionToken };
|
|
49
|
+
|
|
50
|
+
// The creator sandbox's publish-scoped credential (injected into the
|
|
51
|
+
// sandbox session env; see docs/creator-v2-local-dev.md). Sent as a Bearer
|
|
52
|
+
// token; the platform accepts it on the publish and version-management
|
|
53
|
+
// (channels/versions) endpoints and for explicit, binding-scoped owner
|
|
54
|
+
// metadata reads. Other endpoints choose their accepted scopes independently.
|
|
55
|
+
const publishToken = readCliEnv(env, "PUBLISH_TOKEN");
|
|
56
|
+
if (publishToken) return { apiKey: publishToken };
|
|
57
|
+
|
|
58
|
+
// A host-run Creator session must not publish as the developer whose login
|
|
59
|
+
// happens to be saved on disk. The scoped token above belongs to this run.
|
|
60
|
+
const savedSession = resolvePoeTilesSessionToken({
|
|
61
|
+
env,
|
|
62
|
+
fileSystem,
|
|
63
|
+
homeDir,
|
|
64
|
+
});
|
|
65
|
+
if (savedSession) return { sessionToken: savedSession };
|
|
66
|
+
|
|
67
|
+
const resolvedApiKey = resolvePoeApiKey({ env, fileSystem, homeDir });
|
|
68
|
+
if (resolvedApiKey) return { apiKey: resolvedApiKey };
|
|
69
|
+
|
|
70
|
+
throw new CliError(missingPoeCliCredentialMessage());
|
|
71
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Resolve `.poe-tile.json` media fields (screenshots, video) into the
|
|
4
|
+
* `SlopPoeClient.publishTile` call shape — reading local files into bytes with
|
|
5
|
+
* their MIME inferred from the extension. Split out of `publish-tile-from-config.ts`
|
|
6
|
+
* (which carries the `noExcessiveLinesPerFile` directive) so the resolvers live
|
|
7
|
+
* in a focused module.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { statSync } from "node:fs";
|
|
11
|
+
import { readBoundedFile } from "./bounded-read.js";
|
|
12
|
+
import { extname, resolve } from "node:path";
|
|
13
|
+
import { CliError } from "./errors.js";
|
|
14
|
+
import type { PoeTileConfigVideo } from "./poe-tile-config.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Map a local image extension to the publish endpoint's accepted MIME type.
|
|
18
|
+
* Kept in sync with `PROFILE_PICTURE_MAGIC_BYTES` on the server
|
|
19
|
+
* (`poe-tiles-api/image-upload-validation.ts`).
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The server's caps on one uploaded media file, mirrored here so a file past
|
|
23
|
+
* them is refused BEFORE it is read: profile pictures, screenshots and video
|
|
24
|
+
* posters share the tile-image cap (`PROFILE_PICTURE_MAX_BYTES` in
|
|
25
|
+
* `@lib/poe-tiles-api`), the preview video has its own
|
|
26
|
+
* (`PREVIEW_VIDEO_MAX_BYTES`). Copied rather than imported because the CLI is
|
|
27
|
+
* installed from a tarball outside the monorepo; a test pins them to the
|
|
28
|
+
* server's values. Creator's bridge runs this code in its own process, where
|
|
29
|
+
* reading a multi-gigabyte file the server would refuse anyway is not a
|
|
30
|
+
* failed publish but a stalled session.
|
|
31
|
+
*/
|
|
32
|
+
export const IMAGE_UPLOAD_MAX_BYTES = 512 * 1024;
|
|
33
|
+
export const PREVIEW_VIDEO_MAX_BYTES = 8 * 1024 * 1024;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A media file's bytes, read only after its size passes the cap; the check
|
|
37
|
+
* after the read catches a file that grew in between.
|
|
38
|
+
*/
|
|
39
|
+
export function readMediaFile(
|
|
40
|
+
absPath: string,
|
|
41
|
+
maxBytes: number,
|
|
42
|
+
label: string,
|
|
43
|
+
): Uint8Array {
|
|
44
|
+
return readBoundedFile(absPath, maxBytes, (size) =>
|
|
45
|
+
overMediaCap(label, absPath, size, maxBytes),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function overMediaCap(
|
|
50
|
+
label: string,
|
|
51
|
+
absPath: string,
|
|
52
|
+
size: number,
|
|
53
|
+
maxBytes: number,
|
|
54
|
+
): CliError {
|
|
55
|
+
return new CliError(
|
|
56
|
+
`${label} is ${size} bytes; the maximum is ${maxBytes} (${absPath}).`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function inferImageMimeType(path: string): string | undefined {
|
|
61
|
+
switch (extname(path).toLowerCase()) {
|
|
62
|
+
case ".png":
|
|
63
|
+
return "image/png";
|
|
64
|
+
case ".jpg":
|
|
65
|
+
case ".jpeg":
|
|
66
|
+
return "image/jpeg";
|
|
67
|
+
case ".webp":
|
|
68
|
+
return "image/webp";
|
|
69
|
+
default:
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Resolve a `.poe-tile.json` `screenshots` list into the publish call shape.
|
|
76
|
+
* Mirrors profile-picture resolution per entry: an `https://` URL passes
|
|
77
|
+
* through as `{ url }`; a local path (resolved relative to `baseDir`, the
|
|
78
|
+
* config file's directory) is read into bytes with its MIME inferred from the
|
|
79
|
+
* extension. Throws {@link CliError} on a missing file or unsupported type —
|
|
80
|
+
* the same error surface as the profile picture.
|
|
81
|
+
*/
|
|
82
|
+
export function resolveScreenshots(
|
|
83
|
+
entries: string[],
|
|
84
|
+
baseDir: string,
|
|
85
|
+
): Array<{ bytes: Uint8Array; mimeType: string } | { url: string }> {
|
|
86
|
+
return entries.map((entry) => {
|
|
87
|
+
if (entry.startsWith("https://")) return { url: entry };
|
|
88
|
+
const absPath = resolve(baseDir, entry);
|
|
89
|
+
if (!statSync(absPath, { throwIfNoEntry: false })?.isFile()) {
|
|
90
|
+
throw new CliError(`Screenshot file not found: ${absPath}`);
|
|
91
|
+
}
|
|
92
|
+
const mimeType = inferImageMimeType(absPath);
|
|
93
|
+
if (!mimeType) {
|
|
94
|
+
throw new CliError(
|
|
95
|
+
`Screenshot must be a .png, .jpg, .jpeg, or .webp file (got ${extname(absPath)}).`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
bytes: readMediaFile(absPath, IMAGE_UPLOAD_MAX_BYTES, "Screenshot"),
|
|
100
|
+
mimeType,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Resolve a `.poe-tile.json` `video` value into the publish call shape. Both
|
|
107
|
+
* `src` (mp4) and `poster` (image) are local paths (no `https://` pass-through;
|
|
108
|
+
* enforced at config-read time), read into bytes relative to `baseDir`. `null`
|
|
109
|
+
* passes through as the clear sentinel. Throws {@link CliError} on a missing
|
|
110
|
+
* file or unsupported type.
|
|
111
|
+
*/
|
|
112
|
+
export function resolveVideo(
|
|
113
|
+
video: PoeTileConfigVideo | null,
|
|
114
|
+
baseDir: string,
|
|
115
|
+
): {
|
|
116
|
+
src: { bytes: Uint8Array; mimeType: string };
|
|
117
|
+
poster: { bytes: Uint8Array; mimeType: string };
|
|
118
|
+
} | null {
|
|
119
|
+
if (video === null) return null;
|
|
120
|
+
const srcPath = resolve(baseDir, video.src);
|
|
121
|
+
if (!statSync(srcPath, { throwIfNoEntry: false })?.isFile()) {
|
|
122
|
+
throw new CliError(`Video file not found: ${srcPath}`);
|
|
123
|
+
}
|
|
124
|
+
if (extname(srcPath).toLowerCase() !== ".mp4") {
|
|
125
|
+
throw new CliError(`Video must be a .mp4 file (got ${extname(srcPath)}).`);
|
|
126
|
+
}
|
|
127
|
+
const posterPath = resolve(baseDir, video.poster);
|
|
128
|
+
if (!statSync(posterPath, { throwIfNoEntry: false })?.isFile()) {
|
|
129
|
+
throw new CliError(`Video poster file not found: ${posterPath}`);
|
|
130
|
+
}
|
|
131
|
+
const posterMime = inferImageMimeType(posterPath);
|
|
132
|
+
if (!posterMime) {
|
|
133
|
+
throw new CliError(
|
|
134
|
+
`Video poster must be a .png, .jpg, .jpeg, or .webp file (got ${extname(posterPath)}).`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
src: {
|
|
139
|
+
bytes: readMediaFile(srcPath, PREVIEW_VIDEO_MAX_BYTES, "Video"),
|
|
140
|
+
mimeType: "video/mp4",
|
|
141
|
+
},
|
|
142
|
+
poster: {
|
|
143
|
+
bytes: readMediaFile(posterPath, IMAGE_UPLOAD_MAX_BYTES, "Video poster"),
|
|
144
|
+
mimeType: posterMime,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* The two package.json keys a tile project may use for the tile SDK.
|
|
4
|
+
*
|
|
5
|
+
* `joiner-sdk` is the taught name; `poe-tiles-sdk` stays accepted with no end
|
|
6
|
+
* date. The CLI keeps its own copy of the names: the published CLI cannot
|
|
7
|
+
* import the SDK package, and a released SDK may predate the name helper.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const SDK_PACKAGE_NAME = "joiner-sdk";
|
|
11
|
+
export const LEGACY_SDK_PACKAGE_NAME = "poe-tiles-sdk";
|
|
12
|
+
export const SDK_PACKAGE_NAMES = [
|
|
13
|
+
SDK_PACKAGE_NAME,
|
|
14
|
+
LEGACY_SDK_PACKAGE_NAME,
|
|
15
|
+
] as const;
|
|
16
|
+
export type SdkPackageName = (typeof SDK_PACKAGE_NAMES)[number];
|
|
17
|
+
|
|
18
|
+
export interface SdkDependencySections {
|
|
19
|
+
dependencies?: unknown;
|
|
20
|
+
devDependencies?: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type SdkDependency =
|
|
24
|
+
| { key: SdkPackageName; spec: string }
|
|
25
|
+
| { error: "both" };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Finds the project's SDK dependency in `dependencies` or `devDependencies`
|
|
29
|
+
* (runtime dependencies win when one key is in both). Returns
|
|
30
|
+
* `{ error: "both" }` when the project declares both keys, because two SDK
|
|
31
|
+
* copies would bundle SDK modules twice, and `null` when it declares neither.
|
|
32
|
+
*/
|
|
33
|
+
export function findSdkDependency(
|
|
34
|
+
pkg: SdkDependencySections,
|
|
35
|
+
): SdkDependency | null {
|
|
36
|
+
const found: Array<{ key: SdkPackageName; spec: string }> = [];
|
|
37
|
+
for (const key of SDK_PACKAGE_NAMES) {
|
|
38
|
+
const spec =
|
|
39
|
+
readStringDependency(pkg.dependencies, key) ??
|
|
40
|
+
readStringDependency(pkg.devDependencies, key);
|
|
41
|
+
if (spec !== undefined) found.push({ key, spec });
|
|
42
|
+
}
|
|
43
|
+
if (found.length > 1) return { error: "both" };
|
|
44
|
+
return found[0] ?? null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function readStringDependency(
|
|
48
|
+
section: unknown,
|
|
49
|
+
key: string,
|
|
50
|
+
): string | undefined {
|
|
51
|
+
if (!section || typeof section !== "object") return undefined;
|
|
52
|
+
const value = (section as Record<string, unknown>)[key];
|
|
53
|
+
return typeof value === "string" ? value : undefined;
|
|
54
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Install the SDK skills bundled with the currently-installed CLI into a
|
|
4
|
+
* target directory, **merging** with any existing skill directories at the
|
|
5
|
+
* same paths (files at matching paths are overwritten; user-added files
|
|
6
|
+
* outside the bundle are preserved).
|
|
7
|
+
*
|
|
8
|
+
* Shared by `poe-tiles skills install`, `poe-tiles remix`, and
|
|
9
|
+
* `poe-tiles tiles checkout` so all write the
|
|
10
|
+
* same skills the same way. See `src/commands/skills.ts` for the merge-vs-wipe
|
|
11
|
+
* trade-off discussion.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
cpSync,
|
|
16
|
+
existsSync,
|
|
17
|
+
mkdirSync,
|
|
18
|
+
readdirSync,
|
|
19
|
+
readFileSync,
|
|
20
|
+
rmSync,
|
|
21
|
+
statSync,
|
|
22
|
+
writeFileSync,
|
|
23
|
+
} from "node:fs";
|
|
24
|
+
import { resolve } from "node:path";
|
|
25
|
+
import { resolveBundledResource } from "./commands/init/scaffold.js";
|
|
26
|
+
|
|
27
|
+
/** Default target for installed skills, relative to the app root. */
|
|
28
|
+
export const DEFAULT_SKILLS_DIR = ".claude/skills";
|
|
29
|
+
|
|
30
|
+
export interface InstallSkillsOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Delete each bundled skill's existing directory before copying, so files a
|
|
33
|
+
* newer release removed or renamed do not linger. Skill directories the
|
|
34
|
+
* bundle does not ship are left alone. Default: merge.
|
|
35
|
+
*/
|
|
36
|
+
replace?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Refresh both hosts without changing existing project instructions. */
|
|
40
|
+
export function installWorkspaceSkills(
|
|
41
|
+
root: string,
|
|
42
|
+
options: InstallSkillsOptions = {},
|
|
43
|
+
): string[] {
|
|
44
|
+
const names = installSdkSkills(resolve(root, DEFAULT_SKILLS_DIR), options);
|
|
45
|
+
installSdkSkills(resolve(root, ".agents/skills"), options);
|
|
46
|
+
const instructions = resolve(root, "AGENTS.md");
|
|
47
|
+
if (!existsSync(instructions)) {
|
|
48
|
+
const claude = resolve(root, "CLAUDE.md");
|
|
49
|
+
writeFileSync(
|
|
50
|
+
instructions,
|
|
51
|
+
existsSync(claude)
|
|
52
|
+
? readFileSync(claude)
|
|
53
|
+
: "# Joiner tile\n\nLoad the tile-creator skill before editing, and synced-store before changing shared state. Read linked references explicitly. Follow the project's build and verification scripts; report which paths were actually tested. Explain live version, discovery, and source visibility before publishing.\n",
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return names;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Copy each bundled SDK skill into `<targetDir>/<skill-name>/`, returning the
|
|
61
|
+
* installed skill names. Merge semantics by default: existing files at
|
|
62
|
+
* matching paths are overwritten; unrelated user-added files survive. With
|
|
63
|
+
* `replace`, each shipped skill directory is rebuilt from the bundle.
|
|
64
|
+
*/
|
|
65
|
+
export function installSdkSkills(
|
|
66
|
+
targetDir: string,
|
|
67
|
+
options: InstallSkillsOptions = {},
|
|
68
|
+
): string[] {
|
|
69
|
+
const sdkSkillsDir = resolveBundledResource(
|
|
70
|
+
"skills",
|
|
71
|
+
"packages/poe-tiles-sdk/skills",
|
|
72
|
+
);
|
|
73
|
+
const skillNames = readdirSync(sdkSkillsDir).filter((name) =>
|
|
74
|
+
statSync(resolve(sdkSkillsDir, name)).isDirectory(),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
mkdirSync(targetDir, { recursive: true });
|
|
78
|
+
for (const name of skillNames) {
|
|
79
|
+
const src = resolve(sdkSkillsDir, name);
|
|
80
|
+
const dest = resolve(targetDir, name);
|
|
81
|
+
if (options.replace) rmSync(dest, { recursive: true, force: true });
|
|
82
|
+
cpSync(src, dest, { recursive: true, dereference: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
return skillNames;
|
|
85
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// owner: aaronroe
|
|
2
|
+
import type { Command } from "commander";
|
|
3
|
+
|
|
4
|
+
export function shouldSkipClientSetup(actionCommand: Command): boolean {
|
|
5
|
+
const cmdName = actionCommand.name();
|
|
6
|
+
const parentName = actionCommand.parent?.name();
|
|
7
|
+
return (
|
|
8
|
+
(cmdName === "remix" &&
|
|
9
|
+
actionCommand.getOptionValue("localArchive") !== undefined) ||
|
|
10
|
+
cmdName === "doctor" ||
|
|
11
|
+
(cmdName === "create" && parentName === "tiles") ||
|
|
12
|
+
(cmdName === "inspect" && parentName === "tiles") ||
|
|
13
|
+
cmdName === "init" ||
|
|
14
|
+
parentName === "skills" ||
|
|
15
|
+
cmdName === "upgrade" ||
|
|
16
|
+
cmdName === "install-joiner" ||
|
|
17
|
+
cmdName === "sdk-url" ||
|
|
18
|
+
cmdName === "creator-source-capability"
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// owner: klu
|
|
2
|
+
import type { JSONValue } from "./client.js";
|
|
3
|
+
import { CliError } from "./errors.js";
|
|
4
|
+
import type { SimulationSnapshot } from "./simulation-types.js";
|
|
5
|
+
|
|
6
|
+
export const SIMULATION_DEBUG_MIN_BYTES = 256 * 1024;
|
|
7
|
+
export const SIMULATION_DEBUG_MAX_BYTES = 4 * 1024 * 1024;
|
|
8
|
+
export const SIMULATION_DEBUG_MAX_SEATS = 16;
|
|
9
|
+
|
|
10
|
+
export function validateDebugOptions(options: {
|
|
11
|
+
maxBytes: number;
|
|
12
|
+
timeoutMs: number;
|
|
13
|
+
}): void {
|
|
14
|
+
if (
|
|
15
|
+
!Number.isSafeInteger(options.maxBytes) ||
|
|
16
|
+
options.maxBytes < SIMULATION_DEBUG_MIN_BYTES ||
|
|
17
|
+
options.maxBytes > SIMULATION_DEBUG_MAX_BYTES
|
|
18
|
+
) {
|
|
19
|
+
throw new CliError(
|
|
20
|
+
`--max-bytes must be an integer between ${SIMULATION_DEBUG_MIN_BYTES} and ${SIMULATION_DEBUG_MAX_BYTES}.`,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (
|
|
24
|
+
!Number.isSafeInteger(options.timeoutMs) ||
|
|
25
|
+
options.timeoutMs <= 0 ||
|
|
26
|
+
options.timeoutMs > 2_147_483_647
|
|
27
|
+
) {
|
|
28
|
+
throw new CliError(
|
|
29
|
+
"--timeout-ms must be an integer between 1 and 2147483647.",
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
35
|
+
// type-erasure-boundary -- untrusted WebSocket JSON is validated into SimulationSnapshot below
|
|
36
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type SnapshotActionResponse = {
|
|
40
|
+
type: "action_response";
|
|
41
|
+
request_id: string;
|
|
42
|
+
} & (
|
|
43
|
+
| { success: true; result: unknown }
|
|
44
|
+
| { success: false; error: { type: string; message: string } }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export function isSnapshotActionResponse(
|
|
48
|
+
value: unknown,
|
|
49
|
+
): value is SnapshotActionResponse {
|
|
50
|
+
if (
|
|
51
|
+
!isRecord(value) ||
|
|
52
|
+
value["type"] !== "action_response" ||
|
|
53
|
+
typeof value["request_id"] !== "string"
|
|
54
|
+
)
|
|
55
|
+
return false;
|
|
56
|
+
if (value["success"] === true) return "result" in value;
|
|
57
|
+
const error = value["error"];
|
|
58
|
+
return (
|
|
59
|
+
value["success"] === false &&
|
|
60
|
+
isRecord(error) &&
|
|
61
|
+
typeof error["type"] === "string" &&
|
|
62
|
+
typeof error["message"] === "string"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isJsonValue(value: unknown): value is JSONValue {
|
|
67
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
68
|
+
return true;
|
|
69
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
70
|
+
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
71
|
+
return isRecord(value) && Object.values(value).every(isJsonValue);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isRow(value: unknown): boolean {
|
|
75
|
+
if (!isRecord(value)) return false;
|
|
76
|
+
return (
|
|
77
|
+
(value["visibility"] === "public" || value["visibility"] === "private") &&
|
|
78
|
+
typeof value["itemKey"] === "string" &&
|
|
79
|
+
typeof value["sortKey"] === "string" &&
|
|
80
|
+
isJsonValue(value["value"])
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function isSeat(value: unknown): boolean {
|
|
85
|
+
if (!isRecord(value)) return false;
|
|
86
|
+
return (
|
|
87
|
+
typeof value["userId"] === "string" &&
|
|
88
|
+
(value["slug"] === undefined || typeof value["slug"] === "string") &&
|
|
89
|
+
typeof value["complete"] === "boolean" &&
|
|
90
|
+
typeof value["bytes"] === "number" &&
|
|
91
|
+
isRecord(value["tables"]) &&
|
|
92
|
+
Object.values(value["tables"]).every(
|
|
93
|
+
(rows) => Array.isArray(rows) && rows.every(isRow),
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isSnapshot(value: unknown): value is SimulationSnapshot {
|
|
99
|
+
if (!isRecord(value)) return false;
|
|
100
|
+
const limits = value["limits"];
|
|
101
|
+
const seats = value["seats"];
|
|
102
|
+
return (
|
|
103
|
+
typeof value["version"] === "number" &&
|
|
104
|
+
typeof value["schemaVersion"] === "number" &&
|
|
105
|
+
typeof value["consistent"] === "boolean" &&
|
|
106
|
+
typeof value["complete"] === "boolean" &&
|
|
107
|
+
isRecord(limits) &&
|
|
108
|
+
Object.values(limits).every((v) => typeof v === "number") &&
|
|
109
|
+
"maxBytes" in limits &&
|
|
110
|
+
"reservedBytes" in limits &&
|
|
111
|
+
"perSeatBytes" in limits &&
|
|
112
|
+
Array.isArray(seats) &&
|
|
113
|
+
seats.length > 0 &&
|
|
114
|
+
seats.length <= SIMULATION_DEBUG_MAX_SEATS &&
|
|
115
|
+
seats.every(isSeat)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function parseSimulationSnapshot(value: unknown): SimulationSnapshot {
|
|
120
|
+
if (!isSnapshot(value))
|
|
121
|
+
throw new CliError("Invalid debug snapshot returned by the server.");
|
|
122
|
+
return value;
|
|
123
|
+
}
|