Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(jira): add weekly JIRA status report generation and UI

Adam Eivy7b60415a522e
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 1e3afde456..98e67b58a4 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -18,6 +18,7 @@ import Settings from './pages/Settings';
import Shell from './pages/Shell';
import BrowserPage from './pages/Browser';
import Jira from './pages/Jira';
+import JiraReports from './pages/JiraReports';
import Insights from './pages/Insights';
import Instances from './pages/Instances';
import MeatSpace from './pages/MeatSpace';
@@ -132,6 +133,7 @@ export default function App() {
<Route path="datadog" element={<Navigate to="/devtools/datadog" replace />} />
<Route path="jira" element={<Navigate to="/devtools/jira" replace />} />
<Route path="devtools/jira" element={<Jira />} />
+ <Route path="devtools/jira/reports" element={<JiraReports />} />
<Route path="city" element={<CyberCity />} />
<Route path="city/settings" element={<CyberCity />} />
<Route path="character" element={<CharacterSheet />} />
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 64fd627f53..5a223c5095 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -152,6 +152,7 @@ const navItems = [
{ to: '/devtools/history', label: 'History', icon: History },
{ to: '/instances', label: 'Instances', icon: Network },
{ to: '/devtools/jira', label: 'JIRA', icon: Ticket },
+ { to: '/devtools/jira/reports', label: 'JIRA Reports', icon: FileText },
{ to: '/devtools/processes', label: 'Processes', icon: Activity },
{ to: '/shell', label: 'Shell', icon: SquareTerminal },
{ to: '/devtools/usage', label: 'Usage', icon: BarChart3 }
diff --git a/client/src/components/cos/tabs/TaskItem.jsx b/client/src/components/cos/tabs/TaskItem.jsx
index 9d79c8ac3d..b1a963c1f0 100644
--- a/client/src/components/cos/tabs/TaskItem.jsx
+++ b/client/src/components/cos/tabs/TaskItem.jsx
@@ -47,6 +47,7 @@ function extractTaskType(description) {
if (d.includes('typing') || d.includes('typescript')) return 'task:typing';
if (d.includes('release')) return 'task:release-check';
if (d.includes('dependency')) return 'task:dependency-updates';
+ if (d.includes('jira') && d.includes('report')) return 'task:jira-status-report';
if (d.includes('jira') || d.includes('sprint')) return 'task:jira-sprint-manager';
}
diff --git a/client/src/pages/Jira.jsx b/client/src/pages/Jira.jsx
index 695ae84d8e..156a5746ef 100644
--- a/client/src/pages/Jira.jsx
+++ b/client/src/pages/Jira.jsx
@@ -1,4 +1,5 @@
import { useState, useEffect } from 'react';
+import { Link } from 'react-router-dom';
import toast from 'react-hot-toast';
import api from '../services/api';
@@ -183,14 +184,22 @@ export default function Jira() {
<div className="p-4 sm:p-6 max-w-6xl mx-auto">
<div className="flex flex-col sm:flex-row sm:justify-between sm:items-center gap-4 mb-6">
<h1 className="text-xl sm:text-2xl font-bold text-white">JIRA Integration</h1>
- {!editingInstance && (
- <button
- onClick={handleCreate}
- className="w-full sm:w-auto px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded"
+ <div className="flex items-center gap-2">
+ <Link
+ to="/devtools/jira/reports"
+ className="px-4 py-2 border border-port-border hover:border-port-accent text-gray-300 hover:text-white rounded text-sm"
>
- + Add JIRA Instance
- </button>
- )}
+ Status Reports
+ </Link>
+ {!editingInstance && (
+ <button
+ onClick={handleCreate}
+ className="w-full sm:w-auto px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded"
+ >
+ + Add JIRA Instance
+ </button>
+ )}
+ </div>
</div>
{/* Delete Confirmation Modal */}
diff --git a/client/src/pages/JiraReports.jsx b/client/src/pages/JiraReports.jsx
new file mode 100644
index 0000000000..23a1b663c4
--- /dev/null
+++ b/client/src/pages/JiraReports.jsx
@@ -0,0 +1,309 @@
+import { useState, useEffect } from 'react';
+import { useSearchParams } from 'react-router-dom';
+import toast from 'react-hot-toast';
+import {
+ FileText,
+ RefreshCw,
+ ChevronDown,
+ ChevronRight,
+ BarChart3,
+ Users,
+ CheckCircle,
+ Clock,
+ AlertCircle,
+ Loader2
+} from 'lucide-react';
+import * as api from '../services/api';
+
+const PRIORITY_COLORS = {
+ Highest: 'text-red-400',
+ High: 'text-orange-400',
+ Medium: 'text-yellow-400',
+ Low: 'text-blue-400',
+ Lowest: 'text-gray-400'
+};
+
+function ProgressBar({ value, max, color = 'bg-port-accent' }) {
+ const pct = max > 0 ? Math.round((value / max) * 100) : 0;
+ return (
+ <div className="w-full bg-port-border rounded-full h-2">
+ <div className={`${color} h-2 rounded-full transition-all`} style={{ width: `${pct}%` }} />
+ </div>
+ );
+}
+
+function StatCard({ icon: Icon, label, value, sub, color = 'text-port-accent' }) {
+ return (
+ <div className="bg-port-card border border-port-border rounded-lg p-3">
+ <div className="flex items-center gap-2 mb-1">
+ <Icon size={14} className={color} />
+ <span className="text-xs text-gray-400">{label}</span>
+ </div>
+ <div className="text-xl font-bold text-white">{value}</div>
+ {sub && <div className="text-xs text-gray-500 mt-0.5">{sub}</div>}
+ </div>
+ );
+}
+
+function TicketRow({ ticket }) {
+ return (
+ <div className="flex items-center gap-3 py-1.5 px-2 hover:bg-port-border/30 rounded text-sm">
+ <a
+ href={ticket.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-port-accent hover:underline font-mono text-xs shrink-0"
+ >
+ {ticket.key}
+ </a>
+ <span className="text-white truncate flex-1">{ticket.summary}</span>
+ {ticket.storyPoints != null && (
+ <span className="text-xs bg-port-border rounded-full px-1.5 py-0.5 text-gray-400 shrink-0">
+ {ticket.storyPoints}pt
+ </span>
+ )}
+ <span className={`text-xs shrink-0 ${PRIORITY_COLORS[ticket.priority] || 'text-gray-400'}`}>
+ {ticket.priority}
+ </span>
+ <span className="text-xs text-gray-500 shrink-0 w-24 truncate">{ticket.assignee}</span>
+ </div>
+ );
+}
+
+function TicketSection({ title, tickets, icon: Icon, iconColor, defaultOpen = false }) {
+ const [open, setOpen] = useState(defaultOpen);
+
+ if (!tickets?.length) return null;
+
+ return (
+ <div className="mb-3">
+ <button
+ onClick={() => setOpen(!open)}
+ className="flex items-center gap-2 w-full text-left py-1.5 px-2 hover:bg-port-border/30 rounded"
+ >
+ {open ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
+ <Icon size={14} className={iconColor} />
+ <span className="text-sm font-medium text-white">{title}</span>
+ <span className="text-xs text-gray-500 ml-auto">{tickets.length}</span>
+ </button>
+ {open && (
+ <div className="ml-2 border-l border-port-border pl-2 mt-1">
+ {tickets.map(t => <TicketRow key={t.key} ticket={t} />)}
+ </div>
+ )}
+ </div>
+ );
+}
+
+function ReportCard({ report, onClick, isSelected }) {
+ return (
+ <button
+ onClick={onClick}
+ className={`w-full text-left p-3 rounded-lg border transition-colors ${
+ isSelected
+ ? 'bg-port-accent/10 border-port-accent'
+ : 'bg-port-card border-port-border hover:border-gray-600'
+ }`}
+ >
+ <div className="flex items-center justify-between mb-1">
+ <span className="text-sm font-medium text-white">{report.appName || report.appId}</span>
+ <span className="text-xs text-gray-500">{report.date}</span>
+ </div>
+ <div className="flex items-center gap-3 text-xs text-gray-400">
+ <span className="text-port-success">{report.summary.done} done</span>
+ <span className="text-port-accent">{report.summary.inProgress} in progress</span>
+ <span className="text-gray-500">{report.summary.todo} to do</span>
+ <span className="ml-auto">{report.summary.completionRate}%</span>
+ </div>
+ </button>
+ );
+}
+
+function ReportDetail({ report }) {
+ if (!report) {
+ return (
+ <div className="flex items-center justify-center h-64 text-gray-500">
+ Select a report to view details
+ </div>
+ );
+ }
+
+ const { summary, byAssignee, tickets } = report;
+
+ return (
+ <div className="space-y-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-lg font-bold text-white">{report.appName || report.appId}</h3>
+ <p className="text-sm text-gray-400">
+ {report.projectKey} &middot; {report.date} &middot; Generated {new Date(report.generatedAt).toLocaleString()}
+ </p>
+ </div>
+ </div>
+
+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-2">
+ <StatCard icon={BarChart3} label="Total Tickets" value={summary.totalTickets} />
+ <StatCard icon={CheckCircle} label="Done" value={summary.done} color="text-port-success" sub={`${summary.completedPoints} pts`} />
+ <StatCard icon={Clock} label="In Progress" value={summary.inProgress} color="text-port-accent" sub={`${summary.inProgressPoints} pts`} />
+ <StatCard icon={AlertCircle} label="To Do" value={summary.todo} color="text-gray-400" sub={`${summary.remainingPoints - summary.inProgressPoints} pts`} />
+ </div>
+
+ <div>
+ <div className="flex items-center justify-between text-xs text-gray-400 mb-1">
+ <span>Sprint Progress</span>
+ <span>{summary.completionRate}% ({summary.completedPoints}/{summary.totalPoints} pts)</span>
+ </div>
+ <ProgressBar value={summary.completedPoints} max={summary.totalPoints} color="bg-port-success" />
+ </div>
+
+ {Object.keys(byAssignee).length > 0 && (
+ <div>
+ <h4 className="text-sm font-medium text-gray-300 mb-2 flex items-center gap-1.5">
+ <Users size={14} /> By Assignee
+ </h4>
+ <div className="space-y-1.5">
+ {Object.entries(byAssignee)
+ .sort((a, b) => (b[1].done + b[1].inProgress) - (a[1].done + a[1].inProgress))
+ .map(([name, stats]) => (
+ <div key={name} className="flex items-center gap-3 text-sm px-2 py-1 bg-port-card rounded border border-port-border">
+ <span className="text-white w-32 truncate">{name}</span>
+ <span className="text-port-success text-xs">{stats.done}d</span>
+ <span className="text-port-accent text-xs">{stats.inProgress}ip</span>
+ <span className="text-gray-500 text-xs">{stats.todo}td</span>
+ <span className="text-xs text-gray-400 ml-auto">{stats.points} pts</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+
+ <div>
+ <TicketSection title="In Progress" tickets={tickets.inProgress} icon={Clock} iconColor="text-port-accent" defaultOpen={true} />
+ <TicketSection title="To Do" tickets={tickets.todo} icon={AlertCircle} iconColor="text-gray-400" />
+ <TicketSection title="Done (Sprint)" tickets={tickets.done} icon={CheckCircle} iconColor="text-port-success" />
+ <TicketSection title="Recently Completed (7 days)" tickets={tickets.recentlyCompleted} icon={CheckCircle} iconColor="text-green-400" />
+ </div>
+ </div>
+ );
+}
+
+export default function JiraReports() {
+ const [searchParams, setSearchParams] = useSearchParams();
+ const [reports, setReports] = useState([]);
+ const [selectedReport, setSelectedReport] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [generating, setGenerating] = useState(false);
+ const [apps, setApps] = useState([]);
+
+ const filterAppId = searchParams.get('app') || '';
+
+ useEffect(() => {
+ loadReports();
+ loadApps();
+ }, []);
+
+ const loadApps = async () => {
+ const allApps = await api.getApps();
+ const jiraApps = (allApps || []).filter(a => a.jira?.enabled);
+ setApps(jiraApps);
+ };
+
+ const loadReports = async () => {
+ setLoading(true);
+ const result = await api.getJiraReports();
+ setReports(result || []);
+ setLoading(false);
+ };
+
+ const handleGenerate = async (appId = null) => {
+ setGenerating(true);
+ const result = await api.generateJiraReport(appId);
+ if (result) {
+ toast.success(appId ? 'Report generated' : `Generated ${Array.isArray(result) ? result.length : 1} report(s)`);
+ await loadReports();
+ if (!Array.isArray(result) && result.appId) {
+ setSelectedReport(result);
+ }
+ }
+ setGenerating(false);
+ };
+
+ const handleSelectReport = async (reportMeta) => {
+ const full = await api.getJiraReport(reportMeta.appId, reportMeta.date);
+ if (full) setSelectedReport(full);
+ };
+
+ const handleFilterApp = (appId) => {
+ if (appId) {
+ setSearchParams({ app: appId });
+ } else {
+ setSearchParams({});
+ }
+ setSelectedReport(null);
+ };
+
+ const filteredReports = filterAppId
+ ? reports.filter(r => r.appId === filterAppId)
+ : reports;
+
+ return (
+ <div className="p-4 max-w-7xl mx-auto">
+ <div className="flex items-center justify-between mb-4">
+ <div className="flex items-center gap-2">
+ <FileText size={20} className="text-port-accent" />
+ <h1 className="text-lg font-bold text-white">JIRA Status Reports</h1>
+ </div>
+ <div className="flex items-center gap-2">
+ <select
+ value={filterAppId}
+ onChange={e => handleFilterApp(e.target.value)}
+ className="bg-port-card border border-port-border rounded px-2 py-1.5 text-sm text-white"
+ >
+ <option value="">All Apps</option>
+ {apps.map(app => (
+ <option key={app.id} value={app.id}>{app.name}</option>
+ ))}
+ </select>
+ <button
+ onClick={() => handleGenerate(filterAppId || null)}
+ disabled={generating}
+ className="flex items-center gap-1.5 bg-port-accent hover:bg-blue-600 text-white text-sm px-3 py-1.5 rounded disabled:opacity-50"
+ >
+ {generating ? <Loader2 size={14} className="animate-spin" /> : <RefreshCw size={14} />}
+ {generating ? 'Generating...' : 'Generate Report'}
+ </button>
+ </div>
+ </div>
+
+ {loading ? (
+ <div className="flex items-center justify-center h-64">
+ <Loader2 size={24} className="animate-spin text-port-accent" />
+ </div>
+ ) : filteredReports.length === 0 ? (
+ <div className="flex flex-col items-center justify-center h-64 text-gray-500">
+ <FileText size={48} className="mb-3 opacity-30" />
+ <p>No reports yet. Generate your first report above.</p>
+ {apps.length === 0 && (
+ <p className="text-xs mt-2">Enable JIRA on an app first (Apps &rarr; Edit &rarr; JIRA)</p>
+ )}
+ </div>
+ ) : (
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
+ <div className="space-y-2 lg:col-span-1 max-h-[calc(100vh-160px)] overflow-y-auto pr-1">
+ {filteredReports.map(r => (
+ <ReportCard
+ key={`${r.appId}-${r.date}`}
+ report={r}
+ onClick={() => handleSelectReport(r)}
+ isSelected={selectedReport?.appId === r.appId && selectedReport?.date === r.date}
+ />
+ ))}
+ </div>
+ <div className="lg:col-span-2 bg-port-bg border border-port-border rounded-lg p-4 max-h-[calc(100vh-160px)] overflow-y-auto">
+ <ReportDetail report={selectedReport} />
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/services/api.js b/client/src/services/api.js
index e128bb2fdb..ec3b253b80 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -1644,6 +1644,15 @@ export const transitionJiraTicket = (instanceId, ticketId, transitionId, options
...options
});
+// JIRA Status Reports
+export const getJiraReports = () => request('/jira/reports');
+export const generateJiraReport = (appId) => request('/jira/reports/generate', {
+ method: 'POST',
+ body: JSON.stringify(appId ? { appId } : {})
+});
+export const getJiraReport = (appId, date) => request(`/jira/reports/${appId}/${date}`);
+export const getLatestJiraReport = (appId) => request(`/jira/reports/${appId}/latest`);
+
// Browser - CDP browser management
export const getBrowserStatus = () => request('/browser');
export const getBrowserConfig = () => request('/browser/config');
diff --git a/server/routes/jira.js b/server/routes/jira.js
index 13d87fef35..b6254f5099 100644
--- a/server/routes/jira.js
+++ b/server/routes/jira.js
@@ -4,6 +4,8 @@
import express from 'express';
import * as jiraService from '../services/jira.js';
+import * as jiraReports from '../services/jiraReports.js';
+import { getAppById } from '../services/apps.js';
import { ServerError } from '../lib/errorHandler.js';
const router = express.Router();
@@ -285,4 +287,80 @@ router.get('/instances/:instanceId/projects/:projectKey/epics', async (req, res,
}
});
+// ============================================================
+// JIRA Status Reports
+// ============================================================
+
+/**
+ * GET /api/jira/reports
+ * List all JIRA status reports, optionally filtered by appId
+ */
+router.get('/reports', async (req, res, next) => {
+ try {
+ const reports = await jiraReports.listReports(req.query.appId || null);
+ res.json(reports);
+ } catch (error) {
+ next(error);
+ }
+});
+
+/**
+ * POST /api/jira/reports/generate
+ * Generate status report for a specific app or all JIRA-enabled apps
+ */
+router.post('/reports/generate', async (req, res, next) => {
+ try {
+ const { appId } = req.body;
+
+ if (appId) {
+ const app = await getAppById(appId);
+ if (!app) {
+ throw new ServerError('App not found', { status: 404, code: 'NOT_FOUND' });
+ }
+ if (!app.jira?.enabled) {
+ throw new ServerError('JIRA is not enabled for this app', { status: 400, code: 'JIRA_NOT_ENABLED' });
+ }
+ const report = await jiraReports.generateReport(appId, app);
+ res.json(report);
+ } else {
+ const reports = await jiraReports.generateAllReports();
+ res.json(reports);
+ }
+ } catch (error) {
+ next(error);
+ }
+});
+
+/**
+ * GET /api/jira/reports/:appId/latest
+ * Get the latest report for an app
+ */
+router.get('/reports/:appId/latest', async (req, res, next) => {
+ try {
+ const report = await jiraReports.getLatestReport(req.params.appId);
+ if (!report) {
+ throw new ServerError('No reports found for this app', { status: 404, code: 'NOT_FOUND' });
+ }
+ res.json(report);
+ } catch (error) {
+ next(error);
+ }
+});
+
+/**
+ * GET /api/jira/reports/:appId/:date
+ * Get a specific report by app and date
+ */
+router.get('/reports/:appId/:date', async (req, res, next) => {
+ try {
+ const report = await jiraReports.getReport(req.params.appId, req.params.date);
+ if (!report) {
+ throw new ServerError('Report not found', { status: 404, code: 'NOT_FOUND' });
+ }
+ res.json(report);
+ } catch (error) {
+ next(error);
+ }
+});
+
export default router;
diff --git a/server/services/jira.js b/server/services/jira.js
index 2de49457a9..5152b67495 100644
--- a/server/services/jira.js
+++ b/server/services/jira.js
@@ -76,7 +76,7 @@ export async function deleteInstance(instanceId) {
/**
* Create axios client for JIRA instance
*/
-function createJiraClient(instance) {
+export function createJiraClient(instance) {
if (instance.allowSelfSigned) {
console.warn(`⚠️ JIRA instance ${instance.name || instance.id} using allowSelfSigned — TLS verification disabled`);
}
diff --git a/server/services/jiraReports.js b/server/services/jiraReports.js
new file mode 100644
index 0000000000..92aec02b07
--- /dev/null
+++ b/server/services/jiraReports.js
@@ -0,0 +1,247 @@
+/**
+ * JIRA Status Report Service
+ * Generates weekly status reports from JIRA for JIRA-enabled projects
+ */
+
+import { writeFile, readdir } from 'fs/promises';
+import { join } from 'path';
+import { ensureDir, PATHS, readJSONFile } from '../lib/fileUtils.js';
+import { getInstances, createJiraClient } from './jira.js';
+import { getActiveApps } from './apps.js';
+
+const REPORTS_DIR = join(PATHS.data, 'jira-reports');
+
+function mapIssue(issue, baseUrl) {
+ return {
+ key: issue.key,
+ summary: issue.fields.summary,
+ status: issue.fields.status.name,
+ statusCategory: issue.fields.status.statusCategory?.name,
+ priority: issue.fields.priority?.name,
+ issueType: issue.fields.issuetype?.name,
+ assignee: issue.fields.assignee?.displayName || 'Unassigned',
+ storyPoints: issue.fields.customfield_10106,
+ updated: issue.fields.updated,
+ url: `${baseUrl}/browse/${issue.key}`
+ };
+}
+
+async function getSprintTickets(instance, projectKey) {
+ const client = createJiraClient(instance);
+ const jql = `project = "${projectKey}" AND sprint in openSprints() ORDER BY status ASC, priority DESC, updated DESC`;
+
+ const response = await client.get('/rest/api/2/search', {
+ params: {
+ jql,
+ fields: 'summary,status,priority,issuetype,assignee,updated,created,customfield_10106,resolution',
+ maxResults: 100
+ }
+ });
+
+ return response.data.issues.map(issue => ({
+ ...mapIssue(issue, instance.baseUrl),
+ created: issue.fields.created,
+ resolved: issue.fields.resolution?.name || null
+ }));
+}
+
+async function getRecentlyCompleted(instance, projectKey) {
+ const client = createJiraClient(instance);
+ const jql = `project = "${projectKey}" AND status changed to Done AFTER -7d ORDER BY updated DESC`;
+
+ const response = await client.get('/rest/api/2/search', {
+ params: {
+ jql,
+ fields: 'summary,status,priority,issuetype,assignee,updated,customfield_10106,resolutiondate',
+ maxResults: 50
+ }
+ });
+
+ return response.data.issues.map(issue => ({
+ ...mapIssue(issue, instance.baseUrl),
+ resolvedAt: issue.fields.resolutiondate
+ }));
+}
+
+const TICKET_SUMMARY_FIELDS = ['key', 'summary', 'priority', 'assignee', 'storyPoints', 'url'];
+function ticketSummary(ticket, extraFields = []) {
+ const obj = {};
+ for (const f of [...TICKET_SUMMARY_FIELDS, ...extraFields]) {
+ if (ticket[f] !== undefined) obj[f] = ticket[f];
+ }
+ return obj;
+}
+
+/**
+ * Generate a status report for a single app
+ */
+export async function generateReport(appId, app) {
+ const jiraConfig = app.jira;
+ if (!jiraConfig?.enabled || !jiraConfig.instanceId || !jiraConfig.projectKey) {
+ return null;
+ }
+
+ const config = await getInstances();
+ const instance = config.instances[jiraConfig.instanceId];
+ if (!instance) {
+ console.error(`❌ JIRA instance ${jiraConfig.instanceId} not found for app ${appId}`);
+ return null;
+ }
+
+ const [sprintTickets, recentlyCompleted] = await Promise.all([
+ getSprintTickets(instance, jiraConfig.projectKey),
+ getRecentlyCompleted(instance, jiraConfig.projectKey)
+ ]);
+
+ const todo = sprintTickets.filter(t => t.statusCategory === 'To Do');
+ const inProgress = sprintTickets.filter(t => t.statusCategory === 'In Progress');
+ const done = sprintTickets.filter(t => t.statusCategory === 'Done');
+
+ const totalPoints = sprintTickets.reduce((sum, t) => sum + (t.storyPoints || 0), 0);
+ const completedPoints = done.reduce((sum, t) => sum + (t.storyPoints || 0), 0);
+ const inProgressPoints = inProgress.reduce((sum, t) => sum + (t.storyPoints || 0), 0);
+
+ const byAssignee = {};
+ for (const ticket of sprintTickets) {
+ const name = ticket.assignee;
+ if (!byAssignee[name]) {
+ byAssignee[name] = { todo: 0, inProgress: 0, done: 0, points: 0 };
+ }
+ if (ticket.statusCategory === 'To Do') byAssignee[name].todo++;
+ else if (ticket.statusCategory === 'In Progress') byAssignee[name].inProgress++;
+ else if (ticket.statusCategory === 'Done') byAssignee[name].done++;
+ byAssignee[name].points += ticket.storyPoints || 0;
+ }
+
+ const byPriority = {};
+ for (const ticket of sprintTickets) {
+ const priority = ticket.priority || 'None';
+ if (!byPriority[priority]) byPriority[priority] = 0;
+ byPriority[priority]++;
+ }
+
+ const report = {
+ appId,
+ appName: app.name,
+ projectKey: jiraConfig.projectKey,
+ instanceId: jiraConfig.instanceId,
+ generatedAt: new Date().toISOString(),
+ date: new Date().toISOString().split('T')[0],
+ summary: {
+ totalTickets: sprintTickets.length,
+ todo: todo.length,
+ inProgress: inProgress.length,
+ done: done.length,
+ totalPoints,
+ completedPoints,
+ inProgressPoints,
+ remainingPoints: totalPoints - completedPoints,
+ completionRate: sprintTickets.length > 0
+ ? Math.round((done.length / sprintTickets.length) * 100)
+ : 0,
+ recentlyCompletedCount: recentlyCompleted.length
+ },
+ byAssignee,
+ byPriority,
+ tickets: {
+ todo: todo.map(t => ticketSummary(t)),
+ inProgress: inProgress.map(t => ticketSummary(t)),
+ done: done.map(t => ticketSummary(t)),
+ recentlyCompleted: recentlyCompleted.map(t => ticketSummary(t, ['resolvedAt']))
+ }
+ };
+
+ await ensureDir(REPORTS_DIR);
+ const filename = `${appId}-${report.date}.json`;
+ await writeFile(join(REPORTS_DIR, filename), JSON.stringify(report, null, 2));
+ console.log(`📊 JIRA status report generated for ${app.name} (${jiraConfig.projectKey})`);
+
+ return report;
+}
+
+/**
+ * Generate status reports for all JIRA-enabled apps
+ */
+export async function generateAllReports() {
+ const apps = await getActiveApps();
+ const jiraApps = apps.filter(app => app.jira?.enabled && app.jira?.instanceId && app.jira?.projectKey);
+
+ if (jiraApps.length === 0) {
+ console.log(`📊 No JIRA-enabled apps found for status report generation`);
+ return [];
+ }
+
+ const results = await Promise.allSettled(
+ jiraApps.map(app => generateReport(app.id, app))
+ );
+ const reports = results
+ .filter(r => r.status === 'fulfilled' && r.value)
+ .map(r => r.value);
+
+ console.log(`📊 Generated ${reports.length} JIRA status reports`);
+ return reports;
+}
+
+/**
+ * Get a stored report by app and date
+ */
+export async function getReport(appId, date) {
+ const filename = `${appId}-${date}.json`;
+ const filepath = join(REPORTS_DIR, filename);
+ return readJSONFile(filepath, null);
+}
+
+/**
+ * List all reports, optionally filtered by appId.
+ * Returns summary data from each report for display in lists.
+ */
+export async function listReports(appId = null) {
+ await ensureDir(REPORTS_DIR);
+ const files = await readdir(REPORTS_DIR);
+
+ const entries = files
+ .filter(f => f.endsWith('.json'))
+ .filter(f => !appId || f.startsWith(`${appId}-`))
+ .map(f => {
+ const parts = f.replace('.json', '').split('-');
+ const date = parts.slice(-3).join('-');
+ const app = parts.slice(0, -3).join('-');
+ return { appId: app, date, filename: f };
+ })
+ .sort((a, b) => b.date.localeCompare(a.date));
+
+ const results = await Promise.all(
+ entries.map(async entry => {
+ const filepath = join(REPORTS_DIR, entry.filename);
+ const report = await readJSONFile(filepath, null);
+ if (!report) return null;
+ return {
+ appId: entry.appId,
+ date: entry.date,
+ appName: report.appName,
+ projectKey: report.projectKey,
+ generatedAt: report.generatedAt,
+ summary: report.summary
+ };
+ })
+ );
+
+ return results.filter(Boolean);
+}
+
+/**
+ * Get the latest report for an app
+ */
+export async function getLatestReport(appId) {
+ await ensureDir(REPORTS_DIR);
+ const files = await readdir(REPORTS_DIR);
+
+ const matching = files
+ .filter(f => f.endsWith('.json') && f.startsWith(`${appId}-`))
+ .sort()
+ .reverse();
+
+ if (matching.length === 0) return null;
+ const filepath = join(REPORTS_DIR, matching[0]);
+ return readJSONFile(filepath, null);
+}
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index d78aa75a88..f235ed9b25 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -594,6 +594,22 @@ Do NOT comment on JIRA tickets directly — all action items go to the Review Hu
9. Generate a summary report covering triage actions taken and implementation work completed`,
+ 'jira-status-report': `[Task: {appName}] JIRA Weekly Status Report
+
+Generate a JIRA status report for {appName}:
+
+Repository: {repoPath}
+
+1. Call POST /api/jira/reports/generate with the app's ID to generate a fresh status report
+2. The report will be automatically saved and available at /devtools/jira/reports
+
+This task runs on a schedule and generates status reports summarizing:
+- Sprint ticket counts by status (To Do, In Progress, Done)
+- Story point progress
+- Breakdown by assignee
+- Recently completed tickets (last 7 days)
+- Priority distribution`,
+
'branch-cleanup': `[Improvement: {appName}] Branch Cleanup — Delete Merged Branches
Clean up stale branches in {appName} that have already been merged into the default branch.
@@ -877,7 +893,7 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
'security', 'code-quality', 'test-coverage', 'performance',
'accessibility', 'branch-cleanup', 'console-errors', 'dependency-updates', 'documentation',
'ui-bugs', 'mobile-responsive', 'feature-ideas', 'error-handling',
- 'typing', 'release-check', 'pr-reviewer', 'jira-sprint-manager'
+ 'typing', 'release-check', 'pr-reviewer', 'jira-sprint-manager', 'jira-status-report'
];
const DEFAULT_TASK_INTERVALS = {
@@ -897,7 +913,8 @@ const DEFAULT_TASK_INTERVALS = {
'typing': { type: INTERVAL_TYPES.ONCE, enabled: false, providerId: null, model: null, prompt: null },
'release-check': { type: INTERVAL_TYPES.ON_DEMAND, enabled: false, providerId: null, model: null, prompt: null },
'pr-reviewer': { type: INTERVAL_TYPES.CUSTOM, intervalMs: 7200000, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null },
- 'jira-sprint-manager': { type: INTERVAL_TYPES.DAILY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null, taskMetadata: { useWorktree: true, openPR: true, simplify: true } }
+ 'jira-sprint-manager': { type: INTERVAL_TYPES.DAILY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null, taskMetadata: { useWorktree: true, openPR: true, simplify: true } },
+ 'jira-status-report': { type: INTERVAL_TYPES.WEEKLY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null }
};
/**
@@ -1747,7 +1764,8 @@ function getTaskTypeDescription(taskType) {
'error-handling': 'Improve error handling',
'typing': 'Improve TypeScript types',
'pr-reviewer': 'Review open PRs from contributors',
- 'jira-sprint-manager': 'Triage and implement JIRA sprint tickets'
+ 'jira-sprint-manager': 'Triage and implement JIRA sprint tickets',
+ 'jira-status-report': 'Generate JIRA weekly status report'
};
return descriptions[taskType] || taskType.replace(/-/g, ' ');
}