Repository navigation
Expand file tree
/
Copy pathtask-init
More file actions
executable file
·161 lines (145 loc) · 5.53 KB
/
Copy pathtask-init
File metadata and controls
executable file
·161 lines (145 loc) · 5.53 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
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage: task-init [--help] [--force] [impl] [impl-options]
Sets up the current git repo for an agentic-workflow implementation.
With no impl argument, shows an interactive TUI selector (fzf or gum) if available,
or falls back to a two-step numbered menu.
Implementations:
claude-jira Claude Code + Jira (Atlassian MCP)
Options: --site URL, --key PROJ, --board NAME, --force
claude-notion Claude Code + Notion MCP
Options: --force, --help-ids
claude-gh Claude Code + GitHub Projects (gh CLI)
Options: --force
claude-local Claude Code + local markdown task tracking (no external tracker)
Options: --force
kiro-notion Kiro CLI + Notion MCP
Options: --force, --help-ids
kiro-gh Kiro CLI + GitHub Projects (gh CLI)
Options: --force
kiro-local Kiro CLI + local markdown task tracking (no external tracker)
Options: --force
Global options:
--force Overwrite existing config files (passed through to impl)
-h, --help Show this help
Examples:
task-init
task-init claude-gh
task-init kiro-gh --force
task-init claude-jira --site https://acme.atlassian.net --key PROJ --board "My Board"
EOF
exit 0
}
# Resolve own path through symlinks to find the repo root
src="${BASH_SOURCE[0]}"
while [ -L "$src" ]; do
dir=$(cd -P "$(dirname "$src")" && pwd)
src=$(readlink "$src")
[[ $src != /* ]] && src="$dir/$src"
done
REPO_ROOT=$(cd -P "$(dirname "$src")" && pwd)
IMPL=""
FORCE_FLAG=""
HELP_IDS=false
PASSTHROUGH=()
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help) usage ;;
--force) FORCE_FLAG="--force"; shift ;;
--help-ids) HELP_IDS=true; PASSTHROUGH+=("$1"); shift ;;
claude-jira|claude-notion|claude-gh|claude-local|kiro-notion|kiro-gh|kiro-local) IMPL="$1"; shift ;;
*) PASSTHROUGH+=("$1"); shift ;;
esac
done
# --help-ids only prints a guide; skip git-repo check and TUI selector
if [[ "$HELP_IDS" == true ]]; then
if [[ -z "$IMPL" ]]; then
echo "Error: specify an impl with --help-ids (e.g. task-init claude-notion --help-ids)" >&2
exit 1
fi
IMPL_INIT="$REPO_ROOT/$IMPL/bin/task-init"
[[ -f "$IMPL_INIT" ]] || { echo "Error: $IMPL_INIT not found. Is the repository complete?" >&2; exit 1; }
[[ -x "$IMPL_INIT" ]] || { echo "Error: $IMPL_INIT is not executable." >&2; exit 1; }
exec "$IMPL_INIT" "${PASSTHROUGH[@]}"
fi
git rev-parse --show-toplevel >/dev/null 2>&1 || { echo "Error: not in a git repo" >&2; exit 1; }
if [[ -z "$IMPL" ]]; then
_LABELS=(
"Claude Code + GitHub Projects → .claude/gh-workflow.md"
"Claude Code + Notion → .claude/notion-workflow.md"
"Claude Code + Jira → .claude/jira-workflow.md"
"Claude Code + local tracking → .claude/local-workflow.md"
"Kiro + GitHub Projects → .kiro/steering/gh-workflow.md"
"Kiro + Notion → .kiro/steering/notion-workflow.md"
"Kiro + local tracking → .kiro/steering/local-workflow.md"
)
_TARGETS=(claude-gh claude-notion claude-jira claude-local kiro-gh kiro-notion kiro-local)
_resolve_label() {
local selected="$1" i
for i in "${!_LABELS[@]}"; do
[[ "${_LABELS[$i]}" == "$selected" ]] && echo "${_TARGETS[$i]}" && return 0
done
}
if command -v fzf &>/dev/null; then
if SELECTED=$(printf '%s\n' "${_LABELS[@]}" \
| fzf --prompt="Select implementation (↑↓ / Enter): "); then
IMPL=$(_resolve_label "$SELECTED")
else
exit 1
fi
elif command -v gum &>/dev/null; then
if SELECTED=$(gum choose "${_LABELS[@]}"); then
IMPL=$(_resolve_label "$SELECTED")
else
exit 1
fi
else
echo "Which AI tool?"
echo " 1) Claude Code"
echo " 2) Kiro"
read -erp "Choice [1-2]: " tool_choice
case "$tool_choice" in
1)
echo ""
echo "Which board/tracker?"
echo " 1) Jira (Atlassian MCP) → .claude/jira-workflow.md + CLAUDE.md"
echo " 2) Notion (Notion MCP) → .claude/notion-workflow.md + CLAUDE.md"
echo " 3) GitHub Projects (gh CLI) → .claude/gh-workflow.md + CLAUDE.md"
echo " 4) Local markdown → .claude/local-workflow.md + CLAUDE.md + tasks/"
read -erp "Choice [1-4]: " board_choice
case "$board_choice" in
1) IMPL="claude-jira" ;;
2) IMPL="claude-notion" ;;
3) IMPL="claude-gh" ;;
4) IMPL="claude-local" ;;
*) echo "Invalid choice: $board_choice" >&2; exit 1 ;;
esac ;;
2)
echo ""
echo "Which board/tracker?"
echo " 1) Notion (Notion MCP) → .kiro/steering/notion-workflow.md"
echo " 2) GitHub Projects (gh CLI) → .kiro/steering/gh-workflow.md"
echo " 3) Local markdown → .kiro/steering/local-workflow.md + tasks/"
read -erp "Choice [1-3]: " board_choice
case "$board_choice" in
1) IMPL="kiro-notion" ;;
2) IMPL="kiro-gh" ;;
3) IMPL="kiro-local" ;;
*) echo "Invalid choice: $board_choice" >&2; exit 1 ;;
esac ;;
*) echo "Invalid choice: $tool_choice" >&2; exit 1 ;;
esac
fi
fi
IMPL_INIT="$REPO_ROOT/$IMPL/bin/task-init"
if [[ ! -f "$IMPL_INIT" ]]; then
echo "Error: $IMPL_INIT not found. Is the repository complete?" >&2
exit 1
fi
if [[ ! -x "$IMPL_INIT" ]]; then
echo "Error: $IMPL_INIT is not executable." >&2
exit 1
fi
exec "$IMPL_INIT" $FORCE_FLAG ${PASSTHROUGH[@]+"${PASSTHROUGH[@]}"}