-
Notifications
You must be signed in to change notification settings - Fork 46
(cli): Indent-Based Code Formatter #454
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
(cli): Indent-Based Code Formatter #454
Conversation
thank you for your contributing |
@@ -14,3 +14,31 @@ describe("formatWithPrettier", () => { | |||
expect(result).toBe(content); | |||
}); | |||
}); | |||
|
|||
describe("insertWithIndent", () => { |
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.
test code looks good
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.
Hi! @luke0408
the code looks good!!
I'd like to change a few things.
- remove prettier from package.json. we don't need them anymore
- remove implementation of prettier and replace them in
commands/start.ts
- add new package names in
build.config.ts
, otherwise unbuild operation fails. you can check by executingpnpm run build
I'll update this part before the work is finalized and merged. :) |
So that means the overall code structure looks good—glad to hear that! I was a bit concerned since the structure differs from the original, but now I feel more confident to move on to the next step. I'll make the changes you mentioned shortly. |
Also, would it be okay to add I'm currently working in the "Firebase Studio" environment, and in order to use I think adding it to |
I'm fine with it. Therefore, I think we need to check ryoppippi's opinion again. |
While running Could this be an issue with my environment? |
Hi @luke0408
I think you can include the change in this PR. Anything merged into main in this repository may be published at any time. It would also be nice if you could verify that start.ts works well without prettier as this PR is intended to replace prettier.
I don't think it is a good idea :(
On the CI environment, build process is executed successfully. I think it is your environmental issue. If you create an issue with reproduction environment, I'll take a look 😄 |
imo it's not draft, can i click the 'Ready for review' button? |
@luke0408 let me know when you done with this PR. |
Thank you for your patience. However, due to issues with my development environment, I’m not sure when I’ll be able to continue working on it. As you may know, I’m currently not in a situation where I can freely work, and on top of that, I’m having problems with my internet connection, which has caused the work to come to a halt. At this point, all I can do is reply via my phone. If the task needs to be completed sooner, someone else may need to take over the branch and continue the work. |
Thanks I'll fix it with vibe coding! |
Move detect-indent and indent-string from devDependencies to dependencies since they are imported at runtime in the insertWithIndent function.
3142332
to
7aa78c5
Compare
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.
Pull Request Overview
This PR replaces the Prettier-based formatting step with a lightweight indent-based inserter for code snippets, removes the Prettier dependency, and updates all usages and tests accordingly.
- Introduce
insertWithIndent
utility and deprecateformatWithPrettier
- Update connector and CLI command logic to use indent-based insertion
- Adjust tests and package deps (added
detect-indent
&indent-string
)
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/cli/src/utils.ts | Added insertWithIndent and removed Prettier formatter function |
packages/cli/src/utils.test.ts | Swapped out Prettier tests for insertWithIndent and updated imports |
packages/cli/src/connectors.ts | Updated insertCodeIntoAgenticaStarter to use new insert helper |
packages/cli/src/commands/start.ts | Removed Prettier formatting from generated files |
packages/cli/package.json | Removed Prettier optional dep; added detect-indent & indent-string |
packages/cli/build.config.ts | Excluded new indent deps from bundle |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
packages/cli/src/utils.ts:23
- Update the doc comment to clearly state that this function inserts a code block at the placeholder with preserved indentation and returns the original content unchanged if the placeholder isn't found or on error.
* Format the given content with indent-string.
packages/cli/src/utils.test.ts:11
- The test description doesn't match the assertion (which verifies insertion). Rename to something like
should insert code with correct indentation at the placeholder
.
it("should return the same content if indent is not available", async () => {
@agentica/benchmark
@agentica/chat
agentica
@agentica/core
create-agentica
@agentica/rpc
@agentica/vector-selector
commit: |
CI fails but it is really fragile. it is not because of the implementation in this repo. that's so weird |
@luke0408 I am no longer with this organisation today and I believe that someone else will take this over. |
thank you for your contributing! |
oops, i miss to modify commit title... |
Apologies for the late PR. Due to personal circumstances, I haven't been able to code much over the past two months. I’ve been working on this intermittently in my spare time, so I’m only able to submit it now. Thank you for your patience.
Added Features
As discussed in #290 , I implemented a lightweight code formatter using indent-string and detect-indent, as an alternative to Prettier.
Implementation Example
How It Works
Question
I'm unsure whether it would be appropriate to apply this replacement logic as a utility function like the one above. If so, I’d appreciate any suggestions on how to abstract this part cleanly.