@c4a/context-cli 0.7.105 → 0.7.107

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 (30) hide show
  1. package/cli.js +2458 -1557
  2. package/indexers/contracts/profile-contract.json +245 -245
  3. package/indexers/release-manifest.json +1 -1
  4. package/package.json +12 -12
  5. package/plugins/VERSION +1 -1
  6. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  7. package/plugins/claude/commands/context.md +17 -5
  8. package/plugins/claude/resources/context/routine-update.md +46 -27
  9. package/plugins/claude/skills/context-plan/SKILL.md +4 -2
  10. package/plugins/claude/skills/context-plan/references/project-planning.md +9 -1
  11. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  12. package/plugins/codex/skills/context/SKILL.md +17 -5
  13. package/plugins/codex/skills/context/references/routine-update.md +46 -27
  14. package/plugins/codex/skills/context-plan/SKILL.md +4 -2
  15. package/plugins/codex/skills/context-plan/references/project-planning.md +9 -1
  16. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  17. package/plugins/cursor/commands/c4a-context.md +17 -5
  18. package/plugins/cursor/resources/context/routine-update.md +46 -27
  19. package/plugins/cursor/skills/context-plan/SKILL.md +4 -2
  20. package/plugins/cursor/skills/context-plan/references/project-planning.md +9 -1
  21. package/plugins/skills/context/SKILL.md +17 -5
  22. package/plugins/skills/context/references/routine-update.md +46 -27
  23. package/plugins/skills/context-plan/SKILL.md +4 -2
  24. package/plugins/skills/context-plan/references/project-planning.md +9 -1
  25. package/providers/context/manifest.json +10 -10
  26. package/providers/context/provider.yaml +1 -1
  27. package/providers/context/resources/manuals/guides/knowledge-updates.md +137 -0
  28. package/providers/context/resources/procedures/approved-revision.md +6 -1
  29. package/providers/context/resources/procedures/knowledge-updates.md +137 -0
  30. package/providers/context/resources/procedures/source-update.md +20 -0
@@ -456,6 +456,136 @@ Before importing a `note`, read [note source preparation](note.md).
456
456
  Before importing `sessions`, read [development summary preparation](sessions.md).
457
457
  Choose the reference for the actual input; do not read both by default.
458
458
 
