@c4a/context-cli 0.6.13 → 0.6.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +6 -0
  2. package/README.zh-CN.md +5 -0
  3. package/cli.js +6114 -3390
  4. package/docs/document-optimization.md +58 -0
  5. package/docs/document-optimization.zh-CN.md +50 -0
  6. package/package.json +3 -2
  7. package/plugins/VERSION +1 -1
  8. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  9. package/plugins/claude/commands/context.md +43 -2
  10. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  11. package/plugins/codex/skills/context/SKILL.md +43 -2
  12. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  13. package/plugins/cursor/commands/c4a-context.md +43 -2
  14. package/plugins/skills/c4a-context/SKILL.md +43 -2
  15. package/providers/context/actions/optimize-documents.yaml +6 -0
  16. package/providers/context/actions/preview-extraction-batch.yaml +5 -0
  17. package/providers/context/actions/revise-document.yaml +5 -0
  18. package/providers/context/codes.yaml +6 -0
  19. package/providers/context/graphs/workspace.yaml +118 -3
  20. package/providers/context/manifest.json +242 -26
  21. package/providers/context/provider.yaml +1 -1
  22. package/providers/context/resources/dialogue/code-extraction.md +39 -9
  23. package/providers/context/resources/dialogue/package-output.md +5 -8
  24. package/providers/context/resources/manuals/guides/package-outputs.md +14 -20
  25. package/providers/context/resources/manuals/reference/code-extractors.md +75 -18
  26. package/providers/context/resources/manuals/reference/package-templates.md +26 -33
  27. package/providers/context/resources/manuals/reference/project-api.md +156 -14
  28. package/providers/context/resources/manuals/reference/template-variables.md +4 -3
  29. package/providers/context/resources/procedures/close-and-build.md +5 -0
  30. package/providers/context/resources/procedures/code-extraction.md +86 -13
  31. package/providers/context/resources/procedures/document-optimization.md +43 -0
  32. package/providers/context/resources/procedures/document-revision.md +31 -0
  33. package/providers/context/resources/procedures/package-output.md +10 -34
  34. package/providers/context/resources/semantic/code-index/classification.md +267 -0
  35. package/providers/context/resources/semantic/code-index/templates/adapter.md +109 -0
  36. package/providers/context/resources/semantic/code-index/templates/api-service.md +116 -0
  37. package/providers/context/resources/semantic/code-index/templates/background-runtime.md +109 -0
  38. package/providers/context/resources/semantic/code-index/templates/cli-tool.md +129 -0
  39. package/providers/context/resources/semantic/code-index/templates/contract-source.md +73 -0
  40. package/providers/context/resources/semantic/code-index/templates/cross-module-chain.md +78 -0
  41. package/providers/context/resources/semantic/code-index/templates/derived-source.md +116 -0
  42. package/providers/context/resources/semantic/code-index/templates/domain-service.md +109 -0
  43. package/providers/context/resources/semantic/code-index/templates/event-flow.md +62 -0
  44. package/providers/context/resources/semantic/code-index/templates/monorepo-container.md +124 -0
  45. package/providers/context/resources/semantic/code-index/templates/persistence-boundary.md +56 -0
  46. package/providers/context/resources/semantic/code-index/templates/plugin-extension.md +52 -0
  47. package/providers/context/resources/semantic/code-index/templates/protocol-boundary.md +88 -0
  48. package/providers/context/resources/semantic/code-index/templates/sdk-library.md +132 -0
  49. package/providers/context/resources/semantic/code-index/templates/web-application.md +145 -0
  50. package/providers/context/resources/views/document-optimization-current.yaml +6 -0
  51. package/providers/context/resources/views/extraction-preview.yaml +6 -0
  52. package/providers/context/schemas/document-optimization-decisions.schema.json +34 -0
