-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat: implement .apply REPL dot-command (Approach 1: Minimalist Function Injection) #1789
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 all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
bc45478
Initial plan
Copilot 56b48ff
Merge branch 'main' into copilot/implement-apply-command-design
pmcelhaney 965dc4e
feat: implement .apply REPL command (Approach 1: Minimalist Function …
Copilot 9c431c1
fix: address code review feedback - rename test params, add path trav…
Copilot ad25c0c
docs: add .apply command documentation to usage.md
Copilot 3bdc527
feat: update ApplyContext to import Context type; generate default sc…
Copilot 18a7690
fix: use generic example code in default scenarios/index.ts scaffold
Copilot dacc7d6
feat: scan for _.context.ts files to generate narrowed loadContext ov…
Copilot 8571e86
fix: improve parameter name sanitization and strengthen ordering test…
Copilot ba514bb
Merge branch 'main' into copilot/implement-apply-command-design
pmcelhaney b08a259
feat: add tab completion for .apply command in the REPL
Copilot 6ed61e5
fix: document export regex limitation and strengthen tab completion t…
Copilot 0f9bf16
fix: restrict .apply tab completion to exported functions only
Copilot fb4b293
feat: add ScenarioRegistry; move scenario loading from REPL to Module…
Copilot 46856c2
refactor: fix async test and add JSDoc to createCompleter
Copilot 87415e3
fix: resolve build errors and address code review feedback
Copilot 10937d0
refactor: rename method and extract regex constant per code review
Copilot 726a06f
feat: update scenarios/index.ts scaffold with JSDoc comments and help…
Copilot 4cdebd5
feat: rename apply-context.ts to scenario-context.ts, add Scenario ty…
Copilot 85db3c2
feat: regenerate scenario-context.ts when _.context.ts files change a…
Copilot 5505dcf
refactor: extract isContextFile helper in ModuleLoader
Copilot e8dd300
refactor: use EventTarget event instead of callback for context-file-…
Copilot ac90080
Merge branch 'main' into copilot/implement-apply-command-design
pmcelhaney e1f0e25
refactor: make ContextRegistry an EventTarget, dispatch context-chang…
Copilot 785ca5b
fix: use correct path key when removing context from ContextRegistry …
Copilot 795a039
docs: add JSDoc to ContextRegistry.remove(), simplify context path no…
Copilot 6e7eca0
Merge branch 'main' into copilot/implement-apply-command-design
pmcelhaney fcb0d05
fix code formatting
pmcelhaney 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| "counterfact": minor | ||
| --- | ||
|
|
||
| Add `.apply` REPL dot-command (Approach 1: Minimalist Function Injection). | ||
|
|
||
| The `.apply` command lets you run scenario scripts from the REPL prompt without leaving the terminal. A scenario is a plain TypeScript (or JavaScript) file that exports named functions. Each function receives an `ApplyContext` object with `{ context, loadContext, routes, route }` and can freely read or mutate state. | ||
|
|
||
| **Path resolution:** | ||
|
|
||
| | Command | File | Function | | ||
| |---|---|---| | ||
| | `.apply foo` | `scenarios/index.ts` | `foo` | | ||
| | `.apply foo/bar` | `scenarios/foo.ts` | `bar` | | ||
| | `.apply foo/bar/baz` | `scenarios/foo/bar.ts` | `baz` | | ||
|
|
||
| The `ApplyContext` type is written to `types/apply-context.ts` during code generation. |
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
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.
When
scenarioRegistryis not provided, the.applycompleter callscallback(null, [[], line]). In Node’s REPL completer API the second tuple element should be the word to replace (here the.applyargument partial), not the full input line; returninglinecan cause completion to behave incorrectly. Computepartialfrom the regex match unconditionally and return[[], partial]in this branch.