|
2 | 2 | # |
3 | 3 | # make_new_job.sh - Create directory structure for a new DeepWork job |
4 | 4 | # |
5 | | -# Usage: ./make_new_job.sh <job_name> |
| 5 | +# Usage: ./make_new_job.sh --project-root DIR <job_name> |
6 | 6 | # |
7 | 7 | # Input: |
8 | | -# job_name - Lowercase name using only letters, numbers, and underscores. |
9 | | -# Must start with a letter. |
| 8 | +# --project-root DIR - Required. The MCP server's project root directory. |
| 9 | +# Jobs are created at DIR/.deepwork/jobs/<job_name>/. |
| 10 | +# job_name - Lowercase name using only letters, numbers, and |
| 11 | +# underscores. Must start with a letter. |
10 | 12 | # |
11 | 13 | # Output: |
12 | | -# Creates .deepwork/jobs/<job_name>/ at the git repository root with |
| 14 | +# Creates .deepwork/jobs/<job_name>/ under the specified project root with |
13 | 15 | # subdirectories: hooks/, templates/, scripts/, plus AGENTS.md |
14 | 16 | # and optionally .deepreview (if template.deepreview exists alongside |
15 | 17 | # this script). |
16 | 18 | # |
17 | 19 | # Exit codes: |
18 | 20 | # 0 - Success |
19 | 21 | # 1 - Usage error (missing args, invalid job name, job already exists, |
20 | | -# not a git repository) |
| 22 | +# missing --project-root) |
21 | 23 | # |
22 | 24 |
|
23 | 25 | set -euo pipefail |
@@ -54,28 +56,52 @@ main() { |
54 | 56 | local script_dir |
55 | 57 | script_dir="$(cd "$(dirname "$0")" && pwd)" |
56 | 58 |
|
| 59 | + # Parse --project-root flag |
| 60 | + local project_root="" |
| 61 | + while [[ $# -gt 0 ]]; do |
| 62 | + case "$1" in |
| 63 | + --project-root) |
| 64 | + if [[ $# -lt 2 ]]; then |
| 65 | + error "--project-root requires a directory argument" |
| 66 | + fi |
| 67 | + project_root="$2" |
| 68 | + shift 2 |
| 69 | + ;; |
| 70 | + -*) |
| 71 | + error "Unknown option: $1" |
| 72 | + ;; |
| 73 | + *) |
| 74 | + break |
| 75 | + ;; |
| 76 | + esac |
| 77 | + done |
| 78 | + |
| 79 | + if [[ -z "$project_root" ]]; then |
| 80 | + error "--project-root is required. Pass the project_root from the MCP workflow response." |
| 81 | + fi |
| 82 | + |
| 83 | + if [[ ! -d "$project_root" ]]; then |
| 84 | + error "Project root directory does not exist: $project_root" |
| 85 | + fi |
| 86 | + |
57 | 87 | if [[ $# -lt 1 ]]; then |
58 | | - echo "Usage: $0 <job_name>" |
| 88 | + echo "Usage: $0 --project-root DIR <job_name>" |
59 | 89 | echo "" |
60 | 90 | echo "Creates the directory structure for a new DeepWork job." |
61 | 91 | echo "" |
62 | 92 | echo "Arguments:" |
63 | | - echo " job_name Name of the job (lowercase, underscores allowed)" |
| 93 | + echo " --project-root DIR Project root directory (required)" |
| 94 | + echo " job_name Name of the job (lowercase, underscores allowed)" |
64 | 95 | echo "" |
65 | 96 | echo "Example:" |
66 | | - echo " $0 competitive_research" |
| 97 | + echo " $0 --project-root /path/to/project competitive_research" |
67 | 98 | exit 1 |
68 | 99 | fi |
69 | 100 |
|
70 | 101 | local job_name="$1" |
71 | 102 | validate_job_name "$job_name" |
72 | 103 |
|
73 | | - # Determine the base path by anchoring to the git repository root |
74 | | - local repo_root |
75 | | - if ! repo_root="$(git rev-parse --show-toplevel 2>/dev/null)"; then |
76 | | - error "Not inside a git repository. Run this from within a git repo." |
77 | | - fi |
78 | | - local base_path="${repo_root}/.deepwork/jobs" |
| 104 | + local base_path="${project_root}/.deepwork/jobs" |
79 | 105 | mkdir -p "$base_path" |
80 | 106 |
|
81 | 107 | local job_path="${base_path}/${job_name}" |
|
0 commit comments