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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Add JIRA multi-instance integration
Adam Eivyc6feee0e07dc
diff --git a/client/src/App.jsx b/client/src/App.jsxindex 70298c2940..87b4f37b6b 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -15,6 +15,7 @@ import Agents from './pages/Agents';import Uploads from './pages/Uploads';import Shell from './pages/Shell';import BrowserPage from './pages/Browser';+import Jira from './pages/Jira';// Lazy load heavier pages for code splitting// DevTools pages are large (~2300 lines total) so lazy load them@@ -64,6 +65,7 @@ export default function App() {<Route path="uploads" element={<Uploads />} /><Route path="shell" element={<Shell />} /><Route path="browser" element={<BrowserPage />} />+ <Route path="jira" element={<Jira />} /><Route path="city" element={<CyberCity />} /><Route path="city/settings" element={<CyberCity />} /><Route path="agents" element={<Agents />} />diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsxindex aeca793cf6..1b7f3d9188 100644--- a/client/src/components/Layout.jsx+++ b/client/src/components/Layout.jsx@@ -33,7 +33,8 @@ import {SquareTerminal,Globe,Newspaper,- Building2+ Building2,+ Ticket} from 'lucide-react';import packageJson from '../../package.json';import Logo from './Logo';@@ -58,6 +59,7 @@ const navItems = [{ to: '/apps', label: 'Apps', icon: Package, single: true },{ href: '//:5560', label: 'Autofixer', icon: Wrench, external: true, dynamicHost: true },{ to: '/browser', label: 'Browser', icon: Globe, single: true },+ { to: '/jira', label: 'JIRA', icon: Ticket, single: true },{label: 'Chief of Staff',icon: Crown,diff --git a/client/src/pages/Jira.jsx b/client/src/pages/Jira.jsxnew file mode 100644index 0000000000..5a2419dadd--- /dev/null+++ b/client/src/pages/Jira.jsx@@ -0,0 +1,412 @@+import { useState, useEffect } from 'react';+import toast from 'react-hot-toast';+import api from '../services/api';++export default function Jira() {+ const [instances, setInstances] = useState({});+ const [loading, setLoading] = useState(true);+ const [editingInstance, setEditingInstance] = useState(null);+ const [testingInstance, setTestingInstance] = useState(null);+ const [testResult, setTestResult] = useState(null);+ const [saveError, setSaveError] = useState(null);+ const [saving, setSaving] = useState(false);+ const [deleteConfirm, setDeleteConfirm] = useState(null);++ // Form state+ const [formData, setFormData] = useState({+ id: '',+ name: '',+ baseUrl: '',+ email: '',+ apiToken: ''+ });++ useEffect(() => {+ loadInstances();+ }, []);++ const loadInstances = async () => {+ try {+ setLoading(true);+ const response = await api.get('/api/jira/instances');+ setInstances(response.data.instances || {});+ } catch (error) {+ console.error('Failed to load JIRA instances:', error);+ toast.error(`Failed to load JIRA instances: ${error.message}`);+ } finally {+ setLoading(false);+ }+ };++ const handleEdit = (instance) => {+ setEditingInstance(instance.id);+ setFormData({+ id: instance.id,+ name: instance.name,+ baseUrl: instance.baseUrl,+ email: instance.email,+ apiToken: '' // Don't pre-fill token for security+ });+ setTestResult(null);+ setSaveError(null);+ };++ const handleCreate = () => {+ setEditingInstance('new');+ setFormData({+ id: '',+ name: '',+ baseUrl: '',+ email: '',+ apiToken: ''+ });+ setTestResult(null);+ setSaveError(null);+ };++ const handleCancel = () => {+ setEditingInstance(null);+ setFormData({+ id: '',+ name: '',+ baseUrl: '',+ email: '',+ apiToken: ''+ });+ setTestResult(null);+ setSaveError(null);+ };++ const handleSave = async () => {+ try {+ setSaving(true);+ setSaveError(null);++ const payload = {+ id: formData.id || formData.name.toLowerCase().replace(/\s+/g, '-'),+ name: formData.name,+ baseUrl: formData.baseUrl,+ email: formData.email,+ apiToken: formData.apiToken+ };++ console.log('Saving JIRA instance:', payload);+ await api.post('/api/jira/instances', payload);++ toast.success(`JIRA instance "${payload.name}" saved successfully`);+ await loadInstances();+ handleCancel();+ } catch (error) {+ console.error('Failed to save JIRA instance:', error);+ setSaveError(error.message);+ toast.error(`Failed to save: ${error.message}`);+ } finally {+ setSaving(false);+ }+ };++ const handleDeleteClick = (instanceId) => {+ setDeleteConfirm(instanceId);+ };++ const handleDeleteConfirm = async () => {+ const instanceId = deleteConfirm;+ setDeleteConfirm(null);++ try {+ await api.delete(`/api/jira/instances/${instanceId}`);+ toast.success(`JIRA instance "${instanceId}" deleted`);+ await loadInstances();+ } catch (error) {+ console.error('Failed to delete JIRA instance:', error);+ toast.error(`Failed to delete: ${error.message}`);+ }+ };++ const handleDeleteCancel = () => {+ setDeleteConfirm(null);+ };++ const handleTest = async (instanceId) => {+ try {+ setTestingInstance(instanceId);+ setTestResult(null);++ const response = await api.post(`/api/jira/instances/${instanceId}/test`);+ setTestResult(response.data);++ if (response.data.success) {+ toast.success('Connection successful!');+ }+ } catch (error) {+ setTestResult({+ success: false,+ error: error.message+ });+ toast.error(`Connection failed: ${error.message}`);+ } finally {+ setTestingInstance(null);+ }+ };++ const handleInputChange = (e) => {+ setFormData({+ ...formData,+ [e.target.name]: e.target.value+ });+ // Clear error when user starts typing+ if (saveError) {+ setSaveError(null);+ }+ };++ if (loading) {+ return (+ <div className="flex justify-center items-center h-screen">+ <div className="text-gray-400">Loading JIRA instances...</div>+ </div>+ );+ }++ return (+ <div className="p-6 max-w-6xl mx-auto">+ <div className="flex justify-between items-center mb-6">+ <h1 className="text-2xl font-bold text-white">JIRA Integration</h1>+ {!editingInstance && (+ <button+ onClick={handleCreate}+ className="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded"+ >+ + Add JIRA Instance+ </button>+ )}+ </div>++ {/* Delete Confirmation Modal */}+ {deleteConfirm && (+ <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">+ <div className="bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4">+ <h3 className="text-xl font-bold text-white mb-4">Delete JIRA Instance?</h3>+ <p className="text-gray-300 mb-6">+ Are you sure you want to delete "{deleteConfirm}"? This will not affect existing tickets.+ </p>+ <div className="flex gap-2 justify-end">+ <button+ onClick={handleDeleteCancel}+ className="px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded"+ >+ Cancel+ </button>+ <button+ onClick={handleDeleteConfirm}+ className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded"+ >+ Delete+ </button>+ </div>+ </div>+ </div>+ )}++ {editingInstance ? (+ <div className="bg-gray-800 rounded-lg p-6 mb-6">+ <h2 className="text-xl font-bold text-white mb-4">+ {editingInstance === 'new' ? 'Add' : 'Edit'} JIRA Instance+ </h2>++ {saveError && (+ <div className="mb-4 p-3 bg-red-900 border border-red-700 rounded">+ <p className="text-red-300 font-medium">Error saving JIRA instance</p>+ <p className="text-red-400 text-sm mt-1">{saveError}</p>+ </div>+ )}++ <div className="space-y-4">+ <div>+ <label className="block text-sm font-medium text-gray-300 mb-1">+ Instance ID+ </label>+ <input+ type="text"+ name="id"+ value={formData.id}+ onChange={handleInputChange}+ disabled={editingInstance !== 'new'}+ className="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white disabled:opacity-50"+ placeholder="e.g., company-jira"+ />+ <p className="text-xs text-gray-400 mt-1">+ Unique identifier (cannot be changed after creation)+ </p>+ </div>++ <div>+ <label className="block text-sm font-medium text-gray-300 mb-1">+ Display Name+ </label>+ <input+ type="text"+ name="name"+ value={formData.name}+ onChange={handleInputChange}+ className="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white"+ placeholder="e.g., Company JIRA"+ />+ </div>++ <div>+ <label className="block text-sm font-medium text-gray-300 mb-1">+ Base URL+ </label>+ <input+ type="url"+ name="baseUrl"+ value={formData.baseUrl}+ onChange={handleInputChange}+ className="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white"+ placeholder="https://jira.example.com"+ />+ </div>++ <div>+ <label className="block text-sm font-medium text-gray-300 mb-1">+ </label>+ <input+ type="email"+ name="email"+ value={formData.email}+ onChange={handleInputChange}+ className="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white"+ placeholder="[email protected]"+ />+ </div>++ <div>+ <label className="block text-sm font-medium text-gray-300 mb-1">+ API Token (Personal Access Token)+ </label>+ <input+ type="password"+ name="apiToken"+ value={formData.apiToken}+ onChange={handleInputChange}+ className="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white"+ placeholder="Enter your JIRA Personal Access Token"+ />+ <p className="text-xs text-gray-400 mt-1">+ Generate this from your JIRA profile → Personal Access Tokens+ </p>+ </div>++ <div className="flex gap-2">+ <button+ onClick={handleSave}+ disabled={saving || !formData.name || !formData.baseUrl || !formData.email || !formData.apiToken}+ className="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded disabled:opacity-50 disabled:cursor-not-allowed"+ >+ {saving ? 'Saving...' : 'Save'}+ </button>+ <button+ onClick={handleCancel}+ disabled={saving}+ className="px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded disabled:opacity-50"+ >+ Cancel+ </button>+ </div>+ </div>+ </div>+ ) : null}++ <div className="space-y-4">+ {Object.values(instances).length === 0 ? (+ <div className="bg-gray-800 rounded-lg p-8 text-center">+ <p className="text-gray-400">No JIRA instances configured.</p>+ <p className="text-gray-500 text-sm mt-2">+ Add a JIRA instance to enable ticket creation for your apps.+ </p>+ </div>+ ) : (+ Object.values(instances).map((instance) => (+ <div key={instance.id} className="bg-gray-800 rounded-lg p-6">+ <div className="flex justify-between items-start">+ <div className="flex-1">+ <h3 className="text-lg font-bold text-white">{instance.name}</h3>+ <p className="text-gray-400 text-sm mt-1">{instance.baseUrl}</p>+ <p className="text-gray-500 text-sm">Email: {instance.email}</p>+ <p className="text-gray-500 text-sm">+ API Token: {instance.hasApiToken ? '✓ Configured' : '✗ Not set'}+ </p>+ </div>++ <div className="flex gap-2">+ <button+ onClick={() => handleTest(instance.id)}+ disabled={testingInstance === instance.id}+ className="px-3 py-1 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded disabled:opacity-50"+ >+ {testingInstance === instance.id ? 'Testing...' : 'Test'}+ </button>+ <button+ onClick={() => handleEdit(instance)}+ className="px-3 py-1 bg-yellow-600 hover:bg-yellow-700 text-white text-sm rounded"+ >+ Edit+ </button>+ <button+ onClick={() => handleDeleteClick(instance.id)}+ className="px-3 py-1 bg-red-600 hover:bg-red-700 text-white text-sm rounded"+ >+ Delete+ </button>+ </div>+ </div>++ {testResult && testResult.success !== undefined && (+ <div+ className={`mt-4 p-3 rounded ${+ testResult.success+ ? 'bg-green-900 border border-green-700'+ : 'bg-red-900 border border-red-700'+ }`}+ >+ {testResult.success ? (+ <div>+ <p className="text-green-300 font-medium">✓ Connection successful</p>+ <p className="text-green-400 text-sm mt-1">+ Authenticated as: {testResult.user} ({testResult.email})+ </p>+ </div>+ ) : (+ <div>+ <p className="text-red-300 font-medium">✗ Connection failed</p>+ <p className="text-red-400 text-sm mt-1">{testResult.error}</p>+ </div>+ )}+ </div>+ )}+ </div>+ ))+ )}+ </div>++ <div className="mt-8 bg-gray-800 rounded-lg p-6">+ <h2 className="text-lg font-bold text-white mb-4">Usage</h2>+ <div className="space-y-2 text-sm text-gray-300">+ <p>1. Add one or more JIRA instances above</p>+ <p>2. Go to Apps and configure JIRA settings for each app</p>+ <p>+ 3. When the Chief of Staff works on an app with JIRA enabled, it will:+ </p>+ <ul className="list-disc list-inside ml-4 space-y-1 text-gray-400">+ <li>Create a JIRA ticket for the work</li>+ <li>Create a feature branch (e.g., feature/PROJ-1234)</li>+ <li>Make commits to that branch</li>+ <li>Create a pull request with ticket link</li>+ </ul>+ </div>+ </div>+ </div>+ );+}diff --git a/server/index.js b/server/index.jsindex 909807b79d..86d52a8987 100644--- a/server/index.js+++ b/server/index.js@@ -38,6 +38,7 @@ import lmstudioRoutes from './routes/lmstudio.js';import browserRoutes from './routes/browser.js';import moltworldToolsRoutes from './routes/moltworldTools.js';import moltworldWsRoutes from './routes/moltworldWs.js';+import jiraRoutes from './routes/jira.js';import { initSocket } from './services/socket.js';import { initScriptRunner } from './services/scriptRunner.js';import { errorMiddleware, setupProcessErrorHandlers, asyncHandler } from './lib/errorHandler.js';@@ -204,6 +205,7 @@ app.use('/api/digital-twin/genome', genomeRoutes);app.use('/api/digital-twin', digitalTwinRoutes);app.use('/api/lmstudio', lmstudioRoutes);app.use('/api/browser', browserRoutes);+app.use('/api/jira', jiraRoutes);// Initialize script runnerinitScriptRunner().catch(err => console.error(`❌ Script runner init failed: ${err.message}`));diff --git a/server/routes/jira.js b/server/routes/jira.jsnew file mode 100644index 0000000000..35e9154ff9--- /dev/null+++ b/server/routes/jira.js@@ -0,0 +1,205 @@+/**+ * JIRA API Routes+ */++import express from 'express';+import * as jiraService from '../services/jira.js';+import { ServerError } from '../lib/errorHandler.js';++const router = express.Router();++/**+ * GET /api/jira/instances+ * Get all JIRA instances+ */+router.get('/instances', async (req, res, next) => {+ try {+ const config = await jiraService.getInstances();++ // Don't send API tokens to client+ const sanitized = {+ instances: Object.fromEntries(+ Object.entries(config.instances).map(([id, instance]) => [+ id,+ {+ id: instance.id,+ name: instance.name,+ baseUrl: instance.baseUrl,+ email: instance.email,+ hasApiToken: !!instance.apiToken,+ createdAt: instance.createdAt,+ updatedAt: instance.updatedAt+ }+ ])+ )+ };++ res.json(sanitized);+ } catch (error) {+ next(error);+ }+});++/**+ * POST /api/jira/instances+ * Create or update JIRA instance+ */+router.post('/instances', async (req, res, next) => {+ try {+ const { id, name, baseUrl, email, apiToken } = req.body;++ if (!id || !name || !baseUrl || !email || !apiToken) {+ throw new ServerError('Missing required fields', {+ status: 400,+ code: 'INVALID_INPUT'+ });+ }++ const instance = await jiraService.upsertInstance(id, {+ name,+ baseUrl,+ email,+ apiToken+ });++ // Don't send API token back+ const sanitized = {+ id: instance.id,+ name: instance.name,+ baseUrl: instance.baseUrl,+ email: instance.email,+ hasApiToken: true,+ createdAt: instance.createdAt,+ updatedAt: instance.updatedAt+ };++ res.json(sanitized);+ } catch (error) {+ next(error);+ }+});++/**+ * DELETE /api/jira/instances/:id+ * Delete JIRA instance+ */+router.delete('/instances/:id', async (req, res, next) => {+ try {+ await jiraService.deleteInstance(req.params.id);+ res.json({ success: true });+ } catch (error) {+ next(error);+ }+});++/**+ * POST /api/jira/instances/:id/test+ * Test JIRA instance connection+ */+router.post('/instances/:id/test', async (req, res, next) => {+ try {+ const result = await jiraService.testConnection(req.params.id);+ res.json(result);+ } catch (error) {+ next(error);+ }+});++/**+ * GET /api/jira/instances/:id/projects+ * Get projects for JIRA instance+ */+router.get('/instances/:id/projects', async (req, res, next) => {+ try {+ const projects = await jiraService.getProjects(req.params.id);+ res.json(projects);+ } catch (error) {+ next(error);+ }+});++/**+ * POST /api/jira/instances/:id/tickets+ * Create JIRA ticket+ */+router.post('/instances/:id/tickets', async (req, res, next) => {+ try {+ const result = await jiraService.createTicket(req.params.id, req.body);+ res.json(result);+ } catch (error) {+ next(error);+ }+});++/**+ * PUT /api/jira/instances/:instanceId/tickets/:ticketId+ * Update JIRA ticket+ */+router.put('/instances/:instanceId/tickets/:ticketId', async (req, res, next) => {+ try {+ const result = await jiraService.updateTicket(+ req.params.instanceId,+ req.params.ticketId,+ req.body+ );+ res.json(result);+ } catch (error) {+ next(error);+ }+});++/**+ * POST /api/jira/instances/:instanceId/tickets/:ticketId/comments+ * Add comment to JIRA ticket+ */+router.post('/instances/:instanceId/tickets/:ticketId/comments', async (req, res, next) => {+ try {+ const { comment } = req.body;++ if (!comment) {+ throw new ServerError('Comment is required', {+ status: 400,+ code: 'INVALID_INPUT'+ });+ }++ const result = await jiraService.addComment(+ req.params.instanceId,+ req.params.ticketId,+ comment+ );++ res.json(result);+ } catch (error) {+ next(error);+ }+});++/**+ * POST /api/jira/instances/:instanceId/tickets/:ticketId/transition+ * Transition JIRA ticket status+ */+router.post('/instances/:instanceId/tickets/:ticketId/transition', async (req, res, next) => {+ try {+ const { transitionId } = req.body;++ if (!transitionId) {+ throw new ServerError('Transition ID is required', {+ status: 400,+ code: 'INVALID_INPUT'+ });+ }++ const result = await jiraService.transitionTicket(+ req.params.instanceId,+ req.params.ticketId,+ transitionId+ );++ res.json(result);+ } catch (error) {+ next(error);+ }+});++export default router;diff --git a/server/services/jira.js b/server/services/jira.jsnew file mode 100644index 0000000000..9f22eb0ec1--- /dev/null+++ b/server/services/jira.js@@ -0,0 +1,278 @@+/**+ * JIRA API Service+ * Supports multiple JIRA instances with Personal Access Tokens+ */++import axios from 'axios';+import https from 'https';+import fs from 'fs/promises';+import path from 'path';+import { fileURLToPath } from 'url';++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const JIRA_CONFIG_FILE = path.join(__dirname, '../../data/jira.json');++/**+ * Get JIRA instances configuration+ */+export async function getInstances() {+ try {+ const content = await fs.readFile(JIRA_CONFIG_FILE, 'utf-8');+ return JSON.parse(content);+ } catch (error) {+ if (error.code === 'ENOENT') {+ // Initialize with empty config+ const defaultConfig = { instances: {} };+ await saveInstances(defaultConfig);+ return defaultConfig;+ }+ throw error;+ }+}++/**+ * Save JIRA instances configuration+ */+export async function saveInstances(config) {+ await fs.writeFile(+ JIRA_CONFIG_FILE,+ JSON.stringify(config, null, 2),+ 'utf-8'+ );+}++/**+ * Add or update JIRA instance+ */+export async function upsertInstance(instanceId, instanceData) {+ const config = await getInstances();++ config.instances[instanceId] = {+ id: instanceId,+ name: instanceData.name,+ baseUrl: instanceData.baseUrl,+ email: instanceData.email,+ apiToken: instanceData.apiToken, // PAT (Personal Access Token)+ createdAt: config.instances[instanceId]?.createdAt || new Date().toISOString(),+ updatedAt: new Date().toISOString()+ };++ await saveInstances(config);+ return config.instances[instanceId];+}++/**+ * Delete JIRA instance+ */+export async function deleteInstance(instanceId) {+ const config = await getInstances();+ delete config.instances[instanceId];+ await saveInstances(config);+}++/**+ * Create axios client for JIRA instance+ */+function createJiraClient(instance) {+ return axios.create({+ baseURL: instance.baseUrl,+ headers: {+ 'Authorization': `Bearer ${instance.apiToken}`,+ 'Content-Type': 'application/json',+ 'Accept': 'application/json'+ },+ httpsAgent: new https.Agent({+ rejectUnauthorized: false // Allow self-signed certs for internal JIRA+ }),+ timeout: 30000+ });+}++/**+ * Test JIRA instance connection+ */+export async function testConnection(instanceId) {+ const config = await getInstances();+ const instance = config.instances[instanceId];++ if (!instance) {+ throw new Error(`JIRA instance ${instanceId} not found`);+ }++ const client = createJiraClient(instance);++ try {+ // Test with /rest/api/2/myself endpoint+ const response = await client.get('/rest/api/2/myself');+ return {+ success: true,+ user: response.data.displayName,+ email: response.data.emailAddress+ };+ } catch (error) {+ return {+ success: false,+ error: error.response?.data?.message || error.message+ };+ }+}++/**+ * Get projects for JIRA instance+ */+export async function getProjects(instanceId) {+ const config = await getInstances();+ const instance = config.instances[instanceId];++ if (!instance) {+ throw new Error(`JIRA instance ${instanceId} not found`);+ }++ const client = createJiraClient(instance);+ const response = await client.get('/rest/api/2/project');++ return response.data.map(project => ({+ key: project.key,+ name: project.name,+ id: project.id+ }));+}++/**+ * Create JIRA ticket+ */+export async function createTicket(instanceId, ticketData) {+ const config = await getInstances();+ const instance = config.instances[instanceId];++ if (!instance) {+ throw new Error(`JIRA instance ${instanceId} not found`);+ }++ const client = createJiraClient(instance);++ const issue = {+ fields: {+ project: {+ key: ticketData.projectKey+ },+ summary: ticketData.summary,+ description: ticketData.description || ticketData.summary,+ issuetype: {+ name: ticketData.issueType || 'Task'+ }+ }+ };++ // Add optional fields+ if (ticketData.assignee) {+ issue.fields.assignee = { name: ticketData.assignee };+ }++ if (ticketData.storyPoints) {+ issue.fields.customfield_10106 = ticketData.storyPoints;+ }++ if (ticketData.epicKey) {+ issue.fields.customfield_10101 = ticketData.epicKey;+ }++ if (ticketData.sprint) {+ issue.fields.customfield_10105 = ticketData.sprint;+ }++ if (ticketData.labels && ticketData.labels.length > 0) {+ issue.fields.labels = ticketData.labels;+ }++ const response = await client.post('/rest/api/2/issue', issue);++ const ticketId = response.data.key;+ const ticketUrl = `${instance.baseUrl}/browse/${ticketId}`;++ return {+ success: true,+ ticketId,+ url: ticketUrl,+ response: response.data+ };+}++/**+ * Update JIRA ticket+ */+export async function updateTicket(instanceId, ticketId, updates) {+ const config = await getInstances();+ const instance = config.instances[instanceId];++ if (!instance) {+ throw new Error(`JIRA instance ${instanceId} not found`);+ }++ const client = createJiraClient(instance);++ const payload = {+ fields: updates+ };++ await client.put(`/rest/api/2/issue/${ticketId}`, payload);++ return {+ success: true,+ ticketId,+ url: `${instance.baseUrl}/browse/${ticketId}`+ };+}++/**+ * Add comment to JIRA ticket+ */+export async function addComment(instanceId, ticketId, comment) {+ const config = await getInstances();+ const instance = config.instances[instanceId];++ if (!instance) {+ throw new Error(`JIRA instance ${instanceId} not found`);+ }++ const client = createJiraClient(instance);++ await client.post(`/rest/api/2/issue/${ticketId}/comment`, {+ body: comment+ });++ return { success: true };+}++/**+ * Transition JIRA ticket (change status)+ */+export async function transitionTicket(instanceId, ticketId, transitionId) {+ const config = await getInstances();+ const instance = config.instances[instanceId];++ if (!instance) {+ throw new Error(`JIRA instance ${instanceId} not found`);+ }++ const client = createJiraClient(instance);++ await client.post(`/rest/api/2/issue/${ticketId}/transitions`, {+ transition: { id: transitionId }+ });++ return { success: true };+}++export default {+ getInstances,+ saveInstances,+ upsertInstance,+ deleteInstance,+ testConnection,+ getProjects,+ createTicket,+ updateTicket,+ addComment,+ transitionTicket+};