-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathjustfile
More file actions
186 lines (169 loc) · 7.09 KB
/
justfile
File metadata and controls
186 lines (169 loc) · 7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Plugin management commands
plugins := "code-review customaize-agent ddd docs git kaizen mcp reflexion sadd sdd tdd tech-stack fpf"
marketplace := ".claude-plugin/marketplace.json"
# Show all commands
help:
@just --list
# Copy README.md files from docs/plugins/ to respective plugins/ folders
sync-docs-to-plugins:
@echo "Syncing README.md files from docs/plugins/ to plugins/..."
@for plugin in {{plugins}}; do \
if [ -f "docs/plugins/$plugin/README.md" ]; then \
cp "docs/plugins/$plugin/README.md" "plugins/$plugin/README.md"; \
echo " Copied: docs/plugins/$plugin/README.md -> plugins/$plugin/README.md"; \
else \
echo " Skipped: docs/plugins/$plugin/README.md (not found)"; \
fi; \
done
@echo "Done."
# Copy README.md files from plugins/ to docs/plugins/ folders
sync-plugins-to-docs:
@echo "Syncing README.md files from plugins/ to docs/plugins/..."
@for plugin in {{plugins}}; do \
if [ -f "plugins/$plugin/README.md" ]; then \
mkdir -p "docs/plugins/$plugin"; \
cp "plugins/$plugin/README.md" "docs/plugins/$plugin/README.md"; \
echo " Copied: plugins/$plugin/README.md -> docs/plugins/$plugin/README.md"; \
else \
echo " Skipped: plugins/$plugin/README.md (not found)"; \
fi; \
done
@echo "Done."
# Set version for a specific plugin
set-version plugin version:
@if [ ! -f "plugins/{{plugin}}/.claude-plugin/plugin.json" ]; then \
echo "Error: Plugin '{{plugin}}' not found"; \
exit 1; \
fi
@echo "Updating version for plugin '{{plugin}}' to {{version}}..."
@# Update plugin.json
@jq '.version = "{{version}}"' "plugins/{{plugin}}/.claude-plugin/plugin.json" > "plugins/{{plugin}}/.claude-plugin/plugin.json.tmp" && \
mv "plugins/{{plugin}}/.claude-plugin/plugin.json.tmp" "plugins/{{plugin}}/.claude-plugin/plugin.json"
@echo " Updated: plugins/{{plugin}}/.claude-plugin/plugin.json"
@# Update marketplace.json
@jq '(.plugins[] | select(.name == "{{plugin}}")).version = "{{version}}"' "{{marketplace}}" > "{{marketplace}}.tmp" && \
mv "{{marketplace}}.tmp" "{{marketplace}}"
@echo " Updated: {{marketplace}}"
@echo "Done. Version set to {{version}} for plugin '{{plugin}}'"
# Set version for the marketplace
set-marketplace-version version:
@if [ ! -f "{{marketplace}}" ]; then \
echo "Error: Marketplace file '{{marketplace}}' not found"; \
exit 1; \
fi
@echo "Updating marketplace version to {{version}}..."
@jq '.version = "{{version}}"' "{{marketplace}}" > "{{marketplace}}.tmp" && \
mv "{{marketplace}}.tmp" "{{marketplace}}"
@echo " Updated: {{marketplace}}"
@echo "Done. Marketplace version set to {{version}}"
# List all available plugins
list-plugins:
@echo "Available plugins:"
@for plugin in {{plugins}}; do \
if [ -f "plugins/$plugin/.claude-plugin/plugin.json" ]; then \
version=$(jq -r '.version' "plugins/$plugin/.claude-plugin/plugin.json"); \
echo " $plugin (v$version)"; \
fi; \
done
# Get the running devcontainer ID (empty if not running)
_sandbox-id:
@docker ps --filter "label=devcontainer.local_folder={{justfile_directory()}}" --format "{{{{.ID}}" | head -n1
# Start devcontainer and open an interactive shell
sandbox:
#!/usr/bin/env bash
set -euo pipefail
echo "Starting devcontainer... First run can take long time to build the image"
output=$(devcontainer up --workspace-folder .) # TODO: print output during the process
echo "$output"
container_id=$(echo "$output" | grep -oP '"containerId"\s*:\s*"\K[^"]+')
workspace=$(echo "$output" | grep -oP '"remoteWorkspaceFolder"\s*:\s*"\K[^"]+')
user=$(echo "$output" | grep -oP '"remoteUser"\s*:\s*"\K[^"]+')
if [ -z "$container_id" ]; then
echo "Error: could not find devcontainer"
exit 1
fi
echo "Attaching to container $container_id as ${user:-root} at $workspace..."
docker exec -it -u "${user:-root}" -w "${workspace:-/}" "$container_id" zsh
# Attach to a running devcontainer
attach-sandbox:
#!/usr/bin/env bash
set -euo pipefail
container_id=$(just _sandbox-id)
if [ -z "$container_id" ]; then
echo "Error: no running devcontainer found. Run 'just sandbox' first."
exit 1
fi
eval "$(docker inspect "$container_id" | python3 -c "
import json,sys
c = json.load(sys.stdin)[0]
folder = c['Config']['Labels'].get('devcontainer.local_folder','')
ws = next((m['Destination'] for m in c.get('Mounts',[]) if m['Source'] == folder), '/')
meta = json.loads(c['Config']['Labels'].get('devcontainer.metadata','[]'))
user = next((i['remoteUser'] for i in meta if 'remoteUser' in i), 'root')
print(f'workspace={ws}')
print(f'user={user}')
")"
echo "Attaching to container $container_id as $user at $workspace..."
docker exec -it -u "$user" -w "$workspace" "$container_id" zsh
# Stop and remove the devcontainer
stop-sandbox:
#!/usr/bin/env bash
set -euo pipefail
container_id=$(just _sandbox-id)
if [ -z "$container_id" ]; then
echo "No running devcontainer found."
exit 0
fi
echo "Stopping container $container_id..."
docker stop "$container_id" && docker rm "$container_id"
echo "Done."
# Run claude with a prompt and stream plain text output
[no-exit-message]
claude prompt:
#!/usr/bin/env bash
set -euo pipefail
# Usage:
# just claude "Explain this codebase"
# just claude "Summarize the README"
#
# Streams claude's response as plain text to stdout.
# Uses stream-json format with jq to extract text deltas.
claude -p "{{ prompt }}" --output-format stream-json --verbose --include-partial-messages | \
jq -rj 'select(.type == "stream_event" and .event.delta.type? == "text_delta") | .event.delta.text'
# Create a new draft task from a prompt
[no-exit-message]
claude-add-task prompt:
#!/usr/bin/env bash
set -euo pipefail
# Usage:
# just claude-add-task "Add validation to the /decide endpoint"
just claude "/sdd:add-task {{ prompt }}"
# Plan a draft task and then implement it
[no-exit-message]
claude-plan-and-implement task-filename:
#!/usr/bin/env bash
set -euo pipefail
# Usage:
# just claude-plan-and-implement my-task.test.md
#
# 1. Verifies the task file exists in .specs/tasks/draft/
# 2. Runs /sdd:plan to move it to .specs/tasks/todo/
# 3. Verifies the file arrived in todo/
# 4. Runs /sdd:implement on the planned task
draft=".specs/tasks/draft/{{ task-filename }}"
todo=".specs/tasks/todo/{{ task-filename }}"
if [ ! -f "$draft" ]; then
echo "Error: task file not found: $draft"
exit 1
fi
echo "==> Planning: $draft"
just claude "/sdd:plan @$draft"
if [ ! -f "$todo" ]; then
echo "Error: planning did not produce: $todo"
exit 1
fi
echo ""
echo "==> Implementing: $todo"
just claude "/sdd:implement @$todo"
down-devcontainer:
docker compose --project-name decision-engine_devcontainer -f .devcontainer/docker-compose.yaml down