Skip to content

Commit df1eb27

Browse files
authored
fix(addon): auto include dist files (#39)
1 parent 0ab46f4 commit df1eb27

15 files changed

Lines changed: 203 additions & 72 deletions

File tree

AGENTS.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ The low-level plugin and IPC milestone covers:
1616
Application-framework behavior belongs above the low-level plugin and IPC core.
1717
The existing `@gd-kirie/ipc` package is a thin browser-side transport wrapper;
1818
do not expand it into an application event or invocation layer unless the user
19-
explicitly asks for that higher-level work. The planned Kirie CLI owns the app
20-
workflow described below: development sessions, local build inputs, export and
21-
run semantics, initialization, and diagnostics.
19+
explicitly asks for that higher-level work. The Kirie CLI owns app workflow
20+
above the addon core, including the implemented development sessions, local
21+
build inputs, export and run helpers, and the planned initialization and
22+
diagnostics commands.
2223

2324
The mobile IPC v1 experiment keeps Kirie core byte-oriented and CBOR-based with
2425
text, binary, and data lanes. JSON belongs to callers or adapters, not to Kirie
@@ -125,17 +126,17 @@ label them as anecdotal when they influence a decision.
125126
- Keep `KirieClient` as a thin C# wrapper over the same platform singleton.
126127
Expose Kirie signals as C# events, and keep internal Godot `Callable` usage as
127128
bridge plumbing rather than public API.
128-
- Kirie supports packaged web content sourced from project resources. The
129-
planned Kirie app layout standardizes production web content at
130-
`res://src-web/dist/index.html`. When that migration is implemented, drop the
131-
previous `res://web` behavior instead of preserving a compatibility layer.
132-
Runtime-mounted Godot packs remain out of scope for that loading path.
129+
- Kirie supports packaged web content sourced from project resources. The Kirie
130+
app layout standardizes production web content at
131+
`res://src-web/dist/index.html`; do not reintroduce the previous `res://web`
132+
behavior as a compatibility layer. Runtime-mounted Godot packs remain out of
133+
scope for that loading path.
133134
- If an API is needed by both GDScript and C#, keep the behavior aligned and
134135
keep C# as a thin wrapper.
135136

136-
## Planned Kirie CLI Direction
137+
## Kirie CLI Direction
137138

138-
The planned Kirie app layout is:
139+
The Kirie app layout is:
139140

140141
- `kirie.config.ts`
141142
- `package.json`
@@ -145,20 +146,22 @@ The planned Kirie app layout is:
145146
- `addons/kirie/`
146147
- optional `addons/godot_cef/`
147148

148-
Kirie CLI should be installed through npm. The current foundation commands are:
149+
Kirie CLI should be installed through npm. The implemented foundation commands are:
149150

150151
- `kirie dev`: start the Vite development server, launch Godot as a child
151152
process, and inject `KIRIE_DEV=1` and
152153
`KIRIE_WEB_URL=<resolved Vite URL>`.
153154
- `kirie build`: build every configured local input needed by a runnable or
154155
exportable Godot project, without exporting platform packages.
155156
- `kirie build web`: build only the Vite web output for Godot resource loading.
156-
- `kirie build dotnet`: build only the Godot C#/.NET project when one is
157-
configured or discovered.
158-
- `kirie init`: explicitly initialize a Kirie project and write required
159-
project configuration.
160-
- `kirie doctor`: diagnose project configuration without writing files.
161-
- `kirie doctor --fix`: explicitly repair supported configuration problems.
157+
- `kirie build dotnet`: build only the Godot C#/.NET project and fail if none
158+
is configured or discovered.
159+
- `kirie init`: planned command to explicitly initialize a Kirie project and
160+
write required project configuration.
161+
- `kirie doctor`: planned command to diagnose project configuration without
162+
writing files.
163+
- `kirie doctor --fix`: planned command to explicitly repair supported
164+
configuration problems.
162165

163166
The broader app workflow should keep these command semantics:
164167

@@ -189,14 +192,14 @@ Kirie enforces Vite for user web source. Advanced Vite options belong in
189192
`kirie.config.ts` under `web.vite`, but Kirie owns `root`, `base`,
190193
`server.host`, `server.port`, `server.open`, and `build.outDir`. Explicit CLI
191194
flags may override runtime server values for a single command invocation.
192-
Planned `kirie dev` flags include `--config <path>` for the Kirie config,
193-
`--project <dir>` for the Godot project, `--godot <path>` for a Godot executable
194-
override, and Vite-shaped flags such as `--host <host>`, `--port <number>`,
195-
`--strict-port`, `--mode <mode>`, `--force`, `--log-level <level>`,
196-
`--clear-screen`, and `--no-clear-screen`. Kirie must either parse and map
197-
Vite-shaped flags explicitly to Vite's public JavaScript API or proxy them to
198-
the real Vite CLI; unknown flags must not be silently ignored. Arguments after
199-
`--` on `kirie dev` belong to Godot.
195+
Current `kirie dev` flags include `--project <dir>` for the Godot project,
196+
`--godot <path>` for a Godot executable override, and Vite-shaped flags such as
197+
`--host <host>`, `--port <number>`, `--strict-port`, `--mode <mode>`,
198+
`--force`, `--log-level <level>`, `--clear-screen`, and `--no-clear-screen`.
199+
A Kirie `--config <path>` override remains planned. Kirie must either parse and
200+
map Vite-shaped flags explicitly to Vite's public JavaScript API or proxy them
201+
to the real Vite CLI; unknown flags must not be silently ignored. Arguments
202+
after `--` on `kirie dev` belong to Godot.
200203

201204
Only explicit setup and repair commands may write Godot configuration.
202205
`kirie init` and `kirie doctor --fix` may modify `project.godot` or

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enabled for production builds.
3939
```mermaid
4040
flowchart LR
4141
A["Godot Project"] --> B["addons/kirie"]
42-
B --> C["Kirie / KirieView / KirieClient"]
42+
B --> C["GdKirie / KirieNode / KirieClient"]
4343
C --> D["Android native implementation"]
4444
C --> E["iOS native implementation"]
4545
D <--> F["WebView"]
@@ -55,6 +55,8 @@ example, and regression-test areas:
5555
- `packages/ipc`: a thin browser-side transport wrapper for Kirie WebView pages
5656
- `packages/ipc-eventa`: browser-side Eventa adapter over Kirie text IPC
5757
- `packages/build`: public build and export automation API for scripts
58+
- `packages/cli`: Kirie command-line tools for development sessions, export,
59+
install, and launch workflows
5860
- `packages/GdKirie.EventaAdapter`: .NET 10 Eventa adapter over Kirie text IPC
5961
- `examples/basic-ipc`: beginner-friendly demo project for the raw IPC flow
6062
- `examples/basic-kirie-cli`: beginner-friendly demo project for the Kirie CLI workflow

docs/architecture.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Android and iOS use private view IDs only to route callbacks back to the owning
9797

9898
Kirie supports loading packaged offline web content from Godot project
9999
resources. The current native resolvers can serve packaged `res://` paths. The
100-
planned Kirie CLI app layout standardizes production web content at
100+
Kirie CLI app layout standardizes production web content at
101101
`res://src-web/dist/index.html`, as described below.
102102

103103
## Runtime debug configuration
@@ -123,8 +123,8 @@ debugging can opt into `Kirie-debug.aar` for a single export by passing
123123

124124
## Kirie app layout and CLI direction
125125

126-
The planned Kirie application shape is a Godot project with a Vite web frontend
127-
beside the Godot source:
126+
The Kirie application shape is a Godot project with a Vite web frontend beside
127+
the Godot source:
128128

129129
```text
130130
kirie.config.ts
@@ -160,9 +160,9 @@ Kirie does not own native platform project directories. Do not introduce
160160
Capacitor-style `ios/` or `android/` project trees into Kirie user projects.
161161
Native capabilities should be provided by Godot plugins.
162162

163-
The planned Kirie CLI surface is intentionally small. The current implemented
164-
subset covers desktop development, local build inputs, platform export, and
165-
mobile install-and-launch flows:
163+
The Kirie CLI surface is intentionally small. The current implemented subset
164+
covers desktop development, local build inputs, platform export, and mobile
165+
install-and-launch flows:
166166

167167
```sh
168168
kirie dev
@@ -279,10 +279,11 @@ processes. It only supports development sessions that the CLI starts and owns.
279279
`kirie build` builds local intermediate artifacts needed by a runnable or
280280
exportable Godot project, but it does not produce platform application packages.
281281
It should build every configured or clearly discovered input. `kirie build web`
282-
builds only the Vite web output, and `kirie build dotnet` builds only the
283-
Godot C#/.NET project when one is configured or discovered. If no C# project is
284-
configured or discovered, the aggregate `kirie build` command may skip the
285-
`.NET` step; if a C# project is present, C# build failure must fail the command.
282+
builds only the Vite web output. `kirie build dotnet` builds only the Godot
283+
C#/.NET project and fails when no project or solution is present. If no C#
284+
project is configured or discovered, the aggregate `kirie build` command may
285+
skip the `.NET` step; if a C# project is present, C# build failure must fail the
286+
command.
286287

287288
`kirie export` means a complete platform export workflow: build local inputs
288289
first, then call Godot's export flow for the selected platform or preset.
@@ -382,15 +383,14 @@ When loading `http://`, `https://`, or `file://` URLs, Kirie should keep using
382383
the platform WebView's default loading behavior instead of intercepting or
383384
rewriting those URLs.
384385

385-
The planned Kirie CLI app layout uses `res://src-web/dist/index.html` as the
386-
default production entry. When that migration is implemented, the addon export
387-
plugin should package `res://src-web/dist` for Android and iOS exports, fail
388-
export when `res://src-web/dist/index.html` is missing, and drop the previous
389-
`res://web` behavior instead of preserving a compatibility layer. Users should
390-
continue to use Godot's official export preset flow by default. Kirie may
391-
diagnose export preset issues, and explicit setup or repair commands may write
392-
supported preset changes through Godot, but normal run, build, and export
393-
commands must not silently mutate export presets.
386+
The Kirie CLI app layout uses `res://src-web/dist/index.html` as the default
387+
production entry. The addon export plugin packages `res://src-web/dist` for
388+
Android and iOS exports and fails export when `res://src-web/dist/index.html` is
389+
missing. The previous `res://web` behavior is not preserved as a compatibility
390+
layer. Users should continue to use Godot's official export preset flow by
391+
default. Kirie may diagnose export preset issues, and explicit setup or repair
392+
commands may write supported preset changes through Godot, but normal run,
393+
build, and export commands must not silently mutate export presets.
394394

395395
## Desktop Godot CEF direction
396396

docs/npm-publishing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ depend on the CLI.
2222

2323
## npm Setup
2424

25-
The npm organization and package scope is `gd-kirie`; browser packages include
26-
`@gd-kirie/ipc` and `@gd-kirie/ipc-eventa`. Future published packages include
27-
`@gd-kirie/build` and `@gd-kirie/cli`.
25+
The npm organization and package scope is `gd-kirie`; public JavaScript
26+
packages include `@gd-kirie/ipc`, `@gd-kirie/ipc-eventa`, `@gd-kirie/build`,
27+
and `@gd-kirie/cli`.
2828

2929
Configure trusted publishing for each public browser package on npmjs.com. These
3030
fields identify the GitHub repository that is allowed to publish the package:

docs/references.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ packaging, or platform WebView bridge details.
171171
fixture.
172172
- [Vite JavaScript API](https://vite.dev/guide/api-javascript.html)
173173
Reference for `createServer()`, `build()`, `mergeConfig()`, and dev server
174-
`resolvedUrls`, which underpin the planned `kirie dev` implementation.
174+
`resolvedUrls`, which underpin current and planned `kirie dev` behavior.
175175
- [Vite CLI](https://vite.dev/guide/cli)
176176
Reference for Vite command-line flags when Kirie chooses to expose or proxy
177177
Vite-shaped arguments.
@@ -228,5 +228,5 @@ packaging, or platform WebView bridge details.
228228
support, mise task configuration, and Execa.
229229
- When changing the platform integration web fixture, start with the Vite build
230230
guide and `@gd-kirie/ipc`.
231-
- When changing planned Kirie CLI development-server behavior, start with the
232-
Vite JavaScript API and Vite server options.
231+
- When changing Kirie CLI development-server behavior, start with the Vite
232+
JavaScript API and Vite server options.

examples/basic-ipc/export_presets.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runnable=true
66
dedicated_server=false
77
custom_features=""
88
export_filter="all_resources"
9-
include_filter="src-web/dist/index.html,src-web/dist/assets/*"
9+
include_filter=""
1010
exclude_filter="src-web/index.html,src-web/src/*,src-web/node_modules/*,src-web/package.json,src-web/tsconfig.json,src-web/vite.config.ts"
1111
export_path=""
1212
patches=PackedStringArray()
@@ -236,7 +236,7 @@ runnable=true
236236
dedicated_server=false
237237
custom_features=""
238238
export_filter="all_resources"
239-
include_filter="src-web/dist/index.html,src-web/dist/assets/*"
239+
include_filter=""
240240
exclude_filter="src-web/index.html,src-web/src/*,src-web/node_modules/*,src-web/package.json,src-web/tsconfig.json,src-web/vite.config.ts"
241241
export_path=""
242242
patches=PackedStringArray()

examples/basic-kirie-cli/export_presets.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runnable=true
66
dedicated_server=false
77
custom_features=""
88
export_filter="all_resources"
9-
include_filter="src-web/dist/index.html,src-web/dist/assets/*"
9+
include_filter=""
1010
exclude_filter="src-web/index.html,src-web/src/*,src-web/node_modules/*,src-web/package.json,src-web/tsconfig.json,src-web/vite.config.ts,node_modules/*,dist/kirie/*"
1111
export_path=""
1212
patches=PackedStringArray()
@@ -236,7 +236,7 @@ runnable=true
236236
dedicated_server=false
237237
custom_features=""
238238
export_filter="all_resources"
239-
include_filter="src-web/dist/index.html,src-web/dist/assets/*"
239+
include_filter=""
240240
exclude_filter="src-web/index.html,src-web/src/*,src-web/node_modules/*,src-web/package.json,src-web/tsconfig.json,src-web/vite.config.ts,node_modules/*,dist/kirie/*"
241241
export_path=""
242242
patches=PackedStringArray()

examples/eventa-csharp/export_presets.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runnable=true
66
dedicated_server=false
77
custom_features=""
88
export_filter="all_resources"
9-
include_filter="src-web/dist/index.html,src-web/dist/assets/*"
9+
include_filter=""
1010
exclude_filter="src-web/index.html,src-web/src/*,src-web/node_modules/*,src-web/package.json,src-web/tsconfig.json,src-web/vite.config.ts"
1111
export_path=""
1212
patches=PackedStringArray()
@@ -238,7 +238,7 @@ runnable=true
238238
dedicated_server=false
239239
custom_features=""
240240
export_filter="all_resources"
241-
include_filter="src-web/dist/index.html,src-web/dist/assets/*"
241+
include_filter=""
242242
exclude_filter="src-web/index.html,src-web/src/*,src-web/node_modules/*,src-web/package.json,src-web/tsconfig.json,src-web/vite.config.ts"
243243
export_path=""
244244
patches=PackedStringArray()

packages/cli/src/dev.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,41 @@ describe("runDev", () => {
206206
expect(launchRun?.argv).toContain("--kirie-web-url=http://127.0.0.1:5173/");
207207
});
208208

209+
it("waits for iOS simulator app installation before launch", async () => {
210+
const project = await projects.copy();
211+
212+
await installKirieConfigFixture(project, "dev-log-silent.kirie.config.ts");
213+
await installFakeXcrun(project);
214+
215+
const originalPath = process.env.PATH;
216+
process.env.PATH = `${path.join(project, "fake-bin")}${path.delimiter}${originalPath ?? ""}`;
217+
try {
218+
await runIosSimulator({
219+
appPath: "dist/kirie/ios/debug.app",
220+
bundleId: "ai.moeru.kirie.integration",
221+
cwd: project,
222+
simulatorId: "booted",
223+
});
224+
} finally {
225+
process.env.PATH = originalPath;
226+
}
227+
228+
const invocations = await readFakeXcrunInvocations(project);
229+
230+
expect(invocations.map((invocation) => invocation.argv.slice(0, 2))).toEqual([
231+
["simctl", "install"],
232+
["simctl", "get_app_container"],
233+
["simctl", "launch"],
234+
]);
235+
expect(invocations[1]?.argv).toEqual([
236+
"simctl",
237+
"get_app_container",
238+
"booted",
239+
"ai.moeru.kirie.integration",
240+
"app",
241+
]);
242+
});
243+
209244
it("rejects Kirie-owned Vite options", async () => {
210245
const project = await projects.copy();
211246
await installKirieConfigFixture(project, "dev-owned-server-port.kirie.config.ts");

packages/cli/src/run.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ export async function runIosSimulator(options: RunIosSimulatorOptions = {}): Pro
189189
stdio: "inherit",
190190
},
191191
);
192+
await waitForIosSimulatorAppInstall({
193+
bundleId,
194+
cwd: config.cwd,
195+
simulatorId,
196+
});
192197
}
193198

194199
await execa(
@@ -346,6 +351,37 @@ async function waitForAndroidPackagePid(options: {
346351
throw new Error(`Timed out waiting for Android package PID: ${options.packageName}`);
347352
}
348353

354+
// TODO: Replace command-specific polling loops with a shared helper that accepts
355+
// the command, success predicate, timeout, and polling interval.
356+
async function waitForIosSimulatorAppInstall(options: {
357+
bundleId: string;
358+
cwd: string;
359+
simulatorId: string;
360+
timeoutMs?: number;
361+
}): Promise<void> {
362+
const deadline = Date.now() + (options.timeoutMs ?? 30_000);
363+
364+
while (Date.now() < deadline) {
365+
const result = await execa(
366+
"xcrun",
367+
["simctl", "get_app_container", options.simulatorId, options.bundleId, "app"],
368+
{
369+
cwd: options.cwd,
370+
reject: false,
371+
stderr: "ignore",
372+
stdout: "ignore",
373+
},
374+
);
375+
if (result.exitCode === 0) {
376+
return;
377+
}
378+
379+
await new Promise((resolve) => setTimeout(resolve, 500));
380+
}
381+
382+
throw new Error(`Timed out waiting for iOS app install: ${options.bundleId}`);
383+
}
384+
349385
function iosLaunchOptionArgs(launchOptions: LaunchOptions | undefined): string[] {
350386
if (!launchOptions) {
351387
return [];

0 commit comments

Comments
 (0)