Skip to content

Commit

Permalink
Merge pull request #16 from docker/cm/more-prompts
Browse files Browse the repository at this point in the history
Update npm and git_smoosh
  • Loading branch information
ColinMcNeil authored Jun 7, 2024
2 parents 56fe13f + d92589c commit 51c0fed
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 72 deletions.
1 change: 1 addition & 0 deletions prompts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ COPY lazy_docker lazy_docker
COPY git_hooks git_hooks
COPY harmonia harmonia
COPY ollama ollama
COPY git_smoosh git_smoosh

# Can't be shell form because we need to pass JSON as an arg
ENTRYPOINT [ "bb", "prompts.jar" ]
2 changes: 1 addition & 1 deletion prompts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To run this project, use the following run command:

```sh
#docker:command=run
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock vonwig/prompts $PWD my_docker_username darwin npm
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock vonwig/prompts $PWD my_docker_username darwin npm_setup
```

The four arguments are `project root dir`, `docker username`, `platform`, and a top-level prompt folder.
Expand Down
18 changes: 15 additions & 3 deletions prompts/git_smoosh/010_system_prompt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
You are an assistant who specializes in making runbooks for Docker projects,
allowing any developer to quickly run a docker project locally for development.
Since you are an expert and know about their project, be definitive about recommendations.
You are an assistant who specializes in making runbooks for git ammendments. Your name is git smoosh.

The current working directory is the same as the git project, so use paths relative to `.`

```sh
#docker:command=git-smoosh (this is a commend to tag the command)
git rev-parse --short HEAD
git commit --fixup=<last_commit_hash>
```

Afterward, recommend a force push.

Adapt the code block for powershell, but only if the user is on windows.

Platform: {{platform}}
63 changes: 1 addition & 62 deletions prompts/git_smoosh/020_user_prompt.md
Original file line number Diff line number Diff line change
@@ -1,62 +1 @@
I have a project open which will be described.

I have Docker Desktop installed and therefore has full access to run docker commands.

The command for Docker Compose is `docker compose` and not `docker-compose`.

When using docker compose, I use `docker compose up --build`.

I have full access to run docker commands because of Docker Desktop.

My $PWD `.` is the root of my project.

I want to run this project for local development.

My current platform is {{platform}}.

Before you generate a runbook, provide a way to setup env vars.
If the project requires env vars or references an env file, mention that.
If it doesn't mention env vars, tell me.

After steps to set the environment variables, generate a runbook.
A runbook for a Docker project consists of 3 parts: Build, Run, Share. Use regular markdown headings for these sections.
The build section describes how to build the project.
If the project has a Docker Compose file, then simply say I do not need to build separately and show the command `docker compose up --build`.
If there are only Dockerfiles, then build using `docker build`.
An image tag should be used if needed.
The run section describes how to run the project with Docker.
The share section describes how to share the project on Docker hub.
such as `docker push repo/imagename`. Do not recommend stopping or removing containers.

The user is logged in to Docker Hub as {{username}}

The project has the following Dockerfiles:

{{#project.dockerfiles}}
Dockerfile at {{path}} contains:
{{content}}
{{/project.dockerfiles}}



{{#project.composefiles}}
The project has the following Docker Compose files:

Compose file at {{path}} contains:
{{content}}
{{/project.composefiles}}

{{^project.composefiles}}

I am not using Docker Compose in this project.

{{/project.composefiles}}

My project uses the following languages:

{{languages}}

Format runnable sections as code blocks.
For example, use triple backticks to format code blocks in markdown.
Use ```sh for UNIX shell commands and ```powershell for PowerShell commands.

I need a command smooshed. What is the command and how does it work?
2 changes: 1 addition & 1 deletion prompts/git_smoosh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ extractors:

## Description

Run a binary and its dependencies in an npm project without a full install.
Smoosh all of your staged changes into the last commit
7 changes: 4 additions & 3 deletions prompts/src/prompts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
(= "prompts" (first args))
[{:type "docker" :title "using docker in my project"}
{:type "lazy_docker" :title "using lazy-docker"}
{:type "npm" :title "using npm"}
{:type "npm_setup" :title "using npm"}
{:type "git_smoosh" :title "Smoosh changes into last commit"}
#_{:type "ollama" :title "model quantization with Ollama"}
#_{:type "git_hooks" :title "set up my git hooks"}
#_{:type "harmonia" :title "using harmonia to access gpus"}]
Expand Down Expand Up @@ -95,8 +96,8 @@

(comment
(collect-extractors "npm")
(all-facts "/Users/slim/docker/labs-make-runbook/" "npm")
(->> (-prompts "/Users/slim/docker/labs-make-runbook/" "jimclark106" "darwin" "npm")
(all-facts "/Users/slim/docker/labs-make-runbook/" "npm_setup")
(->> (-prompts "/Users/slim/docker/labs-make-runbook/" "jimclark106" "darwin" "npm_setup")
(map :content)
(map println))
(->> (-prompts "/Users/slim/docker/genai-stack/" "jimclark106" "darwin" "docker")
Expand Down
3 changes: 1 addition & 2 deletions src/utils/preparePrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export const prepareProjectPrompt = (projectRoot: vscode.WorkspaceFolder, userna

const promptImage = vscode.workspace.getConfiguration('docker.make-runbook').get('prompt-image') as string;

vscode.window.showInformationMessage(['run', '--rm', "-v", "/var/run/docker.sock:/var/run/docker.sock", promptImage, projectRoot.uri.fsPath, username, JSON.stringify(platform), promptType].join(','))
const result = spawnSync('docker', ['run', '--rm', "-v", "/var/run/docker.sock:/var/run/docker.sock", promptImage, projectRoot.uri.fsPath, username, JSON.stringify(platform), promptType]);
const result = spawnSync('docker', ['run', '--rm', "-v", "/var/run/docker.sock:/var/run/docker.sock", promptImage, projectRoot.uri.fsPath, username, platform, promptType]);

if (result.error) {
throw result.error;
Expand Down

0 comments on commit 51c0fed

Please sign in to comment.