[GH-ISSUE #80] Flowchart of how this works #39

Open
opened 2026-03-03 13:52:25 +03:00 by kerem · 6 comments
Owner

Originally created by @neoOpus on GitHub (Sep 4, 2024).
Original GitHub issue: https://github.com/jehna/humanify/issues/80

Hi,

Could you provide in the readme a graph or flowchart illustrating how this works, or generate one using LLM to help me understand the code better? I'm particularly curious about whether multiple passes are made to enhance the final code. I tried with ChatGPT but I don't have the Plus, and it just failed to generate one...

Originally created by @neoOpus on GitHub (Sep 4, 2024). Original GitHub issue: https://github.com/jehna/humanify/issues/80 Hi, Could you provide in the readme a graph or flowchart illustrating how this works, or generate one using LLM to help me understand the code better? I'm particularly curious about whether multiple passes are made to enhance the final code. I tried with ChatGPT but I don't have the Plus, and it just failed to generate one...
Author
Owner

@jehna commented on GitHub (Sep 4, 2024):

Sorry, what is it that you're trying to do? I'm wondering if you're trying to understand the code to educate/help or if you're trying to use the free ChatGPT to run Humanify?

In case it's the latter, there's unfortunately no way to use without paying to OpenAI. But you don't need the plus subscription, only a pay-as-you-go API access. Humanify uses some clever tricks on API level to force the output to include only the renames, so that's why it would not work with the basic chatgpt.com

<!-- gh-comment-id:2329839369 --> @jehna commented on GitHub (Sep 4, 2024): Sorry, what is it that you're trying to do? I'm wondering if you're trying to understand the code to educate/help or if you're trying to use the free ChatGPT to run Humanify? In case it's the latter, there's unfortunately no way to use without paying to OpenAI. But you don't need the plus subscription, only a pay-as-you-go API access. Humanify uses some clever tricks on API level to force the output to include only the renames, so that's why it would not work with the basic chatgpt.com
Author
Owner

@jehna commented on GitHub (Sep 4, 2024):

If it's the former, I'd love to refactor the code to make it easier to approach!

On pseudocode level humanify works about like this:

const ast = parse(minifiedCode)
for (const varName of ast.identifiers) {
  const newName = aiModel.askToRename(varName, surroundingCode(varName, ast))
  ast.rename(varName, newName)
}
save(ast.toString())

So at least one request to ChatGPT is made per variable. The actual rename is made without ChatGPT. Does this answer your question?

<!-- gh-comment-id:2329856608 --> @jehna commented on GitHub (Sep 4, 2024): If it's the former, I'd love to refactor the code to make it easier to approach! On pseudocode level humanify works about like this: ``` const ast = parse(minifiedCode) for (const varName of ast.identifiers) { const newName = aiModel.askToRename(varName, surroundingCode(varName, ast)) ast.rename(varName, newName) } save(ast.toString()) ``` So at least one request to ChatGPT is made per variable. The actual rename is made without ChatGPT. Does this answer your question?
Author
Owner

@neoOpus commented on GitHub (Sep 5, 2024):

No, my mistake for not being clear enough in my message, I wanted mainly to see how this works internally via a graph that explain the steps your tool do to deliver the finally result... a visual representation.

eg.

Input > unminification > code parsing > looking for patterns via (something) > beautification > ESLint > LLM variable replacement > Loop x times > Output

If this still doesn't make sense, forget about this, I don't want to take up your development time.

<!-- gh-comment-id:2330680940 --> @neoOpus commented on GitHub (Sep 5, 2024): No, my mistake for not being clear enough in my message, I wanted mainly to see how this works internally via a graph that explain the steps your tool do to deliver the finally result... a visual representation. eg. `Input > unminification > code parsing > looking for patterns via (something) > beautification > ESLint > LLM variable replacement > Loop x times > Output` If this still doesn't make sense, forget about this, I don't want to take up your development time.
Author
Owner

@neoOpus commented on GitHub (Sep 5, 2024):

If it's the former, I'd love to refactor the code to make it easier to approach!

On pseudocode level humanify works about like this:

const ast = parse(minifiedCode)
for (const varName of ast.identifiers) {
  const newName = aiModel.askToRename(varName, surroundingCode(varName, ast))
  ast.rename(varName, newName)
}
save(ast.toString())

So at least one request to ChatGPT is made per variable. The actual rename is made without ChatGPT. Does this answer your question?

Yes that would be enough for the moment, I will have to examine the source-code, if I still have questions then I will comeback (I just wanted ChatGPT to generate the graph but I don't have the Plus and tried several times then told me that I reached the limit, I will try again today. As this can give anyone a clear idea of the workflow.

<!-- gh-comment-id:2330685723 --> @neoOpus commented on GitHub (Sep 5, 2024): > If it's the former, I'd love to refactor the code to make it easier to approach! > > On pseudocode level humanify works about like this: > > ``` > const ast = parse(minifiedCode) > for (const varName of ast.identifiers) { > const newName = aiModel.askToRename(varName, surroundingCode(varName, ast)) > ast.rename(varName, newName) > } > save(ast.toString()) > ``` > > So at least one request to ChatGPT is made per variable. The actual rename is made without ChatGPT. Does this answer your question? Yes that would be enough for the moment, I will have to examine the source-code, if I still have questions then I will comeback (I just wanted ChatGPT to generate the graph but I don't have the Plus and tried several times then told me that I reached the limit, I will try again today. As this can give anyone a clear idea of the workflow.
Author
Owner

@0xdevalias commented on GitHub (Sep 12, 2024):

I wanted mainly to see how this works internally via a graph that explain the steps your tool do to deliver the finally result... a visual representation.

I will have to examine the source-code

@neoOpus I sort of looked at this myself the other day to understand things better; I found it easiest to start at the CLI command, which call unminify and provides a pipeline of plugins to apply to it (babel, openaiRename, prettier):

github.com/jehna/humanify@a51847171a/src/commands/openai.ts (L20-L30)

You can see the definition for unminify here:

github.com/jehna/humanify@a51847171a/src/unminify.ts (L6-L27)

You can see the openaiRename plugin code here:

github.com/jehna/humanify@a51847171a/src/plugins/openai/openai-rename.ts (L6-L38)

You can similarly follow the code flows for the local and gemini based CLI options.

<!-- gh-comment-id:2345155159 --> @0xdevalias commented on GitHub (Sep 12, 2024): > I wanted mainly to see how this works internally via a graph that explain the steps your tool do to deliver the finally result... a visual representation. > I will have to examine the source-code @neoOpus I sort of looked at this myself the other day to understand things better; I found it easiest to start at the CLI command, which call `unminify` and provides a pipeline of plugins to apply to it (`babel`, `openaiRename`, `prettier`): https://github.com/jehna/humanify/blob/a51847171add85a65f29ef4cdc4b403812601bc1/src/commands/openai.ts#L20-L30 You can see the definition for `unminify` here: https://github.com/jehna/humanify/blob/a51847171add85a65f29ef4cdc4b403812601bc1/src/unminify.ts#L6-L27 You can see the `openaiRename` plugin code here: https://github.com/jehna/humanify/blob/a51847171add85a65f29ef4cdc4b403812601bc1/src/plugins/openai/openai-rename.ts#L6-L38 You can similarly follow the code flows for the local and gemini based CLI options.
Author
Owner

@neoOpus commented on GitHub (Sep 12, 2024):

Thank you so much Glenn for your help! I really appreciate!

I have a clearer idea now, but I still have some reading to do, I am thinking about feeding the source-code to an LLM to make the flowchart from it, but I still didn't find that solution yet!

BTW, I've been reading your profile and I really liked it, we have a similar approach about learning and doing things!

<!-- gh-comment-id:2345352649 --> @neoOpus commented on GitHub (Sep 12, 2024): Thank you so much Glenn for your help! I really appreciate! I have a clearer idea now, but I still have some reading to do, I am thinking about feeding the source-code to an LLM to make the flowchart from it, but I still didn't find that solution yet! BTW, I've been reading your profile and I really liked it, we have a similar approach about learning and doing things!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/humanify#39
No description provided.