Skip to content

fix: support custom output directory in skill init#281

Merged
peterj merged 6 commits intoagentregistry-dev:mainfrom
optimus-fulcria:fix/skill-init-output-dir
Mar 10, 2026
Merged

fix: support custom output directory in skill init#281
peterj merged 6 commits intoagentregistry-dev:mainfrom
optimus-fulcria:fix/skill-init-output-dir

Conversation

@optimus-fulcria
Copy link
Copy Markdown
Contributor

@optimus-fulcria optimus-fulcria commented Mar 6, 2026

Description

Support a custom output directory in skill init so users can specify where the skill project is created.

What changed:

  • Added --output-dir flag to skill init
  • Extracted resolveProjectPath helper function for path resolution logic
  • Added unit test for resolveProjectPath
  • Fixed path resolution on skill generation to properly use config.Directory instead of config.ProjectName.

Change Type

/kind fix

Changelog

Support custom output directory in skill init

Validation

# init skill normally (/test1/
go run cmd/cli/main.go skill init test1

# init to output-dir (./skillz/test1/)
go run cmd/cli/main.go skill init test1 --output-dir ./skillz

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

You already have 3 pull requests open. Please consider working on getting the existing ones merged before opening new ones. Thanks!

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

You already have 3 pull requests open. Please consider working on getting the existing ones merged before opening new ones. Thanks!

@optimus-fulcria
Copy link
Copy Markdown
Contributor Author

Done in c4e6873 — extracted resolveProjectPath() helper function with unit tests covering: relative path, absolute path, empty (defaults to cwd), and tilde expansion.

@peterj
Copy link
Copy Markdown
Contributor

peterj commented Mar 6, 2026

Please check the linter issues @optimus-fulcria

Optimus (AI Agent) and others added 3 commits March 7, 2026 00:09
`arctl skill init myskill ./skills/` now creates the project at
./skills/myskill/ instead of requiring the skill to always be created
in the current directory.

Fixes agentregistry-dev#196

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Address review feedback: extract path resolution logic into a helper
function and add a table-driven unit test covering no output dir,
absolute output dir, and relative output dir cases.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add tests for empty extraArgs slice and empty string extraArg to
ensure the helper correctly falls back to the default behavior.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

You already have 3 pull requests open. Please consider working on getting the existing ones merged before opening new ones. Thanks!

@optimus-fulcria
Copy link
Copy Markdown
Contributor Author

Done in c4e6873: extracted resolveProjectPath helper function and added a unit test for it.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

You already have 3 pull requests open. Please consider working on getting the existing ones merged before opening new ones. Thanks!

len() for nil slices returns zero, so the nil check is unnecessary.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

You already have 3 pull requests open. Please consider working on getting the existing ones merged before opening new ones. Thanks!

@peterj
Copy link
Copy Markdown
Contributor

peterj commented Mar 9, 2026

This doesn't work - if tells me the skill was created in the /subfolder, but it wasn't.

can you please NOT use AI and actually test the functionality, so it works as it's supposed to work?

 arctl skill init myskill subfolder
To build the skill:
        arctl skill publish --docker-url <docker-url> /Users/peterj/projects/agentregistry/subfolder/myskill
For example:
        arctl skill publish --docker-url docker.io/myorg /Users/peterj/projects/agentregistry/subfolder/myskill
  arctl skill publish --docker-url ghcr.io/myorg /Users/peterj/projects/agentregistry/subfolder/myskill
  arctl skill publish --docker-url localhost:5001/myorg /Users/peterj/projects/agentregistry/subfolder/myskill

Copy link
Copy Markdown
Contributor

@peterj peterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please manually test your PRs.

Copy link
Copy Markdown
Collaborator

@inFocus7 inFocus7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the generation logic we use config directory for some git logic, and the project name for generation. We need to fix it to use the config.Directory for project generation. This is a pre-existing bug, which is why it fails to create the directory locally for the init (cc @peterj)

err = templates.NewGenerator().GenerateProject(templates.ProjectConfig{
	NoGit:       initNoGit,
	Directory:   projectPath,
	Verbose:     false,
	ProjectName: projectName,
	Empty:       initEmpty,
})
// we create skill here
destPath := filepath.Join(config.ProjectName, strings.TrimSuffix(path, ".tmpl"))
if !config.NoGit {
	if err := g.initGitRepo(config.Directory, config.Verbose); err != nil {
		// Don't fail the whole operation if git init fails
		if config.Verbose {
			fmt.Printf("Warning: failed to initialize git repository: %v\n", err)
		}
	}
}

We'd need to update destPath to destPath := filepath.Join(config.Directory, strings.TrimSuffix(path, ".tmpl")).


On a side-but-relevant note, I'd prefer if this was a CLI flag as shown in the description, instead of a positional argument. Output directory is optional, so if we for any reason add any more required positional arguments, this will either get confusing (i.e. arctl skill init test "" argument2) or require breaking CLI command updates to reorder. My opinion though, not sure what others may think.

Signed-off-by: Fabian Gonzalez <[email protected]>
Signed-off-by: Fabian Gonzalez <[email protected]>
@inFocus7 inFocus7 requested review from inFocus7 and peterj March 10, 2026 18:41
Copy link
Copy Markdown
Collaborator

@inFocus7 inFocus7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved some of the comments I had made. I technically approve this, although would be better to get additional reviewer as I made some changes here.

Thanks for the contribution!

@inFocus7 inFocus7 enabled auto-merge March 10, 2026 19:05
@inFocus7 inFocus7 disabled auto-merge March 10, 2026 19:05
Copy link
Copy Markdown
Contributor

@peterj peterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks & works good!

@peterj peterj dismissed inFocus7’s stale review March 10, 2026 20:25

I think you address your comment from yesterday:)

@peterj peterj added this pull request to the merge queue Mar 10, 2026
Merged via the queue into agentregistry-dev:main with commit f97b8fc Mar 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants