@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,371 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Local readiness checks for first-time Poe Tiles creator workspaces.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SpawnSyncReturns } from "node:child_process";
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import {
|
|
9
|
+
existsSync,
|
|
10
|
+
readdirSync,
|
|
11
|
+
readFileSync,
|
|
12
|
+
type Stats,
|
|
13
|
+
statSync,
|
|
14
|
+
} from "node:fs";
|
|
15
|
+
import { homedir } from "node:os";
|
|
16
|
+
import { basename, resolve } from "node:path";
|
|
17
|
+
import {
|
|
18
|
+
type PoeApiKeyFileSystem,
|
|
19
|
+
resolvePoeApiKey,
|
|
20
|
+
resolvePoeTilesSessionToken,
|
|
21
|
+
} from "../auth-token.js";
|
|
22
|
+
import { readCliEnv } from "../cli-env.js";
|
|
23
|
+
import { cliName } from "../cli-name.js";
|
|
24
|
+
import { readPoeTileConfig } from "../poe-tile-config.js";
|
|
25
|
+
import { checkBun } from "./doctor-bun.js";
|
|
26
|
+
import {
|
|
27
|
+
type PackageJsonState,
|
|
28
|
+
readPackageJson,
|
|
29
|
+
} from "./doctor-package-json.js";
|
|
30
|
+
import { checkSdkPin } from "./doctor-sdk-pin.js";
|
|
31
|
+
import { checkStoreKeys } from "./doctor-store-keys.js";
|
|
32
|
+
import { readSdkTarballUrl } from "./init/sdk-tarball-url.js";
|
|
33
|
+
|
|
34
|
+
const REQUIRED_SCRIPTS = ["dev", "build", "publish-to-poe-tiles"] as const;
|
|
35
|
+
type DoctorSpawnSync = (
|
|
36
|
+
command: string,
|
|
37
|
+
args: string[],
|
|
38
|
+
options: { cwd?: string; encoding: "utf8" },
|
|
39
|
+
) => Pick<SpawnSyncReturns<string>, "status" | "stdout" | "stderr" | "error">;
|
|
40
|
+
|
|
41
|
+
export type DoctorStatus = "pass" | "warn" | "fail";
|
|
42
|
+
|
|
43
|
+
export interface DoctorCheck {
|
|
44
|
+
name: string;
|
|
45
|
+
status: DoctorStatus;
|
|
46
|
+
message: string;
|
|
47
|
+
fix?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface DoctorReport {
|
|
51
|
+
ok: boolean;
|
|
52
|
+
cwd: string;
|
|
53
|
+
checks: DoctorCheck[];
|
|
54
|
+
summary: {
|
|
55
|
+
failures: number;
|
|
56
|
+
warnings: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface DoctorCommandRunner {
|
|
61
|
+
run(options: { command: string; args: string[]; cwd?: string }): {
|
|
62
|
+
status: number | null;
|
|
63
|
+
stdout: string;
|
|
64
|
+
stderr: string;
|
|
65
|
+
error?: unknown;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface DoctorFileSystem extends PoeApiKeyFileSystem {
|
|
70
|
+
readFileSync(path: string, encoding: "utf8"): string;
|
|
71
|
+
existsSync(path: string): boolean;
|
|
72
|
+
statSync(path: string): Stats | { isFile(): boolean };
|
|
73
|
+
/** Entries of one directory; symlinks are neither files nor directories. */
|
|
74
|
+
readdirEntries(
|
|
75
|
+
path: string,
|
|
76
|
+
): { name: string; isFile(): boolean; isDirectory(): boolean }[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface RunDoctorOptions {
|
|
80
|
+
apiKey?: string;
|
|
81
|
+
cwd?: string;
|
|
82
|
+
env?: Record<string, string | undefined>;
|
|
83
|
+
fileSystem?: DoctorFileSystem;
|
|
84
|
+
homeDir?: string;
|
|
85
|
+
runner?: DoctorCommandRunner;
|
|
86
|
+
/** SDK tarball URL to compare pins against; defaults to the baked-in URL. */
|
|
87
|
+
currentSdkUrl?: string | null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const nodeFileSystem: DoctorFileSystem = {
|
|
91
|
+
existsSync,
|
|
92
|
+
readFileSync: (path, encoding) => readFileSync(path, encoding),
|
|
93
|
+
statSync,
|
|
94
|
+
readdirEntries: (path) => readdirSync(path, { withFileTypes: true }),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export function createNodeDoctorCommandRunner(
|
|
98
|
+
spawnCommand: DoctorSpawnSync = spawnSync,
|
|
99
|
+
): DoctorCommandRunner {
|
|
100
|
+
return {
|
|
101
|
+
run({ command, args, cwd }) {
|
|
102
|
+
const result = spawnCommand(command, args, {
|
|
103
|
+
cwd,
|
|
104
|
+
encoding: "utf8",
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
status: result.status,
|
|
108
|
+
stdout: result.stdout ?? "",
|
|
109
|
+
stderr: result.stderr ?? "",
|
|
110
|
+
error: result.error,
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const nodeRunner = createNodeDoctorCommandRunner();
|
|
117
|
+
|
|
118
|
+
function readInstalledSdkManifest({
|
|
119
|
+
cwd,
|
|
120
|
+
fileSystem,
|
|
121
|
+
key,
|
|
122
|
+
}: {
|
|
123
|
+
cwd: string;
|
|
124
|
+
fileSystem: DoctorFileSystem;
|
|
125
|
+
key: string;
|
|
126
|
+
}): unknown {
|
|
127
|
+
try {
|
|
128
|
+
return JSON.parse(
|
|
129
|
+
fileSystem.readFileSync(
|
|
130
|
+
resolve(cwd, "node_modules", key, "package.json"),
|
|
131
|
+
"utf8",
|
|
132
|
+
),
|
|
133
|
+
) as unknown;
|
|
134
|
+
} catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function runDoctor(options: RunDoctorOptions = {}): DoctorReport {
|
|
140
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
141
|
+
const fileSystem = options.fileSystem ?? nodeFileSystem;
|
|
142
|
+
const packageJson = readPackageJson({ cwd, fileSystem });
|
|
143
|
+
const checks = [
|
|
144
|
+
checkBun({ cwd, fileSystem, runner: options.runner ?? nodeRunner }),
|
|
145
|
+
checkPackageJson({ packageJson }),
|
|
146
|
+
checkDependencies({ cwd, fileSystem, packageJson }),
|
|
147
|
+
checkPoeTileConfig({ cwd }),
|
|
148
|
+
checkPackageScripts({ packageJson }),
|
|
149
|
+
checkSdkPin({
|
|
150
|
+
// A build-time-only workspace may declare the SDK in devDependencies;
|
|
151
|
+
// both install and build fine, so accept a pin from either group
|
|
152
|
+
// (runtime dependencies win on a duplicate).
|
|
153
|
+
dependencies:
|
|
154
|
+
packageJson.kind === "ok"
|
|
155
|
+
? { ...packageJson.devDependencies, ...packageJson.dependencies }
|
|
156
|
+
: null,
|
|
157
|
+
currentSdkUrl:
|
|
158
|
+
options.currentSdkUrl === undefined
|
|
159
|
+
? readSdkTarballUrl()
|
|
160
|
+
: options.currentSdkUrl,
|
|
161
|
+
readInstalledSdkManifest: (key) =>
|
|
162
|
+
readInstalledSdkManifest({ cwd, fileSystem, key }),
|
|
163
|
+
}),
|
|
164
|
+
checkStoreKeys({ cwd, fileSystem }),
|
|
165
|
+
checkAuth({
|
|
166
|
+
apiKey: options.apiKey,
|
|
167
|
+
env: options.env ?? process.env,
|
|
168
|
+
fileSystem,
|
|
169
|
+
homeDir: options.homeDir ?? homedir(),
|
|
170
|
+
}),
|
|
171
|
+
];
|
|
172
|
+
const failures = checks.filter((check) => check.status === "fail").length;
|
|
173
|
+
const warnings = checks.filter((check) => check.status === "warn").length;
|
|
174
|
+
return {
|
|
175
|
+
ok: failures === 0,
|
|
176
|
+
cwd,
|
|
177
|
+
checks,
|
|
178
|
+
summary: { failures, warnings },
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function checkPackageJson(options: {
|
|
183
|
+
packageJson: PackageJsonState;
|
|
184
|
+
}): DoctorCheck {
|
|
185
|
+
if (options.packageJson.kind === "ok") {
|
|
186
|
+
return {
|
|
187
|
+
name: "Project folder",
|
|
188
|
+
status: "pass",
|
|
189
|
+
message: "Found package.json.",
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
if (options.packageJson.kind === "missing") {
|
|
193
|
+
return {
|
|
194
|
+
name: "Project folder",
|
|
195
|
+
status: "fail",
|
|
196
|
+
message: "This folder is not a Poe Tiles project folder.",
|
|
197
|
+
fix: `Open the folder created by \`${cliName()} tiles init\`, or run \`${cliName()} tiles init <name>\` to create one.`,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
name: "Project folder",
|
|
202
|
+
status: "fail",
|
|
203
|
+
message: `package.json could not be read: ${options.packageJson.error}`,
|
|
204
|
+
fix: `Ask the agent to repair package.json, then re-run \`${cliName()} doctor\`.`,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function checkDependencies(options: {
|
|
209
|
+
cwd: string;
|
|
210
|
+
fileSystem: DoctorFileSystem;
|
|
211
|
+
packageJson: PackageJsonState;
|
|
212
|
+
}): DoctorCheck {
|
|
213
|
+
if (options.packageJson.kind !== "ok") {
|
|
214
|
+
return {
|
|
215
|
+
name: "Dependencies",
|
|
216
|
+
status: "fail",
|
|
217
|
+
message: "Dependencies cannot be checked until package.json is fixed.",
|
|
218
|
+
fix: "Fix the project folder problem above first.",
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
if (options.fileSystem.existsSync(resolve(options.cwd, "node_modules"))) {
|
|
222
|
+
return {
|
|
223
|
+
name: "Dependencies",
|
|
224
|
+
status: "pass",
|
|
225
|
+
message: "Dependencies are installed.",
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
name: "Dependencies",
|
|
230
|
+
status: "fail",
|
|
231
|
+
message: "Dependencies have not been installed in this project.",
|
|
232
|
+
fix: "Run `bun install` in this folder.",
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function checkPoeTileConfig(options: { cwd: string }): DoctorCheck {
|
|
237
|
+
try {
|
|
238
|
+
const result = readPoeTileConfig(options.cwd);
|
|
239
|
+
if (!result.found) {
|
|
240
|
+
return {
|
|
241
|
+
name: "Publish config",
|
|
242
|
+
status: "fail",
|
|
243
|
+
message:
|
|
244
|
+
"Missing .poe-tile.json, so publishing would need manual flags.",
|
|
245
|
+
fix: `Run \`${cliName()} tiles init <name>\` to create a starter project, or ask the agent to add .poe-tile.json.`,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
name: "Publish config",
|
|
250
|
+
status: "pass",
|
|
251
|
+
message: `Found ${basename(result.path)} for handle "${result.config.handle}".`,
|
|
252
|
+
};
|
|
253
|
+
} catch (error) {
|
|
254
|
+
return {
|
|
255
|
+
name: "Publish config",
|
|
256
|
+
status: "fail",
|
|
257
|
+
message: error instanceof Error ? error.message : String(error),
|
|
258
|
+
fix: "Ask the agent to resolve the publish config error above before publishing.",
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function checkPackageScripts(options: {
|
|
264
|
+
packageJson: PackageJsonState;
|
|
265
|
+
}): DoctorCheck {
|
|
266
|
+
const packageJson = options.packageJson;
|
|
267
|
+
if (packageJson.kind !== "ok") {
|
|
268
|
+
return {
|
|
269
|
+
name: "Project scripts",
|
|
270
|
+
status: "fail",
|
|
271
|
+
message: "Project scripts cannot be checked until package.json is fixed.",
|
|
272
|
+
fix: "Fix the project folder problem above first.",
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
const missing = REQUIRED_SCRIPTS.filter(
|
|
276
|
+
(scriptName) => typeof packageJson.scripts[scriptName] !== "string",
|
|
277
|
+
);
|
|
278
|
+
if (missing.length === 0) {
|
|
279
|
+
return {
|
|
280
|
+
name: "Project scripts",
|
|
281
|
+
status: "pass",
|
|
282
|
+
message: "Found dev, build, and publish scripts.",
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
name: "Project scripts",
|
|
287
|
+
status: "fail",
|
|
288
|
+
message: `Missing package script${missing.length === 1 ? "" : "s"}: ${missing.join(", ")}.`,
|
|
289
|
+
fix: "Ask the agent to restore the official Poe Tiles scaffold scripts in package.json.",
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function checkAuth(options: {
|
|
294
|
+
apiKey?: string;
|
|
295
|
+
env: Record<string, string | undefined>;
|
|
296
|
+
fileSystem: DoctorFileSystem;
|
|
297
|
+
homeDir: string;
|
|
298
|
+
}): DoctorCheck {
|
|
299
|
+
try {
|
|
300
|
+
const sessionToken = resolvePoeTilesSessionToken({
|
|
301
|
+
env: options.env,
|
|
302
|
+
fileSystem: options.fileSystem,
|
|
303
|
+
homeDir: options.homeDir,
|
|
304
|
+
});
|
|
305
|
+
if (sessionToken) {
|
|
306
|
+
return {
|
|
307
|
+
name: "Poe login",
|
|
308
|
+
status: "pass",
|
|
309
|
+
message: "Browser login session is available.",
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
} catch (error) {
|
|
313
|
+
return {
|
|
314
|
+
name: "Poe login",
|
|
315
|
+
status: "fail",
|
|
316
|
+
message: `Could not read the browser login session: ${errorMessage(error)}`,
|
|
317
|
+
fix: `Run \`${cliName()} login\` again; it stores a fresh session without putting secrets in chat.`,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// The creator sandbox injects a publish-scoped token (POE_TILES_PUBLISH_TOKEN)
|
|
322
|
+
// into the terminal session env, so publishing is already authorized there and
|
|
323
|
+
// no `poe-tiles login` is needed. `resolveClientCredential` uses it with the
|
|
324
|
+
// same precedence (below the session token, above the legacy API key); mirror
|
|
325
|
+
// that here so doctor reports the workspace as publish-ready instead of steering
|
|
326
|
+
// the sandbox agent into an interactive browser login it can't complete.
|
|
327
|
+
const publishToken = readCliEnv(options.env, "PUBLISH_TOKEN");
|
|
328
|
+
if (publishToken) {
|
|
329
|
+
return {
|
|
330
|
+
name: "Poe login",
|
|
331
|
+
status: "pass",
|
|
332
|
+
message: "Creator sandbox publish credential is available.",
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
const apiKey = resolvePoeApiKey({
|
|
338
|
+
apiKey: options.apiKey,
|
|
339
|
+
env: options.env,
|
|
340
|
+
fileSystem: options.fileSystem,
|
|
341
|
+
homeDir: options.homeDir,
|
|
342
|
+
});
|
|
343
|
+
if (apiKey) {
|
|
344
|
+
return {
|
|
345
|
+
name: "Poe login",
|
|
346
|
+
status: "warn",
|
|
347
|
+
message:
|
|
348
|
+
"A legacy Poe API key is available, but browser login is the safer first-time creator path.",
|
|
349
|
+
fix: `Run \`${cliName()} login\` when possible; do not paste API keys into agent chat for normal setup.`,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
} catch (error) {
|
|
353
|
+
return {
|
|
354
|
+
name: "Poe login",
|
|
355
|
+
status: "fail",
|
|
356
|
+
message: `Could not read the legacy API key fallback: ${errorMessage(error)}`,
|
|
357
|
+
fix: `Run \`${cliName()} login\` to use browser-based auth instead.`,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return {
|
|
362
|
+
name: "Poe login",
|
|
363
|
+
status: "fail",
|
|
364
|
+
message: "Not signed in to Poe Tiles, so publishing would stop.",
|
|
365
|
+
fix: `Run \`${cliName()} login\` and approve the browser prompt. Do not paste API keys into agent chat for normal setup.`,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function errorMessage(error: unknown): string {
|
|
370
|
+
return error instanceof Error ? error.message : String(error);
|
|
371
|
+
}
|