Initial public release of Warp.
Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{js,json,yml}]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
@@ -0,0 +1,4 @@
|
||||
/.yarn/** linguist-vendored
|
||||
/.yarn/releases/* binary
|
||||
/.yarn/plugins/**/* binary
|
||||
/.pnp.* binary linguist-generated
|
||||
@@ -0,0 +1,13 @@
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# Swap the comments on the following lines if you wish to use zero-installs
|
||||
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
|
||||
# Documentation here: https://yarnpkg.com/features/zero-installs
|
||||
|
||||
!.yarn/cache
|
||||
# .pnp.*
|
||||
+7420
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
enableGlobalCache: false
|
||||
|
||||
nodeLinker: pnp
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "js",
|
||||
"version": "1.0.0",
|
||||
"description": "Warp Command Signatures",
|
||||
"main": "build/main.js",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"watch": "npm run build -- --watch",
|
||||
"clean": "rm -r build"
|
||||
},
|
||||
"author": "eng@warp.dev",
|
||||
"license": "",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"packageManager": "yarn@4.0.1"
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
let jackLastNameArgument: Argument = {
|
||||
name: "last-name",
|
||||
description: "Last name of the jack",
|
||||
values: [{ value: "Nichols" }, { value: "Nicholson" }],
|
||||
};
|
||||
let generatedArgument: Argument = {
|
||||
name: "generated-name",
|
||||
description: "Last name of the jack",
|
||||
values: [
|
||||
{
|
||||
generateSuggestionsFn: { script: "echo foobar" }
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
export function activate(warp: Warp) {
|
||||
warp.completions.registerCommandSignature({
|
||||
command: {
|
||||
name: "jack",
|
||||
alias: "j",
|
||||
description: "Jack's special command",
|
||||
subcommands: [
|
||||
{
|
||||
name: "create",
|
||||
description: "Create a jack :D.",
|
||||
arguments: jackLastNameArgument,
|
||||
},
|
||||
{
|
||||
name: "delete",
|
||||
description: "Delete a jack :(.",
|
||||
arguments: jackLastNameArgument,
|
||||
},
|
||||
{
|
||||
name: "update",
|
||||
description: "Update a jack",
|
||||
arguments: [
|
||||
jackLastNameArgument,
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "generate",
|
||||
description: "Generate a jack",
|
||||
arguments: [
|
||||
generatedArgument
|
||||
]
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
name: ["-s", "--special"],
|
||||
description: "Only operate on special jacks",
|
||||
arguments: {
|
||||
name: "level",
|
||||
description: "Level of specialness",
|
||||
values: [ { value: "1" }, { value: "2" }, { value: "3" }],
|
||||
}
|
||||
},
|
||||
{
|
||||
name: ["-c", "--cracker"],
|
||||
description: "Only operate on cracker jacks",
|
||||
},
|
||||
{
|
||||
name: "--eat",
|
||||
description: "Eat the jacks",
|
||||
requiredOptions: ["-c"],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
console.log("Successfully registered command signatures!");
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
// A union type to express common command token delimiters. This is used by various
|
||||
// fields throughout the schema.
|
||||
type Delimiter = ',' | ':' | ';' | '/' | ' ' | '::';
|
||||
|
||||
// Add a new wrapper struct around the root Command object, which scales to provide a
|
||||
// semantically correct place for whole-command level configuration properties, like
|
||||
// supported CLI versions, signature author(s), way to resolve conflicts among CLIs with
|
||||
// the same name.
|
||||
interface CommandSignature {
|
||||
command: Command;
|
||||
|
||||
// See More configurable options parsing below.
|
||||
parseOptions?: {
|
||||
optionArgumentDelimiters?: Delimiter[];
|
||||
optionsMustPrecedeArguments?: boolean;
|
||||
flagsArePosixNoncompliant?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
// This is passed to generateAdditionalSuggestions and custom generator implementations.
|
||||
// See Support dynamic commands and Custom generators below.
|
||||
interface CompletionContext {
|
||||
// Tokens in the input buffer.
|
||||
tokens: string[];
|
||||
|
||||
// Path to shell executable.
|
||||
shell: string;
|
||||
|
||||
// The session's current working directory.
|
||||
pwd: string;
|
||||
|
||||
// Way to execute arbitrary shell command.
|
||||
// Maybe restrict this to running in restricted mode? How do we ensure this is safe?
|
||||
executeShellCommand: (command: string) => Promise<{
|
||||
exitCode: number;
|
||||
success: boolean;
|
||||
output: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface Command {
|
||||
name: string;
|
||||
alias?: string | string[];
|
||||
|
||||
// See Configure suggestion accept behavior below.
|
||||
insertValue?: string;
|
||||
|
||||
description?: string;
|
||||
arguments?: Argument | Argument[];
|
||||
subcommands?: Command[];
|
||||
options?: Option[];
|
||||
priority?: number;
|
||||
|
||||
// See Support dynamic subcommands below.
|
||||
runtimeOptionsAndSubcommands?: (ctx: CompletionContext) => {
|
||||
options?: Option[];
|
||||
subcommands?: Command[];
|
||||
};
|
||||
}
|
||||
|
||||
interface Argument {
|
||||
name: string;
|
||||
description?: string;
|
||||
// This is renamed from ArgumentType to ArgumentValue, because that's semantically what
|
||||
// this array is -- a collection of suggestions for argument values.
|
||||
values?: ArgumentValue[];
|
||||
optional?: boolean;
|
||||
|
||||
// See Alias support below.
|
||||
expandAlias?: (ctx: CompletionContext) => Promise<string[]>;
|
||||
|
||||
// See Multi-suggestion arguments below.
|
||||
arity?: {
|
||||
limit?: number | undefined,
|
||||
delimiter?: Delimiter[],
|
||||
},
|
||||
}
|
||||
|
||||
declare enum TemplateType {
|
||||
Files = "TemplateType.Files",
|
||||
Folders = "TemplateType.Folders" ,
|
||||
FilesAndFolders = "TemplateType.FilesAndFolders",
|
||||
}
|
||||
|
||||
interface Template {
|
||||
typeName: TemplateType;
|
||||
filterName?: string;
|
||||
}
|
||||
|
||||
interface ShellCommandGeneratorFn {
|
||||
script: string | ((tokens: string[]) => string);
|
||||
|
||||
// If left unspecified, splits the output of script on newlines by default. Splitting
|
||||
// on newlines by default is new behavior (currently the postProcess function is
|
||||
// required).
|
||||
postProcess?: (script_output: string) => GeneratorResults;
|
||||
}
|
||||
|
||||
// See Custom generators below.
|
||||
type CustomGeneratorFn = (ctx: CompletionContext) => Promise<GeneratorResults>;
|
||||
type GeneratorFn = ShellCommandGeneratorFn | CustomGeneratorFn;
|
||||
|
||||
interface SuggestionGenerator {
|
||||
generateSuggestionsFn: GeneratorFn,
|
||||
|
||||
options?: {
|
||||
customTrigger?: string
|
||||
}
|
||||
}
|
||||
|
||||
interface GeneratorResults {
|
||||
suggestions: Suggestion[];
|
||||
is_ordered?: boolean;
|
||||
}
|
||||
|
||||
declare type RootCommand = {
|
||||
is_root_command: true
|
||||
};
|
||||
|
||||
type ArgumentValue = Suggestion
|
||||
| Template
|
||||
| SuggestionGenerator
|
||||
| RootCommand;
|
||||
|
||||
interface Suggestion {
|
||||
value: string;
|
||||
displayValue?: string;
|
||||
description?: string;
|
||||
priority?: number;
|
||||
icon?: IconType;
|
||||
isHidden?: boolean;
|
||||
|
||||
insertValue?: string;
|
||||
|
||||
dangerous?: boolean;
|
||||
deprecated?: boolean;
|
||||
}
|
||||
|
||||
declare enum IconType {
|
||||
File = "IconType.File",
|
||||
Folder = "IconType.Folder",
|
||||
GitBranch = "IconType.GitBranch",
|
||||
}
|
||||
|
||||
interface Option {
|
||||
name: string | string[];
|
||||
|
||||
insertValue?: string;
|
||||
description?: string;
|
||||
arguments?: Argument | Argument[];
|
||||
required?: boolean;
|
||||
priority?: number;
|
||||
|
||||
dangerous?: boolean;
|
||||
deprecated?: boolean;
|
||||
|
||||
requiredOptions?: string[];
|
||||
incompatibleOptions?: string[];
|
||||
repeatable?: boolean;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
interface Warp {
|
||||
completions: Completions,
|
||||
}
|
||||
|
||||
interface Completions {
|
||||
registerCommandSignature: (signatures: CommandSignature | CommandSignature[]) => void,
|
||||
}
|
||||
|
||||
declare namespace console {
|
||||
function log(message: string): void;
|
||||
function err(message: string): void;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"include": ["src/**/*"],
|
||||
"compilerOptions": {
|
||||
"target": "es2019",
|
||||
"lib": ["es2019"],
|
||||
"outDir": "build",
|
||||
"strict": true,
|
||||
"typeRoots": [
|
||||
"./src/types"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# This file is generated by running "yarn install" inside your project.
|
||||
# Manual changes might be lost - proceed with caution!
|
||||
|
||||
__metadata:
|
||||
version: 8
|
||||
cacheKey: 10c0
|
||||
|
||||
"js@workspace:.":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "js@workspace:."
|
||||
dependencies:
|
||||
typescript: "npm:^5.2.2"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"typescript@npm:^5.2.2":
|
||||
version: 5.2.2
|
||||
resolution: "typescript@npm:5.2.2"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 91ae3e6193d0ddb8656d4c418a033f0f75dec5e077ebbc2bd6d76439b93f35683936ee1bdc0e9cf94ec76863aa49f27159b5788219b50e1cd0cd6d110aa34b07
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@patch:typescript@npm%3A^5.2.2#optional!builtin<compat/typescript>":
|
||||
version: 5.2.2
|
||||
resolution: "typescript@patch:typescript@npm%3A5.2.2#optional!builtin<compat/typescript>::version=5.2.2&hash=f3b441"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 062c1cee1990e6b9419ce8a55162b8dc917eb87f807e4de0327dbc1c2fa4e5f61bc0dd4e034d38ff541d1ed0479b53bcee8e4de3a4075c51a1724eb6216cb6f5
|
||||
languageName: node
|
||||
linkType: hard
|
||||
Reference in New Issue
Block a user