fix(report): native --contents-file / stdin for entry submit + skill sync#514
Open
PeterGuy326 wants to merge 3 commits into
Open
fix(report): native --contents-file / stdin for entry submit + skill sync#514PeterGuy326 wants to merge 3 commits into
PeterGuy326 wants to merge 3 commits into
Conversation
…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.
Collaborator
Author
Verification1. Unit + dry-run (live cedar envelope)
End-to-end
Before the fix the same 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):
3. DiscoveryNo discovery-config change required. The cedar |
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.
Problem
dws report entry submit --contents-file <f>(and--contents -stdin) silently submittedcontents: [null]and the report failed. Only inline--contents '[...]'worked — which is why the inline-only helperreport createsucceeded whilereport entry submit --contents-filedid not.Root cause is an architecture mismatch, not a single bad transform:
report entry submitis an envelope-driven command (MCP toolcreate_report). Its--contentsflag hasjson_parse(required); the sibling--contents-filehasomitWhen emptybut no transform / mapsTo, so its value mapped to the unusedcontentsFileparam while the realcontentsstayed empty.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 thecreate_reportleaf, wired beside the existing mail/todo/calendar/attendance hooks:requiredon--contentsand declares acontents/contents-fileone-of group, so a--contents-file-only invocation is no longer rejected at parse time (validated before PreRunE).--contentsso the downstreamjson_parsedecodes it uniformly;--contents-fileis then cleared.The existing cedar
contentsFileflag declaration is kept — it is what registers the--contents-fileflag the hook consumes. No Diamond / discovery change is required.Skill sync
The
multi/dingtalk-reportskill tree was two versions behindmono(taught deprecated flat aliases; falsely claimedreport inboxwas unimplemented). Re-aligned SKILL.md + 05-reporting.md + mono intent-guide.md to the canonicaltemplate 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;contentspopulated with the parsed array.--contents -(stdin) → populated from stdin.--contents→ left untouched.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.