-
Notifications
You must be signed in to change notification settings - Fork 66
feat(dev): add seed targets for the non-Docker dev server #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| .DEFAULT_GOAL := help | ||
|
|
||
| # Local (non-Docker) dev server settings, shared by dev-api, dev-ui and the | ||
| # dev-seed-* targets so the port and database path cannot drift apart. DEV_DB | ||
| # is relative to server/backend; DEV_API_PORT is passed through to Vite by | ||
| # dev-ui, which uses it as the /api/v1 proxy target. | ||
| DEV_DB ?= ./dev.db | ||
| DEV_API_PORT ?= 8742 | ||
|
|
||
| .PHONY: help | ||
| help: | ||
| @echo "cq - shared agent knowledge commons" | ||
|
|
@@ -43,6 +50,13 @@ help: | |
| @echo " make sync-schema Copy canonical schemas into the Python schema package" | ||
| @echo " make validate-schema Validate JSON Schema fixtures and values file" | ||
| @echo "" | ||
| @echo "Local development (outside Docker):" | ||
| @echo " make dev-api Run the API on :$(DEV_API_PORT) against server/backend/dev.db" | ||
| @echo " make dev-ui Run the dashboard on :3000 (proxies /api/v1 to dev-api)" | ||
| @echo " make dev-seed-users USER=demo PASS=demo123 Create a user in the dev-api database" | ||
| @echo " make dev-seed-kus USER=demo PASS=demo123 Load sample KUs (requires make dev-api running)" | ||
| @echo " make dev-seed-all USER=demo PASS=demo123 Create user + load KUs" | ||
| @echo "" | ||
| @echo "Docker Compose:" | ||
| @echo " make compose-up Build and start services (creates .env from example if missing)" | ||
| @echo " make compose-down Stop services" | ||
|
|
@@ -135,11 +149,58 @@ endif | |
|
|
||
| .PHONY: dev-api | ||
| dev-api: | ||
| cd server/backend && CQ_DB_PATH=./dev.db CQ_JWT_SECRET=dev-secret CQ_API_KEY_PEPPER=dev-pepper CQ_PORT=8742 uv run cq-server | ||
| cd server/backend && CQ_DATABASE_URL= CQ_DB_PATH="$(DEV_DB)" CQ_JWT_SECRET=dev-secret CQ_API_KEY_PEPPER=dev-pepper CQ_PORT=$(DEV_API_PORT) uv run cq-server | ||
|
|
||
| .PHONY: dev-ui | ||
| dev-ui: | ||
| cd server/frontend && pnpm dev | ||
| cd server/frontend && DEV_API_PORT=$(DEV_API_PORT) pnpm dev | ||
|
|
||
| .PHONY: dev-seed-users | ||
| dev-seed-users: | ||
| # USER is exported by every POSIX shell, so `ifndef USER` never fires and the | ||
| # target would silently fall back to the current OS username. Require it to be | ||
| # passed on the command line, and reject an empty value. | ||
| ifneq ($(origin USER),command line) | ||
| $(error USER is required. Usage: make dev-seed-users USER=demo PASS=demo123) | ||
| endif | ||
| ifeq ($(strip $(USER)),) | ||
| $(error USER is required. Usage: make dev-seed-users USER=demo PASS=demo123) | ||
| endif | ||
| ifeq ($(strip $(PASS)),) | ||
| $(error PASS is required. Usage: make dev-seed-users USER=demo PASS=demo123) | ||
| endif | ||
| cd server/backend && CQ_DATABASE_URL= CQ_DB_PATH="$(DEV_DB)" uv run alembic upgrade head | ||
| cd server/backend && uv run python ../scripts/seed-users.py --username "$(USER)" --password "$(PASS)" --db "$(DEV_DB)" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- Makefile targets and relevant recipes ---'
sed -n '145,195p' Makefile
printf '%s\n' '--- Seed script references ---'
rg -n -C 4 'seed-users|PASS|DEV_DB|USERNAME|PASSWORD' Makefile server scripts 2>/dev/null || true
printf '%s\n' '--- Make configuration affecting command echoing ---'
rg -n -C 3 '^\s*\.SILENT|MAKEFLAGS|silent|seed-users' Makefile GNUmakefile makefile 2>/dev/null || trueRepository: mozilla-ai/cq Length of output: 17808 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- Seed script locations ---'
fd -i 'seed-(users|kus)\.py$' .
printf '%s\n' '--- Seed script argument parsing ---'
for f in $(fd -i 'seed-(users|kus)\.py$' .); do
printf '\n### %s\n' "$f"
rg -n -C 8 'argparse|add_argument|parse_args|password|passwd|stdin|input|sys\.argv' "$f"
done
printf '%s\n' '--- Make dry-run output with a shell-sensitive password ---'
if command -v make >/dev/null 2>&1; then
make -n dev-seed-users USER=demo 'PASS=p a$ b"'\'';touch /tmp/not-created' 2>&1 || true
make -n dev-seed-kus USER=demo 'PASS=p a$ b"'\'';touch /tmp/not-created' 2>&1 || true
else
printf '%s\n' 'make is unavailable'
fiRepository: mozilla-ai/cq Length of output: 4256 🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
import subprocess
password = 'pw$(printf SUBSTITUTED)'
recipe = f'printf "%s\\n" --password "{password}"'
result = subprocess.run(
["/bin/sh", "-c", recipe],
check=True,
text=True,
capture_output=True,
)
print("shell command:", recipe)
print("received argument:", result.stdout.rstrip())
print("command substitution occurred:", "SUBSTITUTED" in result.stdout)
PYRepository: mozilla-ai/cq Length of output: 297 Do not pass The seed recipes expose 🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Happy to do it as a follow-up, I just want to defer to your call here! 😺 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The password exposure concern remains valid, but this PR does not need to make that cross-workflow interface decision. A follow-up should define the protected-input interface and update the scripts, Make targets, Would you like me to open a GitHub issue for that follow-up? 🐇 You are interacting with an AI system. |
||
|
|
||
| .PHONY: dev-seed-kus | ||
| dev-seed-kus: | ||
| # USER is exported by every POSIX shell, so `ifndef USER` never fires and the | ||
| # target would silently fall back to the current OS username. Require it to be | ||
| # passed on the command line, and reject an empty value. | ||
| ifneq ($(origin USER),command line) | ||
| $(error USER is required. Usage: make dev-seed-kus USER=demo PASS=demo123) | ||
| endif | ||
| ifeq ($(strip $(USER)),) | ||
| $(error USER is required. Usage: make dev-seed-kus USER=demo PASS=demo123) | ||
| endif | ||
| ifeq ($(strip $(PASS)),) | ||
| $(error PASS is required. Usage: make dev-seed-kus USER=demo PASS=demo123) | ||
| endif | ||
| cd server/backend && uv run python ../scripts/seed-kus.py --user "$(USER)" --pass "$(PASS)" --url "http://localhost:$(DEV_API_PORT)" | ||
|
|
||
| .PHONY: dev-seed-all | ||
| dev-seed-all: | ||
| ifneq ($(origin USER),command line) | ||
| $(error USER is required. Usage: make dev-seed-all USER=demo PASS=demo123) | ||
| endif | ||
| ifeq ($(strip $(USER)),) | ||
| $(error USER is required. Usage: make dev-seed-all USER=demo PASS=demo123) | ||
| endif | ||
| ifeq ($(strip $(PASS)),) | ||
| $(error PASS is required. Usage: make dev-seed-all USER=demo PASS=demo123) | ||
| endif | ||
| $(MAKE) dev-seed-users USER="$(USER)" PASS="$(PASS)" | ||
| $(MAKE) dev-seed-kus USER="$(USER)" PASS="$(PASS)" | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| .PHONY: validate-schema | ||
| validate-schema: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.