lean_ctx/core/
rule_artifacts.rs1use crate::core::config::CompressionLevel;
13use crate::core::rules_canonical::{self, Wrapper};
14
15pub const ARTIFACT_PATHS: &[&str] = &["LEAN-CTX.md", "rust/LEAN-CTX.md"];
18
19#[must_use]
25pub fn canonical_body() -> String {
26 format!(
27 "{}\n{}\n",
28 rules_canonical::PROJECT_LEAN_CTX_OWNED_MARKER,
29 rules_canonical::render(
30 false,
31 Wrapper::Longform,
32 CompressionLevel::Off,
33 &super::tool_profiles::ToolProfile::Power,
34 )
35 )
36}
37
38pub const SKILL_COPY_PATH: &str = "skills/lean-ctx/SKILL.md";
42
43pub const CLAUDE_MOD_COPIES: &[(&str, &str)] = &[
47 (
48 "integrations/claude-code-mod/hooks/register.ts",
49 crate::core::claude_host::REGISTER_TS,
50 ),
51 (
52 "integrations/claude-code-mod/hooks/hooks.json",
53 crate::core::claude_host::HOOKS_JSON,
54 ),
55 (
56 "integrations/claude-code-mod/.claude-plugin/plugin.json",
57 crate::core::claude_host::PLUGIN_JSON,
58 ),
59 (
60 "integrations/claude-code-mod/hooks/cockpit.tsx",
61 crate::core::claude_host::COCKPIT_TSX,
62 ),
63 (
64 "integrations/claude-code-mod/hooks/render.tsx",
65 crate::core::claude_host::RENDER_TSX,
66 ),
67 (
68 "integrations/claude-code-mod/types/index.d.ts",
69 crate::core::claude_host::TYPES_DTS,
70 ),
71 (
72 "integrations/claude-code-mod-jobs/hooks/register.ts",
73 crate::core::claude_host::JOBS_REGISTER_TS,
74 ),
75 (
76 "integrations/claude-code-mod-jobs/hooks/hooks.json",
77 crate::core::claude_host::JOBS_HOOKS_JSON,
78 ),
79 (
80 "integrations/claude-code-mod-jobs/.claude-plugin/plugin.json",
81 crate::core::claude_host::JOBS_PLUGIN_JSON,
82 ),
83];
84
85#[must_use]
89pub fn artifacts() -> Vec<(&'static str, String)> {
90 let body = canonical_body();
91 let mut arts: Vec<(&'static str, String)> =
92 ARTIFACT_PATHS.iter().map(|p| (*p, body.clone())).collect();
93 arts.push((
94 SKILL_COPY_PATH,
95 include_str!("../templates/SKILL.md").to_string(),
96 ));
97 arts.extend(
98 CLAUDE_MOD_COPIES
99 .iter()
100 .map(|(path, content)| (*path, (*content).to_string())),
101 );
102 arts
103}
104
105#[cfg(test)]
106mod tests {
107 use super::*;
108
109 #[test]
110 fn canonical_body_is_owned_versioned_and_current() {
111 let body = canonical_body();
112 assert!(body.starts_with(rules_canonical::PROJECT_LEAN_CTX_OWNED_MARKER));
113 assert!(body.contains(&format!(
114 "<!-- version: {} -->",
115 rules_canonical::RULES_VERSION
116 )));
117 assert!(body.contains("AGENT LOOP"));
119 assert!(body.contains("NAVIGATION PARADOX"));
120 assert!(body.ends_with('\n'));
121 }
122
123 #[test]
124 fn artifacts_cover_every_declared_path() {
125 let arts = artifacts();
126 for declared in ARTIFACT_PATHS.iter().chain([&SKILL_COPY_PATH]) {
127 assert!(
128 arts.iter().any(|(p, b)| p == declared && !b.is_empty()),
129 "{declared} missing from the generator output"
130 );
131 }
132 }
133}