Update src/ai-repo-commander.user.js
New Command Delimiters ^%$bridge → @bridge@ (easier to type/remember) --- → @end@ (won't conflict with markdown horizontal rules!) Updated All Regex Patterns Command detection Block extraction Completion checking Fingerprinting Updated Test Commands All examples now use @bridge@ / @end@ Added example showing --- working inside content blocks New Command Format: yaml@bridge@ action: update_file repo: test-repo path: docs/README.md content: | # My Markdown This has a horizontal rule: --- No problem! The @end@ terminator is distinctive. body: Optional description @end@
This commit is contained in:
parent
d037173671
commit
9270695403
|
|
@ -1,8 +1,8 @@
|
|||
// ==UserScript==
|
||||
// @name AI Repo Commander
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 1.4.1
|
||||
// @description Execute ^%$bridge YAML commands from AI assistants (safe & robust): complete-block detection, streaming-settle, persistent dedupe, paste+autosubmit, debug console with Tools/Settings, draggable/collapsible panel
|
||||
// @version 1.5.0
|
||||
// @description Execute @bridge@ YAML commands from AI assistants (safe & robust): complete-block detection, streaming-settle, persistent dedupe, paste+autosubmit, debug console with Tools/Settings, draggable/collapsible panel
|
||||
// @author Your Name
|
||||
// @match https://chat.openai.com/*
|
||||
// @match https://chatgpt.com/*
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
// Timing & API
|
||||
DEBOUNCE_DELAY: 3000,
|
||||
MAX_RETRIES: 2,
|
||||
VERSION: '1.4.1',
|
||||
VERSION: '1.5.0',
|
||||
API_TIMEOUT_MS: 60000,
|
||||
|
||||
PROCESS_EXISTING: false,
|
||||
|
|
@ -583,11 +583,11 @@
|
|||
|
||||
// Extract the *command block* if present; else fall back to element text
|
||||
function _commandishText(el) {
|
||||
// Mirror parser's detector: require header, action, and '---'
|
||||
// Mirror parser's detector: require header, action, and '@end@'
|
||||
const blocks = el.querySelectorAll('pre code, pre, code');
|
||||
for (const b of blocks) {
|
||||
const t = _norm(b.textContent || '');
|
||||
if (/\n---\s*$/.test(t) && /(^|\n)\s*\^%\$bridge\b/m.test(t) && /(^|\n)\s*action\s*:/m.test(t)) {
|
||||
if (/@end@\s*$/m.test(t) && /(^|\n)\s*@bridge@\b/m.test(t) && /(^|\n)\s*action\s*:/m.test(t)) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
|
@ -1145,11 +1145,11 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
// ---------------------- Parser (strict, require ---) ----------------------
|
||||
// ---------------------- Parser (strict, require @end@) ----------------------
|
||||
class CommandParser {
|
||||
static parseYAMLCommand(codeBlockText) {
|
||||
const block = this.extractCompleteBlock(codeBlockText);
|
||||
if (!block) throw new Error('No complete ^%$bridge command found (missing --- terminator).');
|
||||
if (!block) throw new Error('No complete @bridge@ command found (missing @end@ terminator).');
|
||||
const parsed = this.parseKeyValuePairs(block);
|
||||
|
||||
// Defaults
|
||||
|
|
@ -1171,7 +1171,8 @@
|
|||
}
|
||||
|
||||
static extractCompleteBlock(text) {
|
||||
const pattern = /^\s*\^%\$bridge[ \t]*\n([\s\S]*?)\n---[ \t]*(?:\n|$)/m;
|
||||
// Require terminator @end@ (clearer than --- which appears in markdown)
|
||||
const pattern = /^\s*@bridge@[ \t]*\n([\s\S]*?)\n@end@[ \t]*(?:\n|$)/m;
|
||||
const m = text.match(pattern);
|
||||
if (!m) return null;
|
||||
const inner = m[1]?.trimEnd();
|
||||
|
|
@ -1603,10 +1604,10 @@
|
|||
}
|
||||
|
||||
isCompleteCommandText(txt) {
|
||||
if (!CONFIG.REQUIRE_TERMINATOR) return /(^|\n)\s*\^%\$bridge\b/m.test(txt) && /(^|\n)\s*action\s*:/m.test(txt);
|
||||
return /(^|\n)\s*\^%\$bridge\b/m.test(txt)
|
||||
if (!CONFIG.REQUIRE_TERMINATOR) return /(^|\n)\s*@bridge@\b/m.test(txt) && /(^|\n)\s*action\s*:/m.test(txt);
|
||||
return /(^|\n)\s*@bridge@\b/m.test(txt)
|
||||
&& /(^|\n)\s*action\s*:/m.test(txt)
|
||||
&& /(^|\n)---\s*$/.test(txt);
|
||||
&& /@end@\s*$/m.test(txt);
|
||||
}
|
||||
|
||||
findCommandInCodeBlock(el) {
|
||||
|
|
@ -2009,51 +2010,53 @@
|
|||
validUpdate:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: update_file
|
||||
repo: test-repo
|
||||
path: TEST.md
|
||||
content: |
|
||||
Test content
|
||||
Multiple lines
|
||||
---
|
||||
---
|
||||
Even markdown horizontal rules work!
|
||||
@end@
|
||||
\`\`\`
|
||||
`,
|
||||
getFile:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: get_file
|
||||
repo: test-repo
|
||||
path: README.md
|
||||
---
|
||||
@end@
|
||||
\`\`\`
|
||||
`,
|
||||
listFiles:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: list_files
|
||||
repo: test-repo
|
||||
path: .
|
||||
---
|
||||
@end@
|
||||
\`\`\`
|
||||
`,
|
||||
createBranch:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: create_branch
|
||||
repo: test-repo
|
||||
branch: feature/new-feature
|
||||
source_branch: main
|
||||
---
|
||||
@end@
|
||||
\`\`\`
|
||||
`,
|
||||
createPR:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: create_pr
|
||||
repo: test-repo
|
||||
title: Add new feature
|
||||
|
|
@ -2063,13 +2066,13 @@ body: |
|
|||
This PR adds a new feature
|
||||
- Item 1
|
||||
- Item 2
|
||||
---
|
||||
@end@
|
||||
\`\`\`
|
||||
`,
|
||||
createIssue:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: create_issue
|
||||
repo: test-repo
|
||||
title: Bug report
|
||||
|
|
@ -2078,25 +2081,25 @@ body: |
|
|||
Steps to reproduce:
|
||||
1. Step one
|
||||
2. Step two
|
||||
---
|
||||
@end@
|
||||
\`\`\`
|
||||
`,
|
||||
createTag:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: create_tag
|
||||
repo: test-repo
|
||||
tag: v1.0.0
|
||||
target: main
|
||||
message: Release version 1.0.0
|
||||
---
|
||||
@end@
|
||||
\`\`\`
|
||||
`,
|
||||
createRelease:
|
||||
`\
|
||||
\`\`\`yaml
|
||||
^%$bridge
|
||||
@bridge@
|
||||
action: create_release
|
||||
repo: test-repo
|
||||
tag_name: v1.0.0
|
||||
|
|
@ -2109,7 +2112,7 @@ body: |
|
|||
## Bug Fixes
|
||||
- Fix X
|
||||
- Fix Y
|
||||
---
|
||||
@end@
|
||||
\`\`\`
|
||||
`
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue