mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-01 08:59:32 +01:00
feat: auto-detect completion phrase from CLAUDE.md
- Extract <promise>PHRASE</promise> from CLAUDE.md on session start - Configure inner loop tracker before first broadcast so UI shows phrase immediately - More lenient bare phrase detection (triggers when loop is active) - Auto-detect on session restoration from screens - Add logging for auto-detection debugging Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e469b30ddb
commit
403c7e77fb
4 files changed
+115
-9
No files matched your search
@@ -786,14 +786,14 @@ export class InnerLoopTracker extends EventEmitter {
|
||||
// If we have an expected completion phrase, also check for bare phrase
|
||||
// This handles cases where Claude outputs "ALL_TASKS_DONE" without the tags
|
||||
const expectedPhrase = this._loopState.completionPhrase;
|
||||
if (expectedPhrase && line.includes(expectedPhrase)) {
|
||||
// Avoid false positives: don't trigger on the original prompt echo
|
||||
// Only trigger if line looks like completion output (standalone or at end)
|
||||
const isStandalone = line.trim() === expectedPhrase;
|
||||
const isAtEnd = line.trim().endsWith(expectedPhrase);
|
||||
if (expectedPhrase && line.toUpperCase().includes(expectedPhrase.toUpperCase())) {
|
||||
// Avoid false positives: don't trigger on prompt context
|
||||
const isNotInPromptContext = !line.includes('<promise>') && !line.includes('output:');
|
||||
// Also avoid triggering on "completion phrase is X" explanatory text
|
||||
const isNotExplanation = !line.toLowerCase().includes('completion phrase') &&
|
||||
!line.toLowerCase().includes('output exactly');
|
||||
|
||||
if ((isStandalone || isAtEnd) && isNotInPromptContext) {
|
||||
if (isNotInPromptContext && isNotExplanation) {
|
||||
this.handleBareCompletionPhrase(expectedPhrase);
|
||||
}
|
||||
}
|
||||
@@ -817,9 +817,13 @@ export class InnerLoopTracker extends EventEmitter {
|
||||
* @fires loopUpdate - When loop state changes
|
||||
*/
|
||||
private handleBareCompletionPhrase(phrase: string): void {
|
||||
// Only count if this phrase was already seen in tagged form (from the prompt)
|
||||
// Allow bare phrase detection if:
|
||||
// 1. Loop is explicitly active (via startLoop()) - phrase was set programmatically
|
||||
// 2. OR phrase was seen in tagged form (from terminal output)
|
||||
const taggedCount = this._completionPhraseCount.get(phrase) || 0;
|
||||
if (taggedCount === 0) return;
|
||||
const loopExplicitlyActive = this._loopState.active;
|
||||
|
||||
if (taggedCount === 0 && !loopExplicitlyActive) return;
|
||||
|
||||
// Track bare occurrences to avoid double-firing
|
||||
const bareKey = `bare:${phrase}`;
|
||||
|
||||
Reference in new issue
Block a user