nika 0.35.4

Semantic YAML workflow engine for AI tasks - DAG execution, MCP integration, multi-provider LLM support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
//! Agent and Skill Resolver
//!
//! Resolves external agent definitions and loads skill files at workflow start.
//! This module handles the loading and resolution of:
//! - External agent definition files (.agent.yaml)
//! - Package agent references (@agents/name)
//! - Package prompt references (@prompts/name)
//! - Package skill references (@skills/name)
//! - Skill files (.skill.md) for prompt augmentation
//!
//! # Example
//!
//! ```yaml
//! agents:
//!   researcher:
//!     from: "@agents/researcher"              # From package
//!   local:
//!     file: ./agents/local.agent.yaml        # Local file
//!   translator:
//!     system: "You are a translator..."      # Inline definition
//!
//! skills:
//!   seo: "@prompts/seo-meta"                  # From package
//!   local: ./skills/seo-writer.skill.md      # Local file
//! ```

use crate::ast::analyzed::AnalyzedWorkflow;
use crate::ast::{AgentDef, SkillDef, Workflow};
use crate::error::NikaError;
use crate::registry::resolver; // Package resolution
use crate::serde_yaml;
use rustc_hash::FxHashMap;
use std::path::{Path, PathBuf};
use tokio::fs;
use tracing::debug;

/// Resolved agents (all expanded to inline definitions)
pub type ResolvedAgents = FxHashMap<String, ResolvedAgent>;

/// Resolved skills (loaded file contents)
pub type ResolvedSkills = FxHashMap<String, String>;

/// Resolved agent definition (always inline after resolution)
#[derive(Debug, Clone)]
pub struct ResolvedAgent {
    /// System prompt for the agent
    pub system: String,
    /// Provider to use (claude, openai, etc.)
    pub provider: String,
    /// Model to use (optional)
    pub model: Option<String>,
    /// Maximum turns for the agent (optional)
    pub max_turns: Option<u32>,
    /// Temperature for generation (optional)
    pub temperature: Option<f32>,
    /// Source of the definition (for debugging)
    pub source: AgentSource,
}

/// Source of agent definition
#[derive(Debug, Clone, PartialEq)]
pub enum AgentSource {
    /// Defined inline in workflow
    Inline,
    /// Loaded from external file
    External(String),
}

/// Resolved assets container
#[derive(Debug, Default)]
pub struct ResolvedAssets {
    /// Resolved agent definitions (all inline)
    pub agents: ResolvedAgents,
    /// Loaded skill contents
    pub skills: ResolvedSkills,
}

impl ResolvedAssets {
    /// Create empty resolved assets
    pub fn new() -> Self {
        Self::default()
    }

    /// Get a resolved agent by name
    pub fn get_agent(&self, name: &str) -> Option<&ResolvedAgent> {
        self.agents.get(name)
    }

    /// Get a loaded skill content by name
    pub fn get_skill(&self, name: &str) -> Option<&str> {
        self.skills.get(name).map(String::as_str)
    }

    /// Check if assets are empty
    pub fn is_empty(&self) -> bool {
        self.agents.is_empty() && self.skills.is_empty()
    }
}

/// Resolve all agents and skills in a workflow.
///
/// This loads external agent files and skill contents, making them available
/// for task execution.
///
/// # Arguments
/// * `workflow` - The workflow to resolve assets for
/// * `base_path` - Base directory for resolving relative paths
///
/// # Errors
/// Returns `NikaError` if any file cannot be loaded or parsed.
pub async fn resolve_assets(
    workflow: &Workflow,
    base_path: &Path,
) -> Result<ResolvedAssets, NikaError> {
    let mut assets = ResolvedAssets::new();

    // Resolve agents
    if let Some(agents) = &workflow.agents {
        for (name, def) in agents {
            let resolved = resolve_agent(name, def, base_path).await?;
            assets.agents.insert(name.clone(), resolved);
        }
    }

    // Load skills
    if let Some(skills) = &workflow.skills {
        for (name, path) in skills {
            let content = load_skill(name, path, base_path).await?;
            assets.skills.insert(name.clone(), content);
        }
    }

    debug!(
        agents = assets.agents.len(),
        skills = assets.skills.len(),
        "Resolved workflow assets"
    );

    Ok(assets)
}

