-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues with openai key, add npm prompt (#19)
* Fix issues with openai key, add npm prompt * Switch to environment var for openai secret * Update entrypoint for `npm` extractor
- Loading branch information
1 parent
942593c
commit b86d804
Showing
8 changed files
with
116 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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,13 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk add --no-cache jq bash fd | ||
|
||
VOLUME [ "/project" ] | ||
|
||
WORKDIR /project | ||
|
||
COPY entrypoint.sh /app/entrypoint.sh | ||
RUN chmod +x /app/entrypoint.sh | ||
|
||
ENTRYPOINT ["/app/entrypoint.sh"] | ||
|
This file contains 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,43 @@ | ||
#!/bin/bash | ||
|
||
OUTPUT_JSON="{}" | ||
|
||
PACKAGE_JSONS=$(fd -e package.json) | ||
|
||
TOTAL_PACKAGE_JSONS=$(echo "$PACKAGE_JSONS" | wc -l) | ||
|
||
OUTPUT_JSON=$(echo "$OUTPUT_JSON" | jq -c ".total_package_json_files = $TOTAL_PACKAGE_JSONS") | ||
# If no package.json files are found, exit | ||
if [ "$TOTAL_PACKAGE_JSONS" -eq 0 ]; then | ||
echo "No package.json files found in the current directory" | ||
exit 1 | ||
fi | ||
|
||
# If root level package.json | ||
if [ -f "package.json" ]; then | ||
OUTPUT_JSON=$(echo "$OUTPUT_JSON" | jq -c ".root_package_json = $(cat package.json)") | ||
|
||
fi | ||
|
||
# If has node_modules | ||
if [ -d "node_modules" ]; then | ||
ARG="$(ls node_modules | wc -l) directories" | ||
OUTPUT_JSON=$(echo "$OUTPUT_JSON" | jq --arg ARG "$ARG" '.node_modules = $ARG') | ||
fi | ||
|
||
# If has package-lock.json | ||
if [ -f "package-lock.json" ]; then | ||
OUTPUT_JSON=$(echo "$OUTPUT_JSON" | jq -c ".package_lock = true") | ||
fi | ||
|
||
# If has yarn.lock | ||
if [ -f "yarn.lock" ]; then | ||
OUTPUT_JSON=$(echo "$OUTPUT_JSON" | jq -c ".yarn_lock = true") | ||
fi | ||
|
||
# If has pnpm-lock.yaml | ||
if [ -f "pnpm-lock.yaml" ]; then | ||
OUTPUT_JSON=$(echo "$OUTPUT_JSON" | jq -c ".pnpm_lock = true") | ||
fi | ||
|
||
echo -e "{\"npm\": $OUTPUT_JSON }" |
This file contains 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 |
---|---|---|
|
@@ -13,5 +13,7 @@ registry: | |
command: | ||
- -json | ||
output-handler: linguist | ||
- name: npm | ||
image: vonwig/npm:latest | ||
|
||
|
This file contains 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,11 @@ | ||
You are and assistant that is an expert at npm projects. | ||
|
||
An NPM project will be described to you. It will include information about the project, the package.json files, the node_modules directory, and the package lock files. | ||
|
||
Inside of a package.json file, the source of truth for package manager should be the key `packageManager` but it is rarely defined. | ||
|
||
If there are multiple lockfiles, you need to respond warning that there are multiple lockfiles. Recommend running the prompt `github.com:docker/labs-ai-tools-for-devs?path=prompts/choose-package-manager` to choose the correct package manager. | ||
|
||
If there is one lockfile, tell them what package manager is used for the project. | ||
|
||
Otherwise, simply summarize the project. Be brief, but consider the package.json provided, and what the typical developer would want to know about the project. |
This file contains 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,23 @@ | ||
The project has {{npm.total_package_json_files}} package.json files. | ||
|
||
The root package.json file is: | ||
|
||
```json | ||
{{npm.root_package_json}} | ||
``` | ||
|
||
There are {{npm.node_modules}} currently installed in the project. | ||
|
||
The package lock files are: | ||
|
||
```json | ||
{{npm.package_lock}} | ||
``` | ||
|
||
```json | ||
{{npm.yarn_lock}} | ||
``` | ||
|
||
```json | ||
{{npm.pnpm_lock}} | ||
``` |
This file contains 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,6 @@ | ||
--- | ||
extractors: | ||
- image: vonwig/npm:latest | ||
--- | ||
|
||
Responds with a summary of the NPM project. |
This file contains 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 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