@c4a/context-cli 0.6.11 → 0.6.16

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 +5 -0
  2. package/README.zh-CN.md +5 -0
  3. package/cli.js +6112 -3389
  4. package/docs/document-optimization.md +62 -0
  5. package/docs/document-optimization.zh-CN.md +54 -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 +50 -5
  10. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  11. package/plugins/codex/skills/context/SKILL.md +50 -5
  12. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  13. package/plugins/cursor/commands/c4a-context.md +50 -5
  14. package/plugins/skills/c4a-context/SKILL.md +50 -5
  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,145 @@
1
+ ---
2
+ id: semantic.code-index.template.web-application
3
+ kind: procedure
4
+ media-type: text/markdown
5
+ ---
6
+
7
+ # Web and interactive application template
8
+
9
+ Use only after evidence classifies a module as `web-application`. This covers
10
+ browser applications, server-rendered sites, embedded WebViews, desktop Web
11
+ shells, native mobile/desktop applications, cross-platform UI runtimes, and
12
+ similar interactive modules. The `web-application` identifier is retained for
13
+ the current contract but represents an interactive application boundary, not
14
+ only browser code. It does
15
+ not automatically cover every package containing UI components; a reusable
16
+ component package is usually `sdk-library`.
17
+
18
+ Recommended `outputProfile`: `application-map`.
19
+
20
+ ## Evidence pass
21
+
22
+ Locate the concrete application bootstrap and trace outward just far enough to
23
+ find:
24
+
25
+ - application mounting, server rendering, shell, or host-container entry;
26
+ - route/page/screen registries and navigation guards;
27
+ - page-to-state, loader, query, client, bridge, or controller boundaries;
28
+ - runtime configuration, environment selection, feature registration, and
29
+ authentication/session initialization;
30
+ - build, local development, test, bundle, and release entrypoints;
31
+ - generated clients, assets, styles, fixtures, and legacy routes that should
32
+ remain evidence rather than reader-facing pages.
33
+
34
+ If the route registry is generated, locate both its generator or source of
35
+ truth and the runtime consumer. Do not infer page identity from a directory
36
+ tree when an explicit registry exists.
37
+
38
+ ## Questions the knowledge must answer
39
+
40
+ A useful application index should let a reader determine:
41
+
42
+ 1. How does the application start, and which runtime or host does it expect?
43
+ 2. What are the stable pages/routes/screens and their entry components?
44
+ 3. How does a page obtain data or call an external capability?
45
+ 4. Which state, session, bridge, or configuration boundaries affect behavior?
46
+ 5. How is the module run, debugged, built, and released?
47
+ 6. Which implementation details are intentionally outside the knowledge scope?
48
+
49
+ ## Suggested knowledge units
50
+
51
+ Select only units supported by the confirmed goal and evidence:
52
+
53
+ - **Application map**: responsibility, runtime, bootstrap, major subsystems,
54
+ stable dependencies, and navigation to deeper pages.
55
+ - **Route or page registry**: concrete route/page identity, entry component,
56
+ loader/guard, main data boundary, and source locator. Aggregate related
57
+ routes when a page-per-route layout would be repetitive.
58
+ - **Data and protocol boundaries**: add application-specific page, state, and
59
+ session context to the canonical operation record in `protocol-boundary.md`;
60
+ do not create a second operation registry.
61
+ - **State and host integration**: only stable stores, bridges, extension points,
62
+ or host contracts that affect multiple pages or public behavior.
63
+ - **Runtime and delivery guide**: module-owned development commands,
64
+ configuration, build output, deployment/release entry, and evidenced recovery
65
+ paths.
66
+ - **Cross-layer flow**: a source-backed page-to-client-to-provider chain when
67
+ both sides are registered sources.
68
+
69
+ These are possible page families, not a required number of Markdown files.
70
+
71
+ ## Chapter blueprints
72
+
73
+ An application-map page may use:
74
+
75
+ ```markdown
76
+ # <Application> module map
77
+ ## Responsibility and supported runtime
78
+ ## Bootstrap sequence
79
+ ## Route/page organization
80
+ ## State, data, and protocol boundaries
81
+ ## Host integrations and extension points
82
+ ## Configuration and environment selection
83
+ ## Development, build, and release entrypoints
84
+ ## Known exclusions and source-of-truth links
85
+ ```
86
+
87
+ A route/page registry may use a compact record rather than prose repetition:
88
+
89
+ ```markdown
90
+ ## <Route or page family>
91
+ - Identity and registration:
92
+ - Entry component or controller:
93
+ - Loader, guard, or initialization:
94
+ - Main client/state dependencies:
95
+ - User-visible outcome:
96
+ - Source evidence:
97
+ ```
98
+
99
+ A cross-layer page may use:
100
+
101
+ ```markdown
102
+ # <User interaction> execution path
103
+ ## Trigger and route entry
104
+ ## UI/state orchestration
105
+ ## Protocol request and authoritative contract
106
+ ## Provider boundary and response handling
107
+ ## Failure, fallback, and observability
108
+ ## Source-backed relationship chain
109
+ ```
110
+
111
+ Do not fill a heading with generic text. Omit or mark a section as a material
112
+ gap when the source cannot support it.
113
+
114
+ ## Granularity and relationships
115
+
116
+ Prefer stable application concepts over one page per component, hook, state
117
+ field, style, generated type, or internal helper. A page registry must contain
118
+ real identities and source locators, not just folder names. A protocol page
119
+ must name concrete operations or contract locations, not merely state that the
120
+ application “uses HTTP”.
121
+
122
+ Create structured relationships only when registration, call sites, imports
123
+ with unambiguous ownership, or parser evidence support them. Keep inferred
124
+ product intent out of the index.
125
+
126
+ ## Template composition examples
127
+
128
+ - A server-rendered application with local API routes also reads
129
+ `api-service.md` and `protocol-boundary.md`.
130
+ - An embedded application with a host bridge also reads `adapter.md` and the
131
+ applicable `plugin-extension.md` or `protocol-boundary.md` template.
132
+ - A design-system package rendered in a demo application may need separate
133
+ index units: `sdk-library` for the supported package and `web-application`
134
+ for the demo host.
135
+
136
+ ## Revise or stop when
137
+
138
+ - no executable bootstrap or route registry can be located;
139
+ - the proposed output is only a directory summary;
140
+ - protocol semantics depend on unavailable material;
141
+ - generated routes or clients are being mistaken for authoritative behavior;
142
+ - one-symbol-per-page selection expands components or API types without a
143
+ deliberate public-reference goal.
144
+
145
+ Resolve these issues before the measured batch preview.
@@ -0,0 +1,6 @@
1
+ schema: agent-graph.resource.v1
2
+ id: context.document-optimization-current
3
+ kind: context-view
4
+ mediaType: text/markdown
5
+ description: Current document revision status and pending batch size.
6
+ materializer: actions/materialize-context-view.yaml
@@ -0,0 +1,6 @@
1
+ schema: agent-graph.resource.v1
2
+ id: context.extraction-preview
3
+ kind: context-view
4
+ mediaType: text/markdown
5
+ description: Current batch code-extraction scale, output profile, ownership, structural probe coverage, and capability report.
6
+ materializer: actions/materialize-context-view.yaml
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "context.document-optimization-decisions.v1",
4
+ "title": "Context document optimization decisions",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema", "decisions"],
8
+ "properties": {
9
+ "schema": { "const": "context.document-optimization-decisions.v1" },
10
+ "decisions": {
11
+ "type": "array",
12
+ "items": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["fragment_id", "input_digest", "context_digest", "policy_digest", "action"],
16
+ "properties": {
17
+ "fragment_id": { "type": "string", "minLength": 1 },
18
+ "input_digest": { "type": "string", "minLength": 1 },
19
+ "context_digest": { "type": "string", "minLength": 1 },
20
+ "policy_digest": { "type": "string", "minLength": 1 },
21
+ "action": { "enum": ["keep", "replace"] },
22
+ "replacement": { "type": "string" },
23
+ "reason": { "type": "string" }
24
+ },
25
+ "allOf": [
26
+ {
27
+ "if": { "properties": { "action": { "const": "replace" } } },
28
+ "then": { "required": ["replacement"] }
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ }
34
+ }