Skip to main content

khive_pack_template/
lib.rs

1//! khive-pack-template — reference scaffold for new packs.
2//!
3//! See `docs/design.md` for the step-by-step guide to creating a new pack.
4
5pub mod handlers;
6mod pack;
7pub mod vocab;
8
9use khive_runtime::KhiveRuntime;
10use khive_types::{HandlerDef, Pack};
11
12pub(crate) use pack::TEMPLATE_HANDLERS;
13
14/// Canonical pack name. Must match the factory below and `PackFactory::name()`.
15pub(crate) const PACK_NAME: &str = "template";
16
17/// Template pack — replace with your pack's struct name and logic.
18pub struct TemplatePack {
19    runtime: KhiveRuntime,
20}
21
22impl Pack for TemplatePack {
23    const NAME: &'static str = PACK_NAME;
24    /// Declare note kinds this pack contributes. Must not overlap with other packs.
25    const NOTE_KINDS: &'static [&'static str] = vocab::NOTE_KINDS;
26    /// Declare entity kinds this pack contributes. Must not overlap with other packs.
27    const ENTITY_KINDS: &'static [&'static str] = vocab::ENTITY_KINDS;
28    /// Handler table. Each entry is one verb or subhandler the pack can dispatch.
29    const HANDLERS: &'static [HandlerDef] = &TEMPLATE_HANDLERS;
30    /// Pack dependencies. The named packs must be in the configured `KHIVE_PACKS` list.
31    const REQUIRES: &'static [&'static str] = &["kg"];
32}
33
34impl TemplatePack {
35    /// Constructs the template pack with a runtime handle.
36    pub fn new(runtime: KhiveRuntime) -> Self {
37        Self { runtime }
38    }
39    pub(crate) fn runtime(&self) -> &KhiveRuntime {
40        &self.runtime
41    }
42}