diff --git a/.claude/skills/meta-exec/SKILL.md b/.claude/skills/meta-exec/SKILL.md index 683eb76..7fff4d2 100644 --- a/.claude/skills/meta-exec/SKILL.md +++ b/.claude/skills/meta-exec/SKILL.md @@ -41,7 +41,7 @@ meta exec -- --version ## Parallel vs Sequential -Commands run in parallel by default (a `.meta` config can set `defaults.parallel: false`; it is only read when you run meta from the directory holding that `.meta`). Use `--sequential` for live output in order, or `--parallel` to force concurrency: +Commands run in parallel by default (a `.meta.yaml` can set `defaults.parallel: false`; it is only read when you run meta from the directory holding that `.meta.yaml`). Use `--sequential` for live output in order, or `--parallel` to force concurrency: ```bash # Parallel (default) - faster, grouped output after completion @@ -61,7 +61,7 @@ Parallel mode: Control which repos run the command: ```bash -# Only these repos: each value is a repo's .meta name or its path from the workspace root +# Only these repos: each value is a repo's .meta.yaml name or its path from the workspace root meta --include api,worker git status meta --include libs/core,. git status # `.` is the root repo @@ -80,7 +80,7 @@ meta --tag backend --include api git status 2. `--include` limits to the named repos 3. `--exclude` removes the named repos -A value names a whole repo, never part of a path: `api` does not match `api-tests`. A value that names no repo is an error, so a typo never runs a command in the repo you meant to skip. Inside a worktree set the same holds: a repo sits at its project's path, so it is named by its `.meta` name or that path, from the set's root. A value starting with `./` is a path only; use it when a name is ambiguous (a value that names several repos is an error too). The meta root repo stays included even when it doesn't match a tag. +A value names a whole repo, never part of a path: `api` does not match `api-tests`. A value that names no repo is an error, so a typo never runs a command in the repo you meant to skip. Inside a worktree set the same holds: a repo sits at its project's path, so it is named by its `.meta.yaml` name or that path, from the set's root. A value starting with `./` is a path only; use it when a name is ambiguous (a value that names several repos is an error too). The meta root repo stays included even when it doesn't match a tag. ## Dry Run @@ -136,8 +136,8 @@ meta --silent exec -- npm install |--------|-------------| | `--parallel` | Run commands concurrently (the default) | | `--sequential` | Run one repo at a time | -| `--include ` | Only these repos (`.meta` name or path from the root) | -| `--exclude ` | Skip these repos (`.meta` name or path from the root) | +| `--include ` | Only these repos (`.meta.yaml` name or path from the root) | +| `--exclude ` | Skip these repos (`.meta.yaml` name or path from the root) | | `--tag ` | Filter by project tag(s) | | `--dry-run` | Preview without executing | | `--json` | Structured JSON output | @@ -187,7 +187,7 @@ meta exec -- rm -rf node_modules dist | One-off scripts | Operations with meta-specific logic | | npm/cargo/make | Clone, update, worktree | -`meta exec -- ` always runs the command as typed, never through a plugin: `meta exec -- git status` runs plain `git status` in each repo, while `meta git status` uses the git plugin. Prefer `meta git ` for git: any git subcommand passes through it, and it runs remote commands (`fetch`, `pull`, `push`) without credential prompts that would hang parallel runs. Plugins intercept only their own subcommands (`meta git ...`, `meta cargo ...`) and provide enhanced behavior. `meta git clone` doesn't run `git clone` in each repo—it reads `.meta` and clones the entire graph. +`meta exec -- ` always runs the command as typed, never through a plugin: `meta exec -- git status` runs plain `git status` in each repo, while `meta git status` uses the git plugin. Prefer `meta git ` for git: any git subcommand passes through it, and it runs remote commands (`fetch`, `pull`, `push`) without credential prompts that would hang parallel runs. Plugins intercept only their own subcommands (`meta git ...`, `meta cargo ...`) and provide enhanced behavior. `meta git clone` doesn't run `git clone` in each repo—it reads `.meta.yaml` and clones the entire graph. ## Worktree Context Detection diff --git a/.claude/skills/meta-git/SKILL.md b/.claude/skills/meta-git/SKILL.md index ce4d3e5..77d51a4 100644 --- a/.claude/skills/meta-git/SKILL.md +++ b/.claude/skills/meta-git/SKILL.md @@ -24,7 +24,7 @@ Any other git subcommand passes through to git in each repo. Meta passes the arg ## Cloning a Meta Repo ```bash -# Clone meta repo and all child repos defined in .meta +# Clone meta repo and all child repos defined in .meta.yaml meta git clone # Clone recursively (if child repos are also meta repos) @@ -37,13 +37,13 @@ meta git clone --parallel 8 meta git clone --depth 1 ``` -**How it works**: Meta clones the parent, reads `.meta`, then queues and clones all children in parallel. With `--recursive`, it repeats for any child that has its own `.meta`. +**How it works**: Meta clones the parent, reads `.meta.yaml`, then queues and clones all children in parallel. With `--recursive`, it repeats for any child that has its own `.meta.yaml`. ## Updating All Repos ```bash meta git pull # Pull every existing repo -meta git update # Clone repos listed in .meta that are missing locally +meta git update # Clone repos listed in .meta.yaml that are missing locally ``` `meta git update` only clones missing repos (nested meta repos included); it does not pull existing ones. `meta git pull --recursive` also pulls nested meta repos. @@ -85,13 +85,13 @@ meta git log --oneline -5 ## Filtering -Target specific repos. With `--tag`, the meta root repo stays included even when it isn't tagged; `--include`/`--exclude` take whole repos (a `.meta` name or the path from the workspace root, `.` for the root), never part of a path, and can drop the root. A value that names no repo is an error. +Target specific repos. With `--tag`, the meta root repo stays included even when it isn't tagged; `--include`/`--exclude` take whole repos (a `.meta.yaml` name or the path from the workspace root, `.` for the root), never part of a path, and can drop the root. A value that names no repo is an error. ```bash # By tag meta --tag backend git status -# By repo: .meta name or path from the root (`api` does not match `api-tests`) +# By repo: .meta.yaml name or path from the root (`api` does not match `api-tests`) meta --include api,web git push # Exclude repos diff --git a/.claude/skills/meta-plugins/SKILL.md b/.claude/skills/meta-plugins/SKILL.md index dec16fe..a9a3e40 100644 --- a/.claude/skills/meta-plugins/SKILL.md +++ b/.claude/skills/meta-plugins/SKILL.md @@ -16,7 +16,7 @@ When you run `meta `, meta checks if a plugin handles that command patt Example: - `meta git status` → git plugin runs `git status` in every repo at this meta level (`--recursive` for nested ones) -- `meta git clone ` → git plugin clones parent + all children from `.meta` +- `meta git clone ` → git plugin clones parent + all children from `.meta.yaml` - `meta npm install` → unrecognized, shows help; use `meta exec npm install` ## Built-in Plugins @@ -27,7 +27,7 @@ Handles all `meta git *` commands with special cases: | Command | Behavior | |---------|----------| -| `meta git clone ` | Clone parent, read `.meta`, clone all children | +| `meta git clone ` | Clone parent, read `.meta.yaml`, clone all children | | `meta git update` | Clone missing repos (use `meta git pull` to pull existing ones) | | `meta git worktree *` | Isolated multi-repo worktree sets (see the `meta-worktree` skill) | | `meta git ` | Pass through to every repo at this meta level | @@ -37,7 +37,7 @@ Handles all `meta git *` commands with special cases: Workspace management: ```bash -meta project list # List projects from .meta +meta project list # List projects from .meta.yaml meta project check # Verify all repos exist meta project dependents # Projects that depend on one ``` diff --git a/.claude/skills/meta-safety/SKILL.md b/.claude/skills/meta-safety/SKILL.md index 55b2dce..d36b8eb 100644 --- a/.claude/skills/meta-safety/SKILL.md +++ b/.claude/skills/meta-safety/SKILL.md @@ -15,7 +15,7 @@ Multi-repo workspaces are powerful but require awareness. Meta gives you precisi ## Precision Operations -Instead of cd-ing into repos one by one, use meta flags to target what you need. Include/exclude take whole repos (a `.meta` name or the path from the workspace root), never part of a path, and a value that names no repo is an error; `--tag` keeps the meta root even when it isn't tagged: +Instead of cd-ing into repos one by one, use meta flags to target what you need. Include/exclude take whole repos (a `.meta.yaml` name or the path from the workspace root), never part of a path, and a value that names no repo is an error; `--tag` keeps the meta root even when it isn't tagged: ```bash # Target specific repos @@ -42,7 +42,7 @@ When modifying a repo that other repos depend on: ## Efficient Commits ```bash -# Commit only in repos repo1 and repo2 (.meta name or path from the root) +# Commit only in repos repo1 and repo2 (.meta.yaml name or path from the root) meta --include repo1,repo2 git commit -m "feat: update shared API" # Push tagged repos (and the root) diff --git a/.claude/skills/meta-workspace/SKILL.md b/.claude/skills/meta-workspace/SKILL.md index f2c78e1..2b96634 100644 --- a/.claude/skills/meta-workspace/SKILL.md +++ b/.claude/skills/meta-workspace/SKILL.md @@ -1,6 +1,6 @@ --- name: meta-workspace -description: Understanding and operating in meta repository workspaces with .meta/.meta.yaml configuration. +description: Understanding and operating in meta repository workspaces with .meta.yaml configuration. --- # Meta Workspace Skill @@ -31,8 +31,8 @@ In a meta repo, changes often span multiple repositories. Using `meta` commands ## The Meta Config -One config file in the workspace root defines the child repositories: -`.meta.yaml` (or `.meta.yml`), or `.meta.json`. +One config file in the workspace root, `.meta.yaml`, defines the child +repositories. ```yaml projects: @@ -46,11 +46,6 @@ projects: **Simple format**: `name: git-url` - clones to `./name` **Extended format**: Object with `repo`, optional `path`, optional `tags` -An older repo may use the legacy `.meta` file (JSON, no extension). It still -works, but it takes the name of meta's `.meta/` folder (skills and -project-local plugins): rename it with `git mv .meta .meta.json` (same content). -Two config files in one directory are an error that names both; keep one. - ## Discovering What's Here ```bash @@ -115,7 +110,7 @@ When the meta MCP server is available, these tools provide structured JSON for p ## Efficiency Tips - **One command, all repos**: `meta git status` replaces N individual `cd && git status` calls -- **Targeted operations**: `meta --include repo1,repo2 exec -- cmd` operates on only the named repos (`.meta` name or path from the workspace root) +- **Targeted operations**: `meta --include repo1,repo2 exec -- cmd` operates on only the named repos (`.meta.yaml` name or path from the workspace root) - **Tag-based filtering**: `meta --tag backend exec -- cargo test` scopes to tagged repos - **Dependency awareness**: `meta_analyze_impact ` shows who depends on a repo before you modify it — prevents cascading fix-up commits - **Session start**: Always run `meta project list --recursive --json` first to get the workspace map diff --git a/.claude/skills/meta-worktree/SKILL.md b/.claude/skills/meta-worktree/SKILL.md index fa91890..87fd48f 100644 --- a/.claude/skills/meta-worktree/SKILL.md +++ b/.claude/skills/meta-worktree/SKILL.md @@ -100,7 +100,10 @@ meta git worktree exec --ephemeral lint-check --all -- make lint `prune` removes sets whose TTL has expired; for a set whose directory is gone it only forgets meta's record. Once its repos are taken out of the meta config, or the checkout it was made from is moved or deleted, a set is no longer the -workspace's: remove it with `git worktree remove`. `--ephemeral` alone only records metadata. A TTL is a backstop for a session that +workspace's: remove each member with `git worktree remove`, run in the repo it +was made from. A member whose repo was deleted with that checkout has no git +record left, so git can't remove it: copy out any files you want to keep, +then delete its folder by hand. `--ephemeral` alone only records metadata. A TTL is a backstop for a session that dies before removing its sets. ## Inspecting Worktrees @@ -149,7 +152,7 @@ Detection relies on the `.worktrees/` path. It, and created with `--recursive` inside another repo of the set (e.g. `open-source/sdk/core` inside `open-source`) are skipped. `list --recursive` shows them; run the tool itself (`cargo`, `git`) in their directory, not `meta exec`, which still scopes to the set's top-level repos there. The root repo is part of a set -by default, so the set has its own `.meta` config; otherwise meta walks up to +by default, so the set has its own `.meta.yaml` config; otherwise meta walks up to the primary checkout's config. `meta --primary ` bypasses detection; run it from the primary checkout to be sure it uses the primary repos. @@ -174,7 +177,7 @@ from inside a set, they act on the workspace the set was made from. ## Lifecycle Hooks -Configure hooks in the meta config (`.meta.yaml`, `.meta.yml`, `.meta.json` or the legacy `.meta`): +Configure hooks in the meta config (`.meta.yaml`): ```yaml worktree: diff --git a/src/context.rs b/src/context.rs index a8114ef..c245787 100644 --- a/src/context.rs +++ b/src/context.rs @@ -103,8 +103,8 @@ fn is_cache_valid(cached: &CachedContext, current_root: &PathBuf) -> bool { pub fn handle_context(json: bool, no_status: bool, no_cache: bool, verbose: bool) -> Result<()> { let cwd = std::env::current_dir().context("Failed to get current directory")?; - let (config_path, _format) = config::find_meta_config(&cwd, None)? - .ok_or_else(|| anyhow::anyhow!("Not a meta workspace (no .meta config found)"))?; + let config_path = config::find_meta_config(&cwd, None)? + .ok_or_else(|| anyhow::anyhow!("Not a meta workspace (no .meta.yaml found)"))?; let meta_dir = config_path .parent() @@ -309,7 +309,7 @@ fn build_dependency_map(projects: &[ProjectInfo]) -> Option String { diff --git a/src/dependency_graph.rs b/src/dependency_graph.rs index 915b886..b296fb0 100644 --- a/src/dependency_graph.rs +++ b/src/dependency_graph.rs @@ -1,6 +1,6 @@ //! Dependency tracking and impact analysis for meta projects //! -//! Supports extended .meta schema with provides/depends_on fields: +//! Supports extended .meta.yaml schema with provides/depends_on fields: //! //! ```yaml //! projects: diff --git a/src/init.rs b/src/init.rs index c66338d..7d6f2a9 100644 --- a/src/init.rs +++ b/src/init.rs @@ -165,16 +165,6 @@ fn install_claude_integration_to( update: bool, verbose: bool, ) -> Result<()> { - // `.meta/` is meta's own folder, so it can't sit next to a legacy `.meta` config file - if target_dir.join(".meta").is_file() { - anyhow::bail!( - "This repo's meta config is the legacy `.meta` file, so meta can't create its \ - `.meta/` folder for skills.\n\ - Rename the config and rerun: `git mv .meta .meta.json` (same content), \ - or convert it to `.meta.yaml`." - ); - } - let claude_dir = target_dir.join(".claude"); let skills_dir = claude_dir.join("skills"); let rules_dir = claude_dir.join("rules"); @@ -183,7 +173,7 @@ fn install_claude_integration_to( if config::find_meta_config_in(target_dir)?.is_none() { println!( "{}", - "Warning: No .meta config found in current directory.".yellow() + "Warning: No .meta.yaml found in current directory.".yellow() ); println!("This integration is designed for meta repositories."); println!(); @@ -1193,20 +1183,6 @@ mod tests { assert!(!dir.path().join(".opencode").exists()); } - #[test] - fn test_install_refuses_legacy_meta_config_file() { - let dir = tempdir().unwrap(); - fs::write(dir.path().join(".meta"), r#"{"projects": {}}"#).unwrap(); - - for (force, update) in [(false, false), (false, true), (true, false)] { - let err = install_claude_integration_to(dir.path(), force, update, false).unwrap_err(); - assert!(err.to_string().contains("git mv .meta .meta.json"), "{err}"); - } - assert!(dir.path().join(".meta").is_file()); - assert!(!dir.path().join(".claude").exists()); - assert!(!dir.path().join(".agents").exists()); - } - #[test] fn test_update_turns_skill_folders_into_links() { let dir = tempdir().unwrap(); diff --git a/src/main.rs b/src/main.rs index 4de3e53..6396d61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,7 @@ use anyhow::Result; use clap::{Args, CommandFactory, Parser, Subcommand}; use colored::*; use loop_lib::run; -use meta_core::config::{ - self, find_meta_config, parse_meta_config, ConfigFormat, MetaTreeNode, ProjectInfo, -}; +use meta_core::config::{self, find_meta_config, parse_meta_config, MetaTreeNode, ProjectInfo}; use meta_core::display::{escape, escape_lines, escape_path}; use std::io::Write; use std::path::PathBuf; @@ -48,7 +46,7 @@ struct Cli { long, global = true, value_delimiter = ',', - help = "Skip these repos: each value is a repo's .meta name or its whole path from the workspace root (. for the root), never part of one" + help = "Skip these repos: each value is a repo's .meta.yaml name or its whole path from the workspace root (. for the root), never part of one" )] exclude: Option>, @@ -57,7 +55,7 @@ struct Cli { long, global = true, value_delimiter = ',', - help = "Only run in these repos: each value is a repo's .meta name or its whole path from the workspace root (. for the root), never part of one" + help = "Only run in these repos: each value is a repo's .meta.yaml name or its whole path from the workspace root (. for the root), never part of one" )] include: Option>, @@ -598,12 +596,14 @@ fn run_cli() -> Result<()> { println!("Arguments:"); println!(" ... Command and arguments to run"); println!(); - println!("The command runs as typed in each project directory defined in .meta,"); + println!( + "The command runs as typed in each project directory defined in .meta.yaml," + ); println!("never through a plugin (use `meta git ...` for the git plugin)."); println!("No shell parses it: each argument reaches the program as given, so"); println!("quotes, $(), ;, | and globs stay literal. For a shell, ask for one."); println!(); - println!("--include/--exclude take repos by .meta name or path from the root"); + println!("--include/--exclude take repos by .meta.yaml name or path from the root"); println!("(. for the root), never part of a path."); println!(); println!("Examples:"); @@ -712,7 +712,7 @@ fn handle_command_dispatch( log::debug!("parallel=false (--sequential flag)"); false } else { - // Load default from .meta config (defaults to parallel: true if not specified) + // Load default from .meta.yaml (defaults to parallel: true if not specified) let cwd = std::env::current_dir().unwrap_or_default(); let defaults = config::load_meta_defaults(&cwd); log::debug!( @@ -725,8 +725,8 @@ fn handle_command_dispatch( let command_str = loop_lib::display_command(&command_args); - // Check if this is `git clone` - it doesn't require a .meta file because - // its purpose is to clone the repo that contains the .meta file + // Check if this is `git clone` - it doesn't require a .meta.yaml file because + // its purpose is to clone the repo that contains the .meta.yaml file let is_git_clone = command_args.first().map(|s| s == "git").unwrap_or(false) && command_args.get(1).map(|s| s == "clone").unwrap_or(false); @@ -734,7 +734,7 @@ fn handle_command_dispatch( if cli.include.is_some() || cli.exclude.is_some() { anyhow::bail!("meta git clone clones every repo in the meta repo; it does not take --include/--exclude"); } - // Handle git clone directly via plugin without requiring .meta file + // Handle git clone directly via plugin without requiring .meta.yaml file let subprocess_options = PluginRequestOptions { json_output: cli.json, verbose: cli.verbose, @@ -792,7 +792,7 @@ fn handle_command_dispatch( ); } - if let Some((config_path, _format)) = + if let Some(config_path) = worktree::set_config(&task_dir, &wt_paths, cli.config.as_ref())? { let (meta_projects, ignore_list) = parse_meta_config(&config_path)?; @@ -919,7 +919,7 @@ fn handle_command_dispatch( } if cli.verbose { eprintln!( - "{} No .meta config found for worktree '{}'. Tags, plugins, and dependency features unavailable.", + "{} No .meta.yaml found for worktree '{}'. Tags, plugins, and dependency features unavailable.", "warning:".yellow().bold(), escape(&task_name) ); @@ -951,13 +951,13 @@ fn handle_command_dispatch( } let absolute_path = match find_meta_config(¤t_dir, cli.config.as_ref())? { - Some((path, _format)) => path, + Some(path) => path, None => { let config_name = cli .config .as_ref() .map(|p| escape_path(p)) - .unwrap_or_else(|| config::META_CONFIG_NAMES.join(" / ")); + .unwrap_or_else(|| config::META_CONFIG_NAME.to_string()); eprintln!("Error: Could not find meta config file '{config_name}'"); eprintln!("Searched from {} up to root", escape_path(¤t_dir)); std::process::exit(1); @@ -1462,7 +1462,7 @@ fn matches_tag_filter(tags: &[String], filter: &str) -> bool { } /// The repos among `dirs` that `--include`/`--exclude` select (see -/// [`repo_filter::select`]); `names` lists the `.meta` names they may use. +/// [`repo_filter::select`]); `names` lists the `.meta.yaml` names they may use. fn select_repos( cli: &Cli, dirs: Vec, @@ -1512,8 +1512,8 @@ fn check_and_warn_orphan() { return; } - // Find the nearest .meta config - let Ok(Some((config_path, _))) = find_meta_config(¤t_dir, None) else { + // Find the nearest .meta.yaml + let Ok(Some(config_path)) = find_meta_config(¤t_dir, None) else { return; }; @@ -1536,24 +1536,13 @@ fn check_and_warn_orphan() { eprintln!(" Parent: {}", escape_path(&warning.parent)); eprintln!(); - // Show format-appropriate syntax eprintln!( " To include it, add to {}:", escape_path(&warning.parent_config) ); - match warning.parent_format { - ConfigFormat::Json => { - eprintln!( - " \"{}\": {{ \"repo\": \"\", \"meta\": true }}", - escape(&warning.suggested_key) - ); - } - ConfigFormat::Yaml => { - eprintln!(" {}:", escape(&warning.suggested_key)); - eprintln!(" repo: "); - eprintln!(" meta: true"); - } - } + eprintln!(" {}:", escape(&warning.suggested_key)); + eprintln!(" repo: "); + eprintln!(" meta: true"); eprintln!(); } } @@ -1741,26 +1730,15 @@ ignore: #[test] fn test_find_meta_config() { let dir = tempfile::tempdir().unwrap(); - let meta_path = dir.path().join(".meta"); + let meta_path = dir.path().join(".meta.yaml"); std::fs::write(&meta_path, r#"{"projects": {}}"#).unwrap(); let result = find_meta_config(dir.path(), None).unwrap(); assert!(result.is_some()); - let (path, _format) = result.unwrap(); + let path = result.unwrap(); assert_eq!(path, meta_path); } - #[test] - fn test_find_meta_config_rejects_ambiguity() { - let dir = tempfile::tempdir().unwrap(); - std::fs::write(dir.path().join(".meta"), r#"{"projects": {}}"#).unwrap(); - std::fs::write(dir.path().join(".meta.yaml"), "projects: {}").unwrap(); - let err = find_meta_config(dir.path(), None).unwrap_err().to_string(); - assert!(err.contains("Multiple meta config files")); - assert!(err.contains(".meta.yaml")); - assert!(err.contains(&escape_path(&dir.path().join(".meta")))); - } - #[test] fn test_parse_meta_config_with_tags() { let dir = tempfile::tempdir().unwrap(); @@ -1819,11 +1797,11 @@ projects: #[test] fn test_discover_nested_projects_no_nested() { let dir = tempfile::tempdir().unwrap(); - // Create a .meta with a project that has no nested .meta + // Create a .meta.yaml with a project that has no nested .meta.yaml let project_dir = dir.path().join("project1"); std::fs::create_dir(&project_dir).unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"project1": "git@github.com:org/project1.git"}}"#, ) .unwrap(); @@ -1840,9 +1818,9 @@ projects: // Create nested structure: // root/ - // .meta (contains project1) + // .meta.yaml (contains project1) // project1/ - // .meta (contains subproject) + // .meta.yaml (contains subproject) // subproject/ let project1_dir = dir.path().join("project1"); @@ -1850,12 +1828,12 @@ projects: std::fs::create_dir_all(&subproject_dir).unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"project1": "git@github.com:org/project1.git"}}"#, ) .unwrap(); std::fs::write( - project1_dir.join(".meta"), + project1_dir.join(".meta.yaml"), r#"{"projects": {"subproject": "git@github.com:org/subproject.git"}}"#, ) .unwrap(); @@ -1877,17 +1855,17 @@ projects: std::fs::create_dir_all(&level2).unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{"projects": {"level1": "git@github.com:org/level1.git"}}"#, ) .unwrap(); std::fs::write( - level1.join(".meta"), + level1.join(".meta.yaml"), r#"{"projects": {"level2": "git@github.com:org/level2.git"}}"#, ) .unwrap(); - // depth 0: no recursion into nested .meta + // depth 0: no recursion into nested .meta.yaml let tree_0 = config::walk_meta_tree(dir.path(), Some(0)).unwrap(); let paths_0 = config::flatten_meta_tree(&tree_0); assert_eq!(paths_0, vec!["level1"]); @@ -1909,7 +1887,7 @@ projects: std::fs::create_dir_all(&backend_dir).unwrap(); std::fs::write( - dir.path().join(".meta"), + dir.path().join(".meta.yaml"), r#"{ "projects": { "frontend": { @@ -1934,40 +1912,10 @@ projects: assert!(!has_backend, "Backend should be excluded (no 'ui' tag)"); } - #[test] - fn test_mixed_json_yaml_format() { - let dir = tempfile::tempdir().unwrap(); - - // Test that we can parse both JSON and YAML in different locations - let json_meta = dir.path().join(".meta"); - std::fs::write( - &json_meta, - r#"{"projects": {"project1": "git@github.com:org/p1.git"}}"#, - ) - .unwrap(); - - let (projects, _) = parse_meta_config(&json_meta).unwrap(); - assert_eq!(projects.len(), 1); - assert_eq!(projects[0].name, "project1"); - - // YAML version - let yaml_dir = tempfile::tempdir().unwrap(); - let yaml_meta = yaml_dir.path().join("config.yaml"); - std::fs::write( - &yaml_meta, - "projects:\n project2: git@github.com:org/p2.git\n", - ) - .unwrap(); - - let (yaml_projects, _) = parse_meta_config(&yaml_meta).unwrap(); - assert_eq!(yaml_projects.len(), 1); - assert_eq!(yaml_projects[0].name, "project2"); - } - #[test] fn test_extended_format_with_optional_path() { let dir = tempfile::tempdir().unwrap(); - let meta_path = dir.path().join(".meta"); + let meta_path = dir.path().join(".meta.yaml"); // Extended format without explicit path (should default to project name) std::fs::write( @@ -1996,34 +1944,14 @@ projects: let nested = dir.path().join("a").join("b").join("c"); std::fs::create_dir_all(&nested).unwrap(); - // Create .meta at root - let meta_path = dir.path().join(".meta"); + // Create .meta.yaml at root + let meta_path = dir.path().join(".meta.yaml"); std::fs::write(&meta_path, r#"{"projects": {}}"#).unwrap(); - // Search from nested directory should find root .meta + // Search from nested directory should find root .meta.yaml let result = find_meta_config(&nested, None).unwrap(); assert!(result.is_some()); - let (found_path, _) = result.unwrap(); + let found_path = result.unwrap(); assert_eq!(found_path, meta_path); } - - #[test] - fn test_yaml_file_extensions() { - let dir = tempfile::tempdir().unwrap(); - - // Test .yaml extension - let yaml_path = dir.path().join(".meta.yaml"); - std::fs::write(&yaml_path, "projects:\n p1: git@test.git\n").unwrap(); - - let result = find_meta_config(dir.path(), None).unwrap(); - assert!(result.is_some()); - - // Clean up and test .yml extension - std::fs::remove_file(&yaml_path).unwrap(); - let yml_path = dir.path().join(".meta.yml"); - std::fs::write(&yml_path, "projects:\n p2: git@test.git\n").unwrap(); - - let result = find_meta_config(dir.path(), None).unwrap(); - assert!(result.is_some()); - } } diff --git a/src/registry.rs b/src/registry.rs index b416eae..f7a1a09 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -115,20 +115,11 @@ pub enum InstallScope { // Future: Custom(PathBuf) for --path flag in M5 } -/// Whether `e` means the path does not exist: not found, or a part of it -/// that is a file (`.meta/plugins` where `.meta` is the config file). -fn missing(e: &std::io::Error) -> bool { - matches!( - e.kind(), - std::io::ErrorKind::NotFound | std::io::ErrorKind::NotADirectory - ) -} - impl PluginManifest { /// Load manifest from file, or return empty manifest if not found pub fn load(manifest_path: &Path) -> Result { let content = match std::fs::read_to_string(manifest_path) { - Err(e) if missing(&e) => return Ok(Self::default()), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Self::default()), result => result.with_context(|| { format!( "Failed to read manifest from {}", @@ -657,8 +648,8 @@ impl PluginInstaller { /// Find the nearest directory holding a config file (not a bare `.meta/`). fn find_workspace_root_from(start_dir: &Path) -> Result { meta_core::config::nearest_meta_dir(start_dir)?.ok_or_else(|| anyhow::anyhow!( - "Not in a meta workspace.\nExpected to find a config file: {}.\nCreate one here (e.g. .meta.yaml), or cd into a workspace.", - meta_core::config::META_CONFIG_NAMES.join(", ") + "Not in a meta workspace.\nExpected to find {} here or in a folder above.\nCreate one here, or cd into a workspace.", + meta_core::config::META_CONFIG_NAME )) } @@ -2133,21 +2124,6 @@ mod tests { ); } - #[test] - fn test_find_workspace_root_with_legacy_meta_file() { - let temp = tempfile::tempdir().unwrap(); - std::fs::write(temp.path().join(".meta"), r#"{"projects":{}}"#).unwrap(); - - let result = PluginInstaller::find_workspace_root_from(temp.path()); - - assert!(result.is_ok()); - // Canonicalize paths for comparison (handles /var vs /private/var on macOS) - assert_eq!( - result.unwrap().canonicalize().unwrap(), - temp.path().canonicalize().unwrap() - ); - } - #[test] fn test_find_workspace_root_fails_outside_workspace() { let temp = tempfile::tempdir().unwrap(); @@ -2159,6 +2135,7 @@ mod tests { let err_msg = result.unwrap_err().to_string(); assert!(err_msg.contains("Not in a meta workspace")); assert!(err_msg.contains("Create one here")); + assert!(err_msg.contains(".meta.yaml")); } #[test] diff --git a/src/repo_filter.rs b/src/repo_filter.rs index bb54a22..6d0d32e 100644 --- a/src/repo_filter.rs +++ b/src/repo_filter.rs @@ -4,7 +4,7 @@ use anyhow::{bail, Result}; use meta_core::config::{MetaTreeNode, ProjectInfo}; use std::path::{Component, Path, PathBuf}; -/// (`.meta` name, path from `meta_dir`) for `projects`, and for every project +/// (`.meta.yaml` name, path from `meta_dir`) for `projects`, and for every project /// nested under `tree` (the result of walking the same meta root). Paths are /// in the same form as [`select`] gives the repos it chooses among. pub fn repo_names( @@ -29,7 +29,7 @@ pub fn repo_names( /// The repos among `dirs` that `include` and `exclude` select, in order. /// -/// A value names a repo by its `.meta` name (from `names`, see +/// A value names a repo by its `.meta.yaml` name (from `names`, see /// [`repo_names`]) or by its whole path from `root` (`.` for the root; a /// trailing `/` is ignored), never by a part of either. A value starting with /// `./` is a path only. Repos are compared as directories, so excluding one @@ -85,7 +85,7 @@ pub fn select( let value = meta_core::display::escape(value); if by_name.len() > 1 { bail!( - "{flag} '{value}' is the .meta name of the repos at {}; name one by its path, \ + "{flag} '{value}' is the .meta.yaml name of the repos at {}; name one by its path, \ as ./", listed(&by_name) ); @@ -94,7 +94,7 @@ pub fn select( |repos: &[&Repo]| -> Vec { repos.iter().map(|r| r.id.clone()).collect() }; if !by_path.is_empty() && !by_name.is_empty() && ids(&by_path) != ids(&by_name) { bail!( - "{flag} '{value}' names the repo at {} by path and the repo at {} by .meta \ + "{flag} '{value}' names the repo at {} by path and the repo at {} by .meta.yaml \ name; name the one you mean by its path, as ./", listed(&by_path), listed(&by_name) @@ -104,7 +104,7 @@ pub fn select( if hits.is_empty() { bail!( "{flag} '{value}' names none of the repos this command runs in. Use a repo's \ - name from .meta or its path from the workspace root (`.` for the root), as \ + name from .meta.yaml or its path from the workspace root (`.` for the root), as \ `meta project list` shows it; in a worktree set, the same, from the set's root. --tag and \ --recursive change which repos the command runs in." ); @@ -358,7 +358,9 @@ mod tests { // `web` is one repo's path and another's name let err = select("web").unwrap_err().to_string(); assert!( - err.contains("names the repo at web by path and the repo at frontend by .meta name"), + err.contains( + "names the repo at web by path and the repo at frontend by .meta.yaml name" + ), "{err}" ); } @@ -378,7 +380,7 @@ mod tests { let select = |value: &str| select(&strings(&[value]), &[], &dirs, &root, &names); let err = select("api").unwrap_err().to_string(); assert!( - err.contains("is the .meta name of the repos at api, group/api"), + err.contains("is the .meta.yaml name of the repos at api, group/api"), "{err}" ); // A ./ path picks one, with a relative root as with an absolute one diff --git a/src/subprocess_plugins.rs b/src/subprocess_plugins.rs index d4b703e..671ba08 100644 --- a/src/subprocess_plugins.rs +++ b/src/subprocess_plugins.rs @@ -187,15 +187,7 @@ impl SubprocessPluginManager { let entries = match std::fs::read_dir(dir) { Ok(entries) => entries, - // A legacy `.meta` config file in place of the `.meta/` folder means no plugins - Err(e) - if matches!( - e.kind(), - std::io::ErrorKind::NotFound | std::io::ErrorKind::NotADirectory - ) => - { - return Ok(()) - } + Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(()), Err(e) => { eprintln!( "Warning: Cannot read plugins directory {}: {}; skipping", diff --git a/src/worktree.rs b/src/worktree.rs index 617c8c2..3fc1c19 100644 --- a/src/worktree.rs +++ b/src/worktree.rs @@ -74,7 +74,7 @@ pub fn set_config( set_dir: &Path, members: &[PathBuf], config_name: Option<&PathBuf>, -) -> Result> { +) -> Result> { use meta_core::config; if let Some(found) = config::meta_config_at(set_dir, config_name)? { return Ok(Some(found)); @@ -155,7 +155,7 @@ fn readable_tree( let children = nested .as_ref() .filter(|_| visited.insert(path.canonicalize().unwrap_or_else(|_| path.clone()))) - .and_then(|(config, _)| config::parse_meta_config(config).ok()) + .and_then(|config| config::parse_meta_config(config).ok()) .map(|(projects, _)| readable_tree(&path, &projects, visited)) .unwrap_or_default(); config::MetaTreeNode { @@ -578,7 +578,7 @@ mod recursive_tests { let config = |dir: &Path, projects: &str| { std::fs::create_dir_all(dir).unwrap(); std::fs::write( - dir.join(".meta.json"), + dir.join(".meta.yaml"), format!(r#"{{"projects": {{{projects}}}}}"#), ) .unwrap(); @@ -586,7 +586,7 @@ mod recursive_tests { config(&workspace, r#""parent": {"repo": "x", "meta": true}"#); config(&workspace.join("parent"), r#""x": "x""#); let (projects, _) = - meta_core::config::parse_meta_config(&workspace.join(".meta.json")).unwrap(); + meta_core::config::parse_meta_config(&workspace.join(".meta.yaml")).unwrap(); let tree = meta_core::config::walk_projects(&workspace, &projects, None).unwrap(); // the set doesn't hold parent: the workspace's config tells about x diff --git a/tests/examples/.meta b/tests/examples/.meta deleted file mode 100644 index 351cb8e..0000000 --- a/tests/examples/.meta +++ /dev/null @@ -1,7 +0,0 @@ -{ - "projects": { - "project1": "project1", - "project2": "project2" - }, - "ignore": [".git"] -} diff --git a/tests/examples/.meta2 b/tests/examples/.meta2 deleted file mode 100644 index c03f147..0000000 --- a/tests/examples/.meta2 +++ /dev/null @@ -1,8 +0,0 @@ -{ - "projects": { - "project1": "project1", - "project2": "project2", - "project3": "project3" - }, - "ignore": [".git"] -} diff --git a/tests/plugin_discovery.rs b/tests/plugin_discovery.rs index c6be992..0d6d1ca 100644 --- a/tests/plugin_discovery.rs +++ b/tests/plugin_discovery.rs @@ -210,24 +210,8 @@ fn local_list_from_subdirectory_uses_real_path_and_binary_version() { } #[test] -fn ambiguous_configs_and_explicit_config_errors_are_escaped() { +fn missing_config_errors_are_escaped() { let f = Fixture::new(true); - fs::write(f.cwd.join(".meta.json"), "{}").unwrap(); - // Help still prints, with a warning; a command that needs the config fails - for (args, works) in [ - (vec!["--help"], true), - (vec!["plugin", "list", "--local"], false), - ] { - let output = f.run(&args); - assert_eq!(output.status.success(), works, "{args:?}"); - let err = String::from_utf8_lossy(&output.stderr); - assert!(err.contains("Multiple meta config files"), "{err}"); - assert!( - err.contains(".meta.json") && err.contains(".meta.yaml"), - "{err}" - ); - } - fs::remove_file(f.cwd.join(".meta.json")).unwrap(); let output = f.run(&["--config", "absent\u{1b}\nFORGED", "exec", "--", "true"]); let err = String::from_utf8_lossy(&output.stderr); assert!( @@ -238,10 +222,7 @@ fn ambiguous_configs_and_explicit_config_errors_are_escaped() { fs::remove_file(f.cwd.join(".meta.yaml")).unwrap(); let output = f.run(&["exec", "--", "true"]); let err = String::from_utf8_lossy(&output.stderr); - assert!( - err.contains("'.meta / .meta.json / .meta.yaml / .meta.yml'"), - "{err}" - ); + assert!(err.contains("'.meta.yaml'"), "{err}"); } #[test] @@ -312,40 +293,49 @@ fn local_install_gitignores_untracked_plugin_files() { #[test] fn orphan_hint_names_actual_parent_config() { - for name in [".meta.json", ".meta.yml"] { - let f = Fixture::new(true); - let parent_config = f.home.join(name); - fs::write( - &parent_config, - if name.ends_with("json") { - "{\"projects\":{}}" - } else { - "projects: {}" - }, - ) - .unwrap(); - let output = f.run(&["--help"]); - assert!(output.status.success()); - let err = String::from_utf8_lossy(&output.stderr); - // meta names the parent by its resolved path (/private/var on macOS) - let parent_config = f.home.canonicalize().unwrap().join(name); + let f = Fixture::new(true); + fs::write(f.home.join(".meta.yaml"), "projects: {}").unwrap(); + let output = f.run(&["--help"]); + assert!(output.status.success()); + let err = String::from_utf8_lossy(&output.stderr); + // meta names the parent by its resolved path (/private/var on macOS) + let parent_config = f.home.canonicalize().unwrap().join(".meta.yaml"); + assert!( + err.contains(&format!( + "To include it, add to {}:", + parent_config.display() + )), + "{err}" + ); +} + +#[test] +fn old_config_names_are_not_a_workspace() { + for name in [".meta", ".meta.json", ".meta.yml"] { + let f = Fixture::new(false); + fs::write(f.cwd.join(name), "{\"projects\": {}}\n").unwrap(); + let out = f.run(&["exec", "--", "true"]); + assert!(!out.status.success(), "{name}"); + let err = String::from_utf8_lossy(&out.stderr); assert!( - err.contains(&format!( - "To include it, add to {}:", - parent_config.display() - )), + err.contains("Could not find meta config file '.meta.yaml'"), "{err}" ); } } #[test] -fn legacy_meta_config_file_means_no_project_plugins_without_a_warning() { - let f = Fixture::new(false); - fs::write(f.cwd.join(".meta"), "{\"projects\": {}}\n").unwrap(); - let out = f.run(&["exec", "--", "true"]); +fn a_meta_file_where_the_folder_goes_is_not_taken_for_no_plugins() { + let f = Fixture::new(true); + fs::write(f.cwd.join(".meta"), "{}\n").unwrap(); + let out = f.run(&["--help"]); assert!(out.status.success()); - assert_eq!(String::from_utf8_lossy(&out.stderr), ""); + let err = String::from_utf8_lossy(&out.stderr); + assert!(err.contains("Cannot read plugins directory"), "{err}"); + let out = f.run(&["plugin", "list", "--local"]); + assert!(!out.status.success()); + let err = String::from_utf8_lossy(&out.stderr); + assert!(err.contains("Failed to read manifest"), "{err}"); } #[test] diff --git a/tests/plugin_git.rs b/tests/plugin_git.rs index 4c7936b..7de0d2c 100644 --- a/tests/plugin_git.rs +++ b/tests/plugin_git.rs @@ -289,7 +289,7 @@ use std::process::Command; #[test] fn test_meta_git_clone_invalid_repo() { let dir = tempdir().unwrap(); - let meta_path = dir.path().join(".meta"); + let meta_path = dir.path().join(".meta.yaml"); fs::write( &meta_path, r#"{ @@ -314,7 +314,7 @@ fn test_meta_git_clone_invalid_repo() { #[test] fn test_meta_dry_run_flag() { let dir = tempdir().unwrap(); - let meta_path = dir.path().join(".meta"); + let meta_path = dir.path().join(".meta.yaml"); fs::write( &meta_path, r#"{ @@ -344,8 +344,8 @@ fn malformed_worktree_membership_is_reported_before_dispatch() { let root = temp.path().canonicalize().unwrap(); let worktree = root.join(".worktrees/broken"); fs::create_dir_all(&worktree).unwrap(); - fs::write(root.join(".meta"), r#"{"projects":{}}"#).unwrap(); - fs::write(worktree.join(".meta"), r#"{"projects":{}}"#).unwrap(); + fs::write(root.join(".meta.yaml"), r#"{"projects":{}}"#).unwrap(); + fs::write(worktree.join(".meta.yaml"), r#"{"projects":{}}"#).unwrap(); fs::write(worktree.join(".git"), "malformed metadata").unwrap(); let marker = root.join("unexpected-dispatch"); let output = std::process::Command::new(env!("CARGO_BIN_EXE_meta")) diff --git a/tests/plugin_routing.rs b/tests/plugin_routing.rs index 166f4dd..2603aaa 100644 --- a/tests/plugin_routing.rs +++ b/tests/plugin_routing.rs @@ -10,7 +10,7 @@ use tempfile::tempdir; /// `touch` and logs each request it receives instead of running it. fn workspace(root: &Path) { fs::write( - root.join(".meta"), + root.join(".meta.yaml"), r#"{"projects":{"a":"https://example.invalid/a.git","b":"https://example.invalid/b.git"}}"#, ) .unwrap();