Module: KairosMcp
- Defined in:
- lib/kairos_mcp.rb,
lib/kairos_mcp/daemon.rb,
lib/kairos_mcp/kairos.rb,
lib/kairos_mcp/logger.rb,
lib/kairos_mcp/safety.rb,
lib/kairos_mcp/server.rb,
lib/kairos_mcp/version.rb,
lib/kairos_mcp/protocol.rb,
lib/kairos_mcp/skillset.rb,
lib/kairos_mcp/action_log.rb,
lib/kairos_mcp/capability.rb,
lib/kairos_mcp/daemon/wal.rb,
lib/kairos_mcp/skills_ast.rb,
lib/kairos_mcp/skills_dsl.rb,
lib/kairos_mcp/http_server.rb,
lib/kairos_mcp/initializer.rb,
lib/kairos_mcp/admin/router.rb,
lib/kairos_mcp/safe_evolver.rb,
lib/kairos_mcp/admin/helpers.rb,
lib/kairos_mcp/config_merger.rb,
lib/kairos_mcp/context_graph.rb,
lib/kairos_mcp/daemon/budget.rb,
lib/kairos_mcp/signal_handle.rb,
lib/kairos_mcp/skills_config.rb,
lib/kairos_mcp/skills_parser.rb,
lib/kairos_mcp/tool_registry.rb,
lib/kairos_mcp/daemon/chronos.rb,
lib/kairos_mcp/daemon/planner.rb,
lib/kairos_mcp/layer_registry.rb,
lib/kairos_mcp/lifecycle_hook.rb,
lib/kairos_mcp/meeting_router.rb,
lib/kairos_mcp/skill_contexts.rb,
lib/kairos_mcp/context_manager.rb,
lib/kairos_mcp/daemon/pid_lock.rb,
lib/kairos_mcp/daemon/task_dag.rb,
lib/kairos_mcp/storage/backend.rb,
lib/kairos_mcp/tools/base_tool.rb,
lib/kairos_mcp/version_manager.rb,
lib/kairos_mcp/auth/token_store.rb,
lib/kairos_mcp/daemon/canonical.rb,
lib/kairos_mcp/daemon/heartbeat.rb,
lib/kairos_mcp/daemon/pdf_build.rb,
lib/kairos_mcp/plugin_projector.rb,
lib/kairos_mcp/skillset_manager.rb,
lib/kairos_mcp/storage/exporter.rb,
lib/kairos_mcp/storage/importer.rb,
lib/kairos_mcp/tools/skills_get.rb,
lib/kairos_mcp/tools/tool_guide.rb,
lib/kairos_mcp/upgrade_analyzer.rb,
lib/kairos_mcp/resource_registry.rb,
lib/kairos_mcp/tools/hello_world.rb,
lib/kairos_mcp/tools/skills_list.rb,
lib/kairos_mcp/auth/authenticator.rb,
lib/kairos_mcp/daemon/credentials.rb,
lib/kairos_mcp/daemon/edit_kernel.rb,
lib/kairos_mcp/daemon/integration.rb,
lib/kairos_mcp/dsl_ast/ast_engine.rb,
lib/kairos_mcp/dsl_ast/decompiler.rb,
lib/kairos_mcp/invocation_context.rb,
lib/kairos_mcp/kairos_chain/block.rb,
lib/kairos_mcp/kairos_chain/chain.rb,
lib/kairos_mcp/knowledge_provider.rb,
lib/kairos_mcp/skill_tool_adapter.rb,
lib/kairos_mcp/tools/chain_export.rb,
lib/kairos_mcp/tools/chain_import.rb,
lib/kairos_mcp/tools/chain_record.rb,
lib/kairos_mcp/tools/chain_status.rb,
lib/kairos_mcp/tools/chain_verify.rb,
lib/kairos_mcp/tools/context_save.rb,
lib/kairos_mcp/tools/skills_audit.rb,
lib/kairos_mcp/tools/state_commit.rb,
lib/kairos_mcp/tools/state_status.rb,
lib/kairos_mcp/tools/token_manage.rb,
lib/kairos_mcp/vector_search/base.rb,
lib/kairos_mcp/daemon/code_gen_act.rb,
lib/kairos_mcp/daemon/wal_recovery.rb,
lib/kairos_mcp/dsl_skills_provider.rb,
lib/kairos_mcp/tools/chain_history.rb,
lib/kairos_mcp/tools/knowledge_get.rb,
lib/kairos_mcp/tools/resource_list.rb,
lib/kairos_mcp/tools/resource_read.rb,
lib/kairos_mcp/tools/skills_evolve.rb,
lib/kairos_mcp/tools/state_history.rb,
lib/kairos_mcp/daemon/approval_gate.rb,
lib/kairos_mcp/daemon/attach_server.rb,
lib/kairos_mcp/daemon/daemon_policy.rb,
lib/kairos_mcp/storage/file_backend.rb,
lib/kairos_mcp/tools/knowledge_list.rb,
lib/kairos_mcp/tools/skills_dsl_get.rb,
lib/kairos_mcp/tools/skills_promote.rb,
lib/kairos_mcp/tools/system_upgrade.rb,
lib/kairos_mcp/daemon/active_observe.rb,
lib/kairos_mcp/daemon/signal_handler.rb,
lib/kairos_mcp/tools/skills_dsl_list.rb,
lib/kairos_mcp/tools/skills_rollback.rb,
lib/kairos_mcp/anthropic_skill_parser.rb,
lib/kairos_mcp/daemon/command_mailbox.rb,
lib/kairos_mcp/daemon/elevation_token.rb,
lib/kairos_mcp/daemon/mandate_factory.rb,
lib/kairos_mcp/daemon/proposal_routes.rb,
lib/kairos_mcp/dsl_ast/drift_detector.rb,
lib/kairos_mcp/storage/sqlite_backend.rb,
lib/kairos_mcp/tools/definition_drift.rb,
lib/kairos_mcp/tools/knowledge_update.rb,
lib/kairos_mcp/vector_search/provider.rb,
lib/kairos_mcp/daemon/policy_elevation.rb,
lib/kairos_mcp/daemon/restricted_shell.rb,
lib/kairos_mcp/daemon/scope_classifier.rb,
lib/kairos_mcp/tools/capability_status.rb,
lib/kairos_mcp/tools/definition_verify.rb,
lib/kairos_mcp/daemon/daemon_llm_caller.rb,
lib/kairos_mcp/daemon/execution_context.rb,
lib/kairos_mcp/daemon/idempotency_check.rb,
lib/kairos_mcp/daemon/ooda_cycle_runner.rb,
lib/kairos_mcp/kairos_chain/merkle_tree.rb,
lib/kairos_mcp/daemon/wal_phase_recorder.rb,
lib/kairos_mcp/tools/instructions_update.rb,
lib/kairos_mcp/daemon/llm_phase_functions.rb,
lib/kairos_mcp/tools/definition_decompile.rb,
lib/kairos_mcp/tools/formalization_record.rb,
lib/kairos_mcp/state_commit/commit_service.rb,
lib/kairos_mcp/tools/context_create_subdir.rb,
lib/kairos_mcp/tools/formalization_history.rb,
lib/kairos_mcp/state_commit/diff_calculator.rb,
lib/kairos_mcp/state_commit/pending_changes.rb,
lib/kairos_mcp/daemon/code_gen_phase_handler.rb,
lib/kairos_mcp/kairos_chain/skill_transition.rb,
lib/kairos_mcp/state_commit/manifest_builder.rb,
lib/kairos_mcp/state_commit/snapshot_manager.rb,
lib/kairos_mcp/vector_search/fallback_search.rb,
lib/kairos_mcp/vector_search/semantic_search.rb,
lib/kairos_mcp/daemon/restricted_shell/errors.rb,
lib/kairos_mcp/daemon/restricted_shell/runner.rb,
lib/kairos_mcp/daemon/idempotent_chain_recorder.rb,
lib/kairos_mcp/kairos_chain/formalization_decision.rb,
lib/kairos_mcp/daemon/restricted_shell/argv_validators.rb,
lib/kairos_mcp/daemon/restricted_shell/binary_resolver.rb,
lib/kairos_mcp/daemon/restricted_shell/sandbox_context.rb,
lib/kairos_mcp/daemon/restricted_shell/sandbox_factory.rb
Defined Under Namespace
Modules: Admin, Auth, Capability, ContextGraph, DslAst, Kairos, KairosChain, LifecycleHook, StateCommit, Storage, Tools, VectorSearch Classes: ActionLog, AnthropicSkillParser, AstNode, ConfigMerger, ContextManager, Daemon, DefinitionContext, DslSkillsProvider, EffectContext, EvolveContext, GuaranteesContext, HttpServer, Initializer, InvocationContext, KnowledgeProvider, LayerRegistry, Logger, MeetingRouter, PluginProjector, Protocol, ResourceRegistry, SafeEvolver, Safety, Server, SignalHandle, SkillBuilder, SkillHistory, SkillSetManager, SkillToolAdapter, SkillsAst, SkillsConfig, SkillsDsl, SkillsParser, Skillset, ToolContext, ToolRegistry, UpgradeAnalyzer, VersionManager
Constant Summary collapse
- TEMPLATE_FILES =
Template Files Registry
Centralized mapping of template files to their data directory destinations. Used by Initializer (for init) and UpgradeAnalyzer (for migration).
Format: [template_relative_path, data_dir_accessor_symbol]
[ ['skills/kairos.rb', :dsl_path], ['skills/kairos.md', :md_path], ['skills/kairos_quickguide.md', :quickguide_path], ['skills/kairos_tutorial.md', :tutorial_path], ['skills/researcher.md', :researcher_path], ['skills/config.yml', :skills_config_path], ['config/safety.yml', :safety_config_path], ['config/tool_metadata.yml', :tool_metadata_path] ].freeze
- TEMPLATE_FILE_TYPES =
File type classification for upgrade conflict resolution
{ 'skills/kairos.rb' => :l0_dsl, 'skills/kairos.md' => :l0_doc, 'skills/kairos_quickguide.md' => :l0_doc, 'skills/kairos_tutorial.md' => :l0_doc, 'skills/researcher.md' => :l0_doc, 'skills/config.yml' => :config_yaml, 'config/safety.yml' => :config_yaml, 'config/tool_metadata.yml' => :config_yaml }.freeze
- PLAUSIBILITY_MARKERS =
Plugin Projection support — consumer project root
Design v0.2 (log/20260512_consumer_project_root_separation_design_v0.2.md): consumer_project_root is decoupled from data_dir. Resolution order:
1. Explicit setter (CLI flag --project-root) 2. Environment variable KAIROS_PROJECT_ROOT 3. Per-transport default with plausibility check: stdio_mcp / cli_direct: Dir.pwd if plausible http_mcp: no default (returns nil; caller must refuse projection)See design §2 (invariants) and §6 (failure taxonomy).
['CLAUDE.md', '.git', '.claude', File.join('.kairos', 'projection_manifest.json')].freeze
- VERSION =
"3.27.0"- CHANGELOG_URL =
"https://github.com/masaomi/KairosChain_2026/blob/main/CHANGELOG.md"
Class Method Summary collapse
-
.action_log_path ⇒ Object
L0 action log file path.
-
.blockchain_path ⇒ Object
Blockchain file path (for file backend).
-
.collect_knowledge_entries(user_context: nil) ⇒ Object
Collect L1 knowledge entries for plugin projection Shared by protocol.rb and plugin_project tool.
-
.config_dir ⇒ Object
Config directory (safety.yml, tool_metadata.yml).
-
.consumer_project_root ⇒ String?
Consumer project root: where projection artifacts (CLAUDE.md, .claude/) are written.
-
.consumer_project_root=(path) ⇒ Object
Explicit setter (used by CLI –project-root flag).
-
.consumer_project_root_source ⇒ Symbol
Source of the currently resolved consumer_project_root.
-
.context_dir(user_context: nil) ⇒ Object
L2 context directory.
-
.data_dir ⇒ String
Get the root data directory for all runtime data.
-
.data_dir=(path) ⇒ Object
Set the root data directory explicitly.
-
.detect_transport ⇒ Symbol
Detect current transport mode based on runtime state.
-
.dsl_path ⇒ Object
L0 skills DSL file path.
-
.embeddings_dir ⇒ Object
Embeddings directory (for vector search).
-
.export_dir ⇒ Object
Export directory (for SQLite export).
-
.gem_root ⇒ String
Path to the gem’s root directory (one level above lib/).
-
.http_server ⇒ Object
HttpServer reference (set when running in HTTP mode) =========================================================================.
- .http_server=(server) ⇒ Object
-
.initialized? ⇒ Boolean
Check if the data directory has been initialized.
-
.knowledge_dir(user_context: nil) ⇒ Object
L1 knowledge directory.
-
.knowledge_index_path ⇒ Object
Knowledge embeddings index path.
- .logger ⇒ Object
- .logger=(instance) ⇒ Object
-
.md_path ⇒ Object
L0 skills philosophy file path.
-
.meta_path ⇒ Object
Meta file path (.kairos_meta.yml for upgrade tracking).
- .parse_frontmatter(path) ⇒ Object
-
.plausibility_check(path) ⇒ Object
Plausibility predicate (design Inv 6 / §11).
-
.project_root ⇒ Object
DEPRECATED in v0.2: parent-of-data-dir derivation.
-
.projection_mode ⇒ Object
Determine projection mode for PluginProjector :project (default) — writes to .claude/skills/, .claude/agents/, settings.json :plugin — writes to plugin root skills/, agents/, hooks/hooks.json.
-
.quickguide_path ⇒ Object
L0 skills quick guide file path (user-facing instructions).
-
.real_path(path) ⇒ Object
Resolve a path to its real path (symlinks resolved).
-
.register_path_resolver(name, &block) ⇒ Object
Register a named path resolver for tenant-aware directory resolution.
-
.researcher_path ⇒ Object
Researcher instruction mode file path.
-
.reset_consumer_project_root! ⇒ Object
Reset resolution cache (for testing or re-initialization).
-
.reset_data_dir! ⇒ Object
Reset data_dir (for testing or re-initialization).
-
.resolve_consumer_project_root(transport: nil) ⇒ String?
Resolve consumer_project_root following the documented order.
-
.safety_config_path ⇒ Object
Safety config file path.
-
.skills_config_path ⇒ Object
L0 skills config file path.
-
.skills_dir ⇒ Object
L0 skills directory (kairos.rb, kairos.md, config.yml, versions/).
-
.skills_index_path ⇒ Object
Skills embeddings index path.
-
.skillsets_config_path ⇒ Object
SkillSets config file (enabled/disabled state, layer overrides).
-
.skillsets_dir ⇒ Object
SkillSets directory (plugin-based extensions).
-
.snapshots_dir ⇒ Object
Snapshots directory (for state commit).
-
.sqlite_path ⇒ Object
SQLite database path.
-
.storage_dir ⇒ Object
Storage directory (blockchain, embeddings, snapshots, tokens, etc.).
-
.templates_dir ⇒ String
Path to the bundled templates directory within the gem.
-
.token_store_path ⇒ Object
Token store file path.
-
.tool_metadata_path ⇒ Object
Tool metadata file path.
-
.tutorial_path ⇒ Object
L0 skills tutorial file path (onboarding instructions).
- .unregister_path_resolver(name) ⇒ Object
-
.versions_dir ⇒ Object
L0 skills versions directory.
Class Method Details
.action_log_path ⇒ Object
L0 action log file path
155 156 157 |
# File 'lib/kairos_mcp.rb', line 155 def action_log_path File.join(skills_dir, 'action_log.jsonl') end |
.blockchain_path ⇒ Object
Blockchain file path (for file backend)
180 181 182 |
# File 'lib/kairos_mcp.rb', line 180 def blockchain_path File.join(storage_dir, 'blockchain.json') end |
.collect_knowledge_entries(user_context: nil) ⇒ Object
Collect L1 knowledge entries for plugin projection Shared by protocol.rb and plugin_project tool
421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/kairos_mcp.rb', line 421 def collect_knowledge_entries(user_context: nil) kdir = knowledge_dir(user_context: user_context) return [] unless Dir.exist?(kdir) Dir.glob(File.join(kdir, '**', '*.md')).filter_map do |f| fm = parse_frontmatter(f) next unless fm { name: fm['name'] || File.basename(f, '.md'), description: fm['description'] || '', version: fm['version'] || '0', tags: fm['tags'] || [], path: f } end end |
.config_dir ⇒ Object
Config directory (safety.yml, tool_metadata.yml)
220 221 222 |
# File 'lib/kairos_mcp.rb', line 220 def config_dir path_for('config') end |
.consumer_project_root ⇒ String?
Consumer project root: where projection artifacts (CLAUDE.md, .claude/) are written. Distinct from data_dir (where KairosChain state lives).
299 300 301 302 |
# File 'lib/kairos_mcp.rb', line 299 def consumer_project_root resolve_consumer_project_root unless defined?(@consumer_project_root_resolved) && @consumer_project_root_resolved @consumer_project_root end |
.consumer_project_root=(path) ⇒ Object
Explicit setter (used by CLI –project-root flag). Setting to nil clears any cached resolution.
313 314 315 316 317 318 319 320 321 322 |
# File 'lib/kairos_mcp.rb', line 313 def consumer_project_root=(path) if path.nil? @consumer_project_root = nil @consumer_project_root_source = :absent else @consumer_project_root = real_path(File.(path)) @consumer_project_root_source = :explicit_cli end @consumer_project_root_resolved = true end |
.consumer_project_root_source ⇒ Symbol
Source of the currently resolved consumer_project_root.
306 307 308 309 |
# File 'lib/kairos_mcp.rb', line 306 def consumer_project_root_source consumer_project_root # trigger resolution @consumer_project_root_source || :absent end |
.context_dir(user_context: nil) ⇒ Object
L2 context directory. Same tenant-aware resolution as knowledge_dir.
169 170 171 172 |
# File 'lib/kairos_mcp.rb', line 169 def context_dir(user_context: nil) resolved = resolve_path(:context, user_context) resolved || path_for('context') end |
.data_dir ⇒ String
Get the root data directory for all runtime data
92 93 94 |
# File 'lib/kairos_mcp.rb', line 92 def data_dir @data_dir ||= resolve_data_dir end |
.data_dir=(path) ⇒ Object
Set the root data directory explicitly
99 100 101 102 |
# File 'lib/kairos_mcp.rb', line 99 def data_dir=(path) @data_dir = File.(path) @path_cache = {} end |
.detect_transport ⇒ Symbol
Detect current transport mode based on runtime state.
394 395 396 397 |
# File 'lib/kairos_mcp.rb', line 394 def detect_transport return :http_mcp if @http_server :stdio_mcp end |
.dsl_path ⇒ Object
L0 skills DSL file path
120 121 122 |
# File 'lib/kairos_mcp.rb', line 120 def dsl_path File.join(skills_dir, 'kairos.rb') end |
.embeddings_dir ⇒ Object
Embeddings directory (for vector search)
195 196 197 |
# File 'lib/kairos_mcp.rb', line 195 def File.join(storage_dir, 'embeddings') end |
.export_dir ⇒ Object
Export directory (for SQLite export)
215 216 217 |
# File 'lib/kairos_mcp.rb', line 215 def export_dir File.join(storage_dir, 'export') end |
.gem_root ⇒ String
Path to the gem’s root directory (one level above lib/)
267 268 269 |
# File 'lib/kairos_mcp.rb', line 267 def gem_root File.('..', __dir__) end |
.http_server ⇒ Object
HttpServer reference (set when running in HTTP mode)
79 80 81 |
# File 'lib/kairos_mcp.rb', line 79 def http_server @http_server end |
.http_server=(server) ⇒ Object
83 84 85 |
# File 'lib/kairos_mcp.rb', line 83 def http_server=(server) @http_server = server end |
.initialized? ⇒ Boolean
Check if the data directory has been initialized
274 275 276 |
# File 'lib/kairos_mcp.rb', line 274 def initialized? File.exist?(dsl_path) && File.exist?(skills_config_path) end |
.knowledge_dir(user_context: nil) ⇒ Object
L1 knowledge directory. When user_context is provided, registered path resolvers can return a tenant-specific path. Without user_context, returns the global path.
162 163 164 165 |
# File 'lib/kairos_mcp.rb', line 162 def knowledge_dir(user_context: nil) resolved = resolve_path(:knowledge, user_context) resolved || path_for('knowledge') end |
.knowledge_index_path ⇒ Object
Knowledge embeddings index path
205 206 207 |
# File 'lib/kairos_mcp.rb', line 205 def knowledge_index_path File.join(, 'knowledge') end |
.logger ⇒ Object
153 154 155 156 157 |
# File 'lib/kairos_mcp/logger.rb', line 153 def self.logger @logger_mutex.synchronize do @logger ||= Logger.new end end |
.logger=(instance) ⇒ Object
159 160 161 162 163 |
# File 'lib/kairos_mcp/logger.rb', line 159 def self.logger=(instance) @logger_mutex.synchronize do @logger = instance end end |
.md_path ⇒ Object
L0 skills philosophy file path
125 126 127 |
# File 'lib/kairos_mcp.rb', line 125 def md_path File.join(skills_dir, 'kairos.md') end |
.meta_path ⇒ Object
Meta file path (.kairos_meta.yml for upgrade tracking)
245 246 247 |
# File 'lib/kairos_mcp.rb', line 245 def File.join(data_dir, '.kairos_meta.yml') end |
.parse_frontmatter(path) ⇒ Object
435 436 437 438 439 440 441 442 443 444 |
# File 'lib/kairos_mcp.rb', line 435 def parse_frontmatter(path) content = File.read(path, encoding: 'utf-8') return nil unless content.start_with?('---') parts = content.split('---', 3) return nil if parts.length < 3 require 'yaml' YAML.safe_load(parts[1]) rescue StandardError nil end |
.plausibility_check(path) ⇒ Object
Plausibility predicate (design Inv 6 / §11). Candidate passes if any recognizable project marker exists at the path.
375 376 377 378 379 380 381 382 |
# File 'lib/kairos_mcp.rb', line 375 def plausibility_check(path) return false if path.nil? || path.empty? return false unless Dir.exist?(path) PLAUSIBILITY_MARKERS.any? do |marker| candidate = File.join(path, marker) File.exist?(candidate) || Dir.exist?(candidate) end end |
.project_root ⇒ Object
DEPRECATED in v0.2: parent-of-data-dir derivation. Returns consumer_project_root when available, falling back to File.dirname(data_dir) only for backward compatibility with internal callers that have not yet been migrated. New code should use consumer_project_root and handle nil explicitly.
403 404 405 |
# File 'lib/kairos_mcp.rb', line 403 def project_root consumer_project_root || File.dirname(data_dir) end |
.projection_mode ⇒ Object
Determine projection mode for PluginProjector :project (default) — writes to .claude/skills/, .claude/agents/, settings.json :plugin — writes to plugin root skills/, agents/, hooks/hooks.json
410 411 412 413 414 415 416 417 |
# File 'lib/kairos_mcp.rb', line 410 def projection_mode return :plugin if ENV['KAIROS_PROJECTION_MODE'] == 'plugin' root = consumer_project_root || File.dirname(data_dir) plugin_json = File.join(root, '.claude-plugin', 'plugin.json') claude_dir = File.join(root, '.claude') return :plugin if File.exist?(plugin_json) && !File.exist?(claude_dir) :project end |
.quickguide_path ⇒ Object
L0 skills quick guide file path (user-facing instructions)
130 131 132 |
# File 'lib/kairos_mcp.rb', line 130 def quickguide_path File.join(skills_dir, 'kairos_quickguide.md') end |
.real_path(path) ⇒ Object
Resolve a path to its real path (symlinks resolved). Falls back to expand_path for non-existent paths.
386 387 388 389 390 |
# File 'lib/kairos_mcp.rb', line 386 def real_path(path) File.realpath(File.(path)) rescue Errno::ENOENT File.(path) end |
.register_path_resolver(name, &block) ⇒ Object
Register a named path resolver for tenant-aware directory resolution. Block receives (type, user_context) and returns a path or nil.
63 64 65 66 67 |
# File 'lib/kairos_mcp.rb', line 63 def register_path_resolver(name, &block) @path_resolver_mutex.synchronize do @path_resolvers[name.to_sym] = block end end |
.researcher_path ⇒ Object
Researcher instruction mode file path
140 141 142 |
# File 'lib/kairos_mcp.rb', line 140 def researcher_path File.join(skills_dir, 'researcher.md') end |
.reset_consumer_project_root! ⇒ Object
Reset resolution cache (for testing or re-initialization).
325 326 327 328 329 |
# File 'lib/kairos_mcp.rb', line 325 def reset_consumer_project_root! @consumer_project_root = nil @consumer_project_root_source = nil @consumer_project_root_resolved = false end |
.reset_data_dir! ⇒ Object
Reset data_dir (for testing or re-initialization)
105 106 107 108 |
# File 'lib/kairos_mcp.rb', line 105 def reset_data_dir! @data_dir = nil @path_cache = {} end |
.resolve_consumer_project_root(transport: nil) ⇒ String?
Resolve consumer_project_root following the documented order.
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 |
# File 'lib/kairos_mcp.rb', line 334 def resolve_consumer_project_root(transport: nil) # Skip env/default lookup if explicit setter was used if @consumer_project_root_source == :explicit_cli && @consumer_project_root @consumer_project_root_resolved = true return @consumer_project_root end transport ||= detect_transport # 1. Environment variable if (env_val = ENV['KAIROS_PROJECT_ROOT']) && !env_val.empty? @consumer_project_root = real_path(File.(env_val)) @consumer_project_root_source = :explicit_env @consumer_project_root_resolved = true return @consumer_project_root end # 2. Transport default if transport == :http_mcp # HTTP MCP: no default permitted (design §4) @consumer_project_root = nil @consumer_project_root_source = :absent @consumer_project_root_resolved = true return nil end # stdio_mcp / cli_direct: cwd default with plausibility candidate = real_path(Dir.pwd) if plausibility_check(candidate) @consumer_project_root = candidate @consumer_project_root_source = :transport_default else @consumer_project_root = nil @consumer_project_root_source = :absent end @consumer_project_root_resolved = true @consumer_project_root end |
.safety_config_path ⇒ Object
Safety config file path
225 226 227 |
# File 'lib/kairos_mcp.rb', line 225 def safety_config_path File.join(config_dir, 'safety.yml') end |
.skills_config_path ⇒ Object
L0 skills config file path
145 146 147 |
# File 'lib/kairos_mcp.rb', line 145 def skills_config_path File.join(skills_dir, 'config.yml') end |
.skills_dir ⇒ Object
L0 skills directory (kairos.rb, kairos.md, config.yml, versions/)
115 116 117 |
# File 'lib/kairos_mcp.rb', line 115 def skills_dir path_for('skills') end |
.skills_index_path ⇒ Object
Skills embeddings index path
200 201 202 |
# File 'lib/kairos_mcp.rb', line 200 def skills_index_path File.join(, 'skills') end |
.skillsets_config_path ⇒ Object
SkillSets config file (enabled/disabled state, layer overrides)
240 241 242 |
# File 'lib/kairos_mcp.rb', line 240 def skillsets_config_path File.join(skillsets_dir, 'config.yml') end |
.skillsets_dir ⇒ Object
SkillSets directory (plugin-based extensions)
235 236 237 |
# File 'lib/kairos_mcp.rb', line 235 def skillsets_dir path_for('skillsets') end |
.snapshots_dir ⇒ Object
Snapshots directory (for state commit)
210 211 212 |
# File 'lib/kairos_mcp.rb', line 210 def snapshots_dir File.join(storage_dir, 'snapshots') end |
.sqlite_path ⇒ Object
SQLite database path
185 186 187 |
# File 'lib/kairos_mcp.rb', line 185 def sqlite_path File.join(storage_dir, 'kairos.db') end |
.storage_dir ⇒ Object
Storage directory (blockchain, embeddings, snapshots, tokens, etc.)
175 176 177 |
# File 'lib/kairos_mcp.rb', line 175 def storage_dir path_for('storage') end |
.templates_dir ⇒ String
Path to the bundled templates directory within the gem
256 257 258 |
# File 'lib/kairos_mcp.rb', line 256 def templates_dir File.('../templates', __dir__) end |
.token_store_path ⇒ Object
Token store file path
190 191 192 |
# File 'lib/kairos_mcp.rb', line 190 def token_store_path File.join(storage_dir, 'tokens.json') end |
.tool_metadata_path ⇒ Object
Tool metadata file path
230 231 232 |
# File 'lib/kairos_mcp.rb', line 230 def File.join(config_dir, 'tool_metadata.yml') end |
.tutorial_path ⇒ Object
L0 skills tutorial file path (onboarding instructions)
135 136 137 |
# File 'lib/kairos_mcp.rb', line 135 def tutorial_path File.join(skills_dir, 'kairos_tutorial.md') end |
.unregister_path_resolver(name) ⇒ Object
69 70 71 72 73 |
# File 'lib/kairos_mcp.rb', line 69 def unregister_path_resolver(name) @path_resolver_mutex.synchronize do @path_resolvers.delete(name.to_sym) end end |
.versions_dir ⇒ Object
L0 skills versions directory
150 151 152 |
# File 'lib/kairos_mcp.rb', line 150 def versions_dir File.join(skills_dir, 'versions') end |