MishkaChelekom.MCP.PathHelper (Mishka Chelekom v0.0.9-alpha.17)

Copy Markdown View Source

Helper module for resolving file paths that works both when:

  1. Running directly inside the mishka_chelekom library (development/testing)
  2. Installed as a dependency in a user's Phoenix project

Uses :code.priv_dir/1 for installed dependency, falls back to local paths for development.

Summary

Functions

Returns the path to a component config file in priv/components/.

Returns the path to a component documentation file in usage-rules/components/.

Checks if a file exists at the given path.

Returns the path to a JS hook documentation file in usage-rules/js/.

Returns the path to a library documentation file in usage-rules/docs/.

Returns the path to mix-tasks.md documentation.

Returns the package root directory for mishka_chelekom. This is where usage-rules/ folder is located.

Returns the priv directory path for mishka_chelekom. Works both in development and when installed as a dependency.

Reads a file, returning {:ok, content} or {:error, reason}.

Returns the path to usage-rules directory. Located at package root, not inside priv.

Returns the path to the user's config file in their project. This always uses File.cwd!() since it's in the user's project, not the library.

Functions

component_config_path(name)

Returns the path to a component config file in priv/components/.

component_doc_path(name)

Returns the path to a component documentation file in usage-rules/components/.

file_exists?(path)

Checks if a file exists at the given path.

js_hook_doc_path(name)

Returns the path to a JS hook documentation file in usage-rules/js/.

lib_doc_path(filename)

Returns the path to a library documentation file in usage-rules/docs/.

mix_tasks_doc_path()

Returns the path to mix-tasks.md documentation.

package_root()

Returns the package root directory for mishka_chelekom. This is where usage-rules/ folder is located.

In development: returns File.cwd!() since we're working in the source tree As dependency: returns the deps path where usage-rules/ is located

priv_dir()

Returns the priv directory path for mishka_chelekom. Works both in development and when installed as a dependency.

read_file(path)

Reads a file, returning {:ok, content} or {:error, reason}.

usage_rules_dir()

Returns the path to usage-rules directory. Located at package root, not inside priv.

user_config_path()

Returns the path to the user's config file in their project. This always uses File.cwd!() since it's in the user's project, not the library.