Chronos executes .chs scripts with one command per line. Lines support quoted arguments, key:value properties, and variable expansion.
- Set a variable:
set var name:World - Use in any command:
echo Hello @nameorecho Hello @{name} - Escape a literal
@: use@@ - Scope: Variables persist for the duration of the current console session or script execution.
- Inspect and remove:
vars— lists variablesvars name:foo— prints a single varunset var foo— removes a var
- Any
key:valuetokens are parsed as properties and passed to commands (e.g.,priority:high). - Quote values with spaces:
category:"deep work". - Detection rule: a token is treated as a property only if the key starts with a letter and the key contains letters, digits, or underscores. This avoids mis-parsing Windows paths like
C:\Work\file.txtas properties.
Two forms are supported:
- Single-line:
if <left> <op> <right> then <command> [args...] [else <command> ...] - Block (.chs):
if <left> <op> <right> then <command> elseif <left> <op> <right> then <command> else <command> end
- Operators:
= != > < >= <= eq ne gt lt ge le matches(regex) - Logic:
and or xor nor not ! - Parentheses for grouping:
( ... ) - Precedence:
not/!>and>or/xor/nor
- Status:
status:<key>reads fromuser/current_status.yml - Status history snapshots append to
user/logs/status_YYYY-MM-DD.yml - Items:
<type>:<name>:<property>(e.g.,task:"Deep Work":priority) - Existence checks:
- Items:
exists <type>:<name>[:<property>](e.g.,exists task:"My Task":due_date) - Filesystem:
exists file:<path>,exists dir:<path>(relative to project root if not absolute) - Environment:
exists env:<NAME>
- Items:
- Literals and
@varsare allowed on either side of operators.
set var who:Alice
create note "IF Note @who" category:work priority:high
if exists note:"IF Note @who" then echo FOUND else echo MISSING
if status:energy eq high and exists env:PATH then echo READY
if note:"IF Note @who":priority matches ^h.* then echo STARTS_WITH_H
if ( status:energy eq high and exists note:"IF Note @who" ) or status:emotion ne sad then echo OK
if status:energy eq high then
echo Outer TRUE
if exists note:"IF Note @who" then
echo Nested FOUND
else
echo Nested MISSING
end
else
echo Outer FALSE
end
Loops are bounded and available in .chs scripts. Each loop exposes @i as a
1-based index during iteration.
repeat count:3 then
echo Pass @i
end
Iterates items and sets @<var> (item name) and @<var>_type (item type).
for item in tasks status:pending then
echo @item
end
Requires a max to prevent infinite loops.
while status:energy eq high max:3 then
echo Still high @i
end
- Single-line and block
ifreport concise parse errors. - In
.chsfiles, errors include the line number for easier debugging.