Skip to content

Commit

Permalink
Update api version
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Jan 19, 2025
1 parent b90ffa3 commit 3817301
Show file tree
Hide file tree
Showing 21 changed files with 332 additions and 34 deletions.
7 changes: 6 additions & 1 deletion cursorless-talon-dev/src/cursorless_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@ def cursorless_record_silent_test():
def private_cursorless_make_snippet_test(target: Any):
"""Test generating a snippet"""
actions.user.private_cursorless_command_no_wait(
{"name": "generateSnippet", "snippetName": "testSnippet", "target": target}
{
"name": "generateSnippet",
"dirPath": "",
"snippetName": "testSnippet",
"target": target,
}
)
2 changes: 1 addition & 1 deletion cursorless-talon/src/versions.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
COMMAND_VERSION = 7
COMMAND_VERSION = 8
3 changes: 2 additions & 1 deletion data/fixtures/recorded/actions/snippets/snipMakeFunk.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
languageId: typescript
command:
version: 6
version: 8
spokenForm: snippet make funk
action:
name: generateSnippet
dirPath: ""
snippetName: snippetTest1
target:
type: primitive
Expand Down
3 changes: 2 additions & 1 deletion data/fixtures/recorded/actions/snippets/snipMakeState.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
languageId: typescript
command:
version: 6
version: 8
spokenForm: snippet make state
action:
name: generateSnippet
dirPath: ""
snippetName: snippetTest1
target:
type: primitive
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
languageId: plaintext
command:
version: 6
version: 8
spokenForm: test snippet make line
action:
name: generateSnippet
dirPath: ""
snippetName: testSnippet
target:
type: primitive
Expand Down
9 changes: 5 additions & 4 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ export * from "./ide/types/Clipboard";
export * from "./ide/types/CommandHistoryStorage";
export * from "./ide/types/CommandId";
export * from "./ide/types/Configuration";
export * from "./ide/types/events.types";
export * from "./ide/types/Events";
export * from "./ide/types/events.types";
export * from "./ide/types/FileSystem.types";
export * from "./ide/types/FlashDescriptor";
export * from "./ide/types/Hats";
export * from "./ide/types/HatStability";
export * from "./ide/types/hatStyles.types";
export * from "./ide/types/ide.types";
export * from "./ide/types/KeyValueStore";
export * from "./ide/types/Messages";
export * from "./ide/types/Paths";
export * from "./ide/types/QuickPickOptions";
export * from "./ide/types/RawTreeSitterQueryProvider";
export * from "./ide/types/KeyValueStore";
export * from "./ide/types/TutorialContentProvider";
export * from "./ide/util/messages";
export * from "./scopeSupportFacets/languageScopeSupport";
Expand All @@ -46,15 +46,16 @@ export * from "./testUtil/TestCaseSnapshot";
export * from "./testUtil/testConstants";
export * from "./types/command/ActionDescriptor";
export * from "./types/command/command.types";
export * from "./types/command/CommandV6.types";
export * from "./types/command/CommandV7.types";
export * from "./types/command/CommandV8.types";
export * from "./types/command/DestinationDescriptor.types";
export * from "./types/command/legacy/ActionCommandV5";
export * from "./types/command/legacy/CommandV0V1.types";
export * from "./types/command/legacy/CommandV2.types";
export * from "./types/command/legacy/CommandV3.types";
export * from "./types/command/legacy/CommandV4.types";
export * from "./types/command/legacy/CommandV5.types";
export * from "./types/command/legacy/CommandV6.types";
export * from "./types/command/legacy/CommandV7.types";
export * from "./types/command/legacy/PartialTargetDescriptorV3.types";
export * from "./types/command/legacy/PartialTargetDescriptorV4.types";
export * from "./types/command/legacy/PartialTargetDescriptorV5.types";
Expand Down
9 changes: 6 additions & 3 deletions packages/common/src/testUtil/serializeTestFixture.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { TestCaseFixtureLegacy } from "../types/TestCaseFixture";
import type { ActionDescriptor } from "../types/command/ActionDescriptor";
import type { CommandV6 } from "../types/command/CommandV6.types";
import type { CommandV7 } from "../types/command/CommandV7.types";
import type { CommandV6 } from "../types/command/legacy/CommandV6.types";
import type { CommandV7 } from "../types/command/legacy/CommandV7.types";
import type { Command } from "../types/command/command.types";
import type { CommandV5 } from "../types/command/legacy/CommandV5.types";
import type { EnforceUndefined } from "../util/typeUtils";
import { serialize } from "./serialize";
import type { ActionDescriptorV6 } from "../types/command/legacy/ActionDescriptorV6";

function reorderFields(
fixture: TestCaseFixtureLegacy,
Expand Down Expand Up @@ -41,6 +42,8 @@ function reorderCommandFields(command: Command): Command {
return reorderCommandV6Fields(command);
case 7:
return reorderCommandV7Fields(command);
case 8:
return command;
}
}

Expand Down Expand Up @@ -81,7 +84,7 @@ function reorderCommandV7Fields(
};
}

function reorderActionFields(action: ActionDescriptor): ActionDescriptor {
function reorderActionFields(action: ActionDescriptorV6): ActionDescriptor {
const { name, ...rest } = action;
return {
name,
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/types/command/ActionDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export interface PasteActionDescriptor {

export interface GenerateSnippetActionDescriptor {
name: "generateSnippet";
dirPath?: string;
dirPath: string;
snippetName?: string;
target: PartialTargetDescriptor;
}
Expand Down
27 changes: 27 additions & 0 deletions packages/common/src/types/command/CommandV8.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { ActionDescriptor } from "./ActionDescriptor";

export interface CommandV8 {
/**
* The version number of the command API
*/
version: 8;

/**
* The spoken form of the command if issued from a voice command system
*/
spokenForm?: string;

/**
* If the command is issued from a voice command system, this boolean indicates
* whether we should use the pre phrase snapshot. Only set this to true if the
* voice command system issues a pre phrase signal at the start of every
* phrase.
*/
usePrePhraseSnapshot: boolean;

/**
* The action to perform. This field contains everything necessary to actually
* perform the action. The other fields are just metadata.
*/
action: ActionDescriptor;
}
10 changes: 6 additions & 4 deletions packages/common/src/types/command/command.types.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import type { ActionDescriptor } from "./ActionDescriptor";
import type { CommandV6 } from "./CommandV6.types";
import type { CommandV7 } from "./CommandV7.types";
import type { CommandV8 } from "./CommandV8.types";
import type { Modifier } from "./PartialTargetDescriptor.types";
import type { CommandV0, CommandV1 } from "./legacy/CommandV0V1.types";
import type { CommandV2 } from "./legacy/CommandV2.types";
import type { CommandV3 } from "./legacy/CommandV3.types";
import type { CommandV4 } from "./legacy/CommandV4.types";
import type { CommandV5 } from "./legacy/CommandV5.types";
import type { CommandV6 } from "./legacy/CommandV6.types";
import type { CommandV7 } from "./legacy/CommandV7.types";

export type CommandComplete = Required<Omit<CommandLatest, "spokenForm">> &
Pick<CommandLatest, "spokenForm">;
export const LATEST_VERSION = 7;
export const LATEST_VERSION = 8;

export type CommandLatest = Command & {
version: typeof LATEST_VERSION;
Expand All @@ -26,7 +27,8 @@ export type Command =
| CommandV4
| CommandV5
| CommandV6
| CommandV7;
| CommandV7
| CommandV8;

export type CommandResponse = { returnValue: unknown } | { fallback: Fallback };

Expand Down
Loading

0 comments on commit 3817301

Please sign in to comment.