feat: add office-agent document workflow (template + writer + differ) #318

Closed
jiayi wants to merge 19 commits from user/jiayiyan/feat_office-agent-document-template into main
Member

Summary

  • workflow-template-document — pure workflow structure: writer/differ role definitions (Zod v4 discriminated union), ModeratorTable, documentWorkflowDefinition, buildDocumentDescriptor()
  • workflow-agent-officeAdapterFn calling office-agent CLI; generate mode produces output.docx, edit mode snapshots original.docx + overwrites modified.docx; exports packageDescriptor
  • workflow-agent-docx-diffAdapterFn calling docx-diff CLI; treats exit 0/1 as success, exit ≥2 as error; exports packageDescriptor

Both agents implement AdapterFn directly (schema.parse(JSON.parse(raw))), skipping LLM extraction for deterministic CLI output.

Architecture

START → writer ──(edit mode)──→ differ → END
↘(generate mode)→ END

Writer saves two workflow-owned files in edit mode (original.docx + modified.docx), so differ never depends on the user's original path.

## Summary - **`workflow-template-document`** — pure workflow structure: writer/differ role definitions (Zod v4 discriminated union), ModeratorTable, `documentWorkflowDefinition`, `buildDocumentDescriptor()` - **`workflow-agent-office`** — `AdapterFn` calling `office-agent` CLI; generate mode produces `output.docx`, edit mode snapshots `original.docx` + overwrites `modified.docx`; exports `packageDescriptor` - **`workflow-agent-docx-diff`** — `AdapterFn` calling `docx-diff` CLI; treats exit 0/1 as success, exit ≥2 as error; exports `packageDescriptor` Both agents implement `AdapterFn` directly (`schema.parse(JSON.parse(raw))`), skipping LLM extraction for deterministic CLI output. ## Architecture START → writer ──(edit mode)──→ differ → END ↘(generate mode)→ END Writer saves two workflow-owned files in edit mode (`original.docx` + `modified.docx`), so differ never depends on the user's original path.
jiayi added 24 commits 2026-05-18 12:07:19 +00:00
Rename .meta({ casRef: true }) to .meta({ 'x-cas-ref': true }) across
all schema annotations. Zod v4 toJSONSchema automatically outputs
x-cas-ref in the generated JSON Schema, so buildDescriptor preserves
the annotation without any code changes.

Add buildDescriptor test verifying x-cas-ref appears in descriptor
output for annotated fields and is absent for plain fields.

220 tests pass, 0 fail.

Fixes #291, Refs #285
12 interlinked architecture cards + index, covering:
- Core: Bundle, Thread, CAS, Registry
- Execution: Engine, Role, Agent Binding, Reactor
- Tooling: CLI, Dashboard, Package Map
- Authoring: Workflow Templates

小橘 <xiaoju@shazhou.work>
小橘 <xiaoju@shazhou.work>
- evaluateModerator(rules, context) with JSONata expression evaluation
- Fallback (when: null), conditional branching, no-match → __end__
- Full develop workflow moderator ported to JSONata
- 31 tests passing

Closes #295
小橘 <xiaoju@shazhou.work>
- New package: @uncaged/workflow-json-def
- registerWorkflow/loadWorkflow for CAS round-trip
- solve-issue and develop templates converted to pure JSON
- Zod schemas → JSON Schema, moderator → JSONata
- 30 tests passing, biome clean

Closes #297
小橘 <xiaoju@shazhou.work>
- json-cas-engine.ts: new engine using json-cas Store + typed nodes
- json-cas-context.ts: build ThreadContext from thread-step chain
- json-cas-types.ts: engine types (JsonCasEngineIo, JsonCasAgentFn, etc.)
- thread-start/step/end/content nodes in json-cas format
- JSONata moderator via evaluateModerator
- react placeholder (Phase 5 will fill in)
- 21 tests passing, biome clean

Closes #299
小橘 <xiaoju@shazhou.work>
- json-cas-react-recorder.ts: writeReactSession stores full ReAct trace
- ReactTrace/ReactTurnTrace/ReactToolCallTrace types
- JsonCasAgentResult with optional react trace
- Engine integration: real react-session when trace provided, placeholder when null
- 10 new tests (29 total for json-cas engine), biome clean

Closes #301
小橘 <xiaoju@shazhou.work>
小橘 <xiaoju@shazhou.work>
- Delete accidentally committed pnpm-lock.yaml
- Add pnpm-lock.yaml, package-lock.json, yarn.lock to .gitignore
- Add packageManager field (bun@1.3.13)
- Add preinstall script that errors when not using bun
- json-cas init/workflow register+show/thread show/node get+list+walk
- Nested subcommand dispatch under 'json-cas' group
- Default store: ~/.uncaged/workflow/json-cas/
- 15 tests passing, biome clean

Closes #304
小橘 <xiaoju@shazhou.work>
Add package.json, tsconfig.json, and placeholder src/index.ts for the
@uncaged/workflow-template-document package; register it in root tsconfig.json references.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add package.json, tsconfig.json, and placeholder src/index.ts for
@uncaged/workflow-agent-docx-diff; append reference in root tsconfig.json.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements createDocxDiffAgent (AdapterFn), packageDescriptor, and exports in index.ts; 9 tests pass (runner 6 + agent 3).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jiayi force-pushed user/jiayiyan/feat_office-agent-document-template from 5d5cc5810a to 5342fa95f2 2026-05-18 12:18:12 +00:00 Compare
jiayi closed this pull request 2026-05-18 13:27:36 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#318