read-playbook.mjs
58 lines 1.8 KB
Raw
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor ⚠ breaking 1 day ago
1 /**
2 * Skill: read-playbook
3 *
4 * Returns a specific playbook (e.g. `influencer-outreach`, `agentic-marketing-framework`)
5 * for one of the three projects. Used by outreach + clip-factory + research agents
6 * that need step-by-step playbooks, not just voice/positioning.
7 *
8 * Vault path convention:
9 * vault/projects/<project>/playbooks/<slug>.md
10 *
11 * @param {ReturnType<import('./hub-client.mjs').createHubClient>} hub
12 * @param {{ project: 'born-free' | 'store-free' | 'knowtation', slug: string }} args
13 * @returns {Promise<{ path: string, frontmatter: object, body: string }>}
14 */
15 import { assertProject } from './hub-client.mjs';
16
17 export async function readPlaybook(hub, args) {
18 const project = assertProject(args.project);
19 const slug = sanitizeSlug(args.slug);
20 const path = `projects/${project}/playbooks/${slug}.md`;
21
22 let note;
23 try {
24 note = await hub.getNote(path);
25 } catch (e) {
26 if (e.status === 404) {
27 throw Object.assign(
28 new Error(
29 `playbook_missing: vault/${path} does not exist on the Hub. ` +
30 `Create it before running agents that need this playbook.`
31 ),
32 { code: 'PLAYBOOK_MISSING', project, path, slug, cause: e }
33 );
34 }
35 throw e;
36 }
37
38 return {
39 path: note.path ?? path,
40 frontmatter: note.frontmatter ?? {},
41 body: typeof note.body === 'string' ? note.body : '',
42 };
43 }
44
45 function sanitizeSlug(slug) {
46 if (typeof slug !== 'string' || !slug.trim()) {
47 throw Object.assign(new Error('invalid_slug: slug must be a non-empty string'), {
48 code: 'INVALID_SLUG',
49 });
50 }
51 if (!/^[a-z0-9][a-z0-9_-]*$/i.test(slug)) {
52 throw Object.assign(
53 new Error(`invalid_slug: '${slug}' contains illegal chars; allowed: a-z, 0-9, -, _`),
54 { code: 'INVALID_SLUG', slug }
55 );
56 }
57 return slug;
58 }
File History 2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor 1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6 docs: accept Calendar Events v0 spec with Phase 0 security … Human 1 day ago