@archmax-ai/harness 0.6.0 → 0.6.1
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.
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export declare const ENGINES: {
|
|
2
|
+
yaml: (input: string) => object;
|
|
3
|
+
js: {
|
|
4
|
+
parse: () => never;
|
|
5
|
+
stringify: () => never;
|
|
6
|
+
};
|
|
7
|
+
javascript: {
|
|
8
|
+
parse: () => never;
|
|
9
|
+
stringify: () => never;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
1
12
|
export interface ParsedFrontmatter {
|
|
2
13
|
/** Parsed YAML frontmatter block (whatever shape the caller expects). */
|
|
3
14
|
data: unknown;
|
package/dist/core/frontmatter.js
CHANGED
|
@@ -7,9 +7,33 @@ import { parse as parseYaml } from "yaml";
|
|
|
7
7
|
* block over with CRLF line endings intact, and a trailing `\r` would otherwise
|
|
8
8
|
* end up inside parsed string values, so normalize before parsing.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const yamlEngine = (input) => (parseYaml(input.replace(/\r(?=\n|$)/g, "")) ?? {});
|
|
11
|
+
/**
|
|
12
|
+
* gray-matter picks a parser from the language tag on the opening fence, so
|
|
13
|
+
* `---js` would hand the block to its bundled `javascript` engine, which runs
|
|
14
|
+
* the block through `eval` in the host process. We parse only YAML, so refuse
|
|
15
|
+
* any fence that names a language, and point the `js`/`javascript` engines at a
|
|
16
|
+
* thrower in case a tag ever reaches gray-matter.
|
|
17
|
+
*/
|
|
18
|
+
const throwEngine = {
|
|
19
|
+
parse: () => {
|
|
20
|
+
throw new Error("frontmatter: only a plain `---` YAML fence is supported");
|
|
21
|
+
},
|
|
22
|
+
stringify: () => {
|
|
23
|
+
throw new Error("frontmatter: only a plain `---` YAML fence is supported");
|
|
24
|
+
},
|
|
12
25
|
};
|
|
26
|
+
export const ENGINES = { yaml: yamlEngine, js: throwEngine, javascript: throwEngine };
|
|
27
|
+
/**
|
|
28
|
+
* Whether the opening `---` fence carries a language tag (e.g. `---js` or
|
|
29
|
+
* `--- javascript`). `matter.test` has already confirmed the input opens with
|
|
30
|
+
* `---`, so the tag is whatever follows on that first line.
|
|
31
|
+
*/
|
|
32
|
+
function hasLanguageTag(raw) {
|
|
33
|
+
const newline = raw.search(/\r?\n/);
|
|
34
|
+
const firstLine = newline === -1 ? raw : raw.slice(0, newline);
|
|
35
|
+
return firstLine.replace(/^-+/, "").trim().length > 0;
|
|
36
|
+
}
|
|
13
37
|
/**
|
|
14
38
|
* Parse a `---`-delimited YAML frontmatter block followed by a Markdown body,
|
|
15
39
|
* the convention shared by `SUBAGENT.md` and `WORKFLOW.md`. Returns `null` when
|
|
@@ -21,8 +45,10 @@ const YAML_ENGINE = {
|
|
|
21
45
|
export function parseFrontmatter(raw) {
|
|
22
46
|
if (!matter.test(raw))
|
|
23
47
|
return null;
|
|
48
|
+
if (hasLanguageTag(raw))
|
|
49
|
+
return null;
|
|
24
50
|
try {
|
|
25
|
-
const parsed = matter(raw, { engines:
|
|
51
|
+
const parsed = matter(raw, { engines: ENGINES, language: "yaml" });
|
|
26
52
|
return { data: parsed.data, body: parsed.content };
|
|
27
53
|
}
|
|
28
54
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/core/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/core/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C;;;;;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O,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archmax-ai/harness",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agents can't reliably follow a process. archmax harness makes them: a governed layer over LangChain Deep Agents that enforces a declarative workflow state machine on every step.",
|
|
6
6
|
"keywords": [
|