-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: add Easy Code as a supported AI tool #1352
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
Open
redknox
wants to merge
3
commits into
Fission-AI:main
Choose a base branch
from
redknox:add-easycode-tool
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * Easy Code Command Adapter | ||
| * | ||
| * Formats commands for Easy Code using TOML format. | ||
| * Easy Code stores commands as TOML files at .easycode/commands/opsx/<id>.toml | ||
| */ | ||
|
|
||
| import path from 'path'; | ||
| import type { CommandContent, ToolCommandAdapter } from '../types.js'; | ||
| import { escapeTOMLBasicString, escapeTOMLMultilineString } from '../toml.js'; | ||
|
|
||
| /** | ||
| * Easy Code adapter for command generation. | ||
| * File path: .easycode/commands/opsx/<id>.toml | ||
| * | ||
| * Format: | ||
| * description = "<basic-string>" single-line, backslash/quote-safe | ||
| * prompt = """<multiline-string>""" multiline, backslash/triple-quote-safe | ||
| */ | ||
| export const easycodeAdapter: ToolCommandAdapter = { | ||
| toolId: 'easycode', | ||
|
|
||
| getFilePath(commandId: string): string { | ||
| return path.join('.easycode', 'commands', 'opsx', `${commandId}.toml`); | ||
| }, | ||
|
|
||
| formatFile(content: CommandContent): string { | ||
| const safeDesc = escapeTOMLBasicString(content.description); | ||
| const safeBody = escapeTOMLMultilineString(content.body); | ||
| return `description = "${safeDesc}"\n\nprompt = """\n${safeBody}\n"""\n`; | ||
| }, | ||
| }; |
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,73 @@ | ||
| /** | ||
| * Shared TOML serialization helpers for command adapters. | ||
| * | ||
| * Easy Code commands are stored as TOML files. This module provides | ||
| * safe serialization for TOML string values so generated files stay | ||
| * valid regardless of the content being embedded. | ||
| */ | ||
|
|
||
| /** | ||
| * Replaces disallowed control characters with TOML \uXXXX escape sequences. | ||
| * | ||
| * TOML basic strings forbid U+0000–U+0008, U+000B–U+000C, U+000E–U+001F, and | ||
| * U+007F. The caller is expected to have already handled \t (U+0009), \n | ||
| * (U+000A), and \r (U+000D) via their named escape sequences before calling | ||
| * this helper. | ||
| */ | ||
| function escapeControlChars(value: string): string { | ||
| return value.replace( | ||
| /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, | ||
| (ch) => `\\u${ch.codePointAt(0)!.toString(16).padStart(4, '0')}` | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Escapes a string for use as a TOML basic string (double-quoted). | ||
| * | ||
| * TOML basic strings support the following escape sequences: | ||
| * \\\\ backslash, \\" double quote, \\n line feed, \\r carriage return, \\t tab. | ||
| * All other control characters (U+0000–U+0008, U+000B–U+000C, U+000E–U+001F, | ||
| * U+007F) are replaced with \\uXXXX unicode escape sequences. | ||
| * | ||
| * @param value - The raw string to embed in a TOML basic string. | ||
| * @returns The escaped string, suitable for wrapping in double quotes. | ||
| */ | ||
| export function escapeTOMLBasicString(value: string): string { | ||
| return escapeControlChars( | ||
| value | ||
| .replace(/\\/g, '\\\\') | ||
| .replace(/"/g, '\\"') | ||
| .replace(/\n/g, '\\n') | ||
| .replace(/\r/g, '\\r') | ||
| .replace(/\t/g, '\\t') | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Prepares a string for use as a TOML basic multiline string (triple double-quoted). | ||
| * | ||
| * TOML basic multiline strings support the same escape sequences as basic strings. | ||
| * We use them instead of literal multiline strings (triple single-quoted) because | ||
| * literal strings cannot escape anything — a literal ''' would close the block. | ||
| * | ||
| * Inside a basic multiline string: | ||
| * - backslashes must be escaped first | ||
| * - runs of 3+ consecutive double quotes would close the block; we escape the | ||
| * first quote in each triple to break the run | ||
| * - newlines are preserved verbatim (TOML allows real newlines in multiline strings) | ||
| * All other control characters (U+0000–U+0008, U+000B–U+000C, U+000E–U+001F, | ||
| * U+007F) are replaced with \\uXXXX unicode escape sequences. | ||
| * | ||
| * @param value - The raw multiline string to embed. | ||
| * @returns The escaped string, suitable for wrapping in triple double quotes. | ||
| */ | ||
| export function escapeTOMLMultilineString(value: string): string { | ||
| return escapeControlChars( | ||
| value | ||
| .replace(/\\/g, '\\\\') | ||
| .replace(/\r/g, '\\r') | ||
| // Escape the first quote in any run of 3+ consecutive double quotes | ||
| // so they cannot prematurely close the triple-double-quote block. | ||
| .replace(/"(?="")/g, '\\"') | ||
| ); | ||
| } | ||
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
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.