Community plugin manifests can only copy individual files, not directories

Open
#227 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
65/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
go

Research direction

Start with internal/plugin/local.go, especially localManifest, validate, and Files, then trace how installed files are recorded in .grit/plugins.lock.json and replayed by grit plugin remove. Check the grit plugin new skeleton for its file entries. Done when directory entries install their files recursively, directory sources in files produce a clear validation error, and removal still works from the per-file lock entries.

Written by the indexing model from the issue text.

Description

A community plugin manifest lists every file it installs one by one. There is no way to map a directory, so a plugin that installs several files under the same destination has to repeat the same to prefix and the same when clause for every file.

Where this comes from

internal/plugin/local.go:

type localManifest struct {
    Files []localFile `json:"files"`
    // ...
}

type localFile struct {
    From string     `json:"from"` // relative to the plugin directory
    To   string     `json:"to"`   // relative to the project root
    When whenClause `json:"when"`
}

validate calls os.Stat on from, and the Files function calls os.ReadFile. A directory passes the stat but fails the read, and the file is silently skipped. So files/components as a from value installs nothing and reports success.

Why it matters

I am writing grit-calendar as a community plugin. Its source is grouped as files/config, files/components, files/pages and files/tests, but plugin.json still needs nine files entries, each with its own from, to and when. Adding a new component means editing both the tree and the manifest, and the two can drift. The grit plugin new skeleton has the same shape: one entry per file.

Proposal

An optional directories array alongside files, for example:

"directories": [
  {
    "from": "files/components",
    "to": "apps/admin/components/calendar",
    "when": { "architecture": ["triple"], "frontend": ["next"] }
  }
]

Install walks it recursively. Each written file still goes into .grit/plugins.lock.json as its own entry, so grit plugin remove keeps replaying the install exactly and needs no second list. Explicit files entries would cover exceptions and single files.

Two small things would come with it:

  1. validate should reject a directory in files[].from with a clear message instead of skipping it at install time.
  2. The grit plugin new skeleton could use a directory entry for files/api and files/admin, which would make generated plugins much shorter.

This is an enhancement, not a blocker. The current file-level mechanism works and removal is correct.

Dominant language
Go
Stars
152
Forks
20
Avg merge
1d 49m
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MUKE-coder/grit

All issues in MUKE-coder/grit

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.