npx claudepluginhub moonsite/moonsite-claude-extensions --plugin jira-autopilotYou are stopping work on the current Jira issue, building a worklog, and posting it to Jira.
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(ls -d ~/.claude/plugins/cache/moonsite-claude-extensions/jira-autopilot/*/ 2>/dev/null | sort -V | tail -1)}"
CLI="${PLUGIN_ROOT}hooks-handlers/jira_core.py"
Resolve PROJECT_ROOT by walking up to find .claude/jira-autopilot.json (handles git worktrees):
_dir="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
PROJECT_ROOT=""
while [ "$_dir" != "/" ]; do
[ -f "$_dir/.claude/jira-autopilot.json" ] && PROJECT_ROOT="$_dir" && break
_dir="$(dirname "$_dir")"
done
[ -z "$PROJECT_ROOT" ] && _mr="$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null | sed 's|/\.git$||')" && [ -f "$_mr/.claude/jira-autopilot.json" ] && PROJECT_ROOT="$_mr"
[ -z "$PROJECT_ROOT" ] && PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
python3 "$CLI" get-session "$PROJECT_ROOT"
Read the config:
cat "$PROJECT_ROOT/.claude/jira-autopilot.json"
If there is no active task (currentIssue is null or empty):
/start-work to begin tracking."/approve-work.Get the current issue key and autonomy level.
python3 "$CLI" build-worklog "$PROJECT_ROOT" "ISSUE_KEY"
Returns:
{
"issueKey": "KEY-42",
"seconds": 1800,
"summary": "Edited auth.ts, login.tsx",
"rawFacts": {
"files": ["src/auth.ts", "src/login.tsx"],
"commands": ["npm test"],
"activityCount": 12
},
"logLanguage": "English"
}
If no work was tracked (seconds == 0 and no activities), inform the user and ask if they still want to stop tracking the issue.
STOP. READ THIS BEFORE PROCEEDING.
You MUST write a human-readable worklog description. This is NOT optional. If you skip this step or post raw technical output, the worklog is useless to the user.
NEVER post any of these to Jira:
Read logLanguage from the project config. ALL worklog text MUST be in this language (e.g. if "Hebrew" → write in Hebrew, not English).
Write the worklog description yourself based on the rawFacts:
logLanguageSELF-CHECK before posting: Does your description contain any English technical terms like "Activity:", "Created", "Edited", "Tool", "Bash"? If yes, REWRITE it in proper logLanguage.
Bad example (NEVER do this):
Work session: Files: /Users/boris/Source/project/src/components/table.tsx, /Users/boris/Source/project/src/utils/api.ts Tools: Edit, Bash, Write
Good example (Hebrew):
עדכון רכיב הטבלה — הוספת עמודות חדשות, תיקון מיון ושיפור ביצועים. עדכון שכבת ה-API עם endpoints חדשים.
Good example (English):
Updated table component — added new columns, fixed sorting, improved performance. Updated API layer with new endpoints.
Read timeRounding and accuracy from config.
Time rounding rules:
Always round UP. Minimum one rounding increment (never zero).
Show both actual and rounded time:
Actual time: 27 minutes
Rounded time: 30 minutes (rounded up to 15-min increments)
If the time exceeds 4 hours (14400 seconds), cap it and inform the user:
Time capped at 4 hours (actual: 5h 12m). This is the maximum for a single worklog.
Present the worklog summary and time to the user, then offer 5 options:
Worklog for KEY-42: {summary}
Time: {rounded_time}
Files: {file_list}
Options:
1. Approve — post this worklog to Jira
2. Approve + go silent — approve this and auto-approve future worklogs for this issue
3. Edit summary — modify the worklog description before posting
4. Log to different issue — redirect this worklog to another issue
5. Reject — keep for later (deferred) or drop entirely
Handle each option:
autoApproveWorklogs: true for this issue in session, then proceed to Step 6.status: "deferred".status: "dropped".Show the worklog summary and time, then auto-approve after a brief display:
Posting worklog for KEY-42: {summary} ({rounded_time})
Silent post with one-line confirmation:
Logged {rounded_time} to KEY-42.
The SUMMARY_TEXT must be the enriched human-readable description from Step 3, NOT raw file paths or tool names.
echo '{"issueKey":"ISSUE_KEY","seconds":SECONDS,"comment":"SUMMARY_TEXT"}' | python3 "$CLI" add-worklog "$PROJECT_ROOT"
If posting fails:
status: "failed"./approve-work."If posting succeeds:
status: "posted".If there were work chunks for this issue, post a summary comment to the Jira issue:
python3 "$CLI" add-comment "$PROJECT_ROOT" "ISSUE_KEY" "COMMENT_TEXT"
The comment should summarize what was done (files changed, key actions) in the configured language.
python3 "$CLI" stop-tracking "$PROJECT_ROOT" "ISSUE_KEY"
This should:
activeIssues.currentIssue to null (or the next active issue if multiple are being tracked).Stopped tracking KEY-42: {summary}
Time logged: {rounded_time}
Worklog: {status}
Check if on a feature branch:
CURRENT_BRANCH=$(git branch --show-current 2>/dev/null)
If the branch contains the issue key:
Offer 3 options:
git checkout main (or master/develop).If there are unpushed commits, auto-suggest opening a PR:
You have unpushed commits on {branch}. Consider opening a PR.
/jira-setup first."failed" and inform the user it can be retried.