@c4a/context 0.6.0-alpha.6 → 0.6.0-beta.2

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.
@@ -18,9 +18,12 @@ When operating through an Agent plugin, use the installed Context continuation e
18
18
 
19
19
  ## 2. Choose And Register A Source Boundary
20
20
 
21
- First decide what one source should mean for this workspace. The source name is
22
- not only a label; it becomes a stable namespace in source refs, phase ids, and
23
- package naming. Approved knowledge paths are derived from collection,
21
+ First decide what one source should mean for this workspace. By default, source
22
+ registration omits a name and the CLI uses today's local date (`YYYYMMDD`) as
23
+ the source namespace. Do not derive source names from filenames, directory
24
+ names, or document content. If today's date already exists, pass an explicit
25
+ date name. The source name becomes a stable namespace in source refs, phase ids,
26
+ and package naming. Approved knowledge paths are derived from collection,
24
27
  containment, and slug, not directly from the source name. ViewRef/NodeRef are
25
28
  identity fields, not path strings:
26
29
 
@@ -55,20 +58,21 @@ For a single component package, use the package directory as the repo source
55
58
  boundary:
56
59
 
57
60
  ```bash
58
- context source add repo component-lib \
61
+ context source add repo \
59
62
  --local ../component-lib \
60
63
  --remote <git-remote-url> \
61
64
  --ref <commit-sha-or-prefix>
62
65
  context source ensure
63
- context source inspect component-lib
66
+ context source inspect <source-name>
64
67
  ```
65
68
 
66
69
  For a monorepo or subspace, choose the boundary deliberately:
67
70
 
68
71
  - If the user wants one package manual, point `--local` at that package
69
- subdirectory and use a source name like `component-lib`.
72
+ subdirectory and use the CLI-returned date source name in `src/index.ts`.
70
73
  - If the user wants one unified manual for the whole subspace, point `--local`
71
- at the subspace root and use a source name for that subspace.
74
+ at the subspace root and use the CLI-returned date source name as that
75
+ namespace.
72
76
 
73
77
  The long-term multi-module namespace shape is:
74
78
 
@@ -83,11 +87,11 @@ package/subdirectory boundary so the initial containment/slug plan stays
83
87
  focused and does not repeat package names accidentally.
84
88
 
85
89
  The CLI records the git root and subpath, then materializes
86
- `sources/repo/<name>` to the scoped view. Do not register the monorepo root and
90
+ `sources/repo/<source-name>` to the scoped view. Do not register the monorepo root and
87
91
  rely on `extractTs.include` to select a package; `include` is only a file filter
88
92
  inside the selected source boundary.
89
93
 
90
- If the user first registers a monorepo root, run `context source inspect <name>`
94
+ If the user first registers a monorepo root, run `context source inspect <source-name>`
91
95
  before extraction. Show the listed module paths to the user as a tree and
92
96
  register the chosen package path as a separate source for current extraction. The
93
97
  inspect output includes package names, manifest paths, versions when available,
@@ -116,7 +120,7 @@ import {
116
120
  source,
117
121
  } from "@c4a/context";
118
122
 
119
- const docs = source("product-docs");
123
+ const docs = source("20260704");
120
124
 
