phibelle-kit 1.0.34 → 1.0.36

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.
@@ -36,7 +36,9 @@ export async function initSceneCommand() {
36
36
  await fs.mkdir(sceneDir, { recursive: false });
37
37
  setupSceneDirectory(sceneDir);
38
38
  await fs.writeFile(path.join(sceneDir, SCENE_FILE_NAME), MINIMAL_SCENE_JSON, "utf8");
39
- await unpackageScene(MINIMAL_SCENE_JSON, sceneDir, "template", templateId);
39
+ await unpackageScene(MINIMAL_SCENE_JSON, sceneDir, "template", templateId, {
40
+ uninitialized: true,
41
+ });
40
42
  console.log(chalk.green(" ✓ Project initialized"));
41
43
  console.log(chalk.gray(` Directory: ${sceneDir}`));
42
44
  console.log(chalk.yellow(" Next steps:"));
@@ -11,7 +11,7 @@ import { toErrorMessage } from "../lib/utils.js";
11
11
  export const BASE_URL = process.env.NODE_ENV === "development" ? "http://localhost:3131" : "https://phibelle.studio";
12
12
  export async function watchSceneCommand() {
13
13
  const sceneDir = process.cwd();
14
- const { sceneId, templateId } = getRequiredManifestIds(sceneDir);
14
+ const { sceneId, templateId, uninitialized } = getRequiredManifestIds(sceneDir);
15
15
  let lastPrintedEditorLink = null;
16
16
  console.log();
17
17
  console.log(chalk.bold.cyan(" Watching for scene sync (WebSocket)"));
@@ -45,6 +45,10 @@ export async function watchSceneCommand() {
45
45
  const incoming = parseIncomingSceneMessage(raw);
46
46
  if (!incoming)
47
47
  return;
48
+ if (incoming.sceneId !== sceneId) {
49
+ console.log(chalk.red(" ✖ Scene ID mismatch: " + incoming.sceneId + " !== " + sceneId));
50
+ process.exit(1);
51
+ }
48
52
  try {
49
53
  parseSceneJson(incoming.sceneData);
50
54
  }
@@ -69,13 +73,15 @@ export async function watchSceneCommand() {
69
73
  startWatcher();
70
74
  return;
71
75
  }
72
- const choice = sceneId === "template"
73
- ? "push-local"
74
- : await promptForInitialSyncChoice().catch((error) => {
75
- console.log(chalk.red(" ✖ " + toErrorMessage(error)));
76
- ws.close();
77
- return null;
78
- });
76
+ const choice = uninitialized
77
+ ? "accept-web"
78
+ : sceneId === "template"
79
+ ? "push-local"
80
+ : await promptForInitialSyncChoice().catch((error) => {
81
+ console.log(chalk.red(" ✖ " + toErrorMessage(error)));
82
+ ws.close();
83
+ return null;
84
+ });
79
85
  if (!choice || currentClient !== ws)
80
86
  return;
81
87
  if (choice === "push-local") {
@@ -100,7 +106,9 @@ export async function watchSceneCommand() {
100
106
  const resolvedTemplateId = incoming.templateId ??
101
107
  (incoming.sceneId === "template" ? getRequiredManifestIds(sceneDir).templateId : undefined);
102
108
  try {
103
- await unpackageScene(incoming.sceneData, sceneDir, incoming.sceneId, resolvedTemplateId);
109
+ await unpackageScene(incoming.sceneData, sceneDir, incoming.sceneId, resolvedTemplateId, {
110
+ uninitialized: false,
111
+ });
104
112
  console.log(chalk.green(" ✓ Synced scene from app"));
105
113
  const updatedIds = getRequiredManifestIds(sceneDir);
106
114
  lastPrintedEditorLink = printEditorLink(updatedIds.sceneId, updatedIds.templateId, lastPrintedEditorLink);
@@ -2,6 +2,8 @@ export type ManifestIds = {
2
2
  sceneId: string;
3
3
  /** Only present when sceneId === "template" */
4
4
  templateId?: string;
5
+ /** When true, watch skips the initial sync prompt and accepts the web scene once. */
6
+ uninitialized?: boolean;
5
7
  };
6
8
  /**
7
9
  * Read manifest.json from sceneDir and return sceneId and optional templateId.
@@ -32,6 +32,9 @@ export function getRequiredManifestIds(sceneDir) {
32
32
  if (sceneId === "template" && typeof manifest.templateId === "string" && manifest.templateId.trim()) {
33
33
  result.templateId = manifest.templateId.trim();
34
34
  }
35
+ if (manifest.uninitialized === true) {
36
+ result.uninitialized = true;
37
+ }
35
38
  return result;
36
39
  }
37
40
  /** @deprecated Use getRequiredManifestIds instead */
@@ -11,7 +11,11 @@ export declare function parseSceneJson(content: string): PhibelleScene;
11
11
  export declare function entityNameToSlug(name: string): string;
12
12
  /** Convert slug to display name: "main-enemy" -> "Main Enemy". */
13
13
  export declare function slugToEntityName(slug: string): string;
14
+ export type UnpackageOptions = {
15
+ /** When true, write `uninitialized`; when false, remove it. */
16
+ uninitialized?: boolean;
17
+ };
14
18
  /** Unpackage scene JSON to filesystem. No DB; accepts full scene JSON string. */
15
- export declare function unpackageScene(sceneJson: string, sceneDir: string, sceneId?: string, templateId?: string): Promise<void>;
19
+ export declare function unpackageScene(sceneJson: string, sceneDir: string, sceneId?: string, templateId?: string, options?: UnpackageOptions): Promise<void>;
16
20
  export declare function patchSceneFromFile(sceneJson: string, sceneDir: string, _relativePath: string, _eventType: "change" | "add" | "unlink" | "addDir" | "unlinkDir"): Promise<string>;
17
21
  export declare function packageSceneFromFilesystem(sceneJson: string, sceneDir: string): Promise<string>;
@@ -40,7 +40,7 @@ export function slugToEntityName(slug) {
40
40
  .join(" ");
41
41
  }
42
42
  /** Unpackage scene JSON to filesystem. No DB; accepts full scene JSON string. */
43
- export async function unpackageScene(sceneJson, sceneDir, sceneId, templateId) {
43
+ export async function unpackageScene(sceneJson, sceneDir, sceneId, templateId, options) {
44
44
  const parsed = parseSceneJson(sceneJson);
45
45
  const parsedSceneId = typeof parsed._id === "string"
46
46
  ? parsed._id
@@ -51,11 +51,13 @@ export async function unpackageScene(sceneJson, sceneDir, sceneId, templateId) {
51
51
  await cleanupKnownEntityDirectories(appDir, previousManifest);
52
52
  await cleanupLegacySceneFiles(appDir);
53
53
  const resolvedSceneId = sceneId?.trim() || parsedSceneId;
54
+ const resolvedUninitialized = options?.uninitialized ?? previousManifest.uninitialized ?? false;
54
55
  const manifest = {
55
56
  sceneId: resolvedSceneId,
56
57
  ...(resolvedSceneId === "template" && templateId?.trim()
57
58
  ? { templateId: templateId.trim() }
58
59
  : {}),
60
+ ...(resolvedUninitialized ? { uninitialized: true } : {}),
59
61
  sceneScript: SCENE_SCRIPT_FILE,
60
62
  sceneProperties: SCENE_PROPERTIES_FILE,
61
63
  entities: {},
@@ -146,6 +148,7 @@ async function readManifest(sceneDir) {
146
148
  ...(sceneId === "template" && typeof parsed.templateId === "string" && parsed.templateId.trim()
147
149
  ? { templateId: parsed.templateId.trim() }
148
150
  : {}),
151
+ ...(parsed.uninitialized === true ? { uninitialized: true } : {}),
149
152
  sceneScript: typeof parsed.sceneScript === "string" ? parsed.sceneScript : SCENE_SCRIPT_FILE,
150
153
  sceneProperties: typeof parsed.sceneProperties === "string" ? parsed.sceneProperties : SCENE_PROPERTIES_FILE,
151
154
  entities: parsed.entities ?? {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phibelle-kit",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "CLI tool for interacting with the Phibelle engine",
5
5
  "type": "module",
6
6
  "bin": {