@jean.gnc/harness-kit 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/agent/index.d.ts +3 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +2 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/schema.d.ts +20 -0
- package/dist/agent/schema.d.ts.map +1 -0
- package/dist/agent/schema.js +20 -0
- package/dist/agent/schema.js.map +1 -0
- package/dist/build.d.ts +9 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +18 -0
- package/dist/build.js.map +1 -0
- package/dist/check/index.d.ts +27 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +160 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/kinds.d.ts +11 -0
- package/dist/check/kinds.d.ts.map +1 -0
- package/dist/check/kinds.js +65 -0
- package/dist/check/kinds.js.map +1 -0
- package/dist/check/suggest.d.ts +2 -0
- package/dist/check/suggest.d.ts.map +1 -0
- package/dist/check/suggest.js +37 -0
- package/dist/check/suggest.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +146 -0
- package/dist/cli.js.map +1 -0
- package/dist/command/index.d.ts +3 -0
- package/dist/command/index.d.ts.map +1 -0
- package/dist/command/index.js +2 -0
- package/dist/command/index.js.map +1 -0
- package/dist/command/schema.d.ts +23 -0
- package/dist/command/schema.d.ts.map +1 -0
- package/dist/command/schema.js +21 -0
- package/dist/command/schema.js.map +1 -0
- package/dist/compile/discovery.d.ts +2 -0
- package/dist/compile/discovery.d.ts.map +1 -0
- package/dist/compile/discovery.js +4 -0
- package/dist/compile/discovery.js.map +1 -0
- package/dist/compile/emit.d.ts +15 -0
- package/dist/compile/emit.d.ts.map +1 -0
- package/dist/compile/emit.js +123 -0
- package/dist/compile/emit.js.map +1 -0
- package/dist/compile/frontmatter.d.ts +7 -0
- package/dist/compile/frontmatter.d.ts.map +1 -0
- package/dist/compile/frontmatter.js +44 -0
- package/dist/compile/frontmatter.js.map +1 -0
- package/dist/compile/index.d.ts +9 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +123 -0
- package/dist/compile/index.js.map +1 -0
- package/dist/compile/validators.d.ts +9 -0
- package/dist/compile/validators.d.ts.map +1 -0
- package/dist/compile/validators.js +112 -0
- package/dist/compile/validators.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/zod.d.ts +3 -0
- package/dist/errors/zod.d.ts.map +1 -0
- package/dist/errors/zod.js +4 -0
- package/dist/errors/zod.js.map +1 -0
- package/dist/fs.d.ts +2 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +11 -0
- package/dist/fs.js.map +1 -0
- package/dist/ids.d.ts +5 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +9 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/install/claude.d.ts +4 -0
- package/dist/install/claude.d.ts.map +1 -0
- package/dist/install/claude.js +37 -0
- package/dist/install/claude.js.map +1 -0
- package/dist/install/codex.d.ts +4 -0
- package/dist/install/codex.d.ts.map +1 -0
- package/dist/install/codex.js +29 -0
- package/dist/install/codex.js.map +1 -0
- package/dist/install/discovery.d.ts +21 -0
- package/dist/install/discovery.d.ts.map +1 -0
- package/dist/install/discovery.js +51 -0
- package/dist/install/discovery.js.map +1 -0
- package/dist/install/index.d.ts +28 -0
- package/dist/install/index.d.ts.map +1 -0
- package/dist/install/index.js +44 -0
- package/dist/install/index.js.map +1 -0
- package/dist/install/runner.d.ts +4 -0
- package/dist/install/runner.d.ts.map +1 -0
- package/dist/install/runner.js +15 -0
- package/dist/install/runner.js.map +1 -0
- package/dist/installed.d.ts +36 -0
- package/dist/installed.d.ts.map +1 -0
- package/dist/installed.js +155 -0
- package/dist/installed.js.map +1 -0
- package/dist/layout/index.d.ts +63 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +159 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/lint.d.ts +9 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +27 -0
- package/dist/lint.js.map +1 -0
- package/dist/marketplace/index.d.ts +3 -0
- package/dist/marketplace/index.d.ts.map +1 -0
- package/dist/marketplace/index.js +2 -0
- package/dist/marketplace/index.js.map +1 -0
- package/dist/marketplace/schema.d.ts +495 -0
- package/dist/marketplace/schema.d.ts.map +1 -0
- package/dist/marketplace/schema.js +92 -0
- package/dist/marketplace/schema.js.map +1 -0
- package/dist/parsing/frontmatter.d.ts +16 -0
- package/dist/parsing/frontmatter.d.ts.map +1 -0
- package/dist/parsing/frontmatter.js +45 -0
- package/dist/parsing/frontmatter.js.map +1 -0
- package/dist/parsing/index.d.ts +3 -0
- package/dist/parsing/index.d.ts.map +1 -0
- package/dist/parsing/index.js +2 -0
- package/dist/parsing/index.js.map +1 -0
- package/dist/placeholders/index.d.ts +5 -0
- package/dist/placeholders/index.d.ts.map +1 -0
- package/dist/placeholders/index.js +3 -0
- package/dist/placeholders/index.js.map +1 -0
- package/dist/placeholders/source-position.d.ts +6 -0
- package/dist/placeholders/source-position.d.ts.map +1 -0
- package/dist/placeholders/source-position.js +13 -0
- package/dist/placeholders/source-position.js.map +1 -0
- package/dist/placeholders/tokens.d.ts +26 -0
- package/dist/placeholders/tokens.d.ts.map +1 -0
- package/dist/placeholders/tokens.js +50 -0
- package/dist/placeholders/tokens.js.map +1 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +2 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/schema.d.ts +164 -0
- package/dist/plugin/schema.d.ts.map +1 -0
- package/dist/plugin/schema.js +61 -0
- package/dist/plugin/schema.js.map +1 -0
- package/dist/readme/index.d.ts +24 -0
- package/dist/readme/index.d.ts.map +1 -0
- package/dist/readme/index.js +119 -0
- package/dist/readme/index.js.map +1 -0
- package/dist/result.d.ts +10 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +7 -0
- package/dist/result.js.map +1 -0
- package/dist/skill/includes.d.ts +29 -0
- package/dist/skill/includes.d.ts.map +1 -0
- package/dist/skill/includes.js +81 -0
- package/dist/skill/includes.js.map +1 -0
- package/dist/skill/index.d.ts +8 -0
- package/dist/skill/index.d.ts.map +1 -0
- package/dist/skill/index.js +5 -0
- package/dist/skill/index.js.map +1 -0
- package/dist/skill/invariants.d.ts +3 -0
- package/dist/skill/invariants.d.ts.map +1 -0
- package/dist/skill/invariants.js +17 -0
- package/dist/skill/invariants.js.map +1 -0
- package/dist/skill/schema.d.ts +50 -0
- package/dist/skill/schema.d.ts.map +1 -0
- package/dist/skill/schema.js +36 -0
- package/dist/skill/schema.js.map +1 -0
- package/dist/skill/source.d.ts +48 -0
- package/dist/skill/source.d.ts.map +1 -0
- package/dist/skill/source.js +114 -0
- package/dist/skill/source.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/placeholders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5D,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/placeholders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAS5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-position.d.ts","sourceRoot":"","sources":["../../src/placeholders/source-position.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAWrE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function offsetToLineCol(text, offset) {
|
|
2
|
+
const clamped = Math.max(0, Math.min(offset, text.length));
|
|
3
|
+
let line = 1;
|
|
4
|
+
let lastLineStart = 0;
|
|
5
|
+
for (let i = 0; i < clamped; i += 1) {
|
|
6
|
+
if (text.charCodeAt(i) === 10 /* \n */) {
|
|
7
|
+
line += 1;
|
|
8
|
+
lastLineStart = i + 1;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return { line, column: clamped - lastLineStart + 1 };
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=source-position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-position.js","sourceRoot":"","sources":["../../src/placeholders/source-position.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAc;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,CAAC;YACV,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,CAAC,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface Placeholder {
|
|
2
|
+
readonly prefix: string;
|
|
3
|
+
readonly value: string | null;
|
|
4
|
+
readonly raw: string;
|
|
5
|
+
readonly start: number;
|
|
6
|
+
readonly end: number;
|
|
7
|
+
}
|
|
8
|
+
export type ValidatorResult = {
|
|
9
|
+
ok: true;
|
|
10
|
+
rendered: string;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
error: string;
|
|
14
|
+
};
|
|
15
|
+
export type Validator = (value: string | null) => ValidatorResult;
|
|
16
|
+
export type ValidatorRegistry = Readonly<Record<string, Validator>>;
|
|
17
|
+
export type SubstituteResult = {
|
|
18
|
+
ok: true;
|
|
19
|
+
rendered: string;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
errors: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function parsePlaceholders(body: string): Placeholder[];
|
|
25
|
+
export declare function substitute(body: string, registry: ValidatorRegistry): SubstituteResult;
|
|
26
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/placeholders/tokens.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5F,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,eAAe,CAAC;AAElE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAIhG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAgB7D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,gBAAgB,CA+BtF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const TOKEN_PATTERN = /\{\{([a-z][a-z0-9-]*)(?::([^{}\n]+?))?\}\}/g;
|
|
2
|
+
export function parsePlaceholders(body) {
|
|
3
|
+
const tokens = [];
|
|
4
|
+
for (const match of body.matchAll(TOKEN_PATTERN)) {
|
|
5
|
+
const raw = match[0];
|
|
6
|
+
const prefix = match[1];
|
|
7
|
+
if (prefix === undefined)
|
|
8
|
+
continue;
|
|
9
|
+
const start = match.index;
|
|
10
|
+
tokens.push({
|
|
11
|
+
prefix,
|
|
12
|
+
value: match[2] ?? null,
|
|
13
|
+
raw,
|
|
14
|
+
start,
|
|
15
|
+
end: start + raw.length,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return tokens;
|
|
19
|
+
}
|
|
20
|
+
export function substitute(body, registry) {
|
|
21
|
+
const tokens = parsePlaceholders(body);
|
|
22
|
+
const errors = [];
|
|
23
|
+
const knownPrefixes = Object.keys(registry).sort().join(", ");
|
|
24
|
+
let rendered = "";
|
|
25
|
+
let cursor = 0;
|
|
26
|
+
for (const token of tokens) {
|
|
27
|
+
rendered += body.slice(cursor, token.start);
|
|
28
|
+
const validator = registry[token.prefix];
|
|
29
|
+
if (!validator) {
|
|
30
|
+
errors.push(`unknown placeholder prefix "${token.prefix}" in ${token.raw} (valid: ${knownPrefixes})`);
|
|
31
|
+
rendered += token.raw;
|
|
32
|
+
cursor = token.end;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const result = validator(token.value);
|
|
36
|
+
if (!result.ok) {
|
|
37
|
+
errors.push(`${token.raw}: ${result.error}`);
|
|
38
|
+
rendered += token.raw;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
rendered += result.rendered;
|
|
42
|
+
}
|
|
43
|
+
cursor = token.end;
|
|
44
|
+
}
|
|
45
|
+
rendered += body.slice(cursor);
|
|
46
|
+
if (errors.length > 0)
|
|
47
|
+
return { ok: false, errors };
|
|
48
|
+
return { ok: true, rendered };
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/placeholders/tokens.ts"],"names":[],"mappings":"AAgBA,MAAM,aAAa,GAAG,6CAA6C,CAAC;AAEpE,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAA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,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YAC7C,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC;QAC9B,CAAC;QACD,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;IACrB,CAAC;IACD,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACpD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpG,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ContextEntrySchema: z.ZodObject<{
|
|
3
|
+
file: z.ZodString;
|
|
4
|
+
summary: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
file: string;
|
|
7
|
+
summary: string;
|
|
8
|
+
}, {
|
|
9
|
+
file: string;
|
|
10
|
+
summary: string;
|
|
11
|
+
}>;
|
|
12
|
+
export type ContextEntry = z.infer<typeof ContextEntrySchema>;
|
|
13
|
+
export declare const HookRequirementSchema: z.ZodEffects<z.ZodObject<{
|
|
14
|
+
event: z.ZodString;
|
|
15
|
+
skill: z.ZodOptional<z.ZodString>;
|
|
16
|
+
command: z.ZodOptional<z.ZodString>;
|
|
17
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strict", z.ZodTypeAny, {
|
|
19
|
+
event: string;
|
|
20
|
+
skill?: string | undefined;
|
|
21
|
+
command?: string | undefined;
|
|
22
|
+
agent?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
event: string;
|
|
25
|
+
skill?: string | undefined;
|
|
26
|
+
command?: string | undefined;
|
|
27
|
+
agent?: string | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
event: string;
|
|
30
|
+
skill?: string | undefined;
|
|
31
|
+
command?: string | undefined;
|
|
32
|
+
agent?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
event: string;
|
|
35
|
+
skill?: string | undefined;
|
|
36
|
+
command?: string | undefined;
|
|
37
|
+
agent?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
export type HookRequirement = z.infer<typeof HookRequirementSchema>;
|
|
40
|
+
export declare const PluginSchema: z.ZodObject<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
version: z.ZodString;
|
|
43
|
+
description: z.ZodEffects<z.ZodString, string, string>;
|
|
44
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
email: z.ZodOptional<z.ZodString>;
|
|
47
|
+
url: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
name: string;
|
|
50
|
+
email?: string | undefined;
|
|
51
|
+
url?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
name: string;
|
|
54
|
+
email?: string | undefined;
|
|
55
|
+
url?: string | undefined;
|
|
56
|
+
}>>;
|
|
57
|
+
homepage: z.ZodOptional<z.ZodString>;
|
|
58
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
59
|
+
license: z.ZodOptional<z.ZodString>;
|
|
60
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
61
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
62
|
+
context: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
63
|
+
file: z.ZodString;
|
|
64
|
+
summary: z.ZodEffects<z.ZodString, string, string>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
file: string;
|
|
67
|
+
summary: string;
|
|
68
|
+
}, {
|
|
69
|
+
file: string;
|
|
70
|
+
summary: string;
|
|
71
|
+
}>, "many">>, {
|
|
72
|
+
file: string;
|
|
73
|
+
summary: string;
|
|
74
|
+
}[] | undefined, {
|
|
75
|
+
file: string;
|
|
76
|
+
summary: string;
|
|
77
|
+
}[] | undefined>;
|
|
78
|
+
commands: z.ZodOptional<z.ZodString>;
|
|
79
|
+
agents: z.ZodOptional<z.ZodString>;
|
|
80
|
+
hooks: z.ZodOptional<z.ZodString>;
|
|
81
|
+
hookRequires: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
82
|
+
event: z.ZodString;
|
|
83
|
+
skill: z.ZodOptional<z.ZodString>;
|
|
84
|
+
command: z.ZodOptional<z.ZodString>;
|
|
85
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, "strict", z.ZodTypeAny, {
|
|
87
|
+
event: string;
|
|
88
|
+
skill?: string | undefined;
|
|
89
|
+
command?: string | undefined;
|
|
90
|
+
agent?: string | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
event: string;
|
|
93
|
+
skill?: string | undefined;
|
|
94
|
+
command?: string | undefined;
|
|
95
|
+
agent?: string | undefined;
|
|
96
|
+
}>, {
|
|
97
|
+
event: string;
|
|
98
|
+
skill?: string | undefined;
|
|
99
|
+
command?: string | undefined;
|
|
100
|
+
agent?: string | undefined;
|
|
101
|
+
}, {
|
|
102
|
+
event: string;
|
|
103
|
+
skill?: string | undefined;
|
|
104
|
+
command?: string | undefined;
|
|
105
|
+
agent?: string | undefined;
|
|
106
|
+
}>, "many">>;
|
|
107
|
+
}, "strict", z.ZodTypeAny, {
|
|
108
|
+
name: string;
|
|
109
|
+
description: string;
|
|
110
|
+
version: string;
|
|
111
|
+
author?: {
|
|
112
|
+
name: string;
|
|
113
|
+
email?: string | undefined;
|
|
114
|
+
url?: string | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
homepage?: string | undefined;
|
|
117
|
+
repository?: string | undefined;
|
|
118
|
+
license?: string | undefined;
|
|
119
|
+
keywords?: string[] | undefined;
|
|
120
|
+
dependencies?: string[] | undefined;
|
|
121
|
+
context?: {
|
|
122
|
+
file: string;
|
|
123
|
+
summary: string;
|
|
124
|
+
}[] | undefined;
|
|
125
|
+
commands?: string | undefined;
|
|
126
|
+
agents?: string | undefined;
|
|
127
|
+
hooks?: string | undefined;
|
|
128
|
+
hookRequires?: {
|
|
129
|
+
event: string;
|
|
130
|
+
skill?: string | undefined;
|
|
131
|
+
command?: string | undefined;
|
|
132
|
+
agent?: string | undefined;
|
|
133
|
+
}[] | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
name: string;
|
|
136
|
+
description: string;
|
|
137
|
+
version: string;
|
|
138
|
+
author?: {
|
|
139
|
+
name: string;
|
|
140
|
+
email?: string | undefined;
|
|
141
|
+
url?: string | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
homepage?: string | undefined;
|
|
144
|
+
repository?: string | undefined;
|
|
145
|
+
license?: string | undefined;
|
|
146
|
+
keywords?: string[] | undefined;
|
|
147
|
+
dependencies?: string[] | undefined;
|
|
148
|
+
context?: {
|
|
149
|
+
file: string;
|
|
150
|
+
summary: string;
|
|
151
|
+
}[] | undefined;
|
|
152
|
+
commands?: string | undefined;
|
|
153
|
+
agents?: string | undefined;
|
|
154
|
+
hooks?: string | undefined;
|
|
155
|
+
hookRequires?: {
|
|
156
|
+
event: string;
|
|
157
|
+
skill?: string | undefined;
|
|
158
|
+
command?: string | undefined;
|
|
159
|
+
agent?: string | undefined;
|
|
160
|
+
}[] | undefined;
|
|
161
|
+
}>;
|
|
162
|
+
export type Plugin = z.infer<typeof PluginSchema>;
|
|
163
|
+
export declare function definePlugin(plugin: Plugin): Plugin;
|
|
164
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/plugin/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kBAAkB;;;;;;;;;EAM7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAyB9D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;EAShC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBd,CAAC;AAEZ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { FQ_ID, PLUGIN_ID } from "../ids.js";
|
|
3
|
+
export const ContextEntrySchema = z.object({
|
|
4
|
+
file: z.string().min(1).regex(/\.md$/, "file must be a .md path"),
|
|
5
|
+
summary: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.refine((s) => !s.includes("\n"), "summary cannot contain newlines"),
|
|
9
|
+
});
|
|
10
|
+
const AuthorSchema = z.object({
|
|
11
|
+
name: z.string().min(1),
|
|
12
|
+
email: z.string().min(1).optional(),
|
|
13
|
+
url: z.string().min(1).optional(),
|
|
14
|
+
});
|
|
15
|
+
const contextListSchema = z
|
|
16
|
+
.array(ContextEntrySchema)
|
|
17
|
+
.optional()
|
|
18
|
+
.refine((arr) => !arr || new Set(arr.map((e) => e.file)).size === arr.length, "context files must be unique");
|
|
19
|
+
const SLUG_REF = z.string().min(1).regex(FQ_ID, "must match <plugin>:<name> kebab-case");
|
|
20
|
+
const HookRequirementBase = z.object({
|
|
21
|
+
event: z.string().min(1),
|
|
22
|
+
skill: SLUG_REF.optional(),
|
|
23
|
+
command: SLUG_REF.optional(),
|
|
24
|
+
agent: SLUG_REF.optional(),
|
|
25
|
+
});
|
|
26
|
+
export const HookRequirementSchema = HookRequirementBase.strict().superRefine((value, ctx) => {
|
|
27
|
+
const slugs = [value.skill, value.command, value.agent].filter((s) => s !== undefined);
|
|
28
|
+
if (slugs.length !== 1) {
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: z.ZodIssueCode.custom,
|
|
31
|
+
message: "exactly one of skill | command | agent must be set",
|
|
32
|
+
path: [],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export const PluginSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
name: z.string().min(1).regex(PLUGIN_ID, "name must be lowercase kebab-case"),
|
|
39
|
+
version: z.string().min(1),
|
|
40
|
+
description: z
|
|
41
|
+
.string()
|
|
42
|
+
.min(1)
|
|
43
|
+
.max(1024)
|
|
44
|
+
.refine((s) => !s.includes("\n"), "description cannot contain newlines"),
|
|
45
|
+
author: AuthorSchema.optional(),
|
|
46
|
+
homepage: z.string().min(1).optional(),
|
|
47
|
+
repository: z.string().min(1).optional(),
|
|
48
|
+
license: z.string().min(1).optional(),
|
|
49
|
+
keywords: z.array(z.string().min(1)).optional(),
|
|
50
|
+
dependencies: z.array(z.string().min(1)).optional(),
|
|
51
|
+
context: contextListSchema,
|
|
52
|
+
commands: z.string().min(1).optional(),
|
|
53
|
+
agents: z.string().min(1).optional(),
|
|
54
|
+
hooks: z.string().min(1).optional(),
|
|
55
|
+
hookRequires: z.array(HookRequirementSchema).optional(),
|
|
56
|
+
})
|
|
57
|
+
.strict();
|
|
58
|
+
export function definePlugin(plugin) {
|
|
59
|
+
return PluginSchema.parse(plugin);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/plugin/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,yBAAyB,CAAC;IACjE,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,iCAAiC,CAAC;CACvE,CAAC,CAAC;AAIH,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,MAA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M,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnD,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACtC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE;CACxD,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface LocalIds {
|
|
2
|
+
readonly skills: ReadonlySet<string>;
|
|
3
|
+
readonly commands: ReadonlySet<string>;
|
|
4
|
+
readonly agents: ReadonlySet<string>;
|
|
5
|
+
}
|
|
6
|
+
export interface OwningPlugin {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly dependencies: ReadonlySet<string>;
|
|
9
|
+
}
|
|
10
|
+
export type ReadmeViolationKind = "placeholder" | "link";
|
|
11
|
+
export interface ReadmeViolation {
|
|
12
|
+
readonly kind: ReadmeViolationKind;
|
|
13
|
+
readonly file: string;
|
|
14
|
+
readonly line: number;
|
|
15
|
+
readonly column: number;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ValidateReadmeOptions {
|
|
19
|
+
readonly filePath: string;
|
|
20
|
+
readonly localIds: LocalIds;
|
|
21
|
+
readonly owner?: OwningPlugin;
|
|
22
|
+
}
|
|
23
|
+
export declare function validateReadme(options: ValidateReadmeOptions): Promise<readonly ReadmeViolation[]>;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/readme/index.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,MAAM,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;CAC/B;AAMD,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAQrC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { pathExists } from "../fs.js";
|
|
4
|
+
import { FQ_ID } from "../ids.js";
|
|
5
|
+
import { offsetToLineCol, parsePlaceholders } from "../placeholders/index.js";
|
|
6
|
+
const SENTINEL = "<!-- harness-kit:validate -->";
|
|
7
|
+
const LINK_PATTERN = /!?\[[^\]]*\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g;
|
|
8
|
+
const ABSOLUTE_URL_PATTERN = /^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i;
|
|
9
|
+
export async function validateReadme(options) {
|
|
10
|
+
const text = await readFile(options.filePath, "utf8");
|
|
11
|
+
if (!text.includes(SENTINEL))
|
|
12
|
+
return [];
|
|
13
|
+
const violations = [];
|
|
14
|
+
for (const v of validatePlaceholders(text, options))
|
|
15
|
+
violations.push(v);
|
|
16
|
+
for (const v of await validateLinks(text, options.filePath))
|
|
17
|
+
violations.push(v);
|
|
18
|
+
return violations;
|
|
19
|
+
}
|
|
20
|
+
function validatePlaceholders(text, options) {
|
|
21
|
+
const violations = [];
|
|
22
|
+
for (const token of parsePlaceholders(text)) {
|
|
23
|
+
const message = placeholderViolation(token, options);
|
|
24
|
+
if (!message)
|
|
25
|
+
continue;
|
|
26
|
+
const { line, column } = offsetToLineCol(text, token.start);
|
|
27
|
+
violations.push({
|
|
28
|
+
kind: "placeholder",
|
|
29
|
+
file: options.filePath,
|
|
30
|
+
line,
|
|
31
|
+
column,
|
|
32
|
+
message: `${token.raw}: ${message}`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return violations;
|
|
36
|
+
}
|
|
37
|
+
function placeholderViolation(token, options) {
|
|
38
|
+
const owner = options.owner ?? null;
|
|
39
|
+
switch (token.prefix) {
|
|
40
|
+
case "skill":
|
|
41
|
+
return localIdViolation(token.value, "skill", options.localIds.skills, owner);
|
|
42
|
+
case "command":
|
|
43
|
+
return localIdViolation(token.value, "command", options.localIds.commands, owner);
|
|
44
|
+
case "agent":
|
|
45
|
+
return localIdViolation(token.value, "agent", options.localIds.agents, owner);
|
|
46
|
+
case "ext":
|
|
47
|
+
return formatViolation(token.value, "ext", "skill");
|
|
48
|
+
case "ext-command":
|
|
49
|
+
return formatViolation(token.value, "ext-command", "command");
|
|
50
|
+
case "ext-agent":
|
|
51
|
+
return formatViolation(token.value, "ext-agent", "agent");
|
|
52
|
+
default:
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function localIdViolation(value, kind, haystack, owner) {
|
|
57
|
+
if (value === null)
|
|
58
|
+
return `expected \`{{${kind}:<plugin>:<${kind}>}}\``;
|
|
59
|
+
if (!FQ_ID.test(value)) {
|
|
60
|
+
return `${kind} id "${value}" must match <plugin>:<${kind}> (kebab-case)`;
|
|
61
|
+
}
|
|
62
|
+
if (!haystack.has(value))
|
|
63
|
+
return `unknown ${kind} id "${value}" — not a local ${kind}`;
|
|
64
|
+
return crossPluginViolation(value, owner);
|
|
65
|
+
}
|
|
66
|
+
function formatViolation(value, prefix, noun) {
|
|
67
|
+
if (value === null)
|
|
68
|
+
return `expected \`{{${prefix}:<plugin>:<${noun}>}}\``;
|
|
69
|
+
if (!FQ_ID.test(value)) {
|
|
70
|
+
return `${prefix} id "${value}" must match <plugin>:<${noun}> (kebab-case)`;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function crossPluginViolation(id, owner) {
|
|
75
|
+
if (!owner)
|
|
76
|
+
return null;
|
|
77
|
+
const idx = id.indexOf(":");
|
|
78
|
+
if (idx === -1)
|
|
79
|
+
return null;
|
|
80
|
+
const otherPlugin = id.slice(0, idx);
|
|
81
|
+
if (otherPlugin === owner.name)
|
|
82
|
+
return null;
|
|
83
|
+
if (owner.dependencies.has(otherPlugin))
|
|
84
|
+
return null;
|
|
85
|
+
return `cross-plugin reference to "${otherPlugin}" requires "${otherPlugin}" in ${owner.name}'s dependencies`;
|
|
86
|
+
}
|
|
87
|
+
async function validateLinks(text, filePath) {
|
|
88
|
+
const dir = dirname(filePath);
|
|
89
|
+
const violations = [];
|
|
90
|
+
for (const match of text.matchAll(LINK_PATTERN)) {
|
|
91
|
+
const url = match[1];
|
|
92
|
+
if (!url)
|
|
93
|
+
continue;
|
|
94
|
+
if (ABSOLUTE_URL_PATTERN.test(url))
|
|
95
|
+
continue;
|
|
96
|
+
const pathPart = stripAnchor(url);
|
|
97
|
+
if (!pathPart)
|
|
98
|
+
continue;
|
|
99
|
+
const target = resolve(dir, pathPart);
|
|
100
|
+
if (await pathExists(target))
|
|
101
|
+
continue;
|
|
102
|
+
const { line, column } = offsetToLineCol(text, match.index);
|
|
103
|
+
violations.push({
|
|
104
|
+
kind: "link",
|
|
105
|
+
file: filePath,
|
|
106
|
+
line,
|
|
107
|
+
column,
|
|
108
|
+
message: `broken link: ${url}`,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return violations;
|
|
112
|
+
}
|
|
113
|
+
function stripAnchor(url) {
|
|
114
|
+
const hashIdx = url.indexOf("#");
|
|
115
|
+
if (hashIdx === -1)
|
|
116
|
+
return url;
|
|
117
|
+
return url.slice(0, hashIdx);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/readme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAoB,MAAM,0BAA0B,CAAC;AA6BhG,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AACjD,MAAM,YAAY,GAAG,2CAA2C,CAAC;AACjE,MAAM,oBAAoB,GAAG,iCAAiC,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA8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CAAC;YAAE,SAAS;QAC7C,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ;YAAE,SAAS;QACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,IAAI,MAAM,UAAU,CAAC,MAAM,CAAC;YAAE,SAAS;QACvC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5D,UAAU,CAAC,IAAI,CAAC;YACd,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI;YACJ,MAAM;YACN,OAAO,EAAE,gBAAgB,GAAG,EAAE;SAC/B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,OAAO,KAAK,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IAC/B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Result<T, E> = {
|
|
2
|
+
readonly ok: true;
|
|
3
|
+
readonly value: T;
|
|
4
|
+
} | {
|
|
5
|
+
readonly ok: false;
|
|
6
|
+
readonly error: E;
|
|
7
|
+
};
|
|
8
|
+
export declare function ok<T>(value: T): Result<T, never>;
|
|
9
|
+
export declare function err<E>(error: E): Result<never, E>;
|
|
10
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAE9C,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAEhD;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAEjD"}
|
package/dist/result.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,EAAE,CAAI,KAAQ;IAC5B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,GAAG,CAAI,KAAQ;IAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Result } from "../result.js";
|
|
2
|
+
export type IncludeError = {
|
|
3
|
+
readonly tag: "include-cycle";
|
|
4
|
+
readonly chain: readonly string[];
|
|
5
|
+
} | {
|
|
6
|
+
readonly tag: "include-missing";
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly from: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly tag: "include-escapes-skill";
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly skillDir: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly tag: "include-not-md";
|
|
15
|
+
readonly path: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly tag: "include-absolute";
|
|
18
|
+
readonly raw: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly tag: "include-empty";
|
|
21
|
+
readonly raw: string;
|
|
22
|
+
};
|
|
23
|
+
export interface ExpandedBody {
|
|
24
|
+
readonly body: string;
|
|
25
|
+
readonly resolvedIncludes: ReadonlySet<string>;
|
|
26
|
+
}
|
|
27
|
+
export declare function expandIncludes(body: string, fromFile: string, skillDir: string): Promise<Result<ExpandedBody, readonly IncludeError[]>>;
|
|
28
|
+
export declare function formatIncludeError(error: IncludeError): string;
|
|
29
|
+
//# sourceMappingURL=includes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"includes.d.ts","sourceRoot":"","sources":["../../src/skill/includes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACpE;IAAE,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjF;IAAE,QAAQ,CAAC,GAAG,EAAE,uBAAuB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3F;IAAE,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,MAAM,WAAW,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