chore: consolidate test files into __tests__/ dirs and clean stray engine artifacts
- Move all co-located *.test.* files into sibling __tests__/ directories so the
layout is consistent across packages (159 renames + content-rewrite moves).
Updates relative imports, vi.mock specifiers, and __dirname/import.meta.url
path resolutions where tests read fixtures from disk.
- Drop tracked tsc-emit alongside engine .ts sources (auth-storage/logger/
skill-resolver/context-limit-detector/pi.{js,d.ts,*.map}). These were
accidentally committed in a merge and the stale pi.js was masking a real
test-mock vs source mismatch (tests imported "../pi.js" and vite preferred
the stale build over pi.ts).
- Add packages/engine/.gitignore to block future src/*.{js,d.ts,map}.
- Refactor plugin pi-module seams (openclaw/paperclip/hermes) to ESM-import
createFnAgent / promptWithFallback / describeModel from @fusion/engine
instead of require()-ing packages/engine/src/pi.js. Adds @fusion/engine to
the two plugin package.jsons that were missing it; exports describeModel
from the engine public API.
- Fix engine test mocks now that they run against current pi.ts: add
ModelRegistry.create static to mocks in pi.test.ts and pi-create-fn-agent
.test.ts; switch three boundary-result toEqual assertions to toMatchObject
so the new content/isError fields don't trip exact-match comparison.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,15 +4,15 @@ import { dirname, join } from "node:path";
|
||||
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { parseYamlFrontmatter } from "./agent-companies-parser.js";
|
||||
import { parseYamlFrontmatter } from "../agent-companies-parser.js";
|
||||
import {
|
||||
agentToCompaniesManifest,
|
||||
exportAgentsToDirectory,
|
||||
generateAgentMd,
|
||||
generateCompanyMd,
|
||||
slugify,
|
||||
} from "./agent-companies-exporter.js";
|
||||
import type { Agent } from "./types.js";
|
||||
} from "../agent-companies-exporter.js";
|
||||
import type { Agent } from "../types.js";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
parseTaskManifest,
|
||||
parseTeamManifest,
|
||||
parseYamlFrontmatter,
|
||||
} from "./agent-companies-parser.js";
|
||||
} from "../agent-companies-parser.js";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
SourceReference,
|
||||
TaskManifest,
|
||||
TeamManifest,
|
||||
} from "./agent-companies-types.js";
|
||||
} from "../agent-companies-types.js";
|
||||
|
||||
describe("agent-companies-types", () => {
|
||||
it("supports schema and kind literals", () => {
|
||||
@@ -3,9 +3,9 @@ import {
|
||||
computeAccessState,
|
||||
isValidPermission,
|
||||
normalizePermissions,
|
||||
} from "./agent-permissions.js";
|
||||
import { AGENT_PERMISSIONS } from "./types.js";
|
||||
import type { Agent, AgentCapability, AgentPermission } from "./types.js";
|
||||
} from "../agent-permissions.js";
|
||||
import { AGENT_PERMISSIONS } from "../types.js";
|
||||
import type { Agent, AgentCapability, AgentPermission } from "../types.js";
|
||||
|
||||
function makeAgent(role: AgentCapability, permissions?: Record<string, boolean>): Agent {
|
||||
return {
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
resolveAgentPrompt,
|
||||
getAvailableTemplates,
|
||||
getTemplatesForRole,
|
||||
} from "./agent-prompts.js";
|
||||
import type { AgentPromptsConfig, AgentPromptTemplate } from "./types.js";
|
||||
} from "../agent-prompts.js";
|
||||
import type { AgentPromptsConfig, AgentPromptTemplate } from "../types.js";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// resolveAgentPrompt
|
||||
@@ -11,15 +11,15 @@
|
||||
* validation, concurrency locking, and SQLite persistence.
|
||||
*/
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { AgentStore } from "./agent-store.js";
|
||||
import { Database } from "./db.js";
|
||||
import { TaskStore } from "./store.js";
|
||||
import { AgentStore } from "../agent-store.js";
|
||||
import { Database } from "../db.js";
|
||||
import { TaskStore } from "../store.js";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { createHash } from "node:crypto";
|
||||
import { CheckoutConflictError, type AgentCapability, type AgentState } from "./types.js";
|
||||
import { CheckoutConflictError, type AgentCapability, type AgentState } from "../types.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "fn-agent-store-test-"));
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
RateLimitError,
|
||||
AiServiceError,
|
||||
__resetSummarizeState,
|
||||
} from "./ai-summarize.js";
|
||||
} from "../ai-summarize.js";
|
||||
|
||||
describe("ai-summarize", () => {
|
||||
beforeEach(() => {
|
||||
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, vi, afterEach } from "vitest";
|
||||
import { readFileSync, existsSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { getAppVersion, parseSemver } from "./app-version.js";
|
||||
import { getAppVersion, parseSemver } from "../app-version.js";
|
||||
|
||||
describe("getAppVersion", () => {
|
||||
it("should return a non-empty string", () => {
|
||||
@@ -20,10 +20,10 @@ describe("getAppVersion", () => {
|
||||
it("should return the actual package version from package.json", () => {
|
||||
const version = getAppVersion();
|
||||
// Read the actual version from package.json for verification
|
||||
// The test file is at packages/core/src/app-version.test.ts
|
||||
// The test file is at packages/core/src/__tests__/app-version.test.ts
|
||||
// Walk up from this file to find packages/core/package.json
|
||||
const testFileDir = dirname(fileURLToPath(import.meta.url));
|
||||
const coreDir = join(testFileDir, "..");
|
||||
const coreDir = join(testFileDir, "..", "..");
|
||||
const pkgPath = join(coreDir, "package.json");
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
||||
expect(version).toBe(pkg.version);
|
||||
@@ -36,7 +36,7 @@ describe("getAppVersion", () => {
|
||||
expect(version1).toBe(version2);
|
||||
// Verify cached version matches the actual package version
|
||||
const testFileDir = dirname(fileURLToPath(import.meta.url));
|
||||
const coreDir = join(testFileDir, "..");
|
||||
const coreDir = join(testFileDir, "..", "..");
|
||||
const pkgPath = join(coreDir, "package.json");
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
||||
expect(version1).toBe(pkg.version);
|
||||
@@ -1,10 +1,10 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { AutomationStore } from "./automation-store.js";
|
||||
import { AutomationStore } from "../automation-store.js";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import type { ScheduledTask, AutomationRunResult, AutomationStep } from "./automation.js";
|
||||
import type { ScheduledTask, AutomationRunResult, AutomationStep } from "../automation.js";
|
||||
import { randomUUID } from "node:crypto";
|
||||
|
||||
/** Create a test automation step. */
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
type ScheduleType,
|
||||
type ScheduledTask,
|
||||
type ScheduledTaskCreateInput,
|
||||
} from "./automation.js";
|
||||
} from "../automation.js";
|
||||
|
||||
const expectedPresetMap = {
|
||||
hourly: "0 * * * *",
|
||||
@@ -12,9 +12,9 @@ import {
|
||||
validateBackupDir,
|
||||
runBackupCommand,
|
||||
syncBackupRoutine,
|
||||
} from "./backup.js";
|
||||
import { RoutineStore } from "./routine-store.js";
|
||||
import type { ProjectSettings } from "./types.js";
|
||||
} from "../backup.js";
|
||||
import { RoutineStore } from "../routine-store.js";
|
||||
import type { ProjectSettings } from "../types.js";
|
||||
|
||||
describe("BackupManager", () => {
|
||||
let tempDir: string;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { canTransition, getValidTransitions, resolveDependencyOrder } from "./board.js";
|
||||
import { VALID_TRANSITIONS, type Task, type Column } from "./types.js";
|
||||
import { canTransition, getValidTransitions, resolveDependencyOrder } from "../board.js";
|
||||
import { VALID_TRANSITIONS, type Task, type Column } from "../types.js";
|
||||
|
||||
/**
|
||||
* Board logic tests
|
||||
@@ -2,11 +2,11 @@ import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { mkdtempSync, rmSync, mkdirSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { CentralCore } from "./central-core.js";
|
||||
import { NodeDiscovery } from "./node-discovery.js";
|
||||
import { NodeConnection, type ConnectionResult } from "./node-connection.js";
|
||||
import { getAppVersion } from "./app-version.js";
|
||||
import * as systemMetrics from "./system-metrics.js";
|
||||
import { CentralCore } from "../central-core.js";
|
||||
import { NodeDiscovery } from "../node-discovery.js";
|
||||
import { NodeConnection, type ConnectionResult } from "../node-connection.js";
|
||||
import { getAppVersion } from "../app-version.js";
|
||||
import * as systemMetrics from "../system-metrics.js";
|
||||
import type {
|
||||
RegisteredProject,
|
||||
ProjectHealth,
|
||||
@@ -15,7 +15,7 @@ import type {
|
||||
SystemMetrics,
|
||||
DiscoveryConfig,
|
||||
DiscoveredNode,
|
||||
} from "./types.js";
|
||||
} from "../types.js";
|
||||
|
||||
describe("CentralCore", () => {
|
||||
let tempDir: string;
|
||||
@@ -2673,7 +2673,7 @@ describe("CentralCore", () => {
|
||||
url: "http://localhost:9992",
|
||||
});
|
||||
|
||||
let emittedPayload: { nodeId: string; remoteNodeId: string; state: import("./types.js").SettingsSyncState } | undefined;
|
||||
let emittedPayload: { nodeId: string; remoteNodeId: string; state: import("../types.js").SettingsSyncState } | undefined;
|
||||
central.on("settings:sync:completed", (payload) => {
|
||||
emittedPayload = payload;
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { mkdtempSync, rmSync, statSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { CentralDatabase, createCentralDatabase, toJson, fromJson } from "./central-db.js";
|
||||
import { CentralDatabase, createCentralDatabase, toJson, fromJson } from "../central-db.js";
|
||||
|
||||
describe("CentralDatabase", () => {
|
||||
let tempDir: string;
|
||||
@@ -3,13 +3,13 @@ import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { GlobalSettingsStore } from "./global-settings.js";
|
||||
import { GlobalSettingsStore } from "../global-settings.js";
|
||||
import {
|
||||
DaemonTokenManager,
|
||||
DAEMON_TOKEN_PREFIX,
|
||||
DAEMON_TOKEN_HEX_LENGTH,
|
||||
isDaemonTokenFormat,
|
||||
} from "./daemon-token.js";
|
||||
} from "../daemon-token.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "fn-daemon-token-test-"));
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { detectLegacyData, migrateFromLegacy, getMigrationStatus } from "./db-migrate.js";
|
||||
import { Database } from "./db.js";
|
||||
import { detectLegacyData, migrateFromLegacy, getMigrationStatus } from "../db-migrate.js";
|
||||
import { Database } from "../db.js";
|
||||
import { mkdir, writeFile, rm, readdir, appendFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync, existsSync } from "node:fs";
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { Database, createDatabase, toJson, toJsonNullable, fromJson, normalizeTaskComments } from "./db.js";
|
||||
import { DEFAULT_PROJECT_SETTINGS } from "./types.js";
|
||||
import { Database, createDatabase, toJson, toJsonNullable, fromJson, normalizeTaskComments } from "../db.js";
|
||||
import { DEFAULT_PROJECT_SETTINGS } from "../types.js";
|
||||
import { mkdtempSync, existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -17,9 +17,9 @@ import { mkdtempSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { Database } from "./db.js";
|
||||
import { ArchiveDatabase } from "./archive-db.js";
|
||||
import { TaskStore } from "./store.js";
|
||||
import { Database } from "../db.js";
|
||||
import { ArchiveDatabase } from "../archive-db.js";
|
||||
import { TaskStore } from "../store.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-fts5-guard-test-"));
|
||||
@@ -2,7 +2,7 @@ import { describe, it, expect, vi } from "vitest";
|
||||
import {
|
||||
getGhErrorMessage,
|
||||
parseRepoFromRemote,
|
||||
} from "./gh-cli.js";
|
||||
} from "../gh-cli.js";
|
||||
|
||||
// Tests for pure functions (no child_process dependency)
|
||||
describe("getGhErrorMessage", () => {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { GlobalSettingsStore, defaultGlobalDir } from "./global-settings.js";
|
||||
import { DEFAULT_GLOBAL_SETTINGS } from "./types.js";
|
||||
import { GlobalSettingsStore, defaultGlobalDir } from "../global-settings.js";
|
||||
import { DEFAULT_GLOBAL_SETTINGS } from "../types.js";
|
||||
import { readFile, rm, writeFile, mkdir } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync, existsSync } from "node:fs";
|
||||
@@ -11,8 +11,8 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { Database, createDatabase, fromJson } from "./db.js";
|
||||
import { InsightStore, computeInsightFingerprint } from "./insight-store.js";
|
||||
import { Database, createDatabase, fromJson } from "../db.js";
|
||||
import { InsightStore, computeInsightFingerprint } from "../insight-store.js";
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -24,7 +24,7 @@ import type {
|
||||
InsightProvenance,
|
||||
InsightRunTrigger,
|
||||
InsightRunStatus,
|
||||
} from "./insight-types.js";
|
||||
} from "../insight-types.js";
|
||||
|
||||
// ── Test Fixtures ────────────────────────────────────────────────────
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { createLogger } from "./logger.js";
|
||||
import { createLogger } from "../logger.js";
|
||||
|
||||
describe("core createLogger", () => {
|
||||
let logSpy: ReturnType<typeof vi.spyOn>;
|
||||
@@ -34,8 +34,8 @@ import {
|
||||
listAgentMemoryFiles,
|
||||
readAgentMemoryFile,
|
||||
writeAgentMemoryFile,
|
||||
} from "./memory-backend.js";
|
||||
import type { MemoryBackend } from "./memory-backend.js";
|
||||
} from "../memory-backend.js";
|
||||
import type { MemoryBackend } from "../memory-backend.js";
|
||||
|
||||
describe("memory-backend", () => {
|
||||
let tempDir: string;
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
DEFAULT_AUTO_SUMMARIZE_SCHEDULE,
|
||||
AiServiceError,
|
||||
__resetCompactionState,
|
||||
} from "./memory-compaction.js";
|
||||
} from "../memory-compaction.js";
|
||||
|
||||
describe("memory-compaction", () => {
|
||||
beforeEach(() => {
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
MEMORY_DREAMS_SCHEDULE_NAME,
|
||||
processAgentMemoryDreams,
|
||||
syncMemoryDreamsAutomation,
|
||||
} from "./memory-dreams.js";
|
||||
} from "../memory-dreams.js";
|
||||
|
||||
describe("memory-dreams automation", () => {
|
||||
it("creates a scheduled dream processor automation with defaults", () => {
|
||||
@@ -22,9 +22,9 @@ import {
|
||||
createInsightExtractionAutomation,
|
||||
validatePruneCandidate,
|
||||
applyMemoryPruning,
|
||||
} from "./memory-insights.js";
|
||||
import type { MemoryInsight, InsightExtractionResult } from "./memory-insights.js";
|
||||
import type { ProjectSettings } from "./types.js";
|
||||
} from "../memory-insights.js";
|
||||
import type { MemoryInsight, InsightExtractionResult } from "../memory-insights.js";
|
||||
import type { ProjectSettings } from "../types.js";
|
||||
|
||||
describe("memory-insights", () => {
|
||||
let tempDir: string;
|
||||
@@ -630,7 +630,7 @@ import {
|
||||
MEMORY_AUDIT_PATH,
|
||||
readMemoryAudit,
|
||||
writeMemoryAudit,
|
||||
} from "./memory-insights.js";
|
||||
} from "../memory-insights.js";
|
||||
|
||||
describe("memory-insights audit file operations", () => {
|
||||
let tempDir: string;
|
||||
@@ -690,7 +690,7 @@ describe("memory-insights audit file operations", () => {
|
||||
import {
|
||||
processInsightExtractionRun,
|
||||
processAndAuditInsightExtraction,
|
||||
} from "./memory-insights.js";
|
||||
} from "../memory-insights.js";
|
||||
|
||||
describe("memory-insights run processing", () => {
|
||||
let tempDir: string;
|
||||
@@ -1021,7 +1021,7 @@ Durable content.`;
|
||||
import {
|
||||
generateMemoryAudit,
|
||||
renderMemoryAuditMarkdown,
|
||||
} from "./memory-insights.js";
|
||||
} from "../memory-insights.js";
|
||||
|
||||
describe("memory-insights audit generation", () => {
|
||||
let tempDir: string;
|
||||
@@ -2,9 +2,9 @@ import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { Database } from "./db.js";
|
||||
import { MessageStore } from "./message-store.js";
|
||||
import type { Message, Mailbox } from "./types.js";
|
||||
import { Database } from "../db.js";
|
||||
import { MessageStore } from "../message-store.js";
|
||||
import type { Message, Mailbox } from "../types.js";
|
||||
|
||||
describe("MessageStore", () => {
|
||||
let store: MessageStore;
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
BackwardCompat,
|
||||
ProjectRequiredError,
|
||||
type ProjectSetupInput,
|
||||
} from "./migration.js";
|
||||
import { CentralCore } from "./central-core.js";
|
||||
} from "../migration.js";
|
||||
import { CentralCore } from "../central-core.js";
|
||||
|
||||
// Helper to create a fake kb project
|
||||
function createFakeKbProject(dir: string): void {
|
||||
@@ -16,7 +16,7 @@ import { mkdtempSync } from "node:fs";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { TaskStore } from "./store.js";
|
||||
import { TaskStore } from "../store.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-mission-factory-parity-"));
|
||||
@@ -3,8 +3,8 @@ import { mkdtempSync } from "node:fs";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { TaskStore } from "./store.js";
|
||||
import { Database } from "./db.js";
|
||||
import { TaskStore } from "../store.js";
|
||||
import { Database } from "../db.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-mission-integration-"));
|
||||
@@ -3,7 +3,7 @@ import { mkdtempSync } from "node:fs";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { TaskStore } from "./store.js";
|
||||
import { TaskStore } from "../store.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-mission-planning-"));
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { MissionStore } from "./mission-store.js";
|
||||
import { Database } from "./db.js";
|
||||
import { MissionStore } from "../mission-store.js";
|
||||
import { Database } from "../db.js";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -1484,10 +1484,10 @@ describe("MissionStore", () => {
|
||||
const m1Data = withHierarchy.milestones.find((m) => m.id === m1.id)!;
|
||||
expect(m1Data.slices).toHaveLength(2);
|
||||
|
||||
const s1Data = m1Data.slices.find((s) => s.id === s1.id)! as import("./mission-types.js").SliceWithFeatures;
|
||||
const s1Data = m1Data.slices.find((s) => s.id === s1.id)! as import("../mission-types.js").SliceWithFeatures;
|
||||
expect(s1Data.features).toHaveLength(2);
|
||||
expect(s1Data.features.find((f: import("./mission-types.js").MissionFeature) => f.id === f1.id)).toBeDefined();
|
||||
expect(s1Data.features.find((f: import("./mission-types.js").MissionFeature) => f.id === f2.id)).toBeDefined();
|
||||
expect(s1Data.features.find((f: import("../mission-types.js").MissionFeature) => f.id === f1.id)).toBeDefined();
|
||||
expect(s1Data.features.find((f: import("../mission-types.js").MissionFeature) => f.id === f2.id)).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1660,7 +1660,7 @@ describe("MissionStore", () => {
|
||||
|
||||
it("throws if feature not found", async () => {
|
||||
// Need a TaskStore reference for this test
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1670,7 +1670,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("throws if feature is already triaged", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1690,7 +1690,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("creates a task and links it to the feature", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1722,7 +1722,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("uses provided title and description overrides", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1743,7 +1743,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("emits feature:linked event", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1778,7 +1778,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("throws if slice not found", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1788,7 +1788,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("triages all defined features in a slice", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1815,7 +1815,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("skips already triaged features", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1837,7 +1837,7 @@ describe("MissionStore", () => {
|
||||
});
|
||||
|
||||
it("returns empty array if no defined features", async () => {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const msWithTs = ts.getMissionStore();
|
||||
|
||||
@@ -1855,10 +1855,10 @@ describe("MissionStore", () => {
|
||||
describe("activateSlice with autoAdvance", () => {
|
||||
/** Helper to create a MissionStore with a real TaskStore reference */
|
||||
async function createStoreWithTaskStore(): Promise<{
|
||||
ts: import("./store.js").TaskStore;
|
||||
ts: import("../store.js").TaskStore;
|
||||
ms: MissionStore;
|
||||
}> {
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
const ts = new TaskStore(fusionDir, join(fusionDir, ".fusion-global-settings"));
|
||||
const ms = ts.getMissionStore();
|
||||
return { ts, ms };
|
||||
@@ -1,7 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { NodeConnection } from "./node-connection.js";
|
||||
import type { CentralCore } from "./central-core.js";
|
||||
import type { NodeConfig } from "./types.js";
|
||||
import { NodeConnection } from "../node-connection.js";
|
||||
import type { CentralCore } from "../central-core.js";
|
||||
import type { NodeConfig } from "../types.js";
|
||||
|
||||
function jsonResponse(body: unknown, status = 200): Response {
|
||||
return new Response(JSON.stringify(body), {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import type { DiscoveryConfig, DiscoveredNode } from "./types.js";
|
||||
import type { DiscoveryConfig, DiscoveredNode } from "../types.js";
|
||||
|
||||
interface MockBrowser {
|
||||
on: ReturnType<typeof vi.fn>;
|
||||
@@ -20,7 +20,7 @@ vi.mock("bonjour-service", () => ({
|
||||
default: BonjourMock,
|
||||
}));
|
||||
|
||||
import { NodeDiscovery } from "./node-discovery.js";
|
||||
import { NodeDiscovery } from "../node-discovery.js";
|
||||
|
||||
function createMockBrowser(): MockBrowser {
|
||||
const listeners = new Map<string, Set<(...args: unknown[]) => void>>();
|
||||
@@ -3,9 +3,9 @@ import { writeFile, mkdir } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync, existsSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { PluginLoader } from "./plugin-loader.js";
|
||||
import { PluginStore } from "./plugin-store.js";
|
||||
import type { FusionPlugin, PluginManifest } from "./plugin-types.js";
|
||||
import { PluginLoader } from "../plugin-loader.js";
|
||||
import { PluginStore } from "../plugin-store.js";
|
||||
import type { FusionPlugin, PluginManifest } from "../plugin-types.js";
|
||||
|
||||
// Test plugin manifest
|
||||
function makeManifest(overrides: Partial<PluginManifest> = {}): PluginManifest {
|
||||
@@ -131,11 +131,11 @@ async function loadPluginLoaderWithMockedLogger() {
|
||||
return logger;
|
||||
});
|
||||
|
||||
vi.doMock("./logger.js", () => ({
|
||||
vi.doMock("../logger.js", () => ({
|
||||
createLogger: createLoggerMock,
|
||||
}));
|
||||
|
||||
const { PluginLoader: MockedPluginLoader } = await import("./plugin-loader.js");
|
||||
const { PluginLoader: MockedPluginLoader } = await import("../plugin-loader.js");
|
||||
return { MockedPluginLoader, createLoggerMock, loggerMap };
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { PluginStore } from "./plugin-store.js";
|
||||
import { PluginStore } from "../plugin-store.js";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import type { PluginManifest, PluginState } from "./plugin-types.js";
|
||||
import type { PluginManifest, PluginState } from "../plugin-types.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-plugin-test-"));
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { validatePluginManifest } from "./plugin-types.js";
|
||||
import { validatePluginManifest } from "../plugin-types.js";
|
||||
|
||||
describe("validatePluginManifest", () => {
|
||||
// ── Valid Manifests ─────────────────────────────────────────────────
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
readProjectMemoryWithBackend,
|
||||
searchProjectMemory,
|
||||
resolveMemoryInstructionContext,
|
||||
} from "./project-memory.js";
|
||||
} from "../project-memory.js";
|
||||
|
||||
describe("project-memory", () => {
|
||||
let testDir: string;
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
isValidPromptKey,
|
||||
isValidPromptOverrideMap,
|
||||
assertValidPromptOverrideMap,
|
||||
} from "./prompt-overrides.js";
|
||||
} from "../prompt-overrides.js";
|
||||
|
||||
describe("prompt-overrides", () => {
|
||||
describe("PROMPT_KEY_CATALOG", () => {
|
||||
@@ -3,8 +3,8 @@ import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { ReflectionStore } from "./reflection-store.js";
|
||||
import type { AgentReflection, ReflectionTrigger } from "./types.js";
|
||||
import { ReflectionStore } from "../reflection-store.js";
|
||||
import type { AgentReflection, ReflectionTrigger } from "../types.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-reflection-store-test-"));
|
||||
@@ -8,8 +8,8 @@ import {
|
||||
mapRoadmapToMissionHandoff,
|
||||
mapRoadmapWithHierarchyToMissionHandoff,
|
||||
mapAllFeaturesToTaskHandoffs,
|
||||
} from "./roadmap-handoff.js";
|
||||
import { normalizeRoadmapMilestoneOrder } from "./roadmap-ordering.js";
|
||||
} from "../roadmap-handoff.js";
|
||||
import { normalizeRoadmapMilestoneOrder } from "../roadmap-ordering.js";
|
||||
import type {
|
||||
Roadmap,
|
||||
RoadmapMilestone,
|
||||
@@ -17,7 +17,7 @@ import type {
|
||||
RoadmapWithHierarchy,
|
||||
RoadmapFeatureTaskPlanningHandoff,
|
||||
RoadmapMissionPlanningHandoff,
|
||||
} from "./roadmap-types.js";
|
||||
} from "../roadmap-types.js";
|
||||
|
||||
// ── Test Fixtures ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
moveRoadmapFeature,
|
||||
normalizeRoadmapFeatureOrder,
|
||||
normalizeRoadmapMilestoneOrder,
|
||||
} from "./roadmap-ordering.js";
|
||||
import type { RoadmapFeature, RoadmapMilestone } from "./roadmap-types.js";
|
||||
} from "../roadmap-ordering.js";
|
||||
import type { RoadmapFeature, RoadmapMilestone } from "../roadmap-types.js";
|
||||
|
||||
function createMilestone(
|
||||
id: string,
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { Database, createDatabase } from "./db.js";
|
||||
import { RoadmapStore } from "./roadmap-store.js";
|
||||
import { Database, createDatabase } from "../db.js";
|
||||
import { RoadmapStore } from "../roadmap-store.js";
|
||||
import type {
|
||||
RoadmapCreateInput,
|
||||
RoadmapUpdateInput,
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
RoadmapMilestoneReorderInput,
|
||||
RoadmapFeatureReorderInput,
|
||||
RoadmapFeatureMoveInput,
|
||||
} from "./roadmap-types.js";
|
||||
} from "../roadmap-types.js";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { RoutineStore } from "./routine-store.js";
|
||||
import { RoutineStore } from "../routine-store.js";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync, existsSync } from "node:fs";
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
RoutineCreateInput,
|
||||
RoutineExecutionResult,
|
||||
RoutineTrigger,
|
||||
} from "./routine.js";
|
||||
} from "../routine.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-routine-test-"));
|
||||
@@ -16,9 +16,9 @@ import { mkdtempSync } from "node:fs";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { Database } from "./db.js";
|
||||
import { TaskStore } from "./store.js";
|
||||
import type { RunAuditEventInput, RunAuditEvent } from "./types.js";
|
||||
import { Database } from "../db.js";
|
||||
import { TaskStore } from "../store.js";
|
||||
import type { RunAuditEventInput, RunAuditEvent } from "../types.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "fn-run-audit-integration-test-"));
|
||||
@@ -3,9 +3,9 @@ import { mkdtempSync } from "node:fs";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { Database } from "./db.js";
|
||||
import { TaskStore } from "./store.js";
|
||||
import type { RunAuditEventInput, RunAuditEventFilter } from "./types.js";
|
||||
import { Database } from "../db.js";
|
||||
import { TaskStore } from "../store.js";
|
||||
import type { RunAuditEventInput, RunAuditEventFilter } from "../types.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "fn-run-audit-test-"));
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { runCommandAsync } from "./run-command.js";
|
||||
import { runCommandAsync } from "../run-command.js";
|
||||
|
||||
function isProcessAlive(pid: number): boolean {
|
||||
try {
|
||||
@@ -2,9 +2,9 @@ import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { mkdtempSync, writeFileSync, rmSync, mkdirSync, existsSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import type { TaskStore } from "./store.js";
|
||||
import type { GlobalSettingsStore } from "./global-settings.js";
|
||||
import type { Settings, GlobalSettings, ProjectSettings } from "./types.js";
|
||||
import type { TaskStore } from "../store.js";
|
||||
import type { GlobalSettingsStore } from "../global-settings.js";
|
||||
import type { Settings, GlobalSettings, ProjectSettings } from "../types.js";
|
||||
import {
|
||||
exportSettings,
|
||||
importSettings,
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
type SettingsExportData,
|
||||
type ExportSettingsOptions,
|
||||
type ImportSettingsOptions,
|
||||
} from "./settings-export.js";
|
||||
} from "../settings-export.js";
|
||||
|
||||
// Helper to create a temporary test environment
|
||||
function createTestEnv() {
|
||||
@@ -57,7 +57,7 @@ describe("settings-export", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
env = createTestEnv();
|
||||
const { TaskStore } = await import("./store.js");
|
||||
const { TaskStore } = await import("../store.js");
|
||||
store = new TaskStore(env.tempDir, env.globalSettingsDir);
|
||||
await store.init();
|
||||
});
|
||||
@@ -10,8 +10,8 @@ vi.mock("node:child_process", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./run-command.js", async (importOriginal) => {
|
||||
const mod = await importOriginal<typeof import("./run-command.js")>();
|
||||
vi.mock("../run-command.js", async (importOriginal) => {
|
||||
const mod = await importOriginal<typeof import("../run-command.js")>();
|
||||
return {
|
||||
...mod,
|
||||
runCommandAsync: vi.fn((...args: Parameters<typeof mod.runCommandAsync>) => mod.runCommandAsync(...args)),
|
||||
@@ -20,16 +20,16 @@ vi.mock("./run-command.js", async (importOriginal) => {
|
||||
|
||||
import { execSync } from "node:child_process";
|
||||
const mockedExecSync = vi.mocked(execSync);
|
||||
import { runCommandAsync } from "./run-command.js";
|
||||
import { runCommandAsync } from "../run-command.js";
|
||||
const mockedRunCommandAsync = vi.mocked(runCommandAsync);
|
||||
|
||||
import { TaskStore, TaskHasDependentsError } from "./store.js";
|
||||
import { TaskStore, TaskHasDependentsError } from "../store.js";
|
||||
import { appendFile, readFile, writeFile, mkdir, rm, readdir, unlink } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync, existsSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import * as projectMemory from "./project-memory.js";
|
||||
import type { Task } from "./types.js";
|
||||
import * as projectMemory from "../project-memory.js";
|
||||
import type { Task } from "../types.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return mkdtempSync(join(tmpdir(), "kb-store-test-"));
|
||||
@@ -9113,7 +9113,7 @@ Task with acceptance criteria
|
||||
},
|
||||
);
|
||||
mockedRunCommandAsync.mockImplementation((...args: Parameters<typeof runCommandAsync>) =>
|
||||
vi.importActual<typeof import("./run-command.js")>("./run-command.js").then((mod) =>
|
||||
vi.importActual<typeof import("../run-command.js")>("../run-command.js").then((mod) =>
|
||||
mod.runCommandAsync(...args),
|
||||
),
|
||||
);
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { collectSystemMetrics } from "./system-metrics.js";
|
||||
import { collectSystemMetrics } from "../system-metrics.js";
|
||||
|
||||
const { checkDiskSpaceMock, cpusMock, totalmemMock, freememMock, uptimeMock } = vi.hoisted(() => ({
|
||||
checkDiskSpaceMock: vi.fn(),
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import type { StepStatus } from "./types.js";
|
||||
import { getTaskCompletionBlocker, getTaskMergeBlocker, isTaskReadyForMerge } from "./task-merge.js";
|
||||
import type { StepStatus } from "../types.js";
|
||||
import { getTaskCompletionBlocker, getTaskMergeBlocker, isTaskReadyForMerge } from "../task-merge.js";
|
||||
|
||||
const baseTask = {
|
||||
column: "in-review" as const,
|
||||
@@ -6,13 +6,13 @@ import {
|
||||
isTaskPriority,
|
||||
normalizeTaskPriority,
|
||||
sortTasksByPriorityThenAgeAndId,
|
||||
} from "./task-priority.js";
|
||||
} from "../task-priority.js";
|
||||
import {
|
||||
DEFAULT_TASK_PRIORITY,
|
||||
TASK_PRIORITIES,
|
||||
type TaskPriority,
|
||||
} from "./types.js";
|
||||
import * as core from "./index.js";
|
||||
} from "../types.js";
|
||||
import * as core from "../index.js";
|
||||
|
||||
describe("task-priority", () => {
|
||||
it("defines the bounded priority contract in order", () => {
|
||||
Reference in New Issue
Block a user