chore: add MIT LICENSE file#62
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an MIT LICENSE file and introduces a shared scaffolding FileWriter to centralize “create-if-missing” file creation logic, refactoring waza init and waza new to use it.
Changes:
- Add repository
LICENSE(MIT). - Add
internal/scaffoldFileWriter+ unit tests to safely create missing files and report outcomes. - Refactor
cmd/wazainit/new scaffolding to useFileWriterand print outcomes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
LICENSE |
Adds the MIT License text. |
internal/scaffold/writer.go |
New helper to write files idempotently (create missing, skip existing) and return an inventory. |
internal/scaffold/writer_test.go |
Unit tests for FileWriter behavior (create, skip, inventory, mkdir parents). |
cmd/waza/cmd_new.go |
Refactors skill scaffolding write loop to use FileWriter, with special handling for overwrite cases. |
cmd/waza/cmd_init.go |
Refactors project initialization file creation to use FileWriter and adjusts summary logic. |
| var overwriteFiles []fileEntry | ||
|
|
||
| for _, f := range files { | ||
| if f.overwrite { | ||
| overwriteFiles = append(overwriteFiles, f) | ||
| } else { |
There was a problem hiding this comment.
overwriteFiles is collected but never used. In Go this causes a compile error (unused variable) and will fail the build/tests. Remove it or use it (e.g., process overwrite entries separately without keeping a second slice).
| var overwriteFiles []fileEntry | |
| for _, f := range files { | |
| if f.overwrite { | |
| overwriteFiles = append(overwriteFiles, f) | |
| } else { | |
| for _, f := range files { | |
| if !f.overwrite { |
| if f.overwrite { | ||
| // Handle overwrite files (malformed SKILL.md repair) | ||
| if _, statErr := os.Stat(f.path); statErr == nil { | ||
| if err := os.WriteFile(f.path, []byte(f.content), 0o644); err != nil { | ||
| return fmt.Errorf("failed to write %s: %w", f.path, err) | ||
| } | ||
| fmt.Fprintf(cmd.OutOrStdout(), " %s %-40s %s (updated)\n", yellowPlus, relPath, f.label) //nolint:errcheck | ||
| created++ | ||
| continue | ||
| } | ||
| fmt.Fprintf(cmd.OutOrStdout(), " %s %-40s %s\n", greenCheck, relPath, f.label) //nolint:errcheck | ||
| continue | ||
| } | ||
|
|
||
| if err := os.WriteFile(f.path, []byte(f.content), 0o644); err != nil { | ||
| return fmt.Errorf("failed to write %s: %w", f.path, err) | ||
| } else { |
There was a problem hiding this comment.
The new overwrite handling only writes when the target file already exists. Previously, overwrite entries were still created when missing; now a missing file with overwrite=true will be silently skipped (no write and no output), which changes scaffolding behavior and can leave required files absent. Update the logic to create the file when it doesn't exist (and only overwrite when it does).
See below for a potential fix:
existed := true
if _, statErr := os.Stat(f.path); statErr != nil {
if os.IsNotExist(statErr) {
existed = false
} else {
return fmt.Errorf("failed to stat %s: %w", f.path, statErr)
}
}
if err := os.WriteFile(f.path, []byte(f.content), 0o644); err != nil {
return fmt.Errorf("failed to write %s: %w", f.path, err)
}
if existed {
fmt.Fprintf(cmd.OutOrStdout(), " %s %-40s %s (updated)\n", yellowPlus, relPath, f.label) //nolint:errcheck
} else {
fmt.Fprintf(cmd.OutOrStdout(), " %s %-40s %s (created)\n", yellowPlus, relPath, f.label) //nolint:errcheck
}
created++
| func (w *FileWriter) writeFile(entry FileEntry) (FileOutcome, error) { | ||
| // Check if file exists | ||
| if _, err := os.Stat(entry.Path); err == nil { | ||
| return FileSkipped, nil |
There was a problem hiding this comment.
writeFile treats any os.Stat error as "file missing" and proceeds to create/write. This can mask permission/I/O errors and may write in cases where the path exists but can't be stated. Only skip/create when the error is os.ErrNotExist; for other errors, return a wrapped error.
| return FileSkipped, nil | |
| return FileSkipped, nil | |
| } else if !os.IsNotExist(err) { | |
| return "", fmt.Errorf("failed to stat %s: %w", entry.Path, err) |
| @@ -549,11 +563,19 @@ func initCommandE(cmd *cobra.Command, args []string, noSkill bool, flagSkillsDir | |||
| relPath += string(filepath.Separator) | |||
| } | |||
|
|
|||
| if existed { | |||
| if item.isDir { | |||
| // Directories always show as existing (we created them if needed above) | |||
| indicator = "{exist}" | |||
There was a problem hiding this comment.
Directory items are always displayed as existing (✅) even when they were just created by the MkdirAll pass. This makes the inventory output inaccurate and can confuse the "created" summary. Consider checking whether the directory existed before creating it (e.g., os.Stat / errors.Is(err, os.ErrNotExist)) and set the indicator accordingly.
| MIT License | ||
|
|
||
| Copyright (c) 2026 Microsoft Corporation |
There was a problem hiding this comment.
PR metadata says this change only adds an MIT LICENSE file, but this PR also introduces a new internal/scaffold FileWriter and refactors waza init/new file-writing logic. Please update the PR title/description (or split into separate PRs) so reviewers understand the full scope and risk of the changes.
|
Closing — branch got crossed with FileWriter scaffold changes during concurrent agent execution. Will re-create with LICENSE file only. |
Pull request was closed
Packages waza as an azd extension, allowing users to run waza commands via azd waza <command>. Contributes to microsoft#62 ## What's New - extension.yaml — Extension manifest defining microsoft.azd.waza with commands: init, generate, run, compare, tokens - build.ps1 / build.sh — Cross-platform build scripts for creating extension binaries (Windows, macOS, Linux across amd64/arm64) - registry.json — Extension registry metadata for distribution (for testing only) - version.txt — Version tracking file ## Usage ### Install the custom extension source used while testing ``` azd ext source add -n waza -t url -l "https://raw.githubusercontent.com/wbreza/waza/refs/heads/azd-extension/registry.json" ``` ### Install the extension ``` azd extension install microsoft.azd.waza ``` ### Run waza commands through azd ``` azd waza run examples/code-explainer/eval.yaml -v azd waza init my-eval --interactive ```
Closes #1
This PR adds the standard MIT License file to the repository as referenced in the README.
Using MIT License with Microsoft Corporation as the copyright holder (2026), which is the standard license used by Microsoft open source projects.