-
Notifications
You must be signed in to change notification settings - Fork 12
feat: file mode — write graph files from analyze, add watch/clean/hook #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1e330bb
feat: add sidecars vertical slice with generate/watch/clean/hook/render
greynewell c97b1bd
refactor: replace sidecars subcommand with integrated file mode
greynewell 0530e9c
fix: address all golangci-lint issues in internal/files
greynewell 6a38eec
fix: extract pollLoop helper, fix changedFiles dropped on incremental…
greynewell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/supermodeltools/cli/internal/config" | ||
| "github.com/supermodeltools/cli/internal/files" | ||
| ) | ||
|
|
||
| func init() { | ||
| var dryRun bool | ||
|
|
||
| c := &cobra.Command{ | ||
| Use: "clean [path]", | ||
| Short: "Remove all .graph.* files from the repository", | ||
| Args: cobra.MaximumNArgs(1), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| cfg, err := config.Load() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| dir := "." | ||
| if len(args) > 0 { | ||
| dir = args[0] | ||
| } | ||
| return files.Clean(cmd.Context(), cfg, dir, dryRun) | ||
| }, | ||
| } | ||
|
|
||
| c.Flags().BoolVar(&dryRun, "dry-run", false, "show what would be removed without removing") | ||
| rootCmd.AddCommand(c) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/supermodeltools/cli/internal/files" | ||
| ) | ||
|
|
||
| func init() { | ||
| var port int | ||
|
|
||
| c := &cobra.Command{ | ||
| Use: "hook", | ||
| Short: "Forward Claude Code file-change events to the watch daemon", | ||
| Long: `Reads a Claude Code PostToolUse JSON payload from stdin and forwards the file path to the running watch daemon via UDP. Install as a PostToolUse hook in .claude/settings.json.`, | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return files.Hook(port) | ||
| }, | ||
| } | ||
|
|
||
| c.Flags().IntVar(&port, "port", 7734, "UDP port of the watch daemon") | ||
| rootCmd.AddCommand(c) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/supermodeltools/cli/internal/config" | ||
| "github.com/supermodeltools/cli/internal/files" | ||
| ) | ||
|
|
||
| func init() { | ||
| var opts files.WatchOptions | ||
|
|
||
| c := &cobra.Command{ | ||
| Use: "watch [path]", | ||
| Short: "Generate graph files on startup, then keep them updated as you code", | ||
| Long: `Runs a full generate on startup (using cached graph if available), then | ||
| enters daemon mode. Listens for file-change notifications from the | ||
| 'supermodel hook' command and incrementally re-renders affected files. | ||
|
|
||
| Press Ctrl+C to stop and remove graph files.`, | ||
| Args: cobra.MaximumNArgs(1), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| cfg, err := config.Load() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if err := cfg.RequireAPIKey(); err != nil { | ||
| return err | ||
| } | ||
| dir := "." | ||
| if len(args) > 0 { | ||
| dir = args[0] | ||
| } | ||
| return files.Watch(cmd.Context(), cfg, dir, opts) | ||
| }, | ||
| } | ||
|
|
||
| c.Flags().StringVar(&opts.CacheFile, "cache-file", "", "override cache file path") | ||
| c.Flags().DurationVar(&opts.Debounce, "debounce", 2*time.Second, "debounce duration before processing changes") | ||
| c.Flags().IntVar(&opts.NotifyPort, "notify-port", 7734, "UDP port for hook notifications") | ||
| c.Flags().BoolVar(&opts.FSWatch, "fs-watch", false, "enable git-poll fallback") | ||
| c.Flags().DurationVar(&opts.PollInterval, "poll-interval", 3*time.Second, "git poll interval when --fs-watch is enabled") | ||
|
|
||
| rootCmd.AddCommand(c) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the shutdown help text.
Line 22 says Ctrl+C removes graph files, but the current shutdown path only stops the daemon. Cleanup is a separate flow, so this text is promising behavior that does not happen.
Suggested text
📝 Committable suggestion
🤖 Prompt for AI Agents