43
return new ParsedPromptFile(uri, header, body);
44
}
46
>
47
>
48
>
export class ParsedPromptFile {
49
>
constructor(public readonly uri: URI, public readonly header?: PromptHeader, public readonly body?: PromptBody) {
50
}
52
>
53
>
export interface ParseError {
54
>
readonly message: string;
55
>
readonly range: Range;
56
>
readonly code: string;
57
>
}
58
>
59
>
interface ParsedHeader {
60
>
readonly node: YamlNode | undefined;
61
>
readonly errors: ParseError[];
62
>
readonly attributes: IHeaderAttribute[];
63
>
}
64
>
65
>
export namespace PromptHeaderAttributes {
66
>
export const name = 'name';
67
>
export const description = 'description';
68
>
export const agent = 'agent';
69
>
export const mode = 'mode';
70
>
export const model = 'model';
71
>
export const applyTo = 'applyTo';
72
>
export const paths = 'paths';
73
>
export const tools = 'tools';
74
>
export const handOffs = 'handoffs';
75
>
export const advancedOptions = 'advancedOptions';
76
>
export const argumentHint = 'argument-hint';
77
>
export const excludeAgent = 'excludeAgent';
78
>
export const target = 'target';
79
>
export const infer = 'infer';
80
>
export const license = 'license';
81
>
export const compatibility = 'compatibility';
82
>
export const metadata = 'metadata';
83
>
export const agents = 'agents';
84
>
export const userInvocable = 'user-invocable';
85
>
export const disableModelInvocation = 'disable-model-invocation';
86
>
export const hooks = 'hooks';
87
>
export const context = 'context';
88
>
}
89
>
90
>
export class PromptHeader {
91
>
private _parsed: ParsedHeader | undefined;
92
>
93
>
constructor(public readonly range: Range, public readonly uri: URI, private readonly linesWithEOL: string[]) {
94
}
96
>
private get _parsedHeader(): ParsedHeader {
97
if (this._parsed === undefined) {
98
const yamlErrors: YamlParseError[] = [];