From d428a2492b6db59625e814d157576fb5e4b10c13 Mon Sep 17 00:00:00 2001 From: -Puter <22245429+puterhimself@users.noreply.github.com> Date: Wed, 29 Jul 2026 07:51:07 +0530 Subject: [PATCH] fix: make primitives Node ESM compatible --- packages/agents/tsconfig.json | 2 +- packages/primitives/src/agent-os.ts | 2 +- packages/primitives/src/git-local-runtime.ts | 2 +- packages/primitives/src/harness-runtime.ts | 2 +- packages/primitives/src/index.ts | 36 ++++---- packages/primitives/src/project-issue.ts | 2 +- packages/primitives/src/project-work.ts | 2 +- packages/primitives/src/project-workspace.ts | 4 +- packages/primitives/src/project.ts | 92 ++++++++++---------- packages/primitives/src/resolver.ts | 2 +- packages/primitives/src/work.ts | 4 +- packages/primitives/tsconfig.json | 1 + 12 files changed, 77 insertions(+), 74 deletions(-) diff --git a/packages/agents/tsconfig.json b/packages/agents/tsconfig.json index 09e6502..07f2078 100644 --- a/packages/agents/tsconfig.json +++ b/packages/agents/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "@code/config/tsconfig.base.json", - "compilerOptions": { "types": ["bun"] }, + "compilerOptions": { "allowImportingTsExtensions": true, "types": ["bun"] }, "include": ["src/**/*.ts"], "exclude": ["dist"] } diff --git a/packages/primitives/src/agent-os.ts b/packages/primitives/src/agent-os.ts index 7ca5fc8..5bd98f3 100644 --- a/packages/primitives/src/agent-os.ts +++ b/packages/primitives/src/agent-os.ts @@ -4,7 +4,7 @@ import { agentOS as createAgentOsActor } from "@rivet-dev/agentos"; import type { AgentOSConfigInput } from "@rivet-dev/agentos"; import { Context, Effect, Layer, Schema } from "effect"; -import { getExecutableGitSoftware } from "./agent-os-git-software"; +import { getExecutableGitSoftware } from "./agent-os-git-software.ts"; const withGitSoftware = ( config: AgentOSConfigInput diff --git a/packages/primitives/src/git-local-runtime.ts b/packages/primitives/src/git-local-runtime.ts index eee6e6d..9eae9d2 100644 --- a/packages/primitives/src/git-local-runtime.ts +++ b/packages/primitives/src/git-local-runtime.ts @@ -4,7 +4,7 @@ import { promisify } from "node:util"; import { Context, Effect, Layer, Schema } from "effect"; -import { GitBranchName } from "./git.js"; +import { GitBranchName } from "./git.ts"; const execFileP = promisify(execFile); diff --git a/packages/primitives/src/harness-runtime.ts b/packages/primitives/src/harness-runtime.ts index e5ce5a4..7441b01 100644 --- a/packages/primitives/src/harness-runtime.ts +++ b/packages/primitives/src/harness-runtime.ts @@ -1,6 +1,6 @@ import { Effect, Schema } from "effect"; -import type { AttemptOutcome } from "./resolver"; +import type { AttemptOutcome } from "./resolver.ts"; const Text = Schema.String.check( Schema.makeFilter((value) => value.trim().length > 0, { diff --git a/packages/primitives/src/index.ts b/packages/primitives/src/index.ts index e97417d..a39086c 100644 --- a/packages/primitives/src/index.ts +++ b/packages/primitives/src/index.ts @@ -1,19 +1,19 @@ // oxlint-disable-next-line no-barrel-file -- The package root intentionally exposes its public modules. -export * from "./agent-os"; -export * from "./execution-runtime"; -export * from "./git"; -export * from "./git-local-runtime"; -export * from "./git-remote-runtime"; -export * from "./project"; -export * from "./project-issue"; -export * from "./project-workspace"; -export * from "./project-work"; -export * from "./signal"; -export * from "./smoke"; -export * from "./work"; -export * from "./work-artifact"; -export * from "./work-definition"; -export * from "./work-design"; -export * from "./work-lifecycle"; -export * from "./resolver"; -export * from "./harness-runtime"; +export * from "./agent-os.ts"; +export * from "./execution-runtime.ts"; +export * from "./git.ts"; +export * from "./git-local-runtime.ts"; +export * from "./git-remote-runtime.ts"; +export * from "./project.ts"; +export * from "./project-issue.ts"; +export * from "./project-workspace.ts"; +export * from "./project-work.ts"; +export * from "./signal.ts"; +export * from "./smoke.ts"; +export * from "./work.ts"; +export * from "./work-artifact.ts"; +export * from "./work-definition.ts"; +export * from "./work-design.ts"; +export * from "./work-lifecycle.ts"; +export * from "./resolver.ts"; +export * from "./harness-runtime.ts"; diff --git a/packages/primitives/src/project-issue.ts b/packages/primitives/src/project-issue.ts index d85530a..a382768 100644 --- a/packages/primitives/src/project-issue.ts +++ b/packages/primitives/src/project-issue.ts @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file -- each domain failure has a distinct tagged reason. */ import { Effect, Schema } from "effect"; -import { ProblemStatement, ProjectId, SignalId } from "./signal.js"; +import { ProblemStatement, ProjectId, SignalId } from "./signal.ts"; const MeaningfulString = Schema.String.check( Schema.makeFilter((value) => value.trim().length > 0, { diff --git a/packages/primitives/src/project-work.ts b/packages/primitives/src/project-work.ts index b43baf7..dd7627a 100644 --- a/packages/primitives/src/project-work.ts +++ b/packages/primitives/src/project-work.ts @@ -1,4 +1,4 @@ -import type { ProjectIssueStatus } from "./project-issue.js"; +import type { ProjectIssueStatus } from "./project-issue.ts"; export const PROJECT_ISSUE_STATUSES = [ "open", diff --git a/packages/primitives/src/project-workspace.ts b/packages/primitives/src/project-workspace.ts index aa1775e..d634cf1 100644 --- a/packages/primitives/src/project-workspace.ts +++ b/packages/primitives/src/project-workspace.ts @@ -1,9 +1,9 @@ /* eslint-disable max-classes-per-file -- workspace errors stay next to their contracts. */ import { Effect, Schema } from "effect"; -import { CONTEXT_KINDS } from "./project.js"; +import { CONTEXT_KINDS } from "./project.ts"; -export type { ContextKind } from "./project.js"; +export type { ContextKind } from "./project.ts"; const MeaningfulString = Schema.String.check( Schema.makeFilter((value) => value.trim().length > 0, { diff --git a/packages/primitives/src/project.ts b/packages/primitives/src/project.ts index fe31b9e..461778d 100644 --- a/packages/primitives/src/project.ts +++ b/packages/primitives/src/project.ts @@ -1,9 +1,9 @@ /* eslint-disable max-classes-per-file -- deep Effect v4 domain module: branded schemas, tagged errors, and context services */ import { Context, Effect, Layer, Schema } from "effect"; -import { OrganizationId, ProjectId, TimestampMs } from "./signal.js"; +import { OrganizationId, ProjectId, TimestampMs } from "./signal.ts"; -export type { OrganizationId, ProjectId } from "./signal.js"; +export type { OrganizationId, ProjectId } from "./signal.ts"; // --------------------------------------------------------------------------- // Domain constants @@ -649,19 +649,21 @@ export class ProjectApplication extends Context.Service< const store = yield* ProjectStore; return ProjectApplication.of({ - getProject: Effect.fn("ProjectApplication.getProject")(function* getProject({ - userId, - projectId, - }: { - readonly userId: string; - readonly projectId: ProjectId; - }) { - return yield* store - .getProject(userId, projectId) - .pipe(Effect.mapError(mapStoreError)); - }), + getProject: Effect.fn("ProjectApplication.getProject")( + function* getProject({ + userId, + projectId, + }: { + readonly userId: string; + readonly projectId: ProjectId; + }) { + return yield* store + .getProject(userId, projectId) + .pipe(Effect.mapError(mapStoreError)); + } + ), importPublicGit: Effect.fn("ProjectApplication.importPublicGit")( - function* importPublicGit({ + function* importPublicGit({ userId, repositoryUrl, }: { @@ -686,7 +688,7 @@ export class ProjectApplication extends Context.Service< } ), importPublicText: Effect.fn("ProjectApplication.importPublicText")( - function* importPublicText({ + function* importPublicText({ userId, projectId, kind, @@ -724,38 +726,38 @@ export class ProjectApplication extends Context.Service< .pipe(Effect.mapError(mapStoreError)); } ), - listProjects: Effect.fn("ProjectApplication.listProjects")(function* listProjects({ - userId, - }: { - readonly userId: string; - }) { - return yield* store - .listProjects(userId) - .pipe(Effect.mapError(mapStoreError)); - }), - putContext: Effect.fn("ProjectApplication.putContext")(function* putContext({ - userId, - projectId, - kind, - content, - origin, - }: { - readonly userId: string; - readonly projectId: ProjectId; - readonly kind: ContextKind; - readonly content: string; - readonly origin: "paste" | "upload"; - }) { - const write: ContextWrite = { - _tag: "UserText", - content, + listProjects: Effect.fn("ProjectApplication.listProjects")( + function* listProjects({ userId }: { readonly userId: string }) { + return yield* store + .listProjects(userId) + .pipe(Effect.mapError(mapStoreError)); + } + ), + putContext: Effect.fn("ProjectApplication.putContext")( + function* putContext({ + userId, + projectId, kind, + content, origin, - }; - return yield* store - .putContext({ projectId, userId, write }) - .pipe(Effect.mapError(mapStoreError)); - }), + }: { + readonly userId: string; + readonly projectId: ProjectId; + readonly kind: ContextKind; + readonly content: string; + readonly origin: "paste" | "upload"; + }) { + const write: ContextWrite = { + _tag: "UserText", + content, + kind, + origin, + }; + return yield* store + .putContext({ projectId, userId, write }) + .pipe(Effect.mapError(mapStoreError)); + } + ), }); }) ); diff --git a/packages/primitives/src/resolver.ts b/packages/primitives/src/resolver.ts index ea2e5c5..c22f7a9 100644 --- a/packages/primitives/src/resolver.ts +++ b/packages/primitives/src/resolver.ts @@ -1,6 +1,6 @@ import { Schema } from "effect"; -import type { WorkStatus } from "./work-lifecycle"; +import type { WorkStatus } from "./work-lifecycle.ts"; const Text = Schema.String.check( Schema.makeFilter((value) => value.trim().length > 0, { diff --git a/packages/primitives/src/work.ts b/packages/primitives/src/work.ts index ee9070b..b25c200 100644 --- a/packages/primitives/src/work.ts +++ b/packages/primitives/src/work.ts @@ -1,7 +1,7 @@ import { Array as EffectArray, Effect, Order, Schema } from "effect"; -export { WorkStatus } from "./work-lifecycle"; -export type { WorkStatus as WorkLifecycleStatus } from "./work-lifecycle"; +export { WorkStatus } from "./work-lifecycle.ts"; +export type { WorkStatus as WorkLifecycleStatus } from "./work-lifecycle.ts"; const MeaningfulString = Schema.String.check( Schema.makeFilter((value) => value.trim().length > 0, { diff --git a/packages/primitives/tsconfig.json b/packages/primitives/tsconfig.json index a571807..1742908 100644 --- a/packages/primitives/tsconfig.json +++ b/packages/primitives/tsconfig.json @@ -1,5 +1,6 @@ { "extends": "@code/config/tsconfig.base.json", + "compilerOptions": { "allowImportingTsExtensions": true }, "include": ["src/**/*.ts"], "exclude": ["dist"] }