>>107782460
import {
tool run_command(cmd : string);
tool write_file(path : string, content : string);
tool show_mdfile_to_user(path : string);
}
function main() {
switch(prompt) {
case "request related to local files" {
doLocalFileTask();
}
case "not local files task" {
return "answer" - tools;
}
}
}
function doLocalFileTask() {
// "local" keyword: reference to something exist in current context
local string plan = makePlanFile();
$"show plan file to user";
// new context object, uninvolved with current context
// after this line, this new context object will only know about the plan (file path and content)
new ctx plan_progress_checker = plan;
// use "new" so that AI context won't know about "tasks" object
new list<string> tasks = $"get task list from plan";
// loop keyword: all iteration added to context
loop foreach (var task in tasks) {
$"do task: {task}";
plan_progress_checker$"update to planning file: task {task} completed";
}
// silence: nothing added to context
silence while (verify() as issues) {
loop foreach (var issue in issues) {
$"fix issue: {issue}";
}
}
$"clear planning file";
}
function makePlanFile() {
run_command(/*some hard code cmd to check local files..*/);
$"write plan to a new md file with approriate name"
return format<"plan file : {%string}, plan : {%string}">("path of planfile and the plan content");
}
function verify() -> list<string>? {
$"check if user request sastified: only check for hard error, runtime error, etc";
return "list of problems";
}