Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d38ed4111 | ||
|
|
9ccdf55f1e | ||
|
|
f428bd1d60 | ||
|
|
70ea8d02ab | ||
|
|
ad401376ef | ||
|
|
6f24fc5099 | ||
|
|
c3f312d63d | ||
|
|
886152ddf6 | ||
|
|
1881d3fdcd | ||
|
|
39fc01dbe6 | ||
|
|
9039dabef1 | ||
|
|
2b072674e5 | ||
|
|
2128cd310d | ||
|
|
e03f548923 | ||
|
|
bc97010372 | ||
|
|
b151dfc2cc | ||
|
|
94c7f0da20 | ||
|
|
13ea94d18d | ||
|
|
aa427a6772 | ||
|
|
2e4924726f | ||
|
|
70fd19bd06 | ||
|
|
9c57c99591 | ||
|
|
01e0a4b341 | ||
|
|
6fc41dd50f | ||
|
|
0e74f0b5e0 | ||
|
|
b66c054b3f | ||
|
|
4e1b7dc586 | ||
|
|
1fabf1e49c | ||
|
|
6ed02bca7d | ||
|
|
bfbaa1bb73 | ||
|
|
1603c58b1b | ||
|
|
216d56bf29 | ||
|
|
caad34ba05 | ||
|
|
58db559a7d | ||
|
|
fafc8bedb2 | ||
|
|
63d556914c | ||
|
|
77c920e0c7 | ||
|
|
efd5fc2dcd | ||
|
|
bfae215a20 | ||
|
|
d08f3efc44 | ||
|
|
57c6bc1b9a | ||
|
|
66e45bf882 | ||
|
|
e5da57ef3f | ||
|
|
4e55fd44f1 | ||
|
|
bfea2cca93 | ||
|
|
1bb872d4c6 | ||
|
|
53c9c090a8 | ||
|
|
73373344b8 | ||
|
|
27287d967d | ||
|
|
3b13f3d407 | ||
|
|
9f42816441 | ||
|
|
6fd1dbbb27 | ||
|
|
466b5614d3 | ||
|
|
54c3fce061 | ||
|
|
4615f6d558 | ||
|
|
42965e39cd | ||
|
|
88a81baf27 | ||
|
|
f45362ef1b | ||
|
|
d9b20cc05c | ||
|
|
d468bbd351 | ||
|
|
02a3ed19eb | ||
|
|
ae88371737 | ||
|
|
9d985b69d1 | ||
|
|
2f7802661a | ||
|
|
bd08f39532 | ||
|
|
ab99d83b7a | ||
|
|
ad02c7d1cf | ||
|
|
af64e57a1d | ||
|
|
3efed6e1f4 | ||
|
|
02c8c3793b | ||
|
|
baab6abf7a | ||
|
|
c79a92725e | ||
|
|
7c490d8fdf | ||
|
|
556bdd3552 | ||
|
|
c7ed67e2dc | ||
|
|
f4fac28598 | ||
|
|
125484d157 | ||
|
|
e2b0b260d4 | ||
|
|
08eb898ee3 | ||
|
|
aa36952508 | ||
|
|
028b2db469 | ||
|
|
3c43b92209 | ||
|
|
0a92b02cdf | ||
|
|
ef652f8179 | ||
|
|
09702e144d | ||
|
|
f6e340b2b7 | ||
|
|
b6a7743aca | ||
|
|
1d1eb49946 | ||
|
|
7a81e00d5e | ||
|
|
e83dae0e70 | ||
|
|
c473e276cd | ||
|
|
a18e6bf419 | ||
|
|
7d65025806 | ||
|
|
1eb5fd3de2 | ||
|
|
ccbad38a60 | ||
|
|
4097ce5d79 | ||
|
|
4b77d513a1 | ||
|
|
a733f87cba | ||
|
|
d0993d71ad | ||
|
|
b5f4ebfa16 | ||
|
|
f1dc2a1dff | ||
|
|
7d18f5089d | ||
|
|
900850f1a9 | ||
|
|
d30e918704 | ||
|
|
736882b1bd | ||
|
|
7a6b8207e1 | ||
|
|
1dab289a8f | ||
|
|
11324d6ece | ||
|
|
3818deacec | ||
|
|
2325a89629 | ||
|
|
d23b515003 | ||
|
|
5b43aa3c3d | ||
|
|
0b8aadc911 | ||
|
|
63bd330b81 | ||
|
|
af81a9a23a | ||
|
|
b6f405010e | ||
|
|
7ad56a3d3e | ||
|
|
f11c8b1174 | ||
|
|
860cc9af13 | ||
|
|
11b013134c | ||
|
|
269a277103 | ||
|
|
01522177f3 | ||
|
|
76fdecaccd | ||
|
|
5595bd70df | ||
|
|
7260d62662 | ||
|
|
a6473d2adf | ||
|
|
d631050d0d | ||
|
|
5d4ab56ed8 | ||
|
|
7b9f01b870 | ||
|
|
690c0db1bb | ||
|
|
019de0a0d6 | ||
|
|
3c11971227 | ||
|
|
af43d15d63 | ||
|
|
75e5d449b3 | ||
|
|
e58d9194a5 | ||
|
|
a84907925a | ||
|
|
12380d75ab | ||
|
|
43cd7f3908 | ||
|
|
7389a549cd | ||
|
|
17c9564fbd | ||
|
|
398c87020b | ||
|
|
35577f8fa6 | ||
|
|
4ef4081b52 | ||
|
|
3c08c08edc | ||
|
|
419899fd3b | ||
|
|
d3154ea5a0 | ||
|
|
782ad3d24a | ||
|
|
fdf38893ea | ||
|
|
bfd50cdf62 | ||
|
|
e277757410 | ||
|
|
268888ff95 | ||
|
|
17fbd99469 | ||
|
|
e09048a3b3 | ||
|
|
2d1759f560 | ||
|
|
ed470b98fe | ||
|
|
43ae482eb3 | ||
|
|
1ef26f4d79 | ||
|
|
7b5e324779 | ||
|
|
55db65df1d | ||
|
|
7216521a43 | ||
|
|
841b7e9bfc | ||
|
|
a78d30c778 | ||
|
|
31456658f2 | ||
|
|
81ff4593ae | ||
|
|
4fe2486539 | ||
|
|
278b115944 | ||
|
|
b86a904a0a | ||
|
|
1f8fd4b8d0 | ||
|
|
fbbe884b27 | ||
|
|
7fa42e6785 | ||
|
|
a128a47328 | ||
|
|
09d066216a | ||
|
|
4b6a2def2d | ||
|
|
47952f78e5 | ||
|
|
31b0f8a4bf | ||
|
|
4ebbf0d691 | ||
|
|
163a0e5e88 | ||
|
|
0be7d77a49 | ||
|
|
e6ad9d0991 | ||
|
|
c908342167 | ||
|
|
1f094bf922 | ||
|
|
bed1b70504 | ||
|
|
7bc8c17c0a | ||
|
|
99833a0b8c | ||
|
|
18e79b36fd | ||
|
|
f0529e8234 | ||
|
|
6712e5db0c | ||
|
|
2b3d10148e | ||
|
|
dda2d2e894 | ||
|
|
475476ebfc | ||
|
|
c5482abf97 | ||
|
|
fab864ea17 | ||
|
|
25e703aeda | ||
|
|
7b18c1d8be | ||
|
|
5d090d0e4e | ||
|
|
e77b982aa0 | ||
|
|
ab3919c04b | ||
|
|
45309a5b6c | ||
|
|
7930aa9914 | ||
|
|
6eb166e377 | ||
|
|
7c6d5a128d | ||
|
|
98c2c6ef6f | ||
|
|
6c5da2dee3 | ||
|
|
33874fd8cb | ||
|
|
1f36722f3c | ||
|
|
06b21c4d67 | ||
|
|
06d1c49694 | ||
|
|
bbe4f08d85 | ||
|
|
73deeeaca4 | ||
|
|
1007f934f9 | ||
|
|
a4138169aa | ||
|
|
677be34dbb | ||
|
|
e54c7fdca6 | ||
|
|
6ef450d90d | ||
|
|
edcb5f8302 | ||
|
|
99c819fa88 | ||
|
|
c54c90edcb | ||
|
|
00b27d9804 | ||
|
|
d7b92a5aaf | ||
|
|
890eb99381 | ||
|
|
c4cc79a107 | ||
|
|
dd3895b2a0 | ||
|
|
87ac93168b | ||
|
|
7827f0cda4 | ||
|
|
b45cab3719 | ||
|
|
56354be0f2 | ||
|
|
37f85b8b4f | ||
|
|
6483eeff03 | ||
|
|
f9d2b03579 | ||
|
|
0e724f6484 | ||
|
|
2b05b9e41d | ||
|
|
89d5735e06 | ||
|
|
912109b58c | ||
|
|
d47ea26fed | ||
|
|
0fd81dff0d | ||
|
|
f394a4c6d4 | ||
|
|
5ae1079708 | ||
|
|
5dca47fd0e | ||
|
|
9eac5812be | ||
|
|
dc91713e77 | ||
|
|
2955e44e05 | ||
|
|
8564441d2d | ||
|
|
b44b78c2d4 | ||
|
|
22b4e3e4a3 | ||
|
|
5188d17398 | ||
|
|
16742b4670 | ||
|
|
878b4638e7 | ||
|
|
96a7312a81 | ||
|
|
b05e5314e4 | ||
|
|
576ac323c5 | ||
|
|
d8e0209494 | ||
|
|
5b0482ce08 | ||
|
|
221e3090a4 | ||
|
|
0707f7f530 | ||
|
|
4b6fb732ce | ||
|
|
a2f5802933 | ||
|
|
fbf3e1ed72 | ||
|
|
e27ceb65c8 | ||
|
|
a92f9c8c6b | ||
|
|
7b6028b86c | ||
|
|
90a951c7aa | ||
|
|
7aedf02555 | ||
|
|
c3d3441f02 | ||
|
|
d049726f05 | ||
|
|
6a5d9e11a4 | ||
|
|
0af6d263d9 | ||
|
|
59de0d5b2e | ||
|
|
662a0b1063 | ||
|
|
291e287178 | ||
|
|
92130510d8 | ||
|
|
71700229a3 | ||
|
|
e4e42f4880 | ||
|
|
14a5383b34 | ||
|
|
31c38e8b93 | ||
|
|
5d2bbdadc6 | ||
|
|
49d94d7430 | ||
|
|
adf7431ad4 | ||
|
|
28562a0a36 | ||
|
|
9874794062 | ||
|
|
9ac1270bb5 | ||
|
|
664095e190 | ||
|
|
1d127c6503 | ||
|
|
f250bcb0c8 | ||
|
|
0e8b5e4725 | ||
|
|
cb3d4c9079 | ||
|
|
87059a67bf | ||
|
|
77016527bc | ||
|
|
803d5266f0 | ||
|
|
aaed0c2d14 | ||
|
|
081495a671 | ||
|
|
b0e3a807fa | ||
|
|
3302c98e32 | ||
|
|
989271d3e1 | ||
|
|
4200187a00 | ||
|
|
f7fc3ff223 | ||
|
|
804d86f09d | ||
|
|
2df0197470 | ||
|
|
0627f7dd37 | ||
|
|
06de5b2721 | ||
|
|
59ed4e766b | ||
|
|
8e12645767 | ||
|
|
1f67f8df52 | ||
|
|
579ebeb531 | ||
|
|
f060ec3988 | ||
|
|
bd4bbd4f73 | ||
|
|
69f83c616a | ||
|
|
d828c0817b | ||
|
|
f82cf222ed | ||
|
|
e9e93b609e | ||
|
|
e5d2a49b45 | ||
|
|
bde0598680 | ||
|
|
8d86507d82 | ||
|
|
56a269ff74 | ||
|
|
61c6bab406 | ||
|
|
8050af9df6 | ||
|
|
bd4b7b107e | ||
|
|
88a2f31385 | ||
|
|
016cb75c18 | ||
|
|
fafa785611 | ||
|
|
d9f960ee26 | ||
|
|
eef1c98a1a | ||
|
|
4cdb0394b7 | ||
|
|
9f8fc5bd48 | ||
|
|
ca8e50bb12 | ||
|
|
d2dd96cf32 | ||
|
|
79688b9f4c | ||
|
|
0e73811320 | ||
|
|
df0112dcf5 | ||
|
|
ab8a354038 | ||
|
|
a19f1ee6ff | ||
|
|
cbdec667c6 | ||
|
|
c58d4e602e | ||
|
|
1266c5378e | ||
|
|
a974412497 | ||
|
|
af112e4d25 | ||
|
|
2d78b1ac7c | ||
|
|
13bbb79cf0 | ||
|
|
63ba83aca6 | ||
|
|
5cf7366861 | ||
|
|
51a93a19d9 | ||
|
|
621b181f34 | ||
|
|
747472ecb2 | ||
|
|
f49e072148 | ||
|
|
36d6f99de9 | ||
|
|
28b5ab04ca | ||
|
|
d125ce4f2d | ||
|
|
0e1f20e298 | ||
|
|
53add1473d | ||
|
|
53bf4f2eb2 | ||
|
|
11bcaf4ee0 | ||
|
|
19d5411a24 | ||
|
|
843bd6fe66 | ||
|
|
b8efa68601 | ||
|
|
e1989a20aa | ||
|
|
0377b9181b | ||
|
|
00fabf1981 | ||
|
|
f992a9180b | ||
|
|
41df5d5dba | ||
|
|
7a1bf94ceb | ||
|
|
9ae46c627e | ||
|
|
f5390d85a5 | ||
|
|
a1260b624f | ||
|
|
50f3a8ed6d | ||
|
|
3599bad770 | ||
|
|
328b5aff3f | ||
|
|
46a175fa34 | ||
|
|
550e00de88 | ||
|
|
9dcecd6a50 | ||
|
|
f33b8a191d | ||
|
|
7e7f0329d4 | ||
|
|
f11cbc80fb | ||
|
|
f107b2a0df | ||
|
|
82ac24d32f | ||
|
|
573b632c41 | ||
|
|
6339dab94c | ||
|
|
85cd06159f | ||
|
|
305053dec5 | ||
|
|
ecde810b97 | ||
|
|
45d118b733 | ||
|
|
bbf4f16b02 | ||
|
|
bd2bb39f29 | ||
|
|
5eef3ea535 | ||
|
|
a587b06673 | ||
|
|
85905afe96 | ||
|
|
997a9163f1 | ||
|
|
fb5134114d | ||
|
|
6122de4296 | ||
|
|
ad7095ec7c | ||
|
|
685eb4e143 | ||
|
|
333ba2f875 | ||
|
|
decfee4212 | ||
|
|
2fbebbec05 | ||
|
|
7198ebc587 | ||
|
|
a2fd6b63c8 | ||
|
|
e13d77aaaf | ||
|
|
e228b1acc8 | ||
|
|
6f692b7e32 | ||
|
|
8a528a6e47 | ||
|
|
493ad25947 | ||
|
|
5de8e26024 | ||
|
|
8c2f07ae66 | ||
|
|
fc0729181e | ||
|
|
d0613da5c4 | ||
|
|
ac944513cd | ||
|
|
6cd29b096c | ||
|
|
b19f3c4c4c | ||
|
|
28e90d8747 | ||
|
|
53b70d16d5 | ||
|
|
9a243a8019 | ||
|
|
feab1a9350 | ||
|
|
b193a2e726 | ||
|
|
70bedd0473 | ||
|
|
7bf57c56d5 | ||
|
|
6c47e79b09 | ||
|
|
28759c07e3 | ||
|
|
9ea2e00696 | ||
|
|
910902d5cc | ||
|
|
779413138e | ||
|
|
009263e870 | ||
|
|
28ece54b9f | ||
|
|
a9f3646f8c | ||
|
|
6605d396dd | ||
|
|
90c36f55d5 | ||
|
|
d1a6db792a | ||
|
|
12fb43d300 | ||
|
|
dbe11dffbb | ||
|
|
61d7d0dbb0 | ||
|
|
fe43032ccc | ||
|
|
d3b5cb815b | ||
|
|
e2ff252eec | ||
|
|
ea24cd0e6f | ||
|
|
b83d2a35cd | ||
|
|
e7bf8829ec | ||
|
|
c83b05f1ac | ||
|
|
3077f00966 | ||
|
|
e8dfd3db3d | ||
|
|
1f5a2a6c6d | ||
|
|
4175783d93 | ||
|
|
d527f78a8d | ||
|
|
39a2c2e1b0 | ||
|
|
529e8aac90 | ||
|
|
f17fed4326 | ||
|
|
da62a1a546 | ||
|
|
d6801e3316 | ||
|
|
85813b4c1f | ||
|
|
c0dc855f77 | ||
|
|
871ea723bb | ||
|
|
529512c48d | ||
|
|
cf270ba04b | ||
|
|
e366faee1f | ||
|
|
bab3db1c26 | ||
|
|
11867cf71c | ||
|
|
3ac1f58405 | ||
|
|
8128a83c4c | ||
|
|
4ce7121044 | ||
|
|
842543c6cb | ||
|
|
0a25f04da5 | ||
|
|
f8c4513d2c | ||
|
|
838fbd3ea6 | ||
|
|
2797478457 | ||
|
|
a1ef965a0a | ||
|
|
83733697ab | ||
|
|
2a9cf6dc16 | ||
|
|
17a8c616a8 | ||
|
|
3cba691a49 | ||
|
|
108e4775b6 | ||
|
|
02b90adeb8 | ||
|
|
6c84ebe030 | ||
|
|
c8efea2e2f | ||
|
|
058afcf19b | ||
|
|
72c7ca0286 | ||
|
|
6758780183 | ||
|
|
d7eb388daf | ||
|
|
78bf4f81e0 | ||
|
|
ff68e1b8b3 | ||
|
|
f3e3f55cbe | ||
|
|
f9913eddb7 | ||
|
|
ba07c4d563 | ||
|
|
f99157cc3e | ||
|
|
c88f9eed06 | ||
|
|
fb80f5e0d4 | ||
|
|
b12a05f2f1 | ||
|
|
1cd6a4c1f7 | ||
|
|
5ffd6f861a | ||
|
|
59ee3d24b1 | ||
|
|
e5d94569d0 | ||
|
|
dbf802f809 | ||
|
|
a91426bd90 | ||
|
|
bf2b3ec0e3 | ||
|
|
400a8e516d | ||
|
|
108b3af91c | ||
|
|
e1d856c79a | ||
|
|
b07e8810ea | ||
|
|
4f13f01ccb | ||
|
|
0beb8868d9 | ||
|
|
934366bf76 | ||
|
|
8ea8894f07 | ||
|
|
888c57e216 | ||
|
|
446d7ba73e | ||
|
|
786aa6cca7 | ||
|
|
3dd7f1c67d | ||
|
|
9a73f8287f | ||
|
|
279341cbe5 | ||
|
|
64726e6c83 | ||
|
|
1af803c684 | ||
|
|
fbb84fd8ce | ||
|
|
e9f90216c1 | ||
|
|
e58742909f | ||
|
|
b91804a656 | ||
|
|
666cf6dec4 | ||
|
|
3232483494 | ||
|
|
560bfd14e3 | ||
|
|
8b82d6ccca | ||
|
|
6458781bfb | ||
|
|
3e37e8d9dc | ||
|
|
d7ee514132 | ||
|
|
c8a45734eb | ||
|
|
9fd589f704 | ||
|
|
1c3e45f824 | ||
|
|
366e9e0a3b | ||
|
|
bd42eff987 | ||
|
|
c7446fcdd3 | ||
|
|
f3aba36d00 | ||
|
|
fbbad35a1a | ||
|
|
1d2207b045 | ||
|
|
e5c7d4be1a | ||
|
|
94b3bd5f9d | ||
|
|
900553a78c | ||
|
|
dc67b1bfbe | ||
|
|
0287ec2c42 | ||
|
|
60a7ea95d8 | ||
|
|
70d6ebd5d1 | ||
|
|
0051b8606d | ||
|
|
8105d9c2a1 | ||
|
|
30b7fe49f7 | ||
|
|
6cae610826 | ||
|
|
c33e306696 | ||
|
|
bb2ca352c0 | ||
|
|
a47e9659f6 | ||
|
|
90d70c554f | ||
|
|
9518791a68 | ||
|
|
447ca785fb | ||
|
|
413e944db0 | ||
|
|
49544e7deb | ||
|
|
ad0f17ebb7 | ||
|
|
85330a2390 | ||
|
|
c9904167b2 | ||
|
|
b8ad52294b | ||
|
|
39a1be8b24 | ||
|
|
9130be924f | ||
|
|
f7eec1888c | ||
|
|
8e38e2a6f4 | ||
|
|
3575ba97f0 | ||
|
|
4479ef83e2 | ||
|
|
0e17c333d5 | ||
|
|
f4e3522523 | ||
|
|
bfd8d552d2 | ||
|
|
e3cbeda015 | ||
|
|
1c242eac02 | ||
|
|
3220a032df | ||
|
|
7b6a7aa9db | ||
|
|
c36d80a247 | ||
|
|
eedcbdc38e | ||
|
|
d1307b06f4 | ||
|
|
61f6e2ca41 | ||
|
|
43d9fabfbc | ||
|
|
48ef3929fc | ||
|
|
02774c652c | ||
|
|
8c692e51e5 | ||
|
|
00faaf7e93 | ||
|
|
ac8400e57c | ||
|
|
6eedd34bb0 | ||
|
|
00603e09bb | ||
|
|
9c3cf327b2 | ||
|
|
ebcb99e944 | ||
|
|
ca763d9183 | ||
|
|
c89f5e9b09 | ||
|
|
1d373214f2 | ||
|
|
ca6747894a | ||
|
|
7337178a2b | ||
|
|
c238bc5bd3 | ||
|
|
197fc01897 | ||
|
|
68622fbab8 | ||
|
|
49f929c3f4 | ||
|
|
61f016831d | ||
|
|
90fbe0f049 | ||
|
|
9b25bd887d | ||
|
|
6764286c22 | ||
|
|
8cbb34a62c | ||
|
|
33082cebf4 | ||
|
|
64c1b6b7db |
No files matched your search
+8
-1
@@ -1,4 +1,4 @@
|
||||
# Copy to .env.play when you want to upload screenshots.
|
||||
# Copy to .env.play when you want to upload the store listing.
|
||||
# Do not commit .env.play or the service-account JSON.
|
||||
PLAY_PACKAGE_NAME=xyz.waozi.inbe
|
||||
PLAY_SERVICE_ACCOUNT_JSON=/absolute/path/to/google-play-service-account.json
|
||||
@@ -6,7 +6,14 @@ PLAY_LANGUAGE=en-US
|
||||
PLAY_METADATA_IMAGES_DIR=fastlane/metadata/android/en-US/images
|
||||
PLAY_IMAGE_TYPES=phoneScreenshots,sevenInchScreenshots,tenInchScreenshots
|
||||
PLAY_DELETE_EXISTING=1
|
||||
# Short and full descriptions from every locale folder here. 0 skips text.
|
||||
PLAY_METADATA_DIR=fastlane/metadata/android
|
||||
PLAY_LISTING_TEXT=1
|
||||
# Optional public/unlisted, embeddable YouTube video for PLAY_LANGUAGE.
|
||||
# Leave empty to preserve the existing video.
|
||||
PLAY_VIDEO_URL=
|
||||
|
||||
# Default is validate-only and discards the draft edit.
|
||||
# Set to 1 only when you want the uploaded screenshots committed to Play.
|
||||
# Uploads require make screenshot-review, screenshot-export and play-preflight.
|
||||
PLAY_COMMIT=0
|
||||
@@ -1,2 +1,3 @@
|
||||
unpackaged_assets/**/*.ogg filter=lfs diff=lfs merge=lfs -text
|
||||
test-fixtures/audio/*.mp3 filter=lfs diff=lfs merge=lfs -text
|
||||
themes/catalog_*.kss whitespace=-blank-at-eof
|
||||
@@ -0,0 +1,42 @@
|
||||
name: Set up Emscripten
|
||||
description: >
|
||||
Install the Emscripten SDK version named in .github/emscripten-version and
|
||||
put it on PATH. The SDK, including the system libraries and ports it builds
|
||||
on first use, is cached per version, so a job only downloads it when the
|
||||
pinned version changes.
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Read the pinned Emscripten version
|
||||
id: version
|
||||
shell: bash
|
||||
run: echo "version=$(tr -d '[:space:]' < .github/emscripten-version)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore the Emscripten SDK
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/emsdk
|
||||
key: emsdk-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}-${{ hashFiles('scripts/ensure-emscripten-zlib.sh') }}
|
||||
restore-keys: |
|
||||
emsdk-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}-
|
||||
|
||||
- name: Install and activate Emscripten
|
||||
shell: bash
|
||||
env:
|
||||
EMSCRIPTEN_VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ ! -x "$HOME/emsdk/emsdk" ]; then
|
||||
rm -rf "$HOME/emsdk"
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
fi
|
||||
if [ ! -x "$HOME/emsdk/upstream/emscripten/emcc" ]; then
|
||||
"$HOME/emsdk/emsdk" install "$EMSCRIPTEN_VERSION"
|
||||
fi
|
||||
"$HOME/emsdk/emsdk" activate "$EMSCRIPTEN_VERSION"
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
bash scripts/ensure-emscripten-zlib.sh "$HOME/emsdk/upstream/emscripten/embuilder"
|
||||
@@ -0,0 +1,61 @@
|
||||
name: Fetch Ziran packages
|
||||
description: >
|
||||
Fetch the packages pinned in ziran.lock. The built Ziran compiler is cached
|
||||
by the runner image and the toolchain commit, so bumping another package
|
||||
such as Kryon keeps it; the package checkouts are cached by the whole lock and fall back
|
||||
to the previous checkouts, so a bump fetches only what changed.
|
||||
|
||||
inputs:
|
||||
save-toolchain:
|
||||
description: >
|
||||
Save the built compiler to the cache. A job that only fetches packages
|
||||
must not, or it would store a toolchain cache without the compiler.
|
||||
default: 'true'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Read the Ziran toolchain commit
|
||||
id: toolchain
|
||||
shell: sh
|
||||
run: |
|
||||
commit=$(python3 -c 'import json; print(json.load(open("ziran.lock"))["toolchain"]["commit"])')
|
||||
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
||||
# A compiler built on a newer image needs its newer C library, so
|
||||
# images do not share one: ubuntu-22.04 cannot run a glibc 2.39 build.
|
||||
libc=$(getconf GNU_LIBC_VERSION 2>/dev/null | tr ' ' '-' || true)
|
||||
echo "system=${ImageOS:-local}-${libc:-nolibc}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore the Ziran toolchain
|
||||
if: inputs.save-toolchain == 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
build/ziran-bootstrap
|
||||
build/ziran-toolchain
|
||||
key: ziran-toolchain-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.system }}-${{ steps.toolchain.outputs.commit }}
|
||||
restore-keys: |
|
||||
ziran-toolchain-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.system }}-
|
||||
|
||||
- name: Restore the Ziran toolchain without saving it
|
||||
if: inputs.save-toolchain != 'true'
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
build/ziran-bootstrap
|
||||
build/ziran-toolchain
|
||||
key: ziran-toolchain-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.system }}-${{ steps.toolchain.outputs.commit }}
|
||||
restore-keys: |
|
||||
ziran-toolchain-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.system }}-
|
||||
|
||||
- name: Restore the package sources
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ziran/sources
|
||||
key: ziran-sources-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('ziran.lock') }}
|
||||
restore-keys: |
|
||||
ziran-sources-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
- name: Fetch Ziran packages
|
||||
shell: sh
|
||||
run: sh scripts/packages.sh --locked
|
||||
@@ -21,6 +21,7 @@ libsdl2-2.0-0
|
||||
libsdl2-dev
|
||||
patchelf
|
||||
pkg-config
|
||||
python3-fonttools
|
||||
podman
|
||||
rpm
|
||||
x11-utils
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
build-essential
|
||||
ca-certificates
|
||||
libcurl4-openssl-dev
|
||||
ripgrep
|
||||
zlib1g-dev
|
||||
libdrm-dev
|
||||
libegl1-mesa-dev
|
||||
libgbm-dev
|
||||
libgles2-mesa-dev
|
||||
libsdl2-dev
|
||||
pkg-config
|
||||
python3-fonttools
|
||||
python3-numpy
|
||||
python3-pil
|
||||
python3-requests
|
||||
python3-scipy
|
||||
xvfb
|
||||
xauth
|
||||
xdotool
|
||||
x11-apps
|
||||
x11-utils
|
||||
xclip
|
||||
sqlite3
|
||||
imagemagick
|
||||
tesseract-ocr
|
||||
|
||||
python3-cryptography
|
||||
@@ -2,3 +2,4 @@ build-essential
|
||||
zlib1g-dev
|
||||
zip
|
||||
tcl
|
||||
python3-fonttools
|
||||
@@ -1,6 +1,7 @@
|
||||
build-essential
|
||||
gcc-mingw-w64-i686-win32
|
||||
gcc-mingw-w64-x86-64-win32
|
||||
zlib1g-dev
|
||||
libz-mingw-w64-dev
|
||||
zip
|
||||
nsis
|
||||
python3-fonttools
|
||||
@@ -0,0 +1 @@
|
||||
6.0.10
|
||||
@@ -0,0 +1,148 @@
|
||||
name: Android Moto APK
|
||||
|
||||
"on":
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
source_commit:
|
||||
description: Full commit hash whose Release checks passed
|
||||
required: true
|
||||
verified_run:
|
||||
description: Release run with successful Secret Scan and Test jobs
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
jobs:
|
||||
android:
|
||||
name: Build signed Moto APK
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- name: Require passing checks for the exact source commit
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
SOURCE_COMMIT: ${{ inputs.source_commit }}
|
||||
VERIFIED_RUN: ${{ inputs.verified_run }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
commit = os.environ['SOURCE_COMMIT']
|
||||
run_id = os.environ['VERIFIED_RUN']
|
||||
repository = os.environ['GITHUB_REPOSITORY']
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', commit):
|
||||
raise SystemExit('A full, immutable source commit is required')
|
||||
if not re.fullmatch(r'[0-9]+', run_id):
|
||||
raise SystemExit('A numeric Release run ID is required')
|
||||
|
||||
def api(path):
|
||||
return json.loads(subprocess.check_output(['gh', 'api', path], text=True))
|
||||
|
||||
run = api(f'repos/{repository}/actions/runs/{run_id}')
|
||||
if run['head_sha'] != commit or run['path'] != '.github/workflows/release.yml':
|
||||
raise SystemExit('The Release checks must belong to the requested source commit')
|
||||
jobs = api(f'repos/{repository}/actions/runs/{run_id}/jobs?per_page=100')['jobs']
|
||||
for name in ('Secret Scan', 'Test'):
|
||||
checks = [job for job in jobs if job['name'] == name]
|
||||
if len(checks) != 1 or checks[0]['conclusion'] != 'success':
|
||||
raise SystemExit(f'{name} must have passed before signing')
|
||||
print('Verified passing Secret Scan and full Test jobs for ' + commit)
|
||||
PY
|
||||
|
||||
- name: Checkout verified source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.source_commit }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
|
||||
- name: Cache Android SDK packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
${{ env.ANDROID_HOME }}/platforms/android-36
|
||||
${{ env.ANDROID_HOME }}/build-tools/34.0.0
|
||||
${{ env.ANDROID_HOME }}/ndk/28.2.13676358
|
||||
${{ env.ANDROID_HOME }}/cmake/3.22.1
|
||||
key: android-moto-sdk-${{ runner.os }}-api36-ndk28-cmake322
|
||||
restore-keys: |
|
||||
android-sdk-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
- name: Install Android SDK components
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
|
||||
yes | "$SDKMANAGER" --licenses >/dev/null || true
|
||||
"$SDKMANAGER" "platforms;android-36" "build-tools;34.0.0" "ndk;28.2.13676358" "cmake;3.22.1"
|
||||
|
||||
- name: Prepare Android signing key
|
||||
env:
|
||||
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
mkdir -p ~/.android
|
||||
printf '%s' "$KEYSTORE_BASE64" | base64 -d > ~/.android/inbe-release.keystore
|
||||
|
||||
- name: Prepare Firebase config
|
||||
env:
|
||||
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
|
||||
run: ./scripts/write-google-services-json.sh
|
||||
|
||||
- name: Copy Android assets
|
||||
run: ./scripts/copy-android-assets.sh
|
||||
|
||||
- name: Build signed ARMv7 release APK
|
||||
env:
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
SOURCE_COMMIT: ${{ inputs.source_commit }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./droid/gradlew -p droid assembleRelease \
|
||||
-Papp.onlyAbi=armeabi-v7a \
|
||||
-Pkeystore.path="$HOME/.android/inbe-release.keystore" \
|
||||
-Pkeystore.alias="$KEY_ALIAS" \
|
||||
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
||||
--stacktrace
|
||||
VERSION=$(python3 scripts/check-version.py --print-version)
|
||||
mkdir -p build/release/moto
|
||||
cp droid/app/build/outputs/apk/release/app-armeabi-v7a-release.apk "build/release/moto/inbe-$VERSION-moto.apk"
|
||||
"$ANDROID_HOME/build-tools/34.0.0/apksigner" verify --print-certs "build/release/moto/inbe-$VERSION-moto.apk"
|
||||
printf '%s\n' "$SOURCE_COMMIT" > build/release/moto/source-commit.txt
|
||||
(
|
||||
cd build/release/moto
|
||||
sha256sum "inbe-$VERSION-moto.apk" > "inbe-$VERSION-moto.apk.sha256"
|
||||
)
|
||||
|
||||
- name: Remove signing key
|
||||
if: always()
|
||||
run: rm -f ~/.android/inbe-release.keystore
|
||||
|
||||
- name: Upload signed Moto APK
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android-moto
|
||||
path: build/release/moto/*
|
||||
if-no-files-found: error
|
||||
+86
-95
@@ -24,9 +24,13 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
with:
|
||||
save-toolchain: 'false'
|
||||
|
||||
- name: Check Version Consistency
|
||||
run: |
|
||||
python3 scripts/check-version.py
|
||||
@@ -38,34 +42,42 @@ jobs:
|
||||
python3 scripts/check-secrets.py --working-tree
|
||||
python3 scripts/check-secrets.py --history
|
||||
|
||||
guard-submodule-urls:
|
||||
name: Submodule URLs are public HTTPS
|
||||
guard-package-urls:
|
||||
name: Package URLs are public HTTPS
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Plain checkout on purpose: the guard must not depend on fetching
|
||||
# the submodules it validates (an SSH URL would break that fetch).
|
||||
# the packages it validates (an SSH URL would break that fetch).
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Reject non-HTTPS submodule URLs
|
||||
- name: Reject submodules and non-HTTPS package URLs
|
||||
run: |
|
||||
set -eu
|
||||
if [ ! -f .gitmodules ]; then echo "no submodules - ok"; exit 0; fi
|
||||
bad=$(grep -nE '^[[:space:]]*url[[:space:]]*=' .gitmodules \
|
||||
| grep -vE '^[0-9]+:[[:space:]]*url[[:space:]]*=[[:space:]]*https://' || true)
|
||||
if [ -n "$bad" ]; then
|
||||
echo "::error::Non-HTTPS submodule URL(s) break fresh clones and CI:$bad"
|
||||
if [ -f .gitmodules ]; then
|
||||
echo "::error::Dependencies are Ziran packages in ziran.toml, not submodules"
|
||||
exit 1
|
||||
fi
|
||||
echo "all submodule URLs HTTPS - ok"
|
||||
bad=$(grep -nE '^[[:space:]]*git[[:space:]]*=' ziran.toml \
|
||||
| grep -vE '^[0-9]+:[[:space:]]*git[[:space:]]*=[[:space:]]*"https://' || true)
|
||||
if [ -n "$bad" ]; then
|
||||
echo "::error::Non-HTTPS package URL(s) break fresh clones and CI:$bad"
|
||||
exit 1
|
||||
fi
|
||||
echo "all package URLs HTTPS - ok"
|
||||
|
||||
test:
|
||||
name: Test
|
||||
# make test split across runners; each shard is a third of its targets.
|
||||
name: Test (${{ matrix.shard }}/3)
|
||||
runs-on: ubuntu-latest
|
||||
# Secret Scan runs beside the tests; nothing here publishes, so it need not gate them.
|
||||
needs:
|
||||
- guard-submodule-urls
|
||||
- secret-scan
|
||||
- guard-package-urls
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [0, 1, 2]
|
||||
env:
|
||||
APT_CACHE_DIR: /tmp/apt-cache
|
||||
|
||||
@@ -73,11 +85,13 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
lfs: true
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -95,32 +109,71 @@ jobs:
|
||||
run: .github/scripts/install-apt-packages.sh .github/apt/test-packages.txt
|
||||
|
||||
- name: Run Tests
|
||||
run: make test
|
||||
run: sh scripts/test-shard.sh ${{ matrix.shard }} 3
|
||||
|
||||
- name: Require Visual Tests
|
||||
if: matrix.shard == 1
|
||||
run: make visual-test
|
||||
|
||||
- name: Save Visual Test Evidence
|
||||
if: always() && matrix.shard == 1
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: native-visual-tests
|
||||
path: |
|
||||
build/visual-test/
|
||||
build/native-visual-test/
|
||||
build/native-zoom-test/*.png
|
||||
build/native-zoom-test/app.log
|
||||
build/launcher-ui-test/
|
||||
build/locale-render-ui-test/
|
||||
build/native-screenshot-test/
|
||||
build/native-text-pixels-test/*.png
|
||||
build/native-text-pixels-test/*.log
|
||||
build/settings-sidebar-test/
|
||||
build/startup-quit-test/
|
||||
build/lumi-ui-test/
|
||||
build/lumi-history-ui-test/
|
||||
build/habits-table-ui-test/
|
||||
build/lists-ui-test/
|
||||
build/sync-review-ui-test/
|
||||
build/data-back-ui-test/
|
||||
build/leaderboard-ui-test/
|
||||
build/practice-images-ui-test/
|
||||
retention-days: 7
|
||||
|
||||
- name: Check out sync test server
|
||||
if: matrix.shard == 0
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kryonlabs/daochi
|
||||
ref: 51902c57c537724cf4c083227f5da6c50e24ba39
|
||||
# Includes the private Lumi collection used for shared account activity.
|
||||
ref: f850456a7e039e9ba39fcf03cb7cb802ff6a3329
|
||||
path: .test-server
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up Go for sync test server
|
||||
if: matrix.shard == 0
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: .test-server/go.mod
|
||||
cache-dependency-path: .test-server/go.sum
|
||||
|
||||
- name: Verify sync and recovery
|
||||
if: matrix.shard == 0
|
||||
run: |
|
||||
make -C .test-server build
|
||||
make sync-server-test DAOCHI_BIN="$GITHUB_WORKSPACE/.test-server/daochi"
|
||||
|
||||
build-chrome-extension:
|
||||
name: Build Chrome Extension
|
||||
browser-addons:
|
||||
# Builds the web app once, packages it for Chrome and Firefox, and runs
|
||||
# the smoke test in both browsers. It runs beside the tests; a failure in
|
||||
# either still fails the run.
|
||||
name: Build Browser Add-ons
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
needs: test
|
||||
needs:
|
||||
- guard-package-urls
|
||||
env:
|
||||
APT_CACHE_DIR: /tmp/apt-cache
|
||||
|
||||
@@ -128,11 +181,13 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
lfs: true
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -150,17 +205,9 @@ jobs:
|
||||
run: .github/scripts/install-apt-packages.sh .github/apt/web-packages.txt
|
||||
|
||||
- name: Set up Emscripten
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install latest
|
||||
"$HOME/emsdk/emsdk" activate latest
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
uses: ./.github/actions/emscripten
|
||||
|
||||
- name: Build Chrome Extension ZIP
|
||||
- name: Build Chrome and Firefox ZIPs
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export PATH="$INBE_NODE_BIN:$PATH"
|
||||
@@ -168,74 +215,18 @@ jobs:
|
||||
make package-unpackaged-assets
|
||||
make chrome-web-store
|
||||
test -f build/dist/inbe-chrome-web-store.zip
|
||||
make firefox-addons
|
||||
test -f build/dist/inbe-firefox-addons.zip
|
||||
make firefox-addons-lint
|
||||
|
||||
- name: Run Web Smoke Test
|
||||
# The web build renders on canvas, so this is also the canvas smoke
|
||||
# test.
|
||||
- name: Run Web Smoke Test (Chrome)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export PATH="$INBE_NODE_BIN:$PATH"
|
||||
make web-smoke-test
|
||||
|
||||
- name: Run Canvas Web Smoke Test
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export PATH="$INBE_NODE_BIN:$PATH"
|
||||
make web-canvas
|
||||
make web-canvas-smoke-test
|
||||
|
||||
build-firefox-addons:
|
||||
name: Build Firefox Add-on
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
needs: test
|
||||
env:
|
||||
APT_CACHE_DIR: /tmp/apt-cache
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
lfs: true
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Cache Web apt packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.APT_CACHE_DIR }}
|
||||
key: web-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/web-packages.txt') }}
|
||||
restore-keys: |
|
||||
web-apt-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
- name: Install Web Dependencies
|
||||
timeout-minutes: 15
|
||||
run: .github/scripts/install-apt-packages.sh .github/apt/web-packages.txt
|
||||
|
||||
- name: Set up Emscripten
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install latest
|
||||
"$HOME/emsdk/emsdk" activate latest
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build Firefox Add-on ZIP
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export PATH="$INBE_NODE_BIN:$PATH"
|
||||
node --version
|
||||
make package-unpackaged-assets
|
||||
make firefox-addons
|
||||
test -f build/dist/inbe-firefox-addons.zip
|
||||
make firefox-addons-lint
|
||||
|
||||
- name: Install Firefox (Mozilla build)
|
||||
timeout-minutes: 15
|
||||
run: |
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
name: App packages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'apps/**'
|
||||
- 'assets/**'
|
||||
- 'locales/**'
|
||||
- 'themes/**'
|
||||
- 'scripts/prepare-package-assets.py'
|
||||
- 'src/**'
|
||||
- 'scripts/build-cells.sh'
|
||||
- 'scripts/package-release.py'
|
||||
- 'scripts/generate-package-versions.py'
|
||||
- 'scripts/update-package-version.py'
|
||||
- 'scripts/check-package-versions.py'
|
||||
- 'scripts/check-package-publishers.py'
|
||||
- 'scripts/package-manifests.py'
|
||||
- 'tests/package_manifests_test.py'
|
||||
- 'tests/package_upload_test.py'
|
||||
- 'tests/package_versions_test.py'
|
||||
- 'tests/package_workflow_test.py'
|
||||
- 'ziran.lock'
|
||||
- '.github/workflows/packages.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: inbe-package-publishing
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
packages:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/ziran-packages
|
||||
- name: Install signing and test dependencies
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y python3-cryptography python3-fonttools
|
||||
.github/scripts/install-apt-packages.sh .github/apt/test-packages.txt
|
||||
- name: Build independent packages and check signatures
|
||||
run: |
|
||||
make package-version-test
|
||||
make package-workflow-test
|
||||
make package-manifest-test
|
||||
make package-upload-test
|
||||
make cells build-laws
|
||||
python3 tests/package_release_test.py
|
||||
- name: Run new packages in the last released app
|
||||
run: python3 tests/package_compat_test.py --skip-forward
|
||||
- name: Configure publisher
|
||||
id: publisher
|
||||
env:
|
||||
SIGNING_KEY: ${{ secrets.INBE_PACKAGE_SIGNING_KEY }}
|
||||
KEY_ID: ${{ vars.INBE_PACKAGE_KEY_ID }}
|
||||
SSH_KEY: ${{ secrets.INBE_NODE_SSH_KEY }}
|
||||
SSH_HOSTS: ${{ secrets.INBE_NODE_KNOWN_HOSTS }}
|
||||
TARGET: ${{ secrets.INBE_NODE_SSH_TARGET }}
|
||||
STORE: ${{ secrets.INBE_NODE_PACKAGE_STORE }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import os
|
||||
from pathlib import Path
|
||||
signing = all(os.environ.get(name) for name in ('SIGNING_KEY', 'KEY_ID'))
|
||||
configured = signing and all(os.environ.get(name) for name in ('SSH_KEY', 'SSH_HOSTS', 'TARGET', 'STORE'))
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
|
||||
output.write('signing=' + str(signing).lower() + '\n')
|
||||
output.write('configured=' + str(configured).lower() + '\n')
|
||||
if signing:
|
||||
directory = Path(os.environ['RUNNER_TEMP']) / 'inbe-publisher'
|
||||
directory.mkdir(mode=0o700)
|
||||
files = [('publisher.pem', 'SIGNING_KEY')]
|
||||
if configured:
|
||||
files += [('node.key', 'SSH_KEY'), ('known_hosts', 'SSH_HOSTS')]
|
||||
for filename, name in files:
|
||||
path = directory / filename
|
||||
path.write_text(os.environ[name] + '\n')
|
||||
path.chmod(0o600)
|
||||
if signing and not configured:
|
||||
print('Node deployment is not configured; signed releases will be archived for installation on the node.')
|
||||
elif not signing:
|
||||
print('Signing is not configured; unsigned build artifacts will be archived without publication.')
|
||||
PY
|
||||
- name: Sign app releases
|
||||
if: steps.publisher.outputs.signing == 'true'
|
||||
env:
|
||||
KEY_ID: ${{ vars.INBE_PACKAGE_KEY_ID }}
|
||||
run: |
|
||||
python3 scripts/check-package-publishers.py
|
||||
python3 scripts/package-release.py --store build/package-releases \
|
||||
--key "$RUNNER_TEMP/inbe-publisher/publisher.pem" --key-id "$KEY_ID"
|
||||
- name: Sign and publish to Waozi's Daochi node
|
||||
if: steps.publisher.outputs.configured == 'true'
|
||||
env:
|
||||
KEY_ID: ${{ vars.INBE_PACKAGE_KEY_ID }}
|
||||
TARGET: ${{ secrets.INBE_NODE_SSH_TARGET }}
|
||||
STORE: ${{ secrets.INBE_NODE_PACKAGE_STORE }}
|
||||
run: |
|
||||
export INBE_SSH_IDENTITY="$RUNNER_TEMP/inbe-publisher/node.key"
|
||||
export INBE_SSH_KNOWN_HOSTS="$RUNNER_TEMP/inbe-publisher/known_hosts"
|
||||
python3 scripts/package-release.py --store build/package-releases \
|
||||
--key "$RUNNER_TEMP/inbe-publisher/publisher.pem" --key-id "$KEY_ID" \
|
||||
--ssh-target "$TARGET" --remote-store "$STORE" \
|
||||
--verify-origin https://api.waozi.xyz
|
||||
- name: Archive packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: inbe-app-packages
|
||||
path: |
|
||||
build/inbe.zib
|
||||
build/cells/*.zib
|
||||
build/package-releases/
|
||||
if-no-files-found: error
|
||||
- name: Remove signing material
|
||||
if: always()
|
||||
run: rm -rf "$RUNNER_TEMP/inbe-publisher"
|
||||
+64
-26
@@ -1,13 +1,14 @@
|
||||
name: Cloudflare Pages
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- Release
|
||||
types:
|
||||
- completed
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
# Refresh available downloads after a release; pushes deploy independently.
|
||||
workflow_run:
|
||||
workflows: [Release]
|
||||
types: [completed]
|
||||
branches: [master]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -20,28 +21,55 @@ permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: pages-${{ github.event.workflow_run.head_branch || github.ref }}
|
||||
# A failed Release produces a skipped refresh, which must not cancel a push.
|
||||
group: pages-${{ github.ref }}-${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion != 'success' && 'skipped' || 'deploy' }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Site
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.workflow_run.head_sha || github.ref }}
|
||||
submodules: recursive
|
||||
lfs: true
|
||||
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js for the web build
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Resolve published downloads
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
gh api repos/waozixyz/inbe/releases/latest > "$RUNNER_TEMP/inbe-published-release.json"
|
||||
python3 - "$RUNNER_TEMP/inbe-published-release.json" >> "$GITHUB_ENV" <<'PY'
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
release = json.loads(Path(sys.argv[1]).read_text())
|
||||
tag = release["tag_name"]
|
||||
version = tag.removeprefix("v")
|
||||
assert re.fullmatch(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)", version), "Invalid published release version"
|
||||
assets = {asset["name"] for asset in release["assets"]}
|
||||
candidates = [f"inbe-{version}-arm64-v8a.apk", f"inbe-{version}.apk"]
|
||||
android = next((name for name in candidates if name in assets), None)
|
||||
assert android is not None, "Published release has no compatible Android APK"
|
||||
print(f"SITE_RELEASE_VERSION={version}")
|
||||
print(f"SITE_ANDROID_APK_ASSET={android}")
|
||||
PY
|
||||
|
||||
- name: Install Packages
|
||||
if: ${{ !inputs.released_web }}
|
||||
timeout-minutes: 15
|
||||
@@ -49,15 +77,7 @@ jobs:
|
||||
|
||||
- name: Set Up Emscripten
|
||||
if: ${{ !inputs.released_web }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install latest
|
||||
"$HOME/emsdk/emsdk" activate latest
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
uses: ./.github/actions/emscripten
|
||||
|
||||
- name: Download Released Web App
|
||||
if: ${{ inputs.released_web }}
|
||||
@@ -65,13 +85,25 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
version=$(sed -n 's/^#define APP_VERSION_STRING "\([^"]*\)"/\1/p' src/core/version.h)
|
||||
version="$SITE_RELEASE_VERSION"
|
||||
test -n "$version"
|
||||
mkdir -p build/released-web build/dist/web
|
||||
gh release download "v$version" --pattern inbe-web.zip --dir build/released-web
|
||||
unzip -q build/released-web/inbe-web.zip -d build/dist/web
|
||||
test -s build/dist/web/index.wasm
|
||||
|
||||
- name: Web runner diagnostics
|
||||
if: ${{ !inputs.released_web }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
lscpu
|
||||
free -m
|
||||
for browser in chromium chromium-browser google-chrome google-chrome-stable; do
|
||||
if command -v "$browser" >/dev/null 2>&1; then
|
||||
"$browser" --version
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Build Site
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -81,12 +113,13 @@ jobs:
|
||||
else
|
||||
export PATH="$INBE_NODE_BIN:$PATH"
|
||||
node --version
|
||||
make build-laws
|
||||
make site
|
||||
fi
|
||||
test -f build/site/index.html
|
||||
test -f build/site/build/web/index.html
|
||||
test -f build/site/build/web/index.js
|
||||
test -f build/site/build/web/index.wasm
|
||||
test -f build/site/build/web/index.wasm || test -f build/site/build/web/index.wasm.gz || test -f build/site/build/web/index.wasm.parts.json
|
||||
if [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then
|
||||
make site-release-assets-check
|
||||
else
|
||||
@@ -96,6 +129,15 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASED_WEB: ${{ inputs.released_web }}
|
||||
|
||||
- name: Upload Web diagnostics after a failed build
|
||||
if: ${{ failure() && !inputs.released_web }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: inbe-web-diagnostics
|
||||
path: build/dist/web
|
||||
if-no-files-found: warn
|
||||
retention-days: 3
|
||||
|
||||
- name: Upload Site Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
@@ -121,17 +163,13 @@ jobs:
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: pages deploy build/site --project-name=inbe --branch=${{ github.head_ref || github.ref_name }}
|
||||
command: pages deploy build/site --project-name=inbe --branch=${{ github.head_ref || github.ref_name }} --commit-hash=${{ github.sha }}
|
||||
|
||||
deploy-production:
|
||||
name: Deploy Production
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: |
|
||||
(github.event_name == 'workflow_run' &&
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.head_branch == 'master') ||
|
||||
(github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master')
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
|
||||
|
||||
steps:
|
||||
- name: Download Site Artifact
|
||||
@@ -145,4 +183,4 @@ jobs:
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: pages deploy build/site --project-name=inbe --branch=master
|
||||
command: pages deploy build/site --project-name=inbe --branch=master --commit-hash=${{ github.sha }}
|
||||
@@ -35,10 +35,12 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Scan Tracked Files and History
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
+164
-112
@@ -4,6 +4,23 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'src/**'
|
||||
- '!src/cells/versions.zi'
|
||||
- 'droid/**'
|
||||
- 'apps/publishers.json'
|
||||
- 'CHANGELOG.md'
|
||||
- 'Makefile'
|
||||
- 'ziran.lock'
|
||||
- 'scripts/**'
|
||||
- '!scripts/package-release.py'
|
||||
- '!scripts/update-package-version.py'
|
||||
- '!scripts/generate-package-versions.py'
|
||||
- '!scripts/prepare-package-assets.py'
|
||||
- '!scripts/check-package-versions.py'
|
||||
- '!scripts/package-manifests.py'
|
||||
- 'packaging/**'
|
||||
- '.github/workflows/release.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -21,9 +38,16 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
with:
|
||||
save-toolchain: 'false'
|
||||
|
||||
- name: Require configured app publisher
|
||||
run: python3 scripts/check-package-publishers.py
|
||||
|
||||
- name: Check Version Consistency
|
||||
run: |
|
||||
python3 scripts/check-version.py
|
||||
@@ -47,11 +71,13 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
lfs: true
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -71,6 +97,39 @@ jobs:
|
||||
- name: Run Tests
|
||||
run: make test
|
||||
|
||||
- name: Require Visual Tests
|
||||
run: make visual-test
|
||||
|
||||
- name: Run Packages Across App Versions
|
||||
run: make package-compat-test
|
||||
|
||||
- name: Save Visual Test Evidence
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-visual-tests
|
||||
path: |
|
||||
build/visual-test/
|
||||
build/native-visual-test/
|
||||
build/native-zoom-test/*.png
|
||||
build/native-zoom-test/app.log
|
||||
build/launcher-ui-test/
|
||||
build/locale-render-ui-test/
|
||||
build/native-screenshot-test/
|
||||
build/native-text-pixels-test/*.png
|
||||
build/native-text-pixels-test/*.log
|
||||
build/settings-sidebar-test/
|
||||
build/startup-quit-test/
|
||||
build/lumi-ui-test/
|
||||
build/lumi-history-ui-test/
|
||||
build/habits-table-ui-test/
|
||||
build/lists-ui-test/
|
||||
build/sync-review-ui-test/
|
||||
build/data-back-ui-test/
|
||||
build/leaderboard-ui-test/
|
||||
build/practice-images-ui-test/
|
||||
retention-days: 7
|
||||
|
||||
build-web:
|
||||
name: Build Web
|
||||
runs-on: ubuntu-latest
|
||||
@@ -83,11 +142,13 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
lfs: true
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -105,15 +166,7 @@ jobs:
|
||||
run: .github/scripts/install-apt-packages.sh .github/apt/web-packages.txt
|
||||
|
||||
- name: Set up Emscripten
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install latest
|
||||
"$HOME/emsdk/emsdk" activate latest
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
uses: ./.github/actions/emscripten
|
||||
|
||||
- name: Build Web ZIP
|
||||
run: |
|
||||
@@ -144,11 +197,13 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
lfs: true
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -166,15 +221,7 @@ jobs:
|
||||
run: .github/scripts/install-apt-packages.sh .github/apt/web-packages.txt
|
||||
|
||||
- name: Set up Emscripten
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install latest
|
||||
"$HOME/emsdk/emsdk" activate latest
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
uses: ./.github/actions/emscripten
|
||||
|
||||
- name: Build Chrome Extension ZIP
|
||||
run: |
|
||||
@@ -205,11 +252,13 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
lfs: true
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -227,15 +276,7 @@ jobs:
|
||||
run: .github/scripts/install-apt-packages.sh .github/apt/web-packages.txt
|
||||
|
||||
- name: Set up Emscripten
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install latest
|
||||
"$HOME/emsdk/emsdk" activate latest
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "INBE_NODE_BIN=$(dirname "$(command -v node)")" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
uses: ./.github/actions/emscripten
|
||||
|
||||
- name: Build Firefox Add-on ZIP
|
||||
run: |
|
||||
@@ -277,10 +318,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -313,7 +356,7 @@ jobs:
|
||||
- name: Build Linux AppImage
|
||||
env:
|
||||
APPIMAGE_EXTRACT_AND_RUN: "1"
|
||||
RAY_RAYLIB_CONFIG: -DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=0
|
||||
RAY_RAYLIB_CONFIG: -DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=1
|
||||
run: |
|
||||
set -euo pipefail
|
||||
RAY_SDL_INCLUDE_DIR="$(pkg-config --variable=includedir sdl2 | sed 's,/SDL2$,,')"
|
||||
@@ -343,6 +386,13 @@ jobs:
|
||||
app_pid=$!
|
||||
for _ in $(seq 1 30); do
|
||||
if xwininfo -tree -root | grep -q 'Inner Breeze'; then
|
||||
sleep 3
|
||||
# A build without TrueType support draws a pixel font.
|
||||
if grep -q 'Font is not supported' /tmp/inbe-appimage.log; then
|
||||
echo "AppImage could not load its fonts"
|
||||
cat /tmp/inbe-appimage.log || true
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
if ! kill -0 "$app_pid" >/dev/null 2>&1; then
|
||||
@@ -383,10 +433,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -441,10 +493,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -499,10 +553,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -554,10 +610,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -589,52 +647,6 @@ jobs:
|
||||
path: build/release/linux/*
|
||||
if-no-files-found: error
|
||||
|
||||
build-freebsd:
|
||||
name: Build FreeBSD Package
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
needs: test
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Build FreeBSD .pkg
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
release: "14.3"
|
||||
usesh: true
|
||||
prepare: |
|
||||
for attempt in 1 2 3; do
|
||||
pkg install -y node22 python3 gmake cmake pkgconf sdl2 gtk3 curl sqlite3 mesa-libs libdrm hicolor-icon-theme desktop-file-utils && break
|
||||
if [ "$attempt" -eq 3 ]; then
|
||||
exit 1
|
||||
fi
|
||||
pkg update -f
|
||||
sleep 10
|
||||
done
|
||||
run: |
|
||||
set -eu
|
||||
gmake package-freebsd
|
||||
mkdir -p build/release/freebsd
|
||||
find build/dist/freebsd -maxdepth 1 -type f -name '*.pkg' -exec cp {} build/release/freebsd/ \;
|
||||
test -n "$(find build/release/freebsd -type f -print -quit)"
|
||||
|
||||
- name: Upload FreeBSD Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-freebsd
|
||||
path: build/release/freebsd/*
|
||||
if-no-files-found: error
|
||||
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: ubuntu-latest
|
||||
@@ -647,10 +659,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -669,7 +683,7 @@ jobs:
|
||||
path: |
|
||||
vendor-builds/windows
|
||||
vendor-builds/sqlite
|
||||
key: windows-vendor-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile', 'vendor/kryon/mk/**', 'vendor/kryon/scripts/prepare-raylib-source.sh', 'vendor/kryon/tools/generate-kryon-compat.sh', 'vendor/kryon/vendor/raylib/src/**', 'vendor/kryon/vendor/curl/**', 'vendor/sqlite/**') }}
|
||||
key: windows-vendor-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile', 'ziran.lock') }}
|
||||
restore-keys: |
|
||||
windows-vendor-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
@@ -681,9 +695,6 @@ jobs:
|
||||
if [ -x /usr/bin/x86_64-w64-mingw32-gcc-win32 ]; then
|
||||
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-win32
|
||||
fi
|
||||
if [ -x /usr/bin/i686-w64-mingw32-gcc-win32 ]; then
|
||||
sudo update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-win32
|
||||
fi
|
||||
|
||||
- name: Build Windows ZIP and Setup
|
||||
run: |
|
||||
@@ -710,10 +721,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Node.js for Bend proofs
|
||||
- name: Fetch Ziran packages
|
||||
uses: ./.github/actions/ziran-packages
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
@@ -727,6 +740,9 @@ jobs:
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
|
||||
- name: Install translation check dependency
|
||||
run: sudo apt-get update && sudo apt-get install -y python3-fonttools
|
||||
|
||||
- name: Cache Android SDK packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -746,7 +762,7 @@ jobs:
|
||||
path: |
|
||||
droid/app/.cxx
|
||||
droid/app/build/intermediates/cxx
|
||||
key: android-native-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('droid/app/src/main/cpp/CMakeLists.txt', 'droid/app/build.gradle', 'src/**/*.c', 'src/**/*.h', 'vendor/kryon/src/**/*.c', 'vendor/kryon/include/**/*.h', 'vendor/kryon/vendor/raylib/src/**') }}
|
||||
key: android-native-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('droid/app/src/main/cpp/CMakeLists.txt', 'droid/app/build.gradle', 'src/**/*.c', 'src/**/*.h', 'ziran.lock') }}
|
||||
restore-keys: |
|
||||
android-native-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
@@ -792,6 +808,22 @@ jobs:
|
||||
--stacktrace
|
||||
make android-copy-release-apks
|
||||
make android-copy-bundle
|
||||
# F-Droid rebuilds the universal APK with -PfDroidBuild and copies
|
||||
# this APK's signature onto it, so the two must match byte for byte.
|
||||
./droid/gradlew -p droid assembleRelease -PfDroidBuild=true \
|
||||
-Pkeystore.path="$HOME/.android/inbe-release.keystore" \
|
||||
-Pkeystore.alias="$KEY_ALIAS" \
|
||||
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
||||
--stacktrace
|
||||
make android-copy-fdroid-apk
|
||||
|
||||
- name: Preserve Android Native Crash Symbols
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android-native-symbols
|
||||
path: droid/app/build/intermediates/native_debug_metadata/**/out/**/*.dbg
|
||||
if-no-files-found: error
|
||||
retention-days: 90
|
||||
|
||||
- name: Collect Android Release Files
|
||||
run: |
|
||||
@@ -802,13 +834,19 @@ jobs:
|
||||
echo "Could not read APP_VERSION_STRING"
|
||||
exit 1
|
||||
fi
|
||||
for apk in "build/android/inbe-$VERSION.apk" "build/android/inbe-$VERSION-gplay.apk"; do
|
||||
for apk in "build/android/inbe-$VERSION.apk" "build/android/inbe-$VERSION-gplay.apk" \
|
||||
"build/android/inbe-$VERSION-fdroid.apk"; do
|
||||
if [ ! -f "$apk" ]; then
|
||||
echo "Missing universal APK: $apk"
|
||||
exit 1
|
||||
fi
|
||||
cp "$apk" build/release/android/
|
||||
done
|
||||
for abi in arm64-v8a armeabi-v7a x86 x86_64; do
|
||||
apk="build/android/inbe-$VERSION-$abi.apk"
|
||||
test -f "$apk"
|
||||
cp "$apk" build/release/android/
|
||||
done
|
||||
cp "build/android/inbe-$VERSION-gplay.aab" build/release/android/
|
||||
|
||||
- name: Upload Android Artifacts
|
||||
@@ -831,7 +869,6 @@ jobs:
|
||||
- build-linux-rpm
|
||||
- build-linux-snap
|
||||
- build-linux-flatpak
|
||||
- build-freebsd
|
||||
- build-windows
|
||||
- build-android
|
||||
outputs:
|
||||
@@ -846,12 +883,6 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout Kryon Appcast Tool
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git submodule update --init --depth 1 vendor/kryon
|
||||
test -f vendor/kryon/scripts/make_appcast.py
|
||||
|
||||
- name: Download Release Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
@@ -877,6 +908,16 @@ jobs:
|
||||
done < <(scripts/list-expected-release-assets.sh "$VERSION")
|
||||
exit "$missing"
|
||||
|
||||
- name: Require a Passing Phone Check for a New Version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION=$(python3 scripts/check-version.py --print-version)
|
||||
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
||||
echo "v$VERSION is already tagged; no new version to check"
|
||||
exit 0
|
||||
fi
|
||||
python3 scripts/check-phone-check.py "$VERSION"
|
||||
|
||||
- name: Create and Push Tag If Version Is New
|
||||
id: tag_version
|
||||
env:
|
||||
@@ -950,11 +991,22 @@ jobs:
|
||||
arch="${arch%.rpm}"
|
||||
channels+=("--channel" "rpm-$arch=$rpm")
|
||||
done
|
||||
# Directly installed APKs update themselves from these channels;
|
||||
# the Google Play and F-Droid builds update through their stores.
|
||||
while IFS= read -r apk; do
|
||||
abi="$(basename "$apk" .apk)"
|
||||
abi="${abi#inbe-$VERSION}"
|
||||
case "$abi" in
|
||||
-gplay|-fdroid) continue ;;
|
||||
"") channels+=("--channel" "android=$apk") ;;
|
||||
*) channels+=("--channel" "android$abi=$apk") ;;
|
||||
esac
|
||||
done < <(find build/release -maxdepth 2 -name "inbe-$VERSION*.apk" | sort)
|
||||
if [ ${#channels[@]} -eq 0 ]; then
|
||||
echo "no release artifacts found for the appcast"
|
||||
exit 1
|
||||
fi
|
||||
python3 vendor/kryon/scripts/make_appcast.py \
|
||||
python3 scripts/make_appcast.py \
|
||||
--version "$VERSION" \
|
||||
--base-url "$BASE" \
|
||||
--notes-url "https://github.com/waozixyz/inbe/releases/tag/$TAG" \
|
||||
@@ -1413,6 +1465,6 @@ jobs:
|
||||
fi
|
||||
"$HOME/wingetcreate" update xyz.waozi.inbe \
|
||||
--version "$VERSION" \
|
||||
--urls "$SETUP_URL#x64" "$SETUP_URL#x86" \
|
||||
--urls "$SETUP_URL#x64" \
|
||||
--submit \
|
||||
--token "$WINGET_TOKEN"
|
||||
+11
@@ -15,6 +15,8 @@
|
||||
.ccache
|
||||
*.wasm
|
||||
build/
|
||||
/backup/
|
||||
/output/
|
||||
tmp/
|
||||
vendor-builds/
|
||||
node_modules
|
||||
@@ -70,3 +72,12 @@ __pycache__/
|
||||
|
||||
/pro/
|
||||
.kotlin/
|
||||
ziran.local.toml
|
||||
|
||||
# Sun salutation reference videos and frames, and check images; the
|
||||
# renderers write their videos and frames under build/.
|
||||
design/sun-salutation/*/reference.mp4
|
||||
design/sun-salutation/*/reference-*.png
|
||||
design/sun-salutation/generated-video-cut/source.mp4
|
||||
design/sun-salutation/girl-parts/head-layers-check.png
|
||||
.wrangler/
|
||||
@@ -1,9 +0,0 @@
|
||||
[submodule "vendor/rini"]
|
||||
path = vendor/rini
|
||||
url = https://github.com/raysan5/rini.git
|
||||
[submodule "vendor/sqlite"]
|
||||
path = vendor/sqlite
|
||||
url = https://github.com/sqlite/sqlite
|
||||
[submodule "vendor/kryon"]
|
||||
path = vendor/kryon
|
||||
url = https://github.com/kryonlabs/kryon.git
|
||||
@@ -2,23 +2,51 @@
|
||||
|
||||
## Ownership and releases
|
||||
|
||||
- Never edit `vendor/`. Change Kryon in its upstream repository on `master`,
|
||||
commit and push there, then update only Inbe's clean submodule pointer.
|
||||
Run `make no-vendor-edits` after dependency changes.
|
||||
- Dependencies are Ziran packages pinned in `ziran.toml`/`ziran.lock` and
|
||||
linked under `build/packages/`; there is no `vendor/`. Never edit a package
|
||||
checkout. Change Kryon (or any dependency) in its own repository on `master`,
|
||||
commit and push there, then run `ziran update NAME` here and commit
|
||||
`ziran.lock`. Run `make package-check` after dependency changes. For local
|
||||
debugging, map a package to a working repository in the ignored
|
||||
`ziran.local.toml`; release builds use `PACKAGE_FLAGS=--locked`.
|
||||
- Add the numeric release to `CHANGELOG.md`, then run `./update_version.sh`.
|
||||
The canonical macros are `APP_VERSION_STRING`, `APP_VERSION_MAJOR`,
|
||||
`APP_VERSION_MINOR`, and `APP_VERSION_PATCH`; do not create aliases.
|
||||
Only the GitHub Actions release workflow creates or pushes release tags.
|
||||
- A new version publishes only with a passing phone check of its exact
|
||||
sources: build the APK from the committed release, run
|
||||
`make phone-check APK=...` with the development Moto connected through the
|
||||
ThinkPad, and commit `releases/phone-checks/VERSION.json`. Changes to app
|
||||
sources after the check require a new one.
|
||||
- Packages declare the oldest host interface they run on (`host_api` per app
|
||||
in `apps/versions.json`); the host runs `oldest_host_api` to `host_api`.
|
||||
Raise `host_api` when the host interface changes and `oldest_host_api` only
|
||||
when it can no longer run older packages. `make package-compat-test` runs
|
||||
the node's packages in this build and new packages in the last release.
|
||||
- Goal (owner, 2026-10-11): every app updates through its own package
|
||||
without a new APK. Work toward it in small steps alongside requested work;
|
||||
discuss larger moves with the owner first. Put app screens, rules and text
|
||||
in `apps/<app>/`, not in the host under `src/`. Habits and Practices still
|
||||
draw compiled host screens (see [docs/cells.md](docs/cells.md)); when work
|
||||
touches one, prefer moving it into its package. Keep the host interface
|
||||
small and generic (storage, network, locale, platform effects), because
|
||||
each new host call needs an APK before a package can use it. Apps share
|
||||
data only through the host interface, never another app's internals.
|
||||
- Translate changed strings in every affected locale; no English placeholders.
|
||||
- `make locale-translated-test` fails on any locale string that still equals
|
||||
its English text. Translate it; add it to `tests/locale_same_as_english.txt`
|
||||
only when it is a real brand name, loanword, or format string.
|
||||
|
||||
## Machine-checked contracts
|
||||
|
||||
- `make build-laws` is mandatory for native, web, and Windows artifacts;
|
||||
Gradle and CMake enforce the same version and proof checks independently.
|
||||
Never bypass a failed gate or hand-edit generated policy tables.
|
||||
- Retry behavior lives in `laws/sync_retry/main.bend`. Implement changes there
|
||||
and prove `LAWS.bend` in `PROOF.bend`; the app consumes the checked table.
|
||||
Do not weaken laws to make an implementation pass. Contract changes require
|
||||
Never bypass a failed gate.
|
||||
- Laws are Ziran `#law` obligations checked by `ziran check`. Retry behavior
|
||||
lives in `src/app/sync_retry.zi` with its laws in `sync_retry_laws.zi`;
|
||||
private-data names live in `src/storage/storage_layout.zi` with laws in
|
||||
`storage_layout_laws.zi`. Change the implementation freely, but do not
|
||||
weaken laws to make an implementation pass. Contract changes require
|
||||
explicit product intent and separate review from implementation changes.
|
||||
- Run `make proof-test sync-recovery-test version-test` for these contracts.
|
||||
Coverage, trust boundaries, and the next proof migrations are described in
|
||||
@@ -26,7 +54,8 @@
|
||||
|
||||
## Public UI and sync boundaries
|
||||
|
||||
- Use `Text(TextProps)`, `Image(ImageProps)`, and `Button(ButtonProps)` directly.
|
||||
- Use current Kryon calls `Text(session, TextProps)`,
|
||||
`Image(session, ImageProps)`, and `Button(session, ButtonProps)` directly.
|
||||
Semantic images use the same `Image` surface. No positional Text, legacy
|
||||
drawing calls, alternate widgets, or thin local forwarding wrappers.
|
||||
Keep meaningful compositions and gestures; use standard Checkbox and Toggle.
|
||||
@@ -34,9 +63,17 @@
|
||||
- If a required widget capability is missing, implement the reusable primitive
|
||||
upstream first. Do not work around it in Inbe or generated code.
|
||||
- Use sync protocol v6 and the clean Kryon API; no new `Ksync` names or wrappers.
|
||||
Keep legacy wire strings only for migration. Migrations must be automatic,
|
||||
resumable, and non-destructive, preserving tombstones and legacy projections
|
||||
while supported older installations can return.
|
||||
Remove old wire projections and format fallbacks as the storage and sync
|
||||
modules are converted to current Ziran. Keep the current protocol and data
|
||||
model in Inbe rather than adding compatibility adapters.
|
||||
- Keep on-disk schema and user-data upgrade paths. Convert their implementation
|
||||
to checked Ziran; do not delete a migration merely because it handles an old
|
||||
database. An upgrade must preserve existing data, and its replacement needs
|
||||
a test using an older database fixture before the prior path is removed.
|
||||
- A `.zi` filename is not a completed migration. All owned application
|
||||
behavior, including storage upgrades, must compile as current Ziran. Prefer
|
||||
direct Ziran foreign imports for native libraries; migrate owned C adapters
|
||||
as Ziran gains the required ABI support. Never keep application policy in C.
|
||||
|
||||
## Product behavior and readability
|
||||
|
||||
@@ -49,11 +86,3 @@
|
||||
- Use descriptive names, explicit control flow, and focused helpers. Never
|
||||
compress multiple statements, branches, declarations, or checks onto one line.
|
||||
Format changed source, inspect the final diff, and run `git diff --check`.
|
||||
|
||||
## Bend
|
||||
|
||||
When using Bend:
|
||||
- run `bend guide` to learn it
|
||||
- use `LAWS.bend` to keep important rules
|
||||
- run `bend PROOF.bend` before committing
|
||||
- parallelize the code whenever possible
|
||||
+357
-2
@@ -1,4 +1,359 @@
|
||||
# Changelog
|
||||
## [2.1.33] - 2026-10-13
|
||||
### Added
|
||||
- Lumi guides you through each screen.
|
||||
- Lumi understands habit requests offline.
|
||||
- Lumi asks before going online.
|
||||
- Your own AI provider for Lumi.
|
||||
- Tap Lumi and she swirls.
|
||||
### Changed
|
||||
- Sun Salutation follows your breath.
|
||||
- Span habits: one Good when, length first in statistics.
|
||||
### Fixed
|
||||
- Synced habit settings and days never revert to older copies.
|
||||
- Android: opens about two seconds faster.
|
||||
- Desktop tray shows the current logo.
|
||||
- Progress bars fill visibly in every theme.
|
||||
|
||||
## [2.1.32] - 2026-10-13
|
||||
### Added
|
||||
- Drag habits to reorder or deactivate them.
|
||||
- Habits get icons, schedules, times and daily questions.
|
||||
- Questions can compare with your average.
|
||||
- Apps asks before downloading app updates.
|
||||
### Changed
|
||||
- Habits is a table of the last seven days.
|
||||
### Fixed
|
||||
- Android: the floating practice window opens from Recents and shows results.
|
||||
- The donation reminder shows on one device only.
|
||||
- Held keys repeat in text fields.
|
||||
- The breathing count is readable; older habit entries edit again.
|
||||
|
||||
## [2.1.31] - 2026-10-11
|
||||
### Fixed
|
||||
- Android: after the floating practice window, the app fits the screen again instead of running under the status bar and navigation and losing its sides.
|
||||
|
||||
## [2.1.30] - 2026-10-11
|
||||
### Fixed
|
||||
- Long menus, such as the colour theme, scroll by touch and open at your choice.
|
||||
- With a menu open, tapping the navigation closes it and switches screens in one tap.
|
||||
- Menus stay above the navigation instead of hiding their last options behind it.
|
||||
- Web: the app is sharp on high-density screens instead of magnified and blurry.
|
||||
### Changed
|
||||
- Icons are sharper on the web.
|
||||
|
||||
## [2.1.29] - 2026-10-11
|
||||
### Fixed
|
||||
- Scrolling Lumi's commands keeps the keyboard open.
|
||||
- New habits show each colour choice in its own colour.
|
||||
- Leaving Wim Hof no longer freezes the app for a few seconds.
|
||||
- The app no longer freezes just after launch while it checks for app updates.
|
||||
### Changed
|
||||
- Scrollbars use your theme's colours and show how much is in view.
|
||||
- Apps rearranges to fill the window's width.
|
||||
|
||||
## [2.1.28] - 2026-10-10
|
||||
### Added
|
||||
- Connect a phone and a computer by QR code in Profile.
|
||||
- Leaderboard is its own app.
|
||||
- Profile > Data shows each sync node's storage.
|
||||
### Changed
|
||||
- Profile holds your account, data and Telegram; Settings holds device preferences.
|
||||
- Diary shows bold text as bold.
|
||||
- On desktop, a minimized practice opens in its own window.
|
||||
### Fixed
|
||||
- Linux: text uses Inner Breeze's fonts again.
|
||||
- Smoother minimized breathing count.
|
||||
- The desktop close prompt shows above Apps.
|
||||
|
||||
## [2.1.27] - 2026-10-10
|
||||
### Added
|
||||
- End a held breath from the minimized practice window with Breath or a double tap.
|
||||
- Lumi feedback includes the app version, device and system.
|
||||
### Fixed
|
||||
- Picture-in-picture opens when you leave Inbe during a practice and returns to it.
|
||||
- Lumi keeps answers that arrive during picture-in-picture.
|
||||
- Lumi says whether feedback reached the developer and keeps it to retry.
|
||||
- Feedback saved by older versions is now sent.
|
||||
- Fix a startup crash on 32-bit Android phones.
|
||||
|
||||
## [2.1.26] - 2026-10-09
|
||||
### Added
|
||||
- Detach a running practice into its own resizable desktop window.
|
||||
- Keep the practice visible over other Android apps with picture-in-picture, which you can turn off in Settings.
|
||||
### Changed
|
||||
- The minimized practice window is taller and shows the breath count, time left or phase.
|
||||
- Diary saves quietly, without a "Waiting to save" note.
|
||||
### Fixed
|
||||
- Show the keyboard in Diary on Android.
|
||||
- Keep the practice window over Apps.
|
||||
- Open Lumi without freezing the practice window.
|
||||
|
||||
## [2.1.25] - 2026-10-09
|
||||
### Changed
|
||||
- Minimized practices show their live circle or figure in a resizable window and return to the page you started them from.
|
||||
### Fixed
|
||||
- Stop syncing from pausing the breathing circle while you practice.
|
||||
- Keep breath sounds playing while a practice is minimized.
|
||||
- Animate the Wim Hof breathing circle smoothly, including its Customize preview.
|
||||
- Keep Wim Hof timing accurate when the frame rate varies.
|
||||
- Skip repeated account checks on unchanged animation frames.
|
||||
|
||||
## [2.1.24] - 2026-10-09
|
||||
### Fixed
|
||||
- Open the breathing animation, background music and other menus reliably again.
|
||||
- Use the In / Out breathing animation you choose in Wim Hof sessions.
|
||||
- Offer Test for your own imported music instead of "Audio not installed".
|
||||
- Keep the breathing circle smooth on phones signed in to an account.
|
||||
|
||||
## [2.1.23] - 2026-10-09
|
||||
### Added
|
||||
- Customize KSS in Appearance with live preview, per-app styles, an inspector, undo, and reset to defaults.
|
||||
- Ask Lumi to read, preview, and save appearance changes while preserving your existing customizations.
|
||||
### Fixed
|
||||
- Keep Telegram as input to Lumi without bot notifications; retain messages, replies and full history in Lumi.
|
||||
|
||||
|
||||
## [2.1.22] - 2026-10-08
|
||||
### Added
|
||||
- Minimize a running practice into a small window and keep using the app.
|
||||
### Fixed
|
||||
- Keep Diary opening with existing entries in the same account.
|
||||
- Keep practices and sound running in the background.
|
||||
- Support swipe typing and corrections from Android keyboards.
|
||||
- Stop repeated Lumi chat uploads.
|
||||
- Keep navigation visible on the practice home screen.
|
||||
- Open Lists, Diary and settings faster.
|
||||
- Lumi in Telegram replies in seconds and shows your tasks and habits.
|
||||
|
||||
## [2.1.21] - 2026-10-08
|
||||
### Changed
|
||||
- Clearly mark the selected app in navigation and Apps, including while hovering or pressing.
|
||||
### Fixed
|
||||
- Keep text sharp and stable throughout the zoom range.
|
||||
- Keep Appearance labels readable at large zoom by wrapping them above their controls.
|
||||
- Keep the selected navigation shortcut visible when changing apps or zooming on narrow screens.
|
||||
|
||||
## [2.1.20] - 2026-10-08
|
||||
### Changed
|
||||
- Keep Apps beside your desktop favorites without a large empty gap.
|
||||
- Open Profile beside Settings in Apps, without a fixed desktop Profile shortcut.
|
||||
### Fixed
|
||||
- Fix blank desktop pages when regional settings use comma decimals.
|
||||
|
||||
## [2.1.19] - 2026-10-08
|
||||
### Added
|
||||
- Create or restore an account in Telegram's Mini App, with an encrypted recovery backup saved on your device.
|
||||
- Connect Telegram with approved, expiring Lumi access without sharing your account's private key.
|
||||
### Changed
|
||||
- Keep Telegram access limited to Lumi and let you revoke it from Inbe.
|
||||
### Fixed
|
||||
- Preserve existing account data when account setup or recovery is cancelled or fails.
|
||||
|
||||
## [2.1.18] - 2026-10-08
|
||||
### Changed
|
||||
- Show each app's bundle size in Apps and favorites.
|
||||
- Start with the searchable Apps screen and ready-to-use apps, without an install chooser.
|
||||
- Give new users Lumi, Habits and Practices as their first three favorites.
|
||||
- Arrange favorites by dragging app tiles in Apps, with no separate Apps and Favorites settings page.
|
||||
- Remove the extra Inbe heading above Apps.
|
||||
|
||||
## [2.1.17] - 2026-10-07
|
||||
### Changed
|
||||
- Choose apps from a searchable library with a compact favorites dock on mobile and desktop.
|
||||
- Pin up to two favorites without removing other apps or their saved data.
|
||||
- Open Profile and Settings from the app library, with a Profile shortcut on desktop.
|
||||
|
||||
## [2.1.16] - 2026-10-07
|
||||
### Changed
|
||||
- Open faster by keeping feature packages loaded and loading language fonts only when needed.
|
||||
- Use Android's installed fonts with automatic character fallback where available.
|
||||
- Prepare Android audio when first used so it no longer delays opening the app.
|
||||
### Added
|
||||
- Show a loading indicator on Android until the first app screen is ready.
|
||||
|
||||
## [2.1.15] - 2026-10-07
|
||||
### Fixed
|
||||
- Open Telegram sync links on Android when the installed chat app is hidden from app availability checks.
|
||||
- Open Lumi in the installed Telegram app on Android, with a web link available when Telegram is not installed.
|
||||
|
||||
## [2.1.14] - 2026-10-07
|
||||
### Changed
|
||||
- Scroll up through Lumi chat history without Older and Newer buttons, keeping your place when replies arrive.
|
||||
- Connect, view connection status and disconnect Telegram from Settings under Sync with Telegram.
|
||||
|
||||
## [2.1.13] - 2026-10-07
|
||||
### Changed
|
||||
- Merge sync data directly from the action buttons below the change list, without a separate Apply step.
|
||||
- Review clearer sync changes with colored additions, removals and edits, and fewer repeated or empty details.
|
||||
|
||||
## [2.1.12] - 2026-10-07
|
||||
### Fixed
|
||||
- Display bold emphasis in Lumi replies and recognize app feature suggestions as feedback offline.
|
||||
- Keep app text visible when upgrading to the new Lumi formatting.
|
||||
|
||||
## [2.1.11] - 2026-10-07
|
||||
### Added
|
||||
- Ask Lumi for progress charts and donation links directly in chat.
|
||||
- Talk naturally with Lumi online, with a daily account allowance and access to app actions.
|
||||
- Save app feedback from chat, send it when connected, and receive developer replies in Lumi.
|
||||
### Fixed
|
||||
- Keep feedback available when online chat is disabled or its allowance runs out.
|
||||
|
||||
## [2.1.10] - 2026-10-06
|
||||
### Fixed
|
||||
- Open and scroll Lumi smoothly, including longer conversations.
|
||||
- Use a checkmark for Lists so it is easy to distinguish from Diary.
|
||||
|
||||
## [2.1.9] - 2026-10-06
|
||||
### Fixed
|
||||
- Keep hidden apps installed so adding them back to the sidebar works immediately offline.
|
||||
- Preserve the selected page during upgrades and restore missing shortcuts for selected apps.
|
||||
- Keep the interface responsive if an app fails to reset, and reduce repeated work in Lumi chat.
|
||||
- Open the Android keyboard correctly when writing to Lumi.
|
||||
|
||||
## [2.1.8] - 2026-10-06
|
||||
### Changed
|
||||
- Call sidebar items Apps throughout setup and settings.
|
||||
- Use Shift+Enter for a new line in Lumi chat and Enter to send.
|
||||
### Fixed
|
||||
- Save Diary entries from Lumi chat with the current time above your message, including multiline text.
|
||||
- Ask for the entry text when a Diary request is sent without it, and keep replies short when a request is unclear.
|
||||
- Show Lumi’s mirrored avatar beside replies so the companion faces the conversation.
|
||||
|
||||
## [2.1.7] - 2026-10-06
|
||||
### Changed
|
||||
- Manage Lumi and all other cells in one compact list with icons, drag handles and add/remove controls.
|
||||
- Include Lists and Diary with the app so every cell can be added to the sidebar offline.
|
||||
|
||||
## [2.1.6] - 2026-10-06
|
||||
### Changed
|
||||
- Manage installed and available cells together in Settings, with drag reordering, trash controls and quick reinstallation from saved packages.
|
||||
- Keep Lumi included as the app companion while allowing her sidebar shortcut to be hidden, with an outlined firefly icon matching the other navigation icons.
|
||||
- Let Lumi change themes and appearance directly through chat and app tools.
|
||||
### Fixed
|
||||
- Keep sidebars steady while dragging the scale slider and apply the new scale on release.
|
||||
- Keep Settings available in the final sidebar position.
|
||||
- Honor every checked startup cell, including Diary, and report Diary correctly when opened in Harmony.
|
||||
- Exit promptly when Quit is pressed in the close dialog.
|
||||
|
||||
## [2.1.5] - 2026-10-06
|
||||
### Changed
|
||||
- Chat with Lumi in a simpler conversation view, with her avatar beside replies and a standard cell icon.
|
||||
- Let Lumi complete today’s habits and start practices immediately, including WHM.
|
||||
- Show Lumi commands only for installed and enabled cells.
|
||||
- Ask which habit to complete, choose it by name, and use compact autocomplete chips with case-insensitive matching and command spelling correction.
|
||||
|
||||
## [2.1.4] - 2026-10-06
|
||||
### Added
|
||||
- Meet Lumi, Inner Breeze's firefly companion, as the first recommended cell and home screen.
|
||||
- Chat privately with Lumi, complete commands and todo names as you type, and add, complete or reopen todos locally.
|
||||
### Fixed
|
||||
- Restore missing characters in translations and mixed-language labels, including the Android language picker.
|
||||
|
||||
## [2.1.3] - 2026-10-06
|
||||
### Fixed
|
||||
- Restore translated text after the cell packages load, and refresh translations when packages change.
|
||||
|
||||
## [2.1.2] - 2026-10-06
|
||||
### Changed
|
||||
- Call the independently installed features Cells, with a translated cell picker and separate versions in About.
|
||||
|
||||
## [2.1.1] - 2026-10-06
|
||||
### Added
|
||||
- Attach, browse and remove Diary photos while preserving imported originals.
|
||||
- Load graphics, translations, fonts and styles from cell packages so these resources can update without replacing the APK.
|
||||
- Update the cell picker, Diary and Lists screens through their cell packages.
|
||||
### Fixed
|
||||
- Keep browser account signing and update checks working with the current web runtime.
|
||||
- Keep importing saved account data working in the browser.
|
||||
|
||||
## [2.1.0] - 2026-10-06
|
||||
### Added
|
||||
- Choose recommended Habits and Practices or download optional Lists and Diary from the cell picker.
|
||||
- Receive verified cell updates independently, with a switch to disable automatic updates and a manual update check.
|
||||
- Sync selected apps with your account, including removals, while keeping saved data on each device.
|
||||
- Write private daily entries in Diary and browse them by calendar, preserving the existing Harmony entry format.
|
||||
- View the main application version and each cell version in About.
|
||||
|
||||
## [2.0.12] - 2026-10-06
|
||||
### Fixed
|
||||
- Restore banners and navigation icons when returning to the Android app or changing orientation.
|
||||
- Keep images from disappearing or showing font characters after graphics resources are recreated.
|
||||
- Restore missing characters in translated screens.
|
||||
- Keep Classic and Lightfield styles working on profile actions.
|
||||
|
||||
## [2.0.11] - 2026-10-04
|
||||
### Changed
|
||||
- Lists, Habits, and Practice now load as separate modules inside Inner Breeze, with shared navigation, settings, and saved data.
|
||||
|
||||
## [2.0.10] - 2026-10-02
|
||||
### Changed
|
||||
- Smoothed the outlines of all four Sun Salutation characters during movement.
|
||||
|
||||
### Fixed
|
||||
- Corrected the women's neck placement and removed white fringes and specks around their clothing.
|
||||
|
||||
## [2.0.9] - 2026-10-02
|
||||
### Added
|
||||
- Choose between four painted Sun Salutation characters in Customize. Your choice is saved and appears in the practice, pose previews, and guide.
|
||||
|
||||
### Changed
|
||||
- Replaced the previous Sun Salutation character with the four banner-inspired designs. The men wear distinct rust-and-charcoal and indigo-and-sand outfits.
|
||||
|
||||
## [2.0.8] - 2026-10-02
|
||||
### Fixed
|
||||
- Fixed an Android startup crash after upgrading from older versions, while preserving saved preferences and practice history.
|
||||
- Keep drawing the app when a device cannot allocate the graphics buffers used for screen transitions.
|
||||
- Show the selected breathing speed, round count, breath count, and pause duration in Wim Hof customization.
|
||||
- Keep the progressive start-speed editor's preview and slider visible.
|
||||
|
||||
## [2.0.7] - 2026-10-01
|
||||
### Added
|
||||
- Mini mode provides a compact practice window without changing your saved window or navigation settings.
|
||||
- Habits now have separate overview, statistics, and edit pages, with a dialog for recording daily counts and clearer week and month calendars.
|
||||
|
||||
### Changed
|
||||
- Prebuilt FreeBSD packages are temporarily unavailable.
|
||||
- Sun Salutation now uses a painted character with smooth movement through all twelve poses, consistent proportions, and clean transitions without crossfading.
|
||||
- Practice customization and guides use the full screen, and Sun Salutation shows a simple seconds counter without the distracting progress bar.
|
||||
- Improved phone performance, touch responsiveness, text sizing, and Japanese and Chinese text wrapping.
|
||||
- Refined Settings, Profile, Lists, habit cards, session controls, and mood check-in buttons. Desktop users can zoom with Ctrl and the mouse wheel.
|
||||
|
||||
### Fixed
|
||||
- Music keeps playing when you switch tabs inside the app or leave practice customization.
|
||||
- Restored sound and music playback in the web app.
|
||||
- Appearance dropdown menus stay above the Layout card and other settings, keeping every option visible and selectable.
|
||||
- Practice Customize and How-to actions now open the correct pages, and carousel swipes reliably change practices.
|
||||
- Animated screens keep their controls visible, and navigation transitions finish before accepting the next action.
|
||||
- Habit statistics no longer crash, and saved habit counts and imported records are retained correctly.
|
||||
- Opening a habit card keeps your place in the list instead of scrolling back to the top.
|
||||
- Habit day counts sit centered inside each circle, in a color that stays readable on every habit color.
|
||||
- Deleted sync records stay deleted across devices, and restoring an account preserves local changes waiting to sync.
|
||||
- Web and browser add-on text stays sharp at different text sizes, display scales, and zoom levels with the Canvas renderer.
|
||||
- Cancel reliably closes the exit-session dialog without interrupting the practice.
|
||||
|
||||
## [2.0.6] - 2026-09-22
|
||||
### Fixed
|
||||
- Selected app color themes now keep their backgrounds, cards, and text visible. Theme catalogs are included in every build, and an unavailable palette falls back to readable built-in colors.
|
||||
|
||||
## [2.0.5] - 2026-09-21
|
||||
### Changed
|
||||
- Session details now show the practice name, time, and round count above clearly separated round rows with larger hold times and easier-to-tap edit and delete actions. Editing a round highlights its value and provides a labeled number pad with separate Cancel and Save actions.
|
||||
|
||||
## [2.0.4] - 2026-09-21
|
||||
### Changed
|
||||
- The account screen shows the connected alias, automatic sync progress, and counts for habits, history days, sessions, friends, lists, and list items.
|
||||
- Habits show a distinct mark for days completed through a practice session.
|
||||
- Importing an account key offers Merge or Replace before changing local data, with clear details about each choice.
|
||||
- Profile offers Connect Account, and the sync screen offers Import .key when no account is connected.
|
||||
|
||||
### Fixed
|
||||
- Restoring an existing account now retrieves its username, friends, habits, history, and sessions from the complete account data.
|
||||
- Lists and their items now sync across devices, including completed items and changes made on another device.
|
||||
- Sync status shows the current upload or restore step instead of staying on a generic syncing message.
|
||||
- Connecting an account starts automatic sync without leaving a stale status message behind.
|
||||
|
||||
## [2.0.3] - 2026-09-20
|
||||
### Fixed
|
||||
- Web and browser builds can connect to compatible custom sync servers when you choose one.
|
||||
@@ -94,7 +449,7 @@
|
||||
|
||||
## [1.9.16] - 2026-08-29
|
||||
### Changed
|
||||
- Sync now speaks Ksync protocol v5 compatibility mode while keeping existing secure synced data usable.
|
||||
- Sync remains compatible with existing secure account keys and synced data.
|
||||
|
||||
### Fixed
|
||||
- Fixed web sync key import stability in Firefox.
|
||||
@@ -274,7 +629,7 @@
|
||||
## [1.9.0] - 2026-08-15
|
||||
### Added
|
||||
- Break reminders, Workrave-style: micro, rest and daily break timers with statistics and a desktop timer HUD that lives as a real OS window next to the app (desktop only, off by default, with its own settings tab).
|
||||
- A dedicated Notifications settings tab. Push delivery uses UnifiedPush (no Google services): "Set up push" opens an in-app picker that lists installed distributor apps with their name and icon and registers with the one you pick; the status line reports the real registration state.
|
||||
- A dedicated Notifications settings tab. Push delivery uses UnifiedPush (no Google services): "Set up push" opens an in-cell picker that lists installed distributor apps with their name and icon and registers with the one you pick; the status line reports the real registration state.
|
||||
- Reminders are an editable list: add as many as you want, each with a practice dropdown (Wim Hof, Meditation, Sun Salutation), a [-] time [+] stepper, an on/off toggle and delete. Ships with one enabled Wim-Hof 08:00 reminder.
|
||||
- A notification when new friend requests arrive over social sync (toggleable, on by default).
|
||||
- Screenshot scenes for the first-run guide and the notifications settings, for regression coverage.
|
||||
|
||||
@@ -17,8 +17,13 @@ Inner Breeze is a free, open-source practice app for breathing, meditation, and
|
||||
habit tracking. It works offline, stores data locally in SQLite, and can
|
||||
optionally sync user-owned data through a Daochi-compatible sync server.
|
||||
|
||||
[Account activity](docs/ACCOUNT_ACTIVITY.md) explains persistent Telegram linking,
|
||||
reopening an authorized installation, and seeing and controlling the running
|
||||
practice from another device connected to the same account.
|
||||
|
||||
## Features
|
||||
|
||||
- Lumi, a local firefly companion with private chat, habit completion, practice starts, and optional todo tools
|
||||
- Guided practice sessions with visual and audio cues
|
||||
- Mind, Yoga, and Fitness organization for different practice routines
|
||||
- Customizable breathing sessions, meditation timers, and habit counters
|
||||
@@ -29,16 +34,12 @@ optionally sync user-owned data through a Daochi-compatible sync server.
|
||||
|
||||
## Build
|
||||
|
||||
The build host needs Node.js 22.18 or newer for mandatory Bend proof checking,
|
||||
as well as Python 3 and the platform's native build dependencies. Node and Bend
|
||||
are build tools; they are not installed with the app. See
|
||||
[build contracts and proofs](docs/build-laws-plan.md) for the checked behavior.
|
||||
The build checks Inbe's laws with the Ziran compiler (`ziran check`); no
|
||||
separate proof tool is needed. The build host needs Python 3 and the platform's
|
||||
native build dependencies. See [build laws](docs/build-laws-plan.md) for the
|
||||
checked behavior.
|
||||
|
||||
Initialize the submodules once:
|
||||
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
Build commands fetch the dependencies pinned in `ziran.lock`.
|
||||
|
||||
Build and run the desktop app:
|
||||
|
||||
@@ -70,10 +71,88 @@ make site
|
||||
|
||||
Run the test suite:
|
||||
|
||||
[Custom appearance](docs/appearance.md) describes live KSS editing, per-app
|
||||
customizations, reset, and Lumi's appearance tools.
|
||||
|
||||
```bash
|
||||
make test
|
||||
make visual-test
|
||||
```
|
||||
|
||||
CI and releases require the visual gate. It uses disposable profiles and
|
||||
private Xvfb displays to check glyph pixels, every zoom from 50% to 250%,
|
||||
selected navigation and app cards in all 13 palettes and both color modes,
|
||||
enlarged Appearance labels, shipped locales, and page interactions. It keeps
|
||||
screenshots and logs under `build/`; CI uploads them even when a check fails.
|
||||
Every visual suite runs even if an earlier suite fails. The complete result,
|
||||
including hashes of the tested binary and bundles, is in
|
||||
`build/visual-test/results.json`; changing an artifact during the gate fails it.
|
||||
Its system tools are listed in `.github/apt/test-packages.txt`.
|
||||
|
||||
Store captures cover Apps, Lumi, Practices, Habits, Lists, Diary, Appearance,
|
||||
and supporting pages in phone, 7-inch tablet, 10-inch tablet, and Chromebook
|
||||
layouts. Capture runs use disposable profiles on private Xvfb displays and
|
||||
check viewport sizes, nonblank rendering, and expected screen text. They do
|
||||
not copy images into the store listing until visual review is recorded:
|
||||
|
||||
```bash
|
||||
make native cells PACKAGE_FLAGS=--locked
|
||||
make screenshot
|
||||
# Inspect build/screenshots/review-*.jpg and the full-size PNGs.
|
||||
make screenshot-review REVIEWER="your name"
|
||||
make screenshot-export
|
||||
make play-preflight
|
||||
python3 scripts/upload-play-screenshots.py
|
||||
```
|
||||
|
||||
The scene list in `scripts/screenshot-scenes.json` selects eight store images
|
||||
per phone/tablet type while retaining all 64 captures for review. Changing
|
||||
source, scene definitions, Kryon, binaries, bundles, or screenshot bytes
|
||||
invalidates publishing preflight. A historical capture can still be visually
|
||||
reviewed and used for a review video; Play requires a fresh capture of the
|
||||
current locked build. Local Kryon preview builds cannot pass Play preflight.
|
||||
Preflight checks every dependency against its locked commit and runs a fresh
|
||||
source check, so reused incremental preview outputs cannot hide missing imports.
|
||||
Keep credentials in the ignored `.env.play` using `.env.play.example`.
|
||||
The uploader defaults to validating and discarding its remote edit. After
|
||||
review, `PLAY_COMMIT=1 python3 scripts/upload-play-screenshots.py` validates
|
||||
and commits the listing; a failed edit is discarded. This updates listing
|
||||
assets only. App releases follow the numeric changelog, `update_version.sh`,
|
||||
and the existing release workflow, which builds and publishes the signed
|
||||
Google Play AAB and owns release tags. A local build or commit is not a Play
|
||||
deployment.
|
||||
|
||||
`make lumi-promo` renders a narrated portrait review MP4 from the exact
|
||||
reviewed phone captures and the generated artwork in `design/lumi-promo/`.
|
||||
Lumi uses eight generated wing-flapping frames, flies to each screen and settles
|
||||
facing the app while a narrator explains it. Lumi turns with the flight direction
|
||||
and flips inward after arriving on the right. Wings flap continuously using
|
||||
distinct poses; each app screen stays in a fixed position without sliding in.
|
||||
The audio contains speech only, without music or sound effects. Scene timings
|
||||
expand to fit the complete spoken lines.
|
||||
`make lumi-narration` generates the stored narrator clips through OpenRouter
|
||||
using a locally configured `OPENROUTER_API_KEY`; unchanged clips are reused.
|
||||
The voice, script and provider options are in `design/lumi-promo/narration.json`.
|
||||
The chat example runs real local theme actions; the surrounding forest and
|
||||
glow are marketing effects. Inspect `build/lumi-promo/storyboard.jpg` and
|
||||
`build/lumi-promo/inner-breeze-lumi-review.mp4` before using it publicly.
|
||||
Google Play's preview video field takes a YouTube URL, so the MP4 needs an
|
||||
approved public or unlisted YouTube upload with embedding enabled before it can
|
||||
be added to the listing. Pass `--video-url https://www.youtube.com/watch?v=VIDEO_ID`
|
||||
to the listing uploader, or configure `PLAY_VIDEO_URL`. To update only the
|
||||
video, use `PLAY_COMMIT=1 python3 scripts/upload-play-screenshots.py --video-only --video-url URL`.
|
||||
The [Inner Breeze trailer](https://www.youtube.com/watch?v=GTly6Fu5zPk),
|
||||
"A Day with Lumi", is public on YouTube and configured in every Google Play
|
||||
listing language.
|
||||
`design/promo-film/` holds the trailer's sources: `film.json` (clips, voice
|
||||
times, app-screen inserts), `narrate.py` (Lumi's voice), `score.py` (music),
|
||||
`mix.py`, `keyframes.py` and `compose.py`, which renders the cut with the real
|
||||
app screens into `build/promo-video/`. `mix.py --short` and
|
||||
`compose.py --short` render the 36-second vertical short from `short.json`,
|
||||
the portrait keyframes in `keyframes-vertical/` and sections of the same score.
|
||||
Screenshot publishing still requires the complete current
|
||||
capture, visual review, export and locked build preflight.
|
||||
|
||||
To test sync and recovery against an isolated local server:
|
||||
|
||||
```bash
|
||||
@@ -83,19 +162,30 @@ make sync-server-test DAOCHI_BIN=/absolute/path/to/daochi
|
||||
This uses disposable client databases and a loopback server; see
|
||||
[web and sync test coverage](WEB_RENDERER_TESTS.md) for details.
|
||||
|
||||
The Apps picker, independent ZIB packages, update settings, account choices and
|
||||
publisher setup are described in [app packages](docs/cells.md).
|
||||
|
||||
Native binaries are written to `build/bin/<platform>/`. Release artifacts are
|
||||
written under `build/dist/`.
|
||||
|
||||
To debug Inbe against the root Kryon checkout instead of the vendored
|
||||
submodule, override `KRYON_DIR`:
|
||||
Dependencies, including Kryon and the Ziran toolchain, are pinned in
|
||||
`ziran.lock`. `make` fetches them into the Ziran package cache and links them
|
||||
under `build/packages/`; `sh scripts/packages.sh` does the same by hand.
|
||||
Builders that supply the sources themselves need no network: put Git checkouts
|
||||
containing the locked commits (including Kryon's `raylib` submodule) in
|
||||
`$ZIRAN_PACKAGE_SOURCES`, or declare them as F-Droid srclibs, which are found
|
||||
in `../srclib` automatically.
|
||||
|
||||
```bash
|
||||
make run KRYON_DIR=../kryon
|
||||
To debug Inbe against the root Kryon checkout, map it in an ignored
|
||||
`ziran.local.toml`:
|
||||
|
||||
```toml
|
||||
[overrides]
|
||||
kryon = "../../kryonlabs/kryon"
|
||||
```
|
||||
|
||||
Use this only for local debugging. Permanent Kryon fixes should be committed in
|
||||
the root Kryon repository and then brought into Inbe by updating
|
||||
`vendor/kryon`.
|
||||
the root Kryon repository and then brought into Inbe with `ziran update kryon`.
|
||||
|
||||
## Project Layout
|
||||
|
||||
@@ -104,7 +194,7 @@ the root Kryon repository and then brought into Inbe by updating
|
||||
- `locales/` - translations
|
||||
- `droid/` - Android project
|
||||
- `site/` - website
|
||||
- `vendor/kryon/` - Kryon UI/runtime submodule
|
||||
- `ziran.toml`, `ziran.lock` - pinned Ziran toolchain and dependencies
|
||||
|
||||
## Support
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
# Inner Breeze TODO
|
||||
|
||||
Marketing plan from 2026-10-02. Tick items off as they land and add a date or
|
||||
link where it helps. Inner Breeze's edge: free, no ads, no account, offline,
|
||||
open source, against breathing apps that charge $60–100 a year. It is also
|
||||
visual (painted practice art, the Sun Salutation characters), so put effort
|
||||
where those two things matter.
|
||||
|
||||
## Store listing
|
||||
|
||||
- [x] Rewrite the Play/F-Droid short and full descriptions around what people
|
||||
search for (Wim Hof breathing, box and 4-7-8 breathing, Sun Salutation,
|
||||
meditation timer, habit tracker, no ads, no account) in en-US, de-DE,
|
||||
es-ES, fr-FR and pt-BR. (2026-10-02)
|
||||
- [x] Regenerate the store screenshots from the current app at real phone and
|
||||
tablet scale: painted practice cards, a Sun Salutation pose and showcase
|
||||
habits (`make screenshot`). (2026-10-02)
|
||||
- [ ] Publish the new text and screenshots on Google Play. F-Droid reads them
|
||||
from this repo at the next release. `scripts/upload-play-screenshots.py`
|
||||
uploads images only; the text goes in through Play Console.
|
||||
- [ ] Make a new 1024x500 feature graphic in the painted style. The current
|
||||
one is the old pixel art.
|
||||
- [ ] Add a one-line caption to each store screenshot ("Wim Hof-style
|
||||
rounds", "Follow the Sun Salutation").
|
||||
- [ ] Keep "Wim Hof" out of the app title and icon. Wim Hof Method is a
|
||||
registered trademark; a description that says "based on the Wim Hof
|
||||
Method" is fine.
|
||||
- [ ] Fix the Portuguese app string "Saudacao ao sol" to "Saudação ao sol".
|
||||
- [ ] Give each channel its own tagged Play link, for example
|
||||
`https://play.google.com/store/apps/details?id=xyz.waozi.inbe&referrer=utm_source%3Dreddit`,
|
||||
and check Play Console's acquisition report every month.
|
||||
|
||||
## Short vertical video (best reach for new users)
|
||||
|
||||
- [ ] Record 30–60 second "breathe with me" sessions: a Wim Hof round, box
|
||||
breathing, a Sun Salutation sequence.
|
||||
- [ ] Post them on YouTube Shorts, TikTok and Instagram Reels. Reels can be
|
||||
posted by hand from the phone; the Meta API hold only blocks automation.
|
||||
- [ ] Finish Social's YouTube path: approval in Telegram and a background
|
||||
upload worker (yuebot `plugins/social`).
|
||||
- [ ] Optional: Pinterest pins for Sun Salutation and breathing technique
|
||||
guides, which keep bringing traffic for a long time.
|
||||
|
||||
## Reddit
|
||||
|
||||
Read each subreddit's self-promotion rules first. Post as the developer, show
|
||||
the app, and stay to answer comments.
|
||||
|
||||
- [ ] For users: r/WimHofMethod, r/breathwork, r/Meditation, r/yoga
|
||||
- [ ] For the free/open-source angle: r/androidapps, r/fossdroid,
|
||||
r/opensource, r/degoogle, r/linux
|
||||
|
||||
## Website (inbe.waozi.xyz)
|
||||
|
||||
- [ ] One page per technique with the `?mini` embed, so visitors practise on
|
||||
the page: box breathing timer, 4-7-8 breathing, Wim Hof-style breathing,
|
||||
Sun Salutation steps, meditation timer.
|
||||
- [ ] Put the Play and F-Droid links under each embed.
|
||||
|
||||
## Directories and launches (one-time)
|
||||
|
||||
- [ ] AlternativeTo: list Inner Breeze as an alternative to Calm, Headspace,
|
||||
Breathwrk and Prana Breath.
|
||||
- [ ] Flathub: check whether `packaging/flatpak/xyz.waozi.inbe.yml` is
|
||||
published, and submit it if not.
|
||||
- [ ] Open-source app lists (awesome lists, F-Droid collections).
|
||||
- [ ] Product Hunt launch.
|
||||
- [ ] One Show HN about how it is built: the whole app in Ziran and Kryon,
|
||||
running on Android, web, Linux and Windows. This brings developers and
|
||||
GitHub stars, not meditators, so do it once.
|
||||
|
||||
## Channels to keep small
|
||||
|
||||
- Facebook and Threads Pages: the Meta API is on hold (no business
|
||||
verification). Social is moving Facebook to the ThinkPad's signed-in
|
||||
Chromium instead.
|
||||
- X: the audience is mostly developers; keep it for Ziran and Kryon.
|
||||
- Telegram @lotusinbe: keeps current users engaged but does not find new ones.
|
||||
@@ -0,0 +1,60 @@
|
||||
# Changelog
|
||||
|
||||
## [1.1.10] - 2026-10-13
|
||||
|
||||
- Maintenance release for Inner Breeze 2.1.33.
|
||||
|
||||
## [1.1.9] - 2026-10-11
|
||||
|
||||
### Changed
|
||||
- Scrollbars use your theme's colours and show how much of the page is in view.
|
||||
|
||||
## [1.1.8] - 2026-10-10
|
||||
|
||||
### Added
|
||||
- Correct the spelling of an entry with one button. Inner Breeze sends the entry to the Waozi node, which returns it with only misspelled words corrected. It uses the same daily online allowance as Lumi.
|
||||
- Undo and redo buttons, so a correction or any other change can be taken back.
|
||||
|
||||
### Changed
|
||||
- A title bar shows the date in the middle, between the previous and next day. Today and the calendar sit together on the left, and the entry's tools are compact buttons on the right, leaving more room for writing.
|
||||
- The entry reaches the bottom of the screen; a notice takes room below it only while it is shown.
|
||||
|
||||
## [1.1.7] - 2026-10-10
|
||||
|
||||
### Changed
|
||||
- When a photo is not on this device, for example because your sync node does not store photos, the entry shows where the photo is instead of an empty space.
|
||||
|
||||
## [1.1.6] - 2026-10-10
|
||||
|
||||
### Changed
|
||||
- Show **bold** text as bold. The ** marks appear only on the line you are editing, so you can still change them.
|
||||
|
||||
## [1.1.5] - 2026-10-10
|
||||
### Changed
|
||||
- Save your writing quietly, without a "Waiting to save…" note below the entry.
|
||||
|
||||
## [1.1.4] - 2026-10-08
|
||||
|
||||
- Keep date limits working when Diary updates on existing Inbe installations.
|
||||
|
||||
## [1.1.3] - 2026-10-08
|
||||
|
||||
- Keep the journal on today or earlier dates and show an empty editor without a writing prompt.
|
||||
- Open the same account-synced Diary from Inner Breeze and Harmony, preserving earlier entries and photos.
|
||||
|
||||
## [1.1.2] - 2026-10-07
|
||||
|
||||
- Keep app labels and content visible after updating Inner Breeze.
|
||||
|
||||
## [1.1.1] - 2026-10-06
|
||||
|
||||
- Use Cells consistently in the cell and its independently delivered package.
|
||||
|
||||
## [1.1.0] - 2026-10-06
|
||||
|
||||
- The journal editor and calendar can update independently through the Diary package.
|
||||
- Attach and browse photos in daily entries, including photos imported from Harmony. Removing an attachment preserves its original private file.
|
||||
|
||||
## [1.0.0] - 2026-10-06
|
||||
|
||||
- First independently versioned Diary module.
|
||||
@@ -0,0 +1,405 @@
|
||||
// Date arithmetic and per-day documents moved from Harmony's original Diary.
|
||||
// File effects belong to the host; this bundle has no OS or database access.
|
||||
#import "json_scan"
|
||||
#import, file "diary_view.zi";
|
||||
#import, file "diary_date.zi";
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import "byte_text_linux"
|
||||
#import, file "../../src/cells/diary_types.zi";
|
||||
#import, file "../../src/cells/module_types.zi";
|
||||
#import, file "../../src/core/types.zi";
|
||||
|
||||
host_api :: #system_library "host_api";
|
||||
ReadDiaryHost :: () -> DiaryMessage #foreign host_api;
|
||||
WriteDiaryHost :: (message: DiaryMessage) #foreign host_api;
|
||||
ReadDiaryFileHost :: (name: string) -> DiaryFileResult #foreign host_api;
|
||||
SaveDiaryFileHost :: (name: string, data: string) -> bool #foreign host_api;
|
||||
DiaryClockHost :: () -> string #foreign host_api;
|
||||
|
||||
Today :: () -> Date {
|
||||
clock := DiaryClockHost()
|
||||
if clock.count < 10 {
|
||||
return Date.{}
|
||||
}
|
||||
return ParseDate(clock[:10])
|
||||
}
|
||||
|
||||
Filename :: (date: Date) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%.json", ISO(date))
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
Decode :: (value: string, at: s32) -> string {
|
||||
bytes: Vec(u8)
|
||||
for index: 0..value.count {
|
||||
if !VecPush(bytes, cast(u8)0) {
|
||||
VecFree(bytes);
|
||||
return ""
|
||||
}
|
||||
}
|
||||
count := ReadStringText(value, at, VecSlice(bytes, 0, bytes.count))
|
||||
if count < 0 {
|
||||
VecFree(bytes);
|
||||
return ""
|
||||
}
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%", TextFromBytes(VecSlice(bytes, 0, count)))
|
||||
VecFree(bytes)
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
Json :: (out: *Vec(u8), value: string) {
|
||||
BuilderPrint(out, "\"")
|
||||
for index: 0..value.count - 1 {
|
||||
byte := value[index]
|
||||
if byte == cast(u8)34 {
|
||||
BuilderPrint(out, "\\\"")
|
||||
}
|
||||
else if byte == cast(u8)92 {
|
||||
BuilderPrint(out, "\\\\")
|
||||
}
|
||||
else if byte == cast(u8)10 {
|
||||
BuilderPrint(out, "\\n")
|
||||
}
|
||||
else if byte == cast(u8)13 {
|
||||
BuilderPrint(out, "\\r")
|
||||
}
|
||||
else if byte == cast(u8)9 {
|
||||
BuilderPrint(out, "\\t")
|
||||
}
|
||||
else if byte < cast(u8)32 {
|
||||
BuilderPrint(out, " ")
|
||||
}
|
||||
else {
|
||||
BuilderPrint(out, "%", value[index:index + 1])
|
||||
}
|
||||
}
|
||||
BuilderPrint(out, "\"")
|
||||
}
|
||||
|
||||
Document :: (message: DiaryMessage) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "{\"version\":1,\"date\":")
|
||||
Json(*out, ISO(Date.{message.year, message.month, message.day}))
|
||||
BuilderPrint(*out, ",\"text\":")
|
||||
Json(*out, message.text)
|
||||
BuilderPrint(*out, ",\"photos\":")
|
||||
photos := FieldAt(message.document, 0, "photos")
|
||||
if photos >= 0 && ArrayCount(message.document, photos) >= 0 {
|
||||
end := ValueEnd(message.document, photos, 0)
|
||||
BuilderPrint(*out, "%", message.document[photos:end])
|
||||
} else {
|
||||
BuilderPrint(*out, "[]")
|
||||
}
|
||||
BuilderPrint(*out, "}")
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
SafePhoto :: (file: string) -> bool {
|
||||
if file.count == 0 || file.count > 200 || file == "." || file == ".." {
|
||||
return false
|
||||
}
|
||||
for byte: file {
|
||||
if !((byte >= cast(u8)48 && byte <= cast(u8)57) ||
|
||||
(byte >= cast(u8)97 && byte <= cast(u8)122) ||
|
||||
byte == cast(u8)45 || byte == cast(u8)46) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
PhotoSelection :: (message: DiaryMessage) -> DiaryMessage {
|
||||
rows := FieldAt(message.document, 0, "photos")
|
||||
message.photo_count = ArrayCount(message.document, rows)
|
||||
if message.photo_count < 0 {
|
||||
message.photo_count = 0
|
||||
}
|
||||
message.photo_file = ""
|
||||
message.photo_name = ""
|
||||
if message.photo_count == 0 {
|
||||
message.photo_index = 0
|
||||
return message
|
||||
}
|
||||
if message.photo_index < 0 || message.photo_index >= message.photo_count {
|
||||
message.photo_index = 0
|
||||
}
|
||||
row := ElementAt(message.document, rows, message.photo_index)
|
||||
message.photo_file = Decode(message.document, FieldAt(message.document, row, "file"))
|
||||
message.photo_name = Decode(message.document, FieldAt(message.document, row, "name"))
|
||||
return message
|
||||
}
|
||||
|
||||
PhotoChange :: (message: DiaryMessage, remove: bool) -> DiaryMessage {
|
||||
if !OnOrBefore(Date.{message.year, message.month, message.day}, Today()) ||
|
||||
message.load_error || (!remove && !SafePhoto(message.attachment_file)) {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
rows := FieldAt(message.document, 0, "photos")
|
||||
count := ArrayCount(message.document, rows)
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "{\"photos\":[")
|
||||
written: s32 = 0
|
||||
for index: cast(s32)0..count - 1 {
|
||||
if remove && index == message.photo_index {
|
||||
continue
|
||||
}
|
||||
row := ElementAt(message.document, rows, index)
|
||||
end := ValueEnd(message.document, row, 0)
|
||||
if written > 0 { BuilderPrint(*out, ",") }
|
||||
BuilderPrint(*out, "%", message.document[row:end])
|
||||
written += 1
|
||||
}
|
||||
if !remove {
|
||||
if written > 0 { BuilderPrint(*out, ",") }
|
||||
BuilderPrint(*out, "{\"file\":")
|
||||
Json(*out, message.attachment_file)
|
||||
BuilderPrint(*out, ",\"name\":")
|
||||
Json(*out, message.attachment_name)
|
||||
BuilderPrint(*out, "}")
|
||||
message.photo_index = written
|
||||
}
|
||||
BuilderPrint(*out, "]}")
|
||||
previous := message
|
||||
message.document = BuilderFinish(out)
|
||||
message.saved = false
|
||||
message = Save(message)
|
||||
if !message.saved {
|
||||
previous.succeeded = false
|
||||
return previous
|
||||
}
|
||||
// Removing a reference keeps its private original bytes. A damaged entry
|
||||
// or another imported document can still refer to that same photo.
|
||||
return PhotoSelection(message)
|
||||
}
|
||||
|
||||
Load :: (message: DiaryMessage, date: Date) -> DiaryMessage {
|
||||
if !OnOrBefore(date, Today()) {
|
||||
message.succeeded = false;
|
||||
return message
|
||||
}
|
||||
loaded := ReadDiaryFileHost(Filename(date))
|
||||
message.year = date.year
|
||||
message.month = date.month
|
||||
message.day = date.day
|
||||
message.text = ""
|
||||
message.document = loaded.data
|
||||
message.photo_index = 0
|
||||
message.photo_count = 0
|
||||
message.photo_file = ""
|
||||
message.photo_name = ""
|
||||
message.cursor = 0
|
||||
message.anchor = 0
|
||||
message.load_error = !loaded.succeeded
|
||||
message.saved = true
|
||||
if loaded.missing {
|
||||
message.load_error = false;
|
||||
return message
|
||||
}
|
||||
version := ReadNumber(loaded.data, FieldAt(loaded.data, 0, "version"))
|
||||
day := Decode(loaded.data, FieldAt(loaded.data, 0, "date"))
|
||||
text := FieldAt(loaded.data, 0, "text")
|
||||
if !version.valid || version.value != 1.0 || day != ISO(date) || text < 0 ||
|
||||
loaded.data[text] != cast(u8)34 ||
|
||||
ArrayCount(loaded.data, FieldAt(loaded.data, 0, "photos")) < 0 ||
|
||||
Space(loaded.data, ValueEnd(loaded.data, 0, 0)) != loaded.data.count {
|
||||
message.load_error = true
|
||||
return message
|
||||
}
|
||||
rows := FieldAt(loaded.data, 0, "photos")
|
||||
for index: cast(s32)0..ArrayCount(loaded.data, rows) - 1 {
|
||||
row := ElementAt(loaded.data, rows, index)
|
||||
file := Decode(loaded.data, FieldAt(loaded.data, row, "file"))
|
||||
label := FieldAt(loaded.data, row, "name")
|
||||
if !SafePhoto(file) || label < 0 || loaded.data[label] != cast(u8)34 {
|
||||
message.load_error = true
|
||||
return message
|
||||
}
|
||||
}
|
||||
message.text = Decode(loaded.data, text)
|
||||
return PhotoSelection(message)
|
||||
}
|
||||
|
||||
Save :: (message: DiaryMessage) -> DiaryMessage {
|
||||
if message.load_error || !OnOrBefore(Date.{message.year, message.month, message.day}, Today()) {
|
||||
message.succeeded = false;
|
||||
return message
|
||||
}
|
||||
if message.saved {
|
||||
return message
|
||||
}
|
||||
message.document = Document(message)
|
||||
message.saved = SaveDiaryFileHost(Filename(Date.{message.year, message.month, message.day}),
|
||||
message.document)
|
||||
message.succeeded = message.saved
|
||||
return message
|
||||
}
|
||||
|
||||
Apply :: (message: DiaryMessage) -> DiaryMessage {
|
||||
message.succeeded = true
|
||||
if message.action == DIARY_ROUTE {
|
||||
message.succeeded = message.screen == ScreenDiary
|
||||
return message
|
||||
}
|
||||
if message.action == DIARY_LOAD {
|
||||
date := Date.{message.year, message.month, message.day}
|
||||
if !Valid(date) {
|
||||
date = Today()
|
||||
}
|
||||
return Load(message, date)
|
||||
}
|
||||
if message.action == DIARY_SAVE {
|
||||
return Save(message)
|
||||
}
|
||||
if message.action == DIARY_ATTACH {
|
||||
return PhotoChange(message, false)
|
||||
}
|
||||
if message.action == DIARY_EDIT {
|
||||
if !OnOrBefore(Date.{message.year, message.month, message.day}, Today()) ||
|
||||
message.load_error || message.edit_start < 0 ||
|
||||
message.edit_end < message.edit_start || message.edit_end > message.text.count {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%", message.text[0:message.edit_start])
|
||||
BuilderPrint(*out, "%", message.replacement)
|
||||
BuilderPrint(*out, "%", message.text[message.edit_end:message.text.count])
|
||||
message.text = BuilderFinish(out)
|
||||
message.cursor = message.edit_start + cast(s32)message.replacement.count
|
||||
message.anchor = message.cursor
|
||||
message.saved = false
|
||||
return message
|
||||
}
|
||||
if message.action != DIARY_CONTROL {
|
||||
message.succeeded = false;
|
||||
return message
|
||||
}
|
||||
if message.control == 29008 || message.control == 29009 {
|
||||
if message.photo_count > 0 {
|
||||
message.photo_index = (message.photo_index + message.photo_count +
|
||||
(ifx message.control == 29008 then -1 else 1)) % message.photo_count
|
||||
}
|
||||
return PhotoSelection(message)
|
||||
}
|
||||
if message.control == 29010 {
|
||||
if message.photo_count > 0 {
|
||||
return PhotoChange(message, true)
|
||||
}
|
||||
return message
|
||||
}
|
||||
if message.control == 29013 {
|
||||
clock := DiaryClockHost()
|
||||
if message.load_error || message.calendar || clock.count < 16 {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
stamp: Vec(u8)
|
||||
BuilderPrint(*stamp, "**%**", clock[11:16])
|
||||
message.replacement = BuilderFinish(stamp)
|
||||
message.edit_start = ifx message.cursor < message.anchor then message.cursor else message.anchor
|
||||
message.edit_end = ifx message.cursor > message.anchor then message.cursor else message.anchor
|
||||
message.action = DIARY_EDIT
|
||||
return Apply(message)
|
||||
}
|
||||
if message.control == 29003 {
|
||||
message.calendar = !message.calendar
|
||||
message.month_year = message.year
|
||||
message.month_number = message.month
|
||||
} else if message.control == 29011 || message.control == 29012 {
|
||||
previous_year := message.month_year
|
||||
previous_month := message.month_number
|
||||
message.month_number += ifx message.control == 29011 then -1 else 1
|
||||
if message.month_number < 1 {
|
||||
message.month_number = 12;
|
||||
message.month_year -= 1
|
||||
}
|
||||
if message.month_number > 12 {
|
||||
message.month_number = 1;
|
||||
message.month_year += 1
|
||||
}
|
||||
if !OnOrBefore(Date.{message.month_year, message.month_number, 1}, Today()) {
|
||||
message.month_year = previous_year
|
||||
message.month_number = previous_month
|
||||
message.succeeded = false;
|
||||
return message
|
||||
}
|
||||
} else {
|
||||
before := message
|
||||
date := Date.{before.year, before.month, before.day}
|
||||
if message.control == 29001 {
|
||||
date = Next(date, -1)
|
||||
}
|
||||
else if message.control == 29002 {
|
||||
date = Next(date, 1)
|
||||
}
|
||||
else if message.control == 29004 {
|
||||
date = Today()
|
||||
}
|
||||
else if message.control >= 29101 && message.control <= 29131 {
|
||||
date = Date.{message.month_year, message.month_number, message.control - 29100}
|
||||
} else {
|
||||
message.succeeded = false;
|
||||
return message
|
||||
}
|
||||
if !OnOrBefore(date, Today()) {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
message = Save(message)
|
||||
if !message.saved && !message.load_error {
|
||||
return message
|
||||
}
|
||||
message = Load(message, date)
|
||||
message.calendar = false
|
||||
}
|
||||
if message.calendar {
|
||||
if !Valid(Date.{message.month_year, message.month_number, 1}) {
|
||||
message.succeeded = false
|
||||
message.calendar = false
|
||||
return message
|
||||
}
|
||||
message.month_days = Days(message.month_year, message.month_number)
|
||||
message.month_weekday = Weekday(Date.{message.month_year, message.month_number, 1})
|
||||
for day: cast(s32)0..cast(s32)31 {
|
||||
message.marks[day] = cast(u8)0
|
||||
}
|
||||
for day: cast(s32)1..Days(message.month_year, message.month_number) {
|
||||
file := ReadDiaryFileHost(Filename(Date.{message.month_year, message.month_number, day}))
|
||||
text := FieldAt(file.data, 0, "text")
|
||||
has_text := text >= 0 && text + 1 < file.data.count && file.data[text + 1] != cast(u8)34
|
||||
message.marks[day] = ifx has_text ||
|
||||
ArrayCount(file.data, FieldAt(file.data, 0, "photos")) > 0 then cast(u8)1 else cast(u8)0
|
||||
}
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
#program_export "DiaryMain"
|
||||
Main :: () -> s32 {
|
||||
message := ReadDiaryHost()
|
||||
if message.abi != MODULE_ABI {
|
||||
return -1
|
||||
}
|
||||
if message.action == MODULE_IDENTIFY {
|
||||
return MODULE_DIARY
|
||||
}
|
||||
if message.action == DIARY_FRAME {
|
||||
message.succeeded = true
|
||||
message = DiaryView(message, DiaryObserve(), Today())
|
||||
if message.action != DIARY_FRAME {
|
||||
message = Apply(message)
|
||||
}
|
||||
// A quiet editor saves after its typing delay; file errors stay visible.
|
||||
if !message.saved && DiarySaveDue() {
|
||||
message = Save(message)
|
||||
}
|
||||
WriteDiaryHost(message)
|
||||
} else {
|
||||
WriteDiaryHost(Apply(message))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import "byte_text_linux"
|
||||
|
||||
Date :: struct {
|
||||
year: s32;
|
||||
month: s32;
|
||||
day: s32;
|
||||
}
|
||||
|
||||
Leap :: (year: s32) -> bool {
|
||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
|
||||
}
|
||||
|
||||
Days :: (year: s32, month: s32) -> s32 {
|
||||
lengths: [12]s32 = .[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||
if month < 1 || month > 12 {
|
||||
return 0
|
||||
}
|
||||
if month == 2 && Leap(year) {
|
||||
return 29
|
||||
}
|
||||
return lengths[month - 1]
|
||||
}
|
||||
|
||||
Valid :: (date: Date) -> bool {
|
||||
return date.year >= 1 && date.year <= 9999 && date.month >= 1 &&
|
||||
date.month <= 12 && date.day >= 1 && date.day <= Days(date.year, date.month)
|
||||
}
|
||||
|
||||
Next :: (date: Date, delta: s32) -> Date {
|
||||
value := date
|
||||
if delta > 0 {
|
||||
value.day += 1
|
||||
if value.day > Days(value.year, value.month) {
|
||||
value.day = 1
|
||||
value.month += 1
|
||||
if value.month > 12 {
|
||||
value.month = 1;
|
||||
value.year += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if delta < 0 {
|
||||
value.day -= 1
|
||||
if value.day < 1 {
|
||||
value.month -= 1
|
||||
if value.month < 1 {
|
||||
value.month = 12;
|
||||
value.year -= 1
|
||||
}
|
||||
value.day = Days(value.year, value.month)
|
||||
}
|
||||
}
|
||||
return ifx Valid(value) then value else date
|
||||
}
|
||||
|
||||
Weekday :: (date: Date) -> s32 {
|
||||
year := date.year
|
||||
if date.month < 3 {
|
||||
year -= 1
|
||||
}
|
||||
offsets: [12]s32 = .[0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]
|
||||
return (year + year / 4 - year / 100 + year / 400 +
|
||||
offsets[date.month - 1] + date.day + 6) % 7
|
||||
}
|
||||
|
||||
ISO :: (date: Date) -> string {
|
||||
bytes: [10]u8
|
||||
values: [3]s32 = .[date.year, date.month, date.day]
|
||||
starts: [3]s32 = .[0, 5, 8]
|
||||
lengths: [3]s32 = .[4, 2, 2]
|
||||
bytes[4] = cast(u8)45
|
||||
bytes[7] = cast(u8)45
|
||||
for index: cast(s32)0..cast(s32)2 {
|
||||
number := values[index]
|
||||
for digit: cast(s32)0..lengths[index] - 1 {
|
||||
bytes[starts[index] + lengths[index] - digit - 1] = cast(u8)(48 + number % 10)
|
||||
number /= 10
|
||||
}
|
||||
}
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%", TextFromBytes(bytes[:]))
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
ParseDate :: (value: string) -> Date {
|
||||
date: Date
|
||||
if value.count != 10 || value[4] != cast(u8)45 || value[7] != cast(u8)45 {
|
||||
return date
|
||||
}
|
||||
for index: cast(s32)0..cast(s32)9 {
|
||||
if index == 4 || index == 7 {
|
||||
continue
|
||||
}
|
||||
if value[index] < cast(u8)48 || value[index] > cast(u8)57 {
|
||||
return Date.{}
|
||||
}
|
||||
number := cast(s32)value[index] - 48
|
||||
if index < 4 {
|
||||
date.year = date.year * 10 + number
|
||||
}
|
||||
else if index < 7 {
|
||||
date.month = date.month * 10 + number
|
||||
}
|
||||
else {
|
||||
date.day = date.day * 10 + number
|
||||
}
|
||||
}
|
||||
return ifx Valid(date) then date else Date.{}
|
||||
}
|
||||
|
||||
OnOrBefore :: (date: Date, limit: Date) -> bool {
|
||||
if !Valid(date) || !Valid(limit) {
|
||||
return false
|
||||
}
|
||||
if date.year != limit.year {
|
||||
return date.year < limit.year
|
||||
}
|
||||
if date.month != limit.month {
|
||||
return date.month < limit.month
|
||||
}
|
||||
return date.day <= limit.day
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
#import "geometry"
|
||||
#import, file "diary_date.zi";
|
||||
#import "image_props"
|
||||
#import "image_widget"
|
||||
#import "layout"
|
||||
#import "text_props"
|
||||
#import "text_widget"
|
||||
#import "text_input_props"
|
||||
#import "text_area_widget"
|
||||
#import "button_props"
|
||||
#import "button_widget"
|
||||
#import "control_props"
|
||||
#import "drawing_props"
|
||||
#import "box_props"
|
||||
#import "box_widget"
|
||||
#import "text_align"
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import "byte_text_linux"
|
||||
#import "scroll_props"
|
||||
#import "scroll_widget"
|
||||
#import "tree"
|
||||
#import, file "../../src/cells/diary_types.zi";
|
||||
#import, file "../../src/cells/diary_ui_types.zi";
|
||||
|
||||
using ImageFit;
|
||||
using TextAlign;
|
||||
using TextWrap;
|
||||
using ButtonTone;
|
||||
using ButtonEmphasis;
|
||||
host_api :: #system_library "host_api";
|
||||
ReadDiaryUiHost :: () -> DiaryUiFrame #foreign host_api;
|
||||
WriteDiaryUiHost :: (frame: DiaryUiFrame) #foreign host_api;
|
||||
DiaryLocaleHost :: (key: string) -> string #foreign host_api;
|
||||
state: DiaryMessage;
|
||||
frame: DiaryUiFrame;
|
||||
pending: bool;
|
||||
|
||||
DIARY_PREVIOUS_ICON :: "S1.8rr:M15 5L8 12L15 19"
|
||||
DIARY_NEXT_ICON :: "S1.8rr:M9 5L16 12L9 19"
|
||||
DIARY_CALENDAR_ICON :: "S1.6rr:M4 5H20V20H4ZM4 10H20M8 3V7M16 3V7"
|
||||
DIARY_TIME_ICON :: "S1.6rr:M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12ZM12 7V12L15.5 14"
|
||||
DIARY_PHOTO_ICON :: "S1.6rr:M3 5H21V19H3ZM3 16L8 11L13 16L16 13L21 18M17.5 8.5C17.5 9.33 16.83 10 16 10C15.17 10 14.5 9.33 14.5 8.5C14.5 7.67 15.17 7 16 7C16.83 7 17.5 7.67 17.5 8.5Z"
|
||||
DIARY_UNDO_ICON :: "S1.8rr:M9 14L4 9L9 4M4 9H14C17.31 9 20 11.69 20 15C20 18.31 17.31 21 14 21H11"
|
||||
DIARY_REDO_ICON :: "S1.8rr:M15 14L20 9L15 4M20 9H10C6.69 9 4 11.69 4 15C4 18.31 6.69 21 10 21H13"
|
||||
DIARY_SPELLING_ICON :: "S2rr:M3 14L7.5 3L12 14M4.8 10H10.2M12 17L15.5 20.5L21.5 13"
|
||||
|
||||
DiaryObserve :: () -> DiaryUiFrame {
|
||||
return ReadDiaryUiHost()
|
||||
}
|
||||
|
||||
DiarySaveDue :: () -> bool {
|
||||
return frame.now >= frame.save_at
|
||||
}
|
||||
|
||||
// Markdown bold reads as bold text. Its ** markers stay in the entry but are
|
||||
// hidden, except on the lines holding the caret or a selection, where they
|
||||
// can be edited directly.
|
||||
DIARY_EMPHASIS_MAX :: 256
|
||||
emphasis_hidden: [DIARY_EMPHASIS_MAX * 2]TextRange;
|
||||
emphasis_strong: [DIARY_EMPHASIS_MAX]TextRange;
|
||||
emphasis_hidden_count: s32;
|
||||
emphasis_strong_count: s32;
|
||||
|
||||
DiaryEmphasis :: (value: string, cursor: s32, anchor: s32, editing: bool) {
|
||||
emphasis_hidden_count = 0
|
||||
emphasis_strong_count = 0
|
||||
first := ifx cursor < anchor then cursor else anchor
|
||||
last := ifx cursor < anchor then anchor else cursor
|
||||
line: s32 = 0
|
||||
while line <= cast(s32)value.count && emphasis_strong_count < DIARY_EMPHASIS_MAX {
|
||||
end := line
|
||||
while end < cast(s32)value.count && value[end] != cast(u8)10 { end += 1 }
|
||||
active := editing && last >= line && first <= end
|
||||
at := line
|
||||
while at + 1 < end && emphasis_strong_count < DIARY_EMPHASIS_MAX {
|
||||
if value[at] != cast(u8)42 || value[at + 1] != cast(u8)42 {
|
||||
at += 1
|
||||
continue
|
||||
}
|
||||
close := at + 2
|
||||
while close + 1 < end && (value[close] != cast(u8)42 || value[close + 1] != cast(u8)42) {
|
||||
close += 1
|
||||
}
|
||||
if close + 1 >= end {
|
||||
break
|
||||
}
|
||||
if close > at + 2 {
|
||||
emphasis_strong[emphasis_strong_count] = TextRange.{.start = at + 2, .end = close}
|
||||
emphasis_strong_count += 1
|
||||
if !active {
|
||||
emphasis_hidden[emphasis_hidden_count] = TextRange.{.start = at, .end = at + 2}
|
||||
emphasis_hidden[emphasis_hidden_count + 1] = TextRange.{.start = close, .end = close + 2}
|
||||
emphasis_hidden_count += 2
|
||||
}
|
||||
}
|
||||
at = close + 2
|
||||
}
|
||||
line = end + 1
|
||||
}
|
||||
}
|
||||
|
||||
DateTitle :: (year: s32, month: s32, day: s32) -> string {
|
||||
if month < 1 || month > 12 { return "" }
|
||||
keys: [12]string = .["habit_month_1", "habit_month_2", "habit_month_3",
|
||||
"habit_month_4", "habit_month_5", "habit_month_6", "habit_month_7",
|
||||
"habit_month_8", "habit_month_9", "habit_month_10", "habit_month_11", "habit_month_12"]
|
||||
month_text := DiaryLocaleHost(keys[month - 1])
|
||||
title: Vec(u8)
|
||||
eastern := month_text.count >= 2 && month_text[:2] == "%d"
|
||||
if day > 0 && !eastern { BuilderPrint(*title, "% ", day) }
|
||||
index: s64 = 0
|
||||
while index < month_text.count {
|
||||
if index + 1 < month_text.count && month_text[index:index + 2] == "%d" {
|
||||
BuilderPrint(*title, "%", year)
|
||||
index += 2
|
||||
} else {
|
||||
BuilderPrint(*title, "%", month_text[index:index + 1])
|
||||
index += 1
|
||||
}
|
||||
}
|
||||
if day > 0 && eastern {
|
||||
BuilderPrint(*title, "%", day)
|
||||
suffix := ifx month_text[month_text.count - 3:] == "월" then "일" else "日"
|
||||
BuilderPrint(*title, "%", suffix)
|
||||
}
|
||||
return BuilderFinish(title)
|
||||
}
|
||||
|
||||
HasWords :: (text: string) -> bool {
|
||||
for byte: text {
|
||||
if byte != cast(u8)32 && byte != cast(u8)10 && byte != cast(u8)13 && byte != cast(u8)9 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Scale :: (value: s32) -> s32 {
|
||||
return cast(s32)(cast(float32)value * frame.scale)
|
||||
}
|
||||
|
||||
FinishView :: () -> DiaryMessage {
|
||||
WriteDiaryUiHost(frame)
|
||||
return state
|
||||
}
|
||||
|
||||
// A button with an icon shows only the icon; its label names it for
|
||||
// accessibility.
|
||||
DiaryAction :: ( id: s32, label: string, bounds: Rectangle, enabled: bool = true,
|
||||
icon: string = "", selected: bool = false, loading: bool = false) {
|
||||
if Button(frame.session, ButtonProps.{.id = id, .bounds = bounds,
|
||||
.label = label, .disabled = !enabled, .selected = selected, .loading = loading,
|
||||
.icon_shape = icon, .icon_only = icon != "", .fit_content = true,
|
||||
.tone = cast(ButtonTone)ButtonToneNeutral,
|
||||
.emphasis = cast(ButtonEmphasis)(ifx icon != "" then ButtonEmphasisGhost else ButtonEmphasisSoft)}) != 0 {
|
||||
// Photos, undo, redo and spelling are host effects.
|
||||
frame.focused = false
|
||||
if id == 29005 {
|
||||
frame.photo_requested = true
|
||||
return
|
||||
}
|
||||
if id == 29014 {
|
||||
frame.undo_requested = true
|
||||
return
|
||||
}
|
||||
if id == 29015 {
|
||||
frame.redo_requested = true
|
||||
return
|
||||
}
|
||||
if id == 29016 {
|
||||
frame.spelling_requested = true
|
||||
return
|
||||
}
|
||||
state.action = DIARY_CONTROL
|
||||
state.control = id
|
||||
pending = true
|
||||
frame.scroll = 0
|
||||
}
|
||||
}
|
||||
|
||||
DiaryView :: (message: DiaryMessage, observed: DiaryUiFrame, today: Date) -> DiaryMessage {
|
||||
state = message
|
||||
frame = observed
|
||||
column := CenteredColumnFor(frame.width, Scale(640), Scale(16))
|
||||
left := cast(float32)column.x
|
||||
width := cast(float32)column.width
|
||||
part := (width - cast(float32)Scale(12)) / 3.0
|
||||
compact := frame.height < Scale(480)
|
||||
top := cast(float32)(ifx compact then Scale(4) else Scale(12))
|
||||
control := cast(float32)Scale(44)
|
||||
gap := cast(float32)Scale(8)
|
||||
|
||||
// Title bar: the selected date, centered between the previous and next day.
|
||||
DiaryAction(29001, "‹", Rectangle.{left, top, control, control}, true, DIARY_PREVIOUS_ICON)
|
||||
DiaryAction(29002, "›", Rectangle.{left + width - control, top, control, control},
|
||||
OnOrBefore(Next(Date.{state.year, state.month, state.day}, 1), today) &&
|
||||
!OnOrBefore(today, Date.{state.year, state.month, state.day}),
|
||||
DIARY_NEXT_ICON)
|
||||
title := DateTitle(state.year, state.month, state.day)
|
||||
title_strong: [1]TextRange = .[TextRange.{.start = 0, .end = cast(s32)title.count}]
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{left + control + gap, top,
|
||||
width - 2.0 * (control + gap), control}, .text = title,
|
||||
.font = frame.font + Scale(4), .strong = title_strong[:],
|
||||
.align = cast(TextAlign)TextAlignCenter, .vertical_align = cast(TextAlign)TextAlignCenter,
|
||||
.wrap = cast(TextWrap)TextWrapNone})
|
||||
|
||||
// Tools: Today and the calendar move between days; undo, redo, spelling,
|
||||
// the time and photos change the entry. Today narrows on phones so every
|
||||
// icon keeps its target.
|
||||
tools := top + control + gap
|
||||
tool_gap := cast(float32)Scale(4)
|
||||
tool := control
|
||||
today_width := width - 6.0 * tool - 5.0 * tool_gap - gap
|
||||
if today_width < cast(float32)Scale(64) {
|
||||
// The narrowest phones keep Today readable with smaller icon targets.
|
||||
today_width = cast(float32)Scale(64)
|
||||
tool = (width - today_width - gap - 5.0 * tool_gap) / 6.0
|
||||
}
|
||||
if today_width > cast(float32)Scale(128) {
|
||||
today_width = cast(float32)Scale(128)
|
||||
}
|
||||
DiaryAction(29004, DiaryLocaleHost("diary_today"), Rectangle.{left, tools, today_width, control})
|
||||
DiaryAction(29003, DiaryLocaleHost("tab_diary_calendar"),
|
||||
Rectangle.{left + today_width + gap, tools, tool, control},
|
||||
true, DIARY_CALENDAR_ICON, state.calendar)
|
||||
editable := !state.load_error && state.year > 0
|
||||
if !state.calendar {
|
||||
idle := editable && !frame.spelling_busy
|
||||
DiaryAction(29014, DiaryLocaleHost("diary_undo"),
|
||||
Rectangle.{left + width - 5.0 * tool - 4.0 * tool_gap, tools, tool, control},
|
||||
idle && frame.can_undo, DIARY_UNDO_ICON)
|
||||
DiaryAction(29015, DiaryLocaleHost("diary_redo"),
|
||||
Rectangle.{left + width - 4.0 * tool - 3.0 * tool_gap, tools, tool, control},
|
||||
idle && frame.can_redo, DIARY_REDO_ICON)
|
||||
DiaryAction(29016, DiaryLocaleHost("diary_check_spelling"),
|
||||
Rectangle.{left + width - 3.0 * tool - 2.0 * tool_gap, tools, tool, control},
|
||||
idle && HasWords(state.text), DIARY_SPELLING_ICON, false, frame.spelling_busy)
|
||||
DiaryAction(29013, DiaryLocaleHost("diary_insert_time"),
|
||||
Rectangle.{left + width - 2.0 * tool - tool_gap, tools, tool, control},
|
||||
!frame.spelling_busy, DIARY_TIME_ICON)
|
||||
DiaryAction(29005, DiaryLocaleHost("diary_attach_photo"),
|
||||
Rectangle.{left + width - tool, tools, tool, control},
|
||||
true, DIARY_PHOTO_ICON)
|
||||
}
|
||||
content := tools + control + cast(float32)Scale(12)
|
||||
content_height := cast(float32)(frame.height - frame.bottom) - content - cast(float32)Scale(16)
|
||||
|
||||
if state.calendar {
|
||||
scroll := Scroll(frame.session, ScrollProps.{.key = cast(u64)290300,
|
||||
.bounds = Rectangle.{left, content, width, content_height},
|
||||
.content_height = Scale(344), .scroll_offset = frame.calendar_scroll})
|
||||
frame.calendar_scroll = scroll.scroll_offset
|
||||
if !scroll.opened {
|
||||
return FinishView()
|
||||
}
|
||||
origin := scroll.content.y
|
||||
DiaryAction(29011, "‹", Rectangle.{left, origin, part, cast(float32)Scale(44)})
|
||||
DiaryAction(29012, "›", Rectangle.{left + 2.0 * (part + cast(float32)Scale(6)),
|
||||
origin, part, cast(float32)Scale(44)},
|
||||
state.month_year < today.year ||
|
||||
(state.month_year == today.year && state.month_number < today.month))
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{left + part,
|
||||
origin + cast(float32)Scale(8), part, cast(float32)Scale(32)},
|
||||
.text = DateTitle(state.month_year, state.month_number, 0), .font = frame.font})
|
||||
weekdays: [7]string = .["habit_day_mon", "habit_day_tue", "habit_day_wed", "habit_day_thu",
|
||||
"habit_day_fri", "habit_day_sat", "habit_day_sun"]
|
||||
for day: cast(s32)0..cast(s32)6 {
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{left + cast(float32)day * width / 7.0,
|
||||
origin + cast(float32)Scale(52), width / 7.0, cast(float32)Scale(24)},
|
||||
.text = DiaryLocaleHost(weekdays[day]), .font = frame.font})
|
||||
}
|
||||
for day: cast(s32)1..state.month_days {
|
||||
position := state.month_weekday + day - 1
|
||||
label: Vec(u8)
|
||||
BuilderPrint(*label, "%", day)
|
||||
if state.marks[day] != cast(u8)0 { BuilderPrint(*label, " •") }
|
||||
day_title := BuilderFinish(label)
|
||||
cell := width / 7.0
|
||||
DiaryAction(29100 + day, day_title,
|
||||
Rectangle.{left + cast(float32)(position % 7) * cell,
|
||||
origin + cast(float32)Scale(80 + (position / 7) * 44), cell - 2.0,
|
||||
cast(float32)Scale(42)},
|
||||
OnOrBefore(Date.{state.month_year, state.month_number, day}, today))
|
||||
}
|
||||
End(frame.session)
|
||||
return FinishView()
|
||||
}
|
||||
// The editor reaches the bottom; a notice takes room below it only while
|
||||
// it is shown.
|
||||
notice := frame.photo_error || state.load_error || frame.spelling_notice != ""
|
||||
notice_room := ifx notice then Scale(60) else 0
|
||||
editor_height := cast(s32)content_height - notice_room
|
||||
if editor_height < Scale(120) {
|
||||
editor_height = Scale(120)
|
||||
}
|
||||
page := Scroll(frame.session, ScrollProps.{.key = cast(u64)290301,
|
||||
.bounds = Rectangle.{left, content, width, content_height},
|
||||
.content_height = editor_height + notice_room +
|
||||
(ifx state.photo_count > 0 then Scale(392) else 0), .scroll_offset = frame.page_scroll})
|
||||
frame.page_scroll = page.scroll_offset
|
||||
if !page.opened {
|
||||
return FinishView()
|
||||
}
|
||||
area: TextAreaProps
|
||||
area.key = cast(u64)290200
|
||||
area.focus_id = 29020
|
||||
area.bounds = Rectangle.{left, page.content.y, width, cast(float32)editor_height}
|
||||
area.value = state.text
|
||||
area.label = DiaryLocaleHost("tab_diary")
|
||||
area.wrap = true
|
||||
area.cursor = state.cursor
|
||||
area.anchor = state.anchor
|
||||
area.scroll_y = frame.scroll
|
||||
area.focused = frame.focused
|
||||
area.selecting = frame.selecting
|
||||
// The entry waits while its spelling is checked, so the correction
|
||||
// always applies to the text that was sent.
|
||||
area.read_only = !editable || frame.spelling_busy
|
||||
area.max_bytes = 2147483646
|
||||
area.max_codepoints = 2147483646
|
||||
area.input = frame.input
|
||||
DiaryEmphasis(state.text, state.cursor, state.anchor, frame.focused && !area.read_only)
|
||||
area.hidden = emphasis_hidden[:emphasis_hidden_count]
|
||||
area.strong = emphasis_strong[:emphasis_strong_count]
|
||||
edited := TextArea(frame.session, area)
|
||||
state.cursor = edited.cursor
|
||||
state.anchor = edited.anchor
|
||||
frame.scroll = edited.scroll_y
|
||||
frame.focused = edited.focused
|
||||
frame.selecting = edited.selecting
|
||||
if edited.edit.changed {
|
||||
state.action = DIARY_EDIT
|
||||
state.edit_start = edited.edit.start
|
||||
state.edit_end = edited.edit.end
|
||||
state.replacement = edited.edit.replacement
|
||||
pending = true
|
||||
frame.save_at = frame.now + 0.75
|
||||
}
|
||||
if edited.clipboard_write {
|
||||
frame.clipboard_write = true
|
||||
frame.clipboard_text = edited.clipboard_text
|
||||
}
|
||||
|
||||
if notice {
|
||||
status := frame.spelling_notice
|
||||
if state.load_error {
|
||||
status = "diary_read_error"
|
||||
}
|
||||
if frame.photo_error {
|
||||
status = "diary_photo_error"
|
||||
}
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{left,
|
||||
area.bounds.y + area.bounds.height + cast(float32)Scale(12), width, cast(float32)Scale(40)},
|
||||
.text = DiaryLocaleHost(status), .font = frame.font})
|
||||
}
|
||||
if state.photo_count > 0 {
|
||||
photo_top := area.bounds.y + area.bounds.height + cast(float32)(notice_room + Scale(12))
|
||||
photo_bounds := Rectangle.{left, photo_top, width, cast(float32)Scale(240)}
|
||||
if frame.photo_format.count > 0 {
|
||||
path: Vec(u8)
|
||||
BuilderPrint(*path, "diary/photos/%.%", state.photo_file, frame.photo_format)
|
||||
image := BuilderFinish(path)
|
||||
Image(frame.session, ImageProps.{.asset_path = image,
|
||||
.alt_text = state.photo_name,
|
||||
.bounds = photo_bounds,
|
||||
.fit = cast(ImageFit)ImageFitContain})
|
||||
} else {
|
||||
// The entry names a photo whose bytes are not on this device, for
|
||||
// example when a sync node keeps photos off. The entry still works.
|
||||
Box(frame.session, BoxProps.{.key = cast(u64)29011, .bounds = photo_bounds,
|
||||
.fill = Color.{156, 156, 156, 36}, .radius = cast(float32)Scale(12)})
|
||||
Text(frame.session, TextProps.{.key = cast(u64)29012,
|
||||
.text = DiaryLocaleHost("diary_photo_unavailable"),
|
||||
.bounds = Rectangle.{left + cast(float32)Scale(16), photo_top,
|
||||
width - cast(float32)Scale(32), cast(float32)Scale(240)},
|
||||
.font = frame.font, .align = cast(TextAlign)TextAlignCenter,
|
||||
.vertical_align = cast(TextAlign)TextAlignCenter})
|
||||
}
|
||||
Text(frame.session, TextProps.{.text = state.photo_name,
|
||||
.bounds = Rectangle.{left, photo_top + cast(float32)Scale(248), width,
|
||||
cast(float32)Scale(32)}, .font = frame.font})
|
||||
DiaryAction(29008, "‹", Rectangle.{left, photo_top + cast(float32)Scale(288),
|
||||
part, cast(float32)Scale(44)})
|
||||
DiaryAction(29010, DiaryLocaleHost("diary_remove_photo"),
|
||||
Rectangle.{left + part + cast(float32)Scale(6), photo_top + cast(float32)Scale(288),
|
||||
part, cast(float32)Scale(44)})
|
||||
DiaryAction(29009, "›", Rectangle.{left + 2.0 * (part + cast(float32)Scale(6)),
|
||||
photo_top + cast(float32)Scale(288), part, cast(float32)Scale(44)})
|
||||
}
|
||||
End(frame.session)
|
||||
return FinishView()
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## [1.0.5] - 2026-10-13
|
||||
|
||||
- Maintenance release for Inner Breeze 2.1.33.
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
## [1.0.4] - 2026-10-10
|
||||
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
## [1.0.3] - 2026-10-07
|
||||
|
||||
- Keep app labels and content visible after updating Inner Breeze.
|
||||
|
||||
## [1.0.2] - 2026-10-06
|
||||
|
||||
- Use Cells consistently in the cell and its independently delivered package.
|
||||
|
||||
## [1.0.1] - 2026-10-06
|
||||
|
||||
- Load independently in the updated app host while retaining saved tracking.
|
||||
|
||||
## [1.0.0] - 2026-10-06
|
||||
|
||||
- First independently versioned Habits module.
|
||||
@@ -0,0 +1,136 @@
|
||||
// Habits owns page transitions, linked-day actions and form validation.
|
||||
#import, file "../../src/cells/habits_types.zi";
|
||||
#import, file "../../src/habits/habit_types.zi";
|
||||
#import, file "../../src/core/types.zi";
|
||||
#import, file "../../src/cells/module_types.zi";
|
||||
host_api :: #system_library "host_api";
|
||||
ReadHabitsHost :: () -> HabitsMessage #foreign host_api;
|
||||
WriteHabitsHost :: (message: HabitsMessage) #foreign host_api;
|
||||
HabitNameExistsHost :: (name: string, excluding: s32) -> bool #foreign host_api;
|
||||
SaveHabitHost :: (message: HabitsMessage) -> bool #foreign host_api;
|
||||
|
||||
HabitTrimName :: (name: string) -> string {
|
||||
start: s64 = 0
|
||||
end := name.count
|
||||
while start < end && (name[start] == cast(u8)32 || name[start] == cast(u8)9) {
|
||||
start += 1
|
||||
}
|
||||
while end > start && (name[end - 1] == cast(u8)32 || name[end - 1] == cast(u8)9) {
|
||||
end -= 1
|
||||
}
|
||||
return name[start:end]
|
||||
}
|
||||
|
||||
using HabitSyncMode;
|
||||
|
||||
HabitsApply :: (message: HabitsMessage) -> HabitsMessage {
|
||||
message.succeeded = true
|
||||
if message.action == HABITS_ROUTE {
|
||||
message.succeeded = message.screen == ScreenHabits ||
|
||||
message.screen == ScreenHabitEdit || message.screen == ScreenHabitSessionEdit
|
||||
return message
|
||||
}
|
||||
if message.action == HABITS_DAY_ACTION {
|
||||
// Days off the habit's schedule open and count like planned days.
|
||||
if message.modal_active || message.index < 0 || message.index >= message.count {
|
||||
return message
|
||||
}
|
||||
if message.counter_enabled != 0 {
|
||||
message.day_action = ifx message.decrement then HABITS_DAY_DECREMENT else HABITS_DAY_COUNT
|
||||
} else if message.linked_count > 0 {
|
||||
message.day_action = HABITS_DAY_LINKED
|
||||
} else if message.span {
|
||||
// A tap starts the habit's span, the next ends it; a day with
|
||||
// spans opens their data.
|
||||
message.day_action = HABITS_DAY_SPAN
|
||||
} else if message.question_count > 0 {
|
||||
// The day opens its questions, or the data of a done day,
|
||||
// instead of being marked or cleared.
|
||||
message.day_action = HABITS_DAY_QUESTIONS
|
||||
} else {
|
||||
message.day_action = HABITS_DAY_TOGGLE
|
||||
}
|
||||
message.block_click = true
|
||||
return message
|
||||
}
|
||||
if message.action == HABITS_COMMIT {
|
||||
if !message.active {
|
||||
return message
|
||||
}
|
||||
if !message.is_new && (message.index < 0 || message.index >= message.count) {
|
||||
message.cancel_edit = true
|
||||
return message
|
||||
}
|
||||
message.name_error = 0
|
||||
message.name = HabitTrimName(message.name)
|
||||
if message.name.count == 0 {
|
||||
message.name_error = 1
|
||||
} else if HabitNameExistsHost(message.name,
|
||||
ifx message.is_new then -1 else message.index) {
|
||||
message.name_error = 2
|
||||
}
|
||||
if message.name_error != 0 {
|
||||
message.reset_scroll = true
|
||||
return message
|
||||
}
|
||||
message.sync_mode = ifx message.sync_activity != 0 then HABIT_SYNC_ACTIVITIES else HABIT_SYNC_NONE
|
||||
message.weekdays = message.weekdays & 0xff
|
||||
message.color.a = 255
|
||||
message.succeeded = SaveHabitHost(message)
|
||||
if !message.succeeded {
|
||||
return message
|
||||
}
|
||||
message.cancel_edit = true
|
||||
message.action = HABITS_OVERVIEW
|
||||
}
|
||||
if message.action == HABITS_EXPAND {
|
||||
if message.index < 0 || message.index >= message.count {
|
||||
return message
|
||||
}
|
||||
message.selected = message.index
|
||||
message.screen_mode = HABITS_SCREEN_OVERVIEW
|
||||
message.tab = HABIT_TAB_WEEKLY
|
||||
message.view_mode = HABIT_VIEW_WEEKLY
|
||||
} else if message.action == HABITS_HISTORY || message.action == HABITS_STATISTICS {
|
||||
if message.selected < 0 || message.selected >= message.count {
|
||||
return message
|
||||
}
|
||||
message.reset_scroll = true
|
||||
if message.action == HABITS_HISTORY {
|
||||
message.screen_mode = HABITS_SCREEN_HISTORY
|
||||
message.view_mode = HABIT_VIEW_CALENDAR
|
||||
message.tab = HABIT_TAB_MONTHLY
|
||||
} else {
|
||||
message.screen_mode = HABITS_SCREEN_STATISTICS
|
||||
message.tab = HABIT_TAB_STATISTICS
|
||||
}
|
||||
} else if message.action == HABITS_FOCUS {
|
||||
message.screen_mode = HABITS_SCREEN_OVERVIEW
|
||||
message.tab = HABIT_TAB_WEEKLY
|
||||
message.reset_scroll = true
|
||||
} else if message.action == HABITS_OVERVIEW {
|
||||
message.selected = -1
|
||||
message.screen_mode = HABITS_SCREEN_OVERVIEW
|
||||
message.tab = HABIT_TAB_WEEKLY
|
||||
message.view_mode = HABIT_VIEW_WEEKLY
|
||||
message.reset_scroll = true
|
||||
} else if message.action == HABITS_COLLAPSE {
|
||||
message.selected = -1
|
||||
} else {
|
||||
message.succeeded = false
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
#program_export "HabitsMain"
|
||||
Main :: () -> s32 {
|
||||
message := ReadHabitsHost()
|
||||
if message.abi != MODULE_ABI {
|
||||
return -1
|
||||
}
|
||||
if message.action == MODULE_IDENTIFY {
|
||||
return MODULE_HABITS
|
||||
}
|
||||
WriteHabitsHost(HabitsApply(message))
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
# Changelog
|
||||
|
||||
## [2.1.30] - 2026-10-13
|
||||
|
||||
- Bring Lumi 1.4.0, Habits 1.0.5, Practices 1.1.5, Lists 1.0.6, Diary 1.1.10 and Leaderboard 1.0.2.
|
||||
- Requires Inner Breeze 2.1.33 or later.
|
||||
|
||||
## [2.1.29] - 2026-10-11
|
||||
|
||||
- Bring Lumi 1.3.9, Diary 1.1.9, Lists 1.0.5 and Leaderboard 1.0.1.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.28] - 2026-10-11
|
||||
|
||||
- Bring Lumi's message selection with copy and delete.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.27] - 2026-10-11
|
||||
|
||||
- Bring Lumi's chat that loads older messages as you scroll up.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.26] - 2026-10-10
|
||||
|
||||
- Bring Diary's title bar, undo and redo, and spelling correction, and Lumi's typing dots.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.25] - 2026-10-10
|
||||
|
||||
- Open Leaderboard as its own app.
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
## [2.1.24] - 2026-10-10
|
||||
|
||||
- Remove the text of practice window buttons that are no longer shown.
|
||||
|
||||
## [2.1.23] - 2026-10-10
|
||||
|
||||
- Translate the descriptions in Lumi's command list.
|
||||
|
||||
## [2.1.22] - 2026-10-10
|
||||
|
||||
- Say which app, device and system details Lumi feedback includes before you send it.
|
||||
|
||||
## [2.1.21] - 2026-10-10
|
||||
|
||||
- Explain when approved Lumi feedback is still waiting to send and when the developer inbox has received it.
|
||||
|
||||
## [2.1.20] - 2026-10-09
|
||||
|
||||
- Customize each app in Appearance using live KSS editing, inspection, undo, and reset to defaults.
|
||||
- Ask Lumi to preview and save your appearance changes.
|
||||
|
||||
## [2.1.19] - 2026-10-08
|
||||
|
||||
- Deliver the updated Diary to existing Inbe installations with today as its latest date.
|
||||
|
||||
## [2.1.18] - 2026-10-08
|
||||
|
||||
- Keep Diary in the same account as Habits, including existing entries and photos.
|
||||
- Limit Diary to today and earlier dates and open a blank editor without a writing prompt.
|
||||
|
||||
## [2.1.17] - 2026-10-07
|
||||
|
||||
- Find every app in a searchable library and keep up to two favorites in the compact dock.
|
||||
- Preserve saved app data when changing favorites and keep Profile and Settings close by.
|
||||
|
||||
## [2.1.13] - 2026-10-07
|
||||
|
||||
- Show clean, colored sync changes with translated explanations and complete change symbols.
|
||||
|
||||
## [2.1.12] - 2026-10-07
|
||||
|
||||
- Keep all apps working with Lumi's bold formatting and offline feature suggestions.
|
||||
|
||||
## [2.1.11] - 2026-10-07
|
||||
|
||||
- Connect Lumi to online conversation and app actions without blocking the interface.
|
||||
- Deliver saved app feedback and show developer replies in chat.
|
||||
|
||||
## [2.1.10] - 2026-10-06
|
||||
|
||||
- Preserve the selected page during upgrades and add hidden apps instantly offline.
|
||||
- Keep the interface responsive when an app cannot reset its view.
|
||||
- Open Lumi smoothly and distinguish Lists from Diary with a checkmark icon.
|
||||
|
||||
|
||||
## [2.1.8] - 2026-10-06
|
||||
|
||||
- Call sidebar choices Apps in setup and settings, with shorter instructions.
|
||||
|
||||
## [2.1.7] - 2026-10-06
|
||||
|
||||
- Show Lumi alongside every other cell in one compact, reorderable list.
|
||||
- Include all cells for instant sidebar additions without a download.
|
||||
|
||||
## [2.1.6] - 2026-10-06
|
||||
|
||||
- Show a clearer firefly icon for Lumi and keep the bundled companion available when her shortcut is hidden.
|
||||
- Keep every selected startup cell in the sidebar and preserve cached packages for quick reinstallation.
|
||||
- Provide app tools for changing themes, appearance and settings directly.
|
||||
|
||||
## [2.1.5] - 2026-10-06
|
||||
|
||||
- Use a standard cell icon for Lumi and include translations for her habit and practice commands.
|
||||
|
||||
## [2.1.4] - 2026-10-06
|
||||
|
||||
- Recommend Lumi first in the cell picker and open her chat as the default home.
|
||||
- Keep the firefly helper available offline alongside Habits and Practices.
|
||||
- Include every character used by the current translations in the shared fonts.
|
||||
|
||||
## [2.1.3] - 2026-10-06
|
||||
|
||||
- Use Cells consistently in the cell picker and its independently delivered package.
|
||||
|
||||
## [2.1.2] - 2026-10-06
|
||||
|
||||
- Keep all app choices, the automatic update switch and the manual update button visible at normal desktop sizes.
|
||||
|
||||
## [2.1.1] - 2026-10-06
|
||||
|
||||
- The app picker and its update controls now travel with the app package, together with shared fonts, translations, styles and icons.
|
||||
|
||||
## [2.1.0] - 2026-10-06
|
||||
|
||||
- First independently versioned Inner Breeze module.
|
||||
@@ -0,0 +1,120 @@
|
||||
// The portable root owns app selection and unified navigation policy.
|
||||
// Its assets contain Lumi, Habits and Practices as recommended cells, and
|
||||
// Lists, Diary and Leaderboard as optional ones.
|
||||
#import, file "../../src/cells/inbe_types.zi";
|
||||
#import, file "inbe_view.zi";
|
||||
#import, file "../../src/cells/module_types.zi";
|
||||
#import, file "../../src/core/types.zi";
|
||||
host_api :: #system_library "host_api";
|
||||
ReadInbeHost :: () -> InbeMessage #foreign host_api;
|
||||
WriteInbeHost :: (message: InbeMessage) #foreign host_api;
|
||||
RouteFeatureHost :: (app: s32, screen: s32) -> bool #foreign host_api;
|
||||
|
||||
InbeAppForScreen :: (screen: s32) -> s32 {
|
||||
if screen == ScreenLumi {
|
||||
return APP_LUMI
|
||||
}
|
||||
if screen == ScreenDiary {
|
||||
return APP_DIARY
|
||||
}
|
||||
if screen == ScreenLeaderboard {
|
||||
return APP_LEADERBOARD
|
||||
}
|
||||
if screen == ScreenEList {
|
||||
return APP_LISTS
|
||||
}
|
||||
if screen == ScreenHabits || screen == ScreenHabitEdit ||
|
||||
screen == ScreenHabitSessionEdit {
|
||||
return APP_HABITS
|
||||
}
|
||||
if screen == ScreenStart || screen == ScreenSession ||
|
||||
screen == ScreenMeditation || screen == ScreenSunSalutation ||
|
||||
screen == ScreenPatterns || screen == ScreenResults ||
|
||||
screen == ScreenPracticeConfig || screen == ScreenManual {
|
||||
return APP_PRACTICE
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
InbeHome :: (apps: s32) -> s32 {
|
||||
if (apps & APP_LUMI) != 0 {
|
||||
return ScreenLumi
|
||||
}
|
||||
if (apps & APP_PRACTICE) != 0 {
|
||||
return ScreenStart
|
||||
}
|
||||
if (apps & APP_HABITS) != 0 {
|
||||
return ScreenHabits
|
||||
}
|
||||
if (apps & APP_LISTS) != 0 {
|
||||
return ScreenEList
|
||||
}
|
||||
if (apps & APP_DIARY) != 0 {
|
||||
return ScreenDiary
|
||||
}
|
||||
return ScreenSettings
|
||||
}
|
||||
|
||||
InbeApply :: (message: InbeMessage) -> InbeMessage {
|
||||
message.enabled_apps &= APP_ALL
|
||||
message.succeeded = true
|
||||
if message.action == INBE_MINI_CONFIGURE {
|
||||
// An explicit mini launch is a temporary practice session. It does
|
||||
// not replace the profile's saved selection for the full app.
|
||||
message.enabled_apps = APP_PRACTICE
|
||||
message.screen = ScreenStart
|
||||
}
|
||||
if message.action == INBE_TOGGLE_APP {
|
||||
if message.app != APP_LISTS && message.app != APP_HABITS &&
|
||||
message.app != APP_PRACTICE && message.app != APP_DIARY && message.app != APP_LUMI &&
|
||||
message.app != APP_LEADERBOARD {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
if message.checked {
|
||||
message.enabled_apps |= message.app
|
||||
} else {
|
||||
message.enabled_apps &= ~message.app
|
||||
}
|
||||
}
|
||||
if message.action == INBE_CONFIGURE || message.action == INBE_TOGGLE_APP ||
|
||||
message.action == INBE_MINI_CONFIGURE {
|
||||
message.screen = InbeHome(message.enabled_apps)
|
||||
} else if message.action == INBE_INITIAL_SCREEN {
|
||||
if !message.language_selected {
|
||||
message.screen = ScreenLanguage
|
||||
} else if !message.apps_selected {
|
||||
message.screen = ScreenAppSelection
|
||||
} else {
|
||||
app := InbeAppForScreen(message.screen)
|
||||
if app != 0 && (message.enabled_apps & app) == 0 {
|
||||
message.screen = InbeHome(message.enabled_apps)
|
||||
}
|
||||
}
|
||||
} else if message.action != INBE_ROUTE {
|
||||
message.succeeded = false
|
||||
}
|
||||
app := InbeAppForScreen(message.screen)
|
||||
message.allowed = app == 0 || (message.enabled_apps & app) != 0
|
||||
if message.action == INBE_ROUTE && message.allowed && app != 0 {
|
||||
message.succeeded = RouteFeatureHost(app, message.screen)
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
#program_export "InnerBreezeMain"
|
||||
Main :: () -> s32 {
|
||||
message := ReadInbeHost()
|
||||
if message.abi != MODULE_ABI {
|
||||
return -1
|
||||
}
|
||||
if message.action == MODULE_IDENTIFY {
|
||||
return MODULE_INBE
|
||||
}
|
||||
if message.action == INBE_FRAME {
|
||||
WriteInbeHost(InbePickerView(message))
|
||||
} else {
|
||||
WriteInbeHost(InbeApply(message))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
#import "button_props"
|
||||
#import "button_widget"
|
||||
#import "checkbox_props"
|
||||
#import "checkbox_widget"
|
||||
#import "geometry"
|
||||
#import "layout"
|
||||
#import "text_props"
|
||||
#import "text_widget"
|
||||
#import "control_props"
|
||||
#import "scroll_props"
|
||||
#import "scroll_widget"
|
||||
#import "tree"
|
||||
#import "toggle_props"
|
||||
#import "toggle_widget"
|
||||
#import, file "../../src/cells/inbe_types.zi";
|
||||
#import, file "../../src/cells/inbe_ui_types.zi";
|
||||
using ButtonTone;
|
||||
using ButtonEmphasis;
|
||||
host_api :: #system_library "host_api";
|
||||
ReadPickerUiHost :: () -> InbeUiFrame #foreign host_api;
|
||||
WritePickerUiHost :: (frame: InbeUiFrame) #foreign host_api;
|
||||
PickerLocaleHost :: (key: string) -> string #foreign host_api;
|
||||
frame: InbeUiFrame;
|
||||
state: InbeMessage;
|
||||
|
||||
Scale :: (pixels: s32) -> s32 {
|
||||
return cast(s32)(cast(float32)pixels * frame.scale)
|
||||
}
|
||||
|
||||
Bit :: (package: s32) -> s32 { return cast(s32)1 << (package - 1) }
|
||||
|
||||
Row :: (package: s32) -> AppPackageView {
|
||||
if package == 1 { return frame.lists }
|
||||
if package == 2 { return frame.habits }
|
||||
if package == 3 { return frame.practices }
|
||||
if package == 5 { return frame.lumi }
|
||||
return frame.diary
|
||||
}
|
||||
|
||||
Status :: (package: s32) -> s32 { return Row(package).status }
|
||||
Available :: (package: s32) -> bool { return Row(package).available }
|
||||
|
||||
FinishPicker :: () -> InbeMessage {
|
||||
WritePickerUiHost(frame)
|
||||
state.succeeded = true
|
||||
return state
|
||||
}
|
||||
|
||||
InbePickerView :: (message: InbeMessage) -> InbeMessage {
|
||||
frame = ReadPickerUiHost()
|
||||
state = message
|
||||
column := CenteredColumnFor(frame.width, Scale(420), Scale(16))
|
||||
top := Scale(20)
|
||||
compact := frame.height < Scale(480)
|
||||
scroll_top := ifx compact then Scale(104) else Scale(156)
|
||||
content_height := Scale(548)
|
||||
for package: cast(s32)1..cast(s32)5 {
|
||||
if Status(package) >= 3 {
|
||||
content_height += Scale(16)
|
||||
}
|
||||
}
|
||||
Text(frame.session, TextProps.{
|
||||
.bounds = Rectangle.{cast(float32)column.x, cast(float32)top,
|
||||
cast(float32)column.width, cast(float32)(ifx compact then Scale(28) else Scale(40))},
|
||||
.text = PickerLocaleHost("cells_picker_title"), .font = Scale(24)})
|
||||
Text(frame.session, TextProps.{
|
||||
.bounds = Rectangle.{cast(float32)column.x, cast(float32)(top + (ifx compact then Scale(32) else Scale(48))),
|
||||
cast(float32)column.width, cast(float32)(ifx compact then Scale(44) else Scale(84))},
|
||||
.text = PickerLocaleHost("cells_picker_body"), .font = frame.font})
|
||||
scroll := Scroll(frame.session, ScrollProps.{.key = cast(u64)27000,
|
||||
.bounds = Rectangle.{cast(float32)column.x, cast(float32)scroll_top,
|
||||
cast(float32)column.width, cast(float32)(frame.height - scroll_top - Scale(80))},
|
||||
.content_height = content_height, .scroll_offset = frame.scroll})
|
||||
frame.scroll = scroll.scroll_offset
|
||||
if !scroll.opened {
|
||||
return FinishPicker()
|
||||
}
|
||||
content_width := cast(s32)scroll.content.width
|
||||
row_top := cast(s32)scroll.content.y
|
||||
labels: [5]string = .["Lumi", PickerLocaleHost("tab_habits"), PickerLocaleHost("tab_practices"),
|
||||
PickerLocaleHost("tab_elist"), PickerLocaleHost("tab_diary")]
|
||||
packages: [5]s32 = .[5, 2, 3, 1, 4]
|
||||
index: s32 = 0
|
||||
while index < 5 {
|
||||
if index == 0 || index == 3 {
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{cast(float32)column.x,
|
||||
cast(float32)row_top, cast(float32)content_width, cast(float32)Scale(36)},
|
||||
.text = PickerLocaleHost(ifx index == 0 then "cells_recommended" else "cells_optional"),
|
||||
.font = frame.font})
|
||||
row_top += Scale(40)
|
||||
}
|
||||
package := packages[index]
|
||||
bit := Bit(package)
|
||||
checkbox := Checkbox(frame.session, CheckboxProps.{
|
||||
.id = ifx package == 5 then 278 else 270 + package - 1,
|
||||
.bounds = Rectangle.{cast(float32)column.x,
|
||||
cast(float32)row_top,
|
||||
cast(float32)content_width, cast(float32)Scale(44)},
|
||||
.label = labels[index], .checked = (state.enabled_apps & bit) != 0})
|
||||
if checkbox.changed {
|
||||
if checkbox.checked {
|
||||
state.enabled_apps |= bit
|
||||
} else {
|
||||
state.enabled_apps &= ~bit
|
||||
}
|
||||
}
|
||||
row_top += Scale(44)
|
||||
{
|
||||
status := Status(package)
|
||||
key := ifx ((frame.installed & bit) != 0 || Available(package)) then "cells_installed" else "cells_download"
|
||||
if status == 1 {
|
||||
key = "update_downloading"
|
||||
}
|
||||
else if status == 3 {
|
||||
key = "cells_download_failed"
|
||||
}
|
||||
else if status == 4 {
|
||||
key = "cells_signing_setup"
|
||||
}
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{cast(float32)(column.x + Scale(32)),
|
||||
cast(float32)row_top, cast(float32)(content_width - Scale(32)),
|
||||
cast(float32)(ifx status >= 3 then Scale(44) else Scale(28))},
|
||||
.text = PickerLocaleHost(key), .font = Scale(14)})
|
||||
row_top += ifx status >= 3 then Scale(44) else Scale(28)
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
Text(frame.session, TextProps.{
|
||||
.bounds = Rectangle.{cast(float32)column.x, cast(float32)(row_top + Scale(12)),
|
||||
cast(float32)(content_width - Scale(80)), cast(float32)Scale(44)},
|
||||
.text = PickerLocaleHost("cells_auto_update"), .font = frame.font})
|
||||
automatic := Toggle(frame.session, ToggleProps.{.id = 276,
|
||||
.bounds = Rectangle.{cast(float32)(column.x + content_width - Scale(64)),
|
||||
cast(float32)(row_top + Scale(12)), cast(float32)Scale(64), cast(float32)Scale(44)},
|
||||
.label = PickerLocaleHost("cells_auto_update"), .value = frame.automatic})
|
||||
if automatic.changed {
|
||||
frame.automatic = automatic.value
|
||||
}
|
||||
row_top += Scale(64)
|
||||
if Button(frame.session, ButtonProps.{.id = 277,
|
||||
.bounds = Rectangle.{cast(float32)column.x, cast(float32)row_top,
|
||||
cast(float32)content_width, cast(float32)Scale(44)},
|
||||
.label = PickerLocaleHost("cells_check_updates"),
|
||||
.tone = cast(ButtonTone)ButtonToneNeutral,
|
||||
.emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 {
|
||||
frame.check_updates = true
|
||||
}
|
||||
End(frame.session)
|
||||
if Button(frame.session, ButtonProps.{.id = 274,
|
||||
.bounds = Rectangle.{cast(float32)column.x,
|
||||
cast(float32)(frame.height - Scale(64)), cast(float32)column.width,
|
||||
cast(float32)Scale(44)},
|
||||
.label = PickerLocaleHost("next_button"),
|
||||
.tone = cast(ButtonTone)ButtonToneNeutral,
|
||||
.emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 {
|
||||
frame.confirm = true
|
||||
}
|
||||
return FinishPicker()
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
## [1.0.2] - 2026-10-13
|
||||
|
||||
- Maintenance release for Inner Breeze 2.1.33.
|
||||
|
||||
## [1.0.1] - 2026-10-11
|
||||
|
||||
- Scrollbars use your theme's colours and show how much of the list is in view.
|
||||
|
||||
## [1.0.0] - 2026-10-10
|
||||
|
||||
- Rank yourself with your friends for Wim Hof, breathing patterns, meditation and Sun Salutation.
|
||||
- Sort by current streak, or by average hold in Wim Hof and average time in meditation.
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
@@ -0,0 +1,34 @@
|
||||
// Leaderboard ranks you with your friends for each practice. The unified
|
||||
// host fetches friend results, keeps them for offline use and ranks rows.
|
||||
#import, file "../../src/cells/leaderboard_types.zi";
|
||||
#import, file "../../src/cells/module_types.zi";
|
||||
#import, file "../../src/core/types.zi";
|
||||
#import, file "leaderboard_view.zi";
|
||||
host_api :: #system_library "host_api";
|
||||
ReadLeaderboardHost :: () -> LeaderboardMessage #foreign host_api;
|
||||
WriteLeaderboardHost :: (message: LeaderboardMessage) #foreign host_api;
|
||||
|
||||
LeaderboardApply :: (message: LeaderboardMessage) -> LeaderboardMessage {
|
||||
message.succeeded = true
|
||||
if message.action == LEADERBOARD_ROUTE {
|
||||
message.succeeded = message.screen == ScreenLeaderboard
|
||||
} else if message.action == LEADERBOARD_FRAME {
|
||||
message = LeaderboardView(message)
|
||||
} else {
|
||||
message.succeeded = false
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
#program_export "LeaderboardMain"
|
||||
Main :: () -> s32 {
|
||||
message := ReadLeaderboardHost()
|
||||
if message.abi != MODULE_ABI {
|
||||
return -1
|
||||
}
|
||||
if message.action == MODULE_IDENTIFY {
|
||||
return MODULE_LEADERBOARD
|
||||
}
|
||||
WriteLeaderboardHost(LeaderboardApply(message))
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
// Leaderboard owns its screen composition; the host supplies ranked rows,
|
||||
// prepared once when results arrive, and ordinary Kryon widget effects.
|
||||
#import "session"
|
||||
#import "geometry"
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import "drawing_props"
|
||||
#import "text_props"
|
||||
#import "text_align"
|
||||
#import "text_widget"
|
||||
#import "button_props"
|
||||
#import "button_widget"
|
||||
#import "control_props"
|
||||
#import "scroll_props"
|
||||
#import "scroll_widget"
|
||||
#import "box_props"
|
||||
#import "box_widget"
|
||||
#import "tree"
|
||||
#import, file "../../src/cells/leaderboard_ui_types.zi";
|
||||
#import, file "../../src/cells/leaderboard_types.zi";
|
||||
|
||||
using ButtonTone;
|
||||
using ButtonEmphasis;
|
||||
using TextAlign;
|
||||
using TextWrap;
|
||||
host_api :: #system_library "host_api";
|
||||
ReadLeaderboardUiHost :: () -> LeaderboardUiFrame #foreign host_api;
|
||||
WriteLeaderboardUiHost :: (frame: LeaderboardUiFrame) #foreign host_api;
|
||||
ReadLeaderboardRowHost :: (index: s32) -> LeaderboardUiRow #foreign host_api;
|
||||
LeaderboardLocaleHost :: (key: string) -> string #foreign host_api;
|
||||
frame: LeaderboardUiFrame;
|
||||
state: LeaderboardMessage;
|
||||
|
||||
// Wim Hof, breathing patterns, meditation and Sun Salutation, as in Practice.
|
||||
PRACTICE_COUNT :: 4
|
||||
PracticeAt :: (index: s32) -> s32 {
|
||||
ids: [PRACTICE_COUNT]s32 = .[0, 3, 1, 2]
|
||||
return ids[index]
|
||||
}
|
||||
|
||||
PracticeLabel :: (practice: s32) -> string {
|
||||
if practice == 1 { return LeaderboardLocaleHost("exercise_meditation") }
|
||||
if practice == 2 { return LeaderboardLocaleHost("exercise_sun_salutation") }
|
||||
if practice == 3 { return LeaderboardLocaleHost("exercise_patterns") }
|
||||
return LeaderboardLocaleHost("exercise_wim_hof")
|
||||
}
|
||||
|
||||
Scale :: (pixels: s32) -> s32 {
|
||||
return cast(s32)(cast(float32)pixels * frame.scale)
|
||||
}
|
||||
|
||||
Bounds :: (x: s32, y: s32, width: s32, height: s32) -> Rectangle {
|
||||
return Rectangle.{cast(float32)x, cast(float32)y,
|
||||
cast(float32)width, cast(float32)height}
|
||||
}
|
||||
|
||||
Finish :: () -> LeaderboardMessage {
|
||||
WriteLeaderboardUiHost(frame)
|
||||
state.succeeded = true
|
||||
return state
|
||||
}
|
||||
|
||||
Cell :: (key: u64, x: s32, y: s32, width: s32, height: s32, text: string) {
|
||||
Text(frame.session, TextProps.{.key = key, .bounds = Bounds(x, y, width, height),
|
||||
.text = text, .font = frame.font, .wrap = cast(TextWrap)TextWrapNone,
|
||||
.vertical_align = cast(TextAlign)TextAlignCenter})
|
||||
}
|
||||
|
||||
LeaderboardView :: (message: LeaderboardMessage) -> LeaderboardMessage {
|
||||
frame = ReadLeaderboardUiHost()
|
||||
state = message
|
||||
x := Scale(16)
|
||||
width := frame.width - x * 2
|
||||
y := Scale(12)
|
||||
|
||||
// Every practice stays visible: two per row on phones, four when wide.
|
||||
per_row: s32 = ifx width >= Scale(600) then PRACTICE_COUNT else 2
|
||||
gap := Scale(8)
|
||||
choice_width := (width - gap * (per_row - 1)) / per_row
|
||||
for index: cast(s32)0..PRACTICE_COUNT - 1 {
|
||||
practice := PracticeAt(index)
|
||||
chosen := practice == state.practice
|
||||
choice_x := x + (index % per_row) * (choice_width + gap)
|
||||
choice_y := y + (index / per_row) * (Scale(40) + gap)
|
||||
if Button(frame.session, ButtonProps.{.id = 7100 + index,
|
||||
.bounds = Bounds(choice_x, choice_y, choice_width, Scale(40)),
|
||||
.label = PracticeLabel(practice), .selected = chosen, .fit_content = true,
|
||||
.tone = cast(ButtonTone)(ifx chosen then ButtonToneAccent else ButtonToneNeutral),
|
||||
.emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 && !chosen {
|
||||
state.practice = practice
|
||||
state.metric = LEADERBOARD_STREAK
|
||||
state.refresh = true
|
||||
frame.scroll = 0
|
||||
return Finish()
|
||||
}
|
||||
}
|
||||
y += (PRACTICE_COUNT / per_row) * (Scale(40) + gap) + Scale(8)
|
||||
|
||||
// The name column is wider when only the streak is ranked.
|
||||
columns: s32 = ifx state.has_average then 3 else 2
|
||||
name_width := ifx state.has_average then width / 2 else (width * 2) / 3
|
||||
value_width := ifx state.has_average then (width - name_width) / 2 else width - name_width
|
||||
average_label := ifx state.practice == 1 then "profile_metric_avg_time" else "profile_metric_avg_hold"
|
||||
labels: [3]string = .[LeaderboardLocaleHost("profile_friends_title"),
|
||||
LeaderboardLocaleHost("profile_metric_streak"), LeaderboardLocaleHost(average_label)]
|
||||
header_x := x
|
||||
for column: cast(s32)0..columns - 1 {
|
||||
column_width := ifx column == 0 then name_width else ifx column == columns - 1 then x + width - header_x else value_width
|
||||
metric := column - 1
|
||||
active := column > 0 && state.metric == metric
|
||||
if Button(frame.session, ButtonProps.{.id = 7110 + column,
|
||||
.bounds = Bounds(header_x, y, column_width, Scale(36)),
|
||||
.label = labels[column], .disabled = column == 0, .selected = active,
|
||||
.fit_content = true,
|
||||
.tone = cast(ButtonTone)(ifx active then ButtonToneAccent else ButtonToneNeutral),
|
||||
.emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 &&
|
||||
column > 0 && !active {
|
||||
state.metric = metric
|
||||
return Finish()
|
||||
}
|
||||
header_x += column_width
|
||||
}
|
||||
y += Scale(44)
|
||||
|
||||
if state.row_count == 0 {
|
||||
key := ifx state.loading then "profile_updating_status" else "profile_no_leaderboard_data"
|
||||
Text(frame.session, TextProps.{.key = cast(u64)7120,
|
||||
.bounds = Bounds(x, y, width, Scale(32)), .text = LeaderboardLocaleHost(key),
|
||||
.font = frame.font, .wrap = cast(TextWrap)TextWrapAuto})
|
||||
return Finish()
|
||||
}
|
||||
|
||||
row_height := Scale(40)
|
||||
scroll := Scroll(frame.session, ScrollProps.{.key = cast(u64)7130,
|
||||
.bounds = Bounds(x, y, width, frame.height - frame.bottom - y - Scale(8)),
|
||||
.content_height = state.row_count * row_height, .scroll_offset = frame.scroll})
|
||||
frame.scroll = scroll.scroll_offset
|
||||
if !scroll.opened {
|
||||
return Finish()
|
||||
}
|
||||
row_y := cast(s32)scroll.content.y
|
||||
left := cast(s32)scroll.content.x
|
||||
for index: cast(s32)0..state.row_count - 1 {
|
||||
// Rows outside the viewport are not read from the host.
|
||||
if row_y + row_height > cast(s32)scroll.viewport.y &&
|
||||
row_y < cast(s32)(scroll.viewport.y + scroll.viewport.height) {
|
||||
row := ReadLeaderboardRowHost(index)
|
||||
key := cast(u64)(7200 + index * 4)
|
||||
if row.own || index % 2 == 1 {
|
||||
Box(frame.session, BoxProps.{.key = key, .bounds = Bounds(left, row_y, width, row_height),
|
||||
.fill = ifx row.own then Color.{156, 188, 143, 64} else Color.{156, 156, 156, 24},
|
||||
.radius = cast(float32)Scale(8)})
|
||||
}
|
||||
name: Vec(u8)
|
||||
BuilderPrint(*name, "%. %", row.rank, row.name)
|
||||
pad := Scale(8)
|
||||
Cell(key + 1, left + pad, row_y, name_width - pad * 2, row_height, BuilderFinish(name))
|
||||
Cell(key + 2, left + name_width + pad, row_y, value_width - pad, row_height, row.streak)
|
||||
if state.has_average {
|
||||
Cell(key + 3, left + name_width + value_width + pad, row_y,
|
||||
width - name_width - value_width - pad, row_height, row.average)
|
||||
}
|
||||
}
|
||||
row_y += row_height
|
||||
}
|
||||
End(frame.session)
|
||||
return Finish()
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# Changelog
|
||||
|
||||
## [1.0.6] - 2026-10-13
|
||||
|
||||
- Maintenance release for Inner Breeze 2.1.33.
|
||||
|
||||
## [1.0.5] - 2026-10-11
|
||||
|
||||
- Scrollbars use your theme's colours and show how much of the list is in view.
|
||||
- Scrolling while you type a new item keeps the keyboard open.
|
||||
|
||||
## [1.0.4] - 2026-10-10
|
||||
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
## [1.0.3] - 2026-10-07
|
||||
|
||||
- Keep app labels and content visible after updating Inner Breeze.
|
||||
|
||||
## [1.0.2] - 2026-10-06
|
||||
|
||||
- Use Cells consistently in the cell and its independently delivered package.
|
||||
|
||||
## [1.0.1] - 2026-10-06
|
||||
|
||||
- Load independently in the updated app host while retaining saved lists.
|
||||
- Update the list tabs, editor and completion controls with the Lists package.
|
||||
|
||||
## [1.0.0] - 2026-10-06
|
||||
|
||||
- First independently versioned Lists module.
|
||||
@@ -0,0 +1,140 @@
|
||||
// Lists owns edit decisions and list/item mutations. Storage capabilities use
|
||||
// the unified host's open database and identity.
|
||||
#import, file "../../src/cells/lists_types.zi";
|
||||
#import, file "../../src/core/types.zi";
|
||||
#import, file "../../src/cells/module_types.zi";
|
||||
#import, file "lists_view.zi";
|
||||
host_api :: #system_library "host_api";
|
||||
ReadListsHost :: () -> ListsMessage #foreign host_api;
|
||||
WriteListsHost :: (message: ListsMessage) #foreign host_api;
|
||||
PersistListsHost :: (mutation: ListsMutation) -> ListsMutationResult #foreign host_api;
|
||||
|
||||
ListsApply :: (message: ListsMessage) -> ListsMessage {
|
||||
message.succeeded = true
|
||||
if message.action == LISTS_FRAME {
|
||||
return message
|
||||
}
|
||||
if message.action == LISTS_ROUTE {
|
||||
message.visible = message.screen == ScreenEList
|
||||
return message
|
||||
}
|
||||
if message.action == LISTS_SELECT {
|
||||
if message.index < 0 || message.index >= message.list_count ||
|
||||
message.index == message.selected_list {
|
||||
return message
|
||||
}
|
||||
message.selected_list = message.index
|
||||
message.show_completed = 0
|
||||
message.completing_id = ""
|
||||
message.completing_until = 0.0
|
||||
message.editing_item = -1
|
||||
message.reset_input = true
|
||||
message.reset_scroll = true
|
||||
message.changed = true
|
||||
return message
|
||||
}
|
||||
if message.action == LISTS_VISIBLE {
|
||||
message.visibility_deadline = 0.0
|
||||
message.visible = message.index >= 0 && message.index < message.item_count &&
|
||||
message.selected_list >= 0 && message.selected_list < message.list_count &&
|
||||
message.parent_id == message.selected_id &&
|
||||
(message.done == 0 || message.show_completed != 0 ||
|
||||
(message.now < message.completing_until &&
|
||||
message.id == message.completing_id))
|
||||
if message.visible && message.done != 0 && message.show_completed == 0 {
|
||||
message.visibility_deadline = message.completing_until
|
||||
}
|
||||
return message
|
||||
}
|
||||
mutation: ListsMutation
|
||||
mutation.id = message.id
|
||||
mutation.parent_id = message.parent_id
|
||||
mutation.title = message.title
|
||||
mutation.comment = message.comment
|
||||
mutation.done = message.done
|
||||
mutation.sort_order = message.sort_order
|
||||
if message.action == LISTS_COMMIT {
|
||||
if message.title.count == 0 {
|
||||
return message
|
||||
}
|
||||
if message.editing_item == -2 {
|
||||
mutation.kind = LISTS_CREATE_LIST
|
||||
} else if message.editing_item == -3 && message.selected_list >= 0 &&
|
||||
message.selected_list < message.list_count {
|
||||
mutation.kind = LISTS_UPDATE_LIST
|
||||
} else if message.editing_item >= 0 &&
|
||||
message.editing_item < message.item_count {
|
||||
mutation.kind = LISTS_UPDATE_ITEM
|
||||
} else if message.selected_list >= 0 && message.selected_list < message.list_count {
|
||||
mutation.kind = LISTS_CREATE_ITEM
|
||||
mutation.parent_id = message.selected_id
|
||||
mutation.comment = ""
|
||||
} else {
|
||||
message.input_error = 1
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
} else if message.action == LISTS_SET_DONE {
|
||||
if message.index < 0 || message.index >= message.item_count {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
mutation.kind = LISTS_UPDATE_ITEM
|
||||
} else if message.action == LISTS_DELETE_LIST {
|
||||
if message.selected_list < 0 || message.selected_list >= message.list_count {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
mutation.kind = LISTS_REMOVE_LIST
|
||||
} else if message.action == LISTS_DELETE_ITEM {
|
||||
if message.index < 0 || message.index >= message.item_count {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
mutation.kind = LISTS_REMOVE_ITEM
|
||||
} else {
|
||||
message.succeeded = false
|
||||
return message
|
||||
}
|
||||
result := PersistListsHost(mutation)
|
||||
message.succeeded = result.saved
|
||||
if !result.saved {
|
||||
message.input_error = 1
|
||||
return message
|
||||
}
|
||||
message.input_error = 0
|
||||
message.changed = true
|
||||
message.reload = true
|
||||
message.sync = true
|
||||
if message.action == LISTS_COMMIT {
|
||||
message.reset_input = true
|
||||
message.editing_item = -1
|
||||
message.selected_id = result.created_id
|
||||
} else if message.action == LISTS_SET_DONE {
|
||||
if message.done != 0 {
|
||||
message.completing_id = message.id
|
||||
message.completing_until = message.now + 0.45
|
||||
} else if message.id == message.completing_id {
|
||||
message.completing_id = ""
|
||||
}
|
||||
} else if message.action == LISTS_DELETE_LIST {
|
||||
message.selected_list = 0
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
#program_export "ListsMain"
|
||||
Main :: () -> s32 {
|
||||
message := ReadListsHost()
|
||||
if message.abi != MODULE_ABI {
|
||||
return -1
|
||||
}
|
||||
if message.action == MODULE_IDENTIFY {
|
||||
return MODULE_LISTS
|
||||
}
|
||||
if message.action == LISTS_FRAME {
|
||||
message = ListsView(message)
|
||||
}
|
||||
WriteListsHost(ListsApply(message))
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
// Lists owns its complete screen composition; the host supplies saved rows,
|
||||
// device input and ordinary Kryon widget effects.
|
||||
#import "session"
|
||||
#import "geometry"
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import "text_props"
|
||||
#import "text_align"
|
||||
#import "text_widget"
|
||||
#import "text_input_props"
|
||||
#import "text_field_widget"
|
||||
#import "button_props"
|
||||
#import "button_widget"
|
||||
#import "control_props"
|
||||
#import "checkbox_props"
|
||||
#import "checkbox_widget"
|
||||
#import "tab_bar_props"
|
||||
#import "tab_bar_widget"
|
||||
#import "scroll_props"
|
||||
#import "scroll_widget"
|
||||
#import "tree"
|
||||
#import "icon"
|
||||
#import, file "../../src/cells/lists_ui_types.zi";
|
||||
#import, file "../../src/cells/lists_types.zi";
|
||||
|
||||
using ButtonTone;
|
||||
using ButtonEmphasis;
|
||||
using TextAlign;
|
||||
using TextWrap;
|
||||
using IconType;
|
||||
host_api :: #system_library "host_api";
|
||||
ReadListsUiHost :: () -> ListsUiFrame #foreign host_api;
|
||||
WriteListsUiHost :: (frame: ListsUiFrame) #foreign host_api;
|
||||
ReadListsRowHost :: (index: s32, item: bool) -> ListsUiRow #foreign host_api;
|
||||
ListsLocaleHost :: (key: string) -> string #foreign host_api;
|
||||
frame: ListsUiFrame;
|
||||
state: ListsMessage;
|
||||
|
||||
Scale :: (pixels: s32) -> s32 {
|
||||
return cast(s32)(cast(float32)pixels * frame.scale)
|
||||
}
|
||||
|
||||
Bounds :: (x: s32, y: s32, width: s32, height: s32) -> Rectangle {
|
||||
return Rectangle.{cast(float32)x, cast(float32)y,
|
||||
cast(float32)width, cast(float32)height}
|
||||
}
|
||||
|
||||
ListsActionProps :: (key: u64, label: string, bounds: Rectangle,
|
||||
accent: bool, disabled: bool, icon: s32) -> ButtonProps {
|
||||
return ButtonProps.{.key = key, .bounds = bounds,
|
||||
.label = label, .tone = cast(ButtonTone)(ifx accent then ButtonToneAccent else ButtonToneNeutral),
|
||||
.emphasis = cast(ButtonEmphasis)(ifx accent then ButtonEmphasisFilled else ButtonEmphasisSoft),
|
||||
.pill = icon == 0, .icon_only = icon != 0, .icon_type = icon,
|
||||
.disabled = disabled}
|
||||
}
|
||||
|
||||
BeginInput :: (item: s32, value: string) {
|
||||
state.editing_item = item
|
||||
state.input_error = 0
|
||||
frame.value = value
|
||||
frame.cursor = cast(s32)value.count
|
||||
frame.anchor = frame.cursor
|
||||
frame.scroll_x = 0
|
||||
frame.focused = true
|
||||
}
|
||||
|
||||
Finish :: () -> ListsMessage {
|
||||
WriteListsUiHost(frame)
|
||||
state.succeeded = true
|
||||
return state
|
||||
}
|
||||
|
||||
Mutation :: (action: s32, index: s32) {
|
||||
state.action = action
|
||||
state.index = index
|
||||
if state.selected_list >= 0 && state.selected_list < state.list_count {
|
||||
row := ReadListsRowHost(state.selected_list, false)
|
||||
state.id = row.id
|
||||
state.selected_id = row.id
|
||||
state.sort_order = row.sort_order
|
||||
}
|
||||
item := ifx action == LISTS_COMMIT then state.editing_item else index
|
||||
if item >= 0 && item < state.item_count {
|
||||
row := ReadListsRowHost(item, true)
|
||||
state.id = row.id
|
||||
state.parent_id = row.parent_id
|
||||
state.title = row.title
|
||||
state.comment = row.comment
|
||||
state.done = row.done
|
||||
state.sort_order = row.sort_order
|
||||
}
|
||||
if action == LISTS_COMMIT {
|
||||
state.title = frame.value
|
||||
}
|
||||
}
|
||||
|
||||
Field :: (bounds: Rectangle) -> bool {
|
||||
edited := TextField(frame.session, TextFieldProps.{.key = cast(u64)6501,
|
||||
.bounds = bounds, .value = frame.value, .cursor = frame.cursor,
|
||||
.anchor = frame.anchor, .scroll_x = frame.scroll_x,
|
||||
.focused = frame.focused, .focus_id = 6501,
|
||||
.max_bytes = 127, .max_codepoints = 127, .input = frame.input})
|
||||
if edited.edit.changed {
|
||||
start := edited.edit.start
|
||||
end := edited.edit.end
|
||||
if start >= 0 && end >= start && end <= frame.value.count {
|
||||
value: Vec(u8)
|
||||
BuilderPrint(*value, "%", frame.value[:start])
|
||||
BuilderPrint(*value, "%", edited.edit.replacement)
|
||||
BuilderPrint(*value, "%", frame.value[end:])
|
||||
replacement := BuilderFinish(value)
|
||||
if replacement.count <= 127 {
|
||||
frame.value = replacement
|
||||
}
|
||||
}
|
||||
}
|
||||
frame.cursor = edited.cursor
|
||||
frame.anchor = edited.anchor
|
||||
frame.scroll_x = edited.scroll_x
|
||||
frame.focused = edited.focused
|
||||
frame.clipboard_write = edited.clipboard_write
|
||||
frame.clipboard_text = edited.clipboard_text
|
||||
return edited.committed
|
||||
}
|
||||
|
||||
ListsView :: (message: ListsMessage) -> ListsMessage {
|
||||
frame = ReadListsUiHost()
|
||||
state = message
|
||||
x := Scale(16)
|
||||
width := frame.width - x * 2
|
||||
y := Scale(12)
|
||||
tabs: [32]Tab
|
||||
for index: cast(s32)0..state.list_count - 1 {
|
||||
row := ReadListsRowHost(index, false)
|
||||
tabs[index] = Tab.{.key = cast(u64)(6800 + index), .label = row.title}
|
||||
}
|
||||
action_width := Scale(118)
|
||||
actions := action_width
|
||||
if state.list_count > 0 && state.selected_list >= 0 {
|
||||
actions += Scale(88)
|
||||
}
|
||||
selector := width - actions - Scale(10)
|
||||
if selector < Scale(160) {
|
||||
actions = action_width
|
||||
selector = width - actions - Scale(10)
|
||||
}
|
||||
if state.list_count > 0 && selector > 0 {
|
||||
selected := TabBar(frame.session, TabBarProps.{.id = 6500,
|
||||
.bounds = Bounds(x, y, selector, Scale(44)),
|
||||
.selected_index = state.selected_list, .min_tab_width = Scale(72),
|
||||
.max_tab_width = selector}, tabs[:state.list_count])
|
||||
if selected.selected_index != state.selected_list {
|
||||
state.action = LISTS_SELECT
|
||||
state.index = selected.selected_index
|
||||
return Finish()
|
||||
}
|
||||
}
|
||||
if Button(frame.session, ListsActionProps(cast(u64)6505, ListsLocaleHost("elist_new_list"),
|
||||
Bounds(x + width - action_width, y, action_width, Scale(44)), false, false, 0)) != 0 {
|
||||
BeginInput(-2, "")
|
||||
return Finish()
|
||||
}
|
||||
if state.list_count > 0 && state.selected_list >= 0 && actions > action_width {
|
||||
edit_x := x + width - action_width - Scale(84)
|
||||
if Button(frame.session, ListsActionProps(cast(u64)6503, "", Bounds(edit_x, y, Scale(38), Scale(38)),
|
||||
false, false, cast(s32)IconEdit)) != 0 {
|
||||
BeginInput(-3, ReadListsRowHost(state.selected_list, false).title)
|
||||
}
|
||||
if Button(frame.session, ListsActionProps(cast(u64)6504, "", Bounds(edit_x + Scale(40), y, Scale(38), Scale(38)),
|
||||
false, false, cast(s32)IconTrash)) != 0 {
|
||||
Mutation(LISTS_DELETE_LIST, -1)
|
||||
return Finish()
|
||||
}
|
||||
}
|
||||
y += Scale(60)
|
||||
if state.input_error != 0 {
|
||||
Text(frame.session, TextProps.{.bounds = Bounds(x, y, width, Scale(40)),
|
||||
.text = ListsLocaleHost("results_write_failed"), .wrap = cast(TextWrap)TextWrapAuto})
|
||||
y += Scale(48)
|
||||
}
|
||||
if state.editing_item == -2 || state.editing_item == -3 {
|
||||
committed := Field(Bounds(x, y, width, Scale(44)))
|
||||
if Button(frame.session, ListsActionProps(cast(u64)6506,
|
||||
ListsLocaleHost(ifx state.editing_item == -3 then "done_button" else "elist_create_list"),
|
||||
Bounds(x, y + Scale(52), width, Scale(40)), true, frame.value.count == 0, 0)) != 0 || committed {
|
||||
Mutation(LISTS_COMMIT, -1)
|
||||
}
|
||||
return Finish()
|
||||
}
|
||||
if state.list_count == 0 {
|
||||
Text(frame.session, TextProps.{.bounds = Bounds(x, y + Scale(48), width, Scale(30)),
|
||||
.text = ListsLocaleHost("elist_empty_title"), .align = cast(TextAlign)TextAlignCenter})
|
||||
Text(frame.session, TextProps.{.bounds = Bounds(x, y + Scale(88), width, Scale(48)),
|
||||
.text = ListsLocaleHost("elist_empty_detail"), .align = cast(TextAlign)TextAlignCenter,
|
||||
.wrap = cast(TextWrap)TextWrapAuto})
|
||||
return Finish()
|
||||
}
|
||||
field_width := width - Scale(92)
|
||||
committed := Field(Bounds(x, y, field_width, Scale(44)))
|
||||
if Button(frame.session, ListsActionProps(cast(u64)6507,
|
||||
ListsLocaleHost(ifx state.editing_item >= 0 then "done_button" else "elist_add_item"),
|
||||
Bounds(x + field_width + Scale(8), y, Scale(84), Scale(44)),
|
||||
true, frame.value.count == 0, 0)) != 0 || committed {
|
||||
Mutation(LISTS_COMMIT, -1)
|
||||
return Finish()
|
||||
}
|
||||
y += Scale(52)
|
||||
footer := frame.height - frame.bottom - Scale(72)
|
||||
if footer < y + Scale(58) {
|
||||
footer = y + Scale(58)
|
||||
}
|
||||
footer_width := ifx Scale(176) > width then width else Scale(176)
|
||||
if Button(frame.session, ListsActionProps(cast(u64)6502,
|
||||
ListsLocaleHost(ifx state.show_completed != 0 then "elist_hide_completed" else "elist_show_completed"),
|
||||
Bounds(x + width - footer_width, footer, footer_width, Scale(44)), false, false, 0)) != 0 {
|
||||
state.show_completed = ifx state.show_completed == 0 then 1 else 0
|
||||
frame.scroll = 0
|
||||
}
|
||||
visible: [256]bool
|
||||
count: s32 = 0
|
||||
selected_id := ReadListsRowHost(state.selected_list, false).id
|
||||
for index: cast(s32)0..state.item_count - 1 {
|
||||
row := ReadListsRowHost(index, true)
|
||||
visible[index] = row.parent_id == selected_id && (row.done == 0 ||
|
||||
state.show_completed != 0 || (row.id == state.completing_id && state.now < state.completing_until))
|
||||
if visible[index] {
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
scroll := Scroll(frame.session, ScrollProps.{.key = cast(u64)6600,
|
||||
.bounds = Bounds(x, y, width, footer - y - Scale(12)),
|
||||
.content_height = count * Scale(66), .scroll_offset = frame.scroll})
|
||||
frame.scroll = scroll.scroll_offset
|
||||
if scroll.opened {
|
||||
row_y := cast(s32)scroll.content.y
|
||||
for index: cast(s32)0..state.item_count - 1 {
|
||||
if !visible[index] {
|
||||
continue
|
||||
}
|
||||
if row_y + Scale(58) > cast(s32)scroll.viewport.y &&
|
||||
row_y < cast(s32)(scroll.viewport.y + scroll.viewport.height) {
|
||||
row := ReadListsRowHost(index, true)
|
||||
key := cast(u64)(7000 + index * 4)
|
||||
checked := Checkbox(frame.session, CheckboxProps.{.key = key,
|
||||
.bounds = Bounds(x + Scale(10), row_y + Scale(17), Scale(28), Scale(28)),
|
||||
.checked = row.done != 0})
|
||||
if checked.changed {
|
||||
Mutation(LISTS_SET_DONE, index)
|
||||
state.done = ifx checked.checked then 1 else 0
|
||||
End(frame.session)
|
||||
return Finish()
|
||||
}
|
||||
Text(frame.session, TextProps.{.bounds = Bounds(x + Scale(52), row_y,
|
||||
width - Scale(138), ifx row.comment.count > 0 then Scale(28) else Scale(58)),
|
||||
.text = row.title, .vertical_align = cast(TextAlign)TextAlignCenter,
|
||||
.strikethrough = row.done != 0})
|
||||
if row.comment.count > 0 {
|
||||
Text(frame.session, TextProps.{.bounds = Bounds(x + Scale(52), row_y + Scale(32),
|
||||
width - Scale(138), Scale(18)), .text = row.comment})
|
||||
}
|
||||
if Button(frame.session, ListsActionProps(key + cast(u64)1, "", Bounds(x + width - Scale(78), row_y + Scale(12), Scale(34), Scale(34)),
|
||||
false, false, cast(s32)IconEdit)) != 0 {
|
||||
BeginInput(index, row.title)
|
||||
}
|
||||
if Button(frame.session, ListsActionProps(key + cast(u64)2, "", Bounds(x + width - Scale(40), row_y + Scale(12), Scale(34), Scale(34)),
|
||||
false, false, cast(s32)IconTrash)) != 0 {
|
||||
Mutation(LISTS_DELETE_ITEM, index)
|
||||
End(frame.session)
|
||||
return Finish()
|
||||
}
|
||||
}
|
||||
row_y += Scale(66)
|
||||
}
|
||||
End(frame.session)
|
||||
}
|
||||
return Finish()
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
# Changelog
|
||||
|
||||
## [1.4.0] - 2026-10-13
|
||||
### Added
|
||||
- Lumi understands habit requests on your device, in every app language: add, rename, pause, resume or delete a habit, set its days and reminder, count it or measure it from start to end, and give it questions with what a good answer is. For example “add a habit push ups every day at 8”, “jumping rope should ask how many I did, higher is better” or “my eating window is good at most 8 hours”. Lumi asks before it deletes a habit.
|
||||
- A title bar with a connection button that switches Lumi between offline and online, and a wrench that opens Lumi's settings; Back returns to the chat. Lumi starts offline and goes online only after you agree to its online terms, which say what is sent, where it goes and what is kept. Until you answer, Lumi shows them when you open it, once each time Inner Breeze starts.
|
||||
- Lumi's settings: read or withdraw the online terms, and use your own OpenAI-compatible AI provider with its address, key and model instead of Inner Breeze's server.
|
||||
- Tap Lumi beside her message and she swirls around, just for fun.
|
||||
### Changed
|
||||
- Offline, Lumi sends nothing: no AI requests, no feedback delivery and no Telegram messages until you switch it online.
|
||||
- Lumi answers a request it understood but couldn't carry out itself, such as a name that matches several items, instead of asking the AI.
|
||||
- Diary spelling checks and automatic habit icons follow the same switch and terms. Until then the diary offers no spelling corrections, and habits show their practice's icon or their first letter.
|
||||
- Requires Inner Breeze 2.1.33 or later.
|
||||
|
||||
## [1.3.9] - 2026-10-11
|
||||
### Fixed
|
||||
- Scrolling the command list keeps the keyboard open.
|
||||
### Changed
|
||||
- Scrollbars use your theme's colours and show how much of the chat is in view.
|
||||
|
||||
## [1.3.8] - 2026-10-11
|
||||
### Added
|
||||
- Select messages like in Telegram: hold a message to select it, then tap or drag across others; dragging to the top or bottom of the chat scrolls it, through older messages too. Checkmarks show what is selected, and a bar over the top of the chat shows how many, with copy and delete.
|
||||
### Changed
|
||||
- Lumi's typing dots appear after a short pause, as a person reads before typing.
|
||||
- Feedback shows only its card with Yes and No, without a second copy of the question.
|
||||
|
||||
## [1.3.7] - 2026-10-11
|
||||
### Changed
|
||||
- Like Telegram, the chat shows your newest messages and loads older ones as you scroll up, right away while the newest do not fill the screen.
|
||||
|
||||
## [1.3.6] - 2026-10-10
|
||||
### Added
|
||||
- While Lumi is answering, three dots show in its bubble where the answer will appear.
|
||||
|
||||
## [1.3.5] - 2026-10-10
|
||||
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
## [1.3.4] - 2026-10-10
|
||||
### Added
|
||||
- Tap the / button or type / to see Lumi's commands, as in Telegram. The list narrows as you type; tap a command or press Enter to use it, and commands that need text wait for it in the message box.
|
||||
### Changed
|
||||
- Send with an arrow button.
|
||||
|
||||
## [1.3.3] - 2026-10-10
|
||||
### Fixed
|
||||
- Open the chat without a pause by preparing command suggestions only while you type.
|
||||
|
||||
## [1.3.2] - 2026-10-07
|
||||
### Changed
|
||||
- Load earlier chat messages automatically as you scroll up, preserving your reading position.
|
||||
- Move Telegram setup from the chat toolbar into Settings.
|
||||
|
||||
## [1.3.1] - 2026-10-07
|
||||
|
||||
- Format bold emphasis in replies and save explicit feature suggestions as feedback offline.
|
||||
|
||||
## [1.3.0] - 2026-10-07
|
||||
|
||||
- Show daily progress charts from saved practices, meditation, breath retention and completed habits.
|
||||
- Keep charts in chat, select daily values, and show an empty state when no activity is recorded.
|
||||
- Show donation cards with Bitcoin and Monero addresses, wallet links and browser donation links.
|
||||
|
||||
## [1.2.0] - 2026-10-07
|
||||
|
||||
- Understand natural conversation online with the same tools in Inner Breeze and Harmony.
|
||||
- Save explicit app feedback offline and receive private developer replies in chat.
|
||||
|
||||
## [1.1.3] - 2026-10-06
|
||||
|
||||
- Keep longer conversations responsive when opening, scrolling and typing.
|
||||
|
||||
|
||||
## [1.1.2] - 2026-10-06
|
||||
|
||||
- Write to today's Diary from chat, with the current time above each message.
|
||||
- Ask for text when a Diary request has no entry yet, and preserve multiline messages.
|
||||
- Insert a new line with Shift+Enter and send with Enter.
|
||||
- Keep replies short when a request is unclear.
|
||||
- Display the mirrored avatar beside replies.
|
||||
|
||||
## [1.1.1] - 2026-10-06
|
||||
|
||||
- Change color themes, light and dark mode directly from chat, and open Settings or Appearance.
|
||||
- Keep the bundled companion available when its sidebar shortcut is hidden.
|
||||
- Show a clearer firefly icon in the sidebar.
|
||||
|
||||
## [1.1.0] - 2026-10-06
|
||||
|
||||
- Place Lumi’s avatar beside her replies in a chat without a title bar.
|
||||
- Complete habits for today and start WHM, meditation, Sun Salutation or breathing patterns directly from chat.
|
||||
- Offer only commands supported by installed and enabled cells.
|
||||
- Ask which habit to complete, choose it by name, and use compact autocomplete chips with case-insensitive matching and command spelling correction.
|
||||
|
||||
## [1.0.0] - 2026-10-06
|
||||
|
||||
- Meet Lumi, Inner Breeze's firefly companion, in a private local chat.
|
||||
- Complete commands and todo names as you type, add todos, mark them complete, reopen them, and open your selected apps.
|
||||
@@ -0,0 +1,140 @@
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import "utf8"
|
||||
|
||||
CommandSpace :: (byte: u8) -> bool {
|
||||
return byte == 32 || byte == 9 || byte == 10 || byte == 13
|
||||
}
|
||||
|
||||
CommandFold :: (codepoint: u32) -> u32 {
|
||||
if (codepoint >= 65 && codepoint <= 90) || (codepoint >= 192 && codepoint <= 222 && codepoint != 215) ||
|
||||
(codepoint >= 1040 && codepoint <= 1071) {
|
||||
return codepoint + cast(u32)32
|
||||
}
|
||||
if codepoint >= 1024 && codepoint <= 1039 {
|
||||
return codepoint + cast(u32)80
|
||||
}
|
||||
if ((codepoint >= 256 && codepoint <= 311) || (codepoint >= 330 && codepoint <= 375)) && codepoint % cast(u32)2 == 0 {
|
||||
return codepoint + cast(u32)1
|
||||
}
|
||||
if codepoint >= 313 && codepoint <= 328 && codepoint % cast(u32)2 == 1 {
|
||||
return codepoint + cast(u32)1
|
||||
}
|
||||
if codepoint == 376 {
|
||||
return cast(u32)255
|
||||
}
|
||||
return codepoint
|
||||
}
|
||||
|
||||
CommandEqual :: (left: string, right: string) -> bool {
|
||||
a: s32 = 0
|
||||
b: s32 = 0
|
||||
while a < left.count && b < right.count {
|
||||
x := Decode(left, a)
|
||||
y := Decode(right, b)
|
||||
if CommandFold(x.value) != CommandFold(y.value) {
|
||||
return false
|
||||
}
|
||||
a = x.after
|
||||
b = y.after
|
||||
}
|
||||
return a == left.count && b == right.count
|
||||
}
|
||||
|
||||
// One insertion, deletion, substitution or adjacent transposition in a command
|
||||
// word. Names and IDs never pass through this spelling correction.
|
||||
CommandTypo :: (left: string, right: string) -> bool {
|
||||
if CommandEqual(left, right) {
|
||||
return true
|
||||
}
|
||||
if (left.count > 0 && left[0] == cast(u8)47) || (right.count > 0 && right[0] == cast(u8)47) {
|
||||
return false
|
||||
}
|
||||
if left.count < 4 || right.count < 4 || left.count > 32 || right.count > 32 ||
|
||||
left.count > right.count + 1 || right.count > left.count + 1 {
|
||||
return false
|
||||
}
|
||||
for byte: left {
|
||||
if byte >= 128 { return false }
|
||||
}
|
||||
for byte: right {
|
||||
if byte >= 128 { return false }
|
||||
}
|
||||
a: s64 = 0
|
||||
b: s64 = 0
|
||||
edits: s32 = 0
|
||||
while a < left.count && b < right.count {
|
||||
if LowerASCII(left[a]) == LowerASCII(right[b]) {
|
||||
a += 1
|
||||
b += 1
|
||||
continue
|
||||
}
|
||||
edits += 1
|
||||
if edits > 1 { return false }
|
||||
if left.count == right.count && a + 1 < left.count && b + 1 < right.count &&
|
||||
LowerASCII(left[a]) == LowerASCII(right[b + 1]) && LowerASCII(left[a + 1]) == LowerASCII(right[b]) {
|
||||
a += 2
|
||||
b += 2
|
||||
} else if left.count > right.count {
|
||||
a += 1
|
||||
} else if right.count > left.count {
|
||||
b += 1
|
||||
} else {
|
||||
a += 1
|
||||
b += 1
|
||||
}
|
||||
}
|
||||
if a < left.count || b < right.count { edits += 1 }
|
||||
return edits <= 1
|
||||
}
|
||||
|
||||
CommandPrefixEnd :: (input: string, command: string) -> s32 {
|
||||
a: s32 = 0
|
||||
b: s32 = 0
|
||||
while b < command.count {
|
||||
while a < input.count && CommandSpace(input[a]) { a += 1 }
|
||||
while b < command.count && CommandSpace(command[b]) { b += 1 }
|
||||
if b >= command.count { break }
|
||||
start_a := a
|
||||
start_b := b
|
||||
while a < input.count && !CommandSpace(input[a]) { a += 1 }
|
||||
while b < command.count && !CommandSpace(command[b]) { b += 1 }
|
||||
if !CommandTypo(input[start_a:a], command[start_b:b]) { return -1 }
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
CommandPhrase :: (input: string, command: string) -> bool {
|
||||
return command.count > 0 && CommandPrefixEnd(input, command) == input.count
|
||||
}
|
||||
|
||||
CommandNormalize :: (input: string) -> string {
|
||||
words: [10]string = .["start", "meditation", "sun", "salutation", "salutations",
|
||||
"breathing", "patterns", "wim", "hof", "method"]
|
||||
out: Vec(u8)
|
||||
at: s32 = 0
|
||||
while at < input.count {
|
||||
while at < input.count && CommandSpace(input[at]) { at += 1 }
|
||||
start := at
|
||||
while at < input.count && !CommandSpace(input[at]) { at += 1 }
|
||||
if start == at { break }
|
||||
word := input[start:at]
|
||||
matches: s32 = 0
|
||||
replacement := word
|
||||
for candidate: words {
|
||||
if CommandEqual(word, candidate) {
|
||||
replacement = candidate
|
||||
matches = 1
|
||||
break
|
||||
}
|
||||
if CommandTypo(word, candidate) {
|
||||
replacement = candidate
|
||||
matches += 1
|
||||
}
|
||||
}
|
||||
if matches != 1 { replacement = word }
|
||||
if out.count > 0 { BuilderPrint(*out, " ") }
|
||||
BuilderPrint(*out, "%", replacement)
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
// A small offline engine. UI and host effects do not depend on its internals;
|
||||
// an on-device model can later produce the same typed LumiAction values.
|
||||
#import "utf8"
|
||||
#import, file "command_text.zi";
|
||||
#import, file "regex.zi";
|
||||
#import, file "../../src/cells/lumi_types.zi";
|
||||
#import, file "../../src/app/route_types.zi";
|
||||
|
||||
using AppNavRoute;
|
||||
|
||||
LumiTrim :: (value: string) -> string {
|
||||
start: s64 = 0
|
||||
end := value.count
|
||||
while start < end && CommandSpace(value[start]) {
|
||||
start += 1
|
||||
}
|
||||
while end > start && CommandSpace(value[end - 1]) {
|
||||
end -= 1
|
||||
}
|
||||
return value[start:end]
|
||||
}
|
||||
|
||||
LumiLower :: (byte: u8) -> u8 {
|
||||
if byte >= cast(u8)65 && byte <= cast(u8)90 {
|
||||
return byte + cast(u8)32
|
||||
}
|
||||
return byte
|
||||
}
|
||||
|
||||
LumiStarts :: (value: string, prefix: string) -> bool {
|
||||
a: s32 = 0
|
||||
b: s32 = 0
|
||||
while b < prefix.count {
|
||||
if a >= value.count { return false }
|
||||
x := Decode(value, a)
|
||||
y := Decode(prefix, b)
|
||||
if CommandFold(x.value) != CommandFold(y.value) { return false }
|
||||
a = x.after
|
||||
b = y.after
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
LumiEqual :: (left: string, right: string) -> bool {
|
||||
return CommandEqual(left, right)
|
||||
}
|
||||
|
||||
LumiSuggests :: (candidate: string, typed: string) -> bool {
|
||||
a: s32 = 0
|
||||
b: s32 = 0
|
||||
while b < typed.count {
|
||||
while a < candidate.count && CommandSpace(candidate[a]) { a += 1 }
|
||||
while b < typed.count && CommandSpace(typed[b]) { b += 1 }
|
||||
if b >= typed.count { return true }
|
||||
start_a := a
|
||||
start_b := b
|
||||
while a < candidate.count && !CommandSpace(candidate[a]) { a += 1 }
|
||||
while b < typed.count && !CommandSpace(typed[b]) { b += 1 }
|
||||
word := typed[start_b:b]
|
||||
option := candidate[start_a:a]
|
||||
if b == typed.count && LumiStarts(option, word) { return true }
|
||||
if !CommandTypo(word, option) { return false }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
LumiArgument :: (input: string, command: string) -> string {
|
||||
end := CommandPrefixEnd(input, command)
|
||||
if command.count == 0 || end < 0 || end >= input.count || !CommandSpace(input[end]) {
|
||||
return ""
|
||||
}
|
||||
return LumiTrim(input[end:])
|
||||
}
|
||||
|
||||
LumiProgressIntent :: (input: string, commands: LumiCommands) -> LumiAction {
|
||||
prefixes: [2]string = .[commands.progress, "/progress"]
|
||||
for prefix: prefixes {
|
||||
if prefix.count == 0 {
|
||||
continue
|
||||
}
|
||||
if LumiEqual(input, prefix) {
|
||||
return LumiAction.{.kind = LUMI_SHOW_PROGRESS, .practice = LUMI_PROGRESS_SESSIONS, .route = 7}
|
||||
}
|
||||
argument := LumiArgument(input, prefix)
|
||||
if argument.count == 0 {
|
||||
continue
|
||||
}
|
||||
boundary: s64 = 0
|
||||
while boundary < argument.count && !CommandSpace(argument[boundary]) {
|
||||
boundary += 1
|
||||
}
|
||||
metrics: [4]string = .["sessions", "meditation", "retention", "habits"]
|
||||
for metric: cast(s32)0..cast(s32)3 {
|
||||
if !LumiEqual(argument[:boundary], metrics[metric]) {
|
||||
continue
|
||||
}
|
||||
days_text := LumiTrim(argument[boundary:])
|
||||
days: s32 = 7
|
||||
if days_text.count > 0 {
|
||||
if days_text.count > 2 {
|
||||
return LumiAction.{}
|
||||
}
|
||||
days = 0
|
||||
for byte: days_text {
|
||||
if byte < cast(u8)48 || byte > cast(u8)57 {
|
||||
return LumiAction.{}
|
||||
}
|
||||
days = days * 10 + cast(s32)(byte - cast(u8)48)
|
||||
}
|
||||
}
|
||||
if days >= 1 && days <= LUMI_PROGRESS_MAX_DAYS {
|
||||
return LumiAction.{.kind = LUMI_SHOW_PROGRESS, .practice = metric, .route = days}
|
||||
}
|
||||
}
|
||||
}
|
||||
aliases: [4]string = .["show my progress", "show progress", "show progress chart", "progress chart"]
|
||||
for alias: aliases {
|
||||
if CommandPhrase(input, alias) {
|
||||
return LumiAction.{.kind = LUMI_SHOW_PROGRESS, .practice = LUMI_PROGRESS_SESSIONS, .route = 7}
|
||||
}
|
||||
}
|
||||
return LumiAction.{}
|
||||
}
|
||||
|
||||
LumiIntent :: (input: string, commands: LumiCommands) -> LumiAction {
|
||||
return LumiIntentWith(input, commands, true)
|
||||
}
|
||||
|
||||
// Without shorthand, "add" and "done" alone are left for habit requests
|
||||
// such as "add a habit ...", which Lumi reads before them.
|
||||
LumiIntentWith :: (input: string, commands: LumiCommands, shorthand: bool) -> LumiAction {
|
||||
input = LumiTrim(input)
|
||||
progress := LumiProgressIntent(input, commands)
|
||||
if progress.kind != 0 {
|
||||
return progress
|
||||
}
|
||||
donation_aliases: [5]string = .[commands.donations, "/donate", "donation links", "show donation links", "how can I donate?"]
|
||||
for alias: donation_aliases {
|
||||
if alias.count > 0 && LumiEqual(input, alias) {
|
||||
return LumiAction.{.kind = LUMI_SHOW_DONATIONS}
|
||||
}
|
||||
}
|
||||
// Explicit reports remain usable without a network or a model allowance.
|
||||
feedback_prefixes: [19]string = .["/feedback ", "feedback:", "feedback ", "fix ", "please fix ",
|
||||
"/suggest ", "suggestion:", "suggestion ", "feature request:", "feature request ",
|
||||
"app idea:", "improve the app ", "the app should ", "this app should ", "inbe should ",
|
||||
"inner breeze should ", "lumi should ", "i wish the app ", "i suggest "]
|
||||
for prefix: feedback_prefixes {
|
||||
if LumiStarts(input, prefix) && input.count > prefix.count {
|
||||
return LumiAction.{.kind = LUMI_REPORT_FEEDBACK, .title = input}
|
||||
}
|
||||
}
|
||||
diary_prefixes: [7]string = .[commands.write_diary, "write this to my diary",
|
||||
"write to my diary", "add to my diary", "save to my diary", "/journal", "/diary"]
|
||||
boundary: s32 = 0
|
||||
while boundary < input.count && input[boundary] != cast(u8)58 && input[boundary] != cast(u8)10 {
|
||||
boundary += 1
|
||||
}
|
||||
for prefix: diary_prefixes {
|
||||
if prefix.count == 0 || (prefix == "/diary" && LumiEqual(input, prefix)) {
|
||||
continue
|
||||
}
|
||||
if boundary < input.count && CommandPhrase(LumiTrim(input[:boundary]), prefix) {
|
||||
return LumiAction.{.kind = LUMI_WRITE_DIARY, .title = LumiTrim(input[boundary + 1:])}
|
||||
}
|
||||
end := CommandPrefixEnd(input, prefix)
|
||||
if end >= 0 && (end == input.count || CommandSpace(input[end])) {
|
||||
return LumiAction.{.kind = LUMI_WRITE_DIARY, .title = LumiTrim(input[end:])}
|
||||
}
|
||||
}
|
||||
if LumiEqual(input, commands.settings) || LumiEqual(input, "/settings") ||
|
||||
CommandPhrase(input, "open settings") {
|
||||
return LumiAction.{.kind = LUMI_OPEN, .route = APP_NAV_ROUTE_SETTINGS}
|
||||
}
|
||||
if LumiEqual(input, commands.appearance) || LumiEqual(input, "/appearance") ||
|
||||
CommandPhrase(input, "open appearance") {
|
||||
return LumiAction.{.kind = LUMI_OPEN, .route = APP_NAV_ROUTE_SETTINGS, .practice = 1}
|
||||
}
|
||||
modes: [3]string = .[commands.system, commands.light, commands.dark]
|
||||
mode_aliases: [3]string = .["system mode", "light mode", "dark mode"]
|
||||
mode_commands: [3]string = .["/system", "/light", "/dark"]
|
||||
for index: cast(s32)0..cast(s32)2 {
|
||||
if LumiEqual(input, modes[index]) || LumiEqual(input, mode_commands[index]) ||
|
||||
CommandPhrase(input, mode_aliases[index]) {
|
||||
return LumiAction.{.kind = LUMI_SET_MODE, .route = index}
|
||||
}
|
||||
}
|
||||
theme := LumiArgument(input, commands.theme)
|
||||
if theme.count == 0 {
|
||||
theme = LumiArgument(input, "/theme")
|
||||
}
|
||||
if theme.count == 0 {
|
||||
theme = LumiArgument(input, "theme")
|
||||
}
|
||||
if theme.count > 0 {
|
||||
return LumiAction.{.kind = LUMI_SET_THEME, .title = theme}
|
||||
}
|
||||
starts: [4]string = .[commands.start_whm, commands.start_meditation,
|
||||
commands.start_sun, commands.start_patterns]
|
||||
for index: cast(s32)0..cast(s32)3 {
|
||||
if starts[index].count > 0 && CommandPhrase(input, starts[index]) {
|
||||
return LumiAction.{.kind = LUMI_START_PRACTICE, .practice = index}
|
||||
}
|
||||
}
|
||||
first_word_end: s32 = 0
|
||||
while first_word_end < input.count && !CommandSpace(input[first_word_end]) {
|
||||
first_word_end += 1
|
||||
}
|
||||
// All practice expressions start with the corrected word "start". Free
|
||||
// text needs neither a normalized copy nor seven regex evaluations.
|
||||
if CommandTypo(input[:first_word_end], "start") {
|
||||
normalized := CommandNormalize(input)
|
||||
practice_patterns: [7]string = .["^start\\s+whm[.!?]*$", "^start\\s+wim\\s+hof$",
|
||||
"^start\\s+wim\\s+hof\\s+method$", "^start\\s+meditation[.!?]*$",
|
||||
"^start\\s+sun\\s+salutations?[.!?]*$", "^start\\s+breathing\\s+patterns[.!?]*$",
|
||||
"^start\\s+patterns[.!?]*$"]
|
||||
ids: [7]s32 = .[0, 0, 0, 1, 2, 3, 3]
|
||||
for index: cast(s32)0..cast(s32)6 {
|
||||
if RegexMatch(practice_patterns[index], normalized) {
|
||||
return LumiAction.{.kind = LUMI_START_PRACTICE, .practice = ids[index]}
|
||||
}
|
||||
}
|
||||
}
|
||||
practice_aliases: [10]string = .["start whm", "start wim hof", "start wim hof method",
|
||||
"/whm", "start meditation", "start sun salutation", "start sun salutations",
|
||||
"start breathing patterns", "start patterns", "/meditate"]
|
||||
practice_ids: [10]s32 = .[0, 0, 0, 0, 1, 2, 2, 3, 3, 1]
|
||||
for index: cast(s32)0..cast(s32)9 {
|
||||
if LumiEqual(input, practice_aliases[index]) {
|
||||
return LumiAction.{.kind = LUMI_START_PRACTICE, .practice = practice_ids[index]}
|
||||
}
|
||||
}
|
||||
habit_prefixes: [5]string = .[commands.complete_habit, "/habit", "complete habit",
|
||||
"done habit", "mark habit complete"]
|
||||
for prefix: habit_prefixes {
|
||||
if CommandPhrase(input, prefix) {
|
||||
return LumiAction.{.kind = LUMI_COMPLETE_HABIT}
|
||||
}
|
||||
title := LumiArgument(input, prefix)
|
||||
if title.count > 0 {
|
||||
return LumiAction.{.kind = LUMI_COMPLETE_HABIT, .title = title}
|
||||
}
|
||||
}
|
||||
routes: [4]s32 = .[APP_NAV_ROUTE_ELIST, APP_NAV_ROUTE_HABITS,
|
||||
APP_NAV_ROUTE_PRACTICE, APP_NAV_ROUTE_DIARY]
|
||||
labels: [4]string = .[commands.lists, commands.habits, commands.practices, commands.diary]
|
||||
aliases: [4]string = .["/lists", "/habits", "/practices", "/diary"]
|
||||
for index: cast(s32)0..cast(s32)3 {
|
||||
if CommandPhrase(input, labels[index]) || LumiEqual(input, aliases[index]) {
|
||||
return LumiAction.{.kind = LUMI_OPEN, .route = routes[index]}
|
||||
}
|
||||
}
|
||||
prefixes: [9]string = .[commands.add, "/todo", "add todo", commands.complete,
|
||||
"/done", "complete todo", commands.reopen, "/reopen", "reopen todo"]
|
||||
for index: cast(s32)0..cast(s32)8 {
|
||||
title := LumiArgument(input, prefixes[index])
|
||||
if title.count > 0 {
|
||||
kind: s32 = ifx index < 3 then LUMI_ADD_TODO else ifx index < 6 then LUMI_COMPLETE_TODO else LUMI_REOPEN_TODO
|
||||
return LumiAction.{.kind = kind, .title = title}
|
||||
}
|
||||
}
|
||||
// Common English shorthand remains available beside translated commands.
|
||||
if !shorthand {
|
||||
return LumiAction.{}
|
||||
}
|
||||
add := LumiArgument(input, "add")
|
||||
if add.count > 0 {
|
||||
return LumiAction.{.kind = LUMI_ADD_TODO, .title = add}
|
||||
}
|
||||
done := LumiArgument(input, "done")
|
||||
if done.count > 0 {
|
||||
return LumiAction.{.kind = LUMI_COMPLETE_TODO, .title = done}
|
||||
}
|
||||
return LumiAction.{}
|
||||
}
|
||||
|
||||
// Both the conversation and autocomplete use the same installed tool policy.
|
||||
LumiActionAvailable :: (action: LumiAction, available_apps: s32) -> bool {
|
||||
if action.kind == LUMI_SHOW_DONATIONS || action.kind == LUMI_REPORT_FEEDBACK || action.kind == LUMI_SET_THEME || action.kind == LUMI_SET_MODE ||
|
||||
(action.kind == LUMI_OPEN && action.route == APP_NAV_ROUTE_SETTINGS) {
|
||||
return true
|
||||
}
|
||||
bit: s32 = 0
|
||||
if action.kind == LUMI_SHOW_PROGRESS {
|
||||
bit = ifx action.practice == LUMI_PROGRESS_HABITS then LUMI_HABITS else LUMI_PRACTICES
|
||||
} else if action.kind == LUMI_ADD_TODO || action.kind == LUMI_COMPLETE_TODO || action.kind == LUMI_REOPEN_TODO {
|
||||
bit = LUMI_LISTS
|
||||
} else if action.kind == LUMI_WRITE_DIARY {
|
||||
bit = LUMI_DIARY
|
||||
} else if action.kind == LUMI_COMPLETE_HABIT {
|
||||
bit = LUMI_HABITS
|
||||
} else if action.kind == LUMI_START_PRACTICE {
|
||||
bit = LUMI_PRACTICES
|
||||
} else if action.kind == LUMI_OPEN {
|
||||
if action.route == APP_NAV_ROUTE_ELIST {
|
||||
bit = LUMI_LISTS
|
||||
} else if action.route == APP_NAV_ROUTE_HABITS {
|
||||
bit = LUMI_HABITS
|
||||
} else if action.route == APP_NAV_ROUTE_PRACTICE {
|
||||
bit = LUMI_PRACTICES
|
||||
} else if action.route == APP_NAV_ROUTE_DIARY {
|
||||
bit = LUMI_DIARY
|
||||
}
|
||||
}
|
||||
return bit != 0 && (available_apps & bit) != 0
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
// What Lumi says after a habit request it understood on the device, and
|
||||
// the small readers lumi.zi uses to run it through the host's app tools,
|
||||
// the same validated tools the online model calls. Nothing here calls the
|
||||
// host, so the phrase tests run it as it is.
|
||||
#import "vec"
|
||||
#import "text"
|
||||
#import "json_scan"
|
||||
#import "byte_text_linux"
|
||||
#import, file "habit_intent.zi";
|
||||
#import, file "habit_patterns.zi";
|
||||
#import, file "../../src/cells/lumi_types.zi";
|
||||
|
||||
LUMI_HABITS_MAX :: 48
|
||||
|
||||
// The translated words of Lumi's habit answers. Most are the habit
|
||||
// editor's own, so Lumi and Habits describe a change alike.
|
||||
LumiReplyWords :: struct {
|
||||
created: string
|
||||
renamed: string
|
||||
paused: string
|
||||
resumed: string
|
||||
question_added: string
|
||||
question_removed: string
|
||||
every_day: string
|
||||
every_n_days: string
|
||||
days: [7]string
|
||||
reminder: string
|
||||
no_reminder: string
|
||||
check: string
|
||||
count: string
|
||||
span: string
|
||||
yes: string
|
||||
no: string
|
||||
longer: string
|
||||
shorter: string
|
||||
later_than_average: string
|
||||
above_average: string
|
||||
earlier_than_average: string
|
||||
below_average: string
|
||||
after: string
|
||||
at_least: string
|
||||
before: string
|
||||
at_most: string
|
||||
between: string
|
||||
and_word: string
|
||||
}
|
||||
|
||||
LumiToolOk :: (result: string) -> bool {
|
||||
at := FieldAt(result, 0, "ok")
|
||||
return at >= 0 && MatchLiteral(result, at, "true")
|
||||
}
|
||||
|
||||
LumiToolText :: (result: string, name: string) -> string {
|
||||
bytes: [256]u8
|
||||
count := ReadStringText(result, FieldAt(result, 0, name), bytes[:])
|
||||
if count <= 0 || count >= 256 {
|
||||
return ""
|
||||
}
|
||||
return LumiOwned(TextFromBytes(bytes[:count]))
|
||||
}
|
||||
|
||||
// Fills %s and %d in a translated template, in order.
|
||||
LumiFill :: (template: string, values: []string) -> string {
|
||||
out: Vec(u8)
|
||||
used: s32 = 0
|
||||
at: s64 = 0
|
||||
while at < template.count {
|
||||
if template[at] == cast(u8)37 && at + 1 < template.count &&
|
||||
(template[at + 1] == cast(u8)115 || template[at + 1] == cast(u8)100) &&
|
||||
used < cast(s32)values.count {
|
||||
BuilderPrint(*out, "%", values[used])
|
||||
used += 1
|
||||
at += 2
|
||||
continue
|
||||
}
|
||||
unused VecPush(out, template[at])
|
||||
at += 1
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
LumiNumberText :: (value: s32) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%", value)
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// A time of day as habits show it: 07:00.
|
||||
LumiDayTimeText :: (minutes: s32) -> string {
|
||||
out: Vec(u8)
|
||||
hour := minutes / 60
|
||||
minute := minutes % 60
|
||||
BuilderPrint(*out, "%", ifx hour < 10 then "0" else "")
|
||||
BuilderPrint(*out, "%:", hour)
|
||||
BuilderPrint(*out, "%", ifx minute < 10 then "0" else "")
|
||||
BuilderPrint(*out, "%", minute)
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
LumiGoalValue :: (plan: LumiHabitPlan, value: s32) -> string {
|
||||
if plan.unit == LUMI_UNIT_NUMBER {
|
||||
return LumiNumberText(value)
|
||||
}
|
||||
if plan.unit == LUMI_UNIT_LENGTH {
|
||||
return LumiClockText(value)
|
||||
}
|
||||
return LumiDayTimeText(value)
|
||||
}
|
||||
|
||||
// A goal in the words the habit editor uses: "At most 8:00", "Before
|
||||
// 07:00", "Above my average".
|
||||
LumiGoalText :: (words: LumiReplyWords, plan: LumiHabitPlan) -> string {
|
||||
time := plan.unit == LUMI_UNIT_TIME || (plan.unit == LUMI_UNIT_ANY && plan.answer == LUMI_ANSWER_TIME)
|
||||
if plan.goal == LUMI_GOAL_YES { return words.yes }
|
||||
if plan.goal == LUMI_GOAL_NO { return words.no }
|
||||
if plan.unit == LUMI_UNIT_LENGTH && plan.goal == LUMI_GOAL_ABOVE {
|
||||
return words.longer
|
||||
}
|
||||
if plan.unit == LUMI_UNIT_LENGTH && plan.goal == LUMI_GOAL_BELOW {
|
||||
return words.shorter
|
||||
}
|
||||
if plan.goal == LUMI_GOAL_ABOVE {
|
||||
return ifx time then words.later_than_average else words.above_average
|
||||
}
|
||||
if plan.goal == LUMI_GOAL_BELOW {
|
||||
return ifx time then words.earlier_than_average else words.below_average
|
||||
}
|
||||
out: Vec(u8)
|
||||
if plan.goal == LUMI_GOAL_AT_LEAST {
|
||||
BuilderPrint(*out, "% ", ifx time then words.after else words.at_least)
|
||||
BuilderPrint(*out, "%", LumiGoalValue(plan, plan.low))
|
||||
} else if plan.goal == LUMI_GOAL_AT_MOST {
|
||||
BuilderPrint(*out, "% ", ifx time then words.before else words.at_most)
|
||||
BuilderPrint(*out, "%", LumiGoalValue(plan, plan.high))
|
||||
} else {
|
||||
BuilderPrint(*out, "% ", words.between)
|
||||
BuilderPrint(*out, "% ", LumiGoalValue(plan, plan.low))
|
||||
BuilderPrint(*out, "% ", words.and_word)
|
||||
BuilderPrint(*out, "%", LumiGoalValue(plan, plan.high))
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
LumiScheduleText :: (words: LumiReplyWords, plan: LumiHabitPlan) -> string {
|
||||
if plan.repeat == LUMI_REPEAT_DAILY || (plan.repeat == LUMI_REPEAT_DAYS && plan.weekdays == 127) {
|
||||
return words.every_day
|
||||
}
|
||||
if plan.repeat == LUMI_REPEAT_EVERY {
|
||||
values: [1]string = .[LumiNumberText(plan.every)]
|
||||
return LumiFill(words.every_n_days, values[:])
|
||||
}
|
||||
out: Vec(u8)
|
||||
first := true
|
||||
for day: cast(s32)0..cast(s32)6 {
|
||||
if (plan.weekdays & (1 << day)) != 0 {
|
||||
BuilderPrint(*out, "%", ifx first then "" else ", ")
|
||||
BuilderPrint(*out, "%", words.days[day])
|
||||
first = false
|
||||
}
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// What Lumi says it did: the habit's name in bold, then one line per change.
|
||||
LumiHabitReply :: (words: LumiReplyWords, plan: LumiHabitPlan, title: string) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "**%**", title)
|
||||
if plan.kind == LUMI_HABIT_CREATE {
|
||||
BuilderPrint(*out, "\n%", words.created)
|
||||
}
|
||||
if plan.kind == LUMI_HABIT_RENAME {
|
||||
values: [2]string = .[title, plan.name]
|
||||
BuilderPrint(*out, "\n%", LumiFill(words.renamed, values[:]))
|
||||
}
|
||||
if plan.kind == LUMI_HABIT_PAUSE {
|
||||
BuilderPrint(*out, "\n%", words.paused)
|
||||
}
|
||||
if plan.kind == LUMI_HABIT_RESUME {
|
||||
BuilderPrint(*out, "\n%", words.resumed)
|
||||
}
|
||||
if plan.kind == LUMI_HABIT_ASK || plan.kind == LUMI_HABIT_UNASK {
|
||||
values: [1]string = .[plan.question]
|
||||
template := ifx plan.kind == LUMI_HABIT_ASK then words.question_added else words.question_removed
|
||||
BuilderPrint(*out, "\n%", LumiFill(template, values[:]))
|
||||
if plan.kind == LUMI_HABIT_ASK && plan.goal != 0 {
|
||||
BuilderPrint(*out, "\n%", LumiGoalText(words, plan))
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
if plan.repeat != 0 {
|
||||
BuilderPrint(*out, "\n%", LumiScheduleText(words, plan))
|
||||
}
|
||||
if plan.reminder == 1 {
|
||||
values: [1]string = .[LumiDayTimeText((plan.hour - 1) * 60)]
|
||||
BuilderPrint(*out, "\n%", LumiFill(words.reminder, values[:]))
|
||||
} else if plan.reminder == 2 {
|
||||
BuilderPrint(*out, "\n%", words.no_reminder)
|
||||
}
|
||||
if plan.mode == LUMI_MODE_CHECK {
|
||||
BuilderPrint(*out, "\n%", words.check)
|
||||
} else if plan.mode == LUMI_MODE_COUNT {
|
||||
values: [1]string = .[LumiNumberText(plan.target)]
|
||||
BuilderPrint(*out, "\n%", LumiFill(words.count, values[:]))
|
||||
} else if plan.mode == LUMI_MODE_SPAN {
|
||||
BuilderPrint(*out, "\n%", words.span)
|
||||
if plan.goal != 0 {
|
||||
BuilderPrint(*out, ": %", LumiGoalText(words, plan))
|
||||
}
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// Adds the paused habits a read_context result lists.
|
||||
LumiPausedHabits :: (context: string, habits: []LumiHabitRef, count: s32) -> s32 {
|
||||
list := FieldAt(context, 0, "paused_habits")
|
||||
total := ArrayCount(context, list)
|
||||
for index: cast(s32)0..total - 1 {
|
||||
if count >= cast(s32)habits.count {
|
||||
break
|
||||
}
|
||||
at := ElementAt(context, list, index)
|
||||
id_bytes: [64]u8
|
||||
title_bytes: [64]u8
|
||||
id_count := ReadStringText(context, FieldAt(context, at, "id"), id_bytes[:])
|
||||
title_count := ReadStringText(context, FieldAt(context, at, "title"), title_bytes[:])
|
||||
if id_count <= 0 || id_count >= 64 || title_count <= 0 || title_count >= 64 {
|
||||
continue
|
||||
}
|
||||
habits[count] = LumiHabitRef.{.id = LumiOwned(TextFromBytes(id_bytes[:id_count])),
|
||||
.title = LumiOwned(TextFromBytes(title_bytes[:title_count])), .paused = true}
|
||||
count += 1
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
LumiIdArguments :: (id: string) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "{\"id\":")
|
||||
LumiJsonText(*out, id)
|
||||
BuilderPrint(*out, "}")
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// The questions a read_habit result lists, as JSON, or "".
|
||||
LumiQuestionsOf :: (result: string) -> string {
|
||||
at := FieldAt(result, 0, "questions")
|
||||
end := ValueEnd(result, at, 0)
|
||||
if !LumiToolOk(result) || at < 0 || end < 0 {
|
||||
return ""
|
||||
}
|
||||
return LumiOwned(result[at:end])
|
||||
}
|
||||
|
||||
LumiReplaceNew :: (arguments: string, id: string) -> string {
|
||||
marker := "\"$new\""
|
||||
out: Vec(u8)
|
||||
at: s64 = 0
|
||||
while at < arguments.count {
|
||||
if at + marker.count <= arguments.count && arguments[at:at + marker.count] == marker {
|
||||
LumiJsonText(*out, id)
|
||||
at += marker.count
|
||||
continue
|
||||
}
|
||||
unused VecPush(out, arguments[at])
|
||||
at += 1
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// The person's answer to "Delete ...? Reply yes or no.": 1 yes, 2 no,
|
||||
// 0 neither, in their language or English.
|
||||
LumiYesNo :: (input: string, active: *LumiCompiled, english: *LumiCompiled) -> s32 {
|
||||
matcher: LumiMatcher
|
||||
matcher.input = LumiTrimText(input)
|
||||
matcher.words = *active.words
|
||||
matcher.english_words = *english.words
|
||||
yes := LumiTaggedAt(*matcher, LUMI_WORD_YES, 0)
|
||||
no := LumiTaggedAt(*matcher, LUMI_WORD_NO, 0)
|
||||
if yes > 0 && LumiSkipTail(matcher.input, yes) == cast(s32)matcher.input.count && yes >= no {
|
||||
return 1
|
||||
}
|
||||
if no > 0 && LumiSkipTail(matcher.input, no) == cast(s32)matcher.input.count {
|
||||
return 2
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,847 @@
|
||||
// Lumi's offline understanding of habit requests: a message is read as one
|
||||
// core template (create, rename, pause, remind, ask, ...) and the clauses
|
||||
// around it (every day, at 8, 3 times a day, at most 8 hours, higher is
|
||||
// better, ...), then turned into the same app tool calls the online model
|
||||
// makes (assets/mcp/tools.json). Anything it cannot read whole is left to
|
||||
// the model, or, offline, answered with what Lumi can do.
|
||||
#import "vec"
|
||||
#import "text"
|
||||
#import "utf8"
|
||||
#import "json_scan"
|
||||
#import "byte_text_linux"
|
||||
#import, file "habit_patterns.zi";
|
||||
|
||||
LUMI_HABIT_CREATE :: 1
|
||||
LUMI_HABIT_UPDATE :: 2
|
||||
LUMI_HABIT_RENAME :: 3
|
||||
LUMI_HABIT_PAUSE :: 4
|
||||
LUMI_HABIT_RESUME :: 5
|
||||
LUMI_HABIT_DELETE :: 6
|
||||
LUMI_HABIT_ASK :: 7
|
||||
LUMI_HABIT_UNASK :: 8
|
||||
// A new habit's name is already a habit's, and nothing else was asked.
|
||||
LUMI_HABIT_EXISTS :: 9
|
||||
|
||||
LUMI_REPEAT_DAILY :: 1
|
||||
LUMI_REPEAT_EVERY :: 2
|
||||
LUMI_REPEAT_DAYS :: 3
|
||||
|
||||
LUMI_MODE_CHECK :: 1
|
||||
LUMI_MODE_COUNT :: 2
|
||||
LUMI_MODE_SPAN :: 3
|
||||
|
||||
LUMI_ANSWER_TEXT :: 1
|
||||
LUMI_ANSWER_NUMBER :: 2
|
||||
LUMI_ANSWER_TIME :: 3
|
||||
LUMI_ANSWER_YES_NO :: 4
|
||||
|
||||
LUMI_GOAL_ABOVE :: 1
|
||||
LUMI_GOAL_BELOW :: 2
|
||||
LUMI_GOAL_AT_LEAST :: 3
|
||||
LUMI_GOAL_AT_MOST :: 4
|
||||
LUMI_GOAL_BETWEEN :: 5
|
||||
LUMI_GOAL_YES :: 6
|
||||
LUMI_GOAL_NO :: 7
|
||||
|
||||
// What a goal's bounds measure.
|
||||
LUMI_UNIT_ANY :: 0
|
||||
LUMI_UNIT_NUMBER :: 1
|
||||
LUMI_UNIT_TIME :: 2
|
||||
LUMI_UNIT_LENGTH :: 3
|
||||
|
||||
LUMI_HABIT_INPUT_MAX :: 240
|
||||
|
||||
LumiLanguage :: struct {
|
||||
patterns: string
|
||||
clauses: string
|
||||
words: string
|
||||
}
|
||||
|
||||
LumiHabitPlan :: struct {
|
||||
kind: s32
|
||||
// The habit in the list the parser was given; -1 none, -2 ambiguous.
|
||||
habit: s32
|
||||
name: string
|
||||
question: string
|
||||
answer: s32
|
||||
repeat: s32
|
||||
every: s32
|
||||
weekdays: s32
|
||||
// 1 at hour, 2 off.
|
||||
reminder: s32
|
||||
// The reminder's hour plus one, so that 0 means none was read.
|
||||
hour: s32
|
||||
mode: s32
|
||||
target: s32
|
||||
goal: s32
|
||||
unit: s32
|
||||
low: s32
|
||||
high: s32
|
||||
clauses: s32
|
||||
}
|
||||
|
||||
LumiToolCall :: struct {
|
||||
name: string
|
||||
arguments: string
|
||||
}
|
||||
|
||||
LUMI_CALLS_MAX :: 6
|
||||
|
||||
LumiCoreKind :: (tag: string) -> s32 {
|
||||
if tag == "create" || tag == "remind_new" { return LUMI_HABIT_CREATE }
|
||||
if tag == "rename" { return LUMI_HABIT_RENAME }
|
||||
if tag == "pause" { return LUMI_HABIT_PAUSE }
|
||||
if tag == "resume" { return LUMI_HABIT_RESUME }
|
||||
if tag == "delete" { return LUMI_HABIT_DELETE }
|
||||
if tag == "ask" { return LUMI_HABIT_ASK }
|
||||
if tag == "unask" { return LUMI_HABIT_UNASK }
|
||||
return LUMI_HABIT_UPDATE
|
||||
}
|
||||
|
||||
LumiHabitFilter :: (tag: string) -> s32 {
|
||||
if tag == "resume" { return LUMI_HABITS_PAUSED }
|
||||
if tag == "rename" || tag == "delete" { return LUMI_HABITS_ANY }
|
||||
return LUMI_HABITS_ACTIVE
|
||||
}
|
||||
|
||||
LumiSetOnce :: (field: *s32, value: s32) -> bool {
|
||||
if field.* != 0 && field.* != value {
|
||||
return false
|
||||
}
|
||||
field.* = value
|
||||
return true
|
||||
}
|
||||
|
||||
LumiSetGoal :: (plan: *LumiHabitPlan, goal: s32, unit: s32, low: s32, high: s32) -> bool {
|
||||
if plan.goal != 0 {
|
||||
return false
|
||||
}
|
||||
plan.goal = goal
|
||||
plan.unit = unit
|
||||
plan.low = low
|
||||
plan.high = high
|
||||
return true
|
||||
}
|
||||
|
||||
LumiOrdered :: (values: [2]s32, count: s32, low: *s32, high: *s32) -> bool {
|
||||
if count != 2 {
|
||||
return false
|
||||
}
|
||||
low.* = ifx values[0] <= values[1] then values[0] else values[1]
|
||||
high.* = ifx values[0] <= values[1] then values[1] else values[0]
|
||||
return true
|
||||
}
|
||||
|
||||
// Applies one clause; false when it contradicts one already read.
|
||||
LumiApplyClause :: (plan: *LumiHabitPlan, tag: string, capture: LumiCapture) -> bool {
|
||||
plan.clauses += 1
|
||||
low: s32 = 0
|
||||
high: s32 = 0
|
||||
if tag == "daily" {
|
||||
return LumiSetOnce(*plan.repeat, LUMI_REPEAT_DAILY)
|
||||
}
|
||||
if tag == "every_other" {
|
||||
return LumiSetOnce(*plan.repeat, LUMI_REPEAT_EVERY) && LumiSetOnce(*plan.every, 2)
|
||||
}
|
||||
if tag == "every" {
|
||||
if capture.number_count != 1 || capture.numbers[0] < 1 || capture.numbers[0] > 999 {
|
||||
return false
|
||||
}
|
||||
if capture.numbers[0] == 1 {
|
||||
return LumiSetOnce(*plan.repeat, LUMI_REPEAT_DAILY)
|
||||
}
|
||||
return LumiSetOnce(*plan.repeat, LUMI_REPEAT_EVERY) && LumiSetOnce(*plan.every, capture.numbers[0])
|
||||
}
|
||||
if tag == "days" || tag == "workdays" || tag == "weekend" {
|
||||
mask := capture.days
|
||||
if tag == "workdays" { mask = 31 }
|
||||
if tag == "weekend" { mask = 96 }
|
||||
if mask == 0 || !LumiSetOnce(*plan.repeat, LUMI_REPEAT_DAYS) {
|
||||
return false
|
||||
}
|
||||
plan.weekdays |= mask
|
||||
return true
|
||||
}
|
||||
if tag == "remind" {
|
||||
if capture.time_count != 1 || capture.times[0] % 60 != 0 {
|
||||
return false
|
||||
}
|
||||
return LumiSetOnce(*plan.reminder, 1) && LumiSetOnce(*plan.hour, capture.times[0] / 60 + 1)
|
||||
}
|
||||
if tag == "no_remind" {
|
||||
return LumiSetOnce(*plan.reminder, 2)
|
||||
}
|
||||
if tag == "count" {
|
||||
if capture.number_count != 1 || capture.numbers[0] < 1 || capture.numbers[0] > 9999 {
|
||||
return false
|
||||
}
|
||||
return LumiSetOnce(*plan.mode, LUMI_MODE_COUNT) && LumiSetOnce(*plan.target, capture.numbers[0])
|
||||
}
|
||||
if tag == "check" {
|
||||
return LumiSetOnce(*plan.mode, LUMI_MODE_CHECK)
|
||||
}
|
||||
if tag == "span" {
|
||||
return LumiSetOnce(*plan.mode, LUMI_MODE_SPAN)
|
||||
}
|
||||
if tag == "length_at_most" && capture.length_count == 1 {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_AT_MOST, LUMI_UNIT_LENGTH, 0, capture.lengths[0])
|
||||
}
|
||||
if tag == "length_at_least" && capture.length_count == 1 {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_AT_LEAST, LUMI_UNIT_LENGTH, capture.lengths[0], 0)
|
||||
}
|
||||
if tag == "length_between" && capture.length_count == 1 && capture.number_count == 1 {
|
||||
// "between 6 and 8 hours": the first number takes the second's unit.
|
||||
lengths: [2]s32 = .[capture.numbers[0] * capture.length_unit, capture.lengths[0]]
|
||||
if LumiOrdered(lengths, 2, *low, *high) && low > 0 {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_BETWEEN, LUMI_UNIT_LENGTH, low, high)
|
||||
}
|
||||
return false
|
||||
}
|
||||
if tag == "length_between" && LumiOrdered(capture.lengths, capture.length_count, *low, *high) {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_BETWEEN, LUMI_UNIT_LENGTH, low, high)
|
||||
}
|
||||
if tag == "shorter" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_BELOW, LUMI_UNIT_LENGTH, 0, 0)
|
||||
}
|
||||
if tag == "longer" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_ABOVE, LUMI_UNIT_LENGTH, 0, 0)
|
||||
}
|
||||
if tag == "higher" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_ABOVE, LUMI_UNIT_ANY, 0, 0)
|
||||
}
|
||||
if tag == "lower" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_BELOW, LUMI_UNIT_ANY, 0, 0)
|
||||
}
|
||||
if tag == "at_least" && capture.number_count == 1 {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_AT_LEAST, LUMI_UNIT_NUMBER, capture.numbers[0], 0)
|
||||
}
|
||||
if tag == "at_most" && capture.number_count == 1 {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_AT_MOST, LUMI_UNIT_NUMBER, 0, capture.numbers[0])
|
||||
}
|
||||
if tag == "between" && LumiOrdered(capture.numbers, capture.number_count, *low, *high) {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_BETWEEN, LUMI_UNIT_NUMBER, low, high)
|
||||
}
|
||||
if tag == "before" && capture.time_count == 1 {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_AT_MOST, LUMI_UNIT_TIME, 0, capture.times[0])
|
||||
}
|
||||
if tag == "after" && capture.time_count == 1 {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_AT_LEAST, LUMI_UNIT_TIME, capture.times[0], 0)
|
||||
}
|
||||
if tag == "between_times" && capture.time_count == 2 {
|
||||
// Between a later and an earlier time spans midnight; keep the order.
|
||||
return LumiSetGoal(plan, LUMI_GOAL_BETWEEN, LUMI_UNIT_TIME, capture.times[0], capture.times[1])
|
||||
}
|
||||
if tag == "earlier" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_BELOW, LUMI_UNIT_TIME, 0, 0)
|
||||
}
|
||||
if tag == "later" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_ABOVE, LUMI_UNIT_TIME, 0, 0)
|
||||
}
|
||||
if tag == "yes_good" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_YES, LUMI_UNIT_ANY, 0, 0)
|
||||
}
|
||||
if tag == "no_good" {
|
||||
return LumiSetGoal(plan, LUMI_GOAL_NO, LUMI_UNIT_ANY, 0, 0)
|
||||
}
|
||||
if tag == "answer_number" { return LumiSetOnce(*plan.answer, LUMI_ANSWER_NUMBER) }
|
||||
if tag == "answer_time" { return LumiSetOnce(*plan.answer, LUMI_ANSWER_TIME) }
|
||||
if tag == "answer_yes_no" { return LumiSetOnce(*plan.answer, LUMI_ANSWER_YES_NO) }
|
||||
if tag == "answer_text" { return LumiSetOnce(*plan.answer, LUMI_ANSWER_TEXT) }
|
||||
return false
|
||||
}
|
||||
|
||||
// A language read once: its templates and words.
|
||||
LumiCompiled :: struct {
|
||||
patterns: LumiTemplates
|
||||
clauses: LumiTemplates
|
||||
words: LumiWords
|
||||
}
|
||||
|
||||
LumiCompileLanguage :: (language: LumiLanguage, compiled: *LumiCompiled) {
|
||||
LumiCompileTemplates(language.patterns, *compiled.patterns)
|
||||
LumiCompileTemplates(language.clauses, *compiled.clauses)
|
||||
LumiCompileWords(language.words, *compiled.words)
|
||||
}
|
||||
|
||||
LumiParser :: struct {
|
||||
matcher: LumiMatcher
|
||||
active: *LumiCompiled
|
||||
english: *LumiCompiled
|
||||
// English is not tried twice when it is the active language.
|
||||
english_extra: bool
|
||||
}
|
||||
|
||||
// The clause of either language that matches all of text, applied to plan.
|
||||
// Returns 1 applied, 0 none matched, -1 a contradiction.
|
||||
LumiClauseMatch :: (parser: *LumiParser, text: string, plan: *LumiHabitPlan) -> s32 {
|
||||
last := ifx parser.english_extra then 1 else 0
|
||||
for source: cast(s32)0..last {
|
||||
clauses := ifx source == 0 then *parser.active.clauses else *parser.english.clauses
|
||||
for index: cast(s32)0..clauses.count - 1 {
|
||||
template := *clauses.items[index]
|
||||
parser.matcher.input = text
|
||||
parser.matcher.habit_filter = LUMI_HABITS_ANY
|
||||
capture: LumiCapture
|
||||
if LumiTemplateMatches(*parser.matcher, template, *capture) {
|
||||
return ifx LumiApplyClause(plan, template.tag, capture) then 1 else -1
|
||||
}
|
||||
if parser.matcher.budget <= 0 {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Whether a word of the tag ends text, as "and" before a stripped clause.
|
||||
LumiEndsWithTagged :: (parser: *LumiParser, text: string, tag: s32) -> s32 {
|
||||
at: s32 = 0
|
||||
while at < cast(s32)text.count {
|
||||
if LumiBoundary(text, at) && !LumiSpaceCode(LumiCodeAt(text, at)) {
|
||||
parser.matcher.input = text
|
||||
end := LumiTaggedAt(*parser.matcher, tag, at)
|
||||
if end >= 0 && LumiSkipTail(text, end) == cast(s32)text.count {
|
||||
return at
|
||||
}
|
||||
}
|
||||
at = Decode(text, at).after
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
LumiTrimJoins :: (parser: *LumiParser, text: string) -> string {
|
||||
rest := LumiTrimText(text)
|
||||
for guard: cast(s32)0..cast(s32)3 {
|
||||
unused guard
|
||||
at := LumiEndsWithTagged(parser, rest, LUMI_WORD_JOIN)
|
||||
if at <= 0 {
|
||||
break
|
||||
}
|
||||
rest = LumiTrimText(rest[:at])
|
||||
}
|
||||
return rest
|
||||
}
|
||||
|
||||
// Peels clauses off the end of text, then, when allowed, off its start.
|
||||
// Returns what is left for a core template, or "" on a contradiction.
|
||||
LumiStripClauses :: (parser: *LumiParser, text: string, from_start: bool, plan: *LumiHabitPlan) -> string {
|
||||
rest := LumiTrimJoins(parser, text)
|
||||
for guard: cast(s32)0..cast(s32)7 {
|
||||
unused guard
|
||||
found := false
|
||||
at: s32 = 0
|
||||
while at < cast(s32)rest.count {
|
||||
at = Decode(rest, at).after
|
||||
if at >= cast(s32)rest.count || !LumiBoundary(rest, at) ||
|
||||
LumiSpaceCode(LumiCodeAt(rest, at)) || LumiPunctuationCode(LumiCodeAt(rest, at)) {
|
||||
continue
|
||||
}
|
||||
matched := LumiClauseMatch(parser, rest[at:], plan)
|
||||
if matched < 0 {
|
||||
return ""
|
||||
}
|
||||
if matched > 0 {
|
||||
rest = LumiTrimJoins(parser, rest[:at])
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !from_start {
|
||||
return rest
|
||||
}
|
||||
for guard: cast(s32)0..cast(s32)7 {
|
||||
unused guard
|
||||
found := false
|
||||
end := cast(s32)rest.count
|
||||
while end > 0 {
|
||||
previous := end - 1
|
||||
while previous > 0 && Continuation(rest[previous]) {
|
||||
previous -= 1
|
||||
}
|
||||
end = previous
|
||||
if end <= 0 || !LumiBoundary(rest, end) {
|
||||
continue
|
||||
}
|
||||
matched := LumiClauseMatch(parser, rest[:end], plan)
|
||||
if matched < 0 {
|
||||
return ""
|
||||
}
|
||||
if matched > 0 {
|
||||
rest = LumiTrimText(rest[end:])
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
break
|
||||
}
|
||||
}
|
||||
return rest
|
||||
}
|
||||
|
||||
// A copy that outlives the message it was read from.
|
||||
LumiOwned :: (text: string) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%", text)
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// A new habit's or question's words as the person typed them, with a
|
||||
// capital first letter.
|
||||
LumiCapitalized :: (text: string) -> string {
|
||||
if text.count == 0 || text[0] < cast(u8)97 || text[0] > cast(u8)122 {
|
||||
return text
|
||||
}
|
||||
out: Vec(u8)
|
||||
unused VecPush(out, text[0] - cast(u8)32)
|
||||
BuilderPrint(*out, "%", text[1:])
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
LumiQuestionText :: (text: string) -> string {
|
||||
words := LumiTrimText(text)
|
||||
if words.count >= 2 && (words[0] == cast(u8)34 || words[0] == cast(u8)39) &&
|
||||
words[words.count - 1] == words[0] {
|
||||
return LumiTrimText(words[1:words.count - 1])
|
||||
}
|
||||
capitalized := LumiCapitalized(words)
|
||||
last := LumiCodeBefore(capitalized, cast(s32)capitalized.count)
|
||||
if last == 63 || last == 65311 {
|
||||
return capitalized
|
||||
}
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%?", capitalized)
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// The answer a question's own words suggest: "how many" a number, "what
|
||||
// time" a time, "did I" yes or no.
|
||||
LumiAnswerFromWords :: (parser: *LumiParser, text: string) -> s32 {
|
||||
parser.matcher.input = text
|
||||
if LumiTaggedAt(*parser.matcher, LUMI_WORD_ASK_NUMBER, 0) > 0 { return LUMI_ANSWER_NUMBER }
|
||||
if LumiTaggedAt(*parser.matcher, LUMI_WORD_ASK_TIME, 0) > 0 { return LUMI_ANSWER_TIME }
|
||||
if LumiTaggedAt(*parser.matcher, LUMI_WORD_ASK_YES_NO, 0) > 0 { return LUMI_ANSWER_YES_NO }
|
||||
return LUMI_ANSWER_TEXT
|
||||
}
|
||||
|
||||
// The habit named exactly like name, active or paused, or -1.
|
||||
LumiHabitNamed :: (habits: []LumiHabitRef, name: string) -> s32 {
|
||||
for index: cast(s32)0..cast(s32)habits.count - 1 {
|
||||
if LumiSamePhrase(LumiLineTrim(habits[index].title), name) &&
|
||||
LumiSamePhrase(name, LumiLineTrim(habits[index].title)) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// Checks that a plan's parts fit together; false sends it to the model.
|
||||
LumiPlanComplete :: (parser: *LumiParser, plan: *LumiHabitPlan, habits: []LumiHabitRef) -> bool {
|
||||
kind := plan.kind
|
||||
if plan.habit == -2 {
|
||||
return true
|
||||
}
|
||||
if kind == LUMI_HABIT_PAUSE || kind == LUMI_HABIT_RESUME || kind == LUMI_HABIT_DELETE ||
|
||||
kind == LUMI_HABIT_RENAME || kind == LUMI_HABIT_UNASK {
|
||||
return plan.clauses == 0
|
||||
}
|
||||
if kind == LUMI_HABIT_CREATE {
|
||||
existing := LumiHabitNamed(habits, plan.name)
|
||||
if existing >= 0 {
|
||||
plan.habit = existing
|
||||
plan.kind = ifx plan.clauses == 0 then LUMI_HABIT_EXISTS else LUMI_HABIT_UPDATE
|
||||
if habits[existing].paused && plan.clauses > 0 {
|
||||
return false
|
||||
}
|
||||
kind = plan.kind
|
||||
}
|
||||
}
|
||||
if kind == LUMI_HABIT_UPDATE && plan.clauses == 0 {
|
||||
return false
|
||||
}
|
||||
if kind == LUMI_HABIT_ASK {
|
||||
// The question's own words decide first, so a goal that does not
|
||||
// fit them sends the request to the model instead.
|
||||
if plan.answer == 0 {
|
||||
plan.answer = LumiAnswerFromWords(parser, plan.question)
|
||||
}
|
||||
if plan.answer == LUMI_ANSWER_TEXT && plan.goal != 0 {
|
||||
if plan.unit == LUMI_UNIT_TIME {
|
||||
plan.answer = LUMI_ANSWER_TIME
|
||||
} else if plan.goal == LUMI_GOAL_YES || plan.goal == LUMI_GOAL_NO {
|
||||
plan.answer = LUMI_ANSWER_YES_NO
|
||||
} else {
|
||||
plan.answer = LUMI_ANSWER_NUMBER
|
||||
}
|
||||
}
|
||||
if plan.unit == LUMI_UNIT_LENGTH || plan.repeat != 0 || plan.reminder != 0 || plan.mode != 0 {
|
||||
return false
|
||||
}
|
||||
if plan.goal != 0 {
|
||||
answer := plan.answer
|
||||
yes_no := plan.goal == LUMI_GOAL_YES || plan.goal == LUMI_GOAL_NO
|
||||
if answer == LUMI_ANSWER_TEXT || (answer == LUMI_ANSWER_YES_NO) != yes_no ||
|
||||
(plan.unit == LUMI_UNIT_NUMBER && answer != LUMI_ANSWER_NUMBER) ||
|
||||
(plan.unit == LUMI_UNIT_TIME && answer != LUMI_ANSWER_TIME) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
plan.question = LumiQuestionText(plan.question)
|
||||
return plan.question.count > 0 && plan.question.count < 96
|
||||
}
|
||||
// A habit's own goal judges its spans.
|
||||
if plan.goal != 0 {
|
||||
if plan.unit != LUMI_UNIT_LENGTH {
|
||||
return false
|
||||
}
|
||||
if plan.mode == 0 {
|
||||
plan.mode = LUMI_MODE_SPAN
|
||||
}
|
||||
if plan.mode != LUMI_MODE_SPAN {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if plan.answer != 0 {
|
||||
return false
|
||||
}
|
||||
return kind != LUMI_HABIT_CREATE || (plan.name.count > 0 && plan.name.count < 40)
|
||||
}
|
||||
|
||||
// The plan the first template of tag that matches makes, or kind 0.
|
||||
LumiCoreMatch :: (parser: *LumiParser, text: string, tag: string, base: LumiHabitPlan,
|
||||
habits: []LumiHabitRef) -> LumiHabitPlan {
|
||||
last := ifx parser.english_extra then 1 else 0
|
||||
for source: cast(s32)0..last {
|
||||
patterns := ifx source == 0 then *parser.active.patterns else *parser.english.patterns
|
||||
for index: cast(s32)0..patterns.count - 1 {
|
||||
template := *patterns.items[index]
|
||||
if template.tag != tag {
|
||||
continue
|
||||
}
|
||||
parser.matcher.input = text
|
||||
parser.matcher.habit_filter = LumiHabitFilter(tag)
|
||||
capture: LumiCapture
|
||||
if !LumiTemplateMatches(*parser.matcher, template, *capture) {
|
||||
continue
|
||||
}
|
||||
candidate := base
|
||||
candidate.kind = LumiCoreKind(tag)
|
||||
candidate.habit = capture.habit
|
||||
candidate.name = LumiOwned(LumiCapitalized(LumiTrimText(text[capture.name_at:capture.name_end])))
|
||||
candidate.question = LumiOwned(LumiTrimText(text[capture.text_at:capture.text_end]))
|
||||
// Templates may hold the time themselves, as "{time}に".
|
||||
if capture.time_count == 1 && !LumiApplyClause(*candidate, "remind", capture) {
|
||||
continue
|
||||
}
|
||||
if tag == "no_remind" && !LumiApplyClause(*candidate, "no_remind", capture) {
|
||||
continue
|
||||
}
|
||||
if (tag == "remind" || tag == "remind_new") && candidate.reminder != 1 {
|
||||
continue
|
||||
}
|
||||
if tag == "remind_new" && candidate.repeat == 0 {
|
||||
candidate.repeat = LUMI_REPEAT_DAILY
|
||||
}
|
||||
if LumiPlanComplete(parser, *candidate, habits) {
|
||||
return candidate
|
||||
}
|
||||
}
|
||||
}
|
||||
return LumiHabitPlan.{.habit = -1}
|
||||
}
|
||||
|
||||
LumiParseWith :: (parser: *LumiParser, text: string, from_start: bool,
|
||||
habits: []LumiHabitRef) -> LumiHabitPlan {
|
||||
plan := LumiHabitPlan.{.habit = -1}
|
||||
rest := LumiStripClauses(parser, text, from_start, *plan)
|
||||
if rest.count == 0 {
|
||||
return LumiHabitPlan.{.habit = -1}
|
||||
}
|
||||
// Templates naming an existing habit come before those creating one.
|
||||
tags: [11]string = .["rename", "pause", "resume", "delete", "unask", "ask", "no_remind",
|
||||
"remind", "update", "create", "remind_new"]
|
||||
for tag: tags {
|
||||
matched := LumiCoreMatch(parser, rest, tag, plan, habits)
|
||||
if matched.kind != 0 {
|
||||
return matched
|
||||
}
|
||||
if parser.matcher.budget <= 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return LumiHabitPlan.{.habit = -1}
|
||||
}
|
||||
|
||||
// Reads a habit request with languages already read. A plan of kind 0 is
|
||||
// not one Lumi understands. english may be active itself.
|
||||
LumiHabitParseCompiled :: (input: string, active: *LumiCompiled, english: *LumiCompiled,
|
||||
habits: []LumiHabitRef) -> LumiHabitPlan {
|
||||
text := LumiTrimText(input)
|
||||
if text.count == 0 || text.count > LUMI_HABIT_INPUT_MAX {
|
||||
return LumiHabitPlan.{.habit = -1}
|
||||
}
|
||||
parser: LumiParser
|
||||
parser.active = active
|
||||
parser.english = english
|
||||
parser.english_extra = english != active
|
||||
parser.matcher.words = *active.words
|
||||
parser.matcher.english_words = *english.words
|
||||
parser.matcher.habits = habits
|
||||
parser.matcher.budget = LUMI_PARSE_BUDGET
|
||||
// Clauses may also lead, as in Japanese "毎日8時に読書の習慣を追加".
|
||||
// The reading that understands more of the message wins.
|
||||
plan := LumiParseWith(*parser, text, false, habits)
|
||||
if parser.matcher.budget > 0 {
|
||||
leading := LumiParseWith(*parser, text, true, habits)
|
||||
if leading.kind != 0 && (plan.kind == 0 || leading.clauses > plan.clauses) {
|
||||
plan = leading
|
||||
}
|
||||
}
|
||||
lumi_parse_steps = LUMI_PARSE_BUDGET - parser.matcher.budget
|
||||
return plan
|
||||
}
|
||||
|
||||
// The matcher steps a message may take, and those the last one took.
|
||||
LUMI_PARSE_BUDGET :: 40000
|
||||
lumi_parse_steps: s32;
|
||||
|
||||
lumi_parse_active: LumiCompiled;
|
||||
lumi_parse_english: LumiCompiled;
|
||||
|
||||
// Reads a habit request in a language given as its locale text.
|
||||
LumiHabitParse :: (input: string, active: LumiLanguage, english: LumiLanguage,
|
||||
habits: []LumiHabitRef) -> LumiHabitPlan {
|
||||
LumiCompileLanguage(active, *lumi_parse_active)
|
||||
if english.patterns == active.patterns {
|
||||
return LumiHabitParseCompiled(input, *lumi_parse_active, *lumi_parse_active, habits)
|
||||
}
|
||||
LumiCompileLanguage(english, *lumi_parse_english)
|
||||
return LumiHabitParseCompiled(input, *lumi_parse_active, *lumi_parse_english, habits)
|
||||
}
|
||||
|
||||
LumiJsonText :: (out: *Vec(u8), value: string) {
|
||||
BuilderPrint(out, "\"")
|
||||
for byte: value {
|
||||
if byte == cast(u8)34 || byte == cast(u8)92 {
|
||||
unused VecPush(out.*, cast(u8)92)
|
||||
unused VecPush(out.*, byte)
|
||||
} else if byte == cast(u8)10 {
|
||||
BuilderPrint(out, "\\n")
|
||||
} else if byte >= cast(u8)32 {
|
||||
unused VecPush(out.*, byte)
|
||||
}
|
||||
}
|
||||
BuilderPrint(out, "\"")
|
||||
}
|
||||
|
||||
// A clock time as the tools write it: 7:00, 19:30.
|
||||
LumiClockText :: (minutes: s32) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%:", minutes / 60)
|
||||
BuilderPrint(*out, "%", ifx minutes % 60 < 10 then "0" else "")
|
||||
BuilderPrint(*out, "%", minutes % 60)
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
LumiGoalName :: (goal: s32) -> string {
|
||||
names: [8]string = .["none", "above_average", "below_average", "at_least", "at_most",
|
||||
"between", "yes", "no"]
|
||||
return names[goal]
|
||||
}
|
||||
|
||||
LumiGoalBound :: (out: *Vec(u8), name: string, value: s32, unit: s32) {
|
||||
BuilderPrint(out, ",\"%\":", name)
|
||||
if unit == LUMI_UNIT_NUMBER {
|
||||
BuilderPrint(out, "%", value)
|
||||
} else {
|
||||
LumiJsonText(out, LumiClockText(value))
|
||||
}
|
||||
}
|
||||
|
||||
LumiGoalFields :: (out: *Vec(u8), plan: LumiHabitPlan) {
|
||||
if plan.goal == 0 {
|
||||
return
|
||||
}
|
||||
BuilderPrint(out, ",\"good\":\"%\"", LumiGoalName(plan.goal))
|
||||
if plan.goal == LUMI_GOAL_AT_LEAST || plan.goal == LUMI_GOAL_BETWEEN {
|
||||
LumiGoalBound(out, "low", plan.low, plan.unit)
|
||||
}
|
||||
if plan.goal == LUMI_GOAL_AT_MOST || plan.goal == LUMI_GOAL_BETWEEN {
|
||||
LumiGoalBound(out, "high", plan.high, plan.unit)
|
||||
}
|
||||
}
|
||||
|
||||
LumiCallStart :: (out: *Vec(u8), id: string) {
|
||||
BuilderPrint(out, "{\"id\":")
|
||||
LumiJsonText(out, id)
|
||||
}
|
||||
|
||||
LumiAnswerName :: (answer: s32) -> string {
|
||||
names: [5]string = .["text", "text", "number", "time", "yes_no"]
|
||||
return names[answer]
|
||||
}
|
||||
|
||||
// The same question, ignoring case and a final question mark.
|
||||
LumiSameQuestion :: (left: string, right: string) -> bool {
|
||||
a := LumiTrimText(left)
|
||||
b := LumiTrimText(right)
|
||||
return a.count > 0 && LumiSamePhrase(a, b) && LumiSamePhrase(b, a)
|
||||
}
|
||||
|
||||
// The questions a habit keeps, changed by the plan: the existing JSON items
|
||||
// verbatim, with the asked one replaced or added, or the named one removed.
|
||||
// Returns "" when there is nothing to change or no room.
|
||||
LumiQuestionList :: (plan: LumiHabitPlan, existing: string) -> string {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "[")
|
||||
count: s32 = 0
|
||||
replaced := false
|
||||
removed := false
|
||||
list := ArrayCount(existing, 0)
|
||||
for index: cast(s32)0..list - 1 {
|
||||
at := ElementAt(existing, 0, index)
|
||||
end := ValueEnd(existing, at, 0)
|
||||
if at < 0 || end < 0 {
|
||||
return ""
|
||||
}
|
||||
words: [96]u8
|
||||
length := ReadStringText(existing, FieldAt(existing, at, "text"), words[:])
|
||||
same := length > 0 && length < 96 &&
|
||||
LumiSameQuestion(TextFromBytes(words[:length]), plan.question)
|
||||
if same && plan.kind == LUMI_HABIT_UNASK {
|
||||
removed = true
|
||||
continue
|
||||
}
|
||||
if same && plan.kind == LUMI_HABIT_ASK {
|
||||
replaced = true
|
||||
BuilderPrint(*out, "%", ifx count == 0 then "" else ",")
|
||||
LumiQuestionItem(*out, plan, TextFromBytes(words[:length]))
|
||||
count += 1
|
||||
continue
|
||||
}
|
||||
BuilderPrint(*out, "%", ifx count == 0 then "" else ",")
|
||||
BuilderPrint(*out, "%", existing[at:end])
|
||||
count += 1
|
||||
}
|
||||
if plan.kind == LUMI_HABIT_UNASK && !removed {
|
||||
return ""
|
||||
}
|
||||
if plan.kind == LUMI_HABIT_ASK && !replaced {
|
||||
if count >= 8 {
|
||||
return ""
|
||||
}
|
||||
BuilderPrint(*out, "%", ifx count == 0 then "" else ",")
|
||||
LumiQuestionItem(*out, plan, plan.question)
|
||||
}
|
||||
BuilderPrint(*out, "]")
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
LumiQuestionItem :: (out: *Vec(u8), plan: LumiHabitPlan, text: string) {
|
||||
BuilderPrint(out, "{\"text\":")
|
||||
LumiJsonText(out, text)
|
||||
BuilderPrint(out, ",\"answer\":\"%\"", LumiAnswerName(plan.answer))
|
||||
goal := plan
|
||||
if goal.unit == LUMI_UNIT_ANY && goal.answer == LUMI_ANSWER_TIME {
|
||||
goal.unit = LUMI_UNIT_TIME
|
||||
}
|
||||
LumiGoalFields(out, goal)
|
||||
BuilderPrint(out, "}")
|
||||
}
|
||||
|
||||
// The tool calls a plan makes, in order. "$new" stands for the id the
|
||||
// first call, create_habit, returns. questions holds the habit's current
|
||||
// questions (read_habit) for ask and unask. Returns how many, 0 for none.
|
||||
LumiHabitCalls :: (plan: LumiHabitPlan, habits: []LumiHabitRef, questions: string,
|
||||
calls: []LumiToolCall) -> s32 {
|
||||
count: s32 = 0
|
||||
id := "$new"
|
||||
if plan.habit >= 0 && plan.habit < cast(s32)habits.count {
|
||||
id = habits[plan.habit].id
|
||||
}
|
||||
kind := plan.kind
|
||||
if kind == LUMI_HABIT_CREATE {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "{\"name\":")
|
||||
LumiJsonText(*out, plan.name)
|
||||
BuilderPrint(*out, "}")
|
||||
calls[count] = LumiToolCall.{.name = "create_habit", .arguments = BuilderFinish(out)}
|
||||
count += 1
|
||||
} else if plan.habit < 0 {
|
||||
return 0
|
||||
}
|
||||
if kind == LUMI_HABIT_RENAME || kind == LUMI_HABIT_PAUSE || kind == LUMI_HABIT_RESUME ||
|
||||
kind == LUMI_HABIT_DELETE {
|
||||
out: Vec(u8)
|
||||
LumiCallStart(*out, id)
|
||||
name := "delete_habit"
|
||||
if kind == LUMI_HABIT_RENAME {
|
||||
name = "rename_habit"
|
||||
BuilderPrint(*out, ",\"name\":")
|
||||
LumiJsonText(*out, plan.name)
|
||||
} else if kind != LUMI_HABIT_DELETE {
|
||||
name = "set_habit_active"
|
||||
BuilderPrint(*out, ",\"active\":%", kind == LUMI_HABIT_RESUME)
|
||||
}
|
||||
BuilderPrint(*out, "}")
|
||||
calls[count] = LumiToolCall.{.name = name, .arguments = BuilderFinish(out)}
|
||||
return count + 1
|
||||
}
|
||||
if kind == LUMI_HABIT_ASK || kind == LUMI_HABIT_UNASK {
|
||||
list := LumiQuestionList(plan, questions)
|
||||
if list.count == 0 {
|
||||
return 0
|
||||
}
|
||||
out: Vec(u8)
|
||||
LumiCallStart(*out, id)
|
||||
BuilderPrint(*out, ",\"questions\":%}", list)
|
||||
calls[count] = LumiToolCall.{.name = "set_habit_questions", .arguments = BuilderFinish(out)}
|
||||
return count + 1
|
||||
}
|
||||
if plan.repeat != 0 || plan.reminder != 0 {
|
||||
out: Vec(u8)
|
||||
LumiCallStart(*out, id)
|
||||
if plan.repeat == LUMI_REPEAT_DAILY {
|
||||
BuilderPrint(*out, ",\"repeat\":\"daily\"")
|
||||
} else if plan.repeat == LUMI_REPEAT_EVERY {
|
||||
BuilderPrint(*out, ",\"repeat\":\"daily\",\"every\":%", plan.every)
|
||||
} else if plan.repeat == LUMI_REPEAT_DAYS {
|
||||
BuilderPrint(*out, ",\"repeat\":\"weekly\",\"weekdays\":[")
|
||||
names: [7]string = .["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
|
||||
first := true
|
||||
for day: cast(s32)0..cast(s32)6 {
|
||||
if (plan.weekdays & (1 << day)) != 0 {
|
||||
BuilderPrint(*out, "%\"%\"", ifx first then "" else ",", names[day])
|
||||
first = false
|
||||
}
|
||||
}
|
||||
BuilderPrint(*out, "]")
|
||||
}
|
||||
if plan.reminder == 1 {
|
||||
BuilderPrint(*out, ",\"notification\":true,\"notification_hour\":%", plan.hour - 1)
|
||||
} else if plan.reminder == 2 {
|
||||
BuilderPrint(*out, ",\"notification\":false")
|
||||
}
|
||||
BuilderPrint(*out, "}")
|
||||
calls[count] = LumiToolCall.{.name = "set_habit_schedule", .arguments = BuilderFinish(out)}
|
||||
count += 1
|
||||
}
|
||||
if plan.mode != 0 {
|
||||
modes: [4]string = .["", "check", "count", "span"]
|
||||
out: Vec(u8)
|
||||
LumiCallStart(*out, id)
|
||||
BuilderPrint(*out, ",\"mode\":\"%\"", modes[plan.mode])
|
||||
if plan.mode == LUMI_MODE_COUNT {
|
||||
BuilderPrint(*out, ",\"target\":%", plan.target)
|
||||
}
|
||||
LumiGoalFields(*out, plan)
|
||||
BuilderPrint(*out, "}")
|
||||
calls[count] = LumiToolCall.{.name = "set_habit_tracking", .arguments = BuilderFinish(out)}
|
||||
count += 1
|
||||
}
|
||||
return count
|
||||
}
|
||||
@@ -0,0 +1,965 @@
|
||||
// Matches the translated templates Lumi understands habits with, on the
|
||||
// device and without a model. A template is a line of words and slots:
|
||||
//
|
||||
// create: add a/the habit {name}
|
||||
// remind: [and] remind me at {time}
|
||||
//
|
||||
// Words fold case and, when they are ASCII words of four or more letters,
|
||||
// accept one typo. "a/the" accepts either word, [ ] makes words optional.
|
||||
// Slots: {habit} an existing habit, {name} and {text} free words, {n} a
|
||||
// whole number, {time} a clock time, {length} a duration with its unit,
|
||||
// {days} weekday names. Words need boundaries only between letters of
|
||||
// alphabets written with spaces, so Japanese, Chinese and Korean templates
|
||||
// need no spaces. Matching is bounded; it never runs code from a template.
|
||||
#import "utf8"
|
||||
#import "vec"
|
||||
#import "text"
|
||||
#import, file "command_text.zi";
|
||||
|
||||
LUMI_TOKEN_WORDS :: 0
|
||||
LUMI_TOKEN_SLOT :: 1
|
||||
LUMI_TOKEN_OPEN :: 2
|
||||
LUMI_TOKEN_CLOSE :: 3
|
||||
LUMI_TOKEN_MAX :: 24
|
||||
|
||||
LUMI_SLOT_HABIT :: 1
|
||||
LUMI_SLOT_NAME :: 2
|
||||
LUMI_SLOT_TEXT :: 3
|
||||
LUMI_SLOT_NUMBER :: 4
|
||||
LUMI_SLOT_TIME :: 5
|
||||
LUMI_SLOT_LENGTH :: 6
|
||||
LUMI_SLOT_DAYS :: 7
|
||||
|
||||
// Which habits {habit} may name.
|
||||
LUMI_HABITS_ACTIVE :: 0
|
||||
LUMI_HABITS_PAUSED :: 1
|
||||
LUMI_HABITS_ANY :: 2
|
||||
|
||||
// Habit candidates one {habit} slot considers at a position.
|
||||
LUMI_HABIT_CANDIDATES :: 8
|
||||
|
||||
LumiToken :: struct {
|
||||
kind: s32
|
||||
slot: s32
|
||||
text: string
|
||||
}
|
||||
|
||||
LumiHabitRef :: struct {
|
||||
id: string
|
||||
title: string
|
||||
paused: bool
|
||||
}
|
||||
|
||||
// What a template's slots read. A habit of -2 means several habits match.
|
||||
// Free words are kept as byte ranges of the matched input.
|
||||
LumiCapture :: struct {
|
||||
habit: s32
|
||||
name_at: s32
|
||||
name_end: s32
|
||||
text_at: s32
|
||||
text_end: s32
|
||||
numbers: [2]s32
|
||||
number_count: s32
|
||||
// Minutes since midnight.
|
||||
times: [2]s32
|
||||
time_count: s32
|
||||
// Minutes, and the unit the last one was written in: 60 for hours, 1
|
||||
// for minutes, so "between 6 and 8 hours" reads 6 as hours too.
|
||||
lengths: [2]s32
|
||||
length_count: s32
|
||||
length_unit: s32
|
||||
days: s32
|
||||
}
|
||||
|
||||
// The words a language uses beside its templates, read from its
|
||||
// "tag: a | b" lines once per language: weekdays, numbers, units and the
|
||||
// words of answers.
|
||||
LUMI_WORD_MON :: 0
|
||||
LUMI_WORD_AND :: 7
|
||||
LUMI_WORD_JOIN :: 8
|
||||
// One to ten follow in order.
|
||||
LUMI_WORD_ONE :: 9
|
||||
LUMI_WORD_AM :: 19
|
||||
LUMI_WORD_PM :: 20
|
||||
LUMI_WORD_OCLOCK :: 21
|
||||
LUMI_WORD_HOURS :: 22
|
||||
LUMI_WORD_MINUTES :: 23
|
||||
LUMI_WORD_ASK_NUMBER :: 24
|
||||
LUMI_WORD_ASK_TIME :: 25
|
||||
LUMI_WORD_ASK_YES_NO :: 26
|
||||
LUMI_WORD_YES :: 27
|
||||
LUMI_WORD_NO :: 28
|
||||
LUMI_WORD_TAGS :: 29
|
||||
LUMI_WORD_ALTERNATIVES :: 12
|
||||
|
||||
LumiWords :: struct {
|
||||
phrases: [LUMI_WORD_TAGS * LUMI_WORD_ALTERNATIVES]string
|
||||
counts: [LUMI_WORD_TAGS]s32
|
||||
}
|
||||
|
||||
LumiWordTag :: (tag: string) -> s32 {
|
||||
names: [LUMI_WORD_TAGS]string = .["mon", "tue", "wed", "thu", "fri", "sat", "sun", "and", "join",
|
||||
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "am", "pm", "oclock", "hours", "minutes",
|
||||
"ask_number", "ask_time", "ask_yes_no", "yes", "no"]
|
||||
for index: cast(s32)0..LUMI_WORD_TAGS - 1 {
|
||||
if names[index] == tag {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// A template, read once into words and slots.
|
||||
LumiTemplate :: struct {
|
||||
tag: string
|
||||
tokens: [LUMI_TOKEN_MAX]LumiToken
|
||||
count: s32
|
||||
}
|
||||
|
||||
LUMI_TEMPLATES_MAX :: 128
|
||||
|
||||
LumiTemplates :: struct {
|
||||
items: [LUMI_TEMPLATES_MAX]LumiTemplate
|
||||
count: s32
|
||||
}
|
||||
|
||||
LumiMatcher :: struct {
|
||||
input: string
|
||||
words: *LumiWords
|
||||
english_words: *LumiWords
|
||||
habits: []LumiHabitRef
|
||||
habit_filter: s32
|
||||
budget: s32
|
||||
}
|
||||
|
||||
LumiNewCapture :: () -> LumiCapture {
|
||||
return LumiCapture.{.habit = -1}
|
||||
}
|
||||
|
||||
LumiFoldCode :: (codepoint: u32) -> u32 {
|
||||
// A typed apostrophe matches the typographic one translations use.
|
||||
if codepoint == cast(u32)8217 || codepoint == cast(u32)700 {
|
||||
return cast(u32)39
|
||||
}
|
||||
return CommandFold(codepoint)
|
||||
}
|
||||
|
||||
// Letters and digits of alphabets written with spaces between words.
|
||||
LumiWordCode :: (codepoint: u32) -> bool {
|
||||
return (codepoint >= 48 && codepoint <= 57) || (codepoint >= 65 && codepoint <= 90) ||
|
||||
(codepoint >= 97 && codepoint <= 122) || codepoint == 39 || codepoint == 8217 ||
|
||||
(codepoint >= 192 && codepoint <= 591 && codepoint != 215 && codepoint != 247) ||
|
||||
(codepoint >= 880 && codepoint <= 1327)
|
||||
}
|
||||
|
||||
LumiSpaceCode :: (codepoint: u32) -> bool {
|
||||
return codepoint == 32 || codepoint == 9 || codepoint == 10 || codepoint == 13 ||
|
||||
codepoint == 160 || codepoint == 12288
|
||||
}
|
||||
|
||||
// Punctuation that may end a request or separate its parts.
|
||||
LumiPunctuationCode :: (codepoint: u32) -> bool {
|
||||
return codepoint == 44 || codepoint == 46 || codepoint == 33 || codepoint == 63 ||
|
||||
codepoint == 59 || codepoint == 12290 || codepoint == 12289 || codepoint == 65281 ||
|
||||
codepoint == 65311 || codepoint == 65292 || codepoint == 65307
|
||||
}
|
||||
|
||||
LumiCodeAt :: (text: string, at: s32) -> u32 {
|
||||
if at < 0 || at >= cast(s32)text.count {
|
||||
return cast(u32)0
|
||||
}
|
||||
return Decode(text, at).value
|
||||
}
|
||||
|
||||
// The codepoint before at, or 0 at the start.
|
||||
LumiCodeBefore :: (text: string, at: s32) -> u32 {
|
||||
if at <= 0 || at > cast(s32)text.count {
|
||||
return cast(u32)0
|
||||
}
|
||||
start := at - 1
|
||||
while start > 0 && Continuation(text[start]) {
|
||||
start -= 1
|
||||
}
|
||||
return Decode(text, start).value
|
||||
}
|
||||
|
||||
// No word continues across this position.
|
||||
LumiBoundary :: (text: string, at: s32) -> bool {
|
||||
return !LumiWordCode(LumiCodeBefore(text, at)) || !LumiWordCode(LumiCodeAt(text, at))
|
||||
}
|
||||
|
||||
// Spaces and commas between a template's words: "the shorter, the better".
|
||||
LumiSkipGap :: (text: string, at: s32) -> s32 {
|
||||
while at < cast(s32)text.count {
|
||||
decoded := Decode(text, at)
|
||||
if !LumiSpaceCode(decoded.value) && decoded.value != 44 && decoded.value != 12289 &&
|
||||
decoded.value != 65292 {
|
||||
return at
|
||||
}
|
||||
at = decoded.after
|
||||
}
|
||||
return at
|
||||
}
|
||||
|
||||
LumiSkipSpace :: (text: string, at: s32) -> s32 {
|
||||
while at < cast(s32)text.count {
|
||||
decoded := Decode(text, at)
|
||||
if !LumiSpaceCode(decoded.value) {
|
||||
return at
|
||||
}
|
||||
at = decoded.after
|
||||
}
|
||||
return at
|
||||
}
|
||||
|
||||
// Spaces and punctuation that may end a request.
|
||||
LumiSkipTail :: (text: string, at: s32) -> s32 {
|
||||
while at < cast(s32)text.count {
|
||||
decoded := Decode(text, at)
|
||||
if !LumiSpaceCode(decoded.value) && !LumiPunctuationCode(decoded.value) {
|
||||
return at
|
||||
}
|
||||
at = decoded.after
|
||||
}
|
||||
return at
|
||||
}
|
||||
|
||||
LumiTrimText :: (text: string) -> string {
|
||||
start: s32 = 0
|
||||
while start < cast(s32)text.count {
|
||||
decoded := Decode(text, start)
|
||||
if !LumiSpaceCode(decoded.value) && !LumiPunctuationCode(decoded.value) {
|
||||
break
|
||||
}
|
||||
start = decoded.after
|
||||
}
|
||||
end := cast(s32)text.count
|
||||
while end > start {
|
||||
previous := end - 1
|
||||
while previous > start && Continuation(text[previous]) {
|
||||
previous -= 1
|
||||
}
|
||||
code := Decode(text, previous).value
|
||||
if !LumiSpaceCode(code) && !LumiPunctuationCode(code) {
|
||||
break
|
||||
}
|
||||
end = previous
|
||||
}
|
||||
return text[start:end]
|
||||
}
|
||||
|
||||
// The end of one word or phrase at at, case folded, or -1. Spaces in the
|
||||
// phrase match one or more spaces.
|
||||
LumiPhraseAt :: (text: string, at: s32, phrase: string) -> s32 {
|
||||
return LumiPhraseFrom(text, at, phrase, true)
|
||||
}
|
||||
|
||||
// A unit may follow its number without a space, as in 16h.
|
||||
LumiPhraseFrom :: (text: string, at: s32, phrase: string, word_start: bool) -> s32 {
|
||||
if phrase.count == 0 || at < 0 {
|
||||
return -1
|
||||
}
|
||||
a := at
|
||||
b: s32 = 0
|
||||
while b < cast(s32)phrase.count {
|
||||
y := Decode(phrase, b)
|
||||
if LumiSpaceCode(y.value) {
|
||||
if a >= cast(s32)text.count || !LumiSpaceCode(LumiCodeAt(text, a)) {
|
||||
return -1
|
||||
}
|
||||
a = LumiSkipSpace(text, a)
|
||||
b = LumiSkipSpace(phrase, b)
|
||||
continue
|
||||
}
|
||||
if a >= cast(s32)text.count {
|
||||
return -1
|
||||
}
|
||||
x := Decode(text, a)
|
||||
if LumiFoldCode(x.value) != LumiFoldCode(y.value) {
|
||||
return -1
|
||||
}
|
||||
a = x.after
|
||||
b = y.after
|
||||
}
|
||||
if !LumiBoundary(text, a) || (word_start && !LumiBoundary(text, at)) {
|
||||
return -1
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
LumiAsciiWord :: (word: string) -> bool {
|
||||
if word.count < 4 {
|
||||
return false
|
||||
}
|
||||
for byte: word {
|
||||
if !((byte >= 97 && byte <= 122) || (byte >= 65 && byte <= 90)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// The end of the word at at.
|
||||
LumiWordEnd :: (text: string, at: s32) -> s32 {
|
||||
end := at
|
||||
while end < cast(s32)text.count {
|
||||
decoded := Decode(text, end)
|
||||
if !LumiWordCode(decoded.value) {
|
||||
break
|
||||
}
|
||||
end = decoded.after
|
||||
}
|
||||
return end
|
||||
}
|
||||
|
||||
// One alternative of a template word, allowing a typo in longer words.
|
||||
LumiWordAt :: (text: string, at: s32, word: string) -> s32 {
|
||||
end := LumiPhraseAt(text, at, word)
|
||||
if end >= 0 {
|
||||
return end
|
||||
}
|
||||
if !LumiAsciiWord(word) || !LumiBoundary(text, at) {
|
||||
return -1
|
||||
}
|
||||
word_end := LumiWordEnd(text, at)
|
||||
if word_end > at && CommandTypo(text[at:word_end], word) {
|
||||
return word_end
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// A template word with "/" alternatives: the longest that matches.
|
||||
LumiWordsAt :: (text: string, at: s32, words: string) -> s32 {
|
||||
best: s32 = -1
|
||||
start: s32 = 0
|
||||
while start <= cast(s32)words.count {
|
||||
end := start
|
||||
while end < cast(s32)words.count && words[end] != cast(u8)47 {
|
||||
end += 1
|
||||
}
|
||||
if end > start {
|
||||
matched := LumiWordAt(text, at, words[start:end])
|
||||
if matched > best {
|
||||
best = matched
|
||||
}
|
||||
}
|
||||
start = end + 1
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
// The tag of a "tag: body" line, and its body.
|
||||
LumiLine :: struct {
|
||||
tag: string
|
||||
body: string
|
||||
}
|
||||
|
||||
LumiLineAt :: (text: string, start: s32) -> LumiLine {
|
||||
end := start
|
||||
while end < cast(s32)text.count && text[end] != cast(u8)10 {
|
||||
end += 1
|
||||
}
|
||||
line := text[start:end]
|
||||
colon: s32 = 0
|
||||
while colon < cast(s32)line.count && line[colon] != cast(u8)58 {
|
||||
colon += 1
|
||||
}
|
||||
if colon >= cast(s32)line.count {
|
||||
return LumiLine.{.body = LumiLineTrim(line)}
|
||||
}
|
||||
return LumiLine.{.tag = LumiLineTrim(line[:colon]), .body = LumiLineTrim(line[colon + 1:])}
|
||||
}
|
||||
|
||||
LumiNextLine :: (text: string, start: s32) -> s32 {
|
||||
end := start
|
||||
while end < cast(s32)text.count && text[end] != cast(u8)10 {
|
||||
end += 1
|
||||
}
|
||||
return end + 1
|
||||
}
|
||||
|
||||
LumiLineTrim :: (value: string) -> string {
|
||||
start: s64 = 0
|
||||
end := value.count
|
||||
while start < end && CommandSpace(value[start]) {
|
||||
start += 1
|
||||
}
|
||||
while end > start && CommandSpace(value[end - 1]) {
|
||||
end -= 1
|
||||
}
|
||||
return value[start:end]
|
||||
}
|
||||
|
||||
// Reads a language's "tag: a | b" word lines.
|
||||
LumiCompileWords :: (text: string, words: *LumiWords) {
|
||||
words.* = LumiWords.{}
|
||||
start: s32 = 0
|
||||
while start < cast(s32)text.count {
|
||||
line := LumiLineAt(text, start)
|
||||
start = LumiNextLine(text, start)
|
||||
tag := LumiWordTag(line.tag)
|
||||
if tag < 0 {
|
||||
continue
|
||||
}
|
||||
from: s32 = 0
|
||||
while from <= cast(s32)line.body.count {
|
||||
to := from
|
||||
while to < cast(s32)line.body.count && line.body[to] != cast(u8)124 {
|
||||
to += 1
|
||||
}
|
||||
alternative := LumiLineTrim(line.body[from:to])
|
||||
if alternative.count > 0 && words.counts[tag] < LUMI_WORD_ALTERNATIVES {
|
||||
words.phrases[tag * LUMI_WORD_ALTERNATIVES + words.counts[tag]] = alternative
|
||||
words.counts[tag] += 1
|
||||
}
|
||||
from = to + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reads a language's "tag: template" lines.
|
||||
LumiCompileTemplates :: (text: string, templates: *LumiTemplates) {
|
||||
templates.count = 0
|
||||
start: s32 = 0
|
||||
while start < cast(s32)text.count && templates.count < LUMI_TEMPLATES_MAX {
|
||||
line := LumiLineAt(text, start)
|
||||
start = LumiNextLine(text, start)
|
||||
if line.tag.count == 0 || line.body.count == 0 {
|
||||
continue
|
||||
}
|
||||
template := *templates.items[templates.count]
|
||||
template.tag = line.tag
|
||||
template.count = LumiTokens(line.body, template.tokens[:])
|
||||
if template.count > 0 {
|
||||
templates.count += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The longest alternative of a tag in one words list at at.
|
||||
LumiTaggedFrom :: (words: *LumiWords, tag: s32, text: string, at: s32, word_start: bool) -> s32 {
|
||||
best: s32 = -1
|
||||
if words == null || tag < 0 || tag >= LUMI_WORD_TAGS {
|
||||
return best
|
||||
}
|
||||
for index: cast(s32)0..words.counts[tag] - 1 {
|
||||
matched := LumiPhraseFrom(text, at, words.phrases[tag * LUMI_WORD_ALTERNATIVES + index], word_start)
|
||||
if matched > best {
|
||||
best = matched
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
LumiTaggedEither :: (matcher: *LumiMatcher, tag: s32, at: s32, word_start: bool) -> s32 {
|
||||
active := LumiTaggedFrom(matcher.words, tag, matcher.input, at, word_start)
|
||||
if matcher.english_words == matcher.words {
|
||||
return active
|
||||
}
|
||||
english := LumiTaggedFrom(matcher.english_words, tag, matcher.input, at, word_start)
|
||||
return ifx english > active then english else active
|
||||
}
|
||||
|
||||
// A unit of the language or of English, which may follow its number
|
||||
// without a space, as in 9pm or 16h.
|
||||
LumiUnitAt :: (matcher: *LumiMatcher, tag: s32, at: s32) -> s32 {
|
||||
return LumiTaggedEither(matcher, tag, at, false)
|
||||
}
|
||||
|
||||
// A tagged word of the language or of English.
|
||||
LumiTaggedAt :: (matcher: *LumiMatcher, tag: s32, at: s32) -> s32 {
|
||||
return LumiTaggedEither(matcher, tag, at, true)
|
||||
}
|
||||
|
||||
LumiDigitsAt :: (text: string, at: s32, most: s32) -> s32 {
|
||||
end := at
|
||||
while end < cast(s32)text.count && end - at < most && text[end] >= cast(u8)48 &&
|
||||
text[end] <= cast(u8)57 {
|
||||
end += 1
|
||||
}
|
||||
return end
|
||||
}
|
||||
|
||||
LumiDigitsValue :: (text: string) -> s32 {
|
||||
value: s32 = 0
|
||||
for byte: text {
|
||||
value = value * 10 + cast(s32)(byte - cast(u8)48)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
LumiNumberAt :: (matcher: *LumiMatcher, at: s32, value: *s32) -> s32 {
|
||||
end := LumiDigitsAt(matcher.input, at, 4)
|
||||
if end > at {
|
||||
if !LumiBoundary(matcher.input, end) && LumiCodeAt(matcher.input, end) >= 65 {
|
||||
// Letters straight after digits belong to a unit, not a count.
|
||||
return -1
|
||||
}
|
||||
value.* = LumiDigitsValue(matcher.input[at:end])
|
||||
return end
|
||||
}
|
||||
best: s32 = -1
|
||||
for index: cast(s32)0..cast(s32)9 {
|
||||
matched := LumiTaggedAt(matcher, LUMI_WORD_ONE + index, at)
|
||||
if matched > best {
|
||||
best = matched
|
||||
value.* = index + 1
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
// A clock time: 7, 7:30, 19.30, 7 am or 7pm. Returns its end and the
|
||||
// minutes since midnight, or -1.
|
||||
LumiTimeAt :: (matcher: *LumiMatcher, at: s32, minutes: *s32) -> s32 {
|
||||
text := matcher.input
|
||||
end := LumiDigitsAt(text, at, 2)
|
||||
if end == at {
|
||||
return -1
|
||||
}
|
||||
hour := LumiDigitsValue(text[at:end])
|
||||
minute: s32 = 0
|
||||
if end + 2 < cast(s32)text.count && (text[end] == cast(u8)58 || text[end] == cast(u8)46) {
|
||||
minute_end := LumiDigitsAt(text, end + 1, 2)
|
||||
if minute_end == end + 3 {
|
||||
minute = LumiDigitsValue(text[end + 1:minute_end])
|
||||
end = minute_end
|
||||
}
|
||||
}
|
||||
if minute > 59 {
|
||||
return -1
|
||||
}
|
||||
after := LumiSkipSpace(text, end)
|
||||
// "8 o'clock", "8 Uhr abends", "8時": a clock word, then morning or
|
||||
// evening.
|
||||
oclock := LumiUnitAt(matcher, LUMI_WORD_OCLOCK, after)
|
||||
if oclock > 0 {
|
||||
end = oclock
|
||||
after = LumiSkipSpace(text, end)
|
||||
}
|
||||
am := LumiUnitAt(matcher, LUMI_WORD_AM, after)
|
||||
pm := LumiUnitAt(matcher, LUMI_WORD_PM, after)
|
||||
if am > 0 || pm > 0 {
|
||||
if hour < 1 || hour > 12 {
|
||||
return -1
|
||||
}
|
||||
if hour == 12 {
|
||||
hour = 0
|
||||
}
|
||||
if pm > am {
|
||||
hour += 12
|
||||
end = pm
|
||||
} else {
|
||||
end = am
|
||||
}
|
||||
}
|
||||
if hour > 23 || (!LumiBoundary(text, end) && LumiCodeAt(text, end) >= 65) {
|
||||
return -1
|
||||
}
|
||||
minutes.* = hour * 60 + minute
|
||||
return end
|
||||
}
|
||||
|
||||
// A duration with its unit: 8 hours, 16h, 1.5 hours, 90 minutes, or 8:00.
|
||||
LumiLengthAt :: (matcher: *LumiMatcher, at: s32, minutes: *s32, unit: *s32) -> s32 {
|
||||
text := matcher.input
|
||||
end := LumiDigitsAt(text, at, 3)
|
||||
if end == at {
|
||||
return -1
|
||||
}
|
||||
whole := LumiDigitsValue(text[at:end])
|
||||
if end + 2 < cast(s32)text.count && text[end] == cast(u8)58 {
|
||||
minute_end := LumiDigitsAt(text, end + 1, 2)
|
||||
if minute_end != end + 3 {
|
||||
return -1
|
||||
}
|
||||
part := LumiDigitsValue(text[end + 1:minute_end])
|
||||
if part > 59 {
|
||||
return -1
|
||||
}
|
||||
hours_word := LumiUnitAt(matcher, LUMI_WORD_HOURS, LumiSkipSpace(text, minute_end))
|
||||
minutes.* = whole * 60 + part
|
||||
unit.* = 60
|
||||
return ifx hours_word > 0 then hours_word else minute_end
|
||||
}
|
||||
tenths: s32 = 0
|
||||
if end + 1 < cast(s32)text.count && (text[end] == cast(u8)46 || text[end] == cast(u8)44) &&
|
||||
text[end + 1] >= cast(u8)48 && text[end + 1] <= cast(u8)57 {
|
||||
tenths = cast(s32)(text[end + 1] - cast(u8)48)
|
||||
end = LumiDigitsAt(text, end + 1, 3)
|
||||
}
|
||||
after := LumiSkipSpace(text, end)
|
||||
hours := LumiUnitAt(matcher, LUMI_WORD_HOURS, after)
|
||||
minute_unit := LumiUnitAt(matcher, LUMI_WORD_MINUTES, after)
|
||||
if hours > minute_unit {
|
||||
minutes.* = whole * 60 + tenths * 6
|
||||
unit.* = 60
|
||||
return hours
|
||||
}
|
||||
if minute_unit > 0 && tenths == 0 {
|
||||
minutes.* = whole
|
||||
unit.* = 1
|
||||
return minute_unit
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
LumiDayAt :: (matcher: *LumiMatcher, at: s32, day: *s32) -> s32 {
|
||||
best: s32 = -1
|
||||
for index: cast(s32)0..cast(s32)6 {
|
||||
matched := LumiTaggedAt(matcher, LUMI_WORD_MON + index, at)
|
||||
if matched > best {
|
||||
best = matched
|
||||
day.* = index
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
// The ends of weekday lists at at, shortest first: "mon", "mon and wed".
|
||||
LumiDays :: struct {
|
||||
ends: [7]s32
|
||||
masks: [7]s32
|
||||
count: s32
|
||||
}
|
||||
|
||||
LumiDaysAt :: (matcher: *LumiMatcher, at: s32) -> LumiDays {
|
||||
found: LumiDays
|
||||
mask: s32 = 0
|
||||
position := at
|
||||
while found.count < 7 {
|
||||
day: s32 = 0
|
||||
end := LumiDayAt(matcher, position, *day)
|
||||
if end < 0 {
|
||||
break
|
||||
}
|
||||
mask |= 1 << day
|
||||
found.ends[found.count] = end
|
||||
found.masks[found.count] = mask
|
||||
found.count += 1
|
||||
next := LumiSkipSpace(matcher.input, end)
|
||||
if next < cast(s32)matcher.input.count && matcher.input[next] == cast(u8)44 {
|
||||
next = LumiSkipSpace(matcher.input, next + 1)
|
||||
}
|
||||
joined := LumiTaggedAt(matcher, LUMI_WORD_AND, next)
|
||||
if joined > 0 {
|
||||
next = LumiSkipSpace(matcher.input, joined)
|
||||
}
|
||||
position = next
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
// Folded equality of two phrases, ignoring how many spaces separate words.
|
||||
LumiSamePhrase :: (left: string, right: string) -> bool {
|
||||
return left.count > 0 && LumiPhraseAt(left, 0, right) == cast(s32)left.count
|
||||
}
|
||||
|
||||
// A word close to a habit's word: the same, one typo, or the same stem, as
|
||||
// "meditate" and "Meditation" or "медитации" and "Медитация".
|
||||
LumiNearWord :: (left: string, right: string) -> bool {
|
||||
if CommandEqual(left, right) || CommandTypo(left, right) {
|
||||
return true
|
||||
}
|
||||
a: s32 = 0
|
||||
b: s32 = 0
|
||||
shared: s32 = 0
|
||||
while a < cast(s32)left.count && b < cast(s32)right.count {
|
||||
x := Decode(left, a)
|
||||
y := Decode(right, b)
|
||||
if LumiFoldCode(x.value) != LumiFoldCode(y.value) {
|
||||
break
|
||||
}
|
||||
shared += 1
|
||||
a = x.after
|
||||
b = y.after
|
||||
}
|
||||
left_count := Count(left)
|
||||
right_count := Count(right)
|
||||
longer := ifx left_count > right_count then left_count else right_count
|
||||
return shared >= 5 && shared >= longer - 3
|
||||
}
|
||||
|
||||
// The end of a near match of the title's words at at, or -1.
|
||||
LumiNearTitleAt :: (text: string, at: s32, title: string) -> s32 {
|
||||
position := at
|
||||
from: s32 = 0
|
||||
words: s32 = 0
|
||||
while from < cast(s32)title.count {
|
||||
from = LumiSkipSpace(title, from)
|
||||
if from >= cast(s32)title.count {
|
||||
break
|
||||
}
|
||||
to := LumiWordEnd(title, from)
|
||||
if to == from {
|
||||
return -1
|
||||
}
|
||||
position = LumiSkipSpace(text, position)
|
||||
end := LumiWordEnd(text, position)
|
||||
if end == position || !LumiNearWord(text[position:end], title[from:to]) {
|
||||
return -1
|
||||
}
|
||||
position = end
|
||||
from = to
|
||||
words += 1
|
||||
}
|
||||
return ifx words > 0 then position else -1
|
||||
}
|
||||
|
||||
LumiHabitAllowed :: (matcher: *LumiMatcher, habit: LumiHabitRef) -> bool {
|
||||
if matcher.habit_filter == LUMI_HABITS_ACTIVE {
|
||||
return !habit.paused
|
||||
}
|
||||
if matcher.habit_filter == LUMI_HABITS_PAUSED {
|
||||
return habit.paused
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
LumiTokens :: (template: string, tokens: []LumiToken) -> s32 {
|
||||
count: s32 = 0
|
||||
at: s32 = 0
|
||||
while at < cast(s32)template.count {
|
||||
byte := template[at]
|
||||
if byte == cast(u8)32 || byte == cast(u8)9 {
|
||||
at += 1
|
||||
continue
|
||||
}
|
||||
if count >= cast(s32)tokens.count {
|
||||
return -1
|
||||
}
|
||||
if byte == cast(u8)91 || byte == cast(u8)93 {
|
||||
tokens[count] = LumiToken.{.kind = ifx byte == cast(u8)91 then LUMI_TOKEN_OPEN else LUMI_TOKEN_CLOSE}
|
||||
count += 1
|
||||
at += 1
|
||||
continue
|
||||
}
|
||||
if byte == cast(u8)123 {
|
||||
end := at + 1
|
||||
while end < cast(s32)template.count && template[end] != cast(u8)125 {
|
||||
end += 1
|
||||
}
|
||||
if end >= cast(s32)template.count {
|
||||
return -1
|
||||
}
|
||||
name := template[at + 1:end]
|
||||
slot: s32 = 0
|
||||
if name == "habit" { slot = LUMI_SLOT_HABIT }
|
||||
if name == "name" { slot = LUMI_SLOT_NAME }
|
||||
if name == "text" { slot = LUMI_SLOT_TEXT }
|
||||
if name == "n" { slot = LUMI_SLOT_NUMBER }
|
||||
if name == "time" { slot = LUMI_SLOT_TIME }
|
||||
if name == "length" { slot = LUMI_SLOT_LENGTH }
|
||||
if name == "days" { slot = LUMI_SLOT_DAYS }
|
||||
if slot == 0 {
|
||||
return -1
|
||||
}
|
||||
tokens[count] = LumiToken.{.kind = LUMI_TOKEN_SLOT, .slot = slot}
|
||||
count += 1
|
||||
at = end + 1
|
||||
continue
|
||||
}
|
||||
end := at
|
||||
while end < cast(s32)template.count && template[end] != cast(u8)32 &&
|
||||
template[end] != cast(u8)91 && template[end] != cast(u8)93 && template[end] != cast(u8)123 {
|
||||
end += 1
|
||||
}
|
||||
tokens[count] = LumiToken.{.kind = LUMI_TOKEN_WORDS, .text = template[at:end]}
|
||||
count += 1
|
||||
at = end
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
LumiCloseOf :: (tokens: []LumiToken, open: s32) -> s32 {
|
||||
index := open + 1
|
||||
while index < cast(s32)tokens.count {
|
||||
if tokens[index].kind == LUMI_TOKEN_CLOSE {
|
||||
return index
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
return cast(s32)tokens.count
|
||||
}
|
||||
|
||||
// Free words from at to end: something other than spaces and punctuation.
|
||||
LumiWordsBetween :: (text: string, at: s32, end: s32) -> string {
|
||||
return LumiTrimText(text[at:end])
|
||||
}
|
||||
|
||||
LumiMatchFrom :: (matcher: *LumiMatcher, tokens: []LumiToken, index: s32, at: s32,
|
||||
capture: LumiCapture, out: *LumiCapture) -> bool {
|
||||
matcher.budget -= 1
|
||||
if matcher.budget <= 0 {
|
||||
return false
|
||||
}
|
||||
text := matcher.input
|
||||
at = LumiSkipGap(text, at)
|
||||
if index >= cast(s32)tokens.count {
|
||||
if LumiSkipTail(text, at) != cast(s32)text.count {
|
||||
return false
|
||||
}
|
||||
out.* = capture
|
||||
return true
|
||||
}
|
||||
token := tokens[index]
|
||||
if token.kind == LUMI_TOKEN_OPEN {
|
||||
if LumiMatchFrom(matcher, tokens, index + 1, at, capture, out) {
|
||||
return true
|
||||
}
|
||||
return LumiMatchFrom(matcher, tokens, LumiCloseOf(tokens, index) + 1, at, capture, out)
|
||||
}
|
||||
if token.kind == LUMI_TOKEN_CLOSE {
|
||||
return LumiMatchFrom(matcher, tokens, index + 1, at, capture, out)
|
||||
}
|
||||
if token.kind == LUMI_TOKEN_WORDS {
|
||||
end := LumiWordsAt(text, at, token.text)
|
||||
return end >= 0 && LumiMatchFrom(matcher, tokens, index + 1, end, capture, out)
|
||||
}
|
||||
if token.slot == LUMI_SLOT_NAME || token.slot == LUMI_SLOT_TEXT {
|
||||
// The fewest words that let the rest of the template match.
|
||||
end := at
|
||||
while end < cast(s32)text.count {
|
||||
end = Decode(text, end).after
|
||||
if !LumiBoundary(text, end) {
|
||||
continue
|
||||
}
|
||||
words := LumiWordsBetween(text, at, end)
|
||||
if words.count == 0 {
|
||||
continue
|
||||
}
|
||||
next := capture
|
||||
if token.slot == LUMI_SLOT_NAME {
|
||||
next.name_at = at
|
||||
next.name_end = end
|
||||
} else {
|
||||
next.text_at = at
|
||||
next.text_end = end
|
||||
}
|
||||
if LumiMatchFrom(matcher, tokens, index + 1, end, next, out) {
|
||||
return true
|
||||
}
|
||||
if matcher.budget <= 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if token.slot == LUMI_SLOT_NUMBER {
|
||||
value: s32 = 0
|
||||
end := LumiNumberAt(matcher, at, *value)
|
||||
if end < 0 || capture.number_count >= 2 {
|
||||
return false
|
||||
}
|
||||
next := capture
|
||||
next.numbers[next.number_count] = value
|
||||
next.number_count += 1
|
||||
return LumiMatchFrom(matcher, tokens, index + 1, end, next, out)
|
||||
}
|
||||
if token.slot == LUMI_SLOT_TIME {
|
||||
minutes: s32 = 0
|
||||
end := LumiTimeAt(matcher, at, *minutes)
|
||||
if end < 0 || capture.time_count >= 2 {
|
||||
return false
|
||||
}
|
||||
next := capture
|
||||
next.times[next.time_count] = minutes
|
||||
next.time_count += 1
|
||||
return LumiMatchFrom(matcher, tokens, index + 1, end, next, out)
|
||||
}
|
||||
if token.slot == LUMI_SLOT_LENGTH {
|
||||
minutes: s32 = 0
|
||||
unit: s32 = 0
|
||||
end := LumiLengthAt(matcher, at, *minutes, *unit)
|
||||
if end < 0 || minutes <= 0 || capture.length_count >= 2 {
|
||||
return false
|
||||
}
|
||||
next := capture
|
||||
next.lengths[next.length_count] = minutes
|
||||
next.length_count += 1
|
||||
next.length_unit = unit
|
||||
return LumiMatchFrom(matcher, tokens, index + 1, end, next, out)
|
||||
}
|
||||
if token.slot == LUMI_SLOT_DAYS {
|
||||
days := LumiDaysAt(matcher, at)
|
||||
choice := days.count - 1
|
||||
while choice >= 0 {
|
||||
next := capture
|
||||
next.days |= days.masks[choice]
|
||||
if LumiMatchFrom(matcher, tokens, index + 1, days.ends[choice], next, out) {
|
||||
return true
|
||||
}
|
||||
choice -= 1
|
||||
}
|
||||
return false
|
||||
}
|
||||
return LumiMatchHabit(matcher, tokens, index, at, capture, out)
|
||||
}
|
||||
|
||||
// {habit}: the habits whose names match here, exact ones first and longer
|
||||
// names before shorter. Several near matches of the same words are
|
||||
// ambiguous; the template still matches, and the caller asks.
|
||||
LumiMatchHabit :: (matcher: *LumiMatcher, tokens: []LumiToken, index: s32, at: s32,
|
||||
capture: LumiCapture, out: *LumiCapture) -> bool {
|
||||
text := matcher.input
|
||||
ends: [LUMI_HABIT_CANDIDATES]s32
|
||||
habits: [LUMI_HABIT_CANDIDATES]s32
|
||||
exact: [LUMI_HABIT_CANDIDATES]bool
|
||||
count: s32 = 0
|
||||
for candidate: cast(s32)0..cast(s32)matcher.habits.count - 1 {
|
||||
habit := matcher.habits[candidate]
|
||||
if !LumiHabitAllowed(matcher, habit) || habit.title.count == 0 || count >= LUMI_HABIT_CANDIDATES {
|
||||
continue
|
||||
}
|
||||
end := LumiPhraseAt(text, at, LumiLineTrim(habit.title))
|
||||
is_exact := end >= 0
|
||||
if !is_exact {
|
||||
end = LumiNearTitleAt(text, at, habit.title)
|
||||
}
|
||||
if end >= 0 {
|
||||
ends[count] = end
|
||||
habits[count] = candidate
|
||||
exact[count] = is_exact
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
for pass: cast(s32)0..cast(s32)1 {
|
||||
tried: s32 = 0
|
||||
while tried < count {
|
||||
// The longest remaining candidate of this pass.
|
||||
best: s32 = -1
|
||||
for candidate: cast(s32)0..count - 1 {
|
||||
if ends[candidate] >= 0 && exact[candidate] == (pass == 0) &&
|
||||
(best < 0 || ends[candidate] > ends[best]) {
|
||||
best = candidate
|
||||
}
|
||||
}
|
||||
if best < 0 {
|
||||
break
|
||||
}
|
||||
next := capture
|
||||
next.habit = habits[best]
|
||||
for other: cast(s32)0..count - 1 {
|
||||
if other != best && ends[other] == ends[best] && exact[other] == exact[best] {
|
||||
next.habit = -2
|
||||
ends[other] = -1
|
||||
}
|
||||
}
|
||||
end := ends[best]
|
||||
ends[best] = -1
|
||||
if LumiMatchFrom(matcher, tokens, index + 1, end, next, out) {
|
||||
return true
|
||||
}
|
||||
tried += 1
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Whether a template matches the whole input, filling out.
|
||||
LumiTemplateMatches :: (matcher: *LumiMatcher, template: *LumiTemplate, out: *LumiCapture) -> bool {
|
||||
if template.count <= 0 {
|
||||
return false
|
||||
}
|
||||
return LumiMatchFrom(matcher, template.tokens[:template.count], 0, 0, LumiNewCapture(), out)
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
// Lumi owns conversation decisions. The host supplies only explicit app tools.
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import, file "../../src/cells/lumi_types.zi";
|
||||
#import, file "../../src/cells/module_types.zi";
|
||||
#import, file "../../src/cells/lumi_ui_types.zi";
|
||||
#import, file "../../src/core/types.zi";
|
||||
#import, file "engine.zi";
|
||||
#import, file "lumi_view.zi";
|
||||
#import, file "habit_patterns.zi";
|
||||
#import, file "habit_intent.zi";
|
||||
#import, file "habit_harness.zi";
|
||||
|
||||
host_api :: #system_library "host_api";
|
||||
ReadLumiHost :: () -> LumiMessage #foreign host_api;
|
||||
WriteLumiHost :: (message: LumiMessage) #foreign host_api;
|
||||
ReadLumiTaskHost :: (index: s32) -> LumiTask #foreign host_api;
|
||||
ReadLumiHabitHost :: (index: s32) -> LumiTask #foreign host_api;
|
||||
LumiTaskCountHost :: () -> s32 #foreign host_api;
|
||||
PerformLumiActionHost :: (action: LumiAction) -> bool #foreign host_api;
|
||||
AppendLumiChatHost :: (text: string, user: bool) #foreign host_api;
|
||||
LumiLocaleHost :: (key: string) -> string #foreign host_api;
|
||||
LumiLocaleRevisionHost :: () -> s64 #foreign host_api;
|
||||
command_revision: s64 = -1;
|
||||
command_cache: LumiCommands;
|
||||
ReadLumiToolsHost :: () -> LumiTools #foreign host_api;
|
||||
SetLumiHabitChoiceHost :: (choosing: bool) #foreign host_api;
|
||||
SetLumiDiaryChoiceHost :: (choosing: bool) #foreign host_api;
|
||||
StartLumiOnlineHost :: (input: string) -> bool #foreign host_api;
|
||||
LumiToolHost :: (name: string, arguments: string) -> string #foreign host_api;
|
||||
ConfirmLumiDeleteHost :: (confirmed: bool) -> bool #foreign host_api;
|
||||
LumiEnglishLocaleHost :: (key: string) -> string #foreign host_api;
|
||||
habit_revision: s64 = -1;
|
||||
habit_active: LumiCompiled;
|
||||
habit_english: LumiCompiled;
|
||||
habit_english_extra: bool;
|
||||
habit_words: LumiReplyWords;
|
||||
|
||||
LumiAskHabit :: (tools: LumiTools) {
|
||||
if tools.habit_count == 0 {
|
||||
SetLumiHabitChoiceHost(false)
|
||||
AppendLumiChatHost(LumiLocaleHost("lumi_no_habits"), false)
|
||||
return
|
||||
}
|
||||
SetLumiHabitChoiceHost(true)
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%", LumiLocaleHost("lumi_choose_habit"))
|
||||
for index: cast(s32)0..tools.habit_count - 1 {
|
||||
habit := ReadLumiHabitHost(index)
|
||||
if out.count + habit.title.count + 6 >= LUMI_INPUT_MAX {
|
||||
AppendLumiChatHost(BuilderFinish(out), false)
|
||||
out = Vec(u8).{}
|
||||
}
|
||||
BuilderPrint(*out, "\n• %", habit.title)
|
||||
}
|
||||
AppendLumiChatHost(BuilderFinish(out), false)
|
||||
}
|
||||
|
||||
LumiCommandSet :: () -> LumiCommands {
|
||||
revision := LumiLocaleRevisionHost()
|
||||
if revision == command_revision { return command_cache }
|
||||
command_revision = revision
|
||||
command_cache = LumiCommands.{.add = LumiLocaleHost("lumi_add"),
|
||||
.complete = LumiLocaleHost("lumi_complete"), .reopen = LumiLocaleHost("lumi_reopen"),
|
||||
.complete_habit = LumiLocaleHost("lumi_complete_habit"),
|
||||
.start_whm = LumiLocaleHost("lumi_start_whm"),
|
||||
.start_meditation = LumiLocaleHost("lumi_start_meditation"),
|
||||
.start_sun = LumiLocaleHost("lumi_start_sun"), .start_patterns = LumiLocaleHost("lumi_start_patterns"),
|
||||
.lists = LumiLocaleHost("lumi_open_lists"), .habits = LumiLocaleHost("lumi_open_habits"),
|
||||
.practices = LumiLocaleHost("lumi_open_practices"), .diary = LumiLocaleHost("lumi_open_diary"),
|
||||
.write_diary = LumiLocaleHost("lumi_write_diary"),
|
||||
.settings = LumiLocaleHost("lumi_open_settings"), .appearance = LumiLocaleHost("lumi_open_appearance"),
|
||||
.theme = LumiLocaleHost("lumi_theme"), .dark = LumiLocaleHost("lumi_dark"),
|
||||
.light = LumiLocaleHost("lumi_light"), .system = LumiLocaleHost("lumi_system"),
|
||||
.progress = LumiLocaleHost("lumi_show_progress"), .donations = LumiLocaleHost("lumi_show_donations")}
|
||||
return command_cache
|
||||
}
|
||||
|
||||
// The habit templates of the app's language and of English, and the words
|
||||
// of Lumi's habit answers, read again when the language changes.
|
||||
LumiHabitLanguage :: () {
|
||||
revision := LumiLocaleRevisionHost()
|
||||
if revision == habit_revision {
|
||||
return
|
||||
}
|
||||
habit_revision = revision
|
||||
active := LumiLanguage.{.patterns = LumiLocaleHost("lumi_habit_patterns"),
|
||||
.clauses = LumiLocaleHost("lumi_habit_clauses"), .words = LumiLocaleHost("lumi_habit_words")}
|
||||
english := LumiLanguage.{.patterns = LumiEnglishLocaleHost("lumi_habit_patterns"),
|
||||
.clauses = LumiEnglishLocaleHost("lumi_habit_clauses"),
|
||||
.words = LumiEnglishLocaleHost("lumi_habit_words")}
|
||||
LumiCompileLanguage(active, *habit_active)
|
||||
habit_english_extra = english.patterns != active.patterns
|
||||
if habit_english_extra {
|
||||
LumiCompileLanguage(english, *habit_english)
|
||||
}
|
||||
days: [7]string = .[LumiLocaleHost("habit_day_mon"), LumiLocaleHost("habit_day_tue"),
|
||||
LumiLocaleHost("habit_day_wed"), LumiLocaleHost("habit_day_thu"), LumiLocaleHost("habit_day_fri"),
|
||||
LumiLocaleHost("habit_day_sat"), LumiLocaleHost("habit_day_sun")]
|
||||
habit_words = LumiReplyWords.{.created = LumiLocaleHost("habit_change_created"),
|
||||
.renamed = LumiLocaleHost("habit_change_name"), .paused = LumiLocaleHost("habit_change_paused"),
|
||||
.resumed = LumiLocaleHost("habit_change_resumed"),
|
||||
.question_added = LumiLocaleHost("habit_change_question_added"),
|
||||
.question_removed = LumiLocaleHost("habit_change_question_removed"),
|
||||
.every_day = LumiLocaleHost("habit_every_day"), .every_n_days = LumiLocaleHost("habit_every_n_days"),
|
||||
.days = days, .reminder = LumiLocaleHost("lumi_habit_reminder"),
|
||||
.no_reminder = LumiLocaleHost("lumi_habit_no_reminder"),
|
||||
.check = LumiLocaleHost("habit_tracking_check"), .count = LumiLocaleHost("habit_tracking_count"),
|
||||
.span = LumiLocaleHost("habit_tracking_span"), .yes = LumiLocaleHost("habit_answer_yes"),
|
||||
.no = LumiLocaleHost("habit_answer_no"), .longer = LumiLocaleHost("habit_span_goal_longer"),
|
||||
.shorter = LumiLocaleHost("habit_span_goal_shorter"),
|
||||
.later_than_average = LumiLocaleHost("habit_goal_later_than_average"),
|
||||
.above_average = LumiLocaleHost("habit_goal_above_average"),
|
||||
.earlier_than_average = LumiLocaleHost("habit_goal_earlier_than_average"),
|
||||
.below_average = LumiLocaleHost("habit_goal_below_average"),
|
||||
.after = LumiLocaleHost("habit_goal_after"), .at_least = LumiLocaleHost("habit_goal_at_least"),
|
||||
.before = LumiLocaleHost("habit_goal_before"), .at_most = LumiLocaleHost("habit_goal_at_most"),
|
||||
.between = LumiLocaleHost("habit_goal_between"), .and_word = LumiLocaleHost("habit_goal_and")}
|
||||
}
|
||||
|
||||
// English, or the active language itself when it is English.
|
||||
LumiEnglishCompiled :: () -> *LumiCompiled {
|
||||
return ifx habit_english_extra then *habit_english else *habit_active
|
||||
}
|
||||
|
||||
// Answers a habit request on the device with the same app tools the online
|
||||
// model uses. False leaves the message to the rest of Lumi: other
|
||||
// commands, the model online, or the offline answer.
|
||||
LumiHabitRespond :: (input: string, tools: LumiTools) -> bool {
|
||||
if (tools.available_apps & LUMI_HABITS) == 0 {
|
||||
return false
|
||||
}
|
||||
LumiHabitLanguage()
|
||||
habits: [LUMI_HABITS_MAX]LumiHabitRef
|
||||
count: s32 = 0
|
||||
for index: cast(s32)0..tools.habit_count - 1 {
|
||||
if count >= LUMI_HABITS_MAX {
|
||||
break
|
||||
}
|
||||
habit := ReadLumiHabitHost(index)
|
||||
if habit.id.count > 0 && habit.title.count > 0 {
|
||||
habits[count] = LumiHabitRef.{.id = habit.id, .title = habit.title}
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
count = LumiPausedHabits(LumiToolHost("read_context", "{}"), habits[:], count)
|
||||
known := habits[:count]
|
||||
plan := LumiHabitParseCompiled(input, *habit_active, LumiEnglishCompiled(), known)
|
||||
if plan.kind == 0 {
|
||||
return false
|
||||
}
|
||||
if plan.habit == -2 {
|
||||
AppendLumiChatHost(LumiLocaleHost("lumi_ambiguous"), false)
|
||||
return true
|
||||
}
|
||||
title := plan.name
|
||||
if plan.habit >= 0 {
|
||||
title = known[plan.habit].title
|
||||
}
|
||||
if plan.kind == LUMI_HABIT_EXISTS {
|
||||
values: [1]string = .[title]
|
||||
AppendLumiChatHost(LumiFill(LumiLocaleHost("lumi_habit_exists"), values[:]), false)
|
||||
return true
|
||||
}
|
||||
questions := "[]"
|
||||
if (plan.kind == LUMI_HABIT_ASK || plan.kind == LUMI_HABIT_UNASK) && plan.habit >= 0 {
|
||||
questions = LumiQuestionsOf(LumiToolHost("read_habit", LumiIdArguments(known[plan.habit].id)))
|
||||
if questions.count == 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
calls: [LUMI_CALLS_MAX]LumiToolCall
|
||||
total := LumiHabitCalls(plan, known, questions, calls[:])
|
||||
if total <= 0 {
|
||||
return false
|
||||
}
|
||||
created := ""
|
||||
for index: cast(s32)0..total - 1 {
|
||||
arguments := calls[index].arguments
|
||||
if created.count > 0 {
|
||||
arguments = LumiReplaceNew(arguments, created)
|
||||
}
|
||||
result := LumiToolHost(calls[index].name, arguments)
|
||||
if !LumiToolOk(result) {
|
||||
values: [1]string = .[title]
|
||||
AppendLumiChatHost(LumiFill(LumiLocaleHost("lumi_habit_failed"), values[:]), false)
|
||||
return true
|
||||
}
|
||||
if calls[index].name == "create_habit" {
|
||||
created = LumiToolText(result, "id")
|
||||
title = LumiToolText(result, "title")
|
||||
}
|
||||
if calls[index].name == "delete_habit" {
|
||||
// The host asked in the chat whether to delete; the next
|
||||
// message answers.
|
||||
return true
|
||||
}
|
||||
}
|
||||
AppendLumiChatHost(LumiHabitReply(habit_words, plan, title), false)
|
||||
return true
|
||||
}
|
||||
|
||||
LumiRespond :: (input: string) {
|
||||
input = LumiTrim(input)
|
||||
if input.count == 0 || input.count >= LUMI_INPUT_MAX {
|
||||
return
|
||||
}
|
||||
AppendLumiChatHost(input, true)
|
||||
tools := ReadLumiToolsHost()
|
||||
if tools.confirming_delete {
|
||||
// Lumi asked whether to delete a habit: yes deletes, no keeps it,
|
||||
// and anything else keeps it and is read as a new request.
|
||||
LumiHabitLanguage()
|
||||
answer := LumiYesNo(input, *habit_active, LumiEnglishCompiled())
|
||||
unused ConfirmLumiDeleteHost(answer == 1)
|
||||
if answer == 1 {
|
||||
return
|
||||
}
|
||||
if answer == 2 {
|
||||
AppendLumiChatHost(LumiLocaleHost("lumi_cancelled"), false)
|
||||
return
|
||||
}
|
||||
}
|
||||
help_requested := LumiEqual(input, "help") || LumiEqual(input, "/help") || LumiEqual(input, "how can you help?")
|
||||
if (tools.choosing_diary || tools.choosing_habit) &&
|
||||
(LumiEqual(input, "/cancel") || LumiEqual(input, "cancel") || LumiEqual(input, LumiLocaleHost("cancel_button"))) {
|
||||
SetLumiDiaryChoiceHost(false)
|
||||
SetLumiHabitChoiceHost(false)
|
||||
AppendLumiChatHost(LumiLocaleHost("lumi_cancelled"), false)
|
||||
return
|
||||
}
|
||||
action := LumiIntentWith(input, LumiCommandSet(), false)
|
||||
if tools.choosing_diary && !help_requested {
|
||||
action = LumiAction.{.kind = LUMI_WRITE_DIARY, .title = input}
|
||||
} else if action.kind == 0 && tools.choosing_habit && !help_requested {
|
||||
action = LumiAction.{.kind = LUMI_COMPLETE_HABIT, .title = input}
|
||||
}
|
||||
if action.kind == 0 && !help_requested && !tools.choosing_diary && !tools.choosing_habit {
|
||||
if LumiHabitRespond(input, tools) {
|
||||
return
|
||||
}
|
||||
action = LumiIntent(input, LumiCommandSet())
|
||||
}
|
||||
reply := ifx help_requested then "lumi_help" else "lumi_unknown"
|
||||
if action.kind != 0 && !LumiActionAvailable(action, tools.available_apps) {
|
||||
action.kind = 0
|
||||
reply = "lumi_unavailable"
|
||||
}
|
||||
if action.kind == LUMI_COMPLETE_HABIT && action.title.count == 0 {
|
||||
SetLumiDiaryChoiceHost(false)
|
||||
LumiAskHabit(tools)
|
||||
return
|
||||
}
|
||||
if action.kind == LUMI_WRITE_DIARY && action.title.count == 0 {
|
||||
SetLumiHabitChoiceHost(false)
|
||||
SetLumiDiaryChoiceHost(true)
|
||||
AppendLumiChatHost(LumiLocaleHost("lumi_diary_prompt"), false)
|
||||
return
|
||||
}
|
||||
if action.kind == LUMI_COMPLETE_TODO || action.kind == LUMI_REOPEN_TODO || action.kind == LUMI_COMPLETE_HABIT {
|
||||
count := ifx action.kind == LUMI_COMPLETE_HABIT then tools.habit_count else tools.task_count
|
||||
matches: s32 = 0
|
||||
exact_matches: s32 = 0
|
||||
id: string
|
||||
exact_id: string
|
||||
for index: cast(s32)0..count - 1 {
|
||||
task := ifx action.kind == LUMI_COMPLETE_HABIT then ReadLumiHabitHost(index) else ReadLumiTaskHost(index)
|
||||
eligible := action.kind == LUMI_COMPLETE_HABIT || (action.kind == LUMI_COMPLETE_TODO && !task.done) ||
|
||||
(action.kind == LUMI_REOPEN_TODO && task.done)
|
||||
if eligible && LumiStarts(task.title, action.title) {
|
||||
matches += 1
|
||||
id = task.id
|
||||
if LumiEqual(task.title, action.title) {
|
||||
exact_matches += 1
|
||||
exact_id = task.id
|
||||
}
|
||||
}
|
||||
}
|
||||
if exact_matches == 1 {
|
||||
action.id = exact_id
|
||||
} else if exact_matches == 0 && matches == 1 {
|
||||
action.id = id
|
||||
} else {
|
||||
reply = ifx matches == 0 then "lumi_not_found" else "lumi_ambiguous"
|
||||
action.kind = 0
|
||||
if tools.choosing_habit {
|
||||
SetLumiHabitChoiceHost(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
if action.kind != 0 {
|
||||
if PerformLumiActionHost(action) {
|
||||
SetLumiHabitChoiceHost(false)
|
||||
SetLumiDiaryChoiceHost(false)
|
||||
if action.kind == LUMI_SHOW_PROGRESS || action.kind == LUMI_SHOW_DONATIONS ||
|
||||
action.kind == LUMI_REPORT_FEEDBACK {
|
||||
// These tools already appended their typed card to the chat;
|
||||
// the feedback card with Yes and No is the whole answer.
|
||||
return
|
||||
}
|
||||
reply = "lumi_opened"
|
||||
if action.kind == LUMI_ADD_TODO {
|
||||
reply = "lumi_added"
|
||||
} else if action.kind == LUMI_COMPLETE_TODO {
|
||||
reply = "lumi_completed"
|
||||
} else if action.kind == LUMI_REOPEN_TODO {
|
||||
reply = "lumi_reopened"
|
||||
} else if action.kind == LUMI_COMPLETE_HABIT {
|
||||
reply = "lumi_habit_completed"
|
||||
} else if action.kind == LUMI_SET_THEME || action.kind == LUMI_SET_MODE {
|
||||
reply = "lumi_settings_changed"
|
||||
} else if action.kind == LUMI_START_PRACTICE {
|
||||
reply = "lumi_practice_started"
|
||||
} else if action.kind == LUMI_WRITE_DIARY {
|
||||
reply = "lumi_diary_saved"
|
||||
}
|
||||
} else {
|
||||
reply = "lumi_unavailable"
|
||||
}
|
||||
}
|
||||
// Only what Lumi couldn't understand goes online; a request it read
|
||||
// but couldn't carry out gets its own answer here.
|
||||
if action.kind == 0 && reply == "lumi_unknown" && StartLumiOnlineHost(input) {
|
||||
return
|
||||
}
|
||||
if reply == "lumi_help" {
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%", LumiLocaleHost(reply))
|
||||
commands := LumiCommandSet()
|
||||
if (tools.available_apps & LUMI_PRACTICES) != 0 {
|
||||
BuilderPrint(*out, "\n%", commands.start_whm)
|
||||
}
|
||||
if (tools.available_apps & LUMI_HABITS) != 0 {
|
||||
BuilderPrint(*out, " · %", commands.complete_habit)
|
||||
}
|
||||
if (tools.available_apps & LUMI_LISTS) != 0 {
|
||||
BuilderPrint(*out, " · %", commands.add)
|
||||
}
|
||||
if (tools.available_apps & LUMI_DIARY) != 0 {
|
||||
BuilderPrint(*out, " · %", commands.write_diary)
|
||||
}
|
||||
if (tools.available_apps & LUMI_PRACTICES) != 0 {
|
||||
BuilderPrint(*out, "\n/progress sessions 7 · /progress meditation 30 · /progress retention 7")
|
||||
}
|
||||
if (tools.available_apps & LUMI_HABITS) != 0 {
|
||||
BuilderPrint(*out, "\n/progress habits 7")
|
||||
}
|
||||
BuilderPrint(*out, "\n%", commands.donations)
|
||||
AppendLumiChatHost(BuilderFinish(out), false)
|
||||
} else {
|
||||
AppendLumiChatHost(LumiLocaleHost(reply), false)
|
||||
}
|
||||
}
|
||||
|
||||
#program_export "LumiMain"
|
||||
Main :: () -> s32 {
|
||||
message := ReadLumiHost()
|
||||
if message.abi != MODULE_ABI {
|
||||
return -1
|
||||
}
|
||||
if message.action == MODULE_IDENTIFY {
|
||||
return MODULE_LUMI
|
||||
}
|
||||
message.succeeded = true
|
||||
if message.action == LUMI_ROUTE {
|
||||
message.succeeded = message.screen == ScreenLumi
|
||||
} else if message.action == LUMI_FRAME {
|
||||
commands := LumiCommandSet()
|
||||
message = LumiView(message, commands, command_revision)
|
||||
if message.action == LUMI_SEND {
|
||||
LumiRespond(message.input)
|
||||
}
|
||||
} else if message.action == LUMI_SEND {
|
||||
LumiRespond(message.input)
|
||||
} else {
|
||||
message.succeeded = false
|
||||
}
|
||||
WriteLumiHost(message)
|
||||
return 0
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,106 @@
|
||||
// Reply emphasis is presentation only. Stored messages remain verbatim, and
|
||||
// typed messages and code keep their literal text.
|
||||
#import "text_props"
|
||||
#import "byte_text_linux"
|
||||
#import, file "../../src/cells/lumi_types.zi";
|
||||
|
||||
LumiMessageText :: struct {
|
||||
bytes: [LUMI_INPUT_MAX]u8
|
||||
count: s32
|
||||
strong: [256]TextRange
|
||||
strong_count: s32
|
||||
}
|
||||
|
||||
LumiTextEscaped :: (value: string, at: s32) -> bool {
|
||||
slashes: s32 = 0
|
||||
at -= 1
|
||||
while at >= 0 && value[at] == cast(u8)92 {
|
||||
slashes += 1
|
||||
at -= 1
|
||||
}
|
||||
return slashes % 2 == 1
|
||||
}
|
||||
|
||||
LumiTextMarker :: (value: string, at: s32) -> bool {
|
||||
if at < 0 || at + 1 >= value.count || LumiTextEscaped(value, at) {
|
||||
return false
|
||||
}
|
||||
marker := value[at]
|
||||
return (marker == cast(u8)42 || marker == cast(u8)95) && value[at + 1] == marker &&
|
||||
(at == 0 || value[at - 1] != marker) &&
|
||||
(at + 2 >= value.count || value[at + 2] != marker)
|
||||
}
|
||||
|
||||
LumiTextClosing :: (value: string, at: s32) -> s32 {
|
||||
marker := value[at]
|
||||
start := at + 2
|
||||
if start >= value.count || value[start] <= cast(u8)32 {
|
||||
return -1
|
||||
}
|
||||
code: bool
|
||||
while start + 1 < value.count {
|
||||
if value[start] == cast(u8)96 && !LumiTextEscaped(value, start) {
|
||||
code = !code
|
||||
}
|
||||
if !code && value[start] == marker && LumiTextMarker(value, start) &&
|
||||
start > at + 2 && value[start - 1] > cast(u8)32 {
|
||||
return start
|
||||
}
|
||||
start += 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
LumiFormatCounts :: struct {
|
||||
count: s32
|
||||
strong_count: s32
|
||||
}
|
||||
|
||||
// Formats into caller buffers, for text longer than a chat message such
|
||||
// as Lumi's online terms. Bytes that do not fit are left out.
|
||||
LumiFormatInto :: (value: string, formatted: bool, bytes: []u8, strong: []TextRange) -> LumiFormatCounts {
|
||||
result: LumiFormatCounts
|
||||
limit := cast(s32)bytes.count - 1
|
||||
at: s32 = 0
|
||||
code: bool
|
||||
while at < value.count && result.count < limit {
|
||||
byte := value[at]
|
||||
if formatted && byte == cast(u8)96 && !LumiTextEscaped(value, at) {
|
||||
code = !code
|
||||
}
|
||||
if formatted && !code && LumiTextMarker(value, at) && result.strong_count < cast(s32)strong.count {
|
||||
end := LumiTextClosing(value, at)
|
||||
if end >= 0 {
|
||||
range := TextRange.{.start = result.count}
|
||||
at += 2
|
||||
while at < end && result.count < limit {
|
||||
bytes[result.count] = value[at]
|
||||
result.count += 1
|
||||
at += 1
|
||||
}
|
||||
range.end = result.count
|
||||
strong[result.strong_count] = range
|
||||
result.strong_count += 1
|
||||
at = end + 2
|
||||
continue
|
||||
}
|
||||
}
|
||||
if formatted && byte == cast(u8)92 && at + 1 < value.count &&
|
||||
(value[at + 1] == cast(u8)42 || value[at + 1] == cast(u8)95 || value[at + 1] == cast(u8)92) {
|
||||
at += 1
|
||||
byte = value[at]
|
||||
}
|
||||
bytes[result.count] = byte
|
||||
result.count += 1
|
||||
at += 1
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
LumiFormatMessage :: (value: string, formatted: bool) -> LumiMessageText {
|
||||
result: LumiMessageText
|
||||
counts := LumiFormatInto(value, formatted, result.bytes[:], result.strong[:])
|
||||
result.count = counts.count
|
||||
result.strong_count = counts.strong_count
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Bounded, case-insensitive regex matching for Lumi's fixed command patterns.
|
||||
// Supports anchors, character classes, escapes and ?, * and + quantifiers.
|
||||
RegexAtom :: struct {
|
||||
after: s32
|
||||
matches: bool
|
||||
}
|
||||
|
||||
RegexLower :: (byte: u8) -> u8 {
|
||||
return ifx byte >= 65 && byte <= 90 then byte + cast(u8)32 else byte
|
||||
}
|
||||
|
||||
RegexReadAtom :: (pattern: string, at: s32, value: u8) -> RegexAtom {
|
||||
atom := RegexAtom.{.after = at + 1}
|
||||
byte := pattern[at]
|
||||
if byte == cast(u8)92 && at + 1 < pattern.count {
|
||||
atom.after += 1
|
||||
escaped := pattern[at + 1]
|
||||
atom.matches = ifx escaped == cast(u8)115 then value == 32 || value == 9 || value == 10 || value == 13 else RegexLower(escaped) == RegexLower(value)
|
||||
} else if byte == cast(u8)91 {
|
||||
cursor := at + 1
|
||||
while cursor < pattern.count && pattern[cursor] != cast(u8)93 {
|
||||
if RegexLower(pattern[cursor]) == RegexLower(value) {
|
||||
atom.matches = true
|
||||
}
|
||||
cursor += 1
|
||||
}
|
||||
atom.after = cursor + 1
|
||||
} else {
|
||||
atom.matches = byte == cast(u8)46 || RegexLower(byte) == RegexLower(value)
|
||||
}
|
||||
return atom
|
||||
}
|
||||
|
||||
RegexHere :: (pattern: string, at: s32, input: string, position: s32, budget: *s32) -> bool {
|
||||
budget.* -= 1
|
||||
if budget.* <= 0 {
|
||||
return false
|
||||
}
|
||||
if at >= pattern.count {
|
||||
return true
|
||||
}
|
||||
if pattern[at] == cast(u8)36 && at + 1 == pattern.count {
|
||||
return position == input.count
|
||||
}
|
||||
atom := RegexReadAtom(pattern, at, ifx position < input.count then input[position] else cast(u8)0)
|
||||
if atom.after > pattern.count {
|
||||
return false
|
||||
}
|
||||
quantifier := ifx atom.after < pattern.count then pattern[atom.after] else cast(u8)0
|
||||
if quantifier == 42 || quantifier == 43 || quantifier == 63 {
|
||||
minimum := ifx quantifier == 43 then 1 else 0
|
||||
maximum: s32 = 0
|
||||
while position + maximum < input.count &&
|
||||
RegexReadAtom(pattern, at, input[position + maximum]).matches {
|
||||
maximum += 1
|
||||
if quantifier == 63 {
|
||||
break
|
||||
}
|
||||
}
|
||||
while maximum >= minimum {
|
||||
if RegexHere(pattern, atom.after + 1, input, position + maximum, budget) {
|
||||
return true
|
||||
}
|
||||
maximum -= 1
|
||||
}
|
||||
return false
|
||||
}
|
||||
return position < input.count && atom.matches && RegexHere(pattern, atom.after, input, position + 1, budget)
|
||||
}
|
||||
|
||||
RegexMatch :: (pattern: string, input: string) -> bool {
|
||||
if pattern.count == 0 || pattern.count > 128 || input.count >= 1024 {
|
||||
return false
|
||||
}
|
||||
budget: s32 = 8192
|
||||
if pattern[0] == cast(u8)94 {
|
||||
return RegexHere(pattern, 1, input, 0, *budget)
|
||||
}
|
||||
for position: cast(s32)0..cast(s32)input.count {
|
||||
if RegexHere(pattern, 0, input, position, *budget) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# Changelog
|
||||
|
||||
## [1.1.5] - 2026-10-13
|
||||
|
||||
- Maintenance release for Inner Breeze 2.1.33.
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
## [1.1.4] - 2026-10-10
|
||||
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
## [1.1.3] - 2026-10-07
|
||||
|
||||
- Keep app labels and content visible after updating Inner Breeze.
|
||||
|
||||
## [1.1.2] - 2026-10-07
|
||||
|
||||
- Keep all four Sun Salutation characters and smooth movement in a smaller offline package.
|
||||
- Keep older installations on their working practice graphics until the app is upgraded.
|
||||
|
||||
## [1.1.1] - 2026-10-06
|
||||
|
||||
- Use Cells consistently in the cell and its independently delivered package.
|
||||
|
||||
## [1.1.0] - 2026-10-06
|
||||
|
||||
- Practice banners, characters and sounds now travel with Practices and update with its package.
|
||||
|
||||
## [1.0.0] - 2026-10-06
|
||||
|
||||
- First independently versioned Practices module.
|
||||
@@ -0,0 +1,69 @@
|
||||
// The live practice clocks run in this bundle; the unified host performs
|
||||
// audio, notification, session-save and mobile lifecycle effects.
|
||||
#import, file "../../src/cells/practice_types.zi";
|
||||
#import, file "../../src/core/breath_timing.zi";
|
||||
#import, file "../../src/practices/meditation/meditation_timing.zi";
|
||||
#import, file "../../src/practices/patterns/patterns_clock.zi";
|
||||
#import, file "../../src/cells/module_types.zi";
|
||||
#import, file "../../src/core/types.zi";
|
||||
#import, file "../../src/practices/sun_salutation/sun_salutation_rules.zi";
|
||||
host_api :: #system_library "host_api";
|
||||
ReadPracticeHost :: () -> PracticeMessage #foreign host_api;
|
||||
WritePracticeHost :: (message: PracticeMessage) #foreign host_api;
|
||||
SunSalutationStoredFrame :: (timeline_frame: s32) -> s32 #foreign host_api;
|
||||
|
||||
PracticeApply :: (message: PracticeMessage) -> PracticeMessage {
|
||||
message.succeeded = true
|
||||
if message.action == PRACTICE_ROUTE {
|
||||
message.succeeded = message.screen == ScreenStart || message.screen == ScreenSession ||
|
||||
message.screen == ScreenMeditation || message.screen == ScreenSunSalutation ||
|
||||
message.screen == ScreenPatterns || message.screen == ScreenResults ||
|
||||
message.screen == ScreenPracticeConfig || message.screen == ScreenManual
|
||||
return message
|
||||
}
|
||||
if message.paused {
|
||||
return message
|
||||
}
|
||||
if message.action == PRACTICE_BREATH_STEP {
|
||||
message.breathing = BreathSessionStep(message.breathing)
|
||||
message.completed = message.breathing.completed != 0
|
||||
} else if message.action == PRACTICE_MEDITATION_STEP {
|
||||
next := AdvanceMeditationTime(message.remaining_seconds,
|
||||
message.remainder_ms, message.elapsed_ms)
|
||||
message.remaining_seconds = next.remaining_seconds
|
||||
message.remainder_ms = next.remainder_ms
|
||||
message.elapsed_seconds = next.elapsed_seconds
|
||||
message.completed = next.completed
|
||||
} else if message.action == PRACTICE_SALUTATION_STEP {
|
||||
next := SalutationAdvance(message.salutation, message.elapsed)
|
||||
message.salutation = next.state
|
||||
message.completed = next.completed != 0
|
||||
} else if message.action == PRACTICE_PATTERNS_STEP {
|
||||
next := PatternsAdvance(message.patterns)
|
||||
message.patterns = next.state
|
||||
message.cue = next.cue
|
||||
message.completed = next.completed
|
||||
} else {
|
||||
message.succeeded = false
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
#program_export "PracticeMain"
|
||||
Main :: () -> s32 {
|
||||
message := ReadPracticeHost()
|
||||
if message.abi != MODULE_ABI {
|
||||
return -1
|
||||
}
|
||||
if message.action == MODULE_IDENTIFY {
|
||||
// The smaller frame inventory needs the wrapper's frame mapping.
|
||||
// Older wrappers reject this required capability before replacing
|
||||
// their working package.
|
||||
if SunSalutationStoredFrame(0) != 0 {
|
||||
return -1
|
||||
}
|
||||
return MODULE_PRACTICE
|
||||
}
|
||||
WritePracticeHost(PracticeApply(message))
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"key_id": "inbe-2026-10",
|
||||
"public_key": "d9a549043c0ac91a5197d85053a815c831d342a1082143c2bd1ffd43e1e6f145",
|
||||
"app_ids": [
|
||||
"inbe",
|
||||
"inbe.habits",
|
||||
"inbe.practices",
|
||||
"inbe.lists",
|
||||
"inbe.diary",
|
||||
"inbe.lumi",
|
||||
"inbe.leaderboard"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"host_api": 8,
|
||||
"oldest_host_api": 5,
|
||||
"module_api": 2,
|
||||
"apps": {
|
||||
"inbe": {
|
||||
"id": "inbe",
|
||||
"version": "2.1.30",
|
||||
"sequence": 27,
|
||||
"bundled": true,
|
||||
"host_api": 8
|
||||
},
|
||||
"habits": {
|
||||
"id": "inbe.habits",
|
||||
"version": "1.0.5",
|
||||
"sequence": 6,
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
},
|
||||
"practices": {
|
||||
"id": "inbe.practices",
|
||||
"version": "1.1.5",
|
||||
"sequence": 7,
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
},
|
||||
"lists": {
|
||||
"id": "inbe.lists",
|
||||
"version": "1.0.6",
|
||||
"sequence": 7,
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
},
|
||||
"diary": {
|
||||
"id": "inbe.diary",
|
||||
"version": "1.1.10",
|
||||
"sequence": 12,
|
||||
"bundled": true,
|
||||
"host_api": 7
|
||||
},
|
||||
"lumi": {
|
||||
"id": "inbe.lumi",
|
||||
"version": "1.4.0",
|
||||
"sequence": 17,
|
||||
"bundled": true,
|
||||
"host_api": 8
|
||||
},
|
||||
"leaderboard": {
|
||||
"id": "inbe.leaderboard",
|
||||
"version": "1.0.2",
|
||||
"sequence": 3,
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,3 +11,5 @@ abcdefghijklmnopqrstuvwxyz
|
||||
абвгдеёжзийклмнопрстуфхцчшщъыьэюя
|
||||
。,、!?:;()[]「」『』ー〜・
|
||||
中文简体繁體日本語한국어
|
||||
·—›
|
||||
+ −
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
↔ →
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 168 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
@@ -0,0 +1,6 @@
|
||||
Lumi's navigation glyph is an outlined firefly with antennae and wings.
|
||||
Its 1.6-unit rounded stroke in a 24-unit view box matches the app's navigation
|
||||
icons. sidebar.shape uses Kryon's vector icon format, so the sidebar applies
|
||||
the same size and foreground color as other buttons. sidebar.svg contains the
|
||||
same path; sidebar.png is its 64-pixel transparent export for navigation bars.
|
||||
The full-color conversation avatar remains mascot.png.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1 @@
|
||||
S1.6rr:M9 7C9 5 7.5 4 6 4M15 7C15 5 16.5 4 18 4M12 7C15 7 17 9 17 12C17 15 15 17 12 17C9 17 7 15 7 12C7 9 9 7 12 7ZM9.5 12L9.5 12.1M14.5 12L14.5 12.1M10 17C10 19 11 20 12 20C13 20 14 19 14 17M7 12C4 10 3 12 4 14C4.5 16 6 17 9 16M17 12C20 10 21 12 20 14C19.5 16 18 17 15 16
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<path fill="none" stroke="white" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" d="M9 7C9 5 7.5 4 6 4M15 7C15 5 16.5 4 18 4M12 7C15 7 17 9 17 12C17 15 15 17 12 17C9 17 7 15 7 12C7 9 9 7 12 7ZM9.5 12L9.5 12.1M14.5 12L14.5 12.1M10 17C10 19 11 20 12 20C13 20 14 19 14 17M7 12C4 10 3 12 4 14C4.5 16 6 17 9 16M17 12C20 10 21 12 20 14C19.5 16 18 17 15 16"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 441 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loaded 100 of 6003 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user