Skip to content

feat(fn): transport-agnostic core + try-catch / tRPC / oRPC adapter packages#79

Open
DawidWraga wants to merge 72 commits into
mainfrom
fn-near-term-plan
Open

feat(fn): transport-agnostic core + try-catch / tRPC / oRPC adapter packages#79
DawidWraga wants to merge 72 commits into
mainfrom
fn-near-term-plan

Conversation

@DawidWraga

Copy link
Copy Markdown
Owner

Summary

Makes @davstack/fn a dependency-free, transport-agnostic core and splits transport + Result handling into separate companion packages.

Breaking (@davstack/fn → major)

  • Removed .safeCall — use tryCatch from @davstack/try-catch: const { data, error } = await tryCatch(() => myFn({ input, ctx })).
  • Removed the Result type (now in @davstack/try-catch).
  • Removed the pipe export (dead code; the middleware array is strictly more capable).
  • Extracted the tRPC adapter (initProcedureFactory) to @davstack/fn-trpc.
  • Dropped @trpc/server + superjson from dependencies (superjson was unused; tRPC moved to the adapter). Core now has zero runtime deps.

New packages

  • @davstack/try-catch — zero-dep tryCatch(promiseOrThunk) → { data, error } Result wrapper.
  • @davstack/fn-trpcinitProcedureFactory(t.procedure) turns a fn into a tRPC query/mutation procedure.
  • @davstack/fn-orpcinitProcedureFactory(os) turns a fn into an oRPC procedure (maps oRPC context → fn ctx; chain .route() for OpenAPI).

Docs / notes

  • Rewrote fn README for v2 (createFn / initCreateFn / middleware / FnError / tryCatch + adapters).
  • Added design-decisions and oRPC-internals research notes.

Testing

  • 65 tests pass across fn (49), fn-trpc (2), fn-orpc (8), try-catch (6) — no type errors.
  • All packages typecheck clean (tsc --noEmit) and build (tsup ESM + .d.ts).
  • fn-orpc tests cover router-client round-trip, no-input fns, context→ctx mapping, FnError propagation, input/output validation, and type-level inference.

Notes

  • Changesets included for all four packages (fn major; the three new ones minor) — versioning happens at publish via changeset version.
  • Standard Schema swap and the oRPC OpenAPI/registry work are intentionally out of scope here.

DawidWraga added 30 commits June 3, 2026 21:40
Records the initial Promptfoo LLM-as-judge experiment before cleanup. Known rough edges include mixed smoke/explore config, variant-only artifact paths, hardcoded Gemini execution, and unstructured grader output.
Add --compact-mode to open-agents submit. Compact mode treats the user's input as a short task title, requires a history file, extracts a fixed 50k token-like tail, runs a Cursor composer-2.5 spec-writer job, and then submits the generated spec to the selected executor provider.

The spec-writer prompt now prioritizes a dense <context> block with relevant files, folders, project facts, original user query, useful quotes, decisions, constraints, and caveats. It avoids <acceptance> unless the history explicitly calls for one.

Also extend the eval harness artifacts for title-tail and spec-writer variants so generated specs, recent tails, history snapshots, and executor outputs are persisted for comparison.
Let compact mode find history without manual --history-file wiring. Resolution now prefers --history-file, then OPEN_AGENTS_HISTORY_FILE, then CLAUDE_CODE_TRANSCRIPT_PATH for hook-style callers, then CLAUDE_CODE_SESSION_ID by scanning ~/.claude/projects/*/<session>.jsonl.

This keeps explicit history paths available but makes the common Claude Code-launched flow deterministic for tools that inherit the session environment.
Avoid passing the full 50k-token compact history prompt through argv. The spec-writer task is now persisted to the job .spec.md file, and the composer-2.5 spec-writer receives only a short wrapper telling it to read that file and produce the executor spec. This avoids Windows ENAMETOOLONG failures while keeping the full task inspectable on disk.

Also tighten the spec-writer contract: it should distill history into a super concise executor brief, avoid copying the transcript or long history excerpts, and point the executor at the history file when details are uncertain or too large to summarize cleanly.
Report how long the compact spec-writer stage took and include a user-friendly ~/... path to the generated spec artifact. This makes the handoff easier to inspect after compact mode finishes.

Also silence the Cursor .test.ts probe cleanup message; the cleanup still runs, but compact-mode output no longer includes the noisy swept-stray line.
DawidWraga added 29 commits June 9, 2026 15:51
Add the 0.1.1 changelog entry for the folder metadata XML output changes and bump @davstack/meta from 0.1.0 to 0.1.1.
Add line numbers to TypeScript-like and Python symbol summaries while preserving comment-stripped locations. Render omitted files after nested folders so each folder block ends with unsupported files, and publish this as @davstack/meta 0.1.2.
Render file paths relative to the Git repository root and format code symbol references as [ln start-end] ranges. Update tests for nested folder paths and release @davstack/meta 0.1.3.
Render folder paths relative to the Git repository root using the same convention as file paths, including parent segments for nested folders. Add coverage for scanning a nested Git worktree folder.
Render nested folder metadata with tab indentation so folders, files, symbol bullets, and omitted-file entries visually reflect the XML hierarchy.
Adjust folder metadata indentation so root-level children stay flush-left while nested folder contents indent by folder depth. Render code symbol references without list prefixes, keep markdown headings and omitted files as list entries, and release @davstack/meta 0.1.4.
Introduce configurable metadata output with human and agent presets. Human output keeps indentation and full repo-relative file paths, while agent output removes indentation and uses concise file paths inside full folder paths. Expose --human, --agent, --indent/--no-indent, and --file_paths through gen/view, with explicit flags overriding preset defaults.
Make human and agent metadata presets scan deeply by default, while allowing explicit deep false overrides. Remove the generated Markdown title so output starts directly at the folder XML, simplify renderFolderSummary to return the rendered string, and release @davstack/meta 0.1.5 with the pending meta output changesets consumed.
Summarize describe, test, and it calls in TypeScript-like files using their literal source titles and call-expression line ranges. This makes test-heavy folders informative without adding code excerpts, and releases @davstack/meta 0.1.6.
npx explore tries to fetch a nonexistent npm package; the CLI ships as a
pnpm-global linked binary. Regenerated init copy via gen:init-skills.
Remove pipe and .safeCall; drop @trpc/server + superjson deps. Use @davstack/try-catch for Result-style calls and the adapter packages for transport. BREAKING (major).
Zero-dep tryCatch(promiseOrThunk) -> { data, error } Result wrapper.
initProcedureFactory turns a fn into a tRPC query/mutation procedure.
initProcedureFactory turns a fn into an oRPC procedure (maps context -> ctx).
Rewrite README for v2 (createFn/initCreateFn/middleware/FnError/tryCatch + adapters); add fn-error and pipe-vs-middleware eval notes.
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
davstack-docs Error Error Jun 16, 2026 6:46pm
davstack-t3-with-davstack Error Error Jun 16, 2026 6:46pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant