Skip to content

Conversation

@boblail
Copy link
Member

@boblail boblail commented Dec 30, 2025

For the most part, this splits some procedural logic in discovery.go into four contracts that are tested in order. These are:

Contract Description
DirectoryContract a directory that contains the module metadata file
ExecutableContract an executable the has the extension .exoskeleton and responds to --describe-commands
ShellScriptContract a shell script can provide its summary and help via magic comments
StandaloneExecutableContract any other executable is expected to respond to --summary

This refactor does two things:

  1. It makes these four contracts explicit concepts
  2. It allows clients to control support for each

There is one (known) behavioral change: the first to bytes of executables are read eagerly. This incurs a cost of 80µs per command (or 19ms for 240 commands) — so far I'm not concerned.

@boblail boblail force-pushed the lail/contracts branch 5 times, most recently from 9d1c2da to 8b9773c Compare December 30, 2025 23:19
Comment on lines +35 to +41
buffer := make([]byte, 2)
if _, err := f.Read(buffer); err != nil {
return nil, err
}
if string(buffer) != "#!" {
return nil, ErrNotApplicable // Not a shell script
}
Copy link
Member Author

Choose a reason for hiding this comment

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

👀 This is a behavior change.

We're opening shell scripts more eagerly — during discovery (which adds an up-front cost to every execution) rather than only when needing summary (such as when rendering a menu of commands).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants