Commit Graph
145 Commits
Author SHA1 Message Date
waozi 5da8134ad0 Consolidate Kry language documentation 2026-08-19 18:31:28 -03:00
waozi 668f4d16f1 Document Kry language and publish benchmarks 2026-08-19 18:21:07 -03:00
waozi 2d641c1137 Draw menu bars as frame overlays 2026-08-19 17:41:19 -03:00
waozi a585f1ced5 Implement Canvas WebAudio backend 2026-08-19 16:35:44 -03:00
waozi 27ce4cbb4a Add website backend and widget matrices 2026-08-19 16:03:56 -03:00
waozi e0c588cd23 Add Linux desktop integration helpers 2026-08-19 15:47:56 -03:00
waozi 7055557bf5 CI: gate on public-HTTPS submodule URLs
A guard job (plain checkout, canonical script) fails the run when any
.gitmodules URL is not https:// — SSH URLs work only for a developer
with the right key and break fresh clones, CI and release builders
instead. make test runs the same check locally.
2026-08-19 15:28:04 -03:00
waozi dd5f9fc356 kry_std: kry_update_flow — the embeddable self-update lifecycle 2026-08-19 14:01:25 -03:00
waozi af46dc6109 kry_std: self-update primitives — download, verify, apply
kry_http grows a streaming file sink (kry_http_download) with byte and
fraction progress, sized for artifacts instead of in-memory bodies.
kry_sha256 adds dependency-free FIPS 180-4 hashing (streaming + file +
hex compare). kry_update ties them together: appcast-channel downloads
staged under XDG_DATA_HOME/LOCALAPPDATA with sha256 verification (bad
files are removed), AppImage staging that copies next to the running
image and atomically renames over it (plus re-exec in apply), and a
Windows portable swap script spawned detached from %TEMP%. Tests cover
hash vectors, verified/failed downloads via file://, and AppImage
staging; the exec'ing apply path stays untested by design.
2026-08-19 13:37:20 -03:00
waozi 845f43931e kry_std: add kry_update desktop update-check module
Appcast fetch/parse over kry_http + kry_json, semver compare, and
desktop channel detection (AppImage/Snap/Flatpak env, /usr|/opt
package installs, Windows portable). Poll-based so a frame loop can
watch it; file:// appcasts keep tests offline. Also stub
kry_http_partial in the no-libcurl branch so nothing links unresolved.
2026-08-19 13:08:54 -03:00
waozi 7b6048a9df canvas: split the backend into per-concern sources
canvas_backend.c (1882 lines) becomes canvas_window/input/draw/texture/
text/os/audio.c plus canvas_internal.h, one file per banner section the
monolith had already grown. Pure code motion: the node call-sequence
gate records an identical 413-call trace before and after.

