-
Notifications
You must be signed in to change notification settings - Fork 0
feat: /later command + workspace directory convention #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /** | ||
| * gateway/later-command.ts — Handle the /later command | ||
| * | ||
| * Quickly capture ideas/notes to ~/.roundhouse/workspace/later.md | ||
| * without interrupting the current conversation flow. | ||
| */ | ||
|
|
||
| import { homedir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { appendFileSync, mkdirSync, existsSync, readFileSync } from "node:fs"; | ||
|
|
||
| const WORKSPACE_DIR = join(homedir(), ".roundhouse", "workspace"); | ||
| const LATER_PATH = join(WORKSPACE_DIR, "later.md"); | ||
|
|
||
| export interface LaterCommandContext { | ||
| thread: any; | ||
| text: string; | ||
| postWithFallback: (thread: any, text: string) => Promise<void>; | ||
| } | ||
|
|
||
| function ensureWorkspace(): void { | ||
| if (!existsSync(WORKSPACE_DIR)) { | ||
| mkdirSync(WORKSPACE_DIR, { recursive: true }); | ||
| } | ||
| } | ||
|
|
||
| function ensureLaterFile(): void { | ||
| ensureWorkspace(); | ||
| if (!existsSync(LATER_PATH)) { | ||
| appendFileSync(LATER_PATH, "# Later\n\nIdeas, reminders, and things to get back to.\n\n"); | ||
| } | ||
| } | ||
|
|
||
| export async function handleLater(ctx: LaterCommandContext): Promise<void> { | ||
| const { thread, text, postWithFallback } = ctx; | ||
| const idea = text.replace(/^\/later\s*/i, "").trim(); | ||
|
|
||
| // No argument: show contents | ||
| if (!idea) { | ||
| ensureLaterFile(); | ||
| const contents = readFileSync(LATER_PATH, "utf8").trim(); | ||
| const lines = contents.split("\n").filter(l => l.startsWith("- ")); | ||
| if (lines.length === 0) { | ||
| await postWithFallback(thread, "📋 *Later list is empty.*\n\n_Usage:_ `/later buy more coffee`"); | ||
| } else { | ||
| await postWithFallback(thread, `📋 *Later* (${lines.length} items):\n\n${lines.join("\n")}\n\n_File:_ \`~/.roundhouse/workspace/later.md\``); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // Append the idea | ||
| ensureLaterFile(); | ||
| const timestamp = new Date().toISOString().slice(0, 10); | ||
| appendFileSync(LATER_PATH, `- ${idea} _(${timestamp})_\n`); | ||
|
|
||
| await postWithFallback(thread, `✅ Saved: "${idea}"`); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea extraction regex only strips
/laterfollowed by whitespace, so Telegram group-style commands like/later@MyBotor/later@MyBot buy milkare parsed incorrectly: the first case is treated as a new idea@MyBotinstead of showing the list, and the second saves@MyBot buy milkinstead of just the note text. Since command routing already accepts@botnamevariants, this handler should strip the optional@...suffix as part of command parsing to avoid corrupting saved entries in group chats.Useful? React with 👍 / 👎.