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
feat: add /do:scan button to brain/links cloned repos
Adam Eivy97ff0248b114
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 9afdd40bd0..92ee5653e8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -6,6 +6,12 @@## Added+- **`/brain/links` — per-repo malware/risk scan button.** New "Scan" action (ShieldCheck icon) sits next to Open / Pull on every cloned-status GitHub repo. Clicking it queues a CoS user task that runs `/do:scan` against the clone's `localPath` — the bundled slashdo command is a hardened read-only audit (no scanned code is executed, no fetched URLs are followed, hostile-until-proven-safe). The agent writes its full markdown report to `~/.claude/scans/<basename>-<date>.md` and the user is told to track progress in CoS Tasks. Backed by a new `POST /api/brain/links/:id/scan` endpoint that loads the bundled slashdo body via `loadSlashdoCommand('scan')` and bakes the repo path into the task context as `SCAN_DIR`. Pre-flight checks reject non-cloned links, missing `localPath`, vanished folders, and duplicate in-flight scans for the same repo. Files: `server/routes/brain.js`, `client/src/services/apiBrain.js`, `client/src/components/brain/tabs/LinksTab.jsx`. The slashdo submodule is also bumped from `a38ee04` to `50011ef` (picks up `do:pr-better` and the v2.12.0 release).++## Changed++- **`loadSlashdoFile()` now caches resolved command bodies** (server/lib/fileUtils.js) — slashdo command markdown + their `!cat ~/.claude/lib/...` includes are static within a server lifetime (submodule updates require restart anyway), so the per-call ~26KB read + N-include resolution is now memoized in a process-lifetime `Map` keyed by `${commandName}::${stripFrontmatter}`. Eliminates redundant disk I/O for callers like the new `/brain/links/:id/scan` endpoint and the existing `/api/cos/tasks/slashdo` dispatch.+- **`docs/DEPS.md` — dependency audit reference.** New living doc that records every third-party dependency in PortOS, its tier classification (1 acceptable / 2 audited / 3 removable), and per-package rationale for being kept. Generated by `/do:depfree` runs so future audits can cross-reference prior verdicts and re-audit triggers (e.g. "if `pm2`/`needle` drops `sax`, revisit"). First pass (2026-04-28, default mode): 30 deps audited, 0 removals — `kokoro-js` kept (only pure-JS in-process TTS, replacement requires Python subprocess + pooling), `sax` flagged REMOVE then downgraded to KEEP (transitive) because `pm2 → [email protected] → [email protected]` already pulls the same major version (direct removal saves zero supply chain attack surface). PLAN.md now points at `docs/DEPS.md` instead of duplicating the table.- **One-click "Enable HTTPS" button on the Instances tab.** The Tailnet DNS & trusted HTTPS explainer used to instruct users to drop into a shell and run `npm run setup:cert`. New button on the same banner runs the same flow at runtime via a new `POST /api/instances/provision-cert` endpoint, which calls `tailscale cert` for the local MagicDNS hostname, writes `data/certs/{cert,key}.pem`, and updates `meta.json`. Failure modes (Tailscale not installed, not running, no MagicDNS hostname, HTTPS Certificates feature disabled in the tailnet admin) surface as toasts with actionable guidance. Because the HTTPS listener type is decided at server boot in `lib/tailscale-https.js`, the response includes `requiresRestart: true` whenever PortOS is currently running over HTTP — the UI then prompts the user to restart so the new cert actually takes effect; if HTTPS was already running, the existing `certRenewer` hot-swap path picks up the renewed cert without a restart. The button is disabled until MagicDNS is detected, mirroring what the underlying CLI requires. Files: `server/services/certProvisioner.js` (new), `server/routes/instances.js`, `client/src/services/apiSystem.js`, `client/src/pages/Instances.jsx`.diff --git a/client/src/components/brain/tabs/LinksTab.jsx b/client/src/components/brain/tabs/LinksTab.jsxindex 71cbcd9747..855f2a180f 100644--- a/client/src/components/brain/tabs/LinksTab.jsx+++ b/client/src/components/brain/tabs/LinksTab.jsx@@ -14,7 +14,8 @@ import {Check,AlertCircle,FolderOpen,- Tag+ Tag,+ ShieldCheck} from 'lucide-react';import toast from '../../ui/Toast';import { timeAgo } from '../../../utils/formatters';@@ -46,6 +47,7 @@ export default function LinksTab({ onRefresh }) {const [editingId, setEditingId] = useState(null);const [editForm, setEditForm] = useState({});const [confirmingDeleteId, setConfirmingDeleteId] = useState(null);+ const [scanningId, setScanningId] = useState(null);const inputRef = useRef(null);const fetchLinks = useCallback(async () => {@@ -189,6 +191,19 @@ export default function LinksTab({ onRefresh }) {});};+ const handleScan = async (linkId) => {+ setScanningId(linkId);+ const result = await api.scanBrainLink(linkId).catch(err => {+ toast.error(err.message || 'Failed to start scan');+ return null;+ });+ setScanningId(null);++ if (result) {+ toast.success('Malware scan queued — track progress in CoS Tasks');+ }+ };+if (loading) {return (<div className="flex items-center justify-center h-64">@@ -489,6 +504,19 @@ export default function LinksTab({ onRefresh }) {<RefreshCw size={12} />Pull</button>+ <button+ onClick={() => handleScan(link.id)}+ disabled={scanningId === link.id}+ className="flex items-center gap-1 px-2 py-1 text-xs rounded border border-port-border text-gray-400 hover:text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed"+ title="Read-only malware/risk scan via /do:scan (writes report to ~/.claude/scans/)"+ >+ {scanningId === link.id ? (+ <RefreshCw size={12} className="animate-spin" />+ ) : (+ <ShieldCheck size={12} />+ )}+ Scan+ </button></>)}</>diff --git a/client/src/services/apiBrain.js b/client/src/services/apiBrain.jsindex 1024d06f65..0c1a48c77b 100644--- a/client/src/services/apiBrain.js+++ b/client/src/services/apiBrain.js@@ -164,6 +164,7 @@ export const deleteBrainLink = (id) => request(`/brain/links/${id}`, { method: 'export const cloneBrainLink = (id) => request(`/brain/links/${id}/clone`, { method: 'POST' });export const pullBrainLink = (id) => request(`/brain/links/${id}/pull`, { method: 'POST' });export const openBrainLinkFolder = (id) => request(`/brain/links/${id}/open-folder`, { method: 'POST' });+export const scanBrainLink = (id) => request(`/brain/links/${id}/scan`, { method: 'POST' });// Brain - Graphexport const getBrainGraph = () => request('/brain/graph');diff --git a/lib/slashdo b/lib/slashdoindex a38ee04326..50011ef25d 160000--- a/lib/slashdo+++ b/lib/slashdo@@ -1 +1 @@-Subproject commit a38ee04326684df8063148a88da96958cf6c2342+Subproject commit 50011ef25d2581145ecd1866d5d79293091b3fd9diff --git a/server/lib/fileUtils.js b/server/lib/fileUtils.jsindex c6b421c21e..9d487490d6 100644--- a/server/lib/fileUtils.js+++ b/server/lib/fileUtils.js@@ -483,8 +483,15 @@ export function formatDuration(ms) {/*** Load a slashdo command markdown file, resolving !`cat ~/.claude/lib/...` includes.* Optionally strips YAML frontmatter.+ *+ * Cached: slashdo files are static within a server lifetime (submodule updates+ * require restart). Cache resets on process restart, which is the right behavior.*/+const slashdoFileCache = new Map();export async function loadSlashdoFile(commandName, { stripFrontmatter = false } = {}) {+ const cacheKey = `${commandName}::${stripFrontmatter}`;+ if (slashdoFileCache.has(cacheKey)) return slashdoFileCache.get(cacheKey);+const cmdPath = join(PATHS.slashdo, 'commands/do', `${commandName}.md`);let content = await readFile(cmdPath, 'utf-8').catch(() => null);if (!content) return null;@@ -500,6 +507,7 @@ export async function loadSlashdoFile(commandName, { stripFrontmatter = false }for (const { pattern, content: libContent } of replacements) {if (libContent) content = content.replace(pattern, libContent);}+ slashdoFileCache.set(cacheKey, content);return content;}diff --git a/server/routes/brain.js b/server/routes/brain.jsindex 6ae4ebf20a..461521307a 100644--- a/server/routes/brain.js+++ b/server/routes/brain.js@@ -40,6 +40,8 @@ import { syncAllBrainData } from '../services/brainMemoryBridge.js';import * as brainSyncLog from '../services/brainSyncLog.js';import * as brainSync from '../services/brainSync.js';import * as journal from '../services/brainJournal.js';+import { loadSlashdoCommand } from '../services/subAgentSpawner.js';+import * as cos from '../services/cos.js';const router = Router();@@ -721,6 +723,64 @@ router.post('/links/:id/open-folder', asyncHandler(async (req, res) => {res.json({ message: 'Folder opened', path: link.localPath });}));+/**+ * POST /api/brain/links/:id/scan+ * Queue a read-only malware/risk scan (do:scan) against the cloned repo.+ * Creates a CoS user task whose context inlines the do:scan command body+ * with the repo's localPath baked in as SCAN_DIR. The agent writes its+ * markdown report to ~/.claude/scans/.+ */+router.post('/links/:id/scan', asyncHandler(async (req, res) => {+ const link = await brainService.getLinkById(req.params.id);+ if (!link) {+ throw new ServerError('Link not found', { status: 404, code: 'NOT_FOUND' });+ }+ if (!link.isGitHubRepo || link.cloneStatus !== 'cloned' || !link.localPath) {+ throw new ServerError('Link is not a cloned GitHub repository', {+ status: 400,+ code: 'NOT_CLONED'+ });+ }+ if (!existsSync(link.localPath)) {+ throw new ServerError('Local clone folder does not exist', {+ status: 400,+ code: 'PATH_NOT_FOUND'+ });+ }++ const scanCommand = await loadSlashdoCommand('scan');+ if (!scanCommand) {+ throw new ServerError('Failed to load do:scan command', {+ status: 500,+ code: 'COMMAND_LOAD_FAILED'+ });+ }++ const repoLabel = link.title || link.url;+ const description = `Malware scan: ${repoLabel} (do:scan)`;+ const context = `Run the /do:scan workflow against the cloned repository at: \`${link.localPath}\`++Use that path as SCAN_DIR. Adhere to every Operational Invariant in the command body — this is a hostile-until-proven-safe audit. The full markdown report will be written to ~/.claude/scans/. When complete, summarize the verdict (CLEAN / CAUTION / DANGEROUS) and the top findings in your final response so the report can be surfaced in the UI.++---++${scanCommand}`;++ const result = await cos.addTask(+ { description, context, useWorktree: false, openPR: false, simplify: false, reviewLoop: false },+ 'user'+ );+ if (result?.duplicate) {+ throw new ServerError('A scan for this repo is already pending or in progress', {+ status: 409,+ code: 'DUPLICATE_TASK'+ });+ }++ console.log(`🛡️ Queued malware scan: link=${link.id} path=${link.localPath} task=${result.id}`);+ res.json({ message: 'Scan queued', taskId: result.id, linkId: link.id, scanPath: link.localPath });+}));+// =============================================================================// GRAPH// =============================================================================