/// Resolve agents from an AnalyzedWorkflow.
///
/// AnalyzedWorkflow has `agents` but no `skills` (skills are resolved during
/// analysis and merged via include_loader). This function only resolves agents.
pub async fn resolve_assets_analyzed(
    workflow: &AnalyzedWorkflow,
    base_path: &Path,
) -> Result<ResolvedAssets, NikaError> {
    let mut assets = ResolvedAssets::new();

    // Resolve agents
    if let Some(agents) = &workflow.agents {
        for (name, def) in agents {
            let resolved = resolve_agent(name, def, base_path).await?;
            assets.agents.insert(name.clone(), resolved);
        }
    }

    // No skills on AnalyzedWorkflow — resolved during analysis

    debug!(
        agents = assets.agents.len(),
        "Resolved workflow assets (analyzed)"
    );

    Ok(assets)
}

/// Resolve a single agent definition.
///
/// For external definitions, loads and parses the file.
/// For inline definitions, converts directly.
async fn resolve_agent(
    name: &str,
    def: &AgentDef,
    base_path: &Path,
) -> Result<ResolvedAgent, NikaError> {
    match def {
        AgentDef::From { from } => {
            // Support package references (@agents/name)
            use crate::ast::loader::{load_definition, DefinitionKind};

            let source_path: PathBuf = if from.starts_with('@') {
                // Package reference - resolve via registry
                debug!(agent = name, package = from, "Resolving agent from package");

                let resolved = resolver::resolve_package_path(from).map_err(|e| {
                    NikaError::ContextLoadError {
                        alias: name.to_string(),
                        path: from.clone(),
                        reason: format!("Package not found: {}. Try: nika add {}", e, from),
                    }
                })?;

                // Agent packages should contain agent.md or agent.yaml
                let agent_md = resolved.path.join("agent.md");
                let agent_yaml = resolved.path.join("agent.yaml");

                if agent_md.exists() {
                    agent_md
                } else if agent_yaml.exists() {
                    agent_yaml
                } else {
                    return Err(NikaError::ContextLoadError {
                        alias: name.to_string(),
                        path: from.clone(),
                        reason: format!(
                            "Package {} exists but missing agent.md or agent.yaml at {}",
                            from,
                            resolved.path.display()
                        ),
                    });
                }
            } else {
                // Regular filesystem path
                base_path.join(from)
            };

            debug!(agent = name, path = ?source_path, "Loading agent via multi-format loader");

            let loaded = load_definition(&source_path, DefinitionKind::Agent)?;

            Ok(ResolvedAgent {
                system: loaded.system,
                provider: loaded.provider.unwrap_or_else(|| "claude".to_string()),
                model: loaded.model,
                max_turns: loaded.max_turns,
                temperature: loaded.temperature,
                source: AgentSource::External(from.clone()),
            })
        }
        AgentDef::External { file } => {
            let file_path = base_path.join(file);
            debug!(agent = name, path = ?file_path, "Loading external agent definition");

            let content =
                fs::read_to_string(&file_path)
                    .await
                    .map_err(|e| NikaError::ContextLoadError {
                        alias: name.to_string(),
                        path: file_path.display().to_string(),
                        reason: e.to_string(),
                    })?;

            // Parse the external file as an inline agent definition
            let parsed: ExternalAgentFile =
                serde_yaml::from_str(&content).map_err(|e| NikaError::ParseError {
                    details: format!("Failed to parse agent file '{}': {}", file, e),
                })?;

            Ok(ResolvedAgent {
                system: parsed.system,
                provider: parsed.provider,
                model: parsed.model,
                max_turns: parsed.max_turns,
                temperature: parsed.temperature,
                source: AgentSource::External(file.clone()),
            })
        }
        AgentDef::Inline {
            system,
            provider,
            model,
            max_turns,
            temperature,
            skills: _, // agent-level skills handled by skill injector
        } => Ok(ResolvedAgent {
            system: system.clone(),
            provider: provider.clone(),
            model: model.clone(),
            max_turns: *max_turns,
            temperature: *temperature,
            source: AgentSource::Inline,
        }),
    }
}

/// External agent file structure
#[derive(Debug, serde::Deserialize)]
struct ExternalAgentFile {
    /// System prompt for the agent
    system: String,
    /// Provider to use (claude, openai, etc.)
    #[serde(default = "default_provider")]
    provider: String,
    /// Model to use (optional)
    model: Option<String>,
    /// Maximum turns for the agent (optional)
    max_turns: Option<u32>,
    /// Temperature for generation (optional)
    temperature: Option<f32>,
}

fn default_provider() -> String {
    "claude".to_string()
}

/// Load a skill file content.
async fn load_skill(name: &str, path: &SkillDef, base_path: &Path) -> Result<String, NikaError> {
    // Support package references (@prompts/name, @skills/name)
    let file_path: PathBuf = if path.starts_with('@') {
        // Package reference - resolve via registry
        debug!(
            skill = name,
            package = path,
            "Resolving skill/prompt from package"
        );

        let resolved =
            resolver::resolve_package_path(path).map_err(|e| NikaError::ContextLoadError {
                alias: name.to_string(),
                path: path.to_string(),
                reason: format!("Package not found: {}. Try: nika add {}", e, path),
            })?;

        // Skill/Prompt packages should contain skill.md or prompt.md
        let skill_md = resolved.path.join("skill.md");
        let prompt_md = resolved.path.join("prompt.md");

        if skill_md.exists() {
            skill_md
        } else if prompt_md.exists() {
            prompt_md
        } else {
            return Err(NikaError::ContextLoadError {
                alias: name.to_string(),
                path: path.to_string(),
                reason: format!(
                    "Package {} exists but missing skill.md or prompt.md at {}",
                    path,
                    resolved.path.display()
                ),
            });
        }
    } else {
        // Regular filesystem path
        base_path.join(path)
    };

    debug!(skill = name, path = ?file_path, "Loading skill file");

    let content =
        fs::read_to_string(&file_path)
            .await
            .map_err(|e| NikaError::ContextLoadError {
                alias: name.to_string(),
                path: file_path.display().to_string(),
                reason: e.to_string(),
            })?;

    Ok(content)
}

#[cfg(test)]
mod tests {
    use super::*;
    use tempfile::tempdir;

    #[tokio::test]
    async fn test_resolve_assets_empty() {
        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: None,
            skills: None,
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let dir = tempdir().unwrap();
        let assets = resolve_assets(&workflow, dir.path()).await.unwrap();

        assert!(assets.is_empty());
        assert!(assets.agents.is_empty());
        assert!(assets.skills.is_empty());
    }

    #[tokio::test]
    async fn test_resolve_inline_agent() {
        let mut agents = FxHashMap::default();
        agents.insert(
            "test_agent".to_string(),
            AgentDef::Inline {
                system: "You are a test agent.".to_string(),
                provider: "openai".to_string(),
                model: Some("gpt-4o".to_string()),
                max_turns: Some(5),
                temperature: Some(0.7),
                skills: None, // agent-level skills
            },
        );

        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: Some(agents),
            skills: None,
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let dir = tempdir().unwrap();
        let assets = resolve_assets(&workflow, dir.path()).await.unwrap();

        assert_eq!(assets.agents.len(), 1);
        let agent = assets.get_agent("test_agent").unwrap();
        assert_eq!(agent.system, "You are a test agent.");
        assert_eq!(agent.provider, "openai");
        assert_eq!(agent.model, Some("gpt-4o".to_string()));
        assert_eq!(agent.max_turns, Some(5));
        assert_eq!(agent.temperature, Some(0.7));
        assert_eq!(agent.source, AgentSource::Inline);
    }

