8000 feat: add preinstall/postinstall script + tools for goose and claude code by bpmct · Pull Request #424 · coder/modules · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat: add preinstall/postinstall script + tools for goose and claude code #424

Merged
merged 43 commits into from
Apr 18, 2025
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
470ae43
use `goose` if in PATH
bpmct Apr 7, 2025
364d468
feat(goose): add pre and post install script variables for customization
bpmct Apr 7, 2025
b7cc2f2
refactor(goose): improve handling of pre and post install scripts wit…
bpmct Apr 7, 2025
45b21e1
fix
bpmct Apr 7, 2025
220a026
fix
bpmct Apr 7, 2025
e8ef8f5
debug
bpmct Apr 7, 2025
5744f7a
fix
bpmct Apr 7, 2025
467ad91
cleanup
bpmct Apr 7, 2025
eaceba4
fixup
bpmct Apr 8, 2025
e2cb2fa
fixup
bpmct Apr 8, 2025
d9a7275
ok
bpmct Apr 8, 2025
55073da
add debug
bpmct Apr 8, 2025
3ccd98c
debug
bpmct Apr 8, 2025
d2ca53b
fix handling
bpmct Apr 8, 2025
c1e83e0
fixes
bpmct Apr 8, 2025
92fb309
cleanup
bpmct Apr 8, 2025
9865dec
fix path bs
bpmct Apr 8, 2025
324508e
fix
bpmct Apr 8, 2025
a025219
fix
bpmct Apr 8, 2025
928abda
fix escaping
bpmct Apr 8, 2025
bf41bb2
ok
bpmct Apr 8, 2025
19bda0d
fix
bpmct Apr 8, 2025
a50cb4b
fixup
bpmct Apr 8, 2025
abdbe1f
remove
bpmct Apr 8, 2025
4445af8
no prompt
bpmct Apr 8, 2025
04b9686
always reattach
bpmct Apr 8, 2025
4189f04
fix
bpmct Apr 8, 2025
2709f2a
Merge remote-tracking branch 'origin' into updates
bpmct Apr 8, 2025
e980d9c
fix system prompt
bpmct Apr 8, 2025
7634bd7
fix
bpmct Apr 8, 2025
81ad454
add support for additional extensions
bpmct Apr 9, 2025
2c7e9e9
fix
bpmct Apr 9, 2025
7f836ff
test
bpmct Apr 9, 2025
3542350
even clearer
bpmct Apr 9, 2025
3bf9e0f
fix
bpmct Apr 9, 2025
438c30f
fix again
bpmct Apr 9, 2025
20b1fca
fix
bpmct Apr 9, 2025
77bca7b
feat: add pre/post install for goose + custom extensions
bpmct Apr 9, 2025
d4ffca0
fmt
Apr 16, 2025
1f9d7ea
feat: add pre and post install script variables for Claude Code
Apr 16, 2025
b369d72
postinstallbetter
Apr 16, 2025
d31daad
test
Apr 16, 2025
7a1b282
base64 encode scripts
Apr 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ok
  • Loading branch information
bpmct committed Apr 8, 2025
commit bf41bb26e0487309d92edcc07d472ad182da4c41
35 changes: 32 additions & 3 deletions goose/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,32 @@ variable "experiment_post_install_script" {
default = null
}

variable "GOOSE_SYSTEM_PROMPT" {
type = string
description = "The system prompt to use for Goose."
default = <<-EOT
Hey, you are a fast programming architect! The user will provide you with a prompt of something to create. Come up with a plan then create it the best you can.

Report every tiny task to Coder and be sure to be explicit about the status and whether you need
input or not.

If you are making a web app:
- ALWAYS listen on port 3000 so the user has a consistent preview to see their work
- If the dev server is already running, kill the dev server to run on port 3000.
- Avoid building the project for production. Just use dev servers (in a new \`screen\` as mentioned below)
- When you think you have finished, you should use Playwright to review the HTML to ensure it is working as expected.
- Feel free to fix anything bad you see.
- When reporting URLs to Coder, do not use localhost. Instead, run \`env | grep CODER\` and use a URL like https://nicky-pike.demo.coder.com/@USERNAME/WORKSPACE_NAME.main/apps/preview/ but with it replaced with the proper env vars. That proxies port 3000. If using Vite (or similar), be sure to allow that URL as a host as well.

Keep in mind that the proxied URL above is on a PATH. So if you are using a web framework (I prefer static HTML),
be sure to configure that web framework to run on the proper path as per the URL above.

Always run long-running commands and servers (e.g. \`pnpm dev\`, \`npm run dev\`, \`python3 -m http.server\`) in a new \`screen\` so it runs it in the background and users can prompt you. Other short-lived commands (build, test, cd, write, read, view, etc) can run normally. For previewing, always use the dev server for fast feedback loops.

Your task at hand:
EOT
}

# Install and Initialize Goose
resource "coder_script" "goose" {
agent_id = var.agent_id
Expand Down Expand Up @@ -158,6 +184,10 @@ extensions:
EOL
fi

# Write system prompt to config
mkdir -p "$HOME/.config/goose"
echo "$GOOSE_SYSTEM_PROMPT" > "$HOME/.config/goose/.goosehints"

# Run with screen if enabled
if [ "${var.experiment_use_screen}" = "true" ]; then
echo "Running Goose in the background..."
Expand Down Expand Up @@ -200,8 +230,7 @@ EOL

screen -U -dmS goose bash -c "
cd ${var.folder}
export GOOSE_SYSTEM_PROMPT=\"$GOOSE_SYSTEM_PROMPT\"
\"$GOOSE_CMD\" run --text \"\$GOOSE_SYSTEM_PROMPT\" --interactive | tee -a \"$HOME/.goose.log\"
\"$GOOSE_CMD\" run --text \"\${GOOSE_TASK_PROMPT}\" --interactive | tee -a \"$HOME/.goose.log\"
"
else
# Check if goose is installed before running
Expand Down Expand Up @@ -248,7 +277,7 @@ resource "coder_app" "goose" {
cd ${var.folder}
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
"$GOOSE_CMD" run --text "Always report status and instructions to Coder, before and after your steps" --interactive
"$GOOSE_CMD" run --text "$GOOSE_TASK_PROMPT" --interactive
fi
EOT
icon = var.icon
Expand Down
0