459
+ ## Refresh several registered sources
460
+
461
+ When several registered sources move to newer versions together, size them
462
+ first and update them in batches, so each review covers related pages:
463
+
464
+ 1. **Size read-only.** Before changing `sources/repo/index.yaml`, fetch only the
465
+ target commits (`git ls-remote`, or `git fetch` with `--filter=blob:none` in a
466
+ partial clone). Do not pull, check out or move any HEAD yet: a checkout that
467
+ no longer matches its registered commit reports a changed source boundary.
468
+ List each repository's changes with `git diff --name-status <processed>
469
+ <target> -- <registered subpath>`, which compares trees without downloading
470
+ file contents and prints full paths; do not use `--stat`, which downloads
471
+ both versions of every changed file. Count official code and Markdown files,
472
+ not tests, lock files, generated output (including run records such as
473
+ workflow artifacts) or third-party directories. For documents, check their
474
+ current revision; a `file` source whose local directory no longer exists
475
+ cannot be refreshed, so report it instead of counting it as unchanged.
476
+ 2. **Separate large repositories.** A monorepo, a large repository, or one with
477
+ many relevant changed files (about 500 as a guide, or many new directories
478
+ whose features need assessing) gets its own batch. This is a judgment, not a
479
+ limit: a few new directories are assessed as uncited changes in their batch.
480
+ 3. **Group the rest by requirement.** Each requirement in `src/indexers.yaml`
481
+ whose sources changed forms one batch. A source shared by several
482
+ requirements moves once, in one batch: put it with the requirement whose
483
+ pages cite it most (`knowledge/structure.yaml` lists each page's citations),
484
+ and list it in that update once per
485
+ requirement that includes it. The update covers every page citing it
486
+ whatever its requirement, but advances only the listed requirements; one
487
+ left out stays pending and returns the same citations in another update. A
488
+ requirement whose sources bring only citation changes or one to three pages
489
+ joins the smallest batch instead of forming its own; mention it separately
490
+ in the batch report. Across
491
+ sources, split a batch above 30 pages by source: `module_refs` do not narrow
492
+ the candidate pages of one source, so a smaller batch needs fewer sources. A
493
+ single source above 30 pages uses `context run --deliver` to deliver checked
494
+ pages in groups.
495
+ 4. **Run one batch at a time.** Context keeps one active update. When a batch
496
+ starts, fetch and check out its repositories at the target commits with the
497
+ cited files' contents available (`--input` reads only what the checkout has;
498
+ keep the processed commit available for history), move only this batch's
499
+ registrations (`context source add repo` changing only `--ref`; register a
500
+ checkout kept outside the workspace through a workspace-relative alias such
501
+ as `.tmp/repo/<name>`, as `context source restore` does, not an absolute
502
+ path that only exists on this machine), recapture its documents and upgrade
503
+ its versioned file sources (see "Versioned external content and archived
504
+ collections"), then start one `context update --input` listing all of the batch's `repo:`, `lark:` and `file:` scopes, each
505
+ with its `requirement_ref`. Do not move later batches' registrations early.
506
+ 5. **`--pending` only for one repository-only batch.** `context update
507
+ --pending` covers repositories only and is a write: once it runs, the batch
508
+ cannot be split with `--input` without rolling back. Use it only when the
509
+ batch is every pending repository and has no documents.
510
+
511
+ The user or the workspace `AGENTS.md` may also ask for a corrections-only
512
+ update: correct what pages already say, add no features or topics the pages did
513
+ not cover, and avoid repeating the same detail across pages. In the
514
+ source-update decision, then leave `new_topics` empty, say in `scope_summary`
515
+ which uncited additions were left out, and put the rule into each revised
516
+ page's `instruction` so the writing step follows it.
517
+
518
+ ## Update without cloning: read repositories through Sourcegraph
519
+
520
+ When a registered repository is also registered on a Sourcegraph site, Context
521
+ can read it over HTTP instead of from a checkout. Updates (`context update
522
+ --input` and `--pending`), revisions, submission checks, `verify` and `status`
523
+ then need no clone. The result is byte for byte the same: Context reads the raw
524
+ blob at the registered commit, checks it against its Git object id, and compares
525
+ commits with a names-only diff, so citations, `changed_references`, evidence
526
+ and `uncited_changes` match a local checkout. Writing new pages and parsing code
527
+ still need a local checkout, and so do `context source restore` and `ensure`.
528
+
529
+ Choose the mode with `CONTEXT_SOURCE_MODE` or `--source-mode` (the option wins):
530
+
531
+ | Mode | Behavior |
532
+ | --- | --- |
533
+ | `local` (default) | Checkouts only, exactly as before; Context sends no Sourcegraph request even when a site or token is configured. |
534
+ | `remote` | Every repository source is read from Sourcegraph. A repository it cannot serve is skipped: the update leaves that scope out (its processed version does not move), lists it in `skipped_sources` with the reason, and continues with the other scopes. |
535
+ | `auto` | Sourcegraph first, per repository; one the site cannot serve uses its local checkout, restored as usual when missing. Without a token, auto mode asks for authorization like remote mode instead of falling back. |
536
+
537
+ Sourcegraph can serve a repository when the site declares the remote-read
538
+ operations, the registered `git.remote` names the same code host and repository
539
+ as the Sourcegraph registration, one registered path group contains the whole
540
+ `subpath`, and the registered commit is readable. Commands that read remotely
541
+ say so: `context update` and `verify --format json` return `source_access`
542
+ (each repository's `access`, site, repository and commit, or the reason it was
543
+ skipped or read locally), and in `status` each such source has `access: remote`
544
+ instead of checkout advice. `ready` keeps describing the local checkout.
545
+
546
+ **Authorization.** The Sourcegraph MCP server the Agent already uses is the only
547
+ configuration needed. When a command needs a token and has none, it returns a
548
+ `next_action` with `mcp_tool: authorize_cli`, once, at top level
549
+ (`source_authorization`); sources waiting for it are listed with
550
+ `reason_code: sourcegraph-authorization-required` and need no clone. Call that MCP tool once with
551
+ `client: "context"`, then run
552
+
553
+ ```bash
554
+ context source sourcegraph-auth --code <code> --host <host> --format json
555
+ ```
556
+
557
+ with the returned one-time `code` and `host` (the site's API root). The CLI
558
+ exchanges the code for a temporary read-only token, keeps it in
559
+ `.tmp/context-runtime/sourcegraph/token.json` (mode 600, never committed) and
560
+ reuses it for later commands in this workspace. Authorize again only when a
561
+ command asks for it again: after the token expired unused, was revoked, or
562
+ reached its maximum lifetime. Never print, copy or log the token. If
563
+ `authorize_cli` answers `TEMPORARY_TOKEN_LIMIT`, do not retry; run `context
564
+ source sourcegraph-auth --refused TEMPORARY_TOKEN_LIMIT --format json`, after
565
+ which remote mode skips repository sources and auto mode reads checkouts until
566
+ earlier temporary tokens expire or are revoked in the Sourcegraph user
567
+ settings. On a development machine or in CI, `SOURCEGRAPH_URL` and
568
+ `SOURCEGRAPH_API_TOKEN` take precedence and need no authorization; Sourcegraph
569
+ CLI login configuration is not read.
570
+
571
+ **Versions.** Only the registered commit decides whether a repository can be
572
+ read. When it is not readable yet, `status`, `verify`, revisions and an explicit
573
+ `update --input` report it and change nothing; `context update --pending` asks
574
+ Sourcegraph to prepare its content (when the site allows), waits a bounded time
575
+ and otherwise reports the job and the next step. Rate limits and full quotas
576
+ are reported, never retried in a loop. When only the processed commit is no
577
+ longer readable, the update still runs: history evidence is `unavailable` and
578
+ `uncited_changes` reports the comparison as unknown, as with a shallow checkout.
579
+ A site that cannot list directories still groups uncited changes but marks no
580
+ `new_directory`, and says so in the entry's `note`.
581
+
582
+ **Reading for writing.** For a source the CLI reads from Sourcegraph, size the
583
+ change with the Sourcegraph diff of the processed and registered commits, and
584
+ read or search code through the Sourcegraph MCP tools pinned to the registered
585
+ full commit; do not clone it for the update. A source read locally, a new page
586
+ and code parsing follow the checkout steps above. A read failure in remote mode
587
+ is never a citation change: `verify` reports those citations as not checked.
588
+
459
589
  ## Versioned external content and archived collections
460
590
 
461
591
  Published content that another team versions, such as a documentation
@@ -771,6 +901,13 @@ An unrelated queued page does not revoke an unchanged current page's review.
771
901
  If a page has already been applied, finish its close/build before changing its
772
902
  inputs. Only the final completed scope advances its processed baseline.
773
903
 
904
+ For a source update, the adjustment keeps the citation results the update
905
+ already computed; it does not read the sources again. When those results came
906
+ from the local checkout rather than the source (for example, every citation of
907
+ a repository reported `unavailable` before its checkout was restored or moved),
908
+ discard the unfinished update as described in "Adjust or roll back current work"
909
+ and start `context update` again.
910
+
774
911
  For several documents, `source import` also accepts a JSON/YAML array of the same
775
912
  single-document inputs. Its receipt reports each zero-based input index and
776
913
  success or error separately; a partial batch returns a nonzero exit code.
@@ -29,6 +29,12 @@ with an `instruction` when an addition or shared change affects it. When the
29
29
  pages you revise are written by other Agents, give each writer its page's
30
30
  `changed_references` entries and their evidence.
31
31
 
32
+ When the update's `source_access` marks a repository `remote`, its citations,
33
+ evidence and `uncited_changes` were read from Sourcegraph at the registered
34
+ commit and match a local checkout. Inspect its change with the Sourcegraph diff
35
+ and read its code through the Sourcegraph MCP tools at that commit instead of
36
+ cloning it; a new page from it still needs a local checkout.
37
+
32
38
  Follow each changed reference's `evidence_ref` into the JSON array in
33
39
  `reference_evidence_file` (`reference_evidence_count` entries) for
34
40
  digest-verified historical text and the current excerpt. Read only the entries
@@ -52,6 +58,14 @@ link targets or a restored table may change meaning even if the text looks simil
52
58
  If any mapping is missing or uncertain, use normal revision. A format-only
53
59
  decision does not authorize publication or suppress unrelated version changes.
54
60
 
61
+ Without a proposal, document evidence stays positional, so find the cited text
62
+ in the current snapshot (a distinctive line or its heading) before deciding. A
63
+ change that is only export formatting (merged bold markers, regenerated
64
+ descriptions in omitted-image placeholders) needs no change to the page body:
65
+ kept without an instruction, its citations stay at their previous locations and
66
+ are listed in `reference_warnings`; to clear them now, give the page an
67
+ instruction to re-cite the current text only.
68
+
55
69
  Also inspect additions and shared dependencies in the source change. Existing
56
70
  page references cannot discover every new topic. For repositories,
57
71
  `uncited_changes` lists the changed files no approved page cites, grouped by
@@ -66,6 +80,12 @@ Use an empty list only when existing pages cover the change or the additions
66
80
  are outside the confirmed purpose. New pages go through the same writing and
67
81
  review process as revisions; a new topic is not a no-change decision.
68
82
 
83
+ When the task or the workspace `AGENTS.md` asks for corrections only, leave
84
+ `new_topics` empty, say in `scope_summary` which additions were left out, and
85
+ write the rule into each revised page's `instruction`: correct what the page
86
+ already says, add no features or topics it did not cover, and avoid repeating
87
+ detail that other pages carry.
88
+
69
89
  A kept page's citations whose text only moved in the updated source are
70
90
  relocated when the update settles. When cited text changed or cannot be
71
91
  confirmed, the completion result lists it in `reference_warnings`; those