    #[tokio::test]
    async fn test_resolve_external_agent() {
        let dir = tempdir().unwrap();

        // Create external agent file
        let agent_content = r#"
system: "You are an external agent."
provider: mistral
model: mistral-large-latest
max_turns: 10
temperature: 0.5
"#;
        let agent_path = dir.path().join("agents");
        std::fs::create_dir_all(&agent_path).unwrap();
        std::fs::write(agent_path.join("external.agent.yaml"), agent_content).unwrap();

        let mut agents = FxHashMap::default();
        agents.insert(
            "ext_agent".to_string(),
            AgentDef::External {
                file: "agents/external.agent.yaml".to_string(),
            },
        );

        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: Some(agents),
            skills: None,
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let assets = resolve_assets(&workflow, dir.path()).await.unwrap();

        assert_eq!(assets.agents.len(), 1);
        let agent = assets.get_agent("ext_agent").unwrap();
        assert_eq!(agent.system, "You are an external agent.");
        assert_eq!(agent.provider, "mistral");
        assert_eq!(agent.model, Some("mistral-large-latest".to_string()));
        assert_eq!(agent.max_turns, Some(10));
        assert_eq!(agent.temperature, Some(0.5));
        assert_eq!(
            agent.source,
            AgentSource::External("agents/external.agent.yaml".to_string())
        );
    }

    #[tokio::test]
    async fn test_resolve_external_agent_missing_file() {
        let dir = tempdir().unwrap();

        let mut agents = FxHashMap::default();
        agents.insert(
            "missing".to_string(),
            AgentDef::External {
                file: "nonexistent.agent.yaml".to_string(),
            },
        );

        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: Some(agents),
            skills: None,
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let result = resolve_assets(&workflow, dir.path()).await;
        assert!(result.is_err());
        let err = result.unwrap_err();
        assert!(matches!(err, NikaError::ContextLoadError { .. }));
    }

    #[tokio::test]
    async fn test_load_skill() {
        let dir = tempdir().unwrap();

        // Create skill file
        let skill_content = r#"# SEO Writer Skill

You are an expert SEO content writer.

## Guidelines
- Use relevant keywords naturally
- Write engaging headlines
- Structure content for readability
"#;
        let skills_path = dir.path().join("skills");
        std::fs::create_dir_all(&skills_path).unwrap();
        std::fs::write(skills_path.join("seo.skill.md"), skill_content).unwrap();

        let mut skills = FxHashMap::default();
        skills.insert("seo".to_string(), "skills/seo.skill.md".to_string());

        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: None,
            skills: Some(skills),
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let assets = resolve_assets(&workflow, dir.path()).await.unwrap();

        assert_eq!(assets.skills.len(), 1);
        let skill = assets.get_skill("seo").unwrap();
        assert!(skill.contains("SEO Writer Skill"));
        assert!(skill.contains("expert SEO content writer"));
    }

    #[tokio::test]
    async fn test_load_skill_missing_file() {
        let dir = tempdir().unwrap();

        let mut skills = FxHashMap::default();
        skills.insert("missing".to_string(), "nonexistent.skill.md".to_string());

        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: None,
            skills: Some(skills),
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let result = resolve_assets(&workflow, dir.path()).await;
        assert!(result.is_err());
        let err = result.unwrap_err();
        assert!(matches!(err, NikaError::ContextLoadError { .. }));
    }

