add poc for generation of llms-full. all made by claude code#508
add poc for generation of llms-full. all made by claude code#508
Conversation
|
|
||
| // Remove JSX-style components but keep their text content | ||
| // Handle self-closing components | ||
| result = result.replace(/<\w+[^>]*\/>/g, ''); |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the incomplete multi-character sanitization, apply the regular expression replacement for self-closing components (/<\w+[^>]*\/>/g) repeatedly until no further replacements occur. This guarantees that all such patterns are removed, even in the case of crafted malicious input that could leave unsafe substrings behind after one pass. The fix should be implemented within the removeComponents function, specifically replacing line 84, without altering the semantics of the rest of the code.
Implementation plan:
- Inside
removeComponents, replace the single replace call at line 84 with a loop that applies the replacement repeatedly until no further changes. - No new imports are needed.
- Ensure only this region of code is edited.
| @@ -81,7 +81,13 @@ | ||
|
|
||
| // Remove JSX-style components but keep their text content | ||
| // Handle self-closing components | ||
| result = result.replace(/<\w+[^>]*\/>/g, ''); | ||
| { | ||
| let prev; | ||
| do { | ||
| prev = result; | ||
| result = result.replace(/<\w+[^>]*\/>/g, ''); | ||
| } while (result !== prev); | ||
| } | ||
|
|
||
| // Handle components with children - extract text content | ||
| result = result.replace(/<(\w+)[^>]*>([\s\S]*?)<\/\1>/g, (match, tag, content) => { |
| "build": "npm run generate:llms-full && NODE_ENV=development astro build", | ||
| "preview": "NODE_ENV=development astro preview --open", | ||
| "build:prod": "NODE_ENV=production VITE_PROD_BASE_PATH=/developer/commerce/storefront astro build", | ||
| "build:prod-fast": "NODE_ENV=production VITE_PROD_BASE_PATH=/developer/commerce/storefront SKIP_COMPRESSION=true astro build", | ||
| "build:prod": "npm run generate:llms-full && NODE_ENV=production VITE_PROD_BASE_PATH=/developer/commerce/storefront astro build", | ||
| "build:prod-fast": "npm run generate:llms-full && NODE_ENV=production VITE_PROD_BASE_PATH=/developer/commerce/storefront SKIP_COMPRESSION=true astro build", |
There was a problem hiding this comment.
The script outputs to public folder, and it thinks it'll be served at https://experienceleague.adobe.com/developer/commerce/storefront/llms-full.txt.
I think that path would be ideal, but not sure how to "serve" or publish to that.
Signed-off-by: Stephen Rugh <rugh@adobe.com>
2569f87 to
da4cbf5
Compare
POC for generating
llms-fulllike astro: https://docs.astro.build/en/guides/build-with-ai/#context-filesdon't merge as is - def needs a human eye