Repository navigation
feat: implement /loop command with fixed and dynamic scheduling #621
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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ae59e3a
feat: implement /loop command with fixed and dynamic scheduling modes
khaledmoayad dafec9d
chore: remove unused DEFAULT_INTERVAL constant from loop skill
khaledmoayad d8708a6
revert: drop infra changes, scope PR to /loop skill rewrite only
khaledmoayad fd32e09
fix: restore infra changes needed for /loop in open build
khaledmoayad 27ee05c
fix: replace backslash line continuations with explicit delimiters in…
khaledmoayad 6cfb665
fix: remove remaining AGENT_TRIGGERS guards from print.ts and constan…
khaledmoayad 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
Some comments aren't visible on the classic Files Changed page.
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
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
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,125 @@ | ||
| import { afterEach, expect, test } from 'bun:test' | ||
|
|
||
| import { clearBundledSkills, getBundledSkills } from '../bundledSkills.js' | ||
| import { registerLoopSkill } from './loop.js' | ||
|
|
||
| afterEach(() => { | ||
| clearBundledSkills() | ||
| }) | ||
|
|
||
| test('bare /loop returns dynamic maintenance instructions', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| expect(skill).toBeDefined() | ||
| expect(skill?.type).toBe('prompt') | ||
|
|
||
| const blocks = await skill!.getPromptForCommand('', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — dynamic rescheduling') | ||
| expect(text).toContain('If .claude/loop.md exists, read it and use it.') | ||
| expect(text).toContain('continue any unfinished work from the conversation') | ||
| expect(text).toContain('Set the scheduled prompt to this exact text so the next iteration stays in dynamic mode:') | ||
| expect(text).toContain('/loop') | ||
| }) | ||
|
|
||
| test('prompt-only /loop returns dynamic rescheduling instructions', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('check the deploy', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — dynamic rescheduling') | ||
| expect(text).toContain('check the deploy') | ||
| expect(text).toContain('choose the next delay dynamically between 1 minute and 1 hour') | ||
| expect(text).toContain('/loop check the deploy') | ||
| }) | ||
|
|
||
| test('interval /loop returns fixed recurring instructions', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('5m check the deploy', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — fixed recurring interval') | ||
| expect(text).toContain('Requested interval:') | ||
| expect(text).toContain('5m') | ||
| expect(text).toContain('Call CronCreate') | ||
| expect(text).toContain('recurring: true') | ||
| expect(text).toContain('Immediately execute the effective prompt now') | ||
| }) | ||
|
|
||
| test('interval-only /loop becomes fixed maintenance mode', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('15m', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — fixed recurring interval') | ||
| expect(text).toContain('15m') | ||
| expect(text).toContain('This is a maintenance loop with no explicit prompt.') | ||
| expect(text).toContain('Scheduled maintenance loop iteration.') | ||
| }) | ||
|
|
||
| test('trailing every clause parses interval and prompt', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('check the deploy every 20m', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — fixed recurring interval') | ||
| expect(text).toContain('20m') | ||
| expect(text).toContain('check the deploy') | ||
| }) | ||
|
|
||
| test('trailing every clause with word unit parses correctly', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('run tests every 5 minutes', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — fixed recurring interval') | ||
| expect(text).toContain('5m') | ||
| expect(text).toContain('run tests') | ||
| }) | ||
|
|
||
| test('"check every PR" is not treated as an interval', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('check every PR', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — dynamic rescheduling') | ||
| expect(text).toContain('check every PR') | ||
| }) | ||
|
|
||
| test('human-readable hour unit parses correctly', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('2h check logs', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('# /loop — fixed recurring interval') | ||
| expect(text).toContain('2h') | ||
| expect(text).toContain('check logs') | ||
| }) | ||
|
|
||
| test('prompt delimiters are present and unambiguous', async () => { | ||
| registerLoopSkill() | ||
|
|
||
| const skill = getBundledSkills().find(command => command.name === 'loop') | ||
| const blocks = await skill!.getPromptForCommand('5m say hi', {} as never) | ||
| const text = (blocks[0] as { text: string }).text | ||
|
|
||
| expect(text).toContain('--- BEGIN PROMPT ---') | ||
| expect(text).toContain('say hi') | ||
| expect(text).toContain('--- END PROMPT ---') | ||
| }) | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.