Route routine core, engine, and dashboard diagnostics through debug-gated shared loggers. - Demote steady-state diagnostic sites while preserving warnings and errors for actionable failures. - Add cross-package severity contracts and manifest coverage for demoted log sites. - Document logging severity guidance and add a patch changeset. Files changed: .changeset/fn-8603-log-severity.md | 7 ++ docs/diagnostics.md | 20 ++++-- .../__tests__/log-severity-spam-contract.test.ts | 71 ++++++++++++++++++ packages/core/src/activity-analytics.ts | 5 +- packages/core/src/ai-summarize.ts | 61 +++++++--------- packages/core/src/async-mission-store.ts | 5 +- packages/core/src/async-secrets-store.ts | 7 +- packages/core/src/central-core.ts | 17 ++--- packages/core/src/docker-provisioning.ts | 13 ++-- packages/core/src/index.ts | 1 + packages/core/src/master-key.ts | 9 ++- packages/core/src/memory-compaction.ts | 29 ++++---- packages/core/src/memory-insights.ts | 7 +- packages/core/src/migration-orchestrator.ts | 7 +- packages/core/src/mission-store.ts | 5 +- packages/core/src/node-discovery.ts | 7 +- packages/core/src/notification/dispatcher.ts | 9 ++- .../core/src/plugins/bundled-plugin-install.ts | 11 +-- packages/core/src/reflection-store.ts | 5 +- packages/core/src/secrets-store.ts | 7 +- packages/core/src/task-store/agent-logs.ts | 21 +++--- packages/core/src/task-store/async-events.ts | 5 +- packages/core/src/task-store/async-maintenance.ts | 7 +- packages/core/src/task-store/comments-ops.ts | 7 +- packages/core/src/task-store/task-mutation-ops.ts | 11 +-- packages/core/src/task-store/workflow-integrity.ts | 9 ++- packages/core/src/types/merge-policy.ts | 5 +- packages/core/src/usage-events.ts | 5 +- .../__tests__/log-severity-spam-contract.test.ts | 48 +++++++++++++ packages/dashboard/src/ai-refine.ts | 5 +- packages/dashboard/src/ai-session-diagnostics.ts | 10 +-- packages/dashboard/src/chat.ts | 8 ++- packages/dashboard/src/devserver-manager.ts | 9 ++- packages/dashboard/src/file-service.ts | 5 +- packages/dashboard/src/github-tracking-comments.ts | 7 +- .../dashboard/src/github-tracking-reconciler.ts | 5 +- packages/dashboard/src/github-tracking-state.ts | 5 +- packages/dashboard/src/gitlab-lifecycle.ts | 5 +- packages/dashboard/src/insights-routes.ts | 9 ++- packages/dashboard/src/issue-image-attachments.ts | 5 +- packages/dashboard/src/knowledge-index.ts | 5 +- packages/dashboard/src/plugin-routes.ts | 7 +- packages/dashboard/src/routes/board-workflows.ts | 5 +- packages/dashboard/src/routes/context.ts | 5 +- .../dashboard/src/routes/register-auth-routes.ts | 13 ++-- .../routes/register-docker-provisioning-routes.ts | 7 +- .../dashboard/src/routes/register-git-github.ts | 21 +++--- packages/dashboard/src/routes/register-gitlab.ts | 7 +- .../src/routes/register-session-diff-routes.ts | 9 ++- .../src/routes/register-settings-memory-routes.ts | 7 +- .../src/routes/register-setup-activity-routes.ts | 7 +- .../dashboard/src/routes/register-signal-routes.ts | 5 +- .../src/routes/register-task-workflow-routes.ts | 11 +-- packages/dashboard/src/runtime-logger.ts | 11 +-- packages/dashboard/src/server.ts | 7 +- packages/dashboard/src/sse.ts | 8 ++- packages/dashboard/src/terminal-service.ts | 34 ++++----- packages/dashboard/src/view-chunk-manifest.ts | 5 +- .../engine/src/__tests__/log-severity-manifest.ts | 83 ++++++++++++++++++++++ .../__tests__/log-severity-spam-contract.test.ts | 40 ++++++++++- .../src/__tests__/logger-debug-gating.test.ts | 7 +- packages/engine/src/goal-anchoring-audit.ts | 5 +- packages/engine/src/plugin-runner.ts | 44 ++++++------ packages/engine/src/pty-native.ts | 9 ++- .../engine/src/runtimes/child-process-worker.ts | 4 +- packages/engine/src/self-healing.ts | 12 ++-- packages/engine/src/worktree-hooks.ts | 10 ++- 67 files changed, 632 insertions(+), 250 deletions(-) Fusion-Task-Id: FN-8603 Fusion-Task-Lineage: 53901db6-1af2-4bd7-b5ea-49507e048ef2 Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
205 lines
7.4 KiB
TypeScript
205 lines
7.4 KiB
TypeScript
import { createLogger } from "../logger.js";
|
|
|
|
const severityAuditLog = createLogger("core-bundled-plugin-install");
|
|
/**
|
|
* FNXC:PluginLoader 2026-07-07-00:00:
|
|
* Bundled-plugin auto-install is host-agnostic in @fusion/core. Hosts (the CLI's
|
|
* `<cli>/dist/plugins/<id>` staging layout vs the desktop `@fusion-plugin-examples/<short>`
|
|
* node_modules layout) supply their own bundle-directory resolution — the ONLY
|
|
* host-specific concern — via the `getCandidatePluginDirs` parameter below. This
|
|
* lets the identical install/update/fail-soft-load logic run under both the CLI
|
|
* `dashboard`/`serve`/`daemon` commands and the desktop embedded runtime
|
|
* (`local-runtime.ts` / `local-server.ts`) without `packages/desktop` depending on
|
|
* the CLI package (FN-7637; builds on FN-7623's desktop pluginStore/pluginLoader
|
|
* wiring). Everything below except `getCandidatePluginDirs`/`resolveBundledPluginDir`
|
|
* is a direct, behavior-preserving port of `packages/cli/src/plugins/bundled-plugin-install.ts`.
|
|
*/
|
|
|
|
import { existsSync, statSync } from "node:fs";
|
|
import { readFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { validatePluginManifest } from "../plugin-types.js";
|
|
import type { PluginInstallation, PluginManifest } from "../plugin-types.js";
|
|
import { resolvePluginEntryPath } from "../plugin-loader.js";
|
|
import type { PluginLoader } from "../plugin-loader.js";
|
|
import type { PluginStore } from "../plugin-store.js";
|
|
|
|
const DEPENDENCY_GRAPH_PLUGIN_ID = "fusion-plugin-dependency-graph";
|
|
const CURSOR_RUNTIME_PLUGIN_ID = "fusion-plugin-cursor-runtime";
|
|
const GROK_RUNTIME_PLUGIN_ID = "fusion-plugin-grok-runtime";
|
|
export const CLAUDE_RUNTIME_PLUGIN_ID = "fusion-plugin-claude-runtime";
|
|
|
|
export const BUNDLED_PLUGIN_IDS = [
|
|
"fusion-plugin-dependency-graph",
|
|
"fusion-plugin-reports",
|
|
"fusion-plugin-whatsapp-chat",
|
|
"fusion-plugin-roadmap",
|
|
"fusion-plugin-hermes-runtime",
|
|
"fusion-plugin-openclaw-runtime",
|
|
"fusion-plugin-paperclip-runtime",
|
|
"fusion-plugin-cursor-runtime",
|
|
"fusion-plugin-grok-runtime",
|
|
"fusion-plugin-claude-runtime",
|
|
// FNXC:OmpAcp 2026-07-11-23:35: Oh My Pi ACP runtime available as a staged/bundled install target.
|
|
"fusion-plugin-omp-runtime",
|
|
"fusion-plugin-cli-printing-press",
|
|
"fusion-plugin-compound-engineering",
|
|
"fusion-plugin-linear-import",
|
|
"fusion-plugin-quality",
|
|
] as const;
|
|
|
|
export type BundledPluginId = (typeof BUNDLED_PLUGIN_IDS)[number];
|
|
|
|
export function isBundledPluginId(id: string): id is BundledPluginId {
|
|
return (BUNDLED_PLUGIN_IDS as readonly string[]).includes(id);
|
|
}
|
|
|
|
export type EnsureBundledResult =
|
|
| "installed"
|
|
| "updated"
|
|
| "already-installed"
|
|
| "missing-bundle";
|
|
|
|
/** Host-supplied resolver: given a plugin id, return candidate directories to probe for `manifest.json`. */
|
|
export type BundledPluginDirResolver = (pluginId: string) => string[];
|
|
|
|
async function loadManifest(pluginDir: string): Promise<PluginManifest> {
|
|
const manifestPath = join(pluginDir, "manifest.json");
|
|
const content = await readFile(manifestPath, "utf-8");
|
|
const manifest = JSON.parse(content);
|
|
const validation = validatePluginManifest(manifest);
|
|
if (!validation.valid) {
|
|
throw new Error(`Invalid plugin manifest: ${validation.errors.join(", ")}`);
|
|
}
|
|
return manifest;
|
|
}
|
|
|
|
function resolveBundledPluginDir(pluginId: string, getCandidatePluginDirs: BundledPluginDirResolver): string | null {
|
|
for (const path of getCandidatePluginDirs(pluginId)) {
|
|
if (existsSync(join(path, "manifest.json"))) {
|
|
return path;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function isDirectoryPath(path: string): boolean {
|
|
try {
|
|
return statSync(path).isDirectory();
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ensure a bundled runtime plugin is registered (and, if enabled, loaded) in the
|
|
* given `pluginStore`/`pluginLoader`. The only host-specific input is
|
|
* `getCandidatePluginDirs`, which returns the ordered list of directories to probe
|
|
* for a `manifest.json` for the given plugin id — the CLI supplies its
|
|
* `<cli>/dist/plugins/<id>` search paths, desktop supplies its
|
|
* `node_modules/@fusion-plugin-examples/<short>` resolution. See `resolvePluginEntryPath`
|
|
* (also in `@fusion/core`) for the loadable-entry-file selection this helper reuses
|
|
* rather than re-duplicating.
|
|
*/
|
|
export async function ensureBundledPluginInstalled(
|
|
pluginStore: PluginStore,
|
|
pluginLoader: PluginLoader,
|
|
pluginId: string,
|
|
getCandidatePluginDirs: BundledPluginDirResolver,
|
|
): Promise<EnsureBundledResult> {
|
|
let existingPlugin: PluginInstallation | null = null;
|
|
try {
|
|
existingPlugin = await pluginStore.getPlugin(pluginId);
|
|
} catch {
|
|
// Continue; plugin not installed yet.
|
|
}
|
|
|
|
const bundledDir = resolveBundledPluginDir(pluginId, getCandidatePluginDirs);
|
|
if (!bundledDir) {
|
|
return "missing-bundle";
|
|
}
|
|
|
|
const manifest = await loadManifest(bundledDir);
|
|
const entryPath = resolvePluginEntryPath(bundledDir);
|
|
|
|
if (!entryPath) {
|
|
severityAuditLog.warn(`[plugins] Bundled plugin "${pluginId}" is missing a loadable entry file in ${bundledDir}`);
|
|
return "missing-bundle";
|
|
}
|
|
|
|
if (existingPlugin) {
|
|
const existingPathIsDirectory = isDirectoryPath(existingPlugin.path);
|
|
const pathChanged = existingPathIsDirectory || existingPlugin.path !== entryPath;
|
|
const versionChanged = existingPlugin.version !== manifest.version;
|
|
|
|
if (!pathChanged && !versionChanged) {
|
|
if (existingPlugin.enabled) {
|
|
try {
|
|
await pluginLoader.loadPlugin(existingPlugin.id);
|
|
} catch (err) {
|
|
severityAuditLog.warn("[plugins] failed to load bundled plugin", existingPlugin.id, err);
|
|
}
|
|
}
|
|
return "already-installed";
|
|
}
|
|
|
|
await pluginStore.updatePlugin(pluginId, {
|
|
...(pathChanged ? { path: entryPath } : {}),
|
|
...(versionChanged ? { version: manifest.version } : {}),
|
|
});
|
|
|
|
if (existingPlugin.enabled) {
|
|
try {
|
|
await pluginLoader.loadPlugin(existingPlugin.id);
|
|
} catch (err) {
|
|
severityAuditLog.warn("[plugins] failed to load bundled plugin", existingPlugin.id, err);
|
|
}
|
|
}
|
|
|
|
return "updated";
|
|
}
|
|
|
|
const plugin = await pluginStore.registerPlugin({
|
|
manifest,
|
|
path: entryPath,
|
|
});
|
|
|
|
if (plugin.enabled) {
|
|
try {
|
|
await pluginLoader.loadPlugin(plugin.id);
|
|
} catch (err) {
|
|
severityAuditLog.warn("[plugins] failed to load bundled plugin", plugin.id, err);
|
|
}
|
|
}
|
|
|
|
return "installed";
|
|
}
|
|
|
|
/**
|
|
* @deprecated Use {@link ensureBundledPluginInstalled} with the explicit plugin id.
|
|
* Kept for backwards compatibility with existing call sites.
|
|
*/
|
|
export async function ensureBundledDependencyGraphPluginInstalled(
|
|
pluginStore: PluginStore,
|
|
pluginLoader: PluginLoader,
|
|
getCandidatePluginDirs: BundledPluginDirResolver,
|
|
): Promise<EnsureBundledResult> {
|
|
return ensureBundledPluginInstalled(pluginStore, pluginLoader, DEPENDENCY_GRAPH_PLUGIN_ID, getCandidatePluginDirs);
|
|
}
|
|
|
|
export async function ensureBundledCursorRuntimePluginInstalled(
|
|
pluginStore: PluginStore,
|
|
pluginLoader: PluginLoader,
|
|
getCandidatePluginDirs: BundledPluginDirResolver,
|
|
): Promise<EnsureBundledResult> {
|
|
return ensureBundledPluginInstalled(pluginStore, pluginLoader, CURSOR_RUNTIME_PLUGIN_ID, getCandidatePluginDirs);
|
|
}
|
|
|
|
export async function ensureBundledGrokRuntimePluginInstalled(
|
|
pluginStore: PluginStore,
|
|
pluginLoader: PluginLoader,
|
|
getCandidatePluginDirs: BundledPluginDirResolver,
|
|
): Promise<EnsureBundledResult> {
|
|
return ensureBundledPluginInstalled(pluginStore, pluginLoader, GROK_RUNTIME_PLUGIN_ID, getCandidatePluginDirs);
|
|
}
|