## Summary Waves 6–7 of package code organization (plan: `docs/plans/2026-07-14-001-refactor-package-code-organization-plan.md`), after #2148. ### Wave 6 | New module | Parent | |---|---| | `merger-autostash-labels.ts` | `merger.ts` | | `types/agent-state.ts` | `types.ts` | | `app/api/tasks-lifecycle.ts` | `legacy.ts` | | `task-store/task-row-mappers.ts` | `remaining-ops-3.ts` (rename) | ### Wave 7 | New module | Parent | |---|---| | `self-healing-optional-step-revision.ts` | `self-healing.ts` | | `self-healing-path-utils.ts` | `self-healing.ts` | | `merger-git-parse` (+ `quoteArg`, `getBranchChangedFiles`) | `merger.ts` | | `app/api/settings.ts` | `legacy.ts` | Public import paths stay stable via re-exports. ## Test plan - [x] engine + dashboard typecheck (incl. app) - [x] eslint on touched modules - [x] merger-autostash / parse-porcelain / getBranchChanged / api-tasks - [ ] CI merge gate <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a dedicated task lifecycle API client (task promotion, merge, retry/reset/duplicate, pause/unpause, archive/unarchive, revert, plan approve/reject) plus branch-group and planner oversight actions. * Added a settings/config API service (effective task settings, update check/refresh/install). * Introduced standardized agent lifecycle states with identity/ephemeral detection helpers. * **Bug Fixes** * Improved autostash label compatibility and NUL-delimited changed-file detection for branch diffs. * **Refactor** * Modularized merger labeling/parsing, self-healing helpers, and lifecycle/type wiring while keeping behavior consistent. * **Tests** * Updated merger verification tests for `git diff -z` output handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
/**
|
|
* FNXC:CodeOrganization 2026-07-16-14:00:
|
|
* Settings/config/update client API peeled from legacy.ts.
|
|
*/
|
|
import type { Settings } from "@fusion/core";
|
|
import { api } from "./client.js";
|
|
import type { FetchOptions } from "./client.js";
|
|
import { withProjectId } from "./health.js";
|
|
import type { UpdateCheckResponse } from "./health.js";
|
|
import { dedupe } from "./dedupe.js";
|
|
|
|
export function fetchConfig(projectId?: string): Promise<{ maxConcurrent: number; rootDir: string }> {
|
|
const path = withProjectId("/config", projectId);
|
|
return dedupe(path, () => api<{ maxConcurrent: number; rootDir: string }>(path));
|
|
}
|
|
|
|
export function fetchSettings(projectId?: string, options?: FetchOptions): Promise<Settings> {
|
|
const path = withProjectId("/settings", projectId);
|
|
return dedupe(path, () => api<Settings>(path), options);
|
|
}
|
|
|
|
export function fetchTaskEffectiveSettings(taskId: string, projectId?: string, options?: FetchOptions): Promise<Settings> {
|
|
const path = withProjectId(`/tasks/${taskId}/effective-settings`, projectId);
|
|
return dedupe(path, () => api<Settings>(path), options);
|
|
}
|
|
|
|
export function updateSettings(settings: Partial<Settings>, projectId?: string): Promise<Settings> {
|
|
return api<Settings>(withProjectId("/settings", projectId), {
|
|
method: "PUT",
|
|
body: JSON.stringify(settings),
|
|
});
|
|
}
|
|
|
|
export function checkForUpdate(projectId?: string): Promise<UpdateCheckResponse> {
|
|
return api<UpdateCheckResponse>(withProjectId("/update-check", projectId));
|
|
}
|
|
|
|
export function refreshUpdateCheck(projectId?: string): Promise<UpdateCheckResponse> {
|
|
return api<UpdateCheckResponse>(withProjectId("/update-check/refresh", projectId), {
|
|
method: "POST",
|
|
});
|
|
}
|
|
|
|
export interface UpdateInstallResponse {
|
|
currentVersion: string;
|
|
latestVersion: string | null;
|
|
updated: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
export function installUpdate(projectId?: string): Promise<UpdateInstallResponse> {
|
|
return api<UpdateInstallResponse>(withProjectId("/update-check/install", projectId), {
|
|
method: "POST",
|
|
});
|
|
}
|
|
|