You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created this chat prompt and slash command pair:
chat prompt
["Standup"] = {
strategy="chat",
description="Generate a standup update based on Logseq notes and recent file changes",
opts= {
is_default=false,
short_name="su",
},
prompts= {
{
role=config.constants.SYSTEM_ROLE,
content="This is actually a long blurb about how to look at Logseq files and format them into a standup update.",
opts= {
visible=true,
},
},
{
role=config.constants.USER_ROLE,
content="/changed_files",
},
},
},
slash command
["changed_files"] = {
description="List all files changed in the last N days in journals and pages folders",
---@paramchatCodeCompanion.Chatcallback=function(chat)
localdays_input=""localdays=nil-- Keep asking until we get a valid numberwhiletruedodays_input=vim.fn.input("How many days ago was the last standup? (Enter a number): ")
days=tonumber(days_input)
ifdaysanddays>0thenbreakendvim.notify("Please enter a valid positive number", vim.log.levels.WARN)
end-- Calculate the cutoff date (N days ago)localcutoff_time=os.time() - (days*86400)
localcutoff_date=os.date("%Y-%m-%d", cutoff_time)
-- Get recently modified fileslocalall_files=get_recently_modified_files(days)
localfiles_list= {}
localjournal_files= {}
localpage_files= {}
-- Function to extract date from journal filename (assuming format like YYYY_MM_DD.md)localfunctionextract_date_from_filename(filename)
localyear, month, day=filename:match("(%d%d%d%d)_(%d%d)_(%d%d)")
ifyearandmonthanddaythenreturnyear.."-" ..month.."-" ..dayendreturnnilend-- Filter for journals and pages folders, but include all modified filesfor_, fileinipairs(all_files) doiffile:match("/journals/") thentable.insert(journal_files, file)
table.insert(files_list, file)
elseiffile:match("/pages/") thentable.insert(page_files, file)
table.insert(files_list, file)
endend-- Create a message first to ensure the chat is initializedlocalmessage="# Standup Update Request\n\n".."Current date and time: "..vim.fn.strftime("%c")
.."\n".."Last standup: "..days.." days ago (on "..cutoff_date..")\n\n".."**CRITICAL INSTRUCTION:** Only include information from after "..cutoff_date.." in your standup update.\n".."**DO NOT** include any work or tasks from before this date, even if the files were recently modified.\n\n".."I've provided "..#files_list.." Logseq files that were modified recently, but you must filter the content based on dates."-- Add references for changed files after a short delayvim.defer_fn(function()
if#files_list>0then-- Create a summary of changed fileslocalfiles_summary="# Logseq files changed in the last "..days.." days (since "..cutoff_date.."):\n\n"files_summary=files_summary.."## Journal Files:\n\n"for_, fileinipairs(journal_files) dolocalfilename=file:match("([^/]+)$")
localfile_date=extract_date_from_filename(filename) or"Unknown date"-- Note whether the journal file is from before or after the cutofflocaldate_note=""iffile_datetheniffile_date>=cutoff_datethendate_note=" (after standup)"elsedate_note=" (before standup - check for relevant date references inside)"endendfiles_summary=files_summary.."- " ..filename.." (" ..file_date..")" ..date_note.."\n"-- Try to get file content and add as referencelocalf=io.open(file, "r")
iffthenlocalcontent=f:read("*all")
f:close()
ifcontentandcontent~="" thenchat:add_reference({
role="user",
content="# Journal: " ..file_date.."\n\n" ..content,
}, "journal", filename)
endendendfiles_summary=files_summary.."\n## Page Files:\n\n"for_, fileinipairs(page_files) dolocalfilename=file:match("([^/]+)$")
files_summary=files_summary.."- "..filename.." (check for relevant date references inside)\n"-- Try to get file content and add as referencelocalf=io.open(file, "r")
iffthenlocalcontent=f:read("*all")
f:close()
ifcontentandcontent~="" thenchat:add_reference({
role="user",
content="# Page: " ..filename.."\n\n" ..content,
}, "page", filename)
endendendchat:add_reference({
role="user",
content=files_summary,
}, "summary", "changed_files_summary")
-- Add explicit filtering instructionschat:add_reference({
role="user",
content="# IMPORTANT FILTERING INSTRUCTIONS\n\n".."Today's date: "..os.date("%Y-%m-%d")
.."\n".."Last standup date: "..cutoff_date.."\n\n".."1. ONLY include work done AFTER "..cutoff_date.."\n".."2. ONLY include tasks planned for today ("..os.date("%Y-%m-%d")
..") or future dates\n".."3. For files dated before "..cutoff_date..", scan for content that explicitly references dates after "..cutoff_date.."\n".."4. If you're unsure about when something was done, DO NOT include it\n\n".."It is better to provide an incomplete standup than to include outdated information.",
}, "instructions", "filtering_requirements")
-- Notify user that references were addedvim.notify("Added " ..#files_list.." Logseq file references to the chat", vim.log.levels.INFO)
elsevim.notify("No recently modified Logseq files found", vim.log.levels.INFO)
endend, 500) -- 500ms delay to ensure chat is initializedreturnmessageend,
},
The second part of my chat prompt (/changed_files) is a hack because I can't figure out how to add chat references from either chat or workflow prompts. I backspace and then autocomplete the slash command, which gives me the references I'm looking for. Is there a way to automate this? I'd like to be asked how many days since the last standup, but other than that I'd like it to be an automatic workflow.
By the way, I asked Claude to generate the slash command for me. I'm very new to Code Companion, so if you have any recommendations about better ways to do any of this, I'd love to hear them!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I've created this chat prompt and slash command pair:
chat prompt
slash command
The second part of my chat prompt (
/changed_files
) is a hack because I can't figure out how to add chat references from either chat or workflow prompts. I backspace and then autocomplete the slash command, which gives me the references I'm looking for. Is there a way to automate this? I'd like to be asked how many days since the last standup, but other than that I'd like it to be an automatic workflow.By the way, I asked Claude to generate the slash command for me. I'm very new to Code Companion, so if you have any recommendations about better ways to do any of this, I'd love to hear them!
Beta Was this translation helpful? Give feedback.
All reactions