@c4a/context-cli 0.7.88 → 0.7.91

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.
package/cli.js CHANGED
@@ -92510,6 +92510,7 @@ async function beginKnowledgeUpdate(projectRoot, value, options = {}) {
92510
92510
  source_refs: [...new Set(article.sections.flatMap((section) => section.references.map((reference2) => reference2.source_ref)))]
92511
92511
  };
92512
92512
  }));
92513
+ const scopePages = options.pending ? cited.map((article) => article.path).filter((path2) => !changedPaths.has(path2)) : [];
92513
92514
  const registry2 = await readProductionRequirements(projectRoot);
92514
92515
  const repoReferences = articles.flatMap((article) => article.sections.flatMap((section) => section.references.filter((ref2) => ref2.source_ref.startsWith("repo-content:") && scopes.some((scope2) => repoContentScopeMatches(scope2.source_ref, ref2.source_ref))).map((reference2) => ({ article: article.path, section: section.id, reference: reference2 }))));
92515
92516
  const impact = repoReferences.length ? await repoContentImpactReader(projectRoot) : undefined;
@@ -92525,6 +92526,7 @@ async function beginKnowledgeUpdate(projectRoot, value, options = {}) {
92525
92526
  requirements,
92526
92527
  candidates,
92527
92528
  ...repoContent === undefined ? {} : { repo_content: repoContent },
92529
+ ...scopePages.length === 0 ? {} : { scope_pages: scopePages },
92528
92530
  ...inspected.unresolved.length === 0 ? {} : { changed_references: inspected.unresolved.map((item) => ({
92529
92531
  path: item.path,
92530
92532
  section_id: item.section_id,
@@ -92606,12 +92608,13 @@ async function completeKnowledgeUpdate(input) {
92606
92608
  throw new SubmissionInputError(`Update page paths must be unique; repeated: ${repeated.join(", ")}`, ["decisions"]);
92607
92609
  const candidates = new Set(request.candidates.map((candidate) => candidate.path));
92608
92610
  const missing2 = [...candidates].filter((path2) => !input.decisions.some((decision) => decision.path === path2));
92609
- const unknown2 = input.decisions.map((decision) => decision.path).filter((path2) => !candidates.has(path2));
92611
+ const scopePages = new Set(request.scope_pages ?? []);
92612
+ const unknown2 = input.decisions.map((decision) => decision.path).filter((path2) => !candidates.has(path2) && !scopePages.has(path2));
92610
92613
  if (missing2.length || unknown2.length) {
92611
92614
  throw new SubmissionInputError([
92612
92615
  "Decide each source-bound candidate once; an omitted page is not a no-change decision. List a candidate with only its path to keep it unchanged.",
92613
92616
  ...missing2.length ? [`Missing: ${missing2.join(", ")}.`] : [],
92614
- ...unknown2.length ? [`Not candidates (use new_topics for new pages): ${unknown2.join(", ")}.`] : []
92617
+ ...unknown2.length ? [`Not candidates or scope pages (use new_topics for new pages): ${unknown2.join(", ")}.`] : []
92615
92618
  ].join(" "), ["decisions"]);
92616
92619
  }
92617
92620
  await captureProcessedScopes(input.projectRoot, request.scopes);
@@ -92709,6 +92712,7 @@ var init_knowledgeUpdate = __esm(() => {
92709
92712
  previous_versions: exports_external.array(exports_external.string().nullable()),
92710
92713
  changes: exports_external.string().optional(),
92711
92714
  repo_content: exports_external.unknown().optional(),
92715
+ scope_pages: exports_external.array(exports_external.string()).optional(),
92712
92716
  changed_references: exports_external.array(exports_external.object({
92713
92717
  path: exports_external.string(),
92714
92718
  section_id: exports_external.string(),
@@ -111117,6 +111121,8 @@ const words = {
111117
111121
  previous: ['查看旧文本', 'Previous text'], removed: ['移除或替换的旧内容', 'Removed or replaced content'],
111118
111122
  removedNav: ['移除的目录条目', 'Removed navigation entries'], unplaced: ['待落位文章', 'Unplaced articles'],
111119
111123
  sources: ['来源引用', 'Sources'], feedbackTag: ['修订', 'Notes'],
111124
+ previousPage: ['上一页 −', 'Previous −'], nextPage: ['下一页 +', 'Next +'],
111125
+ previousHint: ['上一页(快捷键 -)', 'Previous article (key -)'], nextHint: ['下一页(快捷键 +)', 'Next article (key +)'],
111120
111126
  };
111121
111127
  let language = 'zh';
111122
111128
  const t = key => words[key]?.[language === 'zh' ? 0 : 1] || key;
@@ -111200,6 +111206,58 @@ function rootFor(pageId) {
111200
111206
  return node?.key || null;
111201
111207
  }
111202
111208
 
111209
+ /** Candidate articles in navigation order, then any the navigation does not place. */
111210
+ function readingOrder() {
111211
+ const ordered = [];
111212
+ const seen = new Set();
111213
+ function walk(parent, visited = new Set()) {
111214
+ for (const node of DATA.nodes.filter(item => (item.parent || null) === parent).sort((a, b) => a.order - b.order)) {
111215
+ if (visited.has(node.key)) continue;
111216
+ visited.add(node.key);
111217
+ const page = pagesById.get(node.page);
111218
+ if (page?.candidate_id && !seen.has(page.id)) { seen.add(page.id); ordered.push(page); }
111219
+ walk(node.key, visited);
111220
+ }
111221
+ }
111222
+ walk(null);
111223
+ return [...ordered, ...candidates.filter(page => !seen.has(page.id))];
111224
+ }
111225
+
111226
+ /** Home and the revision list come before the first article; previous from the first article returns home. */
111227
+ function pagerTargets() {
111228
+ const order = readingOrder();
111229
+ const index = view === 'article' ? order.findIndex(page => page.id === selected) : -1;
111230
+ return { previous: index >= 0 ? (index > 0 ? order[index - 1].id : 'home') : null, next: order[index + 1]?.id || null };
111231
+ }
111232
+
111233
+ function stepPage(direction) {
111234
+ const target = pagerTargets()[direction < 0 ? 'previous' : 'next'];
111235
+ if (target === 'home') showHome();
111236
+ else if (target) showPage(target);
111237
+ }
111238
+
111239
+ function updatePager() {
111240
+ const targets = pagerTargets();
111241
+ $('previous-page').disabled = !targets.previous;
111242
+ $('next-page').disabled = !targets.next;
111243
+ for (const [id, label, hint] of [['previous-page', 'previousPage', 'previousHint'], ['next-page', 'nextPage', 'nextHint']]) {
111244
+ $(id).textContent = t(label);
111245
+ $(id).title = t(hint);
111246
+ }
111247
+ }
111248
+
111249
+ function pagerKey(event) {
111250
+ if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.isComposing) return false;
111251
+ const target = event.target;
111252
+ if (target?.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target?.tagName)) return false;
111253
+ if ($('copy-dialog').open) return false;
111254
+ const direction = ['+', '='].includes(event.key) || event.code === 'NumpadAdd' ? 1 : ['-', '_'].includes(event.key) || event.code === 'NumpadSubtract' ? -1 : 0;
111255
+ if (!direction) return false;
111256
+ event.preventDefault?.();
111257
+ stepPage(direction);
111258
+ return true;
111259
+ }
111260
+
111203
111261
  function updateCounts() {
111204
111262
  const revised = revisedPages().length;
111205
111263
  $('counts').innerHTML = \`<span>\${countText(t('read'), read.size)}</span><span class="separator">/</span>\`
@@ -111289,6 +111347,7 @@ function render() {
111289
111347
  $('article').classList.toggle('review-new-page', view === 'article' && page?.change === 'new');
111290
111348
  renderNav();
111291
111349
  updateCounts();
111350
+ updatePager();
111292
111351
  if (view === 'home') renderHome();
111293
111352
  else if (view === 'revisions') renderRevisions();
111294
111353
  else if (page) {
@@ -111417,7 +111476,11 @@ $('clear-note').onclick = () => {
111417
111476
  $('revision-note').dispatchEvent(new Event('input', { bubbles: true }));
111418
111477
  $('revision-note').focus();
111419
111478
  };
111420
- $('home').onclick = () => { selected = null; active = null; view = 'home'; history.replaceState(null, '', location.pathname + location.search); render(); window.scrollTo(0, 0); };
111479
+ function showHome() { selected = null; active = null; view = 'home'; history.replaceState(null, '', location.pathname + location.search); render(); window.scrollTo(0, 0); }
111480
+ $('home').onclick = showHome;
111481
+ $('previous-page').onclick = () => stepPage(-1);
111482
+ $('next-page').onclick = () => stepPage(1);
111483
+ document.addEventListener('keydown', pagerKey);
111421
111484
  $('theme').onclick = () => { document.body.classList.toggle('dark'); persist(); render(); };
111422
111485
  $('language').onclick = () => { language = language === 'zh' ? 'en' : 'zh'; persist(); render(); };
111423
111486
  $('copy-notes').onclick = copyNotes;
@@ -111465,6 +111528,7 @@ header nav { scrollbar-width: none; }
111465
111528
  header nav::-webkit-scrollbar { display: none; }
111466
111529
  header nav button { padding: 0 11px; }
111467
111530
  .tools { flex-shrink: 0; gap: 16px; }
111531
+ .pager { display: flex; flex-shrink: 0; gap: 6px; }
111468
111532
  .reading-progress { min-width: 225px; }
111469
111533
  #counts { display: flex; align-items: center; justify-content: space-between; gap: 8px; white-space: nowrap; font-size: 12px; color: var(--muted); }
111470
111534
  #counts b { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
@@ -111565,6 +111629,7 @@ function renderReviewHtml(model, diagramScript) {
111565
111629
  <div id="counts" aria-label="阅读进度"></div>
111566
111630
  <div class="read-track" role="progressbar" aria-label="本轮阅读进度" aria-valuemin="0" aria-valuenow="0"><span id="read-fill"></span></div>
111567
111631
  </div>
111632
+ <div class="pager" role="group" aria-label="文章翻页"><button class="btn" id="previous-page" title="上一页(快捷键 -)" disabled>上一页 −</button><button class="btn" id="next-page" title="下一页(快捷键 +)">下一页 +</button></div>
111568
111633
  <button class="btn primary" id="copy-notes">复制修订意见</button>
111569
111634
  </div>
111570
111635
  <button class="btn" id="theme" aria-label="切换深色主题" title="切换深色主题">◐</button>