@oyasmi/pipiclaw 0.8.2 → 0.8.3
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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface RuntimePlaybookMetadata {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
/** Load the small always-on catalog; playbook bodies remain on disk until the agent reads one. */
|
|
8
|
+
export declare function loadRuntimePlaybookCatalog(directory?: string): RuntimePlaybookMetadata[];
|
|
9
|
+
export declare function renderRuntimePlaybookIndex(directory?: string): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import { PLAYBOOKS_DIR } from "../paths.js";
|
|
4
|
+
function parseFrontmatter(content, filename) {
|
|
5
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(content);
|
|
6
|
+
if (!match)
|
|
7
|
+
throw new Error(`Runtime playbook ${filename} has no YAML frontmatter.`);
|
|
8
|
+
const fields = new Map();
|
|
9
|
+
for (const line of match[1]?.split(/\r?\n/) ?? []) {
|
|
10
|
+
const separator = line.indexOf(":");
|
|
11
|
+
if (separator < 0)
|
|
12
|
+
continue;
|
|
13
|
+
const key = line.slice(0, separator).trim();
|
|
14
|
+
let value = line.slice(separator + 1).trim();
|
|
15
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
16
|
+
value = value.slice(1, -1);
|
|
17
|
+
}
|
|
18
|
+
fields.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
const name = fields.get("name")?.trim();
|
|
21
|
+
const description = fields.get("description")?.trim();
|
|
22
|
+
if (!name || !description) {
|
|
23
|
+
throw new Error(`Runtime playbook ${filename} requires non-empty name and description metadata.`);
|
|
24
|
+
}
|
|
25
|
+
if (`${name}.md` !== filename) {
|
|
26
|
+
throw new Error(`Runtime playbook ${filename} metadata name must be "${basename(filename, ".md")}".`);
|
|
27
|
+
}
|
|
28
|
+
return { name, description };
|
|
29
|
+
}
|
|
30
|
+
/** Load the small always-on catalog; playbook bodies remain on disk until the agent reads one. */
|
|
31
|
+
export function loadRuntimePlaybookCatalog(directory = PLAYBOOKS_DIR) {
|
|
32
|
+
return readdirSync(directory)
|
|
33
|
+
.filter((filename) => filename.endsWith(".md"))
|
|
34
|
+
.sort()
|
|
35
|
+
.map((filename) => {
|
|
36
|
+
const path = join(directory, filename);
|
|
37
|
+
return { ...parseFrontmatter(readFileSync(path, "utf-8"), filename), filename, path };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function renderRuntimePlaybookIndex(directory = PLAYBOOKS_DIR) {
|
|
41
|
+
return loadRuntimePlaybookCatalog(directory)
|
|
42
|
+
.map((playbook) => `- ${playbook.filename} — ${playbook.description}`)
|
|
43
|
+
.join("\n");
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oyasmi/pipiclaw",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true }); require('node:fs').rmSync('coverage', { recursive: true, force: true });\"",
|
|
25
|
-
"build": "tsc -p tsconfig.build.json && node -e \"const fs = require('node:fs'); const src = 'src/playbooks', dst = 'dist/playbooks'; fs.
|
|
25
|
+
"build": "tsc -p tsconfig.build.json && node -e \"const fs = require('node:fs'); const src = 'src/playbooks', dst = 'dist/playbooks'; fs.mkdirSync(dst, { recursive: true }); for (const f of fs.readdirSync(src)) if (f.endsWith('.md')) fs.copyFileSync(src + '/' + f, dst + '/' + f); fs.chmodSync('dist/main.js', 0o755)\"",
|
|
26
26
|
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
27
27
|
"lint": "biome check .",
|
|
28
28
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|