The canvas branches in Makefile, mk/common.mk, and examples/Makefile no
longer append the backend file on top of the src/ find sweep — that
would have compiled every canvas TU twice. docs: BACKENDS.md path and
empty-TU wording, FEATURE_MATRIX.md stale 'approximated' note.
2026-08-18 22:29:08 -03:00
waozi 79d4fed6d2 dropdown: wobbled and slow clicks must select, not just pixel-perfect taps
The press-to-release drag threshold armed on any movement past 8px,
even when the popup cannot scroll - so a touchpad click's natural
wobble flipped a click into a 'drag' and silently swallowed the
selection (the 'I press Dark and nothing happens' case on the theme
screen's fixed three-option mode popup).

Arm the drag state only when the list can actually scroll, and on
release still select when a drag never moved the list (wobble there
and back). Covered by two injected-input tests: the layout test now
runs wobbled clicks, slow hold-clicks and scroll-drags from a clean
slate per scenario, and a new theme-screen test drives the stacked
mode/palette/style dropdowns exactly like the settings screen,
including a wobbled Dark press through the two-phase settings API.
2026-08-18 18:35:42 -03:00
waozi eb9967ce29 theme: drop the dedicated Aero palette, keep the style palette-agnostic
The Aero widget style derives its glass tints from whichever palette is
active, so a 13th palette entry was redundant. Remove THEME_AERO (and
its ini mirrors, locale label and picker slot); the style now defaults
to Sky. Saved theme ids beyond the shrunken count normalize through the
existing out-of-range fallback.
2026-08-18 18:08:54 -03:00
waozi 54a71e6b97 dropdown: flip tall popups above the button when space below runs out
dropdown_menu_layout sized a clamped popup from whichever side had more
room, but only honored opening upward when the caller passed the open_up
out-param - and no caller did. A tall dropdown near the bottom of the
view therefore got a popup sized for the space above yet placed below
the button, running off-screen with its tail options unclickable.

Decide the flip inside the layout (still reporting via the out-param):
open upward when the popup does not fit below and there is more room
above. Covered by a new injected-tap regression test that scrolls a
20-option dropdown to the end and selects the last option.
2026-08-18 17:47:47 -03:00
waozi 4669ffb1b3 canvas: implement the HTML5 Canvas2D Tier A backend
src/backend/canvas_backend.c now exists: the full required surface
against a 2d canvas context through EM_JS. Draws are canvas paths,
textures are offscreen canvases (putImageData/drawImage stay
synchronous), text is glyph atlases rasterized from FontFace data
(EM_ASYNC_JS awaits face loading), input flows through the
KryonBackendRaw_* hooks fed by JS listeners, and the shared front-ends
(kry_instance, kry_screenshot, kry_input) are honored via the
KryonRaylibBackend_* seam names. Images decode through kryon's own
kry_sw PNG decoder; no raylib anywhere in the link.

The app while-loop survives the browser via -sASYNCIFY with a frame-end
yield. make canvas-test builds a complete app with this backend under
emcc and verifies the draw-call sequence in node against a recording
Canvas2D shim (glyph rasterize, atlas upload, and per-glyph drawImage
included); it skips cleanly where emcc is absent.

Approximations documented in BACKENDS.md: square rounded rects,
mid-radius ring strokes, no clipboard bridge, alpha-only tint.
2026-08-18 17:06:20 -03:00
waozi 947c0cf506 build: keep the canvas backend out of native builds
The find-based SRCS sweep pulled src/backend/canvas_backend.c into every
native build whenever the file is present, and its sources #error on
native compilers. Filter it unless KRYON_BACKEND=canvas, which already
adds it explicitly.
2026-08-18 16:55:59 -03:00
waozi 356b080ce6 tools: aero_shot renders the themed widget showcase to PNG
cmd/aero_shot draws one frame of every themed control (titlebar, tabs,
buttons, field, dropdown, slider, toggle, checkbox, progress, radios,
spinbox, glass panel) under any palette, mode and style, captures it
through the armed pre-swap readback and writes a PNG with kryon's own
writer. make aero-shot builds it; make aero-shots renders the
palette/mode/style reference matrix into build/<platform>/shots.
2026-08-18 16:55:59 -03:00
waozi ede20eb0e6 build: link kry_sw_png into the KRB logic and asset tests
krb_logic_test and krb_asset_test compile kry_sw.c directly; without
the new PNG decoder object they fail to link since b_texture calls
kry_sw_png_rgba.
2026-08-18 12:48:00 -03:00
waozi b76823e24d kry_sw: decode PNG assets for texture draws
The software rasterizer had no asset decoder, so every path-based
texture drew a tinted placeholder rectangle — headless previews and the
web player rendered pictures as colored boxes. Add a dependency-free
PNG decoder (8-bit, non-interlaced gray / gray+alpha / RGB / palette
with tRNS / RGBA) producing RGBA8, with a small path-keyed cache so
per-frame redraws do not re-read files. Undecodable assets keep the
placeholder so layout stays visible. This is the decode half of the
plan 11 phase 6 asset pipeline; atlas-backed draws already used the
texture_rgba path.
2026-08-18 12:40:41 -03:00
waozi 5351b21eaa ui: build and test the secondary window paths
The secondary-window presenter had no callers and no build coverage:
nothing compiled the UI_WINDOW_HAVE_SDL branch (the Wayland and
SDL-bundled path), and no test exercised the public API at all, so
recent presenter fixes could only be validated by reading the code.

- Compile ui_window.c with -DUI_WINDOW_HAVE_SDL in make test so the SDL
  presenter cannot rot uncompiled.
- Add a ui_window smoke test covering the headless contract: Open fails
  cleanly without a main window, and every entry point is NULL-safe.
- OpenUIWindow now requires IsWindowReady() on both the X11 and SDL
  paths: the content texture allocation needs the app's live GL context.
- Document the -DUI_WINDOW_HAVE_SDL opt-in in ui_window.h.
2026-08-18 12:40:23 -03:00
waozi 681e601818 build: always index static runtime archives 2026-08-17 21:50:54 -03:00
waozi bc0a3999d0 ui: enforce cross-lowering text input latency 2026-08-17 20:26:30 -03:00
waozi d20c5369e5 build: search FreeBSD ports libraries 2026-08-17 12:50:05 -03:00
waozi c8e5d51517 test: build capability cartridge fixture 2026-08-17 12:44:31 -03:00
waozi 81ec1edda8 build: apply GIO notification include flags 2026-08-17 12:30:08 -03:00
waozi de2e896de8 ci: install and link GIO notifications 2026-08-17 12:18:36 -03:00
waozi 52502d81a6 release: automate versions and publish all tools 2026-08-17 12:17:00 -03:00
waozi cce6e637ee ui: add scroll-safe multiline text selection 2026-08-17 11:54:01 -03:00
waozi cafd406e89 krb caps: reference host backends — storage, audio
src/krb/krb_caps.c: flat-file key/value storage (KRB_CAP_STORE_DIR,
atomic replace-and-append), KrbFn adaptors, and KrbCapInstallDefaults
binding storage.get/set + audio.play/stop. The raylib surface host
installs a real audio hook (LoadSound/PlaySound/StopSound) via
constructor, so cartridges on desktop get working audio; headless
hosts return -1 rather than pretending. tests/krb_caps_test.c covers
install count, set/get/replace/missing round-trip, and the audio
hook; wired into make test. All suites green; 11/11 cross-engine
byte-identical.
2026-08-17 08:23:56 -03:00
waozi f8d8c7fd1a k2g: .kry -> Go backend on the shared Kir frontend
Third backend alongside k2c/k2b: k2g lowers a KirProgram to Go source
that drives a Go kryon runtime (the cgo surface binding app uses), so
Go-native apps can be written in .kry. One frontend, three backends —
kry -> kir -> {c, krb, go}.

v1 fully translates the declarative subset: state blocks (Go struct +
instance), app metadata (generated main loop), frames, widget/surface
calls (rt.-qualified), compound literals (Vector2/Rectangle/Color),
scalar casts, hex/float literals, and state-field references including
address-of for scroll offsets. Imperative constructs are best-effort;
unsupported ones are emitted as commented TODOs rather than miscompiled.

Usage: k2g [--no-main] [--pkg NAME] [--runtime IMPORT] --root DIR -o DIR file.kry ...
Smoke-tested by tests/k2g_syntax_test.sh in 'make test'.
2026-08-16 23:51:09 -03:00
waozi 84bd26de20 krb v2: text input — TEXTINPUT node + typed-codepoint vtable path
New node type 13: bounded field drawing the mounted CSTR with a
blinking caret when focused (click to focus). Typed input flows through
the new optional KryBackend.text_key (codepoints, 0x08 backspace):
kry_sw queues via KrySwText (drained per frame by Advance), the raylib
surface backend maps GetCharPressed, SDL maps SDL_TEXTINPUT/BACKSPACE,
krb-web exports krb_web_text from keypress events. UTF-8 runes append
and strip correctly. k2b compiles TextField(x,y,w,h,&state.field).

Verified: click-focus, typing with backspace, and that unfocused
fields ignore keys.
2026-08-16 22:06:53 -03:00
waozi ddcf455dd3 k2b: decode png/jpg/bmp/webp and embed as cartridge pixels
stb_image (vendored with raylib) decodes referenced Picture() files at
compile time; decoded RGBA8 goes in as kind 0 and renders through
texture_rgba in every engine. KRAW stays for hand-made raw pixels;
undecodable files (wav/ogg/fonts) remain opaque kind 2 blobs for
host-side unpacking. Verified: png cartridge renders after the source
file is deleted.
2026-08-16 21:42:09 -03:00
waozi 3b92292e19 renderers: web player opens any .krb + CI builds per-platform downloads
- krb-web is now a player: drop or pick a .krb, it writes to MEMFS
  and boots the cartridge (krb_web_start export); no preload, the
  bundle is a generic renderer. Drag-drop + file picker + canvas
  mouse with correct scaling. Serving it anywhere gives the web a
  KRB renderer.
- .github/workflows/renderers.yml: matrix builds krb-run binaries
  (linux, windows mingw cross, macos) and the web player; artifacts
  on every push, attached to releases on tags.
2026-08-16 21:37:28 -03:00
waozi f17bc26987 krb v2: embedded asset section + texture_rgba blit
Cartridges can now carry their pictures: a v2 asset section (header
offset 28 = asset_bytes) after controls[] holds a directory of
20-byte entries (path, absolute data offset, size, kind, w, h) plus
blobs. KrbAssetFind looks paths up; a PICTURE node whose path is
embedded renders from cartridge pixels through the new optional
KryBackend.texture_rgba (nearest-neighbor scaled, tint-modulated,
clipped) — kry_sw implements it, so krb-run, krb-web, and krb-sdl all
get embedded assets. Non-embedded paths still fall back to host
texture loading. kinds: 0 raw RGBA8, 1 reserved for the glyph atlas.

tests/krb_asset_test.c proves lookup + 2x2->8x8 scaled, tinted blit
with correct bounds; spec updated in KRB_FORMAT.md. k2b embedding of
decoded image files is the follow-up.
2026-08-16 21:29:13 -03:00
waozi 89dc220fda krb v2: in-cartridge logic VM + circle/ring geometry nodes
The plan-07 core: cartridges stop being static pictures.

- New v2 opcodes: a 16-deep int stack machine (PUSH_CONST/PUSH_PATH/
  POP_STORE, ADD..GE, JMP/JZ, TIME) plus OP_DRAW_NODE so UI can be
  conditional on mounted state. Loader accepts v1 and v2; k2b now
  writes version 2.
- New node types CIRCLE (center+radius) and RING (annulus), the shapes
  the inbe breath visualizer needs; k2b parses DrawCircleV/DrawRing
  (with (Color){r,g,b,a} literals). KryBackend gains optional circle/
  ring entries — implemented in kry_sw, the raylib surface backend,
  the null backend, and forwarded+logged by the recorder.
- tests/krb_logic_test.c: hand-assembled v2 cartridge proving counter
  increments per frame, conditional node visibility across frames,
  circle/ring rasterization bounds, and TIME. Engine golden test passes
  unchanged on v2 output (render back-compat).
- KRB_FORMAT.md documents v2 and the R>=0x80 theme-slot color caveat.
2026-08-16 20:37:44 -03:00
waozi 8952cbf3af krb-sdl: SDL2 desktop host for KRB cartridges
Plan 11 phase 7 (pulled forward as the Android-template host):
kry_sw renders, SDL2 owns window/input/presentation via a streaming
RGBA texture. --png renders one frame through the renderer and reads
it back, for headless conformance under SDL_VIDEODRIVER=dummy.

Verified: SDL software-renderer readback of examples/02_buttons.kry at
400x300 is byte-identical (sha256) to the native golden frame — native,
wasm web, and SDL now render the same image.

make krb-sdl (pkg-config sdl2; on omega PKG_CONFIG_PATH points at
~/.local/sdl2 automatically in the rule).
2026-08-16 20:23:47 -03:00
waozi f2e86d9f0d krb-web: native web engine — kry_sw compiled to wasm, blitted to ImageData
Plan 11 phase 3, wasm-first variant (pixel-identical to native):

- cmd/krb-web/main.c: emscripten host running the KRB runtime + kry_sw
  rasterizer; each frame blits the RGBA buffer into an ImageData via
  EM_ASM. Cartridge preloaded at /app.krb, canvas mouse events fed back
  through exported krb_web_mouse/krb_web_button.
- cmd/krb-web/shell.html: minimal shell wiring Module.canvas and input.
- cmd/krb-web/node-capture.js: pre-js for the KRB_WEB_ONESHOT node
  build; stubs a canvas 2D context and dumps the blitted frame to stdout
  so the wasm blit path is testable without a browser.
- make krb-web KRB=examples/xx.kry builds the cartridge + bundle
  (needs emcc on PATH, e.g. source ~/emsdk/emsdk_env.sh).

Verified: node oneshot capture of examples/02_buttons.kry at 800x600 is
byte-identical (sha256) to the native krb-run render; page loads and
runs in a browser.
2026-08-16 20:21:36 -03:00
waozi 6a0591086a krb: kry_sw software rasterizer engine + headless conformance harness
Plan 11 phases 1-2 core:

- src/backend/kry_sw.c: portable software rasterizer behind the
  KryBackend vtable. RGBA8 target with RGB565 conversion, clip stack,
  input injection, theme slots, public-domain font8x8 text (glyph-atlas
  pipeline replaces it later without interface changes).
- src/backend/kry_backend_rec.c: recording backend that logs the
  cartridge draw-call stream while delegating to an inner engine.
- cmd/krb-run: headless cartridge runner; renders one frame to PNG
  (dependency-free writer, stored deflate) and/or dumps the call stream.
- tests: kry_sw unit test plus tests/krb_engine_test.sh golden
  conformance over examples/02_buttons.kry (sha256 goldens, refresh
  with KRB_ENGINE_REGOLDEN=1), wired into make test / make tools.
2026-08-16 20:05:20 -03:00
waozi c670587788 ksync: harden crypto, exports, JSON, delete, and sync transport
- Add shared ksync_crypto module: SHA-256, HMAC-SHA256, PBKDF2-SHA256,
  ChaCha20-Poly1305 (RFC 8439), hex helpers, random bytes; all verified
  against RFC test vectors in tests/ksync_crypto_test.c
- Encrypted account exports (v2): PBKDF2 (600k iterations) +
  ChaCha20-Poly1305, passphrase-protected import/export APIs; the v1
  plaintext format remains importable
- DeleteKsyncSyncAccount no longer transmits the private key: it signs
  a challenge against /api/v1/account/delete and falls back to the
  legacy delete-with-key endpoint on 404/405
- JSON writer escapes control characters (including \b, \f, \uXXXX);
  reader now decodes escapes, rejects substring keys and keys embedded
  in string values
- Token expiry accounts for server clock skew (server_time in the
  login response, clamped to +/-24h)
- Optional retry with exponential backoff for transport errors, 429,
  and 5xx via retry_max/retry_delay_ms/sleep_ms config fields
- Opt-in end-to-end payload encryption (encrypt_payload flag plus
  Wrap/UnwrapKsyncSyncPayload) derived from the account private key
2026-08-16 19:54:53 -03:00
waozi ccec103ebc k2b: report call kinds the KRB vocabulary cannot express
A cartridge that comes out thin (inbe's pet screen: an egg widget,
locale text, Paragraphs) was silently missing everything k2b cannot
lower. The builder now tracks dropped call kinds per file and prints
one stderr line: 'k2b: <file>: N call kinds not in KRB: Paragraph x2
draw_egg x1 ...' - pet_screen.kry reports seven, which is the honest
content of the gap.
2026-08-16 07:52:09 -05:00
waozi 2276b7372f kry_sfs: the live engine as a synthetic file system + real input injection
Everything kryon owns is now addressable and interactable through one
file-tree surface: /info, /theme tokens, /input (mouse position, buttons,
keys, text, wheel - readable and writable), and /widgets (the live
ui_inspect tree with per-widget kind/text/bounds/source plus a tap that
clicks for real).

Input injection is new underneath: kry_inject keeps a pure-state event
queue whose edges derive at each pump (raylib-style previous-vs-current),
and the generated backend wrappers consult it before platform input, so
injected events reach app code that queries GetMousePosition or
IsMouseButtonReleased directly. KryonInjectPump runs from
UpdateKeyPlatformState; injected mouse positions serve for one frame
(two for taps) so the real mouse keeps working. KryTTap/KryTType/
KryTKey in kryon_test.h now inject for real instead of recording
strings.

ui_inspect gained SetUIInspectVisible so the SFS can record the widget
tree without arming the click-stealing overlay. tests/sfs_test.c covers
listing/reading every namespace, edge semantics, tap-to-UIHandleClick,
and the KryT helpers; wired into make test (suite green).
2026-08-15 11:24:10 -05:00
waozi b44b946979 kryon owns the transport, not the vendor: drop kry_zai
kry_json + kry_http are provider-neutral stdlib pieces; a z.ai GLM
client (endpoint, model, key handling, wire format) is harness logic and
moved to krait (native_ai.c). inbe and other apps no longer link a
specific commercial LLM vendor.
2026-08-15 06:56:29 -05:00
waozi a502700ed0 kry std: kry_json, kry_http, kry_zai — the AI-harness foundation
- kry_json: dependency-free recursive-descent parser (objects/arrays/
  strings with \u escapes + surrogate pairs, numbers, bools) and a
  compact KryJsonBuf emitter. Depth-capped against hostile input.
- kry_http: async libcurl-easy client (HAS_LIBCURL) on the existing
  KryThread worker pattern — POST-JSON/GET, poll for state, body owned
  by the request. Stub when curl is absent. file:// counts as success
  (HTTP code 0), which the hermetic tests use.
- kry_zai: z.ai GLM chat-completions client (OpenAI-compatible) on the
  two above. Coding-Plan endpoint default, glm-4.6, ZAI_API_KEY/
  ZAI_BASE_URL/ZAI_MODEL env with an in-process override; thinking
  disabled for fast answers. Live test gated on ZAI_API_KEY.
- mk/vendor.mk: KRYON_CURL_TRANSITIVE_LDLIBS (brotli/zstd) the vendored
  static curl needs at final link.
2026-08-14 22:06:36 -05:00
waozi b8ca07feca Add cross-platform notification helpers
One raylib-style API in notification.h (SendNotification,
SendNotificationEx with tag/id/priority, CancelNotification,
CancelAllNotifications, permission probing, SetNotificationAppName),
three real backends in src/notification/notification.c:

- Android: pure JNI through the native activity -- channels on API 26+,
  legacy Builder priorities on 21-25, areNotificationsEnabled /
  POST_NOTIFICATIONS runtime request on 24+/33+. No Java-side code
  required, so any kryon app gets notifications unchanged.
- Web: the browser Notification API via EM_JS, with an id registry so
  cancel works.
- Desktop Linux: org.freedesktop.Notifications over GDBus
  (KRYON_NOTIFICATION_GDBUS + gio-2.0; mk/vendor.mk exports the probe
  flags). urgency + desktop-entry hints from the priority and app name.
- Everything else: honest stub (supported=0).

Verified: desktop path end-to-end against a live xfce Notifyd
(supported=1 send=1), stub branch syntax-clean, full kryon test suite
green.
2026-08-14 21:32:38 -05:00
waozi 37d1443a2d Remove legacy build/bin tool aliases; export canonical K2C for consumers
The LEGACY_K2C/K2IR/K2B/KT/KRYON_CMD rules copied the per-platform
build/<platform>-<arch>/bin tools to the old top-level build/bin paths.
inbe and uku hardcoded those legacy paths, which is the only reason the
aliases existed.

- mk/vendor.mk now exports the canonical tool paths (KRYON_TOOLS_BIN,
  K2C) using the same platform/arch mapping kryon itself uses, so
  consumers include one file instead of hardcoding paths.
- New phony 'k2c' target builds the compiler by name; consumers call
  'make -C  k2c'.
- Legacy alias variables and rules deleted.
2026-08-14 14:12:41 -05:00
waozi e41e5bceaf k2b: migrate to the shared Kir frontend — one frontend, two backends
k2b drops its private raw-.kry parser (k2b_parse.c + k2b.h deleted). It now
parses via kir_parse_file() — the SAME frontend k2c uses — and lowers
KirModule to .krb + C host:
- collect_state consumes structured KirStateField {name,type,init} directly
  (the decl-string re-parsing is gone); array types convert to C declarator
  order in the emitted host globals.
- collect_widgets tracks block depth on the fly (KirStmt has no depth field)
  for button-handler capture.
- app metadata comes from KirAppMeta; module/no_main flow through params.
- Makefile: k2b links kir.c + kir_parse.c.

Verified: 02_buttons.kry -> 12 nodes, magic 4b524200 (identical output);
krb_cartridge_test + make test green; kryon-preview cartridge renders.
2026-08-14 09:24:09 -05:00
waozi 07222de4f8 k2c: Kir is the only pipeline — delete the entire legacy compiler
The legacy kc line-matcher is gone. k2c is now exclusively:
  .kry -> kir_parse_file() -> KirProgram -> k2c_lower() -> .c/.h

Deleted (the whole legacy pipeline):
- cmd/k2c/kc.c (parse_kry line-matcher, 3300 lines)
- kc_codegen.c (write_generated/write_body_line), kc_defer.c (apply_defers
  brace-counting splice), kc_ast.{c,h} (Phase-1 AST reconstruction),
- kc_ir.c, kc_resolve.c, kc_macros.c, kc_diag.c, kc_project.c, kc_util.c,
- kc_internal.h, and the --emit/--dump-ast/--kir flags.

New k2c main.c is a thin CLI over kir_parse_file + k2c_lower. The lowering
implements the essential translation rules on Kir statements:
- ':=' decls -> __auto_type; typed decls -> 'T x = e;' with {0} zero-init
- multi-assign temps (__kryon_assign_<line>_<k>, temps-first ordering)
- nil -> NULL rewrite; unused X -> (void)X;
- if/else-if/else chains with parens + close-suppression before else
- while/for/switch headers with parens; case at parent indent
- defer registered per scope, spliced LIFO at block close and return
- call statements wrapped in PushUIInspectSource/PopUIInspectSource with
  source spans; goto/labels; state fields with C array declarator order
- screens named <Name>_kry_draw; args 'name: Type' -> 'Type name';
  header guards K_<PATH>_H with _H suffix

tests/k2c_syntax_test.sh rewritten for the Kir-based output (fixture +
assertions + compile check of the generated C). make test green.
2026-08-14 06:59:58 -05:00
waozi 1c5ad13152 k2c: Kir→C lowering skeleton (--kir flag, structurally valid output)
Stage 2 start: k2c now has a --kir flag that parses .kry via the shared
kir_parse_file frontend and lowers KirProgram to .c/.h via k2c_lower.c.

The lowering currently produces structurally valid C (function definitions,
body statements, header guards, includes) but does NOT yet reproduce kc's
byte-for-byte output (PushUIInspectSource wrapping, __auto_type temps, defer
splicing, indent recompute, rewrite_kry_expr, module prefixing). Those land
fixture-by-fixture against the k2c_syntax_test.sh oracle.

The legacy pipeline (parse_kry + write_generated) remains the default path.
k2c links kir.c + kir_parse.c; make test green.
2026-08-13 22:18:22 -05:00
waozi 69eb7b3629 Extract Kir parser into shared kir_parse.c (prerequisite for k2c/k2b backends)
The .kry -> Kir parser is now a shared library (cmd/kir/kir_parse.c +
kir_parse.h) exposing kir_parse_file(path, root) -> KirProgram*. Both k2c
(the C backend) and k2b (the krb backend) can link it to share one frontend.

k2ir/main.c is now a thin wrapper: parse + KirProgramDump to a .kir file.
The output path uses the module's source_path to preserve directory structure.

k2ir_test passes; make test green. The k2c backend (Stage 2) can now link
kir_parse.c to get Kir input.
2026-08-13 22:07:11 -05:00
waozi 2f11e1e773 Rename kc to k2c (kry-to-C compiler)
The .kry->C compiler is now k2c, not kc. This is the first step toward making
Kir the single source of truth (k2c and k2b will both lower from Kir).

- cmd/kc/ -> cmd/k2c/ (directory moved; internal file names unchanged).
- Makefile: KC -> K2C, LEGACY_KC -> LEGACY_K2C, build/bin/kc -> build/bin/k2c.
- tests/kc_syntax_test.sh -> tests/k2c_syntax_test.sh (default binary updated).
- examples/Makefile: KC -> K2C; the two stale --emit-krb lines now use k2b.
- make test green (k2c_syntax_test passes via k2c).
2026-08-13 20:09:53 -05:00