feat: add citation framework for read-command envelopes - #2351
Conversation
|
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c723716 to
892519d
Compare
Add a framework-level citation capability for read commands: a citations array on the top-level JSON success envelope, gated by the LARKSUITE_CLI_CITATION environment variable (default off, byte-identical output when off). - internal/citation: Citation wire type, SourceType enum, exact-match Enabled() gate, Normalize(), and RFC3339 Time() normalization - internal/output: lazy citations on the success envelope, injected only inside emitEnvelope; non-envelope formats structurally never build them - shortcuts/common: shared declaration and runtime validation for the legacy and typed paths (explicit read risk, allocated source types, absolute https URLs, drop-and-warn semantics), plus a _meta.citation schema projection on the typed path - pilots: wiki +node-get (typed) and im +chat-messages-list (legacy, also exposing the resolved chat_id in data) - guard test banning int literal source types under shortcuts/ Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
892519d to
af69e7c
Compare
Summary
AI-agent hosts need read commands to return uniform citation entries so rendered answers can link back to their sources. This PR adds a framework-level citation capability: a
citationsarray on the top-level JSON success envelope, gated by theLARKSUITE_CLI_CITATION=1environment variable (default off, byte-identical output when off), with declaration entry points for both the legacy and typed shortcut paths and two pilot commands. Stacked onfeat/typed-shortcut-help-integration(the typed path integrates withcommon.Define).Changes
internal/citationdomain package:Citationwire type,SourceTypeenum, exact-matchEnabled()gate,Normalize()(drops URL-less entries), andTime()RFC3339 normalization with explicit offsetsLARKSUITE_CLI_CITATIONininternal/envvars/envvars.goEnvelope.Citations+EmitOptions.Citationsclosure invoked only insideemitEnvelope(internal/output/envelope.go,internal/output/emitter.go); table/csv/ndjson/pretty/stream paths structurally never build citationsshortcuts/common/citation.go:CitationDefinition, registration-time checks (explicit read risk, allocated source types), per-entry runtime validation (declared source type, absolute https URL) with drop-and-warn semantics that never fail the commandShortcut.Citationdeclaration,citationProvideronOut/OutRaw/OutFormat/OutFormatRaw, mount-time panic on invalid declarations (shortcuts/common/types.go,shortcuts/common/runner.go)Output.Citation+Hooks.BuildCitation, compile-time checks insideDefine, lazy closure threaded throughemitTypedResult, and a_meta.citationschema projection (shortcuts/common/typed_*.go)wiki +node-get(typed, applink URL built from the brand endpoint resolver) andim +chat-messages-list(legacy, per-message citations; also exposes the resolvedchat_idindataas a generally useful additive key)shortcuts/(internal/citation/literal_guard_test.go)Test Plan
go vet, and unit tests passed (go test ./cmd/... ./internal/... ./shortcuts/...)tests/plugin_e2e(TestConcealedForkProjectsRetainedSchemaCatalog) that reproduces identically on the base branch commit and is unrelated to this changeLARKSUITE_CLI_CITATION=1 ./lark-cli wiki +node-get --node-token <token> --dry-runand--format tableruns confirmed no citations and byte-identicaldataagainst the gate-off runsRelated Issues
N/A