read-playbook.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
11 days 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
4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
11 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b
fix(7C-L1b): route hosted delegation proposals through cani…
Human
minor
⚠
30 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91
fix: repair endpoint now sets has_active_subscription when …
Human
minor
⚠
50 days ago
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
82 days ago