@@ -0,0 +1,116 @@
1
+ ---
2
+ id: semantic.code-index.template.api-service
3
+ kind: procedure
4
+ media-type: text/markdown
5
+ ---
6
+
7
+ # API service and gateway template
8
+
9
+ Use after classifying an inbound HTTP, RPC, GraphQL, message-request, or similar
10
+ surface as `api-service`. A module that only calls a remote API is a protocol
11
+ consumer, not automatically an API service. Gateways that translate to another
12
+ protocol normally also select `adapter`.
13
+
14
+ Recommended `outputProfile`: `protocol-index`. If the reader goal is primarily
15
+ the transformation between inbound and outbound boundaries, use
16
+ `adapter-contract` instead and retain one canonical operation registry.
17
+
18
+ ## Evidence pass
19
+
20
+ Locate and connect:
21
+
22
+ - process/server entry and service startup;
23
+ - route, method, resolver, or service registration;
24
+ - middleware, authentication, authorization, validation, and request context;
25
+ - handler dispatch and the first stable domain/downstream boundary;
26
+ - authoritative IDL, OpenAPI, schema, service definition, or registration;
27
+ - response/error mapping, retry, timeout, and compatibility behavior;
28
+ - configuration, local run, test, deployment, and release entrypoints;
29
+ - generated models or clients and their actual source of truth.
30
+
31
+ Prefer explicit registrations over handler filenames. Sample enough operations
32
+ from each registration family to verify that the proposed aggregation is real.
33
+
34
+ ## Questions the knowledge must answer
35
+
36
+ 1. What protocol does the module provide, and where is it registered?
37
+ 2. Which operations are stable and who handles each one?
38
+ 3. What authentication, validation, middleware, or request context applies?
39
+ 4. Where does each operation hand off to domain logic or a downstream system?
40
+ 5. How are successful responses and failures translated?
41
+ 6. Which schema is authoritative, and which files are generated projections?
42
+ 7. How is the service run, configured, observed, and released?
43
+
44
+ ## Suggested knowledge units
45
+
46
+ - **Service boundary**: responsibility, startup, supported protocols,
47
+ middleware order, downstream systems, and ownership.
48
+ - **Operation registry**: use the canonical operation record from
49
+ `protocol-boundary.md`, adding handler and middleware detail from this
50
+ template rather than creating a second registry.
51
+ - **Dispatch and dependency map**: route/service registration to handler to
52
+ domain/RPC/repository boundary, grouped by coherent operation family.
53
+ - **Error and compatibility contract**: only when status/error mapping,
54
+ versioning, fallback, or compatibility is stable and source-backed.
55
+ - **Runtime and delivery guide**: configuration, startup, diagnostics,
56
+ deployment, and release entrypoints owned by this service.
57
+
58
+ Do not create a page per generated request/response model, constant, converter,
59
+ pack/unpack helper, or handler-local function.
60
+
61
+ ## Chapter blueprints
62
+
63
+ A service-boundary page may use:
64
+
65
+ ```markdown
66
+ # <Service> boundary
67
+ ## Responsibility and consumers
68
+ ## Startup and protocol registration
69
+ ## Middleware and request lifecycle
70
+ ## Operation families
71
+ ## Domain and downstream dependencies
72
+ ## Error, timeout, and compatibility behavior
73
+ ## Configuration, observability, and release
74
+ ## Exclusions and authoritative schemas
75
+ ```
76
+
77
+ A focused execution-path page may use:
78
+
79
+ ```markdown
80
+ # <Operation> execution path
81
+ ## Inbound contract
82
+ ## Middleware and validation
83
+ ## Handler orchestration
84
+ ## Domain/downstream handoff
85
+ ## Response and error mapping
86
+ ## Source-backed edges
87
+ ```
88
+
89
+ ## Granularity and relationships
90
+
91
+ Aggregate operations that share registration, middleware, handler family, and
92
+ downstream ownership. Split when operation families have different contracts,
93
+ owners, or execution paths—not merely because they are separate methods.
94
+
95
+ Record a route-to-handler or handler-to-downstream edge only when the route
96
+ table, registration, call site, or parser evidence is unambiguous. Generated
97
+ types can locate fields but do not prove runtime behavior.
98
+
99
+ ## Template composition examples
100
+
101
+ - A gateway that receives HTTP and calls RPC reads `adapter.md` and
102
+ `protocol-boundary.md` in addition to this template.
103
+ - An RPC service containing stable domain orchestration also reads
104
+ `domain-service.md`.
105
+ - An event-triggered endpoint may require `event-flow.md`; background consumers
106
+ use `background-runtime.md`.
107
+
108
+ ## Revise or stop when
109
+
110
+ - no registration or authoritative operation identity is available;
111
+ - the plan lists handlers without connecting them to provided operations;
112
+ - the only contract source is generated code with an unknown upstream schema;
113
+ - security or error behavior would be guessed from names;
114
+ - scan mode would expand models and helpers into hundreds of pages.
115
+
116
+ Mark unavailable protocol semantics as `material-required` before preview.
@@ -0,0 +1,109 @@
1
+ ---
2
+ id: semantic.code-index.template.background-runtime
3
+ kind: procedure
4
+ media-type: text/markdown
5
+ ---
6
+
7
+ # Background runtime template
8
+
9
+ Use for `background-runtime`: queue or stream consumers, scheduled jobs,
10
+ pipelines, functions, controllers, watchers, and long-running agents activated
11
+ by a trigger instead of an interactive request.
12
+
13
+ Recommended `outputProfile`: `runtime-map`.
14
+
15
+ ## Evidence pass
16
+
17
+ Locate:
18
+
19
+ - process/runtime bootstrap and worker/job registration;
20
+ - trigger identity: topic, queue, schedule, hook, file, controller event, or
21
+ platform invocation;
22
+ - payload/schema locator and producer when available;
23
+ - handler dispatch, concurrency, partitioning, ordering, and state changes;
24
+ - downstream services, persistence, emitted events, and side effects;
25
+ - retry, timeout, checkpoint, idempotency, dead-letter, and recovery behavior;
26
+ - configuration, scaling, health, observability, deployment, and ownership;
27
+ - replay/test fixtures and generated payload types that are not authoritative.
28
+
29
+ Distinguish code defaults from runtime configuration. Do not describe delivery
30
+ guarantees unless registration, framework configuration, or maintained
31
+ documentation proves them.
32
+
33
+ ## Questions the knowledge must answer
34
+
35
+ 1. What activates the runtime and where is that trigger registered?
36
+ 2. What input contract is consumed, and who produces it?
37
+ 3. How does work move from dispatch through orchestration and side effects?
38
+ 4. What are the concurrency, ordering, retry, and idempotency boundaries?
39
+ 5. How does the runtime checkpoint, recover, or surface failed work?
40
+ 6. How is it configured, operated, observed, scaled, and deployed?
41
+
42
+ ## Suggested knowledge units
43
+
44
+ - **Runtime map**: bootstrap, trigger families, handler registry, dependencies,
45
+ state boundaries, and operating model.
46
+ - **Trigger/workflow registry**: stable trigger identity, input contract,
47
+ handler, downstream effects, retry/idempotency, and source locator.
48
+ - **Processing flow**: focused end-to-end path for a high-value workflow family.
49
+ - **Recovery and operations guide**: checkpointing, failed work, observability,
50
+ configuration, local execution, deployment, and safe replay where evidenced.
51
+ - **Producer-consumer chain**: only when both registered modules and the event
52
+ identity are source-backed.
53
+
54
+ ## Chapter blueprints
55
+
56
+ ```markdown
57
+ # <Background runtime> map
58
+ ## Responsibility and activation model
59
+ ## Bootstrap and trigger registration
60
+ ## Workflow or handler families
61
+ ## State and downstream side effects
62
+ ## Concurrency, ordering, retry, and idempotency
63
+ ## Failure recovery and observability
64
+ ## Configuration, scaling, and deployment
65
+ ## Contract sources and exclusions
66
+ ```
67
+
68
+ For a trigger family:
69
+
70
+ ```markdown
71
+ ## <Trigger or workflow>
72
+ - Trigger identity and registration:
73
+ - Input contract and producer:
74
+ - Dispatch and handler:
75
+ - State changes and downstream effects:
76
+ - Retry/idempotency/checkpoint behavior:
77
+ - Failure destination and operator action:
78
+ - Source evidence:
79
+ ```
80
+
81
+ ## Granularity and relationships
82
+
83
+ Prefer one record per stable trigger or coherent workflow family. Do not create
84
+ one page per handler helper, event field, retry branch, or generated payload
85
+ type. Split a page when triggers have different contracts, ownership, delivery,
86
+ or recovery semantics.
87
+
88
+ Every retained page must name concrete trigger, handler, state, side-effect,
89
+ and recovery identities with source locators. A runtime page that only lists
90
+ directories or says a worker “processes events” is too thin.
91
+
92
+ Connect producers and consumers only through a concrete topic/trigger/schema
93
+ identity. A shared type name or import is insufficient.
94
+
95
+ ## Template composition examples
96
+
97
+ - A consumer that invokes a domain boundary reads `domain-service.md`.
98
+ - A scheduler that calls external APIs selects `protocol-consumer` and reads
99
+ `protocol-boundary.md`.
100
+ - A controller exposing administrative commands may combine this template with
101
+ `cli-tool.md` or `api-service.md`, but should still produce one runtime map.
102
+
103
+ ## Revise or stop when
104
+
105
+ - no trigger registry or executable worker entry can be found;
106
+ - delivery, ordering, retry, or idempotency would be guessed;
107
+ - the producer or authoritative payload contract is required but unavailable;
108
+ - the plan expands generated event structures or helpers one symbol per page;
109
+ - runtime configuration cannot be distinguished from test setup.
@@ -0,0 +1,129 @@
1
+ ---
2
+ id: semantic.code-index.template.cli-tool
3
+ kind: procedure
4
+ media-type: text/markdown
5
+ ---
6
+
7
+ # CLI and developer tool template
8
+
9
+ Use for `cli-tool`: command-line applications, developer tools, administrative
10
+ executables, generators, and command-driven plugin hosts. A build script used
11
+ only internally does not need a CLI knowledge unit unless it is a supported
12
+ operator or contributor surface.
13
+
14
+ Recommended `outputProfile`: `command-map`.
15
+
16
+ ## Evidence pass
17
+
18
+ Locate:
19
+
20
+ - executable/bin entry, runtime requirement, and command parser;
21
+ - root and nested command registration;
22
+ - positional arguments, flags, defaults, mutually exclusive options, and input
23
+ schemas;
24
+ - configuration files, environment variables, profiles, credential sources,
25
+ and precedence;
26
+ - interactive prompts versus non-interactive/automation behavior;
27
+ - filesystem, repository, network, platform, and plugin side effects;
28
+ - output formats, stdout/stderr behavior, exit codes, polling, and recovery;
29
+ - local development, packaging, installation, compatibility, and release;
30
+ - deprecated commands, aliases, parser helpers, and formatters to exclude.
31
+
32
+ Inspect actual command registration and representative execution paths. Help
33
+ text is useful evidence but may not describe hidden preconditions or effects.
34
+
35
+ ## Questions the knowledge must answer
36
+
37
+ 1. How is the CLI installed or invoked, and what runtime does it require?
38
+ 2. What stable command families exist and what user outcomes do they produce?
39
+ 3. What inputs, configuration, credentials, and precedence rules apply?
40
+ 4. Which commands mutate files, repositories, remote services, or user state?
41
+ 5. What output and exit behavior supports automation and diagnosis?
42
+ 6. Which plugin or extension points change the command surface?
43
+ 7. How does a user recover from common source-backed failure states?
44
+
45
+ ## Suggested knowledge units
46
+
47
+ - **Command map**: invocation model, command families, configuration,
48
+ credentials, side effects, output formats, and extension points.
49
+ - **Task workflow**: an end-to-end supported user goal spanning several
50
+ commands, with preconditions, state transitions, and recovery.
51
+ - **Command-family reference**: coherent subcommands with inputs, outputs,
52
+ side effects, and examples.
53
+ - **Configuration and credentials**: when precedence or environment behavior is
54
+ complex and stable enough for a dedicated page.
55
+ - **Plugin/extension contract**: use the single complete blueprint in
56
+ `plugin-extension.md`; the command map only links commands and configuration
57
+ to that contract.
58
+ - **Development and release guide**: only source-backed contributor workflows
59
+ owned by this module.
60
+
61
+ ## Chapter blueprints
62
+
63
+ ```markdown
64
+ # <CLI> command map
65
+ ## Purpose, installation, and invocation
66
+ ## Command families
67
+ ## Configuration and precedence
68
+ ## Credentials and external dependencies
69
+ ## Filesystem/repository/remote side effects
70
+ ## Output formats and exit semantics
71
+ ## Plugins, compatibility, and release
72
+ ## Diagnostics, recovery, and exclusions
73
+ ```
74
+
75
+ For a command family:
76
+
77
+ ```markdown
78
+ # <Command family>
79
+ ## User outcomes and preconditions
80
+ ## Commands and arguments
81
+ ## Configuration and credential requirements
82
+ ## Execution and side effects
83
+ ## Output and exit behavior
84
+ ## Failure recovery
85
+ ## Source-backed examples
86
+ ```
87
+
88
+ A workflow page may use:
89
+
90
+ ```markdown
91
+ # <User task>
92
+ ## Starting state
93
+ ## Command sequence
94
+ ## State and artifact changes
95
+ ## Remote operations
96
+ ## Success checks
97
+ ## Recovery and rollback boundaries
98
+ ```
99
+
100
+ ## Granularity and relationships
101
+
102
+ Prefer command families and user tasks over one page per parser node, flag,
103
+ prompt, formatter, or implementation function. Split only when commands have
104
+ different state ownership, external systems, or safety/recovery contracts.
105
+
106
+ Every retained page must name real commands, task outcomes, state changes, or
107
+ extension identities with source locators. A list of command directories or
108
+ parser nodes is not a command map.
109
+
110
+ Connect commands to configuration, package/file outputs, plugin providers, and
111
+ platform operations only when source registrations or call sites prove them.
112
+
113
+ ## Template composition examples
114
+
115
+ - A CLI with installable providers also reads `adapter.md` and
116
+ `plugin-extension.md`.
117
+ - A CLI that primarily wraps a remote protocol selects `protocol-consumer` and
118
+ reads `protocol-boundary.md`.
119
+ - A monorepo release tool may combine this template with
120
+ `monorepo-container.md` and `build-release` without duplicating its command
121
+ registry.
122
+
123
+ ## Revise or stop when
124
+
125
+ - no stable command registry or executable entry is found;
126
+ - examples require inventing flags or commands not present in source;
127
+ - side effects or credential behavior are unclear but material to safe use;
128
+ - every option/parser helper is becoming an independent page;
129
+ - deprecated or hidden implementation commands are presented as supported.
@@ -0,0 +1,73 @@
1
+ ---
2
+ id: semantic.code-index.template.contract-source
3
+ kind: procedure
4
+ media-type: text/markdown
5
+ ---
6
+
7
+ # Authoritative contract source template
8
+
9
+ Use for `contract-source`: a module whose maintained value is an authoritative
10
+ IDL, OpenAPI document, schema registry, message contract, or equivalent
11
+ machine-readable interface definition. It defines contracts consumed by other
12
+ modules but does not need to execute or dispatch them itself.
13
+
14
+ Recommended `outputProfile`: `protocol-index`. Also select
15
+ `protocol-provider`, and use `generated-contract` only for generated projections
16
+ that point back to this authority. The normal lifecycle is `authoritative`.
17
+
18
+ ## Evidence pass
19
+
20
+ Locate:
21
+
22
+ - schema roots, namespaces/packages, service or message registries, and imports;
23
+ - operation, event, request, response, and error identities;
24
+ - versioning, compatibility, deprecation, and evolution rules;
25
+ - generator configuration, target languages/packages, and generated output
26
+ boundaries;
27
+ - known provider and consumer registrations when those modules are registered;
28
+ - ownership, validation, publication, and release entrypoints.
29
+
30
+ ## Questions the knowledge must answer
31
+
32
+ 1. Which contracts are authoritative in this module?
33
+ 2. How are operations/messages grouped and identified?
34
+ 3. What versioning and compatibility rules are declared?
35
+ 4. Which generated artifacts and consumers derive from this source?
36
+ 5. How is the contract validated, published, and changed?
37
+
38
+ ## Suggested knowledge units
39
+
40
+ - **Contract registry**: namespaces, service/message families, authority,
41
+ versions, owners, and navigation.
42
+ - **Operation or message-family reference**: exact identities, payload roles,
43
+ errors, compatibility, and generated targets.
44
+ - **Generation and publication map**: generator inputs/outputs, validation,
45
+ versioning, and release boundary.
46
+ - **Provider-consumer flow**: only when both runtime endpoints are registered
47
+ and source-backed; use the cross-module template.
48
+
49
+ ## Chapter blueprint
50
+
51
+ ```markdown
52
+ # <Contract module> registry
53
+ ## Authority, ownership, and schema roots
54
+ ## Namespaces and contract families
55
+ ## Operations, messages, and error identities
56
+ ## Versioning, compatibility, and deprecation
57
+ ## Generated targets and active consumers
58
+ ## Validation, publication, and release
59
+ ## Evidence and exclusions
60
+ ```
61
+
62
+ Use the canonical operation record from `protocol-boundary.md` for detailed
63
+ families. Do not duplicate every generated language binding or claim runtime
64
+ behavior from the schema alone.
65
+
66
+ ## Granularity and stop conditions
67
+
68
+ Aggregate related operations/messages by authoritative family. Split when
69
+ namespace, owner, version policy, or compatibility behavior differs. Every page
70
+ must contain exact contract identities and source locators, not just filenames.
71
+
72
+ Revise or stop when authority cannot be distinguished from a generated copy,
73
+ imports or versions are unresolved, or compatibility claims are not declared.
@@ -0,0 +1,78 @@
1
+ ---
2
+ id: semantic.code-index.template.cross-module-chain
3
+ kind: procedure
4
+ media-type: text/markdown
5
+ ---
6
+
7
+ # Cross-module flow template
8
+
9
+ Use for `cross-module-chain` only when a stable reader question cannot be
10
+ answered inside one module. The chain is an independently owned index unit with
11
+ `outputProfile: "cross-module-flow"`; each participating module keeps its own
12
+ non-duplicated map.
13
+
14
+ ## Evidence pass
15
+
16
+ Establish:
17
+
18
+ - an explicit start trigger and terminal outcome;
19
+ - each registered module boundary in execution order;
20
+ - operation, event, repository, command, or plugin identities joining adjacent
21
+ modules;
22
+ - transformations, ownership handoffs, state changes, and failure boundaries;
23
+ - source locators on both sides of every join;
24
+ - authentication, retries, fallback, observability, and recovery only where
25
+ they are explicitly configured.
26
+
27
+ Imports, filenames, symbol co-occurrence, and similar names do not prove a
28
+ runtime chain.
29
+
30
+ ## Questions the knowledge must answer
31
+
32
+ 1. What reader goal and source-backed trigger start the flow?
33
+ 2. Which module owns each step and boundary?
34
+ 3. Which exact contract or identity joins each adjacent step?
35
+ 4. What state, identity, or data is transformed at every handoff?
36
+ 5. Where can the flow fail, retry, fall back, or terminate?
37
+
38
+ ## Chapter blueprint
39
+
40
+ ```markdown
41
+ # <Cross-module flow>
42
+ ## Reader goal and starting trigger
43
+ ## Boundary sequence and module ownership
44
+ ## Contract and transformation at each handoff
45
+ ## State changes and terminal outcome
46
+ ## Authentication, failure, retry, and fallback
47
+ ## Source-backed edge inventory
48
+ ## Known gaps and excluded implementation detail
49
+ ```
50
+
51
+ Examples include application-to-client-to-endpoint, endpoint-to-service-to-
52
+ repository, producer-to-event-to-consumer, command-to-remote-operation, and
53
+ plugin-host-to-provider.
54
+
55
+ ## Extractor and ownership rule
56
+
57
+ A chain normally overlaps the sources already owned by module units. Use
58
+ `extractCustom()` and assign each aggregate candidate to the chain unit through
59
+ its `module` field. `extractTs()` assigns ownership at source level, so it cannot
60
+ represent both a per-module unit and an overlapping cross-source chain unit in
61
+ the same phase.
62
+
63
+ The aggregate candidate may cite evidence from every participating source. It
64
+ must cover all Route-reported structural probes selected by the flow profile;
65
+ one page may cover several probes when it carries each exact evidence locator.
66
+ Use `operation` and `handoff` candidate sections and emit source-backed
67
+ `depends_on` edges from the owning module candidate to the next registered
68
+ module candidate. Narrative arrows or a textual sequence do not satisfy the
69
+ structured relationship requirement.
70
+
71
+ ## Granularity and stop conditions
72
+
73
+ Emit one deduplicated page per coherent end-to-end flow family. Split when the
74
+ trigger, terminal outcome, ownership, contract, or failure policy differs.
75
+
76
+ Revise or stop when either endpoint or a joining identity is missing, the chain
77
+ crosses unregistered sources, relationships depend on inference, or the output
78
+ repeats module pages without adding a handoff model.
@@ -0,0 +1,116 @@
1
+ ---
2
+ id: semantic.code-index.template.derived-source
3
+ kind: procedure
4
+ media-type: text/markdown
5
+ ---
6
+
7
+ # Generated, mirrored, vendored, and legacy source template
8
+
9
+ Use for `derived-source` and lifecycle values `generated`, `mirrored`,
10
+ `vendored`, or `legacy`. Its main purpose is to prevent derived artifacts from
11
+ being mistaken for independent knowledge authority while preserving useful
12
+ consumer and provenance information.
13
+
14
+ ## Evidence pass
15
+
16
+ Locate:
17
+
18
+ - generation, sync, vendoring, migration, or deprecation markers;
19
+ - authoritative repository, schema, template, source directory, or upstream
20
+ package;
21
+ - generator/sync command, configuration, version pin, and output boundary;
22
+ - ownership and update cadence;
23
+ - consumers that still import or execute the derived tree;
24
+ - local modifications, compatibility wrappers, or hand-maintained overlays;
25
+ - release/build artifacts and whether they are committed or reproducible;
26
+ - replacement path for legacy source when one is explicitly maintained.
27
+
28
+ Do not assume all files in a generated-looking directory are derived. Confirm
29
+ markers, build steps, headers, manifests, or source mapping.
30
+
31
+ ## Questions the knowledge must answer
32
+
33
+ 1. Why does this source exist and what lifecycle category applies?
34
+ 2. Where is the authoritative source of truth?
35
+ 3. How is the derived content produced, synchronized, or versioned?
36
+ 4. Which consumers depend on it and through what supported surface?
37
+ 5. Are local edits permitted, overwritten, or layered separately?
38
+ 6. What is safe to inspect here, and what knowledge belongs upstream?
39
+ 7. For legacy source, what current replacement and migration status are proven?
40
+
41
+ ## Suggested knowledge units
42
+
43
+ - **Provenance record**: lifecycle, authority, generator/sync, version relation,
44
+ ownership, output boundary, and consumer summary.
45
+ - **Generated public surface**: only when this tree is the supported consumer
46
+ interface; combine with `sdk-library` and keep the upstream schema explicit.
47
+ - **Compatibility or migration boundary**: when maintained wrappers or legacy
48
+ behavior remain operationally relevant and source-backed.
49
+ - **Update/recovery procedure**: only maintained generation or synchronization
50
+ commands, verification, and overwrite boundaries.
51
+
52
+ Default `outputProfile` to `provenance-only` unless a supported consumer surface
53
+ requires another profile. A consumer-facing derived unit should set
54
+ `sourceOfTruth` to the confirmed authority locator; a missing authority remains
55
+ an advisory risk rather than a reason to hide the supported consumer surface.
56
+
57
+ ## Chapter blueprints
58
+
59
+ ```markdown
60
+ # <Derived source> provenance
61
+ ## Lifecycle classification
62
+ ## Authority and ownership
63
+ ## Generator, sync, or vendoring mechanism
64
+ ## Version and compatibility relationship
65
+ ## Output boundary and local-edit policy
66
+ ## Active consumers
67
+ ## Update, verification, and recovery
68
+ ## Reader-facing knowledge owned elsewhere
69
+ ```
70
+
71
+ For a generated public client:
72
+
73
+ ```markdown
74
+ # <Generated client> consumer surface
75
+ ## Intended consumers and supported import
76
+ ## Authoritative schema and generation version
77
+ ## Client initialization and operation families
78
+ ## Generated versus maintained behavior
79
+ ## Compatibility and regeneration
80
+ ## Evidence and excluded generated detail
81
+ ```
82
+
83
+ ## Granularity and relationships
84
+
85
+ Do not duplicate pages already owned by the authoritative schema,
86
+ implementation, or package. Generated files may provide exact locators and
87
+ cross-checks but should not expand every model, constant, serializer, or method
88
+ into reader-facing Markdown.
89
+
90
+ Relate the derived unit to its authority and active consumers. A relationship
91
+ to an upstream schema must use an explicit locator or generation configuration,
92
+ not a naming guess.
93
+
94
+ If the authority cannot be located, a narrow provenance unit may still record
95
+ confirmed lifecycle markers, generator clues, output boundaries, and active
96
+ consumers. Keep any separate unit that promises field semantics, compatibility,
97
+ or upstream meaning as `material-required` until the missing authority is
98
+ provided.
99
+
100
+ ## Template composition examples
101
+
102
+ - A generated API client is `sdk-library` + `derived-source` and reads
103
+ `protocol-boundary.md` for protocol authority.
104
+ - A vendored library with no project-owned surface remains one provenance page,
105
+ not a copied API reference.
106
+ - A legacy adapter still serving callers combines this template with
107
+ `adapter.md`; document only proven compatibility and migration behavior.
108
+
109
+ ## Revise or stop when
110
+
111
+ - the authoritative source cannot be identified for semantic or compatibility
112
+ claims beyond a narrow provenance record;
113
+ - generated and hand-maintained files cannot be separated;
114
+ - the plan duplicates upstream reference material without consumer value;
115
+ - legacy replacement or deprecation claims are inferred rather than evidenced;
116
+ - generated symbols dominate projected pages.