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

fix(jira): make jira-status-report read-only and run in PortOS context

Adam Eivyed0c2cf9231b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
new file mode 100644
index 0000000000..b5f132f9a0
--- /dev/null
+++ b/.changelog/NEXT.md
@@ -0,0 +1,14 @@
+# Unreleased Changes
+
+## Added
+
+## Changed
+
+## Fixed
+
+- jira-status-report task now runs in PortOS context (not the app's directory) and uses the correct PortOS API endpoint
+- jira-status-report agents no longer attempt to commit, push, or modify files (readOnly metadata flag)
+- readOnly tasks skip unnecessary git pull, JIRA branch creation, and worktree setup
+- Added `PORTOS_API_URL` constant to `ports.js` for dynamic API URL resolution in task prompts
+
+## Removed
diff --git a/server/lib/ports.js b/server/lib/ports.js
index ec0cfbe537..4fdf2e5230 100644
--- a/server/lib/ports.js
+++ b/server/lib/ports.js
@@ -2,3 +2,5 @@ export const PORTS = { API: 5555, UI: 5554 };
export const DEFAULT_PEER_PORT = PORTS.API;
export const PORTOS_UI_URL = process.env.PORTOS_UI_URL
|| `http://${process.env.PORTOS_HOST || 'localhost'}:${process.env.PORT_UI || PORTS.UI}`;
+export const PORTOS_API_URL = process.env.PORTOS_API_URL
+ || `http://${process.env.PORTOS_HOST || 'localhost'}:${process.env.PORT || PORTS.API}`;
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 107e90f575..40df3278c5 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -543,7 +543,7 @@ export function validateRequest(schema, data) {
// TASK METADATA SANITIZATION
// =============================================================================
-const ALLOWED_TASK_METADATA_KEYS = ['useWorktree', 'openPR', 'simplify', 'reviewLoop'];
+const ALLOWED_TASK_METADATA_KEYS = ['useWorktree', 'openPR', 'simplify', 'reviewLoop', 'readOnly'];
/**
* Sanitize taskMetadata to only allowed agent-option keys with boolean values.
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 083610bf71..7fb91fb950 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -1424,13 +1424,21 @@ export async function spawnAgentForTask(task) {
});
// Determine workspace path and resolve app name
- let workspacePath = task.metadata?.app
+ const isReadOnly = isTruthyMeta(task.metadata?.readOnly);
+ // Read-only tasks run in PortOS context since they call PortOS API endpoints
+ let workspacePath = task.metadata?.app && !isReadOnly
? await getAppWorkspace(task.metadata.app)
: ROOT_DIR;
const resolvedAppName = task.metadata?.app
? (await getAppById(task.metadata.app).catch(() => null))?.name || null
: null;
+ // Skip git operations, JIRA branch creation, and worktree setup for read-only tasks
+ let jiraTicket = null;
+ let jiraBranchName = null;
+ let worktreeInfo = null;
+
+ if (!isReadOnly) {
// Pull latest from git before starting work (scripted — no LLM needed)
const pullResult = await git.ensureLatest(workspacePath).catch(err => {
emitLog('warning', `⚠️ Pre-task git pull failed for ${workspacePath}: ${err.message}`, { taskId: task.id, workspace: workspacePath });
@@ -1477,8 +1485,6 @@ export async function spawnAgentForTask(task) {
}
// JIRA integration: create ticket + feature branch if app has JIRA enabled and task opted in
- let jiraTicket = null;
- let jiraBranchName = null;
const appData = await getAppDataForTask(task);
if (appData?.jira?.enabled && task.metadata?.createJiraTicket) {
@@ -1529,7 +1535,6 @@ export async function spawnAgentForTask(task) {
// useWorktree: work in an isolated worktree branch
// openPR: open a PR to default branch (implies useWorktree)
// When neither is set, only create a worktree if conflict is detected with other running agents.
- let worktreeInfo = null;
const explicitOpenPR = isTruthyMeta(task.metadata?.openPR);
const explicitWorktree = isTruthyMeta(task.metadata?.useWorktree) || explicitOpenPR;
@@ -1614,6 +1619,7 @@ export async function spawnAgentForTask(task) {
emitLog('debug', `No conflicts for task ${task.id}, using shared workspace`, { taskId: task.id });
}
}
+ } // end !isReadOnly
// Build the agent prompt (includes worktree and JIRA context if applicable)
const prompt = await buildAgentPrompt(task, config, workspacePath, worktreeInfo);
@@ -2908,7 +2914,7 @@ ${skillSection ? `## Task-Type Skill Guidelines\n\n${skillSection}\n` : ''}${too
- If blocked, explain clearly why
- Never update the PortOS changelog (\`.changelog/\`) for work on managed apps — the PortOS changelog tracks PortOS core changes only
- **BTW Messages**: The user may send you additional context while you work. Check for a \`BTW.md\` file in your working directory root — if it exists, read it for important messages from the user. Incorporate that context into your work. Do not delete or modify BTW.md.
-${task.metadata?.app && worktreeInfo && willOpenPR ? `- Commit code after each feature or bug fix using the git tools or /cam skill. A pull request will be automatically created when your task completes — do NOT open a PR manually.` : task.metadata?.app && worktreeInfo ? `- Commit code after each feature or bug fix using the git tools or /cam skill. Your worktree branch will be automatically merged back to the source branch when your task completes — do NOT open a PR.` : `- Commit code after each feature or bug fix using the git tools or /cam skill`}
+${isTruthyMeta(task.metadata?.readOnly) ? `- **This is a read-only task.** Do NOT commit, push, or modify any files in the repository. Only read data and generate reports.` : task.metadata?.app && worktreeInfo && willOpenPR ? `- Commit code after each feature or bug fix using the git tools or /cam skill. A pull request will be automatically created when your task completes — do NOT open a PR manually.` : task.metadata?.app && worktreeInfo ? `- Commit code after each feature or bug fix using the git tools or /cam skill. Your worktree branch will be automatically merged back to the source branch when your task completes — do NOT open a PR.` : `- Commit code after each feature or bug fix using the git tools or /cam skill`}
## Git Hygiene (CRITICAL)
- **Before starting work**, run \`git status\` to verify a clean working tree. If there are uncommitted changes from a previous agent or manual work, **stash or discard them** before proceeding — do NOT commit someone else's changes.
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index f235ed9b25..d1516b48ef 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -20,7 +20,7 @@ import { cosEvents, emitLog } from './cos.js';
import { DAY, ensureDir, HOUR, readJSONFile, PATHS, safeDate } from '../lib/fileUtils.js';
import { getAdaptiveCooldownMultiplier } from './taskLearning.js';
import { isTaskTypeEnabledForApp, getAppTaskTypeInterval, getActiveApps, getAppTaskTypeOverrides } from './apps.js';
-import { PORTOS_UI_URL } from '../lib/ports.js';
+import { PORTOS_UI_URL, PORTOS_API_URL } from '../lib/ports.js';
import { getUserTimezone, getLocalParts } from '../lib/timezone.js';
import { parseCronToNextRun } from './eventScheduler.js';
@@ -596,11 +596,10 @@ Do NOT comment on JIRA tickets directly — all action items go to the Review Hu
'jira-status-report': `[Task: {appName}] JIRA Weekly Status Report
-Generate a JIRA status report for {appName}:
+Generate a JIRA status report for {appName} (App ID: {appId}).
-Repository: {repoPath}
-
-1. Call POST /api/jira/reports/generate with the app's ID to generate a fresh status report
+1. Call the PortOS API to generate a fresh status report:
+ curl -X POST ${PORTOS_API_URL}/api/jira/reports/generate -H "Content-Type: application/json" -d '{"appId": "{appId}"}'
2. The report will be automatically saved and available at /devtools/jira/reports
This task runs on a schedule and generates status reports summarizing:
@@ -914,7 +913,7 @@ const DEFAULT_TASK_INTERVALS = {
'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-status-report': { type: INTERVAL_TYPES.WEEKLY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null }
+ 'jira-status-report': { type: INTERVAL_TYPES.WEEKLY, enabled: false, weekdaysOnly: true, providerId: null, model: null, prompt: null, taskMetadata: { readOnly: true } }
};
/**