feat: language and jurisdictions metadata in .mikeworkflow.json packs - #35
Open
amal66 wants to merge 1 commit into
Open
feat: language and jurisdictions metadata in .mikeworkflow.json packs#35amal66 wants to merge 1 commit into
amal66 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Workflows can now be exported to and imported from portable
.mikeworkflow.jsonfiles, and those files carry optionallanguageandjurisdictionsmetadata alongside title, type, prompt, columns, and practice area. A firm can share e.g. a French-law NDA review workflow and have it arrive tagged correctly; older files without the new fields import cleanly with stable defaults (English/["General"]) — the format stays version 1, no breaking change.Changes
backend/src/lib/workflowFormat.ts— new module: the zodworkflowPackSchemais the single source of truth for the.mikeworkflow.jsonformat (format version 1, strict top level, forward-compatible loose columns), including the optional nullablelanguage(string) andjurisdictions(string array) fields; plusdescribeWorkflowPackIssues(human-readable validation errors) andbuildWorkflowPackJsonSchema(draft-07 JSON Schema envelope with examples).backend/src/routes/workflows.ts— newexportWorkflow/importWorkflow(exported for tests) and two routes:GET /workflows/:workflowId/export(owner-only download, safe filename) andPOST /workflows/import(validates against the schema, inserts a fresh workflow;language/jurisdictionsnormalized to the existingDEFAULT_WORKFLOW_LANGUAGE/DEFAULT_WORKFLOW_JURISDICTIONSdefaults when omitted, via the file's existingnormalizeOptionalString/normalizeJurisdictions).schemas/workflow.schema.json— the published schema for external tooling, generated from the zod source (never hand-edited).backend/scripts/generate-workflow-schema.ts+generate:workflow-schemanpm script — the generator that writes it.backend/tests/workflowFormat.test.ts— drift check (published JSON must deep-equal the zod-derived schema; examples must validate) plus validation-behavior tests including the metadata fields;backend/tests/workflows.import-metadata.test.ts— import stores explicit metadata and applies the defaults to legacy packs. Tests live underbackend/tests/so they are outside thetscbuild'ssrcinclude; they run under the vitest harness.Why
Workflows are the unit of legal know-how in Mike, but they were locked inside one deployment. A single-file interchange format makes them shareable and versionable, and language/jurisdiction tags are the metadata a legal workflow most needs to travel with it. Deriving the published JSON Schema from the same zod schema the import endpoint enforces (with a drift test) guarantees the documented contract and the actual API can never disagree.
Testing
cd backend && npm install && npm run build— green as committed.cd backend && npm run generate:workflow-schema— regeneratesschemas/workflow.schema.jsonbyte-identical to the committed file.upstream-pr/test-harness) merged locally (one trivialpackage.jsonscripts-block conflict, kept both lines):cd backend && npm test→ 3 files, 25 tests passed (13 of them from this PR).Provenance
All changes are mechanical ports of code in amal66/mike@origin/main (commit b3166dd) plus the metadata delta from #18 (branch
feat/workflow-metadata, the fork's language/jurisdictions commit):apps/api/src/modules/workflows/workflowFormat.ts→backend/src/lib/workflowFormat.ts;workflows.service.tsexportWorkflow/importWorkflowandworkflows.routes.tsexport/import routes →backend/src/routes/workflows.ts(this repo already has theDbtype,asyncRoute,withDatabaseWorkflow, normalizers, and default constants those functions use);apps/api/scripts/generate-workflow-schema.ts→backend/scripts/generate-workflow-schema.ts;schemas/workflow.schema.jsonregenerated from the zod source; both test files ported with path-only adjustments. Exceptions: (1) zod import changed from"zod"to"zod/v4"— this repo pins zod ^3.25.76, which ships the v4 API (strictObject/looseObject/z.iso/z.toJSONSchema) under that subpath; the regenerated schema consequently differs from the fork's only in JSON key order; (2) comment/$id-adjacent path strings updated for thebackend/layout, and the schema description's reference to the fork-onlydocs/workflows.mddropped; (3) the fork'sloggercall in its routes has no equivalent here — the existingconsole.error-based error handler inroutes/workflows.tsis unchanged and covers these routes.Credits & prior art
.mikeworkflow.jsonworkflow export/import (client-side download/upload). The fork's original portability commit records feat(workflows): add JSON file download/upload for workflow transfer Open-Legal-Products/mike#59 as its precedent, and the file extension and interchange goal come straight from that PR; this PR moves the format server-side behind a zod schema.schemas/workflow.schema.json,docs/workflows.md). The fork's pack-format commit records feat: local LLM support via Ollama (OpenAI-compatible, behind ENABLE_OLLAMA) #34 as its precedent; this PR ships the same artifact path (schemas/workflow.schema.json), generated from the zod source of truth so the published contract can't drift.🤖 Generated with Claude Code
https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC