Skip to content

fix(report): native --contents-file / stdin for entry submit + skill sync#514

Open
PeterGuy326 wants to merge 3 commits into
mainfrom
fix/report-contents-file
Open

fix(report): native --contents-file / stdin for entry submit + skill sync#514
PeterGuy326 wants to merge 3 commits into
mainfrom
fix/report-contents-file

Conversation

@PeterGuy326

Copy link
Copy Markdown
Collaborator

Problem

dws report entry submit --contents-file <f> (and --contents - stdin) silently submitted contents: [null] and the report failed. Only inline --contents '[...]' worked — which is why the inline-only helper report create succeeded while report entry submit --contents-file did not.

Root cause is an architecture mismatch, not a single bad transform:

  • report entry submit is an envelope-driven command (MCP tool create_report). Its --contents flag has json_parse (required); the sibling --contents-file has omitWhen empty but no transform / mapsTo, so its value mapped to the unused contentsFile param while the real contents stayed empty.
  • The wukong reference reads the file/stdin natively in Go (resolveReportContentsFromFlags, priority --contents-file > --contents - > inline). The open edition already mirrors wukong on the read side via post-merge decorator hooks (AttachReportListReadableEnrichment), so this follows the same idiom.

Fix (no discovery-config change)

internal/compat/report_hooks.go — a build-time hook on the create_report leaf, wired beside the existing mail/todo/calendar/attendance hooks:

  1. Clears the individual required on --contents and declares a contents / contents-file one-of group, so a --contents-file-only invocation is no longer rejected at parse time (validated before PreRunE).
  2. A chained PreRunE reads the file/stdin (10MB cap, UTF-8 check) and writes the JSON back into --contents so the downstream json_parse decodes it uniformly; --contents-file is then cleared.

The existing cedar contentsFile flag declaration is kept — it is what registers the --contents-file flag the hook consumes. No Diamond / discovery change is required.

Skill sync

The multi/dingtalk-report skill tree was two versions behind mono (taught deprecated flat aliases; falsely claimed report inbox was unimplemented). Re-aligned SKILL.md + 05-reporting.md + mono intent-guide.md to the canonical template get / entry submit --contents-file / inbox list / outbox list / entry get / entry stats.

Verification

End-to-end against the live cedar envelope via --dry-run:

  • --contents-file <f> (no --contents) → no required error; contents populated with the parsed array.
  • --contents - (stdin) → populated from stdin.
  • inline --contents → left untouched.
  • neither → at least one of the flags in the group [contents contents-file] is required.

11 new unit tests in report_hooks_test.go; go test ./internal/compat/ ./internal/helpers/ ./internal/app/ green. Full wukong01 sandbox eval in progress.

…ON-array params

The dynamic 'report entry submit --contents-file' (and '--contents -' stdin)
silently produced contents=[null]: the contents flag only had json_parse, so a
file path / '-' was parsed as JSON literal instead of being read first. Single
transforms cannot be chained in the envelope, so a *-file flag could not do
file_read + json_parse in one step.

Adds a file_read_json transform (file_read then json_parse) so a *-file CLI flag
can feed a JSON-array MCP parameter from a path or stdin, while the literal
sibling flag keeps json_parse for inline JSON. The report contentsFile envelope
flag is wired to it via discovery config (transform: file_read_json, mapsTo:
contents). Mirrors the existing doc --content-file (file_read -> markdown) pattern.
…y submit

`report entry submit` (envelope tool create_report) exposed --contents
(json_parse, required) plus a sibling --contents-file (omitWhen empty, no
transform/mapsTo). On its own, --contents-file went nowhere: its value mapped
to the unused contentsFile param while the real contents stayed empty, so a
--contents-file-only or `--contents -` (stdin) submit silently sent
contents:[null] and the report failed. Only inline --contents worked, which is
why `report create` (the inline-only helper) succeeded while
`report entry submit --contents-file` did not.

Mirror the wukong reference (resolveReportContentsFromFlags: priority
--contents-file > --contents - > --contents '<json>') with a build-time compat
hook, alongside the existing report list-enrichment hooks. No discovery-config
change is needed:

- installReportHook clears the individual required annotation on --contents and
  declares a contents / contents-file one-of group (validated before PreRunE),
  so a --contents-file-only invocation is no longer rejected at parse time.
- A chained PreRunE reads the file/stdin (10MB cap, UTF-8 check) and writes the
  JSON back into --contents so the downstream json_parse transform decodes it
  uniformly; --contents-file is then cleared so omitWhen drops the dead param.

Verified end-to-end against the live cedar envelope via --dry-run: file, stdin,
and inline sources all populate contents correctly, and supplying neither errors
with "at least one of the flags in the group [contents contents-file] is
required". 11 new unit tests in report_hooks_test.go.
…x list

The multi/dingtalk-report skill tree was two structural versions behind the
mono tree: it still taught the deprecated flat aliases (report create / sent /
list / detail / stats / template detail) and even claimed `report inbox` was
"not implemented, do not fabricate" — which is now false (inbox list works via
the envelope). With report entry submit --contents-file now fixed natively,
steer agents to the canonical resource.verb commands consistently:

- SKILL.md intent table + query hard-constraints → template get / entry submit
  --contents-file / outbox list / entry get / entry stats.
- references/05-reporting.md query-report + submit-report + monthly recipes →
  same canonical commands, drop the false "inbox unimplemented" note, add the
  deprecated-alias reminder mirroring the mono tree.
- mono intent-guide.md → template get / entry submit / outbox list.

Old aliases still execute (with a stderr deprecation notice); this only changes
what the skill recommends, matching dws-wukong's command surface.
@PeterGuy326

Copy link
Copy Markdown
Collaborator Author

Verification

1. Unit + dry-run (live cedar envelope)

go test ./internal/compat/ ./internal/helpers/ ./internal/app/ green; 11 new tests in report_hooks_test.go.

End-to-end report entry submit against the live cedar envelope via --dry-run:

Input Result
--contents-file <f> (no --contents) no required error; contents populated with the parsed array
--contents - (stdin) populated from stdin
inline --contents '[...]' left untouched
neither at least one of the flags in the group [contents contents-file] is required

Before the fix the same --contents-file invocation sent contents: [null] and the report failed.

2. Full cli_to_mcp eval (wukong01 sandbox, PR binary)

Built this branch and ran the full open-edition suite as wukong01 (PAT scopes fully granted first):

  • report: 4 passed / 0 failed → 100% — the fixed product, zero regression.
  • 100% products: report, calendar, attendance, oa, doc, minutes, aisearch, drive, live.
  • Aggregate 2358 cases, 77.6% — dragged down almost entirely by 363 sheet TIMEOUT errors (known infra issue, needs direct pytest) and the mail org-restriction (暂不支持阿里巴巴邮箱), neither related to this change.
  • Every non-100% product was triaged to a pre-existing cause (sheet/aitable server timeout, contact HR-roster account permission, todo sub-task tool not yet exposed, chat group-history permission, wiki proxy route, devdoc pre-prod stub) — none caused by this change, which only adds a report-scoped compat hook plus one no-op-for-non-report hook call.

3. Discovery

No discovery-config change required. The cedar contentsFile flag declaration is kept — it is what registers the --contents-file flag the hook consumes; the hook resolves its value natively before json_parse runs.

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