diff --git a/ts/CONFIGURATION_AND_PERSISTENCE.md b/ts/CONFIGURATION_AND_PERSISTENCE.md index c25bc7e13..43afc20a2 100644 --- a/ts/CONFIGURATION_AND_PERSISTENCE.md +++ b/ts/CONFIGURATION_AND_PERSISTENCE.md @@ -171,14 +171,14 @@ The `dynamic.json` file contains all dynamically learned rules: "schemas": { "player": [ { - "grammarText": "@ = \"play\" $(trackName:string) \"by\" $(artistName:string)", + "grammarText": " = \"play\" $(trackName:string) \"by\" $(artistName:string)", "timestamp": 1737850800000, "sourceRequest": "play Bohemian Rhapsody by Queen", "actionName": "playTrack", "schemaName": "player" }, { - "grammarText": "@ = \"pause\" (\"the\")? (\"music\")?", + "grammarText": " = \"pause\" (\"the\")? (\"music\")?", "timestamp": 1737850900000, "sourceRequest": "pause music", "actionName": "pause", @@ -187,7 +187,7 @@ The `dynamic.json` file contains all dynamically learned rules: ], "calendar": [ { - "grammarText": "@ = \"schedule\" $(event:string) $(time:CalendarTime)", + "grammarText": " = \"schedule\" $(event:string) $(time:CalendarTime)", "timestamp": 1737851000000, "sourceRequest": "schedule meeting tomorrow at 2pm", "actionName": "scheduleEvent", @@ -212,7 +212,7 @@ await store.setAutoSave(true); // Add a new rule (auto-saves if enabled) await store.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", sourceRequest: "play music", actionName: "playTrack", diff --git a/ts/extensions/agr-language/OVERVIEW.md b/ts/extensions/agr-language/OVERVIEW.md index a1f5bf6b5..02009ff52 100644 --- a/ts/extensions/agr-language/OVERVIEW.md +++ b/ts/extensions/agr-language/OVERVIEW.md @@ -24,11 +24,12 @@ extensions/agr-language/ ### 1. Syntax Elements Highlighted -- **Rule Definitions**: `@ = ...` +- **Rule Definitions**: ` = ...;` - - `@` operator in keyword color - Rule names in type color - Assignment operator `=` highlighted + - Semicolon terminator `;` highlighted + - Multi-line rules supported (span from `=` to `;`) - **Rule References**: `` @@ -74,13 +75,19 @@ The grammar uses a repository-based pattern system: "scopeName": "source.agr", "patterns": [ { "include": "#comments" }, + { "include": "#import-statement" }, { "include": "#rule-definition" }, { "include": "#action-object" } ], "repository": { - "rule-definition": { ... }, + "rule-definition": { + "begin": "^\\s*(<)([A-Za-z_][A-Za-z0-9_]*)(>)\\s*(=)", + "end": "(;)|(?=^\\s*<[A-Za-z_]|^\\s*//|^\\s*import\\b|\\z)", + "..." + }, "capture": { ... }, "rule-reference": { ... }, + "import-statement": { ... }, ... } } @@ -90,9 +97,10 @@ The grammar uses a repository-based pattern system: Uses standard TextMate scope names for compatibility with all VS Code themes: -- `keyword.operator.rule.agr` - Rule operators -- `entity.name.type.rule.agr` - Rule names -- `variable.parameter.capture.agr` - Capture variables +- `entity.name.type.rule.agr` - Rule names in definitions +- `entity.name.type.rule-reference.agr` - Rule names in references +- `punctuation.terminator.statement.agr` - Rule-ending semicolons +- `variable.other.agr` - Capture variable names - `comment.line.double-slash.agr` - Comments - `meta.embedded.block.javascript` - Embedded JS in action objects @@ -116,7 +124,7 @@ Test file: [playerSchema.agr](../../packages/agents/player/src/agent/playerSchem Expected highlighting: - Green/gray comments -- Colorized rule names in `@ ` +- Colorized rule names in ` = ...;` - Distinct colors for captures `$(name:Type)` - Blue/purple keywords for operators - JS syntax in action objects diff --git a/ts/extensions/agr-language/README.md b/ts/extensions/agr-language/README.md index b0dee1e15..9ef92c41e 100644 --- a/ts/extensions/agr-language/README.md +++ b/ts/extensions/agr-language/README.md @@ -9,7 +9,7 @@ Syntax highlighting for Action Grammar (.agr) files used in TypeAgent. - Syntax highlighting for AGR grammar rules - Comment support (`//`) -- Rule definition highlighting (`@ = ...`) +- Rule definition highlighting (` = ...;`) - Rule reference highlighting (``) - Capture syntax highlighting (`$(name:Type)` and `$(name)`) - Action object highlighting with embedded JavaScript syntax @@ -21,7 +21,7 @@ Syntax highlighting for Action Grammar (.agr) files used in TypeAgent. ### Rule Definitions ```agr -@ = pattern1 | pattern2 + = pattern1 | pattern2; ``` ### Captures diff --git a/ts/extensions/agr-language/sample.agr b/ts/extensions/agr-language/sample.agr index 3d54cbe91..edf45f776 100644 --- a/ts/extensions/agr-language/sample.agr +++ b/ts/extensions/agr-language/sample.agr @@ -5,24 +5,24 @@ // This file shows all the major syntax elements // Import syntax -@import { Cardinal, TrackName, ArtistName } from "./base.agr" -@import * from "./shared.agr" +import { Cardinal, TrackName, ArtistName } from "./base.agr"; +import * from "./shared.agr"; // Simple rule definition -@ = | + = | ; // Rule with captures and types -@ = + = hello $(name:PersonName) -> { actionName: "greet", parameters: { name } } - | hi there -> { actionName: "greet" } + | hi there -> { actionName: "greet" }; // Rule with optional elements -@ = + = play (the)? $(track:TrackName) by $(artist:ArtistName) -> { actionName: "playTrack", @@ -31,71 +31,71 @@ artists: [artist] } } - | pause (the)? music? -> { actionName: "pause" } + | pause (the)? music? -> { actionName: "pause" }; // Rule with multiple patterns -@ = + = (turn | set) (the)? volume to $(level:number) -> { actionName: "setVolume", parameters: { level } } | volume up -> { actionName: "volumeUp" } - | volume down -> { actionName: "volumeDown" } + | volume down -> { actionName: "volumeDown" }; // Bare -> results (non-object): string literal, number, or variable reference -@ = ( + = ( ('ask me' | 'confirm' | 'please confirm') -> "true" | ("don't ask" | 'without asking' | 'skip') -> "false" -) +); -@ = ( + = ( 'by query' $(userQuery:string) -> userQuery | 'by category' $(category:string) -> category | 'all' -> "all" -) +); // Numeric patterns -@ = + = $(x:number) | one -> 1 | two -> 2 | three -> 3 | four -> 4 - | five -> 5 + | five -> 5; // String type references -@ = $(x:string) -@ = $(x:string) -@ = $(x:string) + = $(x:string); + = $(x:string); + = $(x:string); // Complex nested rule -@ = - | | + = + | | ; -@ = + = play track $(n:) -> { actionName: "playTrackNumber", parameters: { trackNumber: n, source: "current" } - } + }; -@ = + = play (the)? album $(album:) -> { actionName: "playAlbum", parameters: { albumName: album } - } + }; -@ = + = play music by $(artist:) -> { actionName: "playArtist", parameters: { artistName: artist } - } + }; -@ = $(x:string) + = $(x:string); // Operators demonstration -@ = + = one? two* three+ four // optional, zero-or-more, one-or-more - | (first | second | third) // alternation with grouping + | (first | second | third) // alternation with grouping; diff --git a/ts/extensions/agr-language/syntaxes/agr.tmLanguage.json b/ts/extensions/agr-language/syntaxes/agr.tmLanguage.json index 3cfca3a99..c06c10a95 100644 --- a/ts/extensions/agr-language/syntaxes/agr.tmLanguage.json +++ b/ts/extensions/agr-language/syntaxes/agr.tmLanguage.json @@ -18,12 +18,14 @@ "import-statement": { "patterns": [ { - "comment": "Named import: @import { RuleA, RuleB } from './path.agr'", - "begin": "^\\s*(@)(import)\\b", - "end": "(?=$|//)", + "comment": "Named import: import { RuleA, RuleB } from './path.agr';", + "begin": "^\\s*(import)\\b", + "end": "(;)|(?=$|//)", "beginCaptures": { - "1": { "name": "keyword.operator.rule.agr" }, - "2": { "name": "keyword.control.import.agr" } + "1": { "name": "keyword.control.import.agr" } + }, + "endCaptures": { + "1": { "name": "punctuation.terminator.statement.agr" } }, "patterns": [ { @@ -50,14 +52,16 @@ "rule-definition": { "patterns": [ { - "begin": "^\\s*(@)\\s*(<)([A-Za-z_][A-Za-z0-9_]*)(>)\\s*(=)", - "end": "(?=^\\s*@|^\\s*//|\\z)", + "begin": "^\\s*(<)([A-Za-z_][A-Za-z0-9_]*)(>)\\s*(=)", + "end": "(;)|(?=^\\s*<[A-Za-z_]|^\\s*//|^\\s*import\\b|\\z)", "beginCaptures": { - "1": { "name": "keyword.operator.rule.agr" }, - "2": { "name": "punctuation.definition.rule-name.begin.agr" }, - "3": { "name": "entity.name.type.rule.agr" }, - "4": { "name": "punctuation.definition.rule-name.end.agr" }, - "5": { "name": "keyword.operator.assignment.agr" } + "1": { "name": "punctuation.definition.rule-name.begin.agr" }, + "2": { "name": "entity.name.type.rule.agr" }, + "3": { "name": "punctuation.definition.rule-name.end.agr" }, + "4": { "name": "keyword.operator.assignment.agr" } + }, + "endCaptures": { + "1": { "name": "punctuation.terminator.statement.agr" } }, "patterns": [{ "include": "#rule-body" }] } diff --git a/ts/packages/actionGrammar/DYNAMIC_LOADING.md b/ts/packages/actionGrammar/DYNAMIC_LOADING.md index 3e0e18a33..d2a011f9a 100644 --- a/ts/packages/actionGrammar/DYNAMIC_LOADING.md +++ b/ts/packages/actionGrammar/DYNAMIC_LOADING.md @@ -61,7 +61,7 @@ const baseNFA = compileGrammarToNFA(baseGrammar, "base"); const cache = new DynamicGrammarCache(baseGrammar, baseNFA); // Add generated rule dynamically -const generatedRule = `@ = play $(track:string) by $(artist:string)`; +const generatedRule = ` = play $(track:string) by $(artist:string);`; const result = cache.addRules(generatedRule); if (result.success) { @@ -129,7 +129,7 @@ Before loading, the system validates that all referenced symbols are resolved: const loader = new DynamicGrammarLoader(); // Rule references CalendarDate symbol -const rule = `@ = schedule $(event:string) on $(date:CalendarDate)`; +const rule = ` = schedule $(event:string) on $(date:CalendarDate);`; const result = loader.load(rule); @@ -185,10 +185,10 @@ When multiple rules target the same action, they become alternatives: const cache = new DynamicGrammarCache(baseGrammar, baseNFA); // Add first play pattern -cache.addRules(`@ = play $(track:string)`); +cache.addRules(` = play $(track:string);`); // Add second play pattern (alternative) -cache.addRules(`@ = play $(track:string) by $(artist:string)`); +cache.addRules(` = play $(track:string) by $(artist:string);`); // Both patterns now work const result1 = matchNFA(cache.getNFA(), ["play", "Song"]); @@ -203,7 +203,7 @@ const result2 = matchNFA(cache.getNFA(), ["play", "Song", "by", "Artist"]); ### Parse Errors ```typescript -const result = cache.addRules(`@ = this is not valid grammar`); +const result = cache.addRules(` = this is not valid grammar;`); if (!result.success) { console.error("Parse errors:", result.errors); @@ -215,7 +215,7 @@ if (!result.success) { ```typescript const result = cache.addRules( - `@ = schedule $(event:string) on $(date:UnknownType)`, + ` = schedule $(event:string) on $(date:UnknownType);`, ); if (!result.success) { @@ -274,10 +274,10 @@ const loader = new DynamicGrammarLoader(); // Load multiple rules at once const agrText = ` -@ = play $(track:string) -@ = play $(track:string) by $(artist:string) -@ = pause -@ = resume + = play $(track:string); + = play $(track:string) by $(artist:string); + = pause; + = resume; `; const result = loader.load(agrText); diff --git a/ts/packages/actionGrammar/docs/GRAMMAR_GENERATION_PRACTICAL.md b/ts/packages/actionGrammar/docs/GRAMMAR_GENERATION_PRACTICAL.md index b9913af12..75dba454a 100644 --- a/ts/packages/actionGrammar/docs/GRAMMAR_GENERATION_PRACTICAL.md +++ b/ts/packages/actionGrammar/docs/GRAMMAR_GENERATION_PRACTICAL.md @@ -43,7 +43,7 @@ Create reusable prefix/suffix rules that can be combined with any action. #### Politeness Prefixes ``` -@ = + = (can you)? (please)? | could you (please)? | would you (please)? @@ -53,21 +53,21 @@ Create reusable prefix/suffix rules that can be combined with any action. | would you mind | (I'd)? (I would)? like you to | (I was)? hoping you (could)? (would)? - | if you (could)? (would)? + | if you (could)? (would)?; // French equivalents -@ = + = pouvez-vous | pourriez-vous | (s'il)? (vous)? plaît | (je)? voudrais (que vous)? - | (je)? souhaiterais (que vous)? + | (je)? souhaiterais (que vous)?; ``` #### Desire/Intent Prefixes ``` -@ = + = I want to | I'd like to | I would like to @@ -78,32 +78,32 @@ Create reusable prefix/suffix rules that can be combined with any action. | I'm trying to | help me | can I - | could I + | could I; // French -@ = + = je veux | je voudrais | j'aimerais | (je)? (dois)? | laisse-moi - | aide-moi + | aide-moi; ``` #### Action Initiators ``` -@ = + = go ahead and | please go ahead and | just - | (just)? quickly + | (just)? quickly; ``` #### Politeness Suffixes ``` -@ = + = please | (if you)? (would)? (could)? please | (if you)? don't mind @@ -111,7 +111,7 @@ Create reusable prefix/suffix rules that can be combined with any action. | (if)? (that's)? alright | thanks | thank you - | for me + | for me; ``` #### Usage Pattern @@ -119,10 +119,10 @@ Create reusable prefix/suffix rules that can be combined with any action. Actions can then reference these: ``` -@ = + = ? pause ((the)? music)? ? -> { actionName: "pause" } | pause ((the)? music)? ? -> { actionName: "pause" } - | pause ((the)? music)? -> { actionName: "pause" } + | pause ((the)? music)? -> { actionName: "pause" }; ``` ### 2. Scenario-Based Generation @@ -249,7 +249,7 @@ Create reusable grammar modules: // Licensed under the MIT License. // Politeness prefixes for English -@ = + = (can you)? (please)? | could you (please)? | would you (please)? @@ -261,9 +261,9 @@ Create reusable grammar modules: | (I'd)? (I would)? like you to | (I was)? hoping you (could)? (would)? | if you (could)? (would)? - | (would)? you be able to + | (would)? you be able to; -@ = + = I want to | I'd like to | I would like to @@ -276,17 +276,17 @@ Create reusable grammar modules: | help me | can I | could I - | may I + | may I; -@ = + = go ahead and | please go ahead and | just | (just)? quickly | now - | right now + | right now; -@ = + = please | (if you)? (would)? (could)? please | (if you)? don't mind @@ -295,37 +295,37 @@ Create reusable grammar modules: | (if)? possible | thanks | thank you - | for me + | for me; // French equivalents -@ = + = pouvez-vous | pourriez-vous | (s'il)? (vous)? plaît | (je)? voudrais (que vous)? | (je)? souhaiterais (que vous)? - | serait-il possible de + | serait-il possible de; -@ = + = je veux | je voudrais | j'aimerais | (je)? (dois)? | laisse-moi | aide-moi - | (je)? (peux)? + | (je)? (peux)?; -@ = + = allez-y | juste | maintenant - | tout de suite + | tout de suite; -@ = + = s'il vous plaît | s'il te plaît | merci - | pour moi + | pour moi; ``` #### Phase 2: Scenario Template System @@ -548,7 +548,7 @@ class GrammarExpander { for (const [actionName, actionPatterns] of patterns) { const ruleName = this.toRuleName(actionName); output += `// ${actionName} - ${actionPatterns.length} patterns\n`; - output += `@ <${ruleName}> = \n`; + output += `<${ruleName}> = \n`; // Use prefix/suffix references where applicable const withPrefixes = actionPatterns.map((p) => @@ -557,7 +557,7 @@ class GrammarExpander { output += withPrefixes .map((p, i) => { - const separator = i < withPrefixes.length - 1 ? " |" : ""; + const separator = i < withPrefixes.length - 1 ? " |" : ";"; return ` ${p}${separator}`; }) .join("\n"); @@ -566,13 +566,13 @@ class GrammarExpander { } // Add rule - output += "@ = \n"; + output += " = \n"; const ruleNames = Array.from(patterns.keys()).map((a) => this.toRuleName(a), ); output += ruleNames .map((name, i) => { - const separator = i < ruleNames.length - 1 ? " |" : ""; + const separator = i < ruleNames.length - 1 ? " |" : ";"; return ` <${name}>${separator}`; }) .join("\n"); @@ -734,8 +734,8 @@ class GrammarValidator { **Before (playerSchema.agr):** ``` -@ = pause ((the)? music)? -> { actionName: "pause" } -@ = resume ((the)? music)? -> { actionName: "resume" } + = pause ((the)? music)? -> { actionName: "pause" }; + = resume ((the)? music)? -> { actionName: "resume" }; ``` **After (playerSchema.generated.agr):** @@ -746,12 +746,12 @@ class GrammarValidator { // Total patterns: 847 // Common prefix/suffix patterns -@ = (can you)? (please)? | could you (please)? | would you (please)? | ... -@ = I want to | I'd like to | I need to | ... -@ = please | thank you | for me | ... + = (can you)? (please)? | could you (please)? | would you (please)? | ...; + = I want to | I'd like to | I need to | ...; + = please | thank you | for me | ...; // pause - 106 patterns -@ = + = ? pause ((the)? music)? ? -> { actionName: "pause" } | pause ((the)? music)? ? -> { actionName: "pause" } | hit pause -> { actionName: "pause" } @@ -778,9 +778,10 @@ class GrammarValidator { | mets en pause -> { actionName: "pause" } | pouvez-vous mettre en pause -> { actionName: "pause" } // ... 8 more French patterns + ; // resume - 94 patterns -@ = + = ? resume ((the)? music)? ? -> { actionName: "resume" } | resume ((the)? music)? ? -> { actionName: "resume" } | keep playing -> { actionName: "resume" } @@ -791,6 +792,7 @@ class GrammarValidator { | (let's)? continue (the)? music -> { actionName: "resume" } | start (it)? again -> { actionName: "resume" } // ... 85 more patterns + ; ``` ## Implementation Plan diff --git a/ts/packages/actionGrammar/examples/calendarModule.agr b/ts/packages/actionGrammar/examples/calendarModule.agr new file mode 100644 index 000000000..f43619f56 --- /dev/null +++ b/ts/packages/actionGrammar/examples/calendarModule.agr @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// Entity declarations - these entities must be registered at runtime +entity CalendarDate, Ordinal; + +// CalendarDate - matches date-like strings +// Note: The actual matching/conversion logic is in the TypeScript converter + = $(date:CalendarDate); + +// Example: Schedule event with date + = + schedule $(event:string) on $(date:CalendarDate) -> { + actionName: "scheduleEvent", + parameters: { + eventName: event, + date + } + }; + +// Example: Using imported Ordinal from Global module +// Within this module, we can use Ordinal without qualification +// External modules would reference it as Global.Ordinal + = + schedule $(event:string) on (the)? $(ordinal:Ordinal) -> { + actionName: "scheduleEvent", + parameters: { + eventName: event, + dayOfMonth: ordinal + } + }; + +// Example: Find events by date + = + find events on $(date:CalendarDate) -> { + actionName: "findEvents", + parameters: { + date + } + } +| what\'s on $(date:CalendarDate) -> { + actionName: "findEvents", + parameters: { + date + } + }; diff --git a/ts/packages/actionGrammar/examples/globalModule.agr b/ts/packages/actionGrammar/examples/globalModule.agr new file mode 100644 index 000000000..9145a8ac4 --- /dev/null +++ b/ts/packages/actionGrammar/examples/globalModule.agr @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// This grammar demonstrates built-in entity types (Ordinal and Cardinal) +// which are registered at runtime and don't need inline definitions + +entity Ordinal, Cardinal; + +// Example usage of built-in entities + = ; + + = + play (the)? $(n:Ordinal) (track | song)? -> { + actionName: "playFromCurrentTrackList", + parameters: { + trackNumber: n + } + } +| play track $(n:Cardinal) -> { + actionName: "playFromCurrentTrackList", + parameters: { + trackNumber: n + } + }; diff --git a/ts/packages/actionGrammar/src/generation/grammarGenerator.ts b/ts/packages/actionGrammar/src/generation/grammarGenerator.ts index f22a90d7e..ff48c636e 100644 --- a/ts/packages/actionGrammar/src/generation/grammarGenerator.ts +++ b/ts/packages/actionGrammar/src/generation/grammarGenerator.ts @@ -501,7 +501,7 @@ export class ClaudeGrammarGenerator { * Convert the analysis into a full .agr format grammar rule * Returns empty string if grammar should not be generated * - * Uses the exact action name as the rule name (e.g., @ = ...) + * Uses the exact action name as the rule name (e.g., = ... ;) * to enable easy targeting when extending grammars for specific actions. */ formatAsGrammarRule( @@ -552,10 +552,10 @@ export class ClaudeGrammarGenerator { } // Include rule that references the action rule - let grammar = `@ = <${actionName}>\n`; + let grammar = ` = <${actionName}>;\n`; // Use exact action name as rule name for easy targeting - grammar += `@ <${actionName}> = `; + grammar += `<${actionName}> = `; grammar += matchPattern; grammar += ` -> {\n`; grammar += ` actionName: "${actionName}"`; @@ -575,7 +575,7 @@ export class ClaudeGrammarGenerator { grammar += `\n }`; } - grammar += `\n}`; + grammar += `\n};`; return grammar; } diff --git a/ts/packages/actionGrammar/src/generation/scenarioBasedGenerator.ts b/ts/packages/actionGrammar/src/generation/scenarioBasedGenerator.ts index 85a26ae5a..ef62e75d7 100644 --- a/ts/packages/actionGrammar/src/generation/scenarioBasedGenerator.ts +++ b/ts/packages/actionGrammar/src/generation/scenarioBasedGenerator.ts @@ -584,7 +584,7 @@ export class ScenarioBasedGrammarGenerator { for (const [categoryName, info] of categories) { const verbsList = Array.from(info.verbs).sort(); if (verbsList.length > 0) { - output += `@ <${categoryName}> =\n`; + output += `<${categoryName}> =\n`; verbsList.forEach((verb, index) => { const separator = index < verbsList.length - 1 ? " |" : ""; // Escape backslashes first, then single quotes in verb phrases @@ -686,7 +686,7 @@ export class ScenarioBasedGrammarGenerator { const ruleName = `${actionName}_Verb${structureIndex}`; structureRules.set(structure, ruleName); - output += `@ <${ruleName}> =\n`; + output += `<${ruleName}> =\n`; data.verbPhrases.forEach((verb, index) => { const escapedVerb = this.escapePatternHyphens(verb); const separator = @@ -700,14 +700,14 @@ export class ScenarioBasedGrammarGenerator { output += ` ${escapedVerb}${separator}\n`; } }); - output += `\n`; + output += `;\n`; structureIndex++; } } // Now generate the action rule - output += `@ <${actionName}> =\n`; + output += `<${actionName}> =\n`; const structureArray = Array.from(structureToVerbs.entries()); structureArray.forEach(([structure, data], index) => { @@ -740,51 +740,52 @@ export class ScenarioBasedGrammarGenerator { output += ` ${ruleWithAction}${separator}\n`; }); - output += `\n`; + output += `;\n`; } // Add rule (all action alternatives) - output += `@ =\n`; + output += ` =\n`; const actionNames = Array.from(allPatterns.keys()); actionNames.forEach((name, index) => { const separator = index < actionNames.length - 1 ? " |" : ""; output += ` <${name}>${separator}\n`; }); - output += `\n`; + output += `;\n`; // Add combined prefix rules for each language output += `// Combined prefix categories\n`; - output += `@ =\n`; + output += ` =\n`; output += ` |\n`; output += ` |\n`; output += ` |\n`; output += ` \n`; - output += `\n`; + output += `;\n`; - output += `@ =\n`; + output += ` =\n`; output += ` |\n`; output += ` |\n`; output += ` |\n`; output += ` \n`; - output += `\n`; + output += `;\n`; // Add combined suffix rules for each language output += `// Combined suffix categories\n`; - output += `@ =\n`; + output += ` =\n`; output += ` |\n`; output += ` \n`; - output += `\n`; + output += `;\n`; - output += `@ =\n`; + output += ` =\n`; output += ` |\n`; output += ` \n`; - output += `\n`; + output += `;\n`; // Add rule with optional prefix and suffix output += `// Main Start rule with optional prefixes and suffixes\n`; - output += `@ =\n`; + output += ` =\n`; output += ` ()? ()? |\n`; output += ` ()? ()?\n`; + output += `;\n`; return output; } @@ -879,12 +880,13 @@ export class ScenarioBasedGrammarGenerator { ruleName: string, patterns: string[], ): string { - let output = `@ <${ruleName}> =\n`; + let output = `<${ruleName}> =\n`; patterns.forEach((pattern, index) => { const separator = index < patterns.length - 1 ? " |" : ""; const escaped = this.escapeSpecialChars(pattern); output += ` '${escaped}'${separator}\n`; }); + output += `;\n`; return output; } diff --git a/ts/packages/actionGrammar/src/generation/schemaToGrammarGenerator.ts b/ts/packages/actionGrammar/src/generation/schemaToGrammarGenerator.ts index d200a71e2..a9d3a2cc7 100644 --- a/ts/packages/actionGrammar/src/generation/schemaToGrammarGenerator.ts +++ b/ts/packages/actionGrammar/src/generation/schemaToGrammarGenerator.ts @@ -43,7 +43,7 @@ const SCHEMA_GRAMMAR_PROMPT = `You are an expert at creating comprehensive Actio Your task is to analyze a complete action schema and generate an efficient, maintainable grammar that covers all actions with shared sub-rules where appropriate. The Action Grammar format uses: -- Rule definitions: @ = pattern +- Rule definitions: = pattern; - Literal text: "play" or 'play' - Wildcards with types: $(name:Type) - captures any text and assigns it to 'name' with validation type 'Type' - Optional elements: element? @@ -56,7 +56,7 @@ The Action Grammar format uses: - Comments: // this is a comment (NOT # which is invalid) FULL EXAMPLE showing captures and action body: - @ = ('play' | 'start') $(track:string) ('by' $(artist:string))? -> { actionName: "play", parameters: { track: track, artist: artist } } + = ('play' | 'start') $(track:string) ('by' $(artist:string))? -> { actionName: "play", parameters: { track: track, artist: artist } }; Note: $(track:string) captures to variable 'track'; in the action body write just 'track' (no $ prefix) CRITICAL SYNTAX RULES: @@ -75,40 +75,40 @@ CRITICAL SYNTAX RULES: 4. Wildcard type annotations CANNOT contain pipes or unions For parameters with union types (e.g., CalendarTime | CalendarTimeRange): OPTION A: Create a sub-rule with alternation - @ = $(t:CalendarTime) -> t | $(t:CalendarTimeRange) -> t + = $(t:CalendarTime) -> t | $(t:CalendarTimeRange) -> t; OPTION B: Just use one of the types - @ = $(time:CalendarTime) + = $(time:CalendarTime); WRONG: $(time:CalendarTime | CalendarTimeRange) 5. Action rule names MUST match the exact action name (not capitalized) - CORRECT: @ = ... for action "scheduleEvent" - WRONG: @ = ... for action "scheduleEvent" + CORRECT: = ... ; for action "scheduleEvent" + WRONG: = ... ; for action "scheduleEvent" This enables easy targeting of specific actions when extending grammars incrementally. 6. BARE VARIABLE NAMES in action body values — NEVER use $ in the action body: - CORRECT: @ = 'send' $(msg:string) 'to' $(to:string) -> { actionName: "send", parameters: { message: msg, recipient: to } } + CORRECT: = 'send' $(msg:string) 'to' $(to:string) -> { actionName: "send", parameters: { message: msg, recipient: to } }; WRONG: -> { actionName: "send", parameters: { message: $msg, recipient: $to } } WRONG: -> { actionName: "send", parameters: { message: $(msg), recipient: $(to) } } WRONG: -> { actionName: "send", parameters: { message: $(msg:string) } } The capture $(name:Type) defines the variable 'name'; in the action body, reference it as just 'name'. 7. In sub-rule VALUE positions (after ->), ONLY reference vars captured in THAT SAME RULE's pattern: - CORRECT: @ = $(d:string) -> d (d is captured in this rule's pattern) - CORRECT: @ = $(t:CalendarTime) -> t | $(t:CalendarTimeRange) -> t - WRONG: @ = 'vertical' | 'horizontal' -> direction (no capture, 'direction' is undefined) - WRONG: @ = 'vertical' | 'horizontal' -> $(direction:string) ($ not allowed in value pos) + CORRECT: = $(d:string) -> d; (d is captured in this rule's pattern) + CORRECT: = $(t:CalendarTime) -> t | $(t:CalendarTimeRange) -> t; + WRONG: = 'vertical' | 'horizontal' -> direction; (no capture, 'direction' is undefined) + WRONG: = 'vertical' | 'horizontal' -> $(direction:string); ($ not allowed in value pos) If a sub-rule just matches alternatives ('a' | 'b'), it doesn't produce a value; don't use -> on it. When alternatives capture DIFFERENT variables, give EACH alternative its own ->: - CORRECT: @ = $(m:number) ('minute' | 'minutes') -> m | $(s:number) ('second' | 'seconds') -> s - WRONG: @ = ($(m:number) 'minutes' | $(s:number) 'seconds') -> d (d undefined!) + CORRECT: = $(m:number) ('minute' | 'minutes') -> m | $(s:number) ('second' | 'seconds') -> s; + WRONG: = ($(m:number) 'minutes' | $(s:number) 'seconds') -> d; (d undefined!) 8. Variables referenced in the action body MUST be captured DIRECTLY in the same rule (not only in sub-rules): - CORRECT: @ = 'send' 'email' 'to' $(to:string) 'about' $(subject:string) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } } + CORRECT: = 'send' 'email' 'to' $(to:string) 'about' $(subject:string) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } }; WRONG (to/subject not captured in sendEmail rule, only in sub-rules): - @ = 'send' 'email' -> { actionName: "sendEmail", parameters: { to: to, subject: subject } } + = 'send' 'email' -> { actionName: "sendEmail", parameters: { to: to, subject: subject } }; If you use value-producing sub-rules, capture the sub-rule's OUTPUT with a wildcard in the parent: $(varName:SubRuleName) Or inline the pattern directly in the action rule to avoid this. - CORRECT using sub-rule capture: @ = 'send' $(to:RecipientSpec) $(subject:SubjectSpec) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } } + CORRECT using sub-rule capture: = 'send' $(to:RecipientSpec) $(subject:SubjectSpec) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } }; 9. Comments use // not #: CORRECT: // This is a comment @@ -141,10 +141,10 @@ CRITICAL SYNTAX RULES: EFFICIENCY GUIDELINES: 1. Identify common patterns across actions and extract them as sub-rules - Example: If multiple actions use date expressions, create @ = ('on' | 'for') $(date:CalendarDate) + Example: If multiple actions use date expressions, create = ('on' | 'for') $(date:CalendarDate); 2. Create shared vocabulary rules for common phrases - Example: @ = 'can you'? | 'please'? | 'would you'? + Example: = 'can you'? | 'please'? | 'would you'?; 3. Reuse entity type rules across actions Example: If multiple actions need participant names, reference the same wildcard pattern @@ -154,13 +154,13 @@ EFFICIENCY GUIDELINES: 5. The Start rule should reference all top-level action rules GRAMMAR STRUCTURE: -1. Start with @ rule listing all actions by their exact action names - Example: @ = | | +1. Start with rule listing all actions by their exact action names + Example: = | | ; 2. Define action rules using EXACT action names as rule names (not capitalized) - Example: @ = ... for action "scheduleEvent" - Example: @ = ... for action "findEvents" + Example: = ... ; for action "scheduleEvent" + Example: = ... ; for action "findEvents" 3. Define shared sub-rules used by multiple actions (these can be capitalized) - Example: @ = ..., @ = ... + Example: = ... ;, = ... ; 4. Include common patterns (Cardinal, Ordinal, etc.) AVAILABLE ENTITY TYPES AND CONVERTERS: @@ -208,7 +208,7 @@ Your task: 5. Ensure all actions in the schema are covered 6. Keep shared sub-rules and don't duplicate patterns 7. Follow all AGR syntax rules (see above) -8. IMPORTANT: Use exact action names for action rules (e.g., @ = ..., not @ = ...) +8. IMPORTANT: Use exact action names for action rules (e.g., = ... ;, not = ... ;) This enables easy targeting of specific actions when extending grammars incrementally Response format: Return ONLY the complete improved .agr file content, starting with copyright header.`; @@ -610,13 +610,13 @@ Remember the CRITICAL SYNTAX RULES: WRONG: -> { actionName: "send", parameters: { message: $(msg:string) } } The capture $(name:Type) defines variable 'name'; reference it in action body as just 'name'. 5. In sub-rule VALUE positions (after ->), ONLY reference vars captured in THAT SAME RULE's pattern: - CORRECT: @ = $(d:string) -> d (d was captured in this rule) - WRONG: @ = 'vertical' | 'horizontal' -> direction (no capture, undefined) - WRONG: @ = 'vertical' | 'horizontal' -> $(direction:string) ($ not allowed in values) + CORRECT: = $(d:string) -> d; (d was captured in this rule) + WRONG: = 'vertical' | 'horizontal' -> direction; (no capture, undefined) + WRONG: = 'vertical' | 'horizontal' -> $(direction:string); ($ not allowed in values) 6. Variables in action body must be captured DIRECTLY in the same rule — inline patterns or use $(var:SubRule): - CORRECT: @ = 'send' 'email' 'to' $(to:string) 'about' $(subject:string) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } } - WRONG (to/subject only in sub-rules): @ = 'send' -> { actionName: "sendEmail", parameters: { to: to, subject: subject } } - CORRECT using sub-rule capture: @ = 'send' $(to:RecipientSpec) $(subject:SubjectSpec) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } } + CORRECT: = 'send' 'email' 'to' $(to:string) 'about' $(subject:string) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } }; + WRONG (to/subject only in sub-rules): = 'send' -> { actionName: "sendEmail", parameters: { to: to, subject: subject } }; + CORRECT using sub-rule capture: = 'send' $(to:RecipientSpec) $(subject:SubjectSpec) -> { actionName: "sendEmail", parameters: { to: to, subject: subject } }; 7. Comments use // not #. 8. String literal quoting: a) Apostrophes/contractions must use double quotes: "don't" "it's" (NOT 'don\'t') @@ -624,8 +624,8 @@ Remember the CRITICAL SYNTAX RULES: WRONG: 'auto-reload' or "auto-reload" (BOTH fail with "Special character" error) CORRECT: 'auto' 'reload' (separate tokens) 9. In sub-rule VALUE positions: when alternatives capture DIFFERENT variables, give each its own ->: - CORRECT: @ = $(m:number) ('minute' | 'minutes') -> m | $(s:number) ('second' | 'seconds') -> s - WRONG: @ = ($(m:number) 'minutes' | $(s:number) 'seconds') -> d (d is undefined!) + CORRECT: = $(m:number) ('minute' | 'minutes') -> m | $(s:number) ('second' | 'seconds') -> s; + WRONG: = ($(m:number) 'minutes' | $(s:number) 'seconds') -> d; (d is undefined!) 10. Custom sub-rule names as wildcard types need angle brackets: $(var:) not $(var:MyRule). Only built-in types skip angle brackets: string, number, wildcard, CalendarDate, CalendarTime, etc. Built-in type names are CASE-SENSITIVE and LOWERCASE: diff --git a/ts/packages/actionGrammar/src/grammarRuleParser.ts b/ts/packages/actionGrammar/src/grammarRuleParser.ts index c3d4639c4..59dc5cfcd 100644 --- a/ts/packages/actionGrammar/src/grammarRuleParser.ts +++ b/ts/packages/actionGrammar/src/grammarRuleParser.ts @@ -9,10 +9,10 @@ const debugParse = registerDebug("typeagent:grammar:parse"); * The grammar for cache grammar files is defined as follows (in BNF and regular expressions): * ::= ( | | )* * ::= "entity" ("," )* ";" - * ::= "@import" ( | ) "from" + * ::= "import" ( | ) "from" ";" * ::= "*" * ::= "{" ("," )* "}" - * ::= "@" "=" + * ::= "=" ";" * ::= ( "|" )* * ::= ( "->" )? * @@ -27,15 +27,15 @@ const debugParse = registerDebug("typeagent:grammar:parse"); * ::= "(" ( ")" | ")?" ) // TODO: support for + and *? * * = BooleanValue | NumberValue | StringValue | ObjectValue | ArrayValue | VarReference - * = "[" ("," )* )? "]" - * = "{" ("," )* "}" + * = "[" ( ("," )*)? "]" + * = "{" ( ("," )*)? "}" * = | * = ":" * = * = | {{ Javascript string literal }} * = "true" | "false" * = - * = > + * = * = * * = @@ -48,7 +48,7 @@ const debugParse = registerDebug("typeagent:grammar:parse"); * = {{ Unicode ID_Start character }} * = {{ Unicode ID_Continue character }} * - * In the above grammar, all whitespace or comments can appear between any two symbols in this grammar(terminal or non-terminal). + * In the above grammar, all whitespace or comments can appear between any two symbols in this grammar (terminal or non-terminal). * ::= {{ Javascript Whitespace and Line terminators character ( [\s] in JS regexp )}}* * ::= "//" [^\n]* "\n" * ::= "/*" .* "*\/" @@ -159,7 +159,6 @@ function isIdContinue(char: string) { // Even some of these are not used yet, include them for future use. export const expressionsSpecialChar = [ // Must escape - "@", "|", "(", ")", @@ -167,6 +166,7 @@ export const expressionsSpecialChar = [ ">", "$", // for $( "-", // for -> + ";", // terminator // Reserved for future use "{", "}", @@ -589,7 +589,7 @@ class GrammarRuleParser { result.value = this.parseValue(); } else if ( !this.isAtEnd() && - !this.isAt("@") && + !this.isAt(";") && !this.isAt("|") && !this.isAt(")") ) { @@ -635,6 +635,7 @@ class GrammarRuleParser { const name = this.parseRuleName(); this.consume("=", "after rule identifier"); const rules = this.parseRules(); + this.consume(";", "at end of rule definition"); return { name, rules, pos }; } @@ -714,8 +715,8 @@ class GrammarRuleParser { } private parseImportStatement(): ImportStatement { - // @import { Name1, Name2 } from "file" - // @import * from "file" + // import { Name1, Name2 } from "file"; + // import * from "file"; this.skipWhitespace(6); // skip "import" const pos = this.pos; @@ -756,9 +757,7 @@ class GrammarRuleParser { ); } } else { - this.throwUnexpectedCharError( - "Expected '{' or '*' after '@import'", - ); + this.throwUnexpectedCharError("Expected '{' or '*' after 'import'"); } // Parse "from" @@ -777,6 +776,8 @@ class GrammarRuleParser { } const source = this.parseStringLiteral(); + this.consume(";", "at end of import statement"); + return { names, source, pos }; } @@ -786,22 +787,20 @@ class GrammarRuleParser { const definitions: RuleDefinition[] = []; this.skipWhitespace(); while (!this.isAtEnd()) { - if (this.isAt("@")) { - this.skipWhitespace(1); - if (this.isAt("<")) { - definitions.push(this.parseRuleDefinition()); - continue; - } - if (this.isAt("import")) { - imports.push(this.parseImportStatement()); - continue; - } - } else if (this.isAt("entity")) { + if (this.isAt("<")) { + definitions.push(this.parseRuleDefinition()); + continue; + } + if (this.isAt("import")) { + imports.push(this.parseImportStatement()); + continue; + } + if (this.isAt("entity")) { entities.push(...this.parseEntityDeclaration()); continue; } this.throwUnexpectedCharError( - "Expected 'entity' declaration, '@import' statement, or '@' rule definition", + "Expected rule definition, 'import' statement, or 'entity' declaration", ); } return { entities, imports, definitions }; diff --git a/ts/packages/actionGrammar/src/grammarRuleWriter.ts b/ts/packages/actionGrammar/src/grammarRuleWriter.ts index 46b7a3ecd..0b8db04e2 100644 --- a/ts/packages/actionGrammar/src/grammarRuleWriter.ts +++ b/ts/packages/actionGrammar/src/grammarRuleWriter.ts @@ -21,9 +21,10 @@ export function writeGrammarRules(grammar: RuleDefinition[]): string { } function writeRuleDefinition(result: string[], def: RuleDefinition) { - const ruleStart = `@ <${def.name}> = `; + const ruleStart = `<${def.name}> = `; result.push(ruleStart); writeRules(result, def.rules, ruleStart.length); + result.push(";"); } function writeRules(result: string[], rules: Rule[], indent: number) { diff --git a/ts/packages/actionGrammar/src/nfaCompiler.ts b/ts/packages/actionGrammar/src/nfaCompiler.ts index 314a2d179..a72750121 100644 --- a/ts/packages/actionGrammar/src/nfaCompiler.ts +++ b/ts/packages/actionGrammar/src/nfaCompiler.ts @@ -99,7 +99,7 @@ function collectVariablePaths( /** * Check if a rule is a passthrough rule (single RulesPart without variable or value) - * Passthrough rules need normalization: @ = becomes @ = $(v:) -> $(v) + * Passthrough rules need normalization: = ; becomes = $(_result:) -> _result; */ function isPassthroughRule(rule: GrammarRule): boolean { // A passthrough rule has: @@ -122,7 +122,7 @@ function isPassthroughRule(rule: GrammarRule): boolean { } /** - * Check if a rule is a single-literal rule (e.g., @ = chrome) + * Check if a rule is a single-literal rule (e.g., = chrome;) * Such rules should implicitly produce the matched literal as their value: -> "chrome" */ function isSingleLiteralRule(rule: GrammarRule): { literal: string } | false { @@ -149,8 +149,8 @@ function isSingleLiteralRule(rule: GrammarRule): { literal: string } | false { /** * Normalize a grammar for matching. * This converts: - * - Passthrough rules: @ = becomes @ = $(_result:) -> $(_result) - * - Single-literal rules: @ = chrome becomes @ = chrome -> "chrome" + * - Passthrough rules: = ; becomes = $(_result:) -> _result; + * - Single-literal rules: = chrome; becomes = chrome -> "chrome"; * * Normalization is done as a preprocessing step so matchers don't need special handling. * Both completion-based and NFA-based matchers benefit from this normalization. @@ -208,7 +208,7 @@ function normalizeRule( // Check if this is a passthrough rule that needs transformation if (isPassthroughRule(rule)) { - // Transform: @ = becomes @ = $(_result:) -> $(_result) + // Transform: = ; becomes = $(_result:) -> _result; const rulesPart = normalizedParts[0] as RulesPart; return { parts: [ @@ -224,7 +224,7 @@ function normalizeRule( // Check if this is a single-literal rule that needs transformation const singleLiteral = isSingleLiteralRule(rule); if (singleLiteral) { - // Transform: @ = chrome becomes @ = chrome -> "chrome" + // Transform: = chrome; becomes = chrome -> "chrome"; return { parts: normalizedParts, value: { type: "literal", value: singleLiteral.literal }, @@ -257,7 +257,7 @@ function normalizePart( } /** - * Check if a rule is a single-variable rule (e.g., @ = $(x:wildcard)) + * Check if a rule is a single-variable rule (e.g., = $(x:wildcard);) * Such rules should implicitly produce their variable's value: -> $(x) */ function isSingleVariableRule(rule: GrammarRule): { variable: string } | false { @@ -399,7 +399,7 @@ function createRuleTypeMap(rule: GrammarRule): Map { */ export function compileGrammarToNFA(grammar: Grammar, name?: string): NFA { // Normalize grammar first: convert passthrough rules to explicit form - // @ = becomes @ = $(_result:) -> $(_result) + // = ; becomes = $(_result:) -> _result; const normalizedGrammar = normalizeGrammar(grammar); const builder = new NFABuilder(); @@ -427,8 +427,8 @@ export function compileGrammarToNFA(grammar: Grammar, name?: string): NFA { ); } - // Check for single-variable rules like @ = $(x:wildcard) - // These should implicitly produce their variable's value: -> $(x) + // Check for single-variable rules like = $(x:wildcard); + // These should implicitly produce their variable's value: -> x let effectiveValue = rule.value; if (!effectiveValue) { const singleVar = isSingleVariableRule(rule); @@ -1093,7 +1093,7 @@ function compileRulesPartWithSlots( // Compile and store the action value on the entry state FIRST // We need to know if there's a value before deciding about environments // Passthrough normalization is done upfront, so rules already have explicit values - // Just check for single-variable rules like @ = $(x:wildcard) + // Just check for single-variable rules like = $(x:wildcard); let effectiveValue = rule.value; if (!effectiveValue) { const singleVar = isSingleVariableRule(rule); diff --git a/ts/packages/actionGrammar/test/BASE_GRAMMAR_TEST_STATUS.md b/ts/packages/actionGrammar/test/BASE_GRAMMAR_TEST_STATUS.md index 9f2e1d754..5d3cde54e 100644 --- a/ts/packages/actionGrammar/test/BASE_GRAMMAR_TEST_STATUS.md +++ b/ts/packages/actionGrammar/test/BASE_GRAMMAR_TEST_STATUS.md @@ -27,8 +27,8 @@ The unit tests are currently failing due to a variable capture issue in how nest The player grammar defines nested rules: ``` -@ = $(x:string) -@ = $(x:string) + = $(x:string); + = $(x:string); ``` When referenced as `$(trackName:)`, the inner `$(x:string)` captures override the outer variable name `trackName`. diff --git a/ts/packages/actionGrammar/test/agentGrammarRegistry.spec.ts b/ts/packages/actionGrammar/test/agentGrammarRegistry.spec.ts index 5db440550..a9577c809 100644 --- a/ts/packages/actionGrammar/test/agentGrammarRegistry.spec.ts +++ b/ts/packages/actionGrammar/test/agentGrammarRegistry.spec.ts @@ -58,13 +58,13 @@ describe("Agent Grammar Registry", () => { const agentGrammar = new AgentGrammar("player", baseGrammar, nfa); // Add generated rule - const generatedRule = `@ = -@ = play $(track:string) -> { + const generatedRule = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const addResult = agentGrammar.addGeneratedRules(generatedRule); expect(addResult.success).toBe(true); @@ -96,11 +96,11 @@ describe("Agent Grammar Registry", () => { ); // Try to add rule with unresolved entity (no import) - const invalidRule = `@ = -@ = schedule $(event:string) on $(date:UnknownEntity) -> { + const invalidRule = ` = ; + = schedule $(event:string) on $(date:UnknownEntity) -> { actionName: "schedule", parameters: { event, date } -}`; +};`; const result = agentGrammar.addGeneratedRules(invalidRule); expect(result.success).toBe(false); @@ -126,12 +126,12 @@ describe("Agent Grammar Registry", () => { ); // Add rule with type import - const ruleWithEntity = `@ import { CalendarDate } from "types.ts" -@ = -@ = schedule $(event:string) on $(date:CalendarDate) -> { + const ruleWithEntity = `import { CalendarDate } from "types.ts"; + = ; + = schedule $(event:string) on $(date:CalendarDate) -> { actionName: "schedule", parameters: { event, date } -}`; +};`; const result = agentGrammar.addGeneratedRules(ruleWithEntity); expect(result.success).toBe(true); @@ -177,8 +177,8 @@ describe("Agent Grammar Registry", () => { const initialStateCount = initialStats.stateCount; // Add first rule - simpler format like in cache hit workflow test - const firstRule = `@ = -@ = play $(track:string) -> { actionName: "play", parameters: { track } }`; + const firstRule = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } };`; const firstResult = agentGrammar.addGeneratedRules(firstRule); expect(firstResult.success).toBe(true); @@ -196,8 +196,8 @@ describe("Agent Grammar Registry", () => { expect(trackMatch.actionValue?.parameters?.track).toBe("Yesterday"); // Add second rule - const secondRule = `@ = -@ = resume`; + const secondRule = ` = ; + = resume;`; const secondResult = agentGrammar.addGeneratedRules(secondRule); expect(secondResult.success).toBe(true); @@ -218,8 +218,8 @@ describe("Agent Grammar Registry", () => { // Add third rule with entity declaration to test merging const thirdRule = `entity Ordinal; -@ = -@ = skip`; + = ; + = skip;`; const thirdResult = agentGrammar.addGeneratedRules(thirdRule); expect(thirdResult.success).toBe(true); @@ -265,8 +265,8 @@ describe("Agent Grammar Registry", () => { }); it("should register agents from text", () => { - const agrText = `@ = -@ = play $(track:string) -> { actionName: "play", parameters: { track } }`; + const agrText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } };`; const result = registry.registerAgentFromText("player", agrText); @@ -316,8 +316,8 @@ describe("Agent Grammar Registry", () => { registry.registerAgent("player", baseGrammar); - const generatedRule = `@ = -@ = play $(track:string) -> { actionName: "play", parameters: { track } }`; + const generatedRule = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } };`; const result = registry.addGeneratedRules("player", generatedRule); expect(result.success).toBe(true); @@ -331,7 +331,7 @@ describe("Agent Grammar Registry", () => { // Grammar parse errors (e.g. missing ) still cause failure. const result = registry.addGeneratedRules( "non-existent", - "@ = test", + " = test", ); expect(result.success).toBe(false); @@ -495,8 +495,8 @@ describe("Agent Grammar Registry", () => { it("should support cache hit workflow", () => { // Initial registration - const agrText = `@ = -@ = pause`; + const agrText = ` = + = pause`; registry.registerAgentFromText("player", agrText); @@ -508,13 +508,13 @@ describe("Agent Grammar Registry", () => { expect(firstTry.matched).toBe(false); // Simulate grammarGenerator creating a rule from the request - const generatedRule = `@ = -@ = play $(track:string) -> { + const generatedRule = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; // Add the generated rule to cache const addResult = registry.addGeneratedRules( diff --git a/ts/packages/actionGrammar/test/dynamicGrammarLoader.spec.ts b/ts/packages/actionGrammar/test/dynamicGrammarLoader.spec.ts index d51827105..b809e7621 100644 --- a/ts/packages/actionGrammar/test/dynamicGrammarLoader.spec.ts +++ b/ts/packages/actionGrammar/test/dynamicGrammarLoader.spec.ts @@ -20,13 +20,13 @@ describe("Dynamic Grammar Loader", () => { const loader = new DynamicGrammarLoader(); // Simulated output from grammarGenerator - const agrText = `@ = -@ = play $(track:string) -> { + const agrText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const result = loader.load(agrText); @@ -50,14 +50,14 @@ describe("Dynamic Grammar Loader", () => { const loader = new DynamicGrammarLoader(); // Generated rule with multiple wildcards - const agrText = `@ = -@ = play $(track:string) by $(artist:string) -> { + const agrText = ` = ; + = play $(track:string) by $(artist:string) -> { actionName: "play", parameters: { track, artist } -}`; +};`; const result = loader.load(agrText); @@ -82,13 +82,13 @@ describe("Dynamic Grammar Loader", () => { const loader = new DynamicGrammarLoader(); // Generated rule with optional politeness - const agrText = `@ = -@ = (please)? play $(track:string) -> { + const agrText = ` = ; + = (please)? play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const result = loader.load(agrText); @@ -113,14 +113,14 @@ describe("Dynamic Grammar Loader", () => { const loader = new DynamicGrammarLoader(); // Generated rule using imported type - const agrText = `@ import { Ordinal } from "types.ts" -@ = -@ = play (the)? $(n:Ordinal) track -> { + const agrText = `import { Ordinal } from "types.ts"; + = ; + = play (the)? $(n:Ordinal) track -> { actionName: "play", parameters: { n } -}`; +};`; const result = loader.load(agrText); @@ -140,14 +140,14 @@ describe("Dynamic Grammar Loader", () => { const loader = new DynamicGrammarLoader(); // Rule references unknown type (not imported) - const agrText = `@ = -@ = schedule $(event:string) on $(date:UnknownDateType) -> { + const agrText = ` = ; + = schedule $(event:string) on $(date:UnknownDateType) -> { actionName: "schedule", parameters: { event, date } -}`; +};`; const result = loader.load(agrText); @@ -171,13 +171,13 @@ describe("Dynamic Grammar Loader", () => { }; // New rule to add - const agrText = `@ = -@ = play $(track:string) -> { + const agrText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const result = loader.loadAndMerge( agrText, @@ -222,14 +222,14 @@ describe("Dynamic Grammar Loader", () => { }; // Add another play rule with different structure - const agrText = `@ = -@ = play $(track:string) by $(artist:string) -> { + const agrText = ` = ; + = play $(track:string) by $(artist:string) -> { actionName: "play", parameters: { track, artist } -}`; +};`; const result = loader.loadAndMerge(agrText, existingGrammar); @@ -269,13 +269,13 @@ describe("Dynamic Grammar Loader", () => { expect(stats1.ruleCount).toBe(1); // Add new rule - const agrText = `@ = -@ = play $(track:string) -> { + const agrText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const result = cache.addRules(agrText); expect(result.success).toBe(true); @@ -304,35 +304,35 @@ describe("Dynamic Grammar Loader", () => { const cache = new DynamicGrammarCache(initialGrammar, initialNFA); // Add first rule - const rule1 = `@ = -@ = play $(track:string) -> { + const rule1 = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const result1 = cache.addRules(rule1); expect(result1.success).toBe(true); expect(cache.getGrammar().rules.length).toBe(2); // pause + play (Start refs play) // Add second rule - const rule2 = `@ = -@ = resume -> { + const rule2 = ` = ; + = resume -> { actionName: "resume" -}`; +};`; const result2 = cache.addRules(rule2); expect(result2.success).toBe(true); expect(cache.getGrammar().rules.length).toBe(3); // + resume (Start refs resume) // Add third rule with same action as first (alternative) - const rule3 = `@ = -@ = play $(track:string) by $(artist:string) -> { + const rule3 = ` = ; + = play $(track:string) by $(artist:string) -> { actionName: "play", parameters: { track, artist } -}`; +};`; const result3 = cache.addRules(rule3); expect(result3.success).toBe(true); expect(cache.getGrammar().rules.length).toBe(4); // + play (another play alternative) @@ -362,14 +362,14 @@ describe("Dynamic Grammar Loader", () => { const statsBefore = cache.getStats(); // Try to add rule with unimported type - const invalidRule = `@ = -@ = schedule $(event:string) on $(date:InvalidDateType) -> { + const invalidRule = ` = ; + = schedule $(event:string) on $(date:InvalidDateType) -> { actionName: "schedule", parameters: { event, date } -}`; +};`; const result = cache.addRules(invalidRule); expect(result.success).toBe(false); @@ -388,14 +388,14 @@ describe("Dynamic Grammar Loader", () => { const loader = new DynamicGrammarLoader(); // Complete output from grammarGenerator.formatAsGrammarRule() - const generatedRule = `@ = -@ = play $(trackName:string) by $(artist:string) -> { + const generatedRule = ` = ; + = play $(trackName:string) by $(artist:string) -> { actionName: "playTrack", parameters: { trackName, artist } -}`; +};`; const result = loader.load(generatedRule); @@ -421,14 +421,14 @@ describe("Dynamic Grammar Loader", () => { const loader = new DynamicGrammarLoader(); const generatedRule = `@ import { CalendarDate } from "types.ts" -@ = -@ = schedule $(event:string) on $(date:CalendarDate) -> { + = ; + = schedule $(event:string) on $(date:CalendarDate) -> { actionName: "scheduleEvent", parameters: { event, date } -}`; +};`; const result = loader.load(generatedRule); diff --git a/ts/packages/actionGrammar/test/grammarCompileError.spec.ts b/ts/packages/actionGrammar/test/grammarCompileError.spec.ts index a220dd27a..0f6ecddf0 100644 --- a/ts/packages/actionGrammar/test/grammarCompileError.spec.ts +++ b/ts/packages/actionGrammar/test/grammarCompileError.spec.ts @@ -7,8 +7,8 @@ describe("Grammar Compiler", () => { describe("Error", () => { it("Undefined rule reference", () => { const grammarText = ` - @ = - @ = + = ; + = ; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -20,8 +20,8 @@ describe("Grammar Compiler", () => { it("Undefined rule reference in variable", () => { const grammarText = ` - @ = - @ = $(x:) + = ; + = $(x:); `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -36,10 +36,10 @@ describe("Grammar Compiler", () => { // produce a value (the literal string itself). Rules with multiple parts // (e.g., two rule references) do NOT produce an implicit value. const grammarText = ` - @ = $(x:) - @ = - @ = wait - @ = stop + = $(x:); + = ; + = wait; + = stop; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -50,9 +50,9 @@ describe("Grammar Compiler", () => { }); it("Variable reference to non-value rule in nested rule", () => { const grammarText = ` - @ = $(x:) - @ = please - @ = wait + = $(x:); + = please ; + = wait; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -63,11 +63,11 @@ describe("Grammar Compiler", () => { }); it("Variable reference to non-value rules with multiple values", () => { const grammarText = ` - @ = $(x:) + = $(x:); // This rule has multiple variable references, so cannot produce a single (implicit) value - @ = $(y:) and $(z:) - @ = please wait -> 1 - @ = stop now -> 2 + = $(y:) and $(z:); + = please wait -> 1; + = stop now -> 2; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -79,7 +79,7 @@ describe("Grammar Compiler", () => { it("Undefined variable reference in value expression", () => { const grammarText = ` - @ = $(name) plays music -> { player: name, action: undefinedVar } + = $(name) plays music -> { player: name, action: undefinedVar }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -91,7 +91,7 @@ describe("Grammar Compiler", () => { it("Duplicate variable definition in same rule", () => { const grammarText = ` - @ = $(name) plays $(name) -> { name } + = $(name) plays $(name) -> { name }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -103,7 +103,7 @@ describe("Grammar Compiler", () => { it("Duplicate variable with different types", () => { const grammarText = ` - @ = $(x:string) and $(x:number) -> { x } + = $(x:string) and $(x:number) -> { x }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -115,9 +115,9 @@ describe("Grammar Compiler", () => { it("Duplicate variable with rule reference", () => { const grammarText = ` - @ = $(action:) $(action:) -> { action } - @ = play -> "play" - | pause -> "pause" + = $(action:) $(action:) -> { action }; + = play -> "play" + | pause -> "pause"; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -129,7 +129,7 @@ describe("Grammar Compiler", () => { it("Multiple duplicate variables in same rule", () => { const grammarText = ` - @ = $(x) $(y) $(x) $(y) -> { x, y } + = $(x) $(y) $(x) $(y) -> { x, y }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -144,7 +144,7 @@ describe("Grammar Compiler", () => { it("Variables in nested inline rules have separate scope", () => { const grammarText = ` - @ = $(x) (and $(x)) + = $(x) (and $(x)); `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -154,11 +154,11 @@ describe("Grammar Compiler", () => { it("Same variable in different rules should not error", () => { const grammarText = ` - @ = | - @ = play $(name) -> { name } - @ = stop $(name) -> { name } - @ = resume $(name) -> { name } - | pause $(name) -> { name } + = | ; + = play $(name) -> { name }; + = stop $(name) -> { name }; + = resume $(name) -> { name } + | pause $(name) -> { name }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -167,7 +167,7 @@ describe("Grammar Compiler", () => { it("Duplicate variable with optional modifier", () => { const grammarText = ` - @ = $(name)? $(name) -> { name } + = $(name)? $(name) -> { name }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -179,7 +179,7 @@ describe("Grammar Compiler", () => { it("Start rule without value", () => { const grammarText = ` - @ = $(x:string) $(y:string) wait + = $(x:string) $(y:string) wait; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -191,8 +191,8 @@ describe("Grammar Compiler", () => { it("Start rule with nested non-value rule", () => { const grammarText = ` - @ = - @ = $(x:string) $(y:string) wait + = ; + = $(x:string) $(y:string) wait; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -204,7 +204,7 @@ describe("Grammar Compiler", () => { it("Start rule without value with startValueRequired:false option", () => { const grammarText = ` - @ = $(x:string) $(y:string) wait + = $(x:string) $(y:string) wait; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors, undefined, { @@ -215,8 +215,8 @@ describe("Grammar Compiler", () => { it("Start rule with nested non-value rule and startValueRequired:false option", () => { const grammarText = ` - @ = - @ = $(x:string) $(y:string) wait + = ; + = $(x:string) $(y:string) wait; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors, undefined, { @@ -227,7 +227,7 @@ describe("Grammar Compiler", () => { it("Start rule with value expression is valid", () => { const grammarText = ` - @ = $(x:string) $(y:string) wait -> { x, y } + = $(x:string) $(y:string) wait -> { x, y }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -236,7 +236,7 @@ describe("Grammar Compiler", () => { it("Start rule with single variable is valid", () => { const grammarText = ` - @ = $(x:string) + = $(x:string); `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -245,7 +245,7 @@ describe("Grammar Compiler", () => { it("Start rule with single part and no variables is valid", () => { const grammarText = ` - @ = play -> "play" + = play -> "play"; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -255,9 +255,9 @@ describe("Grammar Compiler", () => { describe("Warning", () => { it("Unused", () => { const grammarText = ` - @ = - @ = pause - @ = unused + = ; + = pause; + = unused; `; const errors: string[] = []; const warnings: string[] = []; @@ -271,8 +271,8 @@ describe("Grammar Compiler", () => { it("Multiple variables without explicit value expression", () => { const grammarText = ` - @ = -> "action" - @ = $(x:string) $(y:string) + = -> "action"; + = $(x:string) $(y:string); `; const errors: string[] = []; const warnings: string[] = []; @@ -286,8 +286,8 @@ describe("Grammar Compiler", () => { it("Single variable without explicit value does not warn", () => { const grammarText = ` - @ = - @ = $(x:string) + = ; + = $(x:string); `; const errors: string[] = []; const warnings: string[] = []; @@ -298,8 +298,8 @@ describe("Grammar Compiler", () => { it("Multiple variables with explicit value does not warn", () => { const grammarText = ` - @ = - @ = $(x:string) $(y:string) -> { x, y } + = ; + = $(x:string) $(y:string) -> { x, y }; `; const errors: string[] = []; const warnings: string[] = []; @@ -310,8 +310,8 @@ describe("Grammar Compiler", () => { it("No variables without explicit value does not warn", () => { const grammarText = ` - @ = - @ = play music + = ; + = play music; `; const errors: string[] = []; const warnings: string[] = []; @@ -324,9 +324,9 @@ describe("Grammar Compiler", () => { describe("Type Imports", () => { it("Imported type reference should not error", () => { const grammarText = ` - @import { CustomType } from "types.ts" + import { CustomType } from "types.ts"; - @ = $(value:CustomType) + = $(value:CustomType); `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -335,9 +335,9 @@ describe("Grammar Compiler", () => { it("Wildcard type import allows any type reference", () => { const grammarText = ` - @import * from "types.ts" + import * from "types.ts"; - @ = $(x:CustomType) and $(y:AnotherType) -> { x, y } + = $(x:CustomType) and $(y:AnotherType) -> { x, y }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -346,10 +346,10 @@ describe("Grammar Compiler", () => { it("Multiple type imports work together", () => { const grammarText = ` - @import { Type1 } from "file1.ts" - @import { Type2 } from "file2.ts" + import { Type1 } from "file1.ts"; + import { Type2 } from "file2.ts"; - @ = $(x:Type1) $(y:Type2) -> { x, y } + = $(x:Type1) $(y:Type2) -> { x, y }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -358,7 +358,7 @@ describe("Grammar Compiler", () => { it("Built-in types do not require imports", () => { const grammarText = ` - @ = $(x:string) $(y:number) $(z:wildcard) -> { x, y, z } + = $(x:string) $(y:number) $(z:wildcard) -> { x, y, z }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -367,9 +367,9 @@ describe("Grammar Compiler", () => { it("Non-imported type errors", () => { const grammarText = ` - @import { CustomType } from "types.ts" + import { CustomType } from "types.ts"; - @ = $(x:CustomType) $(y:UndefinedType) -> { x, y } + = $(x:CustomType) $(y:UndefinedType) -> { x, y }; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -381,9 +381,9 @@ describe("Grammar Compiler", () => { it("Type imports do not affect rule validation", () => { const grammarText = ` - @import { SomeType } from "types.ts" + import { SomeType } from "types.ts"; - @ = + = ; `; const errors: string[] = []; loadGrammarRulesNoThrow("test", grammarText, errors); @@ -395,9 +395,9 @@ describe("Grammar Compiler", () => { it("Unused imported type warns", () => { const grammarText = ` - @import { UnusedType } from "types.ts" + import { UnusedType } from "types.ts"; - @ = play music + = play music; `; const errors: string[] = []; const warnings: string[] = []; @@ -411,9 +411,9 @@ describe("Grammar Compiler", () => { it("Used imported type does not warn", () => { const grammarText = ` - @import { UsedType } from "types.ts" + import { UsedType } from "types.ts"; - @ = $(x:UsedType) + = $(x:UsedType); `; const errors: string[] = []; const warnings: string[] = []; @@ -424,10 +424,10 @@ describe("Grammar Compiler", () => { it("Only unused imported types warn when mixed with used ones", () => { const grammarText = ` - @import { UsedType } from "types.ts" - @import { UnusedType } from "types.ts" + import { UsedType } from "types.ts"; + import { UnusedType } from "types.ts"; - @ = $(x:UsedType) + = $(x:UsedType); `; const errors: string[] = []; const warnings: string[] = []; @@ -441,9 +441,9 @@ describe("Grammar Compiler", () => { it("Wildcard type import does not warn when types are unused", () => { const grammarText = ` - @import * from "types.ts" + import * from "types.ts"; - @ = play music + = play music; `; const errors: string[] = []; const warnings: string[] = []; diff --git a/ts/packages/actionGrammar/test/grammarGenerator.spec.ts b/ts/packages/actionGrammar/test/grammarGenerator.spec.ts index d11be14d5..9b37ff2d3 100644 --- a/ts/packages/actionGrammar/test/grammarGenerator.spec.ts +++ b/ts/packages/actionGrammar/test/grammarGenerator.spec.ts @@ -89,7 +89,7 @@ describe("Grammar Generator", () => { analysis, schemaInfo, ); - expect(grammarRule).toContain("@ ="); + expect(grammarRule).toContain(" ="); expect(grammarRule).toContain('actionName: "playTrack"'); }, 30000); @@ -166,7 +166,7 @@ describe("Grammar Generator", () => { expect(result.success).toBe(true); expect(result.generatedRule).toBeDefined(); - expect(result.generatedRule).toContain("@ ="); + expect(result.generatedRule).toContain(" ="); expect(result.rejectionReason).toBeUndefined(); }, 30000); @@ -560,8 +560,8 @@ describe("Grammar Generator", () => { ); // Verify the rule has correct structure - expect(grammarRule).toContain("@ = "); - expect(grammarRule).toContain("@ ="); + expect(grammarRule).toContain(" = "); + expect(grammarRule).toContain(" ="); expect(grammarRule).toContain('actionName: "selectDevice"'); expect(grammarRule).toContain("$(deviceName:MusicDevice)"); diff --git a/ts/packages/actionGrammar/test/grammarImports.spec.ts b/ts/packages/actionGrammar/test/grammarImports.spec.ts index b2b116c58..8d414daf8 100644 --- a/ts/packages/actionGrammar/test/grammarImports.spec.ts +++ b/ts/packages/actionGrammar/test/grammarImports.spec.ts @@ -39,10 +39,10 @@ describe("Grammar Imports with File Loading", () => { it("should import and use a simple rule from another file", () => { const errors: string[] = []; const grammarFiles: Record = { - "greeting.agr": `@ = (hello | hi | hey) -> "greeting"`, + "greeting.agr": ` = (hello | hi | hey) -> "greeting";`, "main.agr": ` - @import { Greeting } from "./greeting.agr" - @ = $(greeting:) world -> { greeting, target: "world" } + import { Greeting } from "./greeting.agr"; + = $(greeting:) world -> { greeting, target: "world" }; `, }; const grammar = loadGrammarRulesNoThrow( @@ -72,14 +72,14 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "actions.agr": ` - @ = play $(track) -> { action: "play", track } - @ = pause -> { action: "pause" } - @ = stop -> { action: "stop" } + = play $(track) -> { action: "play", track }; + = pause -> { action: "pause" }; + = stop -> { action: "stop" }; `, "main.agr": ` - @import { Play, Pause, Stop } from "./actions.agr" + import { Play, Pause, Stop } from "./actions.agr"; - @ = | | + = | | ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -102,13 +102,13 @@ describe("Grammar Imports with File Loading", () => { it("should import from multiple files", () => { const errors: string[] = []; const grammarFiles: Record = { - "greeting.agr": `@ = (hello | hi) -> "greeting"`, - "farewell.agr": `@ = (goodbye | bye) -> "farewell"`, + "greeting.agr": ` = (hello | hi) -> "greeting";`, + "farewell.agr": ` = (goodbye | bye) -> "farewell";`, "main.agr": ` - @import { Greeting } from "./greeting.agr" - @import { Farewell } from "./farewell.agr" + import { Greeting } from "./greeting.agr"; + import { Farewell } from "./farewell.agr"; - @ = | + = | ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -130,11 +130,11 @@ describe("Grammar Imports with File Loading", () => { it("should use imported rule in a variable reference", () => { const errors: string[] = []; const grammarFiles: Record = { - "numbers.agr": `@ = one -> 1 | two -> 2 | three -> 3`, + "numbers.agr": ` = one -> 1 | two -> 2 | three -> 3;`, "main.agr": ` - @import { Number } from "./numbers.agr" + import { Number } from "./numbers.agr"; - @ = count to $(num:) -> { count: num } + = count to $(num:) -> { count: num }; `, }; const grammar = loadGrammarRulesNoThrow( @@ -160,14 +160,14 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "colors.agr": ` - @ = red -> "red" - @ = blue -> "blue" - @ = green -> "green" + = red -> "red"; + = blue -> "blue"; + = green -> "green"; `, "main.agr": ` - @import * from "./colors.agr" + import * from "./colors.agr"; - @ = | | + = | | ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -189,13 +189,13 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "actions.agr": ` - @ = action one -> 1 - @ = action two -> 2 + = action one -> 1; + = action two -> 2; `, "main.agr": ` - @import * from "./actions.agr" + import * from "./actions.agr"; - @ = | + = | ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -217,16 +217,16 @@ describe("Grammar Imports with File Loading", () => { it("should handle transitive imports (A imports B, B imports C)", () => { const errors: string[] = []; const grammarFiles: Record = { - "base.agr": `@ = base value -> "base"`, + "base.agr": ` = base value -> "base";`, "middle.agr": ` - @import { BaseRule } from "./base.agr" + import { BaseRule } from "./base.agr"; - @ = middle -> "middle" + = middle -> "middle"; `, "main.agr": ` - @import { MiddleRule } from "./middle.agr" + import { MiddleRule } from "./middle.agr"; - @ = start -> "start" + = start -> "start"; `, }; const grammar = loadGrammarRulesNoThrow( @@ -247,18 +247,18 @@ describe("Grammar Imports with File Loading", () => { it("should handle complex import chains", () => { const errors: string[] = []; const grammarFiles: Record = { - "level3.agr": `@ = level three -> 3`, + "level3.agr": ` = level three -> 3;`, "level2.agr": ` - @import { L3 } from "./level3.agr" - @ = level two -> 2 + import { L3 } from "./level3.agr"; + = level two -> 2; `, "level1.agr": ` - @import { L2 } from "./level2.agr" - @ = level one -> 1 + import { L2 } from "./level2.agr"; + = level one -> 1; `, "main.agr": ` - @import { L1 } from "./level1.agr" - @ = + import { L1 } from "./level1.agr"; + = ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -279,10 +279,10 @@ describe("Grammar Imports with File Loading", () => { it("should handle imports from subdirectories", () => { const errors: string[] = []; const grammarFiles: Record = { - "lib/utils.agr": `@ = utility -> "util"`, + "lib/utils.agr": ` = utility -> "util";`, "main.agr": ` - @import { UtilRule } from "./lib/utils.agr" - @ = rule -> "result" + import { UtilRule } from "./lib/utils.agr"; + = rule -> "result"; `, }; const grammar = loadGrammarRulesNoThrow( @@ -302,16 +302,16 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { // Deepest level: /dir1/dir2/base.agr - "dir1/dir2/base.agr": `@ = base -> "base"`, + "dir1/dir2/base.agr": ` = base -> "base";`, // Middle level: /dir1/middle.agr imports from ./dir2/base.agr (relative to /dir1/) "dir1/middle.agr": ` - @import { Base } from "./dir2/base.agr" - @ = middle -> "middle" + import { Base } from "./dir2/base.agr"; + = middle -> "middle"; `, // Top level: /main.agr imports from ./dir1/middle.agr (relative to /) "main.agr": ` - @import { Middle } from "./dir1/middle.agr" - @ = start -> "start" + import { Middle } from "./dir1/middle.agr"; + = start -> "start"; `, }; const grammar = loadGrammarRulesNoThrow( @@ -331,21 +331,21 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { // Shared utility in /shared/common.agr - "shared/common.agr": `@ = common -> "common"`, + "shared/common.agr": ` = common -> "common";`, // Module in /modules/sub/feature.agr imports from ../../shared/common.agr "modules/sub/feature.agr": ` - @import { Common } from "../../shared/common.agr" - @ = feature -> "feature" + import { Common } from "../../shared/common.agr"; + = feature -> "feature"; `, // Wrapper in /modules/wrapper.agr imports from ./sub/feature.agr "modules/wrapper.agr": ` - @import { Feature } from "./sub/feature.agr" - @ = wrapper -> "wrapper" + import { Feature } from "./sub/feature.agr"; + = wrapper -> "wrapper"; `, // Main imports from ./modules/wrapper.agr "main.agr": ` - @import { Wrapper } from "./modules/wrapper.agr" - @ = + import { Wrapper } from "./modules/wrapper.agr"; + = ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -367,8 +367,8 @@ describe("Grammar Imports with File Loading", () => { it("should throw when imported file does not exist", () => { const grammarFiles: Record = { "main.agr": ` - @import { Missing } from "./nonexistent.agr" - @ = + import { Missing } from "./nonexistent.agr"; + = ; `, }; expect(() => { @@ -377,10 +377,10 @@ describe("Grammar Imports with File Loading", () => { }); it("should throw when imported file has syntax errors", () => { const grammarFiles: Record = { - "bad.agr": `@ = invalid syntax {{{`, + "bad.agr": ` = invalid syntax {{{`, "main.agr": ` - @import { Bad } from "./bad.agr" - @ = + import { Bad } from "./bad.agr"; + = ; `, }; expect(() => { @@ -393,8 +393,8 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "main.agr": ` - @import { Missing } from "./nonexistent.agr" - @ = + import { Missing } from "./nonexistent.agr"; + = ; `, }; expect( @@ -410,10 +410,10 @@ describe("Grammar Imports with File Loading", () => { it("should error when imported rule is not defined in the file", () => { const errors: string[] = []; const grammarFiles: Record = { - "actions.agr": `@ = play -> "play"`, + "actions.agr": ` = play -> "play";`, "main.agr": ` - @import { Stop } from "./actions.agr" - @ = + import { Stop } from "./actions.agr"; + = ; `, }; loadGrammarRulesNoThrow( @@ -429,12 +429,12 @@ describe("Grammar Imports with File Loading", () => { it("should error when trying to import a locally defined rule", () => { const errors: string[] = []; const grammarFiles: Record = { - "rules.agr": `@ = imported action -> "imported"`, + "rules.agr": ` = imported action -> "imported";`, "main.agr": ` - @import { Action } from "./rules.agr" + import { Action } from "./rules.agr"; - @ = - @ = local action -> "local" + = ; + = local action -> "local"; `, }; loadGrammarRulesNoThrow( @@ -452,10 +452,10 @@ describe("Grammar Imports with File Loading", () => { it("should error when imported file has syntax errors", () => { const errors: string[] = []; const grammarFiles: Record = { - "bad.agr": `@ = invalid syntax {{{`, + "bad.agr": ` = invalid syntax {{{`, "main.agr": ` - @import { Bad } from "./bad.agr" - @ = + import { Bad } from "./bad.agr"; + = ; `, }; expect( @@ -472,10 +472,10 @@ describe("Grammar Imports with File Loading", () => { it("should refer to files using relative paths in error messages - parse error", () => { const errors: string[] = []; const grammarFiles: Record = { - "lib/broken.agr": `@ = syntax error ->`, + "lib/broken.agr": ` = syntax error ->;`, "main.agr": ` - @import { Broken } from "./lib/broken.agr" - @ = + import { Broken } from "./lib/broken.agr"; + = ; `, }; @@ -497,10 +497,10 @@ describe("Grammar Imports with File Loading", () => { it("should refer to files using relative paths in error messages - compile error", () => { const errors: string[] = []; const grammarFiles: Record = { - "lib/broken.agr": `@ = $(x:UndefinedType)`, + "lib/broken.agr": ` = $(x:UndefinedType);`, "main.agr": ` - @import { Broken } from "./lib/broken.agr" - @ = + import { Broken } from "./lib/broken.agr"; + = ; `, }; @@ -527,16 +527,16 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "base.agr": ` - @ = ( cat | dog | bird ) -> "subject" - @ = ( runs | jumps | flies ) -> "verb" - @ = the $(subject:) $(verb:) -> { + = ( cat | dog | bird ) -> "subject"; + = ( runs | jumps | flies ) -> "verb"; + = the $(subject:) $(verb:) -> { subject, verb - } + }; `, "main.agr": ` - @import { Sentence } from "./base.agr" - @ = + import { Sentence } from "./base.agr"; + = ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -564,16 +564,16 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "imported.agr": ` - @ = imported one -> 1 - @ = imported two -> 2 + = imported one -> 1; + = imported two -> 2; `, "main.agr": ` - @import { ImportedRule1, ImportedRule2 } from "./imported.agr" + import { ImportedRule1, ImportedRule2 } from "./imported.agr"; - @ = local one -> 3 - @ = local two -> 4 + = local one -> 3; + = local two -> 4; - @ = | | | + = | | | ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -596,17 +596,17 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "values.agr": ` - @ = high -> 1 | medium -> 2 | low -> 3 - @ = active -> "active" | inactive -> "inactive" + = high -> 1 | medium -> 2 | low -> 3; + = active -> "active" | inactive -> "inactive"; `, "main.agr": ` - @import { Priority, Status } from "./values.agr" + import { Priority, Status } from "./values.agr"; - @ = task $(name) priority $(p:) status $(s:) -> { + = task $(name) priority $(p:) status $(s:) -> { name, priority: p, status: s - } + }; `, }; const grammar = loadGrammarRulesNoThrow( @@ -631,11 +631,11 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "optional.agr": ` - @ = (please)? $(action) (thank you)? -> action + = (please)? $(action) (thank you)? -> action; `, "main.agr": ` - @import { Polite } from "./optional.agr" - @ = + import { Polite } from "./optional.agr"; + = ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -670,14 +670,14 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "alternatives.agr": ` - @ = + = start $(service) -> { action: "start", service } | stop $(service) -> { action: "stop", service } | - restart $(service) -> { action: "restart", service } + restart $(service) -> { action: "restart", service }; `, "main.agr": ` - @import { Command } from "./alternatives.agr" - @ = + import { Command } from "./alternatives.agr"; + = ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -704,19 +704,19 @@ describe("Grammar Imports with File Loading", () => { it("should handle same file imported from multiple places", () => { const errors: string[] = []; const grammarFiles: Record = { - "utils.agr": `@ = common -> "common"`, + "utils.agr": ` = common -> "common";`, "module1.agr": ` - @import { Common } from "./utils.agr" - @ = module1 -> "m1" + import { Common } from "./utils.agr"; + = module1 -> "m1"; `, "module2.agr": ` - @import { Common } from "./utils.agr" - @ = module2 -> "m2" + import { Common } from "./utils.agr"; + = module2 -> "m2"; `, "main.agr": ` - @import { Module1 } from "./module1.agr" - @import { Module2 } from "./module2.agr" - @ = | + import { Module1 } from "./module1.agr"; + import { Module2 } from "./module2.agr"; + = | ; `, }; const grammar = loadGrammarRulesNoThrow( @@ -739,8 +739,8 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "main.agr": ` - @import { CustomType } from "./types.ts" - @ = value $(x:CustomType) -> x + import { CustomType } from "./types.ts"; + = value $(x:CustomType) -> x; `, }; const grammar = loadGrammarRulesNoThrow( @@ -762,12 +762,12 @@ describe("Grammar Imports with File Loading", () => { it("should distinguish between grammar imports and type imports", () => { const errors: string[] = []; const grammarFiles: Record = { - "rules.agr": `@ = my rule -> "rule"`, + "rules.agr": ` = my rule -> "rule";`, "main.agr": ` - @import { MyRule } from "./rules.agr" - @import { MyType } from "./types.ts" + import { MyRule } from "./rules.agr"; + import { MyType } from "./types.ts"; - @ = $(value:MyType) -> { value } + = $(value:MyType) -> { value }; `, }; const grammar = loadGrammarRulesNoThrow( @@ -791,13 +791,13 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "fileA.agr": ` - @import { RuleB } from "./fileB.agr" - @ = a -> "a" - @ = + import { RuleB } from "./fileB.agr"; + = a -> "a"; + = ; `, "fileB.agr": ` - @import { RuleA } from "./fileA.agr" - @ = b value -> "b" + import { RuleA } from "./fileA.agr"; + = b value -> "b"; `, }; @@ -820,9 +820,9 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "fileA.agr": ` - @import { RuleA } from "./fileA.agr" - @ = a value -> "a" - @ = + import { RuleA } from "./fileA.agr"; + = a value -> "a"; + = ; `, }; @@ -844,17 +844,17 @@ describe("Grammar Imports with File Loading", () => { const errors: string[] = []; const grammarFiles: Record = { "fileA.agr": ` - @import { RuleB } from "./fileB.agr" - @ = a -> "a" - @ = + import { RuleB } from "./fileB.agr"; + = a -> "a"; + = ; `, "fileB.agr": ` - @import { RuleC } from "./fileC.agr" - @ = b -> "b" + import { RuleC } from "./fileC.agr"; + = b -> "b"; `, "fileC.agr": ` - @import { RuleA } from "./fileA.agr" - @ = c value -> "c" + import { RuleA } from "./fileA.agr"; + = c value -> "c"; `, }; diff --git a/ts/packages/actionGrammar/test/grammarMatcher.spec.ts b/ts/packages/actionGrammar/test/grammarMatcher.spec.ts index 5113a6f6b..5c3fcc0ae 100644 --- a/ts/packages/actionGrammar/test/grammarMatcher.spec.ts +++ b/ts/packages/actionGrammar/test/grammarMatcher.spec.ts @@ -22,14 +22,14 @@ describe("Grammar Matcher", () => { [{ arr: [{ nested: true }] }], ]; it.each(values)("matched value - '%j'", (v) => { - const g = `@ = hello world -> ${JSON.stringify(v)}`; + const g = ` = hello world -> ${JSON.stringify(v)};`; const grammar = loadGrammarRules("test.grammar", g); const match = testMatchGrammar(grammar, "hello world"); expect(match).toStrictEqual([v]); }); }); describe("Basic Match", () => { - const g = `@ = hello world -> true`; + const g = ` = hello world -> true;`; const grammar = loadGrammarRules("test.grammar", g); it("space prefix", () => { @@ -55,49 +55,49 @@ describe("Grammar Matcher", () => { }); describe("Escaped Match", () => { it("escaped space prefix", () => { - const g = `@ = ${escapedSpaces}hello world -> true`; + const g = ` = ${escapedSpaces}hello world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `${spaces}hello world`), ).toStrictEqual([true]); }); it("escaped space prefix - alt space", () => { - const g = `@ = ${escapedSpaces}hello world -> true`; + const g = ` = ${escapedSpaces}hello world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `${spaces}hello\tworld`), ).toStrictEqual([true]); }); it("escaped space prefix - extra space", () => { - const g = `@ = ${escapedSpaces}hello world -> true`; + const g = ` = ${escapedSpaces}hello world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, ` ${spaces}hello \nworld`), ).toStrictEqual([true]); }); it("escaped space - not match", () => { - const g = `@ = ${escapedSpaces}hello world -> true`; + const g = ` = ${escapedSpaces}hello world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `${spaces} hello world`), ).toStrictEqual([]); }); it("escaped space infix", () => { - const g = `@ = hello${escapedSpaces} world -> true`; + const g = ` = hello${escapedSpaces} world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `hello${spaces} world`), ).toStrictEqual([true]); }); it("escaped space infix - extra space", () => { - const g = `@ = hello${escapedSpaces} world -> true`; + const g = ` = hello${escapedSpaces} world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `hello${spaces} \r\vworld`), ).toStrictEqual([true]); }); it("escaped space infix - not match", () => { - const g = `@ = hello${escapedSpaces} world -> true`; + const g = ` = hello${escapedSpaces} world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `hello${spaces}world`), @@ -107,7 +107,7 @@ describe("Grammar Matcher", () => { ).toStrictEqual([]); }); it("escaped space infix - no space", () => { - const g = `@ = hello${escapedSpaces}world -> true`; + const g = ` = hello${escapedSpaces}world -> true;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `hello${spaces}world`), @@ -119,89 +119,89 @@ describe("Grammar Matcher", () => { }); describe("Variable Match", () => { it("simple variable - explicit string", () => { - const g = `@ = $(x:string) -> x`; + const g = ` = $(x:string) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "value")).toStrictEqual(["value"]); }); it("simple variable - explicit type name", () => { const g = ` - @import { TrackName } from "types.ts" - @ = $(x:TrackName) -> x + import { TrackName } from "types.ts"; + = $(x:TrackName) -> x; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "value")).toStrictEqual(["value"]); }); it("simple variable - implicit string type", () => { - const g = `@ = $(x) -> x`; + const g = ` = $(x) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "value")).toStrictEqual(["value"]); }); it("simple variable - simple integer", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "1234")).toStrictEqual([1234]); }); it("simple variable - minus integer", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "-1234")).toStrictEqual([-1234]); }); it("simple variable - plus integer", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "+1234")).toStrictEqual([1234]); }); it("simple variable - octal", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "0o123")).toStrictEqual([0o123]); }); it("simple variable - binary", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "0b0101")).toStrictEqual([0b101]); }); it("simple variable - hex", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "0x123")).toStrictEqual([0x123]); }); it("simple variable - float", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "10.123")).toStrictEqual([10.123]); }); it("simple variable - negative float", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "-02120.123")).toStrictEqual([ -2120.123, ]); }); it("simple variable - float with exponent", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "45.678e-9")).toStrictEqual([ 45.678e-9, ]); }); it("simple variable - optional", () => { - const g = `@ = hello $(x:number)? -> x`; + const g = ` = hello $(x:number)? -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "hello")).toStrictEqual([ undefined, ]); }); it("space around variable - string", () => { - const g = `@ = hello $(x) world -> x`; + const g = ` = hello $(x) world -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `hello${spaces}value${spaces}world`), ).toStrictEqual(["value"]); }); it("space around variable - number", () => { - const g = `@ = hello $(x:number) world -> x`; + const g = ` = hello $(x:number) world -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, `hello${spaces}123${spaces}world`), @@ -209,7 +209,7 @@ describe("Grammar Matcher", () => { }); it("no space around variable - number and string not separated", () => { - const g = `@ = $(x:number) $(y: string)-> { n: x, s: y }`; + const g = ` = $(x:number) $(y: string)-> { n: x, s: y };`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "1234b")).toStrictEqual([ { n: 1234, s: "b" }, @@ -217,7 +217,7 @@ describe("Grammar Matcher", () => { }); it("no space around variable - number and term not separated", () => { - const g = `@ = $(x:number)\\-$(y:number)pm -> { a: x, b: y }`; + const g = ` = $(x:number)\\-$(y:number)pm -> { a: x, b: y };`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "1-2pm")).toStrictEqual([ { a: 1, b: 2 }, @@ -225,8 +225,8 @@ describe("Grammar Matcher", () => { }); it("multiple", () => { const g = ` - @ = $(x:number) -> x - @ = $(x) -> x`; + = $(x:number) -> x; + = $(x) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "13.348")).toStrictEqual([ 13.348, @@ -235,9 +235,9 @@ describe("Grammar Matcher", () => { }); it("nested rules", () => { const g = ` - @ = $(x:) $(y:) -> { hello: x, world: y } - @ = hello -> "hello" - @ = world -> "world" + = $(x:) $(y:) -> { hello: x, world: y }; + = hello -> "hello"; + = world -> "world"; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "hello world")).toStrictEqual([ @@ -246,9 +246,9 @@ describe("Grammar Matcher", () => { }); it("nested rules - default value", () => { const g = ` - @ = - @ = hello -> "first" - @ = hello -> "second" + = ; + = hello -> "first"; + = hello -> "second"; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "hello")).toStrictEqual([ @@ -258,9 +258,9 @@ describe("Grammar Matcher", () => { }); it("nested rules - default value with str expr", () => { const g = ` - @ = A $(h:) world -> h - @ = hello -> "first" - @ = hello -> "second" + = A $(h:) world -> h; + = hello -> "first"; + = hello -> "second"; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "a hello world")).toStrictEqual([ @@ -271,8 +271,8 @@ describe("Grammar Matcher", () => { it("nested rules - single string part captures matched text", () => { const g = ` - @ = $(x:) -> x - @ = hello + = $(x:) -> x; + = hello; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "hello")).toStrictEqual(["hello"]); @@ -280,8 +280,8 @@ describe("Grammar Matcher", () => { it("nested rules - single string part with multiple words", () => { const g = ` - @ = $(x:) -> x - @ = hello world + = $(x:) -> x; + = hello world; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "hello world")).toStrictEqual([ @@ -291,9 +291,9 @@ describe("Grammar Matcher", () => { it("nested rules - single string part in complex expression", () => { const g = ` - @ = $(a:) and $(b:) -> { a, b } - @ = first - @ = second + = $(a:) and $(b:) -> { a, b }; + = first; + = second; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "first and second")).toStrictEqual( @@ -303,10 +303,10 @@ describe("Grammar Matcher", () => { it("nested rules - multiple parts should not capture default", () => { const g = ` - @ = $(x:) -> x - @ = - @ = hello - @ = world + = $(x:) -> x; + = ; + = hello; + = world; `; expect(() => loadGrammarRules("test.grammar", g)).toThrow( "Referenced rule '' does not produce a value for variable 'x' in definition ''", @@ -315,7 +315,7 @@ describe("Grammar Matcher", () => { it("wildcard ", () => { const g = ` - @ = hello $(x) world -> x + = hello $(x) world -> x; `; const grammar = loadGrammarRules("test.grammar", g); expect( @@ -324,8 +324,8 @@ describe("Grammar Matcher", () => { }); it("wildcard at end of nested rule", () => { const g = ` - @ = $(h:) world -> h - @ = hello $(x) -> x + = $(h:) world -> h; + = hello $(x) -> x; `; const grammar = loadGrammarRules("test.grammar", g); expect( @@ -335,8 +335,8 @@ describe("Grammar Matcher", () => { it("wildcard at before the nested rule", () => { const g = ` - @ = hello $(x) -> x - @ = world + = hello $(x) -> x; + = world; `; const grammar = loadGrammarRules("test.grammar", g); expect( @@ -345,7 +345,7 @@ describe("Grammar Matcher", () => { }); it("wildcard alternates", () => { - const g = `@ = $(x) by $(y) -> [x, y]`; + const g = ` = $(x) by $(y) -> [x, y];`; const grammar = loadGrammarRules("test.grammar", g); expect( testMatchGrammar(grammar, "song by the sea by Bach"), @@ -358,23 +358,23 @@ describe("Grammar Matcher", () => { describe("Not matched", () => { it("string expr not separated", () => { const g = ` - @ = hello world -> true + = hello world -> true; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "helloworld")).toStrictEqual([]); }); it("sub-string expr not separated", () => { const g = ` - @ = -> true - @ = hello - @ = world + = -> true; + = hello; + = world; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "helloworld")).toStrictEqual([]); }); it("trailing text", () => { const g = ` - @ = hello world -> true + = hello world -> true; `; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "hello world more")).toStrictEqual( @@ -382,34 +382,34 @@ describe("Grammar Matcher", () => { ); }); it("number variable - minus octal", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "-0o123")).toStrictEqual([]); }); it("number variable - plus octal", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "+0o123")).toStrictEqual([]); }); it("number variable - minus binary", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "-0b101")).toStrictEqual([]); }); it("number variable - plus binary", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "+0b0101")).toStrictEqual([]); }); it("number variable - minus octal", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "-0x123")).toStrictEqual([]); }); it("number variable - plus octal", () => { - const g = `@ = $(x:number) -> x`; + const g = ` = $(x:number) -> x;`; const grammar = loadGrammarRules("test.grammar", g); expect(testMatchGrammar(grammar, "+0x123")).toStrictEqual([]); }); diff --git a/ts/packages/actionGrammar/test/grammarRuleParser.spec.ts b/ts/packages/actionGrammar/test/grammarRuleParser.spec.ts index 107e868fd..56a818e57 100644 --- a/ts/packages/actionGrammar/test/grammarRuleParser.spec.ts +++ b/ts/packages/actionGrammar/test/grammarRuleParser.spec.ts @@ -10,7 +10,7 @@ const testParamGrammarRules = (fileName: string, content: string) => describe("Grammar Rule Parser", () => { describe("Basic Rule Definitions", () => { it("a simple rule with string expression", () => { - const grammar = "@ = hello world"; + const grammar = " = hello world;"; const result = testParamGrammarRules("test.agr", grammar); expect(result).toEqual([ @@ -31,7 +31,7 @@ describe("Grammar Rule Parser", () => { }); it("a rule with multiple alternatives", () => { - const grammar = "@ = hello | hi | hey"; + const grammar = " = hello | hi | hey;"; const result = testParamGrammarRules("test.agr", grammar); expect(result).toHaveLength(1); @@ -52,7 +52,7 @@ describe("Grammar Rule Parser", () => { }); it("a rule with value mapping", () => { - const grammar = '@ = hello -> "greeting"'; + const grammar = ' = hello -> "greeting";'; const result = testParamGrammarRules("test.agr", grammar); expect(result).toHaveLength(1); @@ -64,8 +64,8 @@ describe("Grammar Rule Parser", () => { it("multiple rule definitions", () => { const grammar = ` - @ = hello - @ = goodbye + = hello; + = goodbye; `; const result = testParamGrammarRules("test.agr", grammar); @@ -75,7 +75,7 @@ describe("Grammar Rule Parser", () => { }); it("rule with rule reference", () => { - const grammar = "@ = world"; + const grammar = " = world;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions).toHaveLength(2); @@ -92,7 +92,7 @@ describe("Grammar Rule Parser", () => { describe("Expression Parsing", () => { it("variable expressions with default type", () => { - const grammar = "@ = $(name)"; + const grammar = " = $(name);"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -104,7 +104,7 @@ describe("Grammar Rule Parser", () => { }); it("variable expressions with specified type", () => { - const grammar = "@ = $(count:number)"; + const grammar = " = $(count:number);"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -116,7 +116,7 @@ describe("Grammar Rule Parser", () => { }); it("variable expressions with rule reference", () => { - const grammar = "@ = $(item:)"; + const grammar = " = $(item:);"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -128,7 +128,7 @@ describe("Grammar Rule Parser", () => { }); it("variable expressions - optional", () => { - const grammar = "@ = $(item:)?"; + const grammar = " = $(item:)?;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -141,7 +141,7 @@ describe("Grammar Rule Parser", () => { }); it("group expressions", () => { - const grammar = "@ = (hello | hi) world"; + const grammar = " = (hello | hi) world;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions).toHaveLength(2); @@ -161,7 +161,7 @@ describe("Grammar Rule Parser", () => { }); it("optional group expressions", () => { - const grammar = "@ = (please)? help"; + const grammar = " = (please)? help;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -177,7 +177,7 @@ describe("Grammar Rule Parser", () => { }); it("complex expressions with multiple components", () => { - const grammar = "@ = $(action) the $(adverb:string)"; + const grammar = " = $(action) the $(adverb:string);"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions).toHaveLength(4); @@ -193,7 +193,7 @@ describe("Grammar Rule Parser", () => { }); it("should handle escaped characters in string expressions", () => { - const grammar = "@ = hello\\0world"; + const grammar = " = hello\\0world;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -205,8 +205,8 @@ describe("Grammar Rule Parser", () => { describe("Value Parsing", () => { it("boolean literal values", () => { - const grammar1 = "@ = test -> true"; - const grammar2 = "@ = test -> false"; + const grammar1 = " = test -> true;"; + const grammar2 = " = test -> false;"; const result1 = testParamGrammarRules("test.agr", grammar1); const result2 = testParamGrammarRules("test.agr", grammar2); @@ -222,7 +222,7 @@ describe("Grammar Rule Parser", () => { }); it("float literal values", () => { - const grammar = "@ = test -> 42.5"; + const grammar = " = test -> 42.5;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -232,7 +232,7 @@ describe("Grammar Rule Parser", () => { }); it("integer literal values", () => { - const grammar = "@ = test -> 12"; + const grammar = " = test -> 12;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -242,7 +242,7 @@ describe("Grammar Rule Parser", () => { }); it("integer hex literal values", () => { - const grammar = "@ = test -> 0xC"; + const grammar = " = test -> 0xC;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -252,7 +252,7 @@ describe("Grammar Rule Parser", () => { }); it("integer oct literal values", () => { - const grammar = "@ = test -> 0o14"; + const grammar = " = test -> 0o14;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -262,7 +262,7 @@ describe("Grammar Rule Parser", () => { }); it("integer binary literal values", () => { - const grammar = "@ = test -> 0b1100"; + const grammar = " = test -> 0b1100;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -272,8 +272,8 @@ describe("Grammar Rule Parser", () => { }); it("string literal values", () => { - const grammar1 = '@ = test -> "hello world"'; - const grammar2 = "@ = test -> 'hello world'"; + const grammar1 = ' = test -> "hello world";'; + const grammar2 = " = test -> 'hello world';"; const result1 = testParamGrammarRules("test.agr", grammar1); const result2 = testParamGrammarRules("test.agr", grammar2); @@ -289,7 +289,7 @@ describe("Grammar Rule Parser", () => { }); it("string values with escape sequences", () => { - const grammar = '@ = test -> "hello\\tworld\\n"'; + const grammar = ' = test -> "hello\\tworld\\n";'; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -299,7 +299,7 @@ describe("Grammar Rule Parser", () => { }); it("array values", () => { - const grammar = '@ = test -> [1, "hello", true]'; + const grammar = ' = test -> [1, "hello", true];'; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -313,7 +313,7 @@ describe("Grammar Rule Parser", () => { }); it("empty array values", () => { - const grammar = "@ = test -> []"; + const grammar = " = test -> [];"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -323,7 +323,7 @@ describe("Grammar Rule Parser", () => { }); it("object values", () => { - const grammar = '@ = test -> {type: "greeting", count: 1}'; + const grammar = ' = test -> {type: "greeting", count: 1};'; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -336,7 +336,7 @@ describe("Grammar Rule Parser", () => { }); it("empty object values", () => { - const grammar = "@ = test -> {}"; + const grammar = " = test -> {};"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -347,7 +347,7 @@ describe("Grammar Rule Parser", () => { it("object values with single quote properties", () => { const grammar = - "@ = test -> {'type': \"greeting\", 'count': 1}"; + " = test -> {'type': \"greeting\", 'count': 1};"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -361,7 +361,7 @@ describe("Grammar Rule Parser", () => { it("object values with double quote properties", () => { const grammar = - '@ = test -> {"type": "greeting", "count": 1}'; + ' = test -> {"type": "greeting", "count": 1};'; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -374,7 +374,7 @@ describe("Grammar Rule Parser", () => { }); it("variable reference values", () => { - const grammar = "@ = $(name) -> name"; + const grammar = " = $(name) -> name;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -385,7 +385,7 @@ describe("Grammar Rule Parser", () => { it("nested object and array values", () => { const grammar = - "@ = test -> {items: [1, 2], meta: {count: 2}}"; + " = test -> {items: [1, 2], meta: {count: 2}};"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].value).toEqual({ @@ -410,7 +410,7 @@ describe("Grammar Rule Parser", () => { it("should handle nested groups and complex expressions", () => { const grammar = ` - @ = (please)? ($(action) | do) (the)? $(object) ($(adverb))? -> { + = (please)? ($(action) | do) (the)? $(object) ($(adverb))? -> { politeness, actions: [action, "execute"], target: { @@ -420,7 +420,7 @@ describe("Grammar Rule Parser", () => { modifier: adverb } } - } + }; `; const result = testParamGrammarRules("nested.agr", grammar); @@ -554,9 +554,9 @@ describe("Grammar Rule Parser", () => { it("grammar with unicode and special characters", () => { const grammar = ` - @ = café \\u00E9 -> "café" - @ = hello\\tworld\\n -> "formatted" - @ = \\@ \\| \\( \\) -> "escaped" + = café \\u00E9 -> "café"; + = hello\\tworld\\n -> "formatted"; + = \\| \\( \\) -> "escaped"; `; const result = testParamGrammarRules("unicode.agr", grammar); @@ -572,7 +572,7 @@ describe("Grammar Rule Parser", () => { }); expect(result[2].rules[0].expressions[0]).toEqual({ type: "string", - value: ["@", "|", "(", ")"], + value: ["|", "(", ")"], }); }); }); @@ -581,7 +581,7 @@ describe("Grammar Rule Parser", () => { it("should handle collapse whitespace between tokens", () => { const spaces = " \t\v\f\u00a0\ufeff\n\r\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000"; - const grammar = `${spaces}@${spaces}${spaces}=${spaces}hello${spaces}world${spaces}->${spaces}true${spaces}`; + const grammar = `${spaces}${spaces}=${spaces}hello${spaces}world${spaces}->${spaces}true${spaces};`; const result = testParamGrammarRules("test.agr", grammar); expect(result).toEqual([ @@ -606,7 +606,7 @@ describe("Grammar Rule Parser", () => { }); it("should keep escaped whitespace in expression", () => { - const grammar = `@=${escapedSpaces}hello${escapedSpaces}world${escapedSpaces}->true`; + const grammar = `=${escapedSpaces}hello${escapedSpaces}world${escapedSpaces}->true;`; const result = testParamGrammarRules("test.agr", grammar); expect(result).toEqual([ @@ -635,7 +635,7 @@ describe("Grammar Rule Parser", () => { it("should handle single-line comments", () => { const grammar = ` // This is a greeting rule - @ = hello // End of line comment + = hello; // End of line comment // Another comment `; const result = testParamGrammarRules("test.agr", grammar); @@ -646,11 +646,11 @@ describe("Grammar Rule Parser", () => { it("should handle multi-line comments", () => { const grammar = ` - /* + /* * This is a multi-line comment * describing the greeting rule */ - @ = hello /* inline comment */ world + = hello /* inline comment */ world; `; const result = testParamGrammarRules("test.agr", grammar); @@ -661,7 +661,7 @@ describe("Grammar Rule Parser", () => { }); it("should handle mixed whitespace types", () => { - const grammar = "@\t=\r\nhello\n\t world"; + const grammar = "\t=\r\nhello\n\t world;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -671,7 +671,7 @@ describe("Grammar Rule Parser", () => { }); it("should collapse multiple whitespace in strings to single space", () => { - const grammar = "@ = hello world\t\t\ttest"; + const grammar = " = hello world\t\t\ttest;"; const result = testParamGrammarRules("test.agr", grammar); expect(result[0].rules[0].expressions[0]).toEqual({ @@ -682,11 +682,11 @@ describe("Grammar Rule Parser", () => { it("should handle comments in values", () => { const grammar = ` - @ = test -> { + = test -> { // Property comment type: "greeting", /* inline */ count: 1 - } + }; `; const result = testParamGrammarRules("test.agr", grammar); @@ -701,113 +701,113 @@ describe("Grammar Rule Parser", () => { }); describe("Error Handling", () => { - it("should throw error for missing @ at start of rule", () => { + it("should throw error for missing rule terminator", () => { const grammar = " = hello"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( - "Expected 'entity' declaration, '@import' statement, or '@' rule definition", + "';' expected", ); }); it("should throw error for malformed rule name", () => { - const grammar = "@greeting = hello"; + const grammar = "greeting = hello;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( - "Expected 'entity' declaration, '@import' statement, or '@' rule definition", + "Expected rule definition, 'import' statement, or 'entity' declaration", ); }); it("should throw error for missing equals sign", () => { - const grammar = "@ hello"; + const grammar = " hello;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "'=' expected", ); }); it("should throw error for unterminated string literal", () => { - const grammar = '@ = test -> "unterminated'; + const grammar = ' = test -> "unterminated'; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Unterminated string literal", ); }); it("should throw error for unterminated variable", () => { - const grammar = "@ = $(name"; + const grammar = " = $(name;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "')' expected", ); }); it("should throw error for unterminated group", () => { - const grammar = "@ = (hello"; + const grammar = " = (hello;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "')' expected", ); }); it("should throw error for invalid escape sequence", () => { - const grammar = '@ = test -> "invalid\\'; + const grammar = ' = test -> "invalid\\'; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Missing escaped character.", ); }); it("should throw error for invalid hex escape", () => { - const grammar = '@ = test -> "\\xZZ"'; + const grammar = ' = test -> "\\xZZ";'; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Invalid hex escape sequence", ); }); it("should throw error for invalid unicode escape", () => { - const grammar = '@ = test -> "\\uZZZZ"'; + const grammar = ' = test -> "\\uZZZZ";'; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Invalid Unicode escape sequence", ); }); it("should throw error for unterminated array", () => { - const grammar = "@ = test -> [1, 2"; + const grammar = " = test -> [1, 2"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Unexpected end of file in array value", ); }); it("should throw error for unterminated object", () => { - const grammar = '@ = test -> {type: "test"'; + const grammar = ' = test -> {type: "test"'; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Unexpected end of file in object value", ); }); it("should throw error for missing colon in object", () => { - const grammar = '@ = test -> {type "test"}'; + const grammar = ' = test -> {type "test"};'; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "':' expected", ); }); it("should throw error for invalid number", () => { - const grammar = "@ = test -> 1abc"; + const grammar = " = test -> 1abc;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Invalid literal", ); }); it("should throw error for infinity values", () => { - const grammar = "@ = test -> Infinity"; + const grammar = " = test -> Infinity;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Infinity values are not allowed", ); }); it("should throw error for unescaped special characters", () => { - const grammar = "@ = hello-world"; + const grammar = " = hello-world;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Special character needs to be escaped", ); }); it("should throw error for empty expression", () => { - const grammar = "@ = "; + const grammar = " = ;"; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( "Empty expression", ); @@ -815,8 +815,8 @@ describe("Grammar Rule Parser", () => { it("should include line and column information in errors", () => { const grammar = ` - @ = hello - @invalid = world + = hello; + invalid = world; `; expect(() => testParamGrammarRules("test.agr", grammar)).toThrow( /test\.agr:\d+:\d+:/, @@ -827,7 +827,7 @@ describe("Grammar Rule Parser", () => { describe("Complex Integration", () => { it("should handle deeply nested value structures", () => { const grammar = ` - @ = test -> { + = test -> { config: { settings: [ {name: "debug", value: true}, @@ -839,7 +839,7 @@ describe("Grammar Rule Parser", () => { } }, variables: [param1, param2] - } + }; `; const result = testParamGrammarRules("deeply-nested.agr", grammar); @@ -854,31 +854,31 @@ describe("Grammar Rule Parser", () => { it("real-world conversation patterns", () => { const grammar = ` // Weather queries - @ = (what's | what is) the weather (like)? (in $(location))? -> { + = (what's | what is) the weather (like)? (in $(location))? -> { intent: "weather.query", location, type: "current" - } + }; // Calendar operations - @ = (schedule | book) (a)? $(event) (for | on) $(date) (at $(time))? -> { + = (schedule | book) (a)? $(event) (for | on) $(date) (at $(time))? -> { intent: "calendar.create", event: { title: event, date, time } - } + }; // Music control - @ = (play | start) $(song)? (by $(artist))? -> { + = (play | start) $(song)? (by $(artist))? -> { intent: "music.play", query: { song, artist }, shuffle: false - } + }; `; const result = testParamGrammarRules("conversation.agr", grammar); @@ -898,7 +898,7 @@ describe("Grammar Rule Parser", () => { describe("Import Statements", () => { it("parse granular import statement", () => { - const grammar = '@import { Name1, Name2 } from "file.agr"'; + const grammar = 'import { Name1, Name2 } from "file.agr";'; const result = parseGrammarRules("test.agr", grammar, false); expect(result.imports).toHaveLength(1); @@ -907,7 +907,7 @@ describe("Grammar Rule Parser", () => { }); it("parse wildcard import statement", () => { - const grammar = '@import * from "file.agr"'; + const grammar = 'import * from "file.agr";'; const result = parseGrammarRules("test.agr", grammar, false); expect(result.imports).toHaveLength(1); @@ -917,9 +917,9 @@ describe("Grammar Rule Parser", () => { it("parse multiple import statements", () => { const grammar = ` - @import { Action1, Action2 } from "actions.agr" - @import * from "types.ts" - @import { Helper } from "helpers.agr" + import { Action1, Action2 } from "actions.agr"; + import * from "types.ts"; + import { Helper } from "helpers.agr"; `; const result = parseGrammarRules("test.agr", grammar, false); @@ -934,10 +934,10 @@ describe("Grammar Rule Parser", () => { it("parse imports with grammar rules", () => { const grammar = ` - @import { BaseRule } from "base.agr" + import { BaseRule } from "base.agr"; - @ = world - @ = hello + = world; + = hello; `; const result = parseGrammarRules("test.agr", grammar, false); @@ -949,7 +949,7 @@ describe("Grammar Rule Parser", () => { }); it("parse single name import", () => { - const grammar = '@import { SingleName } from "file.agr"'; + const grammar = 'import { SingleName } from "file.agr";'; const result = parseGrammarRules("test.agr", grammar, false); expect(result.imports).toHaveLength(1); diff --git a/ts/packages/actionGrammar/test/grammarRuleWriter.spec.ts b/ts/packages/actionGrammar/test/grammarRuleWriter.spec.ts index dd34c6334..1de6e5dc3 100644 --- a/ts/packages/actionGrammar/test/grammarRuleWriter.spec.ts +++ b/ts/packages/actionGrammar/test/grammarRuleWriter.spec.ts @@ -17,78 +17,78 @@ function validateRoundTrip(grammar: string) { describe("Grammar Rule Writer", () => { it("simple", () => { - validateRoundTrip(`@ = hello world`); + validateRoundTrip(` = hello world;`); }); it("alternates", () => { - validateRoundTrip(`@ = hello | world | again`); + validateRoundTrip(` = hello | world | again;`); }); it("multiple rules", () => { validateRoundTrip(` - @ = hello | world | again - @ = one two three + = hello | world | again; + = one two three; `); }); it("rule reference", () => { validateRoundTrip(` - @ = hello world - @ = one two three + = hello world; + = one two three; `); }); it("optional rule reference", () => { validateRoundTrip(` - @ = hello ()? world - @ = one | two | three + = hello ()? world; + = one | two | three; `); }); it("spaces in expressions", () => { validateRoundTrip( - `@ = ${spaces}${escapedSpaces}${spaces}${escapedSpaces}${spaces}`, + ` = ${spaces}${escapedSpaces}${spaces}${escapedSpaces}${spaces};`, ); }); it("special characters in expressions", () => { validateRoundTrip( - `@ = ${expressionsSpecialChar.map((c) => `\\${c}`).join("")}`, + ` = ${expressionsSpecialChar.map((c) => `\\${c}`).join("")};`, ); }); it("with string value", () => { - validateRoundTrip(`@ = hello -> "greeting"`); + validateRoundTrip(` = hello -> "greeting";`); }); it("with boolean value", () => { - validateRoundTrip(`@ = hello -> true`); + validateRoundTrip(` = hello -> true;`); }); it("with number value", () => { - validateRoundTrip(`@ = hello -> -12.3e+2`); + validateRoundTrip(` = hello -> -12.3e+2;`); }); it("with object value", () => { - validateRoundTrip(`@ = hello -> { b: true, n: 12, s: "string" }`); + validateRoundTrip(` = hello -> { b: true, n: 12, s: "string" };`); }); it("with array value", () => { - validateRoundTrip(`@ = hello -> [true, 34.3, "string"]`); + validateRoundTrip(` = hello -> [true, 34.3, "string"];`); }); it("with nested value", () => { validateRoundTrip( - `@ = hello -> { b: true, n: 12, s: "string", a: [1, 2, { o: "z" }], o: { x: [] } }`, + ` = hello -> { b: true, n: 12, s: "string", a: [1, 2, { o: "z" }], o: { x: [] } };`, ); }); it("with variable", () => { validateRoundTrip( - `@ = hello $(x) world -> { "type": "test", "var": x }`, + ` = hello $(x) world -> { "type": "test", "var": x };`, ); }); it("with number variable", () => { validateRoundTrip( - `@ = hello $(x: number) world -> { "type": "test", "var": x }`, + ` = hello $(x: number) world -> { "type": "test", "var": x };`, ); }); it("with rules reference variable", () => { - validateRoundTrip(`@ = hello $(x:) world -> { "type": "test", "var": x } - @ = one -> 1 | two ->2 | three -> 3`); + validateRoundTrip(` = hello $(x:) world -> { "type": "test", "var": x }; + = one -> 1 | two ->2 | three -> 3;`); }); it("with optional variable", () => { validateRoundTrip( - `@ = hello $(x: number)? world -> { "type": "test", "var": x }`, + ` = hello $(x: number)? world -> { "type": "test", "var": x };`, ); }); }); diff --git a/ts/packages/actionGrammar/test/grammarSerialization.spec.ts b/ts/packages/actionGrammar/test/grammarSerialization.spec.ts index 055909bbf..26a05f352 100644 --- a/ts/packages/actionGrammar/test/grammarSerialization.spec.ts +++ b/ts/packages/actionGrammar/test/grammarSerialization.spec.ts @@ -8,8 +8,8 @@ import { grammarToJson } from "../src/grammarSerializer.js"; describe("Grammar Serialization", () => { it("Round trip", () => { const grammarText = ` - @ = hello $(x:number) -> { greeting: x, x } - @ = one | two | three | $(y:string) | maybe + = hello $(x:number) -> { greeting: x, x }; + = one | two | three | $(y:string) | maybe ; `; const grammar = loadGrammarRules("test", grammarText); const serialized = grammarToJson(grammar); diff --git a/ts/packages/actionGrammar/test/grammarStore.spec.ts b/ts/packages/actionGrammar/test/grammarStore.spec.ts index 4e49987d4..6b2d2dc1e 100644 --- a/ts/packages/actionGrammar/test/grammarStore.spec.ts +++ b/ts/packages/actionGrammar/test/grammarStore.spec.ts @@ -46,7 +46,7 @@ describe("GrammarStore", () => { const store = new GrammarStore(); await store.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", sourceRequest: "play Bohemian Rhapsody", actionName: "playTrack", @@ -68,12 +68,12 @@ describe("GrammarStore", () => { const store = new GrammarStore(); await store.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", }); await store.addRule({ - grammarText: '@ = "schedule" $(event:string)', + grammarText: ' = "schedule" $(event:string)', schemaName: "calendar", }); @@ -89,12 +89,12 @@ describe("GrammarStore", () => { const store = new GrammarStore(); await store.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", }); await store.addRule({ - grammarText: '@ = "pause"', + grammarText: ' = "pause"', schemaName: "player", }); @@ -109,7 +109,7 @@ describe("GrammarStore", () => { const store = new GrammarStore(); store.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", }); @@ -126,7 +126,7 @@ describe("GrammarStore", () => { const store1 = new GrammarStore(); await store1.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", sourceRequest: "play music", actionName: "playTrack", @@ -154,7 +154,7 @@ describe("GrammarStore", () => { await store.setAutoSave(true); await store.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", }); @@ -188,13 +188,13 @@ describe("GrammarStore", () => { const store = new GrammarStore(); await store.addRule({ - grammarText: '@ = "play" $(track:string)', + grammarText: ' = "play" $(track:string)', schemaName: "player", sourceRequest: "play music", }); await store.addRule({ - grammarText: '@ = "pause"', + grammarText: ' = "pause"', schemaName: "player", sourceRequest: "pause", }); @@ -203,8 +203,8 @@ describe("GrammarStore", () => { expect(agr).toContain("# Dynamic Grammar Rules for player"); expect(agr).toContain("# 2 rule(s)"); - expect(agr).toContain('@ = "play" $(track:string)'); - expect(agr).toContain('@ = "pause"'); + expect(agr).toContain(' = "play" $(track:string)'); + expect(agr).toContain(' = "pause"'); expect(agr).toContain('Source: "play music"'); }); @@ -212,13 +212,13 @@ describe("GrammarStore", () => { const store = new GrammarStore(); store.addRule({ - grammarText: "@ = ", + grammarText: " = ;", schemaName: "player", }); store.addRule({ grammarText: - '@ = "play" $(track:string) -> { actionName: "playTrack", parameters: { track } }', + ' = "play" $(track:string) -> { actionName: "playTrack", parameters: { track } };', schemaName: "player", }); diff --git a/ts/packages/agentSdkWrapper/src/schemaToGrammarGenerator.ts b/ts/packages/agentSdkWrapper/src/schemaToGrammarGenerator.ts index b7ac9f913..1e43a540e 100644 --- a/ts/packages/agentSdkWrapper/src/schemaToGrammarGenerator.ts +++ b/ts/packages/agentSdkWrapper/src/schemaToGrammarGenerator.ts @@ -43,7 +43,7 @@ const SCHEMA_GRAMMAR_PROMPT = `You are an expert at creating comprehensive Actio Your task is to analyze a complete action schema and generate an efficient, maintainable grammar that covers all actions with shared sub-rules where appropriate. The Action Grammar format uses: -- Rule definitions: @ = pattern +- Rule definitions: = pattern; - Literal text: "play" or 'play' - Wildcards with types: $(name:Type) - captures any text and assigns it to 'name' with validation type 'Type' - Optional elements: element? @@ -70,22 +70,22 @@ CRITICAL SYNTAX RULES: 4. Wildcard type annotations CANNOT contain pipes or unions For parameters with union types (e.g., CalendarTime | CalendarTimeRange): OPTION A: Create a sub-rule with alternation - @ = $(t:CalendarTime) -> $(t) | $(t:CalendarTimeRange) -> $(t) + = $(t:CalendarTime) -> t | $(t:CalendarTimeRange) -> t; OPTION B: Just use one of the types - @ = $(time:CalendarTime) + = $(time:CalendarTime); WRONG: $(time:CalendarTime | CalendarTimeRange) 5. Action rule names MUST match the exact action name (not capitalized) - CORRECT: @ = ... for action "scheduleEvent" - WRONG: @ = ... for action "scheduleEvent" + CORRECT: = ... ; for action "scheduleEvent" + WRONG: = ... ; for action "scheduleEvent" This enables easy targeting of specific actions when extending grammars incrementally. EFFICIENCY GUIDELINES: 1. Identify common patterns across actions and extract them as sub-rules - Example: If multiple actions use date expressions, create @ = ('on' | 'for') $(date:CalendarDate) + Example: If multiple actions use date expressions, create = ('on' | 'for') $(date:CalendarDate); 2. Create shared vocabulary rules for common phrases - Example: @ = 'can you'? | 'please'? | 'would you'? + Example: = 'can you'? | 'please'? | 'would you'?; 3. Reuse entity type rules across actions Example: If multiple actions need participant names, reference the same wildcard pattern @@ -95,13 +95,13 @@ EFFICIENCY GUIDELINES: 5. The Start rule should reference all top-level action rules GRAMMAR STRUCTURE: -1. Start with @ rule listing all actions by their exact action names - Example: @ = | | +1. Start with rule listing all actions by their exact action names + Example: = | | ; 2. Define action rules using EXACT action names as rule names (not capitalized) - Example: @ = ... for action "scheduleEvent" - Example: @ = ... for action "findEvents" + Example: = ... ; for action "scheduleEvent" + Example: = ... ; for action "findEvents" 3. Define shared sub-rules used by multiple actions (these can be capitalized) - Example: @ = ..., @ = ... + Example: = ... ;, = ... ; 4. Include common patterns (Cardinal, Ordinal, etc.) AVAILABLE ENTITY TYPES AND CONVERTERS: @@ -149,7 +149,7 @@ Your task: 5. Ensure all actions in the schema are covered 6. Keep shared sub-rules and don't duplicate patterns 7. Follow all AGR syntax rules (see above) -8. IMPORTANT: Use exact action names for action rules (e.g., @ = ..., not @ = ...) +8. IMPORTANT: Use exact action names for action rules (e.g., = ... ;, not = ... ;) This enables easy targeting of specific actions when extending grammars incrementally Response format: Return ONLY the complete improved .agr file content, starting with copyright header.`; diff --git a/ts/packages/agentSdkWrapper/test/calendar-extended.agr b/ts/packages/agentSdkWrapper/test/calendar-extended.agr index cdbf9aa15..f860fa6b9 100644 --- a/ts/packages/agentSdkWrapper/test/calendar-extended.agr +++ b/ts/packages/agentSdkWrapper/test/calendar-extended.agr @@ -2,40 +2,40 @@ // Calendar Management Action Grammar // Start rule - references all action rules by exact action names -@ = | | | | + = | | | | ; // Action rules (using exact action names) -@ = ('schedule' | 'set up' | 'book' | 'create' | 'add') ? ? ? -> { actionName: "scheduleEvent", parameters: { description, date, time, location, participant } } + = ('schedule' | 'set up' | 'book' | 'create' | 'add') ? ? ? -> { actionName: "scheduleEvent", parameters: { description, date, time, location, participant } }; -@ = ('find' | 'show me' | 'get' | 'search for' | 'look for' | 'pull up') ('events' | 'meetings' | 'appointments' | 'calendar entries')? ? ? ? -> { actionName: "findEvents", parameters: { description, date, participant } } + = ('find' | 'show me' | 'get' | 'search for' | 'look for' | 'pull up') ('events' | 'meetings' | 'appointments' | 'calendar entries')? ? ? ? -> { actionName: "findEvents", parameters: { description, date, participant } }; -@ = ('add' | 'invite' | 'include' | 'bring in') ('to' | 'in' | 'on') -> { actionName: "addParticipant", parameters: { description, participant } } + = ('add' | 'invite' | 'include' | 'bring in') ('to' | 'in' | 'on') -> { actionName: "addParticipant", parameters: { description, participant } }; -@ = ('show me' | 'find' | 'get' | 'what is' | 'what\'s' | 'tell me' | 'can you tell me') ('on my calendar'? 'today' | 'today\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')? | ('what I have' | 'what\'s scheduled') ('for'? 'today')) -> { actionName: "findTodaysEvents", parameters: {} } + = ('show me' | 'find' | 'get' | 'what is' | 'what\'s' | 'tell me' | 'can you tell me') ('on my calendar'? 'today' | 'today\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')? | ('what I have' | 'what\'s scheduled') ('for'? 'today')) -> { actionName: "findTodaysEvents", parameters: {} }; -@ = ('show me' | 'find' | 'get' | 'what is' | 'what\'s' | 'tell me') ('on my calendar'? ('this week' | 'for this week') | 'this week\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')?) -> { actionName: "findThisWeeksEvents", parameters: {} } + = ('show me' | 'find' | 'get' | 'what is' | 'what\'s' | 'tell me') ('on my calendar'? ('this week' | 'for this week') | 'this week\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')?) -> { actionName: "findThisWeeksEvents", parameters: {} }; // Shared sub-rules -@ = ('can you' | 'please' | 'would you' | 'could you')? + = ('can you' | 'please' | 'would you' | 'could you')?; -@ = ('a' | 'an' | 'my')? $(description:string) ('meeting' | 'event' | 'appointment')? + = ('a' | 'an' | 'my')? $(description:string) ('meeting' | 'event' | 'appointment')?; -@ = (('all' | 'any')? ('meetings' | 'events' | 'appointments' | 'calendar entries') ('with' | 'about' | 'for' | 'that have anything to do with')? $(description:string)) | ($(description:string) ('meeting' | 'event' | 'appointment')?) + = (('all' | 'any')? ('meetings' | 'events' | 'appointments' | 'calendar entries') ('with' | 'about' | 'for' | 'that have anything to do with')? $(description:string)) | ($(description:string) ('meeting' | 'event' | 'appointment')?); -@ = ('the' | 'my')? $(description:string) ('meeting' | 'event' | 'appointment')? + = ('the' | 'my')? $(description:string) ('meeting' | 'event' | 'appointment')?; -@ = ('on' | 'for') $(date:CalendarDate) + = ('on' | 'for') $(date:CalendarDate); -@ = ('at' | 'from') + = ('at' | 'from') ; -@ = $(time:CalendarTime) | $(time:CalendarTimeRange) + = $(time:CalendarTime) | $(time:CalendarTimeRange); -@ = ('in' | 'at' | 'location') ($(location:string) | 'TBD') + = ('in' | 'at' | 'location') ($(location:string) | 'TBD'); -@ = ('please'? ('invite' | 'include' | 'bring in') | 'with') + = ('please'? ('invite' | 'include' | 'bring in') | 'with') ; -@ = $(participant:string) ((',' | 'and') $(participant:string))* + = $(participant:string) ((',' | 'and') $(participant:string))*; -@ = ('with' | 'including') + = ('with' | 'including') ; -@ = $(participant:string) \ No newline at end of file + = $(participant:string); \ No newline at end of file diff --git a/ts/packages/agentSdkWrapper/test/calendar-new.agr b/ts/packages/agentSdkWrapper/test/calendar-new.agr index 47ad5115c..460ecfe47 100644 --- a/ts/packages/agentSdkWrapper/test/calendar-new.agr +++ b/ts/packages/agentSdkWrapper/test/calendar-new.agr @@ -2,40 +2,40 @@ // Calendar Management Action Grammar // Start rule - references all action rules by exact action names -@ = | | | | + = | | | | ; // Action rules (using exact action names) -@ = ('schedule' | 'set up' | 'book' | 'create') ? ? ? -> { actionName: "scheduleEvent", parameters: { description, date, time, location, participant } } + = ('schedule' | 'set up' | 'book' | 'create') ? ? ? -> { actionName: "scheduleEvent", parameters: { description, date, time, location, participant } }; -@ = ('find' | 'show me' | 'get' | 'search for') ('events' | 'meetings' | 'appointments')? ? ? ? -> { actionName: "findEvents", parameters: { description, date, participant } } + = ('find' | 'show me' | 'get' | 'search for') ('events' | 'meetings' | 'appointments')? ? ? ? -> { actionName: "findEvents", parameters: { description, date, participant } }; -@ = ('add' | 'invite' | 'include') ('to' | 'in') -> { actionName: "addParticipant", parameters: { description, participant } } + = ('add' | 'invite' | 'include') ('to' | 'in') -> { actionName: "addParticipant", parameters: { description, participant } }; -@ = ('show me' | 'find' | 'get' | 'what is' | 'what\'s') ('on my calendar'? 'today' | 'today\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')?) -> { actionName: "findTodaysEvents", parameters: {} } + = ('show me' | 'find' | 'get' | 'what is' | 'what\'s') ('on my calendar'? 'today' | 'today\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')?) -> { actionName: "findTodaysEvents", parameters: {} }; -@ = ('show me' | 'find' | 'get' | 'what is' | 'what\'s') ('on my calendar'? ('this week' | 'for this week') | 'this week\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')?) -> { actionName: "findThisWeeksEvents", parameters: {} } + = ('show me' | 'find' | 'get' | 'what is' | 'what\'s') ('on my calendar'? ('this week' | 'for this week') | 'this week\'s' ('events' | 'schedule' | 'calendar' | 'meetings' | 'appointments')?) -> { actionName: "findThisWeeksEvents", parameters: {} }; // Shared sub-rules -@ = ('can you' | 'please' | 'would you')? + = ('can you' | 'please' | 'would you')?; -@ = ('a' | 'an')? $(description:string) ('meeting' | 'event' | 'appointment')? + = ('a' | 'an')? $(description:string) ('meeting' | 'event' | 'appointment')?; -@ = (('all' | 'any')? ('meetings' | 'events' | 'appointments') ('with' | 'about' | 'for' | 'that have anything to do with')? $(description:string)) | ($(description:string) ('meeting' | 'event' | 'appointment')?) + = (('all' | 'any')? ('meetings' | 'events' | 'appointments') ('with' | 'about' | 'for' | 'that have anything to do with')? $(description:string)) | ($(description:string) ('meeting' | 'event' | 'appointment')?); -@ = ('the' | 'my')? $(description:string) ('meeting' | 'event' | 'appointment')? + = ('the' | 'my')? $(description:string) ('meeting' | 'event' | 'appointment')?; -@ = ('on' | 'for') $(date:CalendarDate) + = ('on' | 'for') $(date:CalendarDate); -@ = ('at' | 'from') + = ('at' | 'from') ; -@ = $(time:CalendarTime) | $(time:CalendarTimeRange) + = $(time:CalendarTime) | $(time:CalendarTimeRange); -@ = ('in' | 'at') $(location:string) + = ('in' | 'at') $(location:string); -@ = ('please'? ('invite' | 'include') | 'with') + = ('please'? ('invite' | 'include') | 'with') ; -@ = $(participant:string) ((',' | 'and') $(participant:string))* + = $(participant:string) ((',' | 'and') $(participant:string))*; -@ = ('with' | 'including') + = ('with' | 'including') ; -@ = $(participant:string) \ No newline at end of file + = $(participant:string); \ No newline at end of file diff --git a/ts/packages/agents/browser/src/agent/browserSchema.agr b/ts/packages/agents/browser/src/agent/browserSchema.agr index 593dc4cfd..dc8130d2d 100644 --- a/ts/packages/agents/browser/src/agent/browserSchema.agr +++ b/ts/packages/agents/browser/src/agent/browserSchema.agr @@ -4,7 +4,7 @@ // Browser Agent Grammar - Core Actions // Covers the most common browser operations -@ = + = | | | @@ -12,56 +12,56 @@ | | | - | + | ; // ===== Open Web Page ===== -@ = open $(site:wildcard) -> { actionName: "openWebPage", parameters: { site } } + = open $(site:wildcard) -> { actionName: "openWebPage", parameters: { site } } | go to $(site:wildcard) -> { actionName: "openWebPage", parameters: { site } } | navigate to $(site:wildcard) -> { actionName: "openWebPage", parameters: { site } } | browse to $(site:wildcard) -> { actionName: "openWebPage", parameters: { site } } - | visit $(site:wildcard) -> { actionName: "openWebPage", parameters: { site } } + | visit $(site:wildcard) -> { actionName: "openWebPage", parameters: { site } }; // ===== Close Page ===== -@ = close (the)? (web)? page -> { actionName: "closeWebPage", parameters: {} } + = close (the)? (web)? page -> { actionName: "closeWebPage", parameters: {} } | close (the)? tab -> { actionName: "closeWebPage", parameters: {} } | close all (web)? pages -> { actionName: "closeAllWebPages", parameters: {} } - | close all tabs -> { actionName: "closeAllWebPages", parameters: {} } + | close all tabs -> { actionName: "closeAllWebPages", parameters: {} }; // ===== Navigation ===== -@ = go back -> { actionName: "goBack", parameters: {} } + = go back -> { actionName: "goBack", parameters: {} } | back -> { actionName: "goBack", parameters: {} } | go forward -> { actionName: "goForward", parameters: {} } | forward -> { actionName: "goForward", parameters: {} } | reload (the)? page -> { actionName: "reloadPage", parameters: {} } - | refresh (the)? page -> { actionName: "reloadPage", parameters: {} } + | refresh (the)? page -> { actionName: "reloadPage", parameters: {} }; // ===== Scrolling ===== -@ = scroll down -> { actionName: "scrollDown", parameters: {} } + = scroll down -> { actionName: "scrollDown", parameters: {} } | scroll up -> { actionName: "scrollUp", parameters: {} } | page down -> { actionName: "scrollDown", parameters: {} } - | page up -> { actionName: "scrollUp", parameters: {} } + | page up -> { actionName: "scrollUp", parameters: {} }; // ===== Follow Link ===== -@ = follow (the)? link $(keywords:wildcard) -> { actionName: "followLinkByText", parameters: { keywords } } + = follow (the)? link $(keywords:wildcard) -> { actionName: "followLinkByText", parameters: { keywords } } | click (on)? (the)? link $(keywords:wildcard) -> { actionName: "followLinkByText", parameters: { keywords } } - | click (on)? $(keywords:wildcard) -> { actionName: "followLinkByText", parameters: { keywords } } + | click (on)? $(keywords:wildcard) -> { actionName: "followLinkByText", parameters: { keywords } }; // ===== Tab Control ===== -@ = switch to tab $(n:number) -> { actionName: "changeTabs", parameters: { tabNumber: n } } + = switch to tab $(n:number) -> { actionName: "changeTabs", parameters: { tabNumber: n } } | go to tab $(n:number) -> { actionName: "changeTabs", parameters: { tabNumber: n } } - | next tab -> { actionName: "changeTabs", parameters: { tabNumber: 0 } } + | next tab -> { actionName: "changeTabs", parameters: { tabNumber: 0 } }; // ===== Zoom ===== -@ = zoom in -> { actionName: "zoomIn", parameters: {} } + = zoom in -> { actionName: "zoomIn", parameters: {} } | zoom out -> { actionName: "zoomOut", parameters: {} } - | reset zoom -> { actionName: "zoomReset", parameters: {} } + | reset zoom -> { actionName: "zoomReset", parameters: {} }; // ===== Read Page ===== -@ = read (the)? page -> { actionName: "readPageContent", parameters: {} } + = read (the)? page -> { actionName: "readPageContent", parameters: {} } | read (the)? page (out loud)? -> { actionName: "readPageContent", parameters: {} } - | stop reading -> { actionName: "stopReadPageContent", parameters: {} } + | stop reading -> { actionName: "stopReadPageContent", parameters: {} }; // ===== Screenshot ===== -@ = take (a)? screenshot -> { actionName: "captureScreenshot", parameters: {} } + = take (a)? screenshot -> { actionName: "captureScreenshot", parameters: {} } | capture (the)? screen -> { actionName: "captureScreenshot", parameters: {} } - | screenshot -> { actionName: "captureScreenshot", parameters: {} } + | screenshot -> { actionName: "captureScreenshot", parameters: {} }; diff --git a/ts/packages/agents/calendar/src/calendarSchema.agr b/ts/packages/agents/calendar/src/calendarSchema.agr index 6e692ad9d..936970ef3 100644 --- a/ts/packages/agents/calendar/src/calendarSchema.agr +++ b/ts/packages/agents/calendar/src/calendarSchema.agr @@ -6,7 +6,7 @@ // Types: wildcard = 1+ words, word = exactly 1 word // scheduleEvent -@ = schedule a $(description:wildcard) for $(date:wildcard) at $(time:word) in $(location:wildcard) with $(participant:wildcard) -> { + = schedule a $(description:wildcard) for $(date:wildcard) at $(time:word) in $(location:wildcard) with $(participant:wildcard) -> { actionName: "scheduleEvent", parameters: { description, @@ -33,10 +33,10 @@ location, participant } -} +}; // findEvents -@ = find all events on $(date:wildcard) that include $(participant:wildcard) -> { + = find all events on $(date:wildcard) that include $(participant:wildcard) -> { actionName: "findEvents", parameters: { date, @@ -57,19 +57,19 @@ participant, description } -} +}; // addParticipant -@ = include $(participant:wildcard) in $(description:wildcard) -> { + = include $(participant:wildcard) in $(description:wildcard) -> { actionName: "addParticipant", parameters: { description, participant } -} +}; // findTodaysEvents -@ = what's on my calendar $(date:wildcard) -> { + = what's on my calendar $(date:wildcard) -> { actionName: "findTodaysEvents", parameters: { date @@ -83,17 +83,17 @@ } | (can you)? (tell me)? what (do)? I have scheduled for today -> { actionName: "findTodaysEvents" -} +}; // findThisWeeksEvents -@ = + = | | | - | + | ; -@ = what's happening this week -> { + = what's happening this week -> { actionName: "findThisWeeksEvents" } | show me all my events for this week starting $(startDay:word) -> { @@ -104,4 +104,4 @@ } | (can you)? find what I have scheduled this week -> { actionName: "findThisWeeksEvents" -} +}; diff --git a/ts/packages/agents/code/src/codeSchema.agr b/ts/packages/agents/code/src/codeSchema.agr index a2989c973..32aef644b 100644 --- a/ts/packages/agents/code/src/codeSchema.agr +++ b/ts/packages/agents/code/src/codeSchema.agr @@ -2,20 +2,20 @@ // Natural language interface for code editor actions // Start rule - all available actions -@ = | | | | + = | | | | ; // Main action rules -@ = ('change' | 'switch' | 'set') ('to' | 'the')? $(theme:string) ('color scheme' | 'theme') -> { actionName: "changeColorScheme", parameters: { theme: theme } } + = ('change' | 'switch' | 'set') ('to' | 'the')? $(theme:string) ('color scheme' | 'theme') -> { actionName: "changeColorScheme", parameters: { theme: theme } }; -@ = 'split' ('the'? 'editor')? $(direction:string) ('and'? ('open' | 'put' | 'place'))? $(fileName:string) ('in' | 'on' | 'to') 'the'? $(editorPosition:string) ('side' | 'panel' | 'half')? -> { actionName: "splitEditor", parameters: { direction: direction, editorPosition: editorPosition, fileName: fileName } } + = 'split' ('the'? 'editor')? $(direction:string) ('and'? ('open' | 'put' | 'place'))? $(fileName:string) ('in' | 'on' | 'to') 'the'? $(editorPosition:string) ('side' | 'panel' | 'half')? -> { actionName: "splitEditor", parameters: { direction: direction, editorPosition: editorPosition, fileName: fileName } }; -@ = ('change' | 'switch' | 'set' | 'go back') ('to' | 'the'? 'editor' 'to')? ('a'? | 'up')? $(columnCount:string) ('column' | 'pane') ('layout' | 'view' | 'mode')? -> { actionName: "changeEditorLayout", parameters: { columnCount: columnCount } } + = ('change' | 'switch' | 'set' | 'go back') ('to' | 'the'? 'editor' 'to')? ('a'? | 'up')? $(columnCount:string) ('column' | 'pane') ('layout' | 'view' | 'mode')? -> { actionName: "changeEditorLayout", parameters: { columnCount: columnCount } }; -@ = ('create' | 'make') ('a'? 'new')? $(language:string)? 'file' ('called' | 'named')? $(fileName:string) ('with' | 'and' 'add')? $(content:string)? -> { actionName: "newFile", parameters: { fileName: fileName, language: language, content: content } } + = ('create' | 'make') ('a'? 'new')? $(language:string)? 'file' ('called' | 'named')? $(fileName:string) ('with' | 'and' 'add')? $(content:string)? -> { actionName: "newFile", parameters: { fileName: fileName, language: language, content: content } }; -@ = ('launch' | 'open' | 'start') ('vs code' | 'vscode' | 'code') ('in' $(mode:string) 'mode')? ('at' | 'with' | 'for')? $(path:string)? -> { actionName: "launchVSCode", parameters: { path: path } } + = ('launch' | 'open' | 'start') ('vs code' | 'vscode' | 'code') ('in' $(mode:string) 'mode')? ('at' | 'with' | 'for')? $(path:string)? -> { actionName: "launchVSCode", parameters: { path: path } }; // Shared sub-rules -@ = ("can you" | "please" | "would you" | "i need" | "let's")? + = ("can you" | "please" | "would you" | "i need" | "let's")?; -@ = ('vertically' | 'vertical' | 'horizontally' | 'horizontal') \ No newline at end of file + = ('vertically' | 'vertical' | 'horizontally' | 'horizontal'); \ No newline at end of file diff --git a/ts/packages/agents/code/src/vscode/debugSchema.agr b/ts/packages/agents/code/src/vscode/debugSchema.agr index fc8bb841e..565f9cdb0 100644 --- a/ts/packages/agents/code/src/vscode/debugSchema.agr +++ b/ts/packages/agents/code/src/vscode/debugSchema.agr @@ -3,44 +3,44 @@ // Debug Schema Grammar - Comprehensive debugging interface -@ = | | | | | | | | + = | | | | | | | | ; // Action Rules -@ = ('show' | 'open' | 'display') ('debug' | 'debugging') ('panel' | 'window' | 'view') -> { actionName: "showDebugPanel", parameters: {} } + = ('show' | 'open' | 'display') ('debug' | 'debugging') ('panel' | 'window' | 'view') -> { actionName: "showDebugPanel", parameters: {} }; -@ = () ('with' | 'using') ('the'?) $(configurationName:string) ('configuration' | 'config' | 'setup') $(noDebug:) -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: noDebug } } + = () ('with' | 'using') ('the'?) $(configurationName:string) ('configuration' | 'config' | 'setup') $(noDebug:) -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: noDebug } } | () ('with' | 'using') ('the'?) $(configurationName:string) ('configuration' | 'config' | 'setup') -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: "false" } } | () $(configurationName:string) ('config' | 'configuration') $(noDebug:) -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: noDebug } } | () $(configurationName:string) ('config' | 'configuration') -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: "false" } } | ('debug' | 'launch') $(configurationName:string) $(noDebug:) -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: noDebug } } - | ('debug' | 'launch') $(configurationName:string) -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: "false" } } + | ('debug' | 'launch') $(configurationName:string) -> { actionName: "startDebugging", parameters: { configurationName: configurationName, noDebug: "false" } }; -@ = ('step' | 'continue' | 'next') $(stepType:string) -> { actionName: "step", parameters: { stepType: stepType } } - | ('step' | 'continue' | 'next') -> { actionName: "step", parameters: { stepType: "over" } } + = ('step' | 'continue' | 'next') $(stepType:string) -> { actionName: "step", parameters: { stepType: stepType } } + | ('step' | 'continue' | 'next') -> { actionName: "step", parameters: { stepType: "over" } }; -@ = ('stop' | 'end' | 'exit' | 'quit') ('debugging' | 'debug' | 'the debugger' | 'debugging session' | 'debug mode') -> { actionName: "stopDebugging", parameters: {} } + = ('stop' | 'end' | 'exit' | 'quit') ('debugging' | 'debug' | 'the debugger' | 'debugging session' | 'debug mode') -> { actionName: "stopDebugging", parameters: {} }; -@ = ('show' | 'display') ('hover' | 'hover info' | 'hover information') -> { actionName: "showHover", parameters: {} } + = ('show' | 'display') ('hover' | 'hover info' | 'hover information') -> { actionName: "showHover", parameters: {} }; -@ = ('toggle' | 'add or remove' | 'set') ('a'?) ('breakpoint') ('on' | 'at') ('line')? $(line:string) ('in' | 'of') $(fileName:string) ('in' | 'within') ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "toggleBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } + = ('toggle' | 'add or remove' | 'set') ('a'?) ('breakpoint') ('on' | 'at') ('line')? $(line:string) ('in' | 'of') $(fileName:string) ('in' | 'within') ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "toggleBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } | ('toggle' | 'add or remove' | 'set') ('a'?) ('breakpoint') ('line') $(line:string) ('file' | 'in') $(fileName:string) ('folder' | 'directory') $(folderName:string) -> { actionName: "toggleBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } - | ('toggle' | 'add or remove' | 'set') ('a'?) ('breakpoint') ('line') $(line:string) (',' | 'in') ('file')? $(fileName:string) (',' | 'in') $(folderName:string) ('folder')? -> { actionName: "toggleBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } + | ('toggle' | 'add or remove' | 'set') ('a'?) ('breakpoint') ('line') $(line:string) (',' | 'in') ('file')? $(fileName:string) (',' | 'in') $(folderName:string) ('folder')? -> { actionName: "toggleBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } }; -@ = ('set' | 'add' | 'place') ('a'?) ('breakpoint') ('on' | 'at') ('line')? $(line:string) ('in' | 'of') $(fileName:string) ('in' | 'within') ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "setBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } + = ('set' | 'add' | 'place') ('a'?) ('breakpoint') ('on' | 'at') ('line')? $(line:string) ('in' | 'of') $(fileName:string) ('in' | 'within') ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "setBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } | ('set' | 'add' | 'place') ('a'?) ('breakpoint') ('line') $(line:string) ('file' | 'in') $(fileName:string) ('folder' | 'directory') $(folderName:string) -> { actionName: "setBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } - | ('set' | 'add' | 'place') ('a'?) ('breakpoint') ('line') $(line:string) (',' | 'in') ('file')? $(fileName:string) (',' | 'in') $(folderName:string) ('folder')? -> { actionName: "setBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } + | ('set' | 'add' | 'place') ('a'?) ('breakpoint') ('line') $(line:string) (',' | 'in') ('file')? $(fileName:string) (',' | 'in') $(folderName:string) ('folder')? -> { actionName: "setBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } }; -@ = ('remove' | 'delete' | 'clear') ('the'?) ('breakpoint') ('on' | 'at') ('line')? $(line:string) ('in' | 'of') $(fileName:string) ('in' | 'within') ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "removeBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } + = ('remove' | 'delete' | 'clear') ('the'?) ('breakpoint') ('on' | 'at') ('line')? $(line:string) ('in' | 'of') $(fileName:string) ('in' | 'within') ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "removeBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } | ('remove' | 'delete' | 'clear') ('the'?) ('breakpoint') ('line') $(line:string) ('file' | 'in') $(fileName:string) ('folder' | 'directory') $(folderName:string) -> { actionName: "removeBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } - | ('remove' | 'delete' | 'clear') ('the'?) ('breakpoint') ('line') $(line:string) (',' | 'in') ('file')? $(fileName:string) (',' | 'in') $(folderName:string) ('folder')? -> { actionName: "removeBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } } + | ('remove' | 'delete' | 'clear') ('the'?) ('breakpoint') ('line') $(line:string) (',' | 'in') ('file')? $(fileName:string) (',' | 'in') $(folderName:string) ('folder')? -> { actionName: "removeBreakpoint", parameters: { line: line, fileName: fileName, folderName: folderName } }; -@ = ('remove' | 'delete' | 'clear') ('all') ('breakpoints' | 'the breakpoints') -> { actionName: "removeAllBreakpoints", parameters: {} } + = ('remove' | 'delete' | 'clear') ('all') ('breakpoints' | 'the breakpoints') -> { actionName: "removeAllBreakpoints", parameters: {} }; // Shared Sub-Rules -@ = ('can you' | 'please' | 'would you')? + = ('can you' | 'please' | 'would you')?; -@ = ('start' | 'begin' | 'launch' | 'run') ('debugging' | 'debug session' | 'the debugger') + = ('start' | 'begin' | 'launch' | 'run') ('debugging' | 'debug session' | 'the debugger'); -@ = ('without' ('actually')? 'debugging' | 'but' ('just')? 'run' ('it')? ('normally')? ('without breakpoints')? | 'just run' ('it')? ('normally')?) -> "true" \ No newline at end of file + = ('without' ('actually')? 'debugging' | 'but' ('just')? 'run' ('it')? ('normally')? ('without breakpoints')? | 'just run' ('it')? ('normally')?) -> "true"; \ No newline at end of file diff --git a/ts/packages/agents/code/src/vscode/displaySchema.agr b/ts/packages/agents/code/src/vscode/displaySchema.agr index 296b80259..21e19926b 100644 --- a/ts/packages/agents/code/src/vscode/displaySchema.agr +++ b/ts/packages/agents/code/src/vscode/displaySchema.agr @@ -4,71 +4,71 @@ // Display Schema Grammar - Comprehensive coverage of VS Code display actions // Start rule - all available actions -@ = | | | | | | | | | | | | | + = | | | | | | | | | | | | | ; // Shared sub-rules for common patterns -@ = ('can you' | 'could you' | 'please' | 'would you')? -@ = 'open' | 'show' | 'display' | 'bring up' -@ = 'close' | 'hide' | 'dismiss' -@ = 'in' | 'out' -@ = ('make it' | 'make this' | 'make the text' | 'make everything')? ('bigger' | 'smaller' | 'larger') -@ = ('I need to' | 'I want to' | 'I would like to')? -@ = ('panel' | 'view' | 'interface' | 'window')? -@ = ('to the side' | 'side by side' | 'in a new tab')? + = ('can you' | 'could you' | 'please' | 'would you')?; + = 'open' | 'show' | 'display' | 'bring up'; + = 'close' | 'hide' | 'dismiss'; + = 'in' | 'out'; + = ('make it' | 'make this' | 'make the text' | 'make everything')? ('bigger' | 'smaller' | 'larger'); + = ('I need to' | 'I want to' | 'I would like to')?; + = ('panel' | 'view' | 'interface' | 'window')?; + = ('to the side' | 'side by side' | 'in a new tab')?; // Zoom actions -@ = (('zoom' ) | ) -> { actionName: "zoomIn", parameters: {} } + = (('zoom' ) | ) -> { actionName: "zoomIn", parameters: {} } | 'see this closer' ('zoom in'?)? -> { actionName: "zoomIn", parameters: {} } - | ('so I can see better' | 'please')? -> { actionName: "zoomIn", parameters: {} } + | ('so I can see better' | 'please')? -> { actionName: "zoomIn", parameters: {} }; -@ = 'zoom out' ('a bit' | 'please' | 'so I can see more')? -> { actionName: "zoomOut", parameters: {} } + = 'zoom out' ('a bit' | 'please' | 'so I can see more')? -> { actionName: "zoomOut", parameters: {} } | ('so I can see more' | 'so I can get a better overview' | 'for a better view')? -> { actionName: "zoomOut", parameters: {} } - | ('see the bigger picture' | 'see more of the page') ('zoom out'?)? -> { actionName: "zoomOut", parameters: {} } + | ('see the bigger picture' | 'see more of the page') ('zoom out'?)? -> { actionName: "zoomOut", parameters: {} }; -@ = ('reset' | 'restore') ('font' | 'text')? ('zoom' | 'size') ('to default' | 'to normal')? -> { actionName: "fontZoomReset", parameters: {} } - | ('default' | 'normal' | 'original') ('font' | 'text') ('size' | 'zoom') -> { actionName: "fontZoomReset", parameters: {} } + = ('reset' | 'restore') ('font' | 'text')? ('zoom' | 'size') ('to default' | 'to normal')? -> { actionName: "fontZoomReset", parameters: {} } + | ('default' | 'normal' | 'original') ('font' | 'text') ('size' | 'zoom') -> { actionName: "fontZoomReset", parameters: {} }; // Panel and view actions -@ = ('the'? ('file' | 'project')? ('explorer' | 'tree' | 'browser') ?) -> { actionName: "showExplorer", parameters: {} } + = ('the'? ('file' | 'project')? ('explorer' | 'tree' | 'browser') ?) -> { actionName: "showExplorer", parameters: {} } | 'see the project files' ('show explorer'?)? -> { actionName: "showExplorer", parameters: {} } - | 'explorer' -> { actionName: "showExplorer", parameters: {} } + | 'explorer' -> { actionName: "showExplorer", parameters: {} }; -@ = ('the'? 'search' ('for me' | | 'interface')?) -> { actionName: "showSearch", parameters: {} } + = ('the'? 'search' ('for me' | | 'interface')?) -> { actionName: "showSearch", parameters: {} } | ('search for something' | 'find something') ('bring up the search interface'?)? -> { actionName: "showSearch", parameters: {} } - | 'search' -> { actionName: "showSearch", parameters: {} } + | 'search' -> { actionName: "showSearch", parameters: {} }; -@ = ('the'? 'source control' ?) -> { actionName: "showSourceControl", parameters: {} } + = ('the'? 'source control' ?) -> { actionName: "showSourceControl", parameters: {} } | ('see the git status' | 'check my changes' | 'see source control') ('show source control please'?)? -> { actionName: "showSourceControl", parameters: {} } - | ('git' | 'version control' | 'scm') ? -> { actionName: "showSourceControl", parameters: {} } + | ('git' | 'version control' | 'scm') ? -> { actionName: "showSourceControl", parameters: {} }; -@ = ('the'? 'output' ?) -> { actionName: "showOutputPanel", parameters: {} } + = ('the'? 'output' ?) -> { actionName: "showOutputPanel", parameters: {} } | 'see the output' ('show output panel'?)? -> { actionName: "showOutputPanel", parameters: {} } - | 'output' -> { actionName: "showOutputPanel", parameters: {} } + | 'output' -> { actionName: "showOutputPanel", parameters: {} }; // Search and replace actions -@ = ('toggle' | 'show' | 'hide') 'search details' -> { actionName: "toggleSearchDetails", parameters: {} } + = ('toggle' | 'show' | 'hide') 'search details' -> { actionName: "toggleSearchDetails", parameters: {} } | ('expand' | 'collapse') 'search' ('options' | 'details')? -> { actionName: "toggleSearchDetails", parameters: {} } - | 'search details' -> { actionName: "toggleSearchDetails", parameters: {} } + | 'search details' -> { actionName: "toggleSearchDetails", parameters: {} }; -@ = ('replace in files' | 'find and replace' | 'global replace') -> { actionName: "replaceInFiles", parameters: {} } - | ('replace text across files' | 'do a global find and replace') -> { actionName: "replaceInFiles", parameters: {} } + = ('replace in files' | 'find and replace' | 'global replace') -> { actionName: "replaceInFiles", parameters: {} } + | ('replace text across files' | 'do a global find and replace') -> { actionName: "replaceInFiles", parameters: {} }; // Markdown preview actions -@ = ('the'? 'markdown preview' | 'preview' ('of this markdown' | 'for this file')?) -> { actionName: "openMarkdownPreview", parameters: {} } - | 'preview this markdown' ('file' | 'document')? -> { actionName: "openMarkdownPreview", parameters: {} } + = ('the'? 'markdown preview' | 'preview' ('of this markdown' | 'for this file')?) -> { actionName: "openMarkdownPreview", parameters: {} } + | 'preview this markdown' ('file' | 'document')? -> { actionName: "openMarkdownPreview", parameters: {} }; -@ = ('markdown preview' | 'preview') -> { actionName: "openMarkdownPreviewToSide", parameters: {} } + = ('markdown preview' | 'preview') -> { actionName: "openMarkdownPreviewToSide", parameters: {} } | 'preview this markdown' -> { actionName: "openMarkdownPreviewToSide", parameters: {} } - | 'side by side preview' ('of this markdown')? -> { actionName: "openMarkdownPreviewToSide", parameters: {} } + | 'side by side preview' ('of this markdown')? -> { actionName: "openMarkdownPreviewToSide", parameters: {} }; // Mode and editor actions -@ = ('enter' | 'enable' | 'turn on')? 'zen mode' -> { actionName: "zenMode", parameters: {} } + = ('enter' | 'enable' | 'turn on')? 'zen mode' -> { actionName: "zenMode", parameters: {} } | ('focus' | 'concentrate') ('enter zen mode'?)? -> { actionName: "zenMode", parameters: {} } - | 'zen mode' -> { actionName: "zenMode", parameters: {} } + | 'zen mode' -> { actionName: "zenMode", parameters: {} }; -@ = ('the'? ('current'? ('editor' | 'tab' | 'file') | 'this' ('file' | 'tab'))) -> { actionName: "closeEditor", parameters: {} } - | 'close this' ('file' | 'tab' | 'editor')? -> { actionName: "closeEditor", parameters: {} } + = ('the'? ('current'? ('editor' | 'tab' | 'file') | 'this' ('file' | 'tab'))) -> { actionName: "closeEditor", parameters: {} } + | 'close this' ('file' | 'tab' | 'editor')? -> { actionName: "closeEditor", parameters: {} }; -@ = ('the'? ('settings' | 'preferences' | 'configuration' | 'options')) -> { actionName: "openSettings", parameters: {} } + = ('the'? ('settings' | 'preferences' | 'configuration' | 'options')) -> { actionName: "openSettings", parameters: {} } | ('change settings' | 'configure something') ('open settings'?)? -> { actionName: "openSettings", parameters: {} } - | ('settings' | 'preferences') -> { actionName: "openSettings", parameters: {} } \ No newline at end of file + | ('settings' | 'preferences') -> { actionName: "openSettings", parameters: {} }; \ No newline at end of file diff --git a/ts/packages/agents/code/src/vscode/editorSchema.agr b/ts/packages/agents/code/src/vscode/editorSchema.agr index d381e702d..a0abf2a08 100644 --- a/ts/packages/agents/code/src/vscode/editorSchema.agr +++ b/ts/packages/agents/code/src/vscode/editorSchema.agr @@ -5,43 +5,43 @@ // Editor Schema Grammar - Natural language interface for code editing actions -@ = | | | | | | | | | + = | | | | | | | | | ; // Common patterns and sub-rules -@ = ('can you'? | 'please'? | 'could you'?) -@ = ('quick' | 'quickly' | 'fast')? -@ = ('in' | 'using' | 'as') $(language:string) -> language -@ = ('in' | 'to' | 'at') $(file:string) ('file' | 'document')? -> file -@ = ('at' | 'after' | 'before' | 'above' | 'below' | 'on' | 'near') $(position:string) -> position -@ = ('called' | 'named') $(name:string) -> name -@ = ('in' | 'inside') ('the')? $(folderName:string) ('folder' | 'directory') -> folderName + = ('can you'? | 'please'? | 'could you'?); + = ('quick' | 'quickly' | 'fast')?; + = ('in' | 'using' | 'as') $(language:string) -> language; + = ('in' | 'to' | 'at') $(file:string) ('file' | 'document')? -> file; + = ('at' | 'after' | 'before' | 'above' | 'below' | 'on' | 'near') $(position:string) -> position; + = ('called' | 'named') $(name:string) -> name; + = ('in' | 'inside') ('the')? $(folderName:string) ('folder' | 'directory') -> folderName; // Function creation -@ = ('create' | 'make' | 'add' | 'write') ('a' | 'new')? ('function' | 'method') $(name:)? $(language:)? ('that' | 'to' | 'which')? $(functionDeclaration:string)? ('with' ('body' | 'implementation'))? $(body:string)? ('with' ('documentation' | 'docstring' | 'comments'))? $(docstring:string)? ('taking' | 'with' | 'accepts')? ('parameters' | 'params' | 'arguments' | 'args')? $(args:string)? ('returning' | 'returns')? $(returnType:string)? ('make it' | 'as')? $(isAsync:string)? $(file:)? $(position:)? -> { actionName: "createFunction", parameters: { language: language, functionDeclaration: functionDeclaration, body: body, docstring: docstring, name: name, args: args, returnType: returnType, isAsync: isAsync, file: file, position: position } } + = ('create' | 'make' | 'add' | 'write') ('a' | 'new')? ('function' | 'method') $(name:)? $(language:)? ('that' | 'to' | 'which')? $(functionDeclaration:string)? ('with' ('body' | 'implementation'))? $(body:string)? ('with' ('documentation' | 'docstring' | 'comments'))? $(docstring:string)? ('taking' | 'with' | 'accepts')? ('parameters' | 'params' | 'arguments' | 'args')? $(args:string)? ('returning' | 'returns')? $(returnType:string)? ('make it' | 'as')? $(isAsync:string)? $(file:)? $(position:)? -> { actionName: "createFunction", parameters: { language: language, functionDeclaration: functionDeclaration, body: body, docstring: docstring, name: name, args: args, returnType: returnType, isAsync: isAsync, file: file, position: position } }; // Code block creation -@ = ('create' | 'make' | 'add' | 'write' | 'insert') ('a' | 'new')? ('code' ('block' | 'snippet') | 'snippet') $(language:)? ('with' ('documentation' | 'docstring' | 'comments'))? $(docstring:string)? ('with' ('declaration' | 'signature'))? $(declaration:string)? ('with' ('body' | 'implementation' | 'content'))? $(body:string)? $(codeSnippet:string)? ('as' ('partial' | 'incomplete'))? $(isPartial:string)? $(file:)? $(position:)? -> { actionName: "createCodeBlock", parameters: { language: language, docstring: docstring, declaration: declaration, body: body, codeSnippet: codeSnippet, isPartial: isPartial, file: file, position: position } } + = ('create' | 'make' | 'add' | 'write' | 'insert') ('a' | 'new')? ('code' ('block' | 'snippet') | 'snippet') $(language:)? ('with' ('documentation' | 'docstring' | 'comments'))? $(docstring:string)? ('with' ('declaration' | 'signature'))? $(declaration:string)? ('with' ('body' | 'implementation' | 'content'))? $(body:string)? $(codeSnippet:string)? ('as' ('partial' | 'incomplete'))? $(isPartial:string)? $(file:)? $(position:)? -> { actionName: "createCodeBlock", parameters: { language: language, docstring: docstring, declaration: declaration, body: body, codeSnippet: codeSnippet, isPartial: isPartial, file: file, position: position } }; // Fix code problems -@ = ('fix' | 'solve' | 'resolve' | 'debug' | 'repair') ('the')? $(target:string) ('problem' | 'issue' | 'bug' | 'error' | 'crash')? $(file:)? ('hint' | 'suggestion' | 'related to' | 'caused by')? $(hint:string)? -> { actionName: "fixCodeProblem", parameters: { target: target, hint: hint, file: file } } + = ('fix' | 'solve' | 'resolve' | 'debug' | 'repair') ('the')? $(target:string) ('problem' | 'issue' | 'bug' | 'error' | 'crash')? $(file:)? ('hint' | 'suggestion' | 'related to' | 'caused by')? $(hint:string)? -> { actionName: "fixCodeProblem", parameters: { target: target, hint: hint, file: file } }; // Move cursor -@ = ('move' | 'go' | 'jump' | 'navigate') ('cursor' | 'to' | 'position')? $(target:string) $(file:)? ('hint' | 'near' | 'around')? $(hint:string)? -> { actionName: "moveCursorInFile", parameters: { target: target, file: file, hint: hint } } + = ('move' | 'go' | 'jump' | 'navigate') ('cursor' | 'to' | 'position')? $(target:string) $(file:)? ('hint' | 'near' | 'around')? $(hint:string)? -> { actionName: "moveCursorInFile", parameters: { target: target, file: file, hint: hint } }; // Insert or delete lines -@ = $(operation:string) $(count:string)? ('lines' | 'line')? $(position:)? $(file:)? ('force' | 'forcibly')? $(force:string)? -> { actionName: "insertOrDeleteLines", parameters: { operation: operation, count: count, position: position, file: file, force: force } } + = $(operation:string) $(count:string)? ('lines' | 'line')? $(position:)? $(file:)? ('force' | 'forcibly')? $(force:string)? -> { actionName: "insertOrDeleteLines", parameters: { operation: operation, count: count, position: position, file: file, force: force } }; // Insert comments -@ = ('add' | 'insert' | 'put') ('a' | 'new')? ('comment' | 'note') $(text:string) $(language:)? ('style' | 'format')? $(commentStyle:string)? $(position:)? ('with' ('newline' | 'blank line') 'before')? $(newlineBefore:string)? ('with' ('newline' | 'blank line') 'after')? $(newlineAfter:string)? -> { actionName: "insertComment", parameters: { text: text, language: language, commentStyle: commentStyle, position: position, newlineBefore: newlineBefore, newlineAfter: newlineAfter } } + = ('add' | 'insert' | 'put') ('a' | 'new')? ('comment' | 'note') $(text:string) $(language:)? ('style' | 'format')? $(commentStyle:string)? $(position:)? ('with' ('newline' | 'blank line') 'before')? $(newlineBefore:string)? ('with' ('newline' | 'blank line') 'after')? $(newlineAfter:string)? -> { actionName: "insertComment", parameters: { text: text, language: language, commentStyle: commentStyle, position: position, newlineBefore: newlineBefore, newlineAfter: newlineAfter } }; // Generate with Copilot -@ = ('generate' | 'create' | 'suggest' | 'auto' 'generate') ('with' | 'using')? ('copilot' | 'ai' | 'assistant')? ('using' ('strategy' | 'approach'))? $(strategy:string)? $(position:)? $(language:)? ('with' ('prompt' | 'instruction'))? $(prompt:string)? ('with' ('context' | 'background'))? $(context:string)? ('attempt' ('limit' | 'max'))? $(attemptLimit:string)? ('auto' ('accept' | 'apply'))? $(autoAccept:string)? ('explanation' ('mode' | 'level'))? $(explanationMode:string)? -> { actionName: "generateWithCopilot", parameters: { strategy: strategy, position: position, language: language, prompt: prompt, context: context, attemptLimit: attemptLimit, autoAccept: autoAccept, explanationMode: explanationMode } } + = ('generate' | 'create' | 'suggest' | 'auto' 'generate') ('with' | 'using')? ('copilot' | 'ai' | 'assistant')? ('using' ('strategy' | 'approach'))? $(strategy:string)? $(position:)? $(language:)? ('with' ('prompt' | 'instruction'))? $(prompt:string)? ('with' ('context' | 'background'))? $(context:string)? ('attempt' ('limit' | 'max'))? $(attemptLimit:string)? ('auto' ('accept' | 'apply'))? $(autoAccept:string)? ('explanation' ('mode' | 'level'))? $(explanationMode:string)? -> { actionName: "generateWithCopilot", parameters: { strategy: strategy, position: position, language: language, prompt: prompt, context: context, attemptLimit: attemptLimit, autoAccept: autoAccept, explanationMode: explanationMode } }; // Create file -@ = ('create' | 'make' | 'add') ('a' | 'new')? $(fileName:string) ('file' | 'document')? $(folderName:)? ('relative to' | 'from')? $(folderRelativeTo:string)? $(language:)? ('as' ('untitled' | 'temporary'))? $(untitled:string)? ('open' 'in' ('editor' | 'tab'))? $(openInEditor:string)? ('with' ('content' | 'text'))? $(content:string)? ('overwrite' ('if' 'exists' | 'existing'))? $(overwriteIfExists:string)? ('focus' 'existing' 'if' 'open')? $(focusExistingIfOpen:string)? -> { actionName: "createFile", parameters: { fileName: fileName, folderName: folderName, folderRelativeTo: folderRelativeTo, language: language, untitled: untitled, openInEditor: openInEditor, content: content, overwriteIfExists: overwriteIfExists, focusExistingIfOpen: focusExistingIfOpen } } + = ('create' | 'make' | 'add') ('a' | 'new')? $(fileName:string) ('file' | 'document')? $(folderName:)? ('relative to' | 'from')? $(folderRelativeTo:string)? $(language:)? ('as' ('untitled' | 'temporary'))? $(untitled:string)? ('open' 'in' ('editor' | 'tab'))? $(openInEditor:string)? ('with' ('content' | 'text'))? $(content:string)? ('overwrite' ('if' 'exists' | 'existing'))? $(overwriteIfExists:string)? ('focus' 'existing' 'if' 'open')? $(focusExistingIfOpen:string)? -> { actionName: "createFile", parameters: { fileName: fileName, folderName: folderName, folderRelativeTo: folderRelativeTo, language: language, untitled: untitled, openInEditor: openInEditor, content: content, overwriteIfExists: overwriteIfExists, focusExistingIfOpen: focusExistingIfOpen } }; // Save current file -@ = ('save' ('current' | 'active' | 'this')? ('file' | 'document') | 'save') ('show error' 'if' 'no' 'active' 'editor')? $(showErrorIfNoActiveEditor:string)? ('only' ('dirty' | 'unsaved' | 'changed'))? $(onlyDirty:string)? ('exclude' ('untitled' | 'temporary'))? $(excludeUntitled:string)? -> { actionName: "saveCurrentFile", parameters: { showErrorIfNoActiveEditor: showErrorIfNoActiveEditor, onlyDirty: onlyDirty, excludeUntitled: excludeUntitled } } + = ('save' ('current' | 'active' | 'this')? ('file' | 'document') | 'save') ('show error' 'if' 'no' 'active' 'editor')? $(showErrorIfNoActiveEditor:string)? ('only' ('dirty' | 'unsaved' | 'changed'))? $(onlyDirty:string)? ('exclude' ('untitled' | 'temporary'))? $(excludeUntitled:string)? -> { actionName: "saveCurrentFile", parameters: { showErrorIfNoActiveEditor: showErrorIfNoActiveEditor, onlyDirty: onlyDirty, excludeUntitled: excludeUntitled } }; // Save all files -@ = ('save' ('all' | 'everything') ('files' | 'documents')? | 'save all') ('only' ('dirty' | 'unsaved' | 'changed'))? $(onlyDirty:string)? ('exclude' ('untitled' | 'temporary'))? $(excludeUntitled:string)? ('log' ('result' | 'outcome'))? $(logResult:string)? -> { actionName: "saveAllFiles", parameters: { onlyDirty: onlyDirty, excludeUntitled: excludeUntitled, logResult: logResult } } \ No newline at end of file + = ('save' ('all' | 'everything') ('files' | 'documents')? | 'save all') ('only' ('dirty' | 'unsaved' | 'changed'))? $(onlyDirty:string)? ('exclude' ('untitled' | 'temporary'))? $(excludeUntitled:string)? ('log' ('result' | 'outcome'))? $(logResult:string)? -> { actionName: "saveAllFiles", parameters: { onlyDirty: onlyDirty, excludeUntitled: excludeUntitled, logResult: logResult } }; \ No newline at end of file diff --git a/ts/packages/agents/code/src/vscode/extensionSchema.agr b/ts/packages/agents/code/src/vscode/extensionSchema.agr index e970acbca..53eb6c27c 100644 --- a/ts/packages/agents/code/src/vscode/extensionSchema.agr +++ b/ts/packages/agents/code/src/vscode/extensionSchema.agr @@ -4,41 +4,41 @@ // Extension Management Grammar // Handles VS Code extension operations including installation, enabling/disabling, and querying -@ = | | | | | + = | | | | | ; // Shared sub-rules for common patterns -@ = ("can you" | "could you" | "please" | "would you")? + = ("can you" | "could you" | "please" | "would you")?; -@ = $(query:string) + = $(query:string); -@ = ( + = ( ('ask me' | 'confirm' | 'prompt me' | "I'd like to confirm" | 'check with me') -> "true" | ("don't ask" | "don't prompt" | 'without asking' | 'no prompts' | 'skip confirmation') -> "false" | ('prompt me' | 'ask first') -> "true" -) +); -@ = ( + = ( ('auto reload' | 'reload automatically' | 'restart' | 'auto restart' | 'reload editor' | 'reload when done') -> "true" | ('skip reload' | "don't reload" | 'no reload' | 'without reload') -> "false" | ('reload' | 'restart everything') -> "true" -) +); -@ = ( + = ( 'by user query' $(userQuery:string) -> userQuery | 'by known query' $(knownQuery:string) -> knownQuery | 'by category' $(category:string) -> category | 'for' $(general:string) -> general -) +); // Action rules -@ = ('check' | 'find' | 'search for' | 'look for') ('extensions' | 'extension') $(filter:)? -> { actionName: "checkExtensionAvailable", parameters: { filter: filter } } + = ('check' | 'find' | 'search for' | 'look for') ('extensions' | 'extension') $(filter:)? -> { actionName: "checkExtensionAvailable", parameters: { filter: filter } }; -@ = ('install' | 'add' | 'get') ('the')? $(extensionQuery:) ('extension')? $(prompt:)? $(autoReload:)? -> { actionName: "installExtension", parameters: { extensionQuery: extensionQuery, promptUser: prompt, autoReload: autoReload } } + = ('install' | 'add' | 'get') ('the')? $(extensionQuery:) ('extension')? $(prompt:)? $(autoReload:)? -> { actionName: "installExtension", parameters: { extensionQuery: extensionQuery, promptUser: prompt, autoReload: autoReload } }; -@ = ('reload' | 'restart') ('window' | 'editor' | 'vs code' | 'vscode') -> { actionName: "reloadWindow", parameters: {} } + = ('reload' | 'restart') ('window' | 'editor' | 'vs code' | 'vscode') -> { actionName: "reloadWindow", parameters: {} }; -@ = ('show' | 'list' | 'display') ('all')? 'extensions' -> { actionName: "showExtensions", parameters: {} } + = ('show' | 'list' | 'display') ('all')? 'extensions' -> { actionName: "showExtensions", parameters: {} }; -@ = ('enable' | 'turn on' | 'activate') ('the')? $(extensionQuery:) ('extension')? $(prompt:)? $(autoReload:)? -> { actionName: "enableExtension", parameters: { extensionQuery: extensionQuery, promptUser: prompt, autoReload: autoReload } } + = ('enable' | 'turn on' | 'activate') ('the')? $(extensionQuery:) ('extension')? $(prompt:)? $(autoReload:)? -> { actionName: "enableExtension", parameters: { extensionQuery: extensionQuery, promptUser: prompt, autoReload: autoReload } }; -@ = ('disable' | 'turn off' | 'deactivate') ('the')? $(extensionQuery:) ('extension')? $(prompt:)? $(autoReload:)? -> { actionName: "disableExtension", parameters: { extensionQuery: extensionQuery, promptUser: prompt, autoReload: autoReload } } \ No newline at end of file + = ('disable' | 'turn off' | 'deactivate') ('the')? $(extensionQuery:) ('extension')? $(prompt:)? $(autoReload:)? -> { actionName: "disableExtension", parameters: { extensionQuery: extensionQuery, promptUser: prompt, autoReload: autoReload } }; \ No newline at end of file diff --git a/ts/packages/agents/code/src/vscode/generalSchema.agr b/ts/packages/agents/code/src/vscode/generalSchema.agr index 69b171332..61c6edb06 100644 --- a/ts/packages/agents/code/src/vscode/generalSchema.agr +++ b/ts/packages/agents/code/src/vscode/generalSchema.agr @@ -5,22 +5,22 @@ // General schema grammar for IDE commands and navigation -@ = | | | + = | | | ; // Action rules -@ = ('open' | 'show' | 'bring up' | 'display') 'the'? 'command palette' -> { actionName: "showCommandPalette", parameters: {} } + = ('open' | 'show' | 'bring up' | 'display') 'the'? 'command palette' -> { actionName: "showCommandPalette", parameters: {} }; -@ = $(goto:string) ('in' | 'from') $(ref:string) -> { actionName: "gotoFileOrLineOrSymbol", parameters: { goto: goto, ref: ref } } + = $(goto:string) ('in' | 'from') $(ref:string) -> { actionName: "gotoFileOrLineOrSymbol", parameters: { goto: goto, ref: ref } } | $(goto:string) -> { actionName: "gotoFileOrLineOrSymbol", parameters: { goto: goto, ref: goto } } - | 'to' 'the'? $(goto:string) ('function' | 'method' | 'component' | 'class')? -> { actionName: "gotoFileOrLineOrSymbol", parameters: { goto: goto, ref: goto } } + | 'to' 'the'? $(goto:string) ('function' | 'method' | 'component' | 'class')? -> { actionName: "gotoFileOrLineOrSymbol", parameters: { goto: goto, ref: goto } }; -@ = ('open' | 'show' | 'display') ('user'? 'settings' | 'preferences' | 'configuration') -> { actionName: "showUserSettings", parameters: {} } + = ('open' | 'show' | 'display') ('user'? 'settings' | 'preferences' | 'configuration') -> { actionName: "showUserSettings", parameters: {} }; -@ = ('show' | 'display' | 'open') ('keyboard'? 'shortcuts' | 'keybindings' | 'hotkeys') -> { actionName: "showKeyboardShortcuts", parameters: {} } + = ('show' | 'display' | 'open') ('keyboard'? 'shortcuts' | 'keybindings' | 'hotkeys') -> { actionName: "showKeyboardShortcuts", parameters: {} }; // Shared sub-rules -@ = ('can you' | 'please' | 'would you')? + = ('can you' | 'please' | 'would you')?; -@ = ('go to' | 'jump to' | 'navigate to') ('line' | 'file')? + = ('go to' | 'jump to' | 'navigate to') ('line' | 'file')?; -@ = ('take me' | 'navigate' | 'jump' | 'go') \ No newline at end of file + = ('take me' | 'navigate' | 'jump' | 'go'); \ No newline at end of file diff --git a/ts/packages/agents/code/src/vscode/workbenchSchema.agr b/ts/packages/agents/code/src/vscode/workbenchSchema.agr index 00262ca1f..346fed8c1 100644 --- a/ts/packages/agents/code/src/vscode/workbenchSchema.agr +++ b/ts/packages/agents/code/src/vscode/workbenchSchema.agr @@ -3,23 +3,23 @@ // This Action Grammar file defines natural language patterns for workbench operations. // Main entry point - references all action rules by their exact action names -@ = | | | | + = | | | | ; // Shared sub-rules for common patterns -@ = ('can you' | 'please' | 'would you' | 'could you')? -@ = ('open' | 'show' | 'display' | 'view' | 'load') -@ = ('open' | 'show' | 'browse' | 'explore' | 'navigate to') -@ = ('create' | 'make' | 'add' | 'new') -@ = ('open' | 'launch' | 'start') ('terminal' | 'command line' | 'shell') -@ = ('build' | 'run' | 'execute') ('task' | 'build task' | 'related task') + = ('can you' | 'please' | 'would you' | 'could you')?; + = ('open' | 'show' | 'display' | 'view' | 'load'); + = ('open' | 'show' | 'browse' | 'explore' | 'navigate to'); + = ('create' | 'make' | 'add' | 'new'); + = ('open' | 'launch' | 'start') ('terminal' | 'command line' | 'shell'); + = ('build' | 'run' | 'execute') ('task' | 'build task' | 'related task'); // Action rules using exact action names - with inline variable captures -@ = ('the')? $(fileName:string) ('file')? -> { actionName: "workbenchOpenFile", parameters: { fileName: fileName } } + = ('the')? $(fileName:string) ('file')? -> { actionName: "workbenchOpenFile", parameters: { fileName: fileName } }; -@ = ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "workbenchOpenFolder", parameters: { folderName: folderName } } + = ('the')? $(folderName:string) ('folder' | 'directory')? -> { actionName: "workbenchOpenFolder", parameters: { folderName: folderName } }; -@ = ('folder' | 'directory') $(folderName:string) -> { actionName: "workbenchCreateFolderFromExplorer", parameters: { folderName: folderName } } + = ('folder' | 'directory') $(folderName:string) -> { actionName: "workbenchCreateFolderFromExplorer", parameters: { folderName: folderName } }; -@ = ('in' | 'for') $(folderName:string) ('folder' | 'directory')? -> { actionName: "workbenchBuildRelatedTask", parameters: { folderName: folderName } } + = ('in' | 'for') $(folderName:string) ('folder' | 'directory')? -> { actionName: "workbenchBuildRelatedTask", parameters: { folderName: folderName } }; -@ = ('in' | 'at') ('the')? $(folderName:string) ('folder' | 'directory')? ('and' | 'to')? ('run' | 'execute')? $(commandToExecute:string)? -> { actionName: "openInIntegratedTerminal", parameters: { folderName: folderName, commandToExecute: commandToExecute } } \ No newline at end of file + = ('in' | 'at') ('the')? $(folderName:string) ('folder' | 'directory')? ('and' | 'to')? ('run' | 'execute')? $(commandToExecute:string)? -> { actionName: "openInIntegratedTerminal", parameters: { folderName: folderName, commandToExecute: commandToExecute } }; \ No newline at end of file diff --git a/ts/packages/agents/desktop/src/desktopSchema.agr b/ts/packages/agents/desktop/src/desktopSchema.agr index 3554df1a3..49b24cf33 100644 --- a/ts/packages/agents/desktop/src/desktopSchema.agr +++ b/ts/packages/agents/desktop/src/desktopSchema.agr @@ -4,7 +4,7 @@ // Desktop Agent Grammar - Core Actions // Window management, volume, theme, network, and basic display settings -@ = + = | | | @@ -12,11 +12,11 @@ | | | - | + | ; // ===== Known Programs (for completions and priority matching) ===== // These are matched with higher priority than wildcards -@ = chrome + = chrome | word | excel | powerpoint @@ -36,69 +36,69 @@ | snipping tool | magnifier | spotify - | m365 copilot + | m365 copilot; // Program is either a known program or any wildcard text -@ = - | $(name:wildcard) -> name + = + | $(name:wildcard) -> name; // ===== Program Launch/Close ===== -@ = launch $(program:) -> { actionName: "launchProgram", parameters: { name: program } } + = launch $(program:) -> { actionName: "launchProgram", parameters: { name: program } } | open $(program:) -> { actionName: "launchProgram", parameters: { name: program } } | start $(program:) -> { actionName: "launchProgram", parameters: { name: program } } - | run $(program:) -> { actionName: "launchProgram", parameters: { name: program } } + | run $(program:) -> { actionName: "launchProgram", parameters: { name: program } }; -@ = close $(program:) -> { actionName: "closeProgram", parameters: { name: program } } + = close $(program:) -> { actionName: "closeProgram", parameters: { name: program } } | quit $(program:) -> { actionName: "closeProgram", parameters: { name: program } } - | exit $(program:) -> { actionName: "closeProgram", parameters: { name: program } } + | exit $(program:) -> { actionName: "closeProgram", parameters: { name: program } }; // ===== Window Management ===== -@ = + = | | - | + | ; -@ = maximize $(program:) -> { actionName: "maximize", parameters: { name: program } } - | make $(program:) full screen -> { actionName: "maximize", parameters: { name: program } } + = maximize $(program:) -> { actionName: "maximize", parameters: { name: program } } + | make $(program:) full screen -> { actionName: "maximize", parameters: { name: program } }; -@ = minimize $(program:) -> { actionName: "minimize", parameters: { name: program } } - | hide $(program:) -> { actionName: "minimize", parameters: { name: program } } + = minimize $(program:) -> { actionName: "minimize", parameters: { name: program } } + | hide $(program:) -> { actionName: "minimize", parameters: { name: program } }; -@ = switch to $(program:) -> { actionName: "switchTo", parameters: { name: program } } + = switch to $(program:) -> { actionName: "switchTo", parameters: { name: program } } | focus (on)? $(program:) -> { actionName: "switchTo", parameters: { name: program } } - | go to $(program:) -> { actionName: "switchTo", parameters: { name: program } } + | go to $(program:) -> { actionName: "switchTo", parameters: { name: program } }; -@ = tile $(left:) on (the)? left and $(right:) on (the)? right -> { actionName: "tile", parameters: { leftWindow: left, rightWindow: right } } + = tile $(left:) on (the)? left and $(right:) on (the)? right -> { actionName: "tile", parameters: { leftWindow: left, rightWindow: right } } | put $(left:) on (the)? left and $(right:) on (the)? right -> { actionName: "tile", parameters: { leftWindow: left, rightWindow: right } } - | tile $(left:) and $(right:) -> { actionName: "tile", parameters: { leftWindow: left, rightWindow: right } } + | tile $(left:) and $(right:) -> { actionName: "tile", parameters: { leftWindow: left, rightWindow: right } }; // ===== Volume Control ===== -@ = set volume to $(level:number) (percent)? -> { actionName: "volume", parameters: { targetVolume: level } } + = set volume to $(level:number) (percent)? -> { actionName: "volume", parameters: { targetVolume: level } } | volume $(level:number) (percent)? -> { actionName: "volume", parameters: { targetVolume: level } } | mute -> { actionName: "mute", parameters: { on: true } } | unmute -> { actionName: "mute", parameters: { on: false } } - | restore volume -> { actionName: "restoreVolume" } + | restore volume -> { actionName: "restoreVolume" }; // ===== Theme Mode ===== -@ = set theme to dark -> { actionName: "setThemeMode", parameters: { mode: "dark" } } + = set theme to dark -> { actionName: "setThemeMode", parameters: { mode: "dark" } } | set theme to light -> { actionName: "setThemeMode", parameters: { mode: "light" } } | toggle (theme)? mode -> { actionName: "setThemeMode", parameters: { mode: "toggle" } } | enable dark mode -> { actionName: "setThemeMode", parameters: { mode: "dark" } } | enable light mode -> { actionName: "setThemeMode", parameters: { mode: "light" } } | switch to dark (mode)? -> { actionName: "setThemeMode", parameters: { mode: "dark" } } - | switch to light (mode)? -> { actionName: "setThemeMode", parameters: { mode: "light" } } + | switch to light (mode)? -> { actionName: "setThemeMode", parameters: { mode: "light" } }; // ===== WiFi Control ===== -@ = connect to $(ssid:wildcard) wifi -> { actionName: "connectWifi", parameters: { ssid } } + = connect to $(ssid:wildcard) wifi -> { actionName: "connectWifi", parameters: { ssid } } | connect to wifi $(ssid:wildcard) -> { actionName: "connectWifi", parameters: { ssid } } | disconnect (from)? wifi -> { actionName: "disconnectWifi", parameters: {} } | enable airplane mode -> { actionName: "toggleAirplaneMode", parameters: { enable: true } } | disable airplane mode -> { actionName: "toggleAirplaneMode", parameters: { enable: false } } | turn on airplane mode -> { actionName: "toggleAirplaneMode", parameters: { enable: true } } - | turn off airplane mode -> { actionName: "toggleAirplaneMode", parameters: { enable: false } } + | turn off airplane mode -> { actionName: "toggleAirplaneMode", parameters: { enable: false } }; // ===== Desktop Management ===== -@ = create (new)? desktop -> { actionName: "createDesktop", parameters: { names: [] } } + = create (new)? desktop -> { actionName: "createDesktop", parameters: { names: [] } } | create desktop $(name:wildcard) -> { actionName: "createDesktop", parameters: { names: [name] } } | move $(program:) to desktop $(id:number) -> { actionName: "moveWindowToDesktop", parameters: { name: program, desktopId: id } } | pin $(program:) (to all desktops)? -> { actionName: "pinWindow", parameters: { name: program } } @@ -107,32 +107,32 @@ | previous desktop -> { actionName: "previousDesktop", parameters: {} } | show notifications -> { actionName: "toggleNotifications", parameters: { enable: true } } | hide notifications -> { actionName: "toggleNotifications", parameters: { enable: false } } - | toggle notifications -> { actionName: "toggleNotifications", parameters: { enable: true } } + | toggle notifications -> { actionName: "toggleNotifications", parameters: { enable: true } }; // ===== Network Settings (core) ===== -@ = - | + = + | ; -@ = + = turn on bluetooth -> { actionName: "BluetoothToggle", parameters: { enableBluetooth: true } } | turn off bluetooth -> { actionName: "BluetoothToggle", parameters: { enableBluetooth: false } } | enable bluetooth -> { actionName: "BluetoothToggle", parameters: { enableBluetooth: true } } | disable bluetooth -> { actionName: "BluetoothToggle", parameters: { enableBluetooth: false } } - | toggle bluetooth -> { actionName: "BluetoothToggle", parameters: {} } + | toggle bluetooth -> { actionName: "BluetoothToggle", parameters: {} }; -@ = + = turn on wifi -> { actionName: "enableWifi", parameters: { enable: true } } | turn off wifi -> { actionName: "enableWifi", parameters: { enable: false } } | enable wifi -> { actionName: "enableWifi", parameters: { enable: true } } | disable wifi -> { actionName: "enableWifi", parameters: { enable: false } } | turn on wi\-fi -> { actionName: "enableWifi", parameters: { enable: true } } - | turn off wi\-fi -> { actionName: "enableWifi", parameters: { enable: false } } + | turn off wi\-fi -> { actionName: "enableWifi", parameters: { enable: false } }; // ===== Brightness Control (core) ===== -@ = + = increase (screen)? brightness -> { actionName: "AdjustScreenBrightness", parameters: { brightnessLevel: "increase" } } | decrease (screen)? brightness -> { actionName: "AdjustScreenBrightness", parameters: { brightnessLevel: "decrease" } } | make (the)? screen brighter -> { actionName: "AdjustScreenBrightness", parameters: { brightnessLevel: "increase" } } | make (the)? screen dimmer -> { actionName: "AdjustScreenBrightness", parameters: { brightnessLevel: "decrease" } } | dim (the)? screen -> { actionName: "AdjustScreenBrightness", parameters: { brightnessLevel: "decrease" } } - | brighten (the)? screen -> { actionName: "AdjustScreenBrightness", parameters: { brightnessLevel: "increase" } } + | brighten (the)? screen -> { actionName: "AdjustScreenBrightness", parameters: { brightnessLevel: "increase" } }; diff --git a/ts/packages/agents/desktop/src/windows/displaySchema.agr b/ts/packages/agents/desktop/src/windows/displaySchema.agr index a67fd9b6e..9cb191bc2 100644 --- a/ts/packages/agents/desktop/src/windows/displaySchema.agr +++ b/ts/packages/agents/desktop/src/windows/displaySchema.agr @@ -4,40 +4,40 @@ // Desktop Display Settings Grammar // Night light, color temperature, scaling, orientation, rotation lock -@ = + = | | | - | + | ; -@ = + = enable night light -> { actionName: "EnableBlueLightFilterSchedule", parameters: { schedule: "sunset to sunrise", nightLightScheduleDisabled: false } } | disable night light -> { actionName: "EnableBlueLightFilterSchedule", parameters: { schedule: "", nightLightScheduleDisabled: true } } | turn on night light -> { actionName: "EnableBlueLightFilterSchedule", parameters: { schedule: "sunset to sunrise", nightLightScheduleDisabled: false } } | turn off night light -> { actionName: "EnableBlueLightFilterSchedule", parameters: { schedule: "", nightLightScheduleDisabled: true } } | enable blue light filter -> { actionName: "EnableBlueLightFilterSchedule", parameters: { schedule: "sunset to sunrise", nightLightScheduleDisabled: false } } - | disable blue light filter -> { actionName: "EnableBlueLightFilterSchedule", parameters: { schedule: "", nightLightScheduleDisabled: true } } + | disable blue light filter -> { actionName: "EnableBlueLightFilterSchedule", parameters: { schedule: "", nightLightScheduleDisabled: true } }; -@ = + = adjust color temperature -> { actionName: "adjustColorTemperature", parameters: {} } | reduce blue light -> { actionName: "adjustColorTemperature", parameters: { filterEffect: "reduce" } } | increase blue light -> { actionName: "adjustColorTemperature", parameters: { filterEffect: "increase" } } | warmer (screen)? colors -> { actionName: "adjustColorTemperature", parameters: { filterEffect: "reduce" } } - | cooler (screen)? colors -> { actionName: "adjustColorTemperature", parameters: { filterEffect: "increase" } } + | cooler (screen)? colors -> { actionName: "adjustColorTemperature", parameters: { filterEffect: "increase" } }; -@ = + = set (display)? scaling to $(size:number) (percent)? -> { actionName: "DisplayScaling", parameters: { sizeOverride: size } } | set text scaling to $(size:number) (percent)? -> { actionName: "DisplayScaling", parameters: { sizeOverride: size } } - | set zoom to $(size:number) (percent)? -> { actionName: "DisplayScaling", parameters: { sizeOverride: size } } + | set zoom to $(size:number) (percent)? -> { actionName: "DisplayScaling", parameters: { sizeOverride: size } }; -@ = + = set (screen)? orientation to landscape -> { actionName: "AdjustScreenOrientation", parameters: { orientation: "landscape" } } | set (screen)? orientation to portrait -> { actionName: "AdjustScreenOrientation", parameters: { orientation: "portrait" } } | rotate screen to landscape -> { actionName: "AdjustScreenOrientation", parameters: { orientation: "landscape" } } - | rotate screen to portrait -> { actionName: "AdjustScreenOrientation", parameters: { orientation: "portrait" } } + | rotate screen to portrait -> { actionName: "AdjustScreenOrientation", parameters: { orientation: "portrait" } }; -@ = + = lock (screen)? rotation -> { actionName: "RotationLock", parameters: { enable: true } } | unlock (screen)? rotation -> { actionName: "RotationLock", parameters: { enable: false } } | enable rotation lock -> { actionName: "RotationLock", parameters: { enable: true } } - | disable rotation lock -> { actionName: "RotationLock", parameters: { enable: false } } + | disable rotation lock -> { actionName: "RotationLock", parameters: { enable: false } }; diff --git a/ts/packages/agents/desktop/src/windows/inputSchema.agr b/ts/packages/agents/desktop/src/windows/inputSchema.agr index 93be1a1e3..756ee8dc8 100644 --- a/ts/packages/agents/desktop/src/windows/inputSchema.agr +++ b/ts/packages/agents/desktop/src/windows/inputSchema.agr @@ -4,60 +4,60 @@ // Desktop Input Settings Grammar // Mouse and touchpad settings -@ = + = | | | | | | - | + | ; -@ = + = set mouse speed to $(level:number) -> { actionName: "MouseCursorSpeed", parameters: { speedLevel: level } } | adjust mouse speed to $(level:number) -> { actionName: "MouseCursorSpeed", parameters: { speedLevel: level } } | change mouse sensitivity to $(level:number) -> { actionName: "MouseCursorSpeed", parameters: { speedLevel: level } } - | mouse speed $(level:number) -> { actionName: "MouseCursorSpeed", parameters: { speedLevel: level } } + | mouse speed $(level:number) -> { actionName: "MouseCursorSpeed", parameters: { speedLevel: level } }; -@ = + = set scroll (wheel)? lines to $(lines:number) -> { actionName: "MouseWheelScrollLines", parameters: { scrollLines: lines } } - | scroll $(lines:number) lines (per notch)? -> { actionName: "MouseWheelScrollLines", parameters: { scrollLines: lines } } + | scroll $(lines:number) lines (per notch)? -> { actionName: "MouseWheelScrollLines", parameters: { scrollLines: lines } }; -@ = + = set primary mouse button to left -> { actionName: "setPrimaryMouseButton", parameters: { primaryButton: "left" } } | set primary mouse button to right -> { actionName: "setPrimaryMouseButton", parameters: { primaryButton: "right" } } | swap mouse buttons -> { actionName: "setPrimaryMouseButton", parameters: { primaryButton: "right" } } | use left handed mouse -> { actionName: "setPrimaryMouseButton", parameters: { primaryButton: "right" } } - | use right handed mouse -> { actionName: "setPrimaryMouseButton", parameters: { primaryButton: "left" } } + | use right handed mouse -> { actionName: "setPrimaryMouseButton", parameters: { primaryButton: "left" } }; -@ = + = enable enhanced pointer precision -> { actionName: "EnhancePointerPrecision", parameters: { enable: true } } | disable enhanced pointer precision -> { actionName: "EnhancePointerPrecision", parameters: { enable: false } } | enable mouse acceleration -> { actionName: "EnhancePointerPrecision", parameters: { enable: true } } | disable mouse acceleration -> { actionName: "EnhancePointerPrecision", parameters: { enable: false } } | turn on mouse acceleration -> { actionName: "EnhancePointerPrecision", parameters: { enable: true } } - | turn off mouse acceleration -> { actionName: "EnhancePointerPrecision", parameters: { enable: false } } + | turn off mouse acceleration -> { actionName: "EnhancePointerPrecision", parameters: { enable: false } }; -@ = + = increase pointer size -> { actionName: "AdjustMousePointerSize", parameters: { sizeAdjustment: "increase" } } | decrease pointer size -> { actionName: "AdjustMousePointerSize", parameters: { sizeAdjustment: "decrease" } } | make pointer bigger -> { actionName: "AdjustMousePointerSize", parameters: { sizeAdjustment: "increase" } } | make pointer smaller -> { actionName: "AdjustMousePointerSize", parameters: { sizeAdjustment: "decrease" } } | bigger cursor -> { actionName: "AdjustMousePointerSize", parameters: { sizeAdjustment: "increase" } } - | smaller cursor -> { actionName: "AdjustMousePointerSize", parameters: { sizeAdjustment: "decrease" } } + | smaller cursor -> { actionName: "AdjustMousePointerSize", parameters: { sizeAdjustment: "decrease" } }; -@ = + = customize mouse pointer -> { actionName: "mousePointerCustomization", parameters: {} } | change mouse pointer style -> { actionName: "mousePointerCustomization", parameters: {} } - | open pointer settings -> { actionName: "mousePointerCustomization", parameters: {} } + | open pointer settings -> { actionName: "mousePointerCustomization", parameters: {} }; -@ = + = enable touchpad -> { actionName: "EnableTouchPad", parameters: { enable: true } } | disable touchpad -> { actionName: "EnableTouchPad", parameters: { enable: false } } | turn on touchpad -> { actionName: "EnableTouchPad", parameters: { enable: true } } - | turn off touchpad -> { actionName: "EnableTouchPad", parameters: { enable: false } } + | turn off touchpad -> { actionName: "EnableTouchPad", parameters: { enable: false } }; -@ = + = set touchpad speed to $(speed:number) -> { actionName: "TouchpadCursorSpeed", parameters: { speed } } | adjust touchpad sensitivity -> { actionName: "TouchpadCursorSpeed", parameters: {} } - | touchpad speed $(speed:number) -> { actionName: "TouchpadCursorSpeed", parameters: { speed } } + | touchpad speed $(speed:number) -> { actionName: "TouchpadCursorSpeed", parameters: { speed } }; diff --git a/ts/packages/agents/desktop/src/windows/personalizationSchema.agr b/ts/packages/agents/desktop/src/windows/personalizationSchema.agr index 718bfe899..bbf82f3f9 100644 --- a/ts/packages/agents/desktop/src/windows/personalizationSchema.agr +++ b/ts/packages/agents/desktop/src/windows/personalizationSchema.agr @@ -4,25 +4,25 @@ // Desktop Personalization Settings Grammar // Transparency, title bar colors, high contrast themes -@ = + = | - | + | ; -@ = + = enable transparency -> { actionName: "EnableTransparency", parameters: { enable: true } } | disable transparency -> { actionName: "EnableTransparency", parameters: { enable: false } } | turn on transparency (effects)? -> { actionName: "EnableTransparency", parameters: { enable: true } } - | turn off transparency (effects)? -> { actionName: "EnableTransparency", parameters: { enable: false } } + | turn off transparency (effects)? -> { actionName: "EnableTransparency", parameters: { enable: false } }; -@ = + = apply color to title bar -> { actionName: "ApplyColorToTitleBar", parameters: { enableColor: true } } | show accent color on title bars -> { actionName: "ApplyColorToTitleBar", parameters: { enableColor: true } } | enable title bar color -> { actionName: "ApplyColorToTitleBar", parameters: { enableColor: true } } | disable title bar color -> { actionName: "ApplyColorToTitleBar", parameters: { enableColor: false } } - | remove title bar color -> { actionName: "ApplyColorToTitleBar", parameters: { enableColor: false } } + | remove title bar color -> { actionName: "ApplyColorToTitleBar", parameters: { enableColor: false } }; -@ = + = enable high contrast -> { actionName: "HighContrastTheme", parameters: {} } | turn on high contrast -> { actionName: "HighContrastTheme", parameters: {} } | open high contrast (settings)? -> { actionName: "HighContrastTheme", parameters: {} } - | use high contrast (theme)? -> { actionName: "HighContrastTheme", parameters: {} } + | use high contrast (theme)? -> { actionName: "HighContrastTheme", parameters: {} }; diff --git a/ts/packages/agents/desktop/src/windows/powerSchema.agr b/ts/packages/agents/desktop/src/windows/powerSchema.agr index 194cc405a..cb9bccd20 100644 --- a/ts/packages/agents/desktop/src/windows/powerSchema.agr +++ b/ts/packages/agents/desktop/src/windows/powerSchema.agr @@ -4,28 +4,28 @@ // Desktop Power Settings Grammar // Battery saver and power mode configuration -@ = + = | - | + | ; -@ = + = set battery saver to $(level:number) (percent)? -> { actionName: "BatterySaverActivationLevel", parameters: { thresholdValue: level } } | battery saver at $(level:number) (percent)? -> { actionName: "BatterySaverActivationLevel", parameters: { thresholdValue: level } } | activate battery saver at $(level:number) (percent)? -> { actionName: "BatterySaverActivationLevel", parameters: { thresholdValue: level } } - | turn on battery saver at $(level:number) (percent)? -> { actionName: "BatterySaverActivationLevel", parameters: { thresholdValue: level } } + | turn on battery saver at $(level:number) (percent)? -> { actionName: "BatterySaverActivationLevel", parameters: { thresholdValue: level } }; -@ = + = set power mode to best performance -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "bestPerformance" } } | set power mode to balanced -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "balanced" } } | set power mode to best power efficiency -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "bestPowerEfficiency" } } | enable best performance mode -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "bestPerformance" } } | enable balanced mode -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "balanced" } } | enable power saver mode -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "bestPowerEfficiency" } } - | use best performance -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "bestPerformance" } } + | use best performance -> { actionName: "setPowerModePluggedIn", parameters: { powerMode: "bestPerformance" } }; -@ = + = set battery power mode to best performance -> { actionName: "SetPowerModeOnBattery", parameters: { powerMode: "bestPerformance" } } | set battery power mode to balanced -> { actionName: "SetPowerModeOnBattery", parameters: { powerMode: "balanced" } } | set battery power mode to best power efficiency -> { actionName: "SetPowerModeOnBattery", parameters: { powerMode: "bestPowerEfficiency" } } | on battery use best performance -> { actionName: "SetPowerModeOnBattery", parameters: { powerMode: "bestPerformance" } } - | on battery use power saver -> { actionName: "SetPowerModeOnBattery", parameters: { powerMode: "bestPowerEfficiency" } } + | on battery use power saver -> { actionName: "SetPowerModeOnBattery", parameters: { powerMode: "bestPowerEfficiency" } }; diff --git a/ts/packages/agents/desktop/src/windows/privacySchema.agr b/ts/packages/agents/desktop/src/windows/privacySchema.agr index 8ef3ba4a4..68cefe7d0 100644 --- a/ts/packages/agents/desktop/src/windows/privacySchema.agr +++ b/ts/packages/agents/desktop/src/windows/privacySchema.agr @@ -4,30 +4,30 @@ // Desktop Privacy Settings Grammar // Microphone, camera, and location access -@ = + = | - | + | ; -@ = + = allow microphone access -> { actionName: "ManageMicrophoneAccess", parameters: { accessSetting: "allow" } } | deny microphone access -> { actionName: "ManageMicrophoneAccess", parameters: { accessSetting: "deny" } } | enable microphone (access)? -> { actionName: "ManageMicrophoneAccess", parameters: { accessSetting: "allow" } } | disable microphone (access)? -> { actionName: "ManageMicrophoneAccess", parameters: { accessSetting: "deny" } } | turn on microphone -> { actionName: "ManageMicrophoneAccess", parameters: { accessSetting: "allow" } } - | turn off microphone -> { actionName: "ManageMicrophoneAccess", parameters: { accessSetting: "deny" } } + | turn off microphone -> { actionName: "ManageMicrophoneAccess", parameters: { accessSetting: "deny" } }; -@ = + = allow camera access -> { actionName: "ManageCameraAccess", parameters: { accessSetting: "allow" } } | deny camera access -> { actionName: "ManageCameraAccess", parameters: { accessSetting: "deny" } } | enable camera (access)? -> { actionName: "ManageCameraAccess", parameters: { accessSetting: "allow" } } | disable camera (access)? -> { actionName: "ManageCameraAccess", parameters: { accessSetting: "deny" } } | turn on camera -> { actionName: "ManageCameraAccess", parameters: { accessSetting: "allow" } } - | turn off camera -> { actionName: "ManageCameraAccess", parameters: { accessSetting: "deny" } } + | turn off camera -> { actionName: "ManageCameraAccess", parameters: { accessSetting: "deny" } }; -@ = + = allow location access -> { actionName: "ManageLocationAccess", parameters: { accessSetting: "allow" } } | deny location access -> { actionName: "ManageLocationAccess", parameters: { accessSetting: "deny" } } | enable location (services)? -> { actionName: "ManageLocationAccess", parameters: { accessSetting: "allow" } } | disable location (services)? -> { actionName: "ManageLocationAccess", parameters: { accessSetting: "deny" } } | turn on location -> { actionName: "ManageLocationAccess", parameters: { accessSetting: "allow" } } - | turn off location -> { actionName: "ManageLocationAccess", parameters: { accessSetting: "deny" } } + | turn off location -> { actionName: "ManageLocationAccess", parameters: { accessSetting: "deny" } }; diff --git a/ts/packages/agents/desktop/src/windows/systemSchema.agr b/ts/packages/agents/desktop/src/windows/systemSchema.agr index e3460fbf2..00cb6cfc2 100644 --- a/ts/packages/agents/desktop/src/windows/systemSchema.agr +++ b/ts/packages/agents/desktop/src/windows/systemSchema.agr @@ -4,7 +4,7 @@ // Desktop System Settings Grammar // Accessibility, file explorer, time settings, focus assist, multi-monitor, gaming, metered connections -@ = + = | | | @@ -17,96 +17,96 @@ | | | - | + | ; // ===== Network ===== -@ = + = enable metered connection -> { actionName: "enableMeteredConnections", parameters: { enable: true } } | disable metered connection -> { actionName: "enableMeteredConnections", parameters: { enable: false } } | turn on metered connection -> { actionName: "enableMeteredConnections", parameters: { enable: true } } - | turn off metered connection -> { actionName: "enableMeteredConnections", parameters: { enable: false } } + | turn off metered connection -> { actionName: "enableMeteredConnections", parameters: { enable: false } }; // ===== Gaming ===== -@ = + = enable game mode -> { actionName: "enableGameMode", parameters: {} } | open game mode (settings)? -> { actionName: "enableGameMode", parameters: {} } - | turn on game mode -> { actionName: "enableGameMode", parameters: {} } + | turn on game mode -> { actionName: "enableGameMode", parameters: {} }; // ===== Accessibility ===== -@ = + = enable narrator -> { actionName: "EnableNarratorAction", parameters: { enable: true } } | disable narrator -> { actionName: "EnableNarratorAction", parameters: { enable: false } } | start narrator -> { actionName: "EnableNarratorAction", parameters: { enable: true } } | stop narrator -> { actionName: "EnableNarratorAction", parameters: { enable: false } } | turn on narrator -> { actionName: "EnableNarratorAction", parameters: { enable: true } } - | turn off narrator -> { actionName: "EnableNarratorAction", parameters: { enable: false } } + | turn off narrator -> { actionName: "EnableNarratorAction", parameters: { enable: false } }; -@ = + = enable magnifier -> { actionName: "EnableMagnifier", parameters: { enable: true } } | disable magnifier -> { actionName: "EnableMagnifier", parameters: { enable: false } } | start magnifier -> { actionName: "EnableMagnifier", parameters: { enable: true } } | stop magnifier -> { actionName: "EnableMagnifier", parameters: { enable: false } } | turn on magnifier -> { actionName: "EnableMagnifier", parameters: { enable: true } } - | turn off magnifier -> { actionName: "EnableMagnifier", parameters: { enable: false } } + | turn off magnifier -> { actionName: "EnableMagnifier", parameters: { enable: false } }; -@ = + = enable sticky keys -> { actionName: "enableStickyKeys", parameters: { enable: true } } | disable sticky keys -> { actionName: "enableStickyKeys", parameters: { enable: false } } | turn on sticky keys -> { actionName: "enableStickyKeys", parameters: { enable: true } } - | turn off sticky keys -> { actionName: "enableStickyKeys", parameters: { enable: false } } + | turn off sticky keys -> { actionName: "enableStickyKeys", parameters: { enable: false } }; -@ = + = enable filter keys -> { actionName: "EnableFilterKeysAction", parameters: { enable: true } } | disable filter keys -> { actionName: "EnableFilterKeysAction", parameters: { enable: false } } | turn on filter keys -> { actionName: "EnableFilterKeysAction", parameters: { enable: true } } - | turn off filter keys -> { actionName: "EnableFilterKeysAction", parameters: { enable: false } } + | turn off filter keys -> { actionName: "EnableFilterKeysAction", parameters: { enable: false } }; -@ = + = enable mono audio -> { actionName: "MonoAudioToggle", parameters: { enable: true } } | disable mono audio -> { actionName: "MonoAudioToggle", parameters: { enable: false } } | turn on mono audio -> { actionName: "MonoAudioToggle", parameters: { enable: true } } - | turn off mono audio -> { actionName: "MonoAudioToggle", parameters: { enable: false } } + | turn off mono audio -> { actionName: "MonoAudioToggle", parameters: { enable: false } }; // ===== File Explorer ===== -@ = + = show file extensions -> { actionName: "ShowFileExtensions", parameters: { enable: true } } | hide file extensions -> { actionName: "ShowFileExtensions", parameters: { enable: false } } - | display file extensions -> { actionName: "ShowFileExtensions", parameters: { enable: true } } + | display file extensions -> { actionName: "ShowFileExtensions", parameters: { enable: true } }; -@ = + = show hidden files -> { actionName: "ShowHiddenAndSystemFiles", parameters: { enable: true } } | hide hidden files -> { actionName: "ShowHiddenAndSystemFiles", parameters: { enable: false } } | show system files -> { actionName: "ShowHiddenAndSystemFiles", parameters: { enable: true } } - | display hidden files -> { actionName: "ShowHiddenAndSystemFiles", parameters: { enable: true } } + | display hidden files -> { actionName: "ShowHiddenAndSystemFiles", parameters: { enable: true } }; // ===== Time & Region ===== -@ = + = enable automatic time sync -> { actionName: "AutomaticTimeSettingAction", parameters: { enableAutoTimeSync: true } } | disable automatic time sync -> { actionName: "AutomaticTimeSettingAction", parameters: { enableAutoTimeSync: false } } | automatically set time -> { actionName: "AutomaticTimeSettingAction", parameters: { enableAutoTimeSync: true } } - | sync time automatically -> { actionName: "AutomaticTimeSettingAction", parameters: { enableAutoTimeSync: true } } + | sync time automatically -> { actionName: "AutomaticTimeSettingAction", parameters: { enableAutoTimeSync: true } }; -@ = + = enable automatic dst (adjustment)? -> { actionName: "AutomaticDSTAdjustment", parameters: { enable: true } } | disable automatic dst (adjustment)? -> { actionName: "AutomaticDSTAdjustment", parameters: { enable: false } } | automatically adjust for dst -> { actionName: "AutomaticDSTAdjustment", parameters: { enable: true } } - | enable daylight saving time adjustment -> { actionName: "AutomaticDSTAdjustment", parameters: { enable: true } } + | enable daylight saving time adjustment -> { actionName: "AutomaticDSTAdjustment", parameters: { enable: true } }; // ===== Focus Assist ===== -@ = + = enable quiet hours -> { actionName: "EnableQuietHours", parameters: {} } | enable focus assist -> { actionName: "EnableQuietHours", parameters: {} } | turn on quiet hours -> { actionName: "EnableQuietHours", parameters: {} } | open focus assist (settings)? -> { actionName: "EnableQuietHours", parameters: {} } - | do not disturb -> { actionName: "EnableQuietHours", parameters: {} } + | do not disturb -> { actionName: "EnableQuietHours", parameters: {} }; // ===== Multi-Monitor ===== -@ = + = remember window locations -> { actionName: "RememberWindowLocations", parameters: { enable: true } } | forget window locations -> { actionName: "RememberWindowLocations", parameters: { enable: false } } - | remember window positions -> { actionName: "RememberWindowLocations", parameters: { enable: true } } + | remember window positions -> { actionName: "RememberWindowLocations", parameters: { enable: true } }; -@ = + = minimize windows on disconnect -> { actionName: "MinimizeWindowsOnMonitorDisconnectAction", parameters: { enable: true } } | minimize windows when monitor disconnects -> { actionName: "MinimizeWindowsOnMonitorDisconnectAction", parameters: { enable: true } } - | keep windows when monitor disconnects -> { actionName: "MinimizeWindowsOnMonitorDisconnectAction", parameters: { enable: false } } + | keep windows when monitor disconnects -> { actionName: "MinimizeWindowsOnMonitorDisconnectAction", parameters: { enable: false } }; diff --git a/ts/packages/agents/desktop/src/windows/taskbarSchema.agr b/ts/packages/agents/desktop/src/windows/taskbarSchema.agr index 03e482a63..7c52f6109 100644 --- a/ts/packages/agents/desktop/src/windows/taskbarSchema.agr +++ b/ts/packages/agents/desktop/src/windows/taskbarSchema.agr @@ -4,55 +4,55 @@ // Desktop Taskbar Settings Grammar // Auto-hide, alignment, task view, widgets, badges, multi-monitor, clock -@ = + = | | | | | - | + | ; -@ = + = auto hide (the)? taskbar -> { actionName: "AutoHideTaskbar", parameters: { hideWhenNotUsing: true, alwaysShow: false } } | automatically hide (the)? taskbar -> { actionName: "AutoHideTaskbar", parameters: { hideWhenNotUsing: true, alwaysShow: false } } | always show (the)? taskbar -> { actionName: "AutoHideTaskbar", parameters: { hideWhenNotUsing: false, alwaysShow: true } } | hide (the)? taskbar -> { actionName: "AutoHideTaskbar", parameters: { hideWhenNotUsing: true, alwaysShow: false } } - | show (the)? taskbar -> { actionName: "AutoHideTaskbar", parameters: { hideWhenNotUsing: false, alwaysShow: true } } + | show (the)? taskbar -> { actionName: "AutoHideTaskbar", parameters: { hideWhenNotUsing: false, alwaysShow: true } }; -@ = + = center (the)? taskbar -> { actionName: "TaskbarAlignment", parameters: { alignment: "center" } } | align taskbar (to)? center -> { actionName: "TaskbarAlignment", parameters: { alignment: "center" } } | left align (the)? taskbar -> { actionName: "TaskbarAlignment", parameters: { alignment: "left" } } - | align taskbar (to)? left -> { actionName: "TaskbarAlignment", parameters: { alignment: "left" } } + | align taskbar (to)? left -> { actionName: "TaskbarAlignment", parameters: { alignment: "left" } }; -@ = + = show task view (button)? -> { actionName: "TaskViewVisibility", parameters: { visibility: true } } | hide task view (button)? -> { actionName: "TaskViewVisibility", parameters: { visibility: false } } | enable task view (button)? -> { actionName: "TaskViewVisibility", parameters: { visibility: true } } - | disable task view (button)? -> { actionName: "TaskViewVisibility", parameters: { visibility: false } } + | disable task view (button)? -> { actionName: "TaskViewVisibility", parameters: { visibility: false } }; -@ = + = show widgets (button)? -> { actionName: "ToggleWidgetsButtonVisibility", parameters: { visibility: "show" } } | hide widgets (button)? -> { actionName: "ToggleWidgetsButtonVisibility", parameters: { visibility: "hide" } } | enable widgets (button)? -> { actionName: "ToggleWidgetsButtonVisibility", parameters: { visibility: "show" } } - | disable widgets (button)? -> { actionName: "ToggleWidgetsButtonVisibility", parameters: { visibility: "hide" } } + | disable widgets (button)? -> { actionName: "ToggleWidgetsButtonVisibility", parameters: { visibility: "hide" } }; -@ = + = show taskbar badges -> { actionName: "ShowBadgesOnTaskbar", parameters: { enableBadging: true } } | hide taskbar badges -> { actionName: "ShowBadgesOnTaskbar", parameters: { enableBadging: false } } | enable taskbar badges -> { actionName: "ShowBadgesOnTaskbar", parameters: { enableBadging: true } } - | disable taskbar badges -> { actionName: "ShowBadgesOnTaskbar", parameters: { enableBadging: false } } + | disable taskbar badges -> { actionName: "ShowBadgesOnTaskbar", parameters: { enableBadging: false } }; -@ = + = show taskbar on all monitors -> { actionName: "DisplayTaskbarOnAllMonitors", parameters: { enable: true } } | show taskbar on all displays -> { actionName: "DisplayTaskbarOnAllMonitors", parameters: { enable: true } } | hide taskbar from other monitors -> { actionName: "DisplayTaskbarOnAllMonitors", parameters: { enable: false } } - | show taskbar only on main monitor -> { actionName: "DisplayTaskbarOnAllMonitors", parameters: { enable: false } } + | show taskbar only on main monitor -> { actionName: "DisplayTaskbarOnAllMonitors", parameters: { enable: false } }; -@ = + = show seconds in clock -> { actionName: "DisplaySecondsInSystrayClock", parameters: { enable: true } } | hide seconds in clock -> { actionName: "DisplaySecondsInSystrayClock", parameters: { enable: false } } | display seconds in (system)? clock -> { actionName: "DisplaySecondsInSystrayClock", parameters: { enable: true } } | show only hours and minutes -> { actionName: "DisplaySecondsInSystrayClock", parameters: { enable: false } } | turn off seconds in clock -> { actionName: "DisplaySecondsInSystrayClock", parameters: { enable: false } } - | disable seconds in clock -> { actionName: "DisplaySecondsInSystrayClock", parameters: { enable: false } } + | disable seconds in clock -> { actionName: "DisplaySecondsInSystrayClock", parameters: { enable: false } }; diff --git a/ts/packages/agents/email/src/emailSchema.agr b/ts/packages/agents/email/src/emailSchema.agr index fa2f9ec53..2fa102d3c 100644 --- a/ts/packages/agents/email/src/emailSchema.agr +++ b/ts/packages/agents/email/src/emailSchema.agr @@ -4,38 +4,38 @@ // Email Management Grammar // Covers: sendEmail, replyEmail, forwardEmail, findEmail actions -@ = | | | + = | | | ; // ===== Main Action Rules ===== -@ = $(to:string) $(subject:string) $(body:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "sendEmail", parameters: { to: to, subject: subject, body: body, cc: cc, bcc: bcc, attachments: attachments } } + = $(to:string) $(subject:string) $(body:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "sendEmail", parameters: { to: to, subject: subject, body: body, cc: cc, bcc: bcc, attachments: attachments } } | $(to:string) $(body:string) $(subject:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "sendEmail", parameters: { to: to, subject: subject, body: body, cc: cc, bcc: bcc, attachments: attachments } } | $(to:string) $(subject:string) $(body:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "sendEmail", parameters: { to: to, subject: subject, body: body, cc: cc, bcc: bcc, attachments: attachments } } - | $(to:string) $(body:string) $(subject:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "sendEmail", parameters: { to: to, subject: subject, body: body, cc: cc, bcc: bcc, attachments: attachments } } + | $(to:string) $(body:string) $(subject:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "sendEmail", parameters: { to: to, subject: subject, body: body, cc: cc, bcc: bcc, attachments: attachments } }; -@ = $(messageRef:string) $(body:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "replyEmail", parameters: { messageRef: messageRef, body: body, cc: cc, bcc: bcc, attachments: attachments } } - | $(body:string) ('to' | 'for') $(messageRef:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "replyEmail", parameters: { messageRef: messageRef, body: body, cc: cc, bcc: bcc, attachments: attachments } } + = $(messageRef:string) $(body:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "replyEmail", parameters: { messageRef: messageRef, body: body, cc: cc, bcc: bcc, attachments: attachments } } + | $(body:string) ('to' | 'for') $(messageRef:string) $(cc:)? $(bcc:)? $(attachments:)? -> { actionName: "replyEmail", parameters: { messageRef: messageRef, body: body, cc: cc, bcc: bcc, attachments: attachments } }; -@ = $(messageRef:string) ('to' | 'for') $(to:string) $(additionalMessage:string)? $(cc:)? $(bcc:)? -> { actionName: "forwardEmail", parameters: { messageRef: messageRef, to: to, additionalMessage: additionalMessage, cc: cc, bcc: bcc } } - | $(to:string) $(messageRef:string) $(additionalMessage:string)? $(cc:)? $(bcc:)? -> { actionName: "forwardEmail", parameters: { messageRef: messageRef, to: to, additionalMessage: additionalMessage, cc: cc, bcc: bcc } } + = $(messageRef:string) ('to' | 'for') $(to:string) $(additionalMessage:string)? $(cc:)? $(bcc:)? -> { actionName: "forwardEmail", parameters: { messageRef: messageRef, to: to, additionalMessage: additionalMessage, cc: cc, bcc: bcc } } + | $(to:string) $(messageRef:string) $(additionalMessage:string)? $(cc:)? $(bcc:)? -> { actionName: "forwardEmail", parameters: { messageRef: messageRef, to: to, additionalMessage: additionalMessage, cc: cc, bcc: bcc } }; -@ = $(messageRef:string) -> { actionName: "findEmail", parameters: { messageRef: messageRef } } - | ('with' | 'having')? ('message' | 'msg')? ('reference' | 'ref' | 'id') $(messageRef:string) -> { actionName: "findEmail", parameters: { messageRef: messageRef } } + = $(messageRef:string) -> { actionName: "findEmail", parameters: { messageRef: messageRef } } + | ('with' | 'having')? ('message' | 'msg')? ('reference' | 'ref' | 'id') $(messageRef:string) -> { actionName: "findEmail", parameters: { messageRef: messageRef } }; // ===== Shared Sub-Rules ===== -@ = ? (('send' ('an' | 'a')? 'email') | 'email') ('to' | 'for')? -@ = ? ('reply' | 'respond') ('to' | 'for')? -@ = ? ('forward' | 'fwd') ('the' | 'this')? ('email' | 'message')? -@ = ? (('find' | 'look' 'up' | 'locate' | 'pull' 'up') ('the' | 'that')? ('email' | 'message')) + = ? (('send' ('an' | 'a')? 'email') | 'email') ('to' | 'for')?; + = ? ('reply' | 'respond') ('to' | 'for')?; + = ? ('forward' | 'fwd') ('the' | 'this')? ('email' | 'message')?; + = ? (('find' | 'look' 'up' | 'locate' | 'pull' 'up') ('the' | 'that')? ('email' | 'message')); -@ = ('with' ('the' | 'a')? 'subject' | 'subject' ('should' 'be' | 'is' | ':')?) -@ = ('and' | 'with')? ('let' ('me' | 'them') 'know' | 'saying' | 'that' | 'about' | 'body' | 'message')? -@ = 'about' | 'regarding' | 'concerning' -@ = ('subject' ('should' 'be' | 'is' | ':')? | 'title') + = ('with' ('the' | 'a')? 'subject' | 'subject' ('should' 'be' | 'is' | ':')?); + = ('and' | 'with')? ('let' ('me' | 'them') 'know' | 'saying' | 'that' | 'about' | 'body' | 'message')?; + = 'about' | 'regarding' | 'concerning'; + = ('subject' ('should' 'be' | 'is' | ':')? | 'title'); -@ = ('cc' | 'copy') $(cc:string) -> cc -@ = ('bcc' | 'blind' 'copy') $(bcc:string) -> bcc -@ = ('with' | 'attach' | 'include') $(attachments:string) ('attached' | 'included')? -> attachments + = ('cc' | 'copy') $(cc:string) -> cc; + = ('bcc' | 'blind' 'copy') $(bcc:string) -> bcc; + = ('with' | 'attach' | 'include') $(attachments:string) ('attached' | 'included')? -> attachments; -@ = ('can' 'you' | 'please' | 'would' 'you' | 'i' 'need' 'to') \ No newline at end of file + = ('can' 'you' | 'please' | 'would' 'you' | 'i' 'need' 'to'); \ No newline at end of file diff --git a/ts/packages/agents/image/src/imageSchema.agr b/ts/packages/agents/image/src/imageSchema.agr index fd38bd146..8d3a22ce5 100644 --- a/ts/packages/agents/image/src/imageSchema.agr +++ b/ts/packages/agents/image/src/imageSchema.agr @@ -2,59 +2,59 @@ // Auto-generated grammar for imageSchema // Start rule - references all action rules by exact action names -@ = + = ; // Main action rule for creating images -@ = $(originalRequest:string) $(caption:string) $(numImages:string) -> { + = $(originalRequest:string) $(caption:string) $(numImages:string) -> { actionName: "createImageAction", parameters: { originalRequest: originalRequest, caption: caption, numImages: numImages } -} +}; // Alternative action rule that captures number first -@ = $(numImages:number) 'of' $(originalRequest:string) $(caption:string) -> { + = $(numImages:number) 'of' $(originalRequest:string) $(caption:string) -> { actionName: "createImageAction", parameters: { originalRequest: originalRequest, caption: caption, numImages: numImages } -} +}; // Alternative action rule for single image requests -@ = $(originalRequest:string) $(caption:string) -> { + = $(originalRequest:string) $(caption:string) -> { actionName: "createImageAction", parameters: { originalRequest: originalRequest, caption: caption, numImages: "1" } -} +}; // Shared sub-rules for common patterns // Polite request phrases -@ = ('can you' | 'could you' | 'please' | 'would you')? + = ('can you' | 'could you' | 'please' | 'would you')?; // Create/generate action phrases -@ = ('create' | 'generate' | 'make' ('me')?) + = ('create' | 'generate' | 'make' ('me')?) ; // Caption specification patterns -@ = ('with' ('the')? 'caption' | 'caption' ('it' | 'them' | 'should be')? | 'use' ('the')? 'caption' | 'captioned') + = ('with' ('the')? 'caption' | 'caption' ('it' | 'them' | 'should be')? | 'use' ('the')? 'caption' | 'captioned'); // Number of images specification -@ = $(numImages:number) -> numImages -@ = 'single' -> "1" -@ = ('a' | 'an') -> "1" + = $(numImages:number) -> numImages; + = 'single' -> "1"; + = ('a' | 'an') -> "1"; // Single image phrases -@ = ('an' | 'a' | 'single') ('of' | 'showing')? + = ('an' | 'a' | 'single') ('of' | 'showing')?; // Image-related words -@ = ('image' | 'images' | 'picture' | 'pictures' | 'photo' | 'photos') + = ('image' | 'images' | 'picture' | 'pictures' | 'photo' | 'photos'); // Common conversational fillers -@ = ('I' ('need' | 'want') | 'I\'d like') \ No newline at end of file + = ('I' ('need' | 'want') | 'I\'d like'); \ No newline at end of file diff --git a/ts/packages/agents/list/src/listSchema.agr b/ts/packages/agents/list/src/listSchema.agr index ae0e0d6c3..c25d1ccca 100644 --- a/ts/packages/agents/list/src/listSchema.agr +++ b/ts/packages/agents/list/src/listSchema.agr @@ -6,7 +6,7 @@ // Types: wildcard = 1+ words, word = exactly 1 word // addItems - add one or more items to a list -@ = add $(item:wildcard) to (the)? (my)? $(listName:wildcard) list -> { + = add $(item:wildcard) to (the)? (my)? $(listName:wildcard) list -> { actionName: "addItems", parameters: { items: [item], @@ -33,10 +33,10 @@ items: [item1, item2], listName } -} +}; // removeItems - remove one or more items from a list -@ = remove $(item:wildcard) from (the)? (my)? $(listName:wildcard) list -> { + = remove $(item:wildcard) from (the)? (my)? $(listName:wildcard) list -> { actionName: "removeItems", parameters: { items: [item], @@ -56,10 +56,10 @@ items: [item], listName } -} +}; // createList - create a new list -@ = create (a)? (new)? $(listName:wildcard) list -> { + = create (a)? (new)? $(listName:wildcard) list -> { actionName: "createList", parameters: { listName @@ -76,11 +76,11 @@ parameters: { listName } -} +}; // getList - show what's on the list // Note: Each rule must have at least one distinctive required word before the wildcard -@ = what's on (the)? (my)? $(listName:wildcard) (list)? -> { + = what's on (the)? (my)? $(listName:wildcard) (list)? -> { actionName: "getList", parameters: { listName @@ -115,10 +115,10 @@ parameters: { listName } -} +}; // clearList - clear all items from a list -@ = clear (the)? (my)? $(listName:wildcard) list -> { + = clear (the)? (my)? $(listName:wildcard) list -> { actionName: "clearList", parameters: { listName @@ -135,10 +135,10 @@ parameters: { listName } -} +}; -@ = + = | | | - | + | ; diff --git a/ts/packages/agents/photo/src/photoSchema.agr b/ts/packages/agents/photo/src/photoSchema.agr index 082c4139f..230fefee8 100644 --- a/ts/packages/agents/photo/src/photoSchema.agr +++ b/ts/packages/agents/photo/src/photoSchema.agr @@ -2,16 +2,16 @@ // Photo Action Grammar // Main entry point -@ = + = ; // Action rules -@ = $(originalRequest:string) -> { actionName: "takePhoto", parameters: { originalRequest: originalRequest } } + = $(originalRequest:string) -> { actionName: "takePhoto", parameters: { originalRequest: originalRequest } }; // Sub-rules for common patterns -@ = + = ; -@ = ('can you' | 'could you' | 'please' | 'would you')? + = ('can you' | 'could you' | 'please' | 'would you')?; -@ = ('take' ('a' ('photo' | 'picture' | 'pic' | 'shot'))?) | 'snap' ('a' ('picture' | 'pic' | 'shot'))? | 'photograph' | 'photo' + = ('take' ('a' ('photo' | 'picture' | 'pic' | 'shot'))?) | 'snap' ('a' ('picture' | 'pic' | 'shot'))? | 'photograph' | 'photo'; -@ = 'of'? \ No newline at end of file + = 'of'?; \ No newline at end of file diff --git a/ts/packages/agents/player/src/agent/playerSchema.agr b/ts/packages/agents/player/src/agent/playerSchema.agr index e7ec940bb..40a777e03 100644 --- a/ts/packages/agents/player/src/agent/playerSchema.agr +++ b/ts/packages/agents/player/src/agent/playerSchema.agr @@ -3,22 +3,22 @@ entity Ordinal, Cardinal; -@ = + = | | | - | -@ = pause -> { actionName: "pause" } + | ; + = pause -> { actionName: "pause" } | pause music -> { actionName: "pause" } - | pause the music -> { actionName: "pause" } -@ = resume -> { actionName: "resume" } + | pause the music -> { actionName: "pause" }; + = resume -> { actionName: "resume" } | resume music -> { actionName: "resume" } - | resume the music -> { actionName: "resume" } -@ = next -> { actionName: "nextTrack" } + | resume the music -> { actionName: "resume" }; + = next -> { actionName: "nextTrack" } | skip -> { actionName: "nextTrack" } - | skip -> { actionName: "nextTrack" } -@ = | -@ = + | skip -> { actionName: "nextTrack" }; + = | ; + = play (the)? $(n:Ordinal) ()? -> { actionName: "playFromCurrentTrackList", parameters: { @@ -36,32 +36,32 @@ entity Ordinal, Cardinal; parameters: { trackNumber: n } - } + }; -@ = one | cut | -@ = track | song + = one | cut | ; + = track | song; -@ = $(trackName:) -> trackName + = $(trackName:) -> trackName | the $(trackName:) -> trackName | $(trackName:) -> trackName - | $(trackName:) -> trackName -@ = play $(trackName:) by $(artist:) -> { actionName: "playTrack", parameters: { trackName, artists: [artist] } } + | $(trackName:) -> trackName; + = play $(trackName:) by $(artist:) -> { actionName: "playTrack", parameters: { trackName, artists: [artist] } } | play $(trackName:) from (the)? album $(albumName:) -> { actionName: "playTrack", parameters: { trackName, albumName } } - | play $(trackName:) by $(artist:) from (the)? album $(albumName:) -> { actionName: "playTrack", parameters: { trackName, artists: [artist], albumName } } + | play $(trackName:) by $(artist:) from (the)? album $(albumName:) -> { actionName: "playTrack", parameters: { trackName, artists: [artist], albumName } } ; -@ = select $(deviceName:) -> { actionName: "selectDevice", parameters: { deviceName } } + = select $(deviceName:) -> { actionName: "selectDevice", parameters: { deviceName } } | select (the)? $(deviceName:) device -> { actionName: "selectDevice", parameters: { deviceName } } | switch to $(deviceName:) -> { actionName: "selectDevice", parameters: { deviceName } } | switch to (the)? $(deviceName:) device -> { actionName: "selectDevice", parameters: { deviceName } } | use (the)? $(deviceName:) device -> { actionName: "selectDevice", parameters: { deviceName } } | use device $(deviceName:) -> { actionName: "selectDevice", parameters: { deviceName } } | play on $(deviceName:) -> { actionName: "selectDevice", parameters: { deviceName } } - | play on (the)? $(deviceName:) device -> { actionName: "selectDevice", parameters: { deviceName } } + | play on (the)? $(deviceName:) device -> { actionName: "selectDevice", parameters: { deviceName } }; // Entity types: wildcard = 1+ words, word = exactly 1 word -@ = $(x:wildcard) -@ = $(x:wildcard) -@ = $(x:wildcard) -@ = $(x:wildcard) + = $(x:wildcard); + = $(x:wildcard); + = $(x:wildcard); + = $(x:wildcard); diff --git a/ts/packages/agents/playerLocal/src/agent/localPlayerSchema.agr b/ts/packages/agents/playerLocal/src/agent/localPlayerSchema.agr index b7a8e8481..392b05bd6 100644 --- a/ts/packages/agents/playerLocal/src/agent/localPlayerSchema.agr +++ b/ts/packages/agents/playerLocal/src/agent/localPlayerSchema.agr @@ -5,7 +5,7 @@ entity Ordinal, Cardinal; -@ = + = | | | @@ -16,23 +16,23 @@ entity Ordinal, Cardinal; | | | - | + | ; -@ = pause ((the)? music)? -> { actionName: "pause" } + = pause ((the)? music)? -> { actionName: "pause" }; -@ = resume ((the)? music)? -> { actionName: "resume" } + = resume ((the)? music)? -> { actionName: "resume" }; -@ = stop ((the)? music)? -> { actionName: "stop" } + = stop ((the)? music)? -> { actionName: "stop" }; -@ = (next | skip) (track | song)? -> { actionName: "next" } + = (next | skip) (track | song)? -> { actionName: "next" }; -@ = (previous | back | last) (track | song)? -> { actionName: "previous" } + = (previous | back | last) (track | song)? -> { actionName: "previous" }; -@ = (what('s | is) | show) (playing | status | now playing)? -> { actionName: "status" } + = (what('s | is) | show) (playing | status | now playing)? -> { actionName: "status" }; -@ = + = ; -@ = + = play (the)? $(n:Ordinal) (track | song)? -> { actionName: "playFromQueue", parameters: { @@ -50,26 +50,26 @@ entity Ordinal, Cardinal; parameters: { trackNumber: n } - } + }; -@ = | | + = | | ; -@ = (local player | local music player | music player)? + = (local player | local music player | music player)?; -@ = (turn up | increase | raise) (the)? volume - -> { actionName: "changeVolume", parameters: { amount: 10 } } + = (turn up | increase | raise) (the)? volume + -> { actionName: "changeVolume", parameters: { amount: 10 } }; -@ = (turn down | decrease | lower) (the)? volume - -> { actionName: "changeVolume", parameters: { amount: -10 } } + = (turn down | decrease | lower) (the)? volume + -> { actionName: "changeVolume", parameters: { amount: -10 } }; -@ = set volume (to)? $(n:number) (percent)? - -> { actionName: "setVolume", parameters: { level: n } } + = set volume (to)? $(n:number) (percent)? + -> { actionName: "setVolume", parameters: { level: n } }; -@ = mute (the)? (music | sound | audio)? -> { actionName: "mute", parameters: { isMuted: true } } + = mute (the)? (music | sound | audio)? -> { actionName: "mute", parameters: { isMuted: true } }; -@ = unmute (the)? (music | sound | audio)? -> { actionName: "mute", parameters: { isMuted: false } } + = unmute (the)? (music | sound | audio)? -> { actionName: "mute", parameters: { isMuted: false } }; -@ = (show | list | display) (the)? queue -> { actionName: "showQueue" } + = (show | list | display) (the)? queue -> { actionName: "showQueue" }; -@ = clear (the)? queue -> { actionName: "clearQueue" } + = clear (the)? queue -> { actionName: "clearQueue" }; diff --git a/ts/packages/agents/video/src/videoSchema.agr b/ts/packages/agents/video/src/videoSchema.agr index f0d0b4730..660a33785 100644 --- a/ts/packages/agents/video/src/videoSchema.agr +++ b/ts/packages/agents/video/src/videoSchema.agr @@ -14,57 +14,57 @@ // Video Schema Grammar -@ = + = ; // Main action rule -@ = $(request:) $(files:)? $(duration:)? $(caption:)? -> { actionName: "createVideoAction", parameters: { originalRequest: request, relatedFiles: files, duration: duration, caption: caption } } + = $(request:) $(files:)? $(duration:)? $(caption:)? -> { actionName: "createVideoAction", parameters: { originalRequest: request, relatedFiles: files, duration: duration, caption: caption } }; // Video request patterns -@ = -> "video_request" + = -> "video_request"; -@ = ? ? | | + = ? ? | | ; -@ = ('can you' | 'could you' | 'please' | 'would you')? + = ('can you' | 'could you' | 'please' | 'would you')?; -@ = 'create' | 'make' | 'generate' | 'build' | 'produce' + = 'create' | 'make' | 'generate' | 'build' | 'produce'; -@ = ('a' | 'an')? ('video' | 'slideshow' | 'compilation' | 'clip' | 'presentation') + = ('a' | 'an')? ('video' | 'slideshow' | 'compilation' | 'clip' | 'presentation'); -@ = ('promotional' | 'quick' | 'brief' | 'social media' | 'professional')? + = ('promotional' | 'quick' | 'brief' | 'social media' | 'professional')?; -@ = 'from' ('these' | 'the')? + = 'from' ('these' | 'the')?; -@ = ('i need' | 'need') ('a' | 'an')? + = ('i need' | 'need') ('a' | 'an')?; // File specification patterns -@ = -> "file_spec" + = -> "file_spec"; -@ = | + = | ; -@ = 'using' ('the' | 'these')? + = 'using' ('the' | 'these')? ; -@ = ('product images' | 'vacation photos' | 'screenshots' | 'presentation slides' | 'team photos' | 'recipe photos' | 'renovation pics' | 'before' 'after' 'pics' | 'charts and graphs' | 'files' | 'photos' | 'images') + = ('product images' | 'vacation photos' | 'screenshots' | 'presentation slides' | 'team photos' | 'recipe photos' | 'renovation pics' | 'before' 'after' 'pics' | 'charts and graphs' | 'files' | 'photos' | 'images'); -@ = ('in' 'the')? ('marketing folder' | 'food folder' | 'app demo' | 'folder' | 'directory') + = ('in' 'the')? ('marketing folder' | 'food folder' | 'app demo' | 'folder' | 'directory'); // Duration specification patterns -@ = -> "duration_spec" + = -> "duration_spec"; -@ = | | | + = | | | ; -@ = $(time:string) ('seconds' | 'second' | 'minutes' | 'minute' | 'mins' | 'min') + = $(time:string) ('seconds' | 'second' | 'minutes' | 'minute' | 'mins' | 'min'); -@ = ('keep it' | 'make it') ('under' | 'about' | 'around')? $(time:string) ('seconds' | 'second' | 'minutes' | 'minute') + = ('keep it' | 'make it') ('under' | 'about' | 'around')? $(time:string) ('seconds' | 'second' | 'minutes' | 'minute'); -@ = ('about' | 'around' | 'maybe') $(time:string) ('seconds' | 'second' | 'minutes' | 'minute') ('long' | 'duration')? + = ('about' | 'around' | 'maybe') $(time:string) ('seconds' | 'second' | 'minutes' | 'minute') ('long' | 'duration')?; -@ = $(time:string) ('seconds' | 'second' | 'minutes' | 'minute') ('would be perfect' | 'duration')? + = $(time:string) ('seconds' | 'second' | 'minutes' | 'minute') ('would be perfect' | 'duration')?; // Caption specification patterns -@ = -> "caption_spec" + = -> "caption_spec"; -@ = $(text:string) | $(text:string) + = $(text:string) | $(text:string); -@ = ('add a caption that says' | 'with the caption' | 'caption should be' | 'with caption') + = ('add a caption that says' | 'with the caption' | 'caption should be' | 'with caption'); -@ = ('as the caption' | 'for the caption') \ No newline at end of file + = ('as the caption' | 'for the caption'); \ No newline at end of file diff --git a/ts/packages/agents/weather/src/weatherSchema.agr b/ts/packages/agents/weather/src/weatherSchema.agr index d0b1c6378..6b72f5cef 100644 --- a/ts/packages/agents/weather/src/weatherSchema.agr +++ b/ts/packages/agents/weather/src/weatherSchema.agr @@ -1,17 +1,17 @@ // Copyright (c) 2024 Anthropic PBC. All rights reserved. // Weather Action Grammar -@ = | | + = | | ; // Action Rules -@ = ? $(location:) $(units:)? -> { actionName: "getCurrentConditions", parameters: { location: location, units: units } } + = ? $(location:) $(units:)? -> { actionName: "getCurrentConditions", parameters: { location: location, units: units } }; -@ = ? $(location:) $(days:)? $(units:)? -> { actionName: "getForecast", parameters: { location: location, days: days, units: units } } + = ? $(location:) $(days:)? $(units:)? -> { actionName: "getForecast", parameters: { location: location, days: days, units: units } }; -@ = ? $(location:) -> { actionName: "getAlerts", parameters: { location: location } } + = ? $(location:) -> { actionName: "getAlerts", parameters: { location: location } }; // Weather Pattern Rules -@ = ( + = ( "what's the weather like" | "check the current conditions" | "current weather" | @@ -21,9 +21,9 @@ "current conditions" | "weather conditions" | "how's the weather" -) +); -@ = ( + = ( "weather forecast" | "forecast" | "weather outlook" | @@ -33,9 +33,9 @@ "what's the forecast" | "weather prediction" | "upcoming weather" -) +); -@ = ( + = ( "weather alerts" | "get alerts" | "check alerts" | @@ -43,47 +43,47 @@ "any alerts" | "weather advisories" | "storm warnings" -) +); // Location Specification -@ = ( + = ( ("in" | "for") $(location:string) -> location | $(location:string) -> location -) +); // Days Specification -@ = ( + = ( ("for the next" | "over the next") $(days:number) ("day" | "days") -> days | $(days:number) ("day" | "days") -> days | ("for" | "next") $(days:number) ("day" | "days") -> days | "tomorrow" -> 1 | "next week" -> 7 -) +); // Units Specification -@ = ( + = ( ("in" | "with" | "using") $(units:) -> units | $(units:) -> units -) +); -@ = ( + = ( ("celsius" | "metric" | "metric units") -> "celsius" | ("fahrenheit" | "imperial" | "fahrenheit units") -> "fahrenheit" -) +); // Common Patterns -@ = ( + = ( "can you" | "please" | "would you" | "could you" | "i need" | "show me" -)? +)?; -@ = ( + = ( "right now" | "currently" | "at the moment" | "today" -)? \ No newline at end of file +)?; \ No newline at end of file diff --git a/ts/packages/azure-ai-foundry/package.json b/ts/packages/azure-ai-foundry/package.json index ebcca99ff..21298c703 100644 --- a/ts/packages/azure-ai-foundry/package.json +++ b/ts/packages/azure-ai-foundry/package.json @@ -26,9 +26,9 @@ "clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log", "prettier": "prettier --check . --ignore-path ../../.prettierignore", "prettier:fix": "prettier --write . --ignore-path ../../prettierignore", - "test": "npm run test:local", - "test:local": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", - "test:local:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", + "test": "npm run test:live", + "test:live": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", + "test:live:debug": "node --inspect-brk --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=\".*\\.spec\\.js\"", "tsc": "tsc -b" }, "dependencies": { diff --git a/ts/packages/cache/test/backwardCompatibility.spec.ts b/ts/packages/cache/test/backwardCompatibility.spec.ts index 91b28076e..b15e2ba43 100644 --- a/ts/packages/cache/test/backwardCompatibility.spec.ts +++ b/ts/packages/cache/test/backwardCompatibility.spec.ts @@ -24,13 +24,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { describe("Basic Grammar Loading and Matching", () => { it("should load and match grammar without any NFA infrastructure", () => { // This is how grammars were loaded before NFA integration - const grammarText = `@ = -@ = play $(track:string) -> { + const grammarText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); expect(grammar).toBeDefined(); @@ -61,24 +61,24 @@ describe("Backward Compatibility - Completion-Based Cache", () => { it("should match multiple grammars without NFA", () => { const playerGrammar = loadGrammarRules( "player", - `@ = -@ = play $(track:string) -> { + ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`, +};`, ); const calendarGrammar = loadGrammarRules( "calendar", - `@ = -@ = schedule $(event:string) -> { + ` = ; + = schedule $(event:string) -> { actionName: "schedule", parameters: { event } -}`, +};`, ); const cache = new AgentCache( @@ -118,13 +118,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { describe("Wildcard Matching", () => { it("should match wildcards in completion-based mode", () => { - const grammarText = `@ = -@ = set volume to $(level:number) -> { + const grammarText = ` = ; + = set volume to $(level:number) -> { actionName: "setVolume", parameters: { level } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( @@ -147,13 +147,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { }); it("should handle string wildcards", () => { - const grammarText = `@ = -@ = search for $(query:string) -> { + const grammarText = ` = ; + = search for $(query:string) -> { actionName: "search", parameters: { query } -}`; +};`; const grammar = loadGrammarRules("search", grammarText); const cache = new AgentCache( @@ -181,21 +181,21 @@ describe("Backward Compatibility - Completion-Based Cache", () => { describe("Grammar Alternatives", () => { it("should match multiple alternatives in completion-based mode", () => { - const grammarText = `@ = | | -@ = play $(track:string) -> { + const grammarText = ` = | | ; + = play $(track:string) -> { actionName: "play", parameters: { track } -} -@ = pause -> { +}; + = pause -> { actionName: "pause", parameters: {} -} -@ = stop -> { +}; + = stop -> { actionName: "stop", parameters: {} -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( @@ -230,13 +230,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { describe("Optional Patterns", () => { it("should match optional tokens", () => { - const grammarText = `@ = -@ = play (the)? (song)? $(track:string) -> { + const grammarText = ` = ; + = play (the)? (song)? $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( @@ -271,13 +271,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { describe("No NFA Configuration", () => { it("should work without ever calling configureGrammarGeneration", () => { - const grammarText = `@ = -@ = test $(value:string) -> { + const grammarText = ` = ; + = test $(value:string) -> { actionName: "test", parameters: { value } -}`; +};`; const grammar = loadGrammarRules("test", grammarText); const cache = new AgentCache( @@ -301,13 +301,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { }); it("should work when configureGrammarGeneration is called with completionBased mode", () => { - const grammarText = `@ = -@ = test $(value:string) -> { + const grammarText = ` = ; + = test $(value:string) -> { actionName: "test", parameters: { value } -}`; +};`; const grammar = loadGrammarRules("test", grammarText); const cache = new AgentCache( @@ -333,13 +333,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { describe("Empty and No-Match Cases", () => { it("should return empty array when no grammar matches", () => { - const grammarText = `@ = -@ = play $(track:string) -> { + const grammarText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( @@ -356,13 +356,13 @@ describe("Backward Compatibility - Completion-Based Cache", () => { }); it("should return empty array when namespace key doesn't match", () => { - const grammarText = `@ = -@ = play $(track:string) -> { + const grammarText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( diff --git a/ts/packages/cache/test/grammarIntegration.spec.ts b/ts/packages/cache/test/grammarIntegration.spec.ts index 879c479de..7720cba14 100644 --- a/ts/packages/cache/test/grammarIntegration.spec.ts +++ b/ts/packages/cache/test/grammarIntegration.spec.ts @@ -57,13 +57,13 @@ describe("Grammar Integration", () => { it("should add grammar to AgentCache's internal grammar store", () => { // Create test grammar const grammarText = ` -@ = -@ = play $(track:string) -> { + = ; + = play $(track:string) -> { actionName: "playTrack", parameters: { track } -} +}; `.trim(); const grammar = loadGrammarRules("player", grammarText); @@ -95,13 +95,13 @@ describe("Grammar Integration", () => { it("should sync dynamic rules from AgentGrammarRegistry to GrammarStoreImpl", () => { // Create test grammar const staticGrammarText = ` -@ = -@ = play $(track:string) -> { + = ; + = play $(track:string) -> { actionName: "playTrack", parameters: { track } -} +}; `.trim(); const staticGrammar = loadGrammarRules("player", staticGrammarText); @@ -120,11 +120,11 @@ describe("Grammar Integration", () => { agentGrammarRegistry.registerAgent("player", staticGrammar, nfa); // Add dynamic rule to AgentGrammarRegistry - const dynamicRule = `@ = -@ = pause -> { + const dynamicRule = ` = ; + = pause -> { actionName: "pause", parameters: {} -}`; +};`; const agentGrammar = agentGrammarRegistry.getAgent("player"); const result = agentGrammar!.addGeneratedRules(dynamicRule); if (!result.success) { @@ -169,13 +169,13 @@ describe("Grammar Integration", () => { it("should handle multiple dynamic rule additions with sync", () => { const staticGrammarText = ` -@ = -@ = play $(track:string) -> { + = ; + = play $(track:string) -> { actionName: "playTrack", parameters: { track } -} +}; `.trim(); const staticGrammar = loadGrammarRules("player", staticGrammarText); @@ -200,19 +200,21 @@ describe("Grammar Integration", () => { const agentGrammar = agentGrammarRegistry.getAgent("player"); // Add first dynamic rule - agentGrammar!.addGeneratedRules(`@ = -@ = pause -> { + agentGrammar!.addGeneratedRules(` + = ; + = pause -> { actionName: "pause", parameters: {} -}`); +};`); cache.syncAgentGrammar("player"); // Add second dynamic rule - agentGrammar!.addGeneratedRules(`@ = -@ = stop -> { + agentGrammar!.addGeneratedRules(` + = ; + = stop -> { actionName: "stop", parameters: {} -}`); +};`); cache.syncAgentGrammar("player"); const namespaceKeys = cache.getNamespaceKeys(["player"], undefined); @@ -236,20 +238,20 @@ describe("Grammar Integration", () => { await persistedStore.newStore(grammarStoreFile); await persistedStore.addRule({ - grammarText: `@ = pause -> { + grammarText: ` = pause -> { actionName: "pause", parameters: {} -}`, +};`, schemaName: "player", sourceRequest: "pause", actionName: "pause", }); await persistedStore.addRule({ - grammarText: `@ = stop -> { + grammarText: ` = stop -> { actionName: "stop", parameters: {} -}`, +};`, schemaName: "player", sourceRequest: "stop", actionName: "stop", @@ -259,13 +261,13 @@ describe("Grammar Integration", () => { // Now simulate initialization - load static grammar and merge persisted rules const staticGrammarText = ` -@ = -@ = play $(track:string) -> { + = ; + = play $(track:string) -> { actionName: "playTrack", parameters: { track } -} +}; `.trim(); const staticGrammar = loadGrammarRules("player", staticGrammarText); @@ -301,7 +303,7 @@ describe("Grammar Integration", () => { expect(agentGrammar).toBeDefined(); // Add Start rule to make dynamic rules reachable - const startRule = "@ = | "; + const startRule = " = | ;"; const combinedRules = startRule + "\n\n" + rules.join("\n\n"); const result = agentGrammar!.addGeneratedRules(combinedRules); if (!result.success) { @@ -346,21 +348,21 @@ describe("Grammar Integration", () => { // Add rules for two different schemas await persistedStore.addRule({ - grammarText: `@ = pause -> { + grammarText: ` = pause -> { actionName: "pause", parameters: {} -}`, +};`, schemaName: "player", actionName: "pause", }); await persistedStore.addRule({ - grammarText: `@ = schedule $(event:string) -> { + grammarText: ` = schedule $(event:string) -> { actionName: "scheduleEvent", parameters: { event } -}`, +};`, schemaName: "calendar", actionName: "scheduleEvent", }); @@ -370,23 +372,23 @@ describe("Grammar Integration", () => { // Load static grammars for both schemas const playerGrammar = loadGrammarRules( "player", - `@ = -@ = play $(track:string) -> { + ` = ; + = play $(track:string) -> { actionName: "playTrack", parameters: { track } -}`, +};`, ); const calendarGrammar = loadGrammarRules( "calendar", - `@ = -@ = add $(event:string) -> { + ` = ; + = add $(event:string) -> { actionName: "addEvent", parameters: { event } -}`, +};`, ); const cache = new AgentCache( @@ -435,9 +437,9 @@ describe("Grammar Integration", () => { // Add Start rule appropriate for each schema let startRule = ""; if (schemaName === "player") { - startRule = "@ = "; + startRule = " = ;"; } else if (schemaName === "calendar") { - startRule = "@ = "; + startRule = " = ;"; } const combinedRules = startRule + "\n\n" + rules.join("\n\n"); const result = agentGrammar!.addGeneratedRules(combinedRules); @@ -472,17 +474,17 @@ describe("Grammar Integration", () => { describe("Cache Matching with Combined Grammars", () => { it("should match requests against combined static + dynamic grammars", () => { const staticGrammarText = ` -@ = | -@ = "play" $(track:string) -> { + = | ; + = "play" $(track:string) -> { actionName: "playTrack", parameters: { track } -} -@ = pause music -> { +}; + = pause music -> { actionName: "pause", parameters: {} -} +}; `.trim(); const staticGrammar = loadGrammarRules("player", staticGrammarText); @@ -503,11 +505,11 @@ describe("Grammar Integration", () => { // Add dynamic rule for simple "pause" without "music" const agentGrammar = agentGrammarRegistry.getAgent("player"); - agentGrammar!.addGeneratedRules(`@ = -@ = pause -> { + agentGrammar!.addGeneratedRules(` = ; + = pause -> { actionName: "pauseShort", parameters: {} -}`); +};`); cache.configureGrammarGeneration( agentGrammarRegistry, @@ -537,23 +539,23 @@ describe("Grammar Integration", () => { // Setup two schemas const playerGrammar = loadGrammarRules( "player", - `@ = -@ = play $(track:string) -> { + ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`, +};`, ); const calendarGrammar = loadGrammarRules( "calendar", - `@ = -@ = schedule $(event:string) -> { + ` = ; + = schedule $(event:string) -> { actionName: "schedule", parameters: { event } -}`, +};`, ); const cache = new AgentCache( @@ -602,13 +604,13 @@ describe("Grammar Integration", () => { describe("Dual System Support", () => { it("should support NFA system when configured", () => { - const grammarText = `@ = -@ = play $(track:string) -> { + const grammarText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( @@ -640,13 +642,13 @@ describe("Grammar Integration", () => { }); it("should support completionBased system when configured", () => { - const grammarText = `@ = -@ = play $(track:string) -> { + const grammarText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( @@ -669,21 +671,21 @@ describe("Grammar Integration", () => { describe("Partial Matching / Completions", () => { it("should provide completions for partial requests in NFA mode", () => { - const grammarText = `@ = | | -@ = play $(track:string) -> { + const grammarText = ` = | | ; + = play $(track:string) -> { actionName: "play", parameters: { track } -} -@ = pause -> { +}; + = pause -> { actionName: "pause", parameters: {} -} -@ = stop -> { +}; + = stop -> { actionName: "stop", parameters: {} -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( "test", @@ -723,17 +725,17 @@ describe("Grammar Integration", () => { }); it("should provide completions for partial requests in completion-based mode", () => { - const grammarText = `@ = | -@ = play $(track:string) -> { + const grammarText = ` = | ; + = play $(track:string) -> { actionName: "play", parameters: { track } -} -@ = pause -> { +}; + = pause -> { actionName: "pause", parameters: {} -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( "test", @@ -762,14 +764,14 @@ describe("Grammar Integration", () => { }); it("should provide parameter completions for partial requests", () => { - const grammarText = `@ = -@ = play $(track:string) by $(artist:string) -> { + const grammarText = ` = ; + = play $(track:string) by $(artist:string) -> { actionName: "play", parameters: { track, artist } -}`; +};`; const grammar = loadGrammarRules("player", grammarText); const cache = new AgentCache( "test", @@ -827,13 +829,13 @@ describe("Grammar Integration", () => { () => hasTestKeys(), () => { it("should generate and add grammar rules from request/action pairs", async () => { - const staticGrammarText = `@ = -@ = play $(track:string) -> { + const staticGrammarText = ` = ; + = play $(track:string) -> { actionName: "play", parameters: { track } -}`; +};`; const grammar = loadGrammarRules("player", staticGrammarText); const cache = new AgentCache( "test", @@ -861,7 +863,7 @@ describe("Grammar Integration", () => { // Verify schema file exists if (!fs.existsSync(playerSchemaPath)) { console.log( - `⚠ Player schema not found at ${playerSchemaPath}`, + `⚠ Player schema not found at ${playerSchemaPath};`, ); console.log( "Run 'npm run build' in packages/agents/player to generate the schema", @@ -869,7 +871,7 @@ describe("Grammar Integration", () => { return; // Skip test if schema not built } - console.log(`Using player schema: ${playerSchemaPath}`); + console.log(`Using player schema: ${playerSchemaPath};`); // Configure with schema path getter cache.configureGrammarGeneration( @@ -1002,19 +1004,19 @@ describe("Grammar Integration", () => { describe("Grammar Merging - Comprehensive Tests", () => { it("should handle multi-token sequences correctly after merging", () => { const grammar1Text = ` -@ = -@ = turn on the lights -> { + = ; + = turn on the lights -> { actionName: "lightsOn", parameters: {} -} +}; `.trim(); const grammar2Text = ` -@ = -@ = lights on -> { + = ; + = lights on -> { actionName: "lightsOnShort", parameters: {} -} +}; `.trim(); const grammar1 = loadGrammarRules("test1", grammar1Text); @@ -1072,24 +1074,24 @@ describe("Grammar Integration", () => { it("should handle merging with parameters and wildcards", () => { const staticGrammar = ` -@ = -@ = play $(track:string) on $(device:string) -> { + = ; + = play $(track:string) on $(device:string) -> { actionName: "playOnDevice", parameters: { track, device } -} +}; `.trim(); const dynamicGrammar = ` -@ = -@ = play $(track:string) -> { + = ; + = play $(track:string) -> { actionName: "playSimple", parameters: { track } -} +}; `.trim(); const grammar1 = loadGrammarRules("player", staticGrammar); @@ -1153,21 +1155,21 @@ describe("Grammar Integration", () => { it("should prioritize more specific patterns over general ones", () => { const specificGrammar = ` -@ = -@ = turn on kitchen lights -> { + = ; + = turn on kitchen lights -> { actionName: "kitchenLightsOn", parameters: {} -} +}; `.trim(); const generalGrammar = ` -@ = -@ = turn on $(item:string) -> { + = ; + = turn on $(item:string) -> { actionName: "turnOn", parameters: { item } -} +}; `.trim(); const grammar1 = loadGrammarRules("home", specificGrammar); @@ -1211,18 +1213,18 @@ describe("Grammar Integration", () => { it("should handle multiple Start rules from different merges", () => { const grammar1 = ` -@ = -@ = command one -> { actionName: "one", parameters: {} } + = ; + = command one -> { actionName: "one", parameters: {} }; `.trim(); const grammar2 = ` -@ = -@ = command two -> { actionName: "two", parameters: {} } + = ; + = command two -> { actionName: "two", parameters: {} }; `.trim(); const grammar3 = ` -@ = -@ = command three -> { actionName: "three", parameters: {} } + = ; + = command three -> { actionName: "three", parameters: {} }; `.trim(); const g1 = loadGrammarRules("test", grammar1); @@ -1271,13 +1273,13 @@ describe("Grammar Integration", () => { it("should handle edge case of single token vs multi-token", () => { const multiToken = ` -@ = -@ = stop playing -> { actionName: "stop", parameters: {} } + = ; + = stop playing -> { actionName: "stop", parameters: {} }; `.trim(); const singleToken = ` -@ = -@ = stop -> { actionName: "stopShort", parameters: {} } + = ; + = stop -> { actionName: "stopShort", parameters: {} }; `.trim(); const g1 = loadGrammarRules("player", multiToken); diff --git a/ts/packages/commandExecutor/src/generatedSchemaRegistry.json b/ts/packages/commandExecutor/src/generatedSchemaRegistry.json new file mode 100644 index 000000000..d473ba1b6 --- /dev/null +++ b/ts/packages/commandExecutor/src/generatedSchemaRegistry.json @@ -0,0 +1,1043 @@ +[ + { + "name": "calendar", + "emoji": "📅", + "description": "Agent integration with MS Graph's calendar", + "subSchemas": [ + { + "schemaName": "calendar", + "description": "Calendar agent that keeps track of important dates and events. Use it to schedule appointments, set reminders, and organize activities.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/calendar/src/calendarActionsSchemaV3.ts", + "actions": [ + { + "name": "scheduleEvent", + "description": "Schedule a new event on the calendar" + }, + { + "name": "findEvents", + "description": "Find events on the calendar" + }, + { + "name": "addParticipant", + "description": "Add a participant to an event" + }, + { + "name": "findTodaysEvents", + "description": "Find all events happening today" + }, + { + "name": "findThisWeeksEvents", + "description": "Find all events happening this week" + }, + { + "name": "removeEvent", + "description": "Remove an event from the calendar" + } + ] + } + ] + }, + { + "name": "code", + "emoji": "⚛️", + "description": "Agent for VSCode integration", + "subSchemas": [ + { + "schemaName": "code", + "description": "Code agent helps you with productivity in using an editor and performing actions like creating files, editor customization, writing code, intelligent code suggestions, real-time error detection, debugging, and source control tasks etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/code/src/codeActionsSchema.ts", + "actions": [ + { + "name": "changeColorScheme", + "description": "Change the color scheme of the editor" + }, + { + "name": "splitEditor", + "description": "ACTION: Split an editor window into multiple panes showing the same file or different files side-by-side." + }, + { + "name": "changeEditorLayout", + "description": "Change the editor layout to single, double or three column layout" + }, + { + "name": "newFile", + "description": "Create a new file, this is not same as opening a file or finding a file in the workspace" + }, + { + "name": "launchVSCode", + "description": "Launch or Start VSCode" + } + ] + }, + { + "schemaName": "code.code-debug", + "description": "Code agent that helps you debug code including handling actions like showing the debug panel, adding/toggling breakpoints, stepping in/out of code etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/code/src/vscode/debugActionsSchema.ts", + "actions": [ + { + "name": "showDebugPanel", + "description": "Show debug panel or window in the editor or code window, if not already visible" + }, + { + "name": "startDebugging", + "description": "Start/Continue debugging" + }, + { + "name": "step", + "description": "Step into/out/over" + }, + { + "name": "stopDebugging", + "description": "Stop debugging" + }, + { + "name": "showHover", + "description": "Show hover" + }, + { + "name": "toggleBreakpoint", + "description": "Toggle Breakpoint" + }, + { + "name": "setBreakpoint", + "description": "Set Breakpoint" + }, + { + "name": "removeBreakpoint", + "description": "Remove Breakpoint" + }, + { + "name": "removeAllBreakpoints", + "description": "Remove All Breakpoints" + } + ] + }, + { + "schemaName": "code.code-display", + "description": "Code agent that helps you work with display keyboard bindings, Zoom in, Zoom out, do text search and replace, show extensions etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/code/src/vscode/displayActionsSchema.ts", + "actions": [ + { + "name": "zoomIn", + "description": "Zoom in the editor" + }, + { + "name": "zoomOut", + "description": "Zoom out the editor" + }, + { + "name": "fontZoomReset", + "description": "Zoom reset" + }, + { + "name": "showExplorer", + "description": "Show explorer/show the file explorer" + }, + { + "name": "showSearch", + "description": "Show search or replace pane/window in the sidebar to search for text in the files" + }, + { + "name": "showSourceControl", + "description": "Show source control" + }, + { + "name": "showOutputPanel", + "description": "Show output panel" + }, + { + "name": "toggleSearchDetails", + "description": "Toggle search details" + }, + { + "name": "replaceInFiles", + "description": "Replace in files" + }, + { + "name": "openMarkdownPreview", + "description": "Open markdown preview" + }, + { + "name": "openMarkdownPreviewToSide", + "description": "Open markdown preview to the side" + }, + { + "name": "zenMode", + "description": "Code in Zen Mode" + }, + { + "name": "closeEditor", + "description": "Close the current editor" + }, + { + "name": "openSettings", + "description": "Open settings" + } + ] + }, + { + "schemaName": "code.code-general", + "description": "Code agent that helps you perform actions like finding a file, go to a symbol or a line in a file, Open new vscode window, show the command palette, user settings json etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/code/src/vscode/generalActionsSchema.ts", + "actions": [ + { + "name": "showCommandPalette", + "description": "Show or open the command palette that allows to search and execute commands" + }, + { + "name": "gotoFileOrLineOrSymbol", + "description": "Quick option to access a file, alternate way to search a file by name using keyboard shortcuts" + }, + { + "name": "showUserSettings", + "description": "Show user settings" + }, + { + "name": "showKeyboardShortcuts", + "description": "Show keyboard shortcuts" + } + ] + }, + { + "schemaName": "code.code-editor", + "description": "Code agent that helps you perform vscode editor actions like create a new file, go to a reference, reveal a declaration, clipboard copy or paste, add a comment line etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/code/src/vscode/editorCodeActionsSchema.ts", + "actions": [ + { + "name": "createFunction", + "description": "Schema to generate a function" + }, + { + "name": "createCodeBlock", + "description": "Create Code Block" + }, + { + "name": "fixCodeProblem", + "description": "schema to fix a problem (diagnostic) in the code." + }, + { + "name": "moveCursorInFile", + "description": "ACTION: Move the cursor to a specific position within a file (for navigation or editing preparation)." + }, + { + "name": "insertOrDeleteLines", + "description": "Action for inserting or deleting lines in a file." + }, + { + "name": "insertComment", + "description": "Insert Comment" + }, + { + "name": "generateWithCopilot", + "description": "Generate With Copilot" + }, + { + "name": "createFile", + "description": "Action to create a new file in the editor" + }, + { + "name": "saveCurrentFile", + "description": "Save Current File" + }, + { + "name": "saveAllFiles", + "description": "Save All Files" + } + ] + }, + { + "schemaName": "code.code-workbench", + "description": "Code agent that helps you perform vscode workbench actions like open a file, close a file etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/code/src/vscode/workbenchCommandActionsSchema.ts", + "actions": [ + { + "name": "workbenchOpenFile", + "description": "Workbench Open File" + }, + { + "name": "workbenchOpenFolder", + "description": "Workbench Open Folder" + }, + { + "name": "workbenchCreateFolderFromExplorer", + "description": "Workbench Create Folder From Explorer" + }, + { + "name": "workbenchBuildRelatedTask", + "description": "Workbench Build Related Task" + }, + { + "name": "openInIntegratedTerminal", + "description": "Open In Integrated Terminal" + } + ] + }, + { + "schemaName": "code.code-extension", + "description": "Code agent that helps you perform vscode extension actions like show, install, update, enable, disable, uninstall extensions etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/code/src/vscode/extensionsActionsSchema.ts", + "actions": [ + { + "name": "checkExtensionAvailable", + "description": "The action checks/searches if an extension is available based on user requests like is the copilot extension available?" + }, + { + "name": "installExtension", + "description": "Install Extension" + }, + { + "name": "reloadWindow", + "description": "Reload Window" + }, + { + "name": "showExtensions", + "description": "Show the extensions panel" + }, + { + "name": "enableExtension", + "description": "Enable Extension" + }, + { + "name": "disableExtension", + "description": "Disable Extension" + } + ] + } + ] + }, + { + "name": "desktop", + "emoji": "🪟", + "description": "Agent to control the desktop", + "subSchemas": [ + { + "schemaName": "desktop", + "description": "Desktop agent that allows you to manage the programs running on a computer, change Windows settings, control the desktop environment, and perform actions such as opening a file, closing a window, tiling windows, launching a program, maximizing windows, adjusting display settings, managing privacy settings, and controlling system features.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/actionsSchema.ts", + "actions": [ + { + "name": "launchProgram", + "description": "Launches a new program window on a Windows Desktop" + }, + { + "name": "closeProgram", + "description": "Closes a program window on a Windows Desktop" + }, + { + "name": "tile", + "description": "Positions program windows on a program window on a Windows Desktop" + }, + { + "name": "maximize", + "description": "Maximizes a program window on a Windows Desktop" + }, + { + "name": "minimize", + "description": "Minimizes a program window on a Windows Desktop" + }, + { + "name": "switchTo", + "description": "Sets focus to a program window on a Windows Desktop" + }, + { + "name": "volume", + "description": "Volume" + }, + { + "name": "restoreVolume", + "description": "Restore Volume" + }, + { + "name": "mute", + "description": "Mute" + }, + { + "name": "setWallpaper", + "description": "Set Wallpaper" + }, + { + "name": "setThemeMode", + "description": "Sets the theme mode of the current [windows] desktop" + }, + { + "name": "connectWifi", + "description": "Connect Wifi" + }, + { + "name": "disconnectWifi", + "description": "Disconnects from the current wifi network" + }, + { + "name": "toggleAirplaneMode", + "description": "Toggle Airplane Mode" + }, + { + "name": "createDesktop", + "description": "creates a new Windows Desktop" + }, + { + "name": "moveWindowToDesktop", + "description": "Move Window To Desktop" + }, + { + "name": "pinWindow", + "description": "Pin Window" + }, + { + "name": "switchDesktop", + "description": "Switch Desktop" + }, + { + "name": "nextDesktop", + "description": "switches to the next Windows Desktop" + }, + { + "name": "previousDesktop", + "description": "switches to the previous Windows Desktop" + }, + { + "name": "toggleNotifications", + "description": "Shows/hides windows notification center" + }, + { + "name": "debug", + "description": "Attaches the debugger to the AutoShell process" + }, + { + "name": "setTextSize", + "description": "Changes the text size that appears throughout Windows and your apps" + }, + { + "name": "setScreenResolution", + "description": "Change screen resolution" + }, + { + "name": "BluetoothToggle", + "description": "===== Common Settings Actions =====" + }, + { + "name": "enableWifi", + "description": "Enables or disables WiFi adapter" + }, + { + "name": "AdjustScreenBrightness", + "description": "Adjusts screen brightness (increase or decrease)" + } + ] + }, + { + "schemaName": "desktop.desktop-display", + "description": "Desktop agent for display and screen settings including night light, color temperature, scaling, orientation, and rotation lock.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/windows/displayActionsSchema.ts", + "actions": [ + { + "name": "EnableBlueLightFilterSchedule", + "description": "Enables or disables blue light filter schedule (Night Light)" + }, + { + "name": "adjustColorTemperature", + "description": "Adjusts the color temperature for Night Light" + }, + { + "name": "DisplayScaling", + "description": "Sets display scaling percentage (100, 125, 150, 175, 200)" + }, + { + "name": "AdjustScreenOrientation", + "description": "Adjusts screen orientation between portrait and landscape" + }, + { + "name": "RotationLock", + "description": "Locks or unlocks screen rotation" + } + ] + }, + { + "schemaName": "desktop.desktop-personalization", + "description": "Desktop agent for personalization settings including transparency effects, title bar colors, and high contrast themes.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/windows/personalizationActionsSchema.ts", + "actions": [ + { + "name": "EnableTransparency", + "description": "Enables or disables transparency effects" + }, + { + "name": "ApplyColorToTitleBar", + "description": "Applies accent color to title bars" + }, + { + "name": "HighContrastTheme", + "description": "Enables high contrast theme" + } + ] + }, + { + "schemaName": "desktop.desktop-taskbar", + "description": "Desktop agent for taskbar settings including auto-hide, alignment, task view, widgets, badges, and system clock options.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/windows/taskbarActionsSchema.ts", + "actions": [ + { + "name": "AutoHideTaskbar", + "description": "Auto-hides the taskbar" + }, + { + "name": "TaskbarAlignment", + "description": "Sets taskbar alignment (left or center)" + }, + { + "name": "TaskViewVisibility", + "description": "Shows or hides the Task View button" + }, + { + "name": "ToggleWidgetsButtonVisibility", + "description": "Shows or hides the Widgets button" + }, + { + "name": "ShowBadgesOnTaskbar", + "description": "Shows or hides badges on taskbar icons" + }, + { + "name": "DisplayTaskbarOnAllMonitors", + "description": "Shows taskbar on all monitors" + }, + { + "name": "DisplaySecondsInSystrayClock", + "description": "Shows seconds in the system tray clock" + } + ] + }, + { + "schemaName": "desktop.desktop-input", + "description": "Desktop agent for mouse and touchpad settings including cursor speed, scroll lines, button configuration, pointer precision, and touchpad controls.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/windows/inputActionsSchema.ts", + "actions": [ + { + "name": "MouseCursorSpeed", + "description": "Adjusts mouse cursor speed" + }, + { + "name": "MouseWheelScrollLines", + "description": "Sets the number of lines to scroll per mouse wheel notch" + }, + { + "name": "setPrimaryMouseButton", + "description": "Sets the primary mouse button" + }, + { + "name": "EnhancePointerPrecision", + "description": "Enables or disables enhanced pointer precision (mouse acceleration)" + }, + { + "name": "AdjustMousePointerSize", + "description": "Adjusts mouse pointer size" + }, + { + "name": "mousePointerCustomization", + "description": "Customizes mouse pointer color" + }, + { + "name": "EnableTouchPad", + "description": "Enables or disables the touchpad" + }, + { + "name": "TouchpadCursorSpeed", + "description": "Adjusts touchpad cursor speed" + } + ] + }, + { + "schemaName": "desktop.desktop-privacy", + "description": "Desktop agent for privacy settings to manage microphone, camera, and location access for applications.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/windows/privacyActionsSchema.ts", + "actions": [ + { + "name": "ManageMicrophoneAccess", + "description": "Manages microphone access for apps" + }, + { + "name": "ManageCameraAccess", + "description": "Manages camera access for apps" + }, + { + "name": "ManageLocationAccess", + "description": "Manages location access for apps" + } + ] + }, + { + "schemaName": "desktop.desktop-power", + "description": "Desktop agent for power management settings including battery saver and power mode configuration.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/windows/powerActionsSchema.ts", + "actions": [ + { + "name": "BatterySaverActivationLevel", + "description": "Sets the battery saver activation threshold" + }, + { + "name": "setPowerModePluggedIn", + "description": "Sets power mode when plugged in" + }, + { + "name": "SetPowerModeOnBattery", + "description": "Sets power mode when on battery" + } + ] + }, + { + "schemaName": "desktop.desktop-system", + "description": "Desktop agent for system settings including accessibility features, file explorer options, time settings, focus assist, multi-monitor configuration, and other system-level controls.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/desktop/src/windows/systemActionsSchema.ts", + "actions": [ + { + "name": "enableMeteredConnections", + "description": "Enables or disables metered connection settings" + }, + { + "name": "enableGameMode", + "description": "Enables or disables Game Mode" + }, + { + "name": "EnableNarratorAction", + "description": "Enables or disables Narrator" + }, + { + "name": "EnableMagnifier", + "description": "Enables or disables Magnifier" + }, + { + "name": "enableStickyKeys", + "description": "Enables or disables Sticky Keys" + }, + { + "name": "EnableFilterKeysAction", + "description": "Enables or disables Filter Keys" + }, + { + "name": "MonoAudioToggle", + "description": "Enables or disables mono audio" + }, + { + "name": "ShowFileExtensions", + "description": "Shows or hides file extensions in File Explorer" + }, + { + "name": "ShowHiddenAndSystemFiles", + "description": "Shows or hides hidden and system files in File Explorer" + }, + { + "name": "AutomaticTimeSettingAction", + "description": "Enables or disables automatic time synchronization" + }, + { + "name": "AutomaticDSTAdjustment", + "description": "Enables or disables automatic DST adjustment" + }, + { + "name": "EnableQuietHours", + "description": "Enables or disables Focus Assist (Quiet Hours)" + }, + { + "name": "RememberWindowLocations", + "description": "Remembers window locations based on monitor configuration" + }, + { + "name": "MinimizeWindowsOnMonitorDisconnectAction", + "description": "Minimizes windows when a monitor is disconnected" + } + ] + } + ] + }, + { + "name": "email", + "emoji": "📩", + "description": "Agent integration with MS Graph's email", + "subSchemas": [ + { + "schemaName": "email", + "description": "Email agent helps manage email messages. Use it to send, reply, forward, find messages etc.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/email/src/emailActionsSchema.ts", + "actions": [ + { + "name": "sendEmail", + "description": "Type for sending a simple email" + }, + { + "name": "replyEmail", + "description": "Type for replying to an email" + }, + { + "name": "forwardEmail", + "description": "Type for forwarding an email" + }, + { + "name": "findEmail", + "description": "Type for finding an email message (search for emails)" + } + ] + } + ] + }, + { + "name": "image", + "emoji": "🖼️", + "description": "Agent to create AI images", + "subSchemas": [ + { + "schemaName": "image", + "description": "Image agent that creates images using AI image modes.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/image/src/imageActionSchema.ts", + "actions": [ + { + "name": "createImageAction", + "description": "creates an image based on the supplied description" + } + ] + } + ] + }, + { + "name": "list", + "emoji": "📝", + "description": "Agent to create and manage lists", + "subSchemas": [ + { + "schemaName": "list", + "description": "List agent with actions to create lists, show list items, add and remove list items", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/list/src/listSchema.ts", + "actions": [ + { + "name": "addItems", + "description": "add one or more items to a list; if the list does not exist, create it" + }, + { + "name": "removeItems", + "description": "remove one or more items from a list" + }, + { + "name": "createList", + "description": "Create List" + }, + { + "name": "getList", + "description": "use this action to show the user what's on the list, for example, \"What's on my grocery list?\" or \"what are the contents of my to do list?\"" + }, + { + "name": "clearList", + "description": "Clear List" + }, + { + "name": "startEditList", + "description": "Start Edit List" + } + ] + } + ] + }, + { + "name": "photo", + "emoji": "📷", + "description": "Agent to take and upload photos", + "subSchemas": [ + { + "schemaName": "photo", + "description": "Photo agent that helps the user provide images to the system either by taking pictures or uploading existing images.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/photo/src/photoSchema.ts", + "actions": [ + { + "name": "takePhoto", + "description": "uses a camera attached to the system to take a photo" + } + ] + } + ] + }, + { + "name": "player", + "emoji": "🎧", + "description": "Agent to play music", + "subSchemas": [ + { + "schemaName": "player", + "description": "Music Player agent that lets you search for, play and control music.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/player/src/agent/playerSchema.ts", + "actions": [ + { + "name": "playRandom", + "description": "Use playRandom when the user asks for some music to play" + }, + { + "name": "playTrack", + "description": "Play a specific track" + }, + { + "name": "playFromCurrentTrackList", + "description": "play the track single track at index 'trackNumber' in the current track list" + }, + { + "name": "playAlbum", + "description": "Play a specific album" + }, + { + "name": "playArtist", + "description": "Play Artist" + }, + { + "name": "playGenre", + "description": "Play Genre" + }, + { + "name": "status", + "description": "show now playing including track information, and playback status including playback device" + }, + { + "name": "pause", + "description": "pause playback" + }, + { + "name": "resume", + "description": "resume playback" + }, + { + "name": "next", + "description": "next track" + }, + { + "name": "previous", + "description": "previous track" + }, + { + "name": "shuffle", + "description": "turn shuffle on or off" + }, + { + "name": "listDevices", + "description": "list available playback devices" + }, + { + "name": "setDefaultDevice", + "description": "Set Default Device" + }, + { + "name": "selectDevice", + "description": "select playback device by keyword" + }, + { + "name": "showSelectedDevice", + "description": "show the selected playback device" + }, + { + "name": "setVolume", + "description": "set volume" + }, + { + "name": "setMaxVolume", + "description": "set max volume for the current device" + }, + { + "name": "changeVolume", + "description": "change volume plus or minus a specified percentage" + }, + { + "name": "searchTracks", + "description": "this action is only used when the user asks for a search as in 'search', 'find', 'look for'" + }, + { + "name": "searchForPlaylists", + "description": "this action is used when the user asks to search for public playlists that match a query string like 'search playlist bach hilary hahn'; it is not used to get a specific playlist by name (use GetPlaylistAction for that); it is not used to search for tracks (use SearchTracksAction for that)" + }, + { + "name": "listPlaylists", + "description": "list all playlists" + }, + { + "name": "getPlaylist", + "description": "get playlist by name" + }, + { + "name": "getFromCurrentPlaylistList", + "description": "Get From Current Playlist List" + }, + { + "name": "getAlbum", + "description": "get currently playing album" + }, + { + "name": "getFavorites", + "description": "result of this action is an entity of type 'track-list' with the user's favorites" + }, + { + "name": "createPlaylist", + "description": "create a new playlist, optionally with a list of songs specified by title and artist" + }, + { + "name": "deletePlaylist", + "description": "delete a playlist" + }, + { + "name": "addCurrentTrackToPlaylist", + "description": "add the currently playing track to a playlist" + }, + { + "name": "addToPlaylistFromCurrentTrackList", + "description": "add to the named playlist one or more tracks starting at index 'trackNumber' in the current track list" + }, + { + "name": "addSongsToPlaylist", + "description": "add songs to a playlist by specifying track names and optional artists" + }, + { + "name": "getQueue", + "description": "set the current track list to the queue of upcoming tracks" + }, + { + "name": "playPlaylist", + "description": "play the named play list" + } + ] + } + ] + }, + { + "name": "playerLocal", + "emoji": "🎵", + "description": "Agent to play local music files", + "subSchemas": [ + { + "schemaName": "playerLocal", + "description": "Local Music Player agent that lets you play and control local audio files.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/playerLocal/src/agent/localPlayerSchema.ts", + "actions": [ + { + "name": "playFile", + "description": "Play a specific audio file by path or name" + }, + { + "name": "playFolder", + "description": "Play all audio files in a folder" + }, + { + "name": "playFromQueue", + "description": "Play a specific track from the current queue by index" + }, + { + "name": "status", + "description": "Show now playing status including track information and playback state" + }, + { + "name": "pause", + "description": "Pause playback" + }, + { + "name": "resume", + "description": "Resume playback" + }, + { + "name": "stop", + "description": "Stop playback completely" + }, + { + "name": "next", + "description": "Skip to next track" + }, + { + "name": "previous", + "description": "Go to previous track" + }, + { + "name": "shuffle", + "description": "Turn shuffle on or off" + }, + { + "name": "repeat", + "description": "Set repeat mode" + }, + { + "name": "setVolume", + "description": "Set volume to a specific level (0-100)" + }, + { + "name": "changeVolume", + "description": "Change volume by a relative amount" + }, + { + "name": "mute", + "description": "Mute or unmute audio" + }, + { + "name": "listFiles", + "description": "List audio files in the music folder or a specified folder" + }, + { + "name": "searchFiles", + "description": "Search for audio files by name" + }, + { + "name": "addToQueue", + "description": "Add a file or files to the playback queue" + }, + { + "name": "clearQueue", + "description": "Clear the playback queue" + }, + { + "name": "showQueue", + "description": "Show the current playback queue" + }, + { + "name": "setMusicFolder", + "description": "Set the default music folder path" + }, + { + "name": "showMusicFolder", + "description": "Show the current music folder path" + } + ] + } + ] + }, + { + "name": "video", + "emoji": "📹", + "description": "Agent to create AI videos", + "subSchemas": [ + { + "schemaName": "video", + "description": "Video agent that creates videos using AI text to video modes.", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/video/src/videoActionSchema.ts", + "actions": [ + { + "name": "createVideoAction", + "description": "creates a video based on the supplied description" + } + ] + } + ] + }, + { + "name": "weather", + "emoji": "⛅", + "description": "Agent to get weather information including current conditions, forecasts, and alerts", + "subSchemas": [ + { + "schemaName": "weather", + "description": "Weather agent with actions to get current conditions, forecasts, and alerts", + "schemaFilePath": "/home/curtism/src/TypeAgent/ts/packages/agents/weather/src/weatherSchema.ts", + "actions": [ + { + "name": "getCurrentConditions", + "description": "Get Current Conditions" + }, + { + "name": "getForecast", + "description": "Get Forecast" + }, + { + "name": "getAlerts", + "description": "Get Alerts" + } + ] + } + ] + } +]