    #[tokio::test]
    async fn test_resolve_mixed_agents_and_skills() {
        let dir = tempdir().unwrap();

        // Create external agent file
        let agent_content = r#"
system: "You are a researcher."
"#;
        let agent_path = dir.path().join("agents");
        std::fs::create_dir_all(&agent_path).unwrap();
        std::fs::write(agent_path.join("researcher.agent.yaml"), agent_content).unwrap();

        // Create skill files
        let skill1_content = "# Skill 1\nFirst skill content.";
        let skill2_content = "# Skill 2\nSecond skill content.";
        let skills_path = dir.path().join("skills");
        std::fs::create_dir_all(&skills_path).unwrap();
        std::fs::write(skills_path.join("skill1.skill.md"), skill1_content).unwrap();
        std::fs::write(skills_path.join("skill2.skill.md"), skill2_content).unwrap();

        // Build workflow
        let mut agents = FxHashMap::default();
        agents.insert(
            "researcher".to_string(),
            AgentDef::External {
                file: "agents/researcher.agent.yaml".to_string(),
            },
        );
        agents.insert(
            "writer".to_string(),
            AgentDef::Inline {
                system: "You are a writer.".to_string(),
                provider: "claude".to_string(),
                model: None,
                max_turns: None,
                temperature: None,
                skills: None, // agent-level skills
            },
        );

        let mut skills = FxHashMap::default();
        skills.insert("skill1".to_string(), "skills/skill1.skill.md".to_string());
        skills.insert("skill2".to_string(), "skills/skill2.skill.md".to_string());

        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: Some(agents),
            skills: Some(skills),
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let assets = resolve_assets(&workflow, dir.path()).await.unwrap();

        // Check agents
        assert_eq!(assets.agents.len(), 2);
        let researcher = assets.get_agent("researcher").unwrap();
        assert_eq!(researcher.system, "You are a researcher.");
        assert_eq!(
            researcher.source,
            AgentSource::External("agents/researcher.agent.yaml".to_string())
        );

        let writer = assets.get_agent("writer").unwrap();
        assert_eq!(writer.system, "You are a writer.");
        assert_eq!(writer.source, AgentSource::Inline);

        // Check skills
        assert_eq!(assets.skills.len(), 2);
        assert!(assets
            .get_skill("skill1")
            .unwrap()
            .contains("First skill content"));
        assert!(assets
            .get_skill("skill2")
            .unwrap()
            .contains("Second skill content"));
    }

    #[tokio::test]
    async fn test_external_agent_with_defaults() {
        let dir = tempdir().unwrap();

        // Create minimal external agent file (only required field)
        let agent_content = r#"
system: "You are an agent with defaults."
"#;
        std::fs::write(dir.path().join("minimal.agent.yaml"), agent_content).unwrap();

        let mut agents = FxHashMap::default();
        agents.insert(
            "minimal".to_string(),
            AgentDef::External {
                file: "minimal.agent.yaml".to_string(),
            },
        );

        let workflow = crate::ast::Workflow {
            schema: "nika/workflow@0.12".to_string(),
            name: None,
            provider: "claude".to_string(),
            model: None,
            mcp: None,
            context: None,
            include: None,
            agents: Some(agents),
            skills: None,
            artifacts: None,
            log: None,
            inputs: None,
            tasks: vec![],
        };

        let assets = resolve_assets(&workflow, dir.path()).await.unwrap();

        let agent = assets.get_agent("minimal").unwrap();
        assert_eq!(agent.system, "You are an agent with defaults.");
        assert_eq!(agent.provider, "claude"); // default
        assert!(agent.model.is_none());
        assert!(agent.max_turns.is_none());
        assert!(agent.temperature.is_none());
    }

    #[test]
    fn test_resolved_agent_clone() {
        let agent = ResolvedAgent {
            system: "Test".to_string(),
            provider: "claude".to_string(),
            model: None,
            max_turns: None,
            temperature: None,
            source: AgentSource::Inline,
        };

        let cloned = agent.clone();
        assert_eq!(cloned.system, "Test");
    }

    #[test]
    fn test_resolved_assets_get_methods() {
        let mut assets = ResolvedAssets::new();

        assets.agents.insert(
            "test".to_string(),
            ResolvedAgent {
                system: "Test system".to_string(),
                provider: "claude".to_string(),
                model: None,
                max_turns: None,
                temperature: None,
                source: AgentSource::Inline,
            },
        );
        assets
            .skills
            .insert("skill".to_string(), "Skill content".to_string());

        assert!(assets.get_agent("test").is_some());
        assert!(assets.get_agent("nonexistent").is_none());
        assert_eq!(assets.get_skill("skill"), Some("Skill content"));
        assert!(assets.get_skill("nonexistent").is_none());
        assert!(!assets.is_empty());
    }
}