121
125
  export default defineProject({
122
126
  sources: [docs],
@@ -149,7 +153,7 @@ Edit `src/index.ts`:
149
153
  ```ts
150
154
  import { defineProject, extractTs, reviewValidity, source } from "@c4a/context";
151
155
 
152
- const componentLib = source("component-lib");
156
+ const componentLib = source("20260704");
153
157
 
154
158
  export default defineProject({
155
159
  sources: [componentLib],
@@ -165,8 +169,8 @@ Inspect and run:
165
169
 
166
170
  ```bash
167
171
  context run --list
168
- context run extract:component-lib:codegraph --dry-run
169
- context run extract:component-lib:codegraph
172
+ context run extract:20260704:codegraph --dry-run
173
+ context run extract:20260704:codegraph
170
174
  ```
171
175
 
172
176
  When operating through an Agent, use `--dry-run --format json` as the CLI
@@ -280,7 +284,7 @@ import {
280
284
  source,
281
285
  } from "@c4a/context";
282
286
 
283
- const componentLib = source("component-lib");
287
+ const componentLib = source("20260704");
284
288
 
285
289
  export default defineProject({
286
290
  sources: [componentLib],
@@ -295,7 +299,7 @@ export default defineProject({
295
299
  path: "src/package-templates/kb",
296
300
  vars: { displayName: "Component Library KB" },
297
301
  },
298
- select: { include: ["codegraph/component-lib/**"] },
302
+ select: { include: ["codegraph/20260704/**"] },
299
303
  }),
300
304
  ],
301
305
  });
@@ -308,7 +312,7 @@ of the agent knowledge-base package:
308
312
  llmsPackage({
309
313
  name: "component-lib-llms",
310
314
  template: "src/package-templates/llms",
311
- select: { include: ["codegraph/component-lib/**"] },
315
+ select: { include: ["codegraph/20260704/**"] },
312
316
  });
313
317
  ```
314
318
 
@@ -66,6 +66,8 @@ If you want one manual for only this package, choose the package directory as
66
66
  the source boundary. If you want one manual for the whole subspace, choose the
67
67
  subspace root.
68
68
 
69
+ The CLI will use today's local date (`YYYYMMDD`) as the source name unless that
70
+ date already exists. Do not invent a name from the folder, filenames, or content.
69
71
  The source name becomes part of source refs, phase ids, and package names.
70
72
  Approved knowledge paths are derived from collection, containment, and slug;
71
73
  NodeRef/ViewRef are identity fields, not path strings:
@@ -73,18 +75,11 @@ knowledge/<collection>/<containment>/<slug>.md
73
75
  repo:<source-name>#...
74
76
  dist/<source-name>-kb/...
75
77
 
76
- If the user already gave a path and only the source name is missing, still
77
- explain what the name means:
78
+ If today's date already exists, ask the user for an explicit date name before
79
+ registration. Do not add a sequence number automatically.
78
80
 
79
- - if the path is one package/module, the name appears once in source refs and
80
- phase ids;
81
- - if the path is a parent monorepo/subspace, the name is a parent namespace and
82
- child modules can appear below it later;
83
- - current extraction should inspect a parent source first, then extract from
84
- a confirmed package/subdirectory boundary.
85
-
86
- For a multi-module subspace package shape, a parent name such as product-ui
87
- can group children like:
81
+ For a multi-module subspace package shape, the date source name can group
82
+ children like:
88
83
  knowledge/codegraph/product-ui/component-web/...
89
84
  knowledge/codegraph/product-ui/component-lynx/...
90
85
 
@@ -109,7 +104,8 @@ Good:
109
104
  The source is registered, but registration did not read the document body.
110
105
 
111
106
  The next operation will read this local Markdown file or folder and write a
112
- committed snapshot under `sources/file/<source-name>/`. That snapshot is used
107
+ committed snapshot under `sources/file/<source-name>/`. The source name is the
108
+ date name returned by `context source add file --local <path>`. That snapshot is used
113
109
  later for review, verify, and fresh-clone reproduction.
114
110
 
115
111
  Please confirm that I may read this document source now. After you confirm, I
@@ -123,7 +119,8 @@ For Lark / Feishu:
123
119
  The source is registered, but registration did not fetch the remote document.
124
120
 
125
121
  The next operation will read the Lark/Feishu document you provided and write a
126
- normalized snapshot under `sources/lark/<source-name>/`. The snapshot is
122
+ normalized snapshot under `sources/lark/<source-name>/`. The source name is the
123
+ date name returned by `context source add lark ...`. The snapshot is
127
124
  committed by default so verify can work offline and after a fresh clone. Access
128
125
  credentials stay in the Lark CLI; they are not written to this workspace. If
129
126
  your business repository wants to ignore this snapshot, that is a repository
@@ -174,7 +171,7 @@ phases are not declared yet, then summarize the change. For example:
174
171
 
175
172
  ```text
176
173
  I updated the project flow to add document structure planning and source-bound
177
- compile for `product-docs`. No approved Markdown is written yet. The next gate
174
+ compile for source `20260704`. No approved Markdown is written yet. The next gate
178
175
  is a structure draft for your confirmation.
179
176
  ```
180
177
 
@@ -190,7 +187,7 @@ Bad:
190
187
  ```text
191
188
  是否按 Context 默认范围继续?
192
189
  extractTs({
193
- source: source("component-lib"),
190
+ source: source("20260704"),
194
191
  collection: "codegraph",
195
192
  // include defaults to ["src/**/*.{ts,tsx}"]
196
193
  // exportedOnly defaults to true
@@ -46,7 +46,7 @@ node_modules/@c4a/context/docs/reference/package-templates.md
46
46
  - `unapproved/entities.jsonl` is the committed draft/rejected/deprecated ledger.
47
47
  - `knowledge/` contains approved Markdown.
48
48
  - `dist/` contains generated package outputs.
49
- - file and Lark snapshots live under `sources/file/<name>/` and `sources/lark/<name>/`.
49
+ - file and Lark snapshots live under `sources/file/<source-name>/` and `sources/lark/<source-name>/`.
50
50
  - `.tmp/context-runtime/` contains ignored runtime cache, logs, review HTML, previews, and locks.
51
51
 
52
52
  Do not create hidden workspace state directories.
@@ -58,7 +58,7 @@ Present only the current workflow surface:
58
58
  | Task | Current route |
59
59
  |---|---|
60
60
  | Register a knowledge boundary | `context source add file/lark/repo ...`, followed by the matching project phase declaration. Source registration is a user-confirmed boundary decision. |
61
- | Capture document sources | Run the declared `capture:file:<source>` or `capture:lark:<source>` phase only after read permission. Capture writes committed snapshots under `sources/file/<name>/` or `sources/lark/<name>/`. |
61
+ | Capture document sources | Run the declared `capture:file:<source>` or `capture:lark:<source>` phase only after read permission. Capture writes committed snapshots under `sources/file/<source-name>/` or `sources/lark/<source-name>/`. |
62
62
  | Investigate captured material | Use `context status` and the returned `context run align:<type>:<source>:<collection> --view ...` commands. Evidence views drive reading; raw directory grep is not the workflow. |
63
63
  | Confirm prose structure | `alignProse` validates and stages `unapproved/structure.yaml`. Validation does not equal user confirmation; only confirmed lifecycle state may enter prose compile. |
64
64
  | Compile source-bound drafts | `compileProse` turns confirmed structure into source-bound draft pages. It does not approve knowledge. |
@@ -80,9 +80,12 @@ user first.
80
80
 
81
81
  `missing-source` is a human gate. In user-facing language, describe the next
82
82
  action as adding a knowledge source, not as filling CLI placeholders. Treat this
83
- as a source boundary decision. Explain that the source name is a stable prefix
84
- that appears in source refs and phase ids. Approved paths are derived from
85
- collection, containment, and slug. NodeRef/ViewRef are identity fields, not path strings:
83
+ as a source boundary decision. Explain that the CLI uses today's local date
84
+ (`YYYYMMDD`) as the source name by default; do not invent a name from cwd,
85
+ parent directories, monorepo layout, package names, git remotes, filenames, or
86
+ document content. The source name appears in source refs and phase ids. Approved
87
+ paths are derived from collection, containment, and slug. NodeRef/ViewRef are
88
+ identity fields, not path strings:
86
89
 
87
90
  ```text
88
91
  knowledge/<collection>/<containment>/<slug>.md
@@ -102,26 +105,16 @@ source boundary intentionally covers multiple modules.
102
105
  Ask what the user wants the source to cover: a single local Markdown/MDX document,
103
106
  a local Markdown/MDX directory, an article/documentation repository as a file
104
107
  source, a Lark/Feishu document URL or token, a local code repo/package, a remote
105
- Git repo/package, or a multi-module namespace. Do not infer the source from cwd,
106
- parent directories, monorepo layout, package names, or git remotes. Do not ask
107
- for a raw source name as an isolated parameter; propose one only after the
108
- boundary is clear.
109
-
110
- If the user already provided a path and the remaining question is only the
111
- source name, still explain the boundary implication before asking for
112
- confirmation. A package/module path means the source name becomes the stable
113
- source-ref, phase-id, and package-output identity. A parent monorepo/subspace
114
- path means the source name is a source namespace for possible child modules,
115
- and current extraction must inspect that parent before choosing concrete
116
- package/subdirectory boundaries. Approved paths still come from collection,
117
- containment, and slug.
108
+ Git repo/package, or a multi-module namespace. If today's date source name
109
+ already exists, ask for an explicit date name; do not auto-append a sequence.
110
+ Approved paths still come from collection, containment, and slug.
118
111
 
119
112
  Current execution supports repo sources, local Markdown/MDX file sources, and Lark /
120
113
  Feishu document sources. Local
121
- repo/package sources are registered with `context source add repo <name>
122
- --local <path>`; the materialized `sources/repo/<name>` entry is an ignored
114
+ repo/package sources are registered with `context source add repo --local <path>`;
115
+ the materialized `sources/repo/<source-name>` entry is an ignored
123
116
  symlink to the selected checkout or subdirectory view. Local Markdown/MDX sources
124
- are registered with `context source add file <name> --local <path>` plus any
117
+ are registered with `context source add file --local <path>` plus any
125
118
  needed `--include` patterns, captured with `captureFile`, then planned through
126
119
  `alignProse` and compiled with
127
120
  `compileProse`. A one-file-to-one-page outcome is a degenerate structure plan,
@@ -129,7 +122,7 @@ not a separate content path. Remote Git operations require explicit user approva
129
122
  clone/checkout; clone into an ignored local path, checkout the requested commit,
130
123
  then register that local checkout. Do not commit cloned source content. Lark /
131
124
  Feishu sources are registered as document sources, captured through the Lark
132
- capture phase, and written as committed snapshots under `sources/lark/<name>/`;
125
+ capture phase, and written as committed snapshots under `sources/lark/<source-name>/`;
133
126
  do not fetch or import Lark content with ad hoc scripts.
134
127
 
135
128
  Extraction scope is also a human gate. If no extract phase is declared, explain
@@ -138,8 +131,8 @@ registered source and file/symbol range to ingest. Do not inspect the source
138
131
  repository to choose packages or globs on the user's behalf.
139
132
 
140
133
  For monorepos, one source may conceptually cover the whole repo/subspace or one
141
- package/subdirectory. Explain that the source name becomes a source-ref and
142
- phase-id namespace. A parent source name can support grouped codegraph NodeRefs
134
+ package/subdirectory. Explain that the date source name becomes a source-ref and
135
+ phase-id namespace. A parent date source name can support grouped codegraph NodeRefs
143
136
  such as `knowledge/codegraph/product-ui/component-web/...` and
144
137
  `knowledge/codegraph/product-ui/component-lynx/...`. In the current executable
145
138
  flow, use the whole repo/subspace only for inspection/planning. If the user wants
@@ -19,9 +19,13 @@ declaration list. Put heavy logic in imported transform files.
19
19
 
20
20
  ## Sources
21
21
 
22
- A source is a stable knowledge boundary, not only a display label. The source
22
+ A source is a stable knowledge boundary, not only a display label. By default,
23
+ `context source add repo/file/lark` uses today's local date (`YYYYMMDD`) as the
24
+ source name. Do not derive the name from filenames, directory names, or document
25
+ content. If today's date already exists, pass an explicit date name. The source
23
26
  name becomes a stable identity in source references, phase ids, and package
24
- naming. Approved knowledge paths are derived from collection, containment, and slug. NodeRef/ViewRef are identity fields, not path strings:
27
+ naming. Approved knowledge paths are derived from collection, containment, and
28
+ slug. NodeRef/ViewRef are identity fields, not path strings:
25
29
 
26
30
  ```text
27
31
  knowledge/<collection>/<containment>/<slug>.md
@@ -60,8 +64,7 @@ is a repo, file, or lark source:
60
64
  ```ts
61
65
  import { source } from "@c4a/context";
62
66
 
63
- const componentLib = source("component-lib");
64
- const docs = source("product-docs");
67
+ const docs = source("20260704");
65
68
  ```
66
69
 
67
70
  ### `allSources("repo")`
@@ -124,9 +127,11 @@ Phase id:
124
127
  capture:file:<source-name>
125
128
  ```
126
129
 
127
- Register the source first with `context source add file <name> --local <path>`.
130
+ Register the source first with `context source add file --local <path>`.
128
131
  The first registration requires `--local`; the registry may later keep `local`
129
- only as a refresh hint while committed snapshots remain verifiable.
132
+ only as a refresh hint while committed snapshots remain verifiable. If the
133
+ default date source name already exists, pass an explicit date name:
134
+ `context source add file 20260703 --local <path>`.
130
135
 
131
136
  ### `captureLark`
132
137
 
@@ -143,10 +148,10 @@ Phase id:
143
148
  capture:lark:<source-name>
144
149
  ```
145
150
 
146
- Register the source first with `context source add lark <name>` and exactly one
151
+ Register the source first with `context source add lark` and exactly one
147
152
  identity flag: `--url`, `--doc-token`, or `--wiki-token`. Capture reads the
148
153
  remote document through the CLI runner, writes normalized snapshot files under
149
- `sources/lark/<name>/`, and does not write access credentials into the
154
+ `sources/lark/<source-name>/`, and does not write access credentials into the
150
155
  workspace. Multi-document Lark organization goes through `alignProse`; the
151
156
  current workflow does not provide a one-step Lark stage shortcut.
152
157
 
@@ -258,8 +263,9 @@ Options:
258
263
  | `transform` | Optional markdown transform function or functions |
259
264
 
260
265
  In monorepos, make the package/subdirectory the source boundary. Register the
261
- chosen package path with `context source add repo <name> --local <package-dir>`
262
- and reference it with `source("<name>")`. Do not use `include` to choose a
266
+ chosen package path with `context source add repo --local <package-dir>` and
267
+ reference the CLI-returned date source name with `source("<source-name>")`.
268
+ Do not use `include` to choose a
263
269
  package from a larger monorepo source.
264
270
 
265
271
  Use `context source inspect <source-name>` to list detected module/package
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context",
3
- "version": "0.6.0-alpha.6",
3
+ "version": "0.6.0-beta.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "yaml": "^2.5.1",