@c4a/context-cli 0.7.11 → 0.7.12

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
@@ -56219,7 +56219,9 @@ function projectPackageKnowledgeMarkdown(content3) {
56219
56219
  return content3;
56220
56220
  const body = content3.slice(match[0].length).replace(CONTEXT_METADATA_BLOCK_RE, "").replace(CONTEXT_SECTION_OPEN_RE, (opening) => {
56221
56221
  const key = /\bid="([a-zA-Z0-9_-]+)"/u.exec(opening)?.[1];
56222
- return key === undefined ? "" : `<a id="section-${encodeURIComponent(key)}"></a>
56222
+ return key === undefined ? "" : `
56223
+
56224
+ <a id="section-${encodeURIComponent(key)}"></a>
56223
56225
 
56224
56226
  `;
56225
56227
  }).replace(CONTEXT_SECTION_CLOSE_RE, `
@@ -63869,6 +63871,20 @@ var init_productionStage = __esm(() => {
63869
63871
  });
63870
63872
 
63871
63873
  // src/project/productionStageStore.ts
63874
+ var exports_productionStageStore = {};
63875
+ __export(exports_productionStageStore, {
63876
+ writeProductionProjection: () => writeProductionProjection,
63877
+ saveProductionStage: () => saveProductionStage,
63878
+ readProductionStageSnapshot: () => readProductionStageSnapshot,
63879
+ readProductionStage: () => readProductionStage,
63880
+ readProductionCapabilities: () => readProductionCapabilities,
63881
+ productionStageDirectory: () => productionStageDirectory,
63882
+ productionSourceFile: () => productionSourceFile,
63883
+ productionPlanMarkdown: () => productionPlanMarkdown,
63884
+ prepareNextProductionStage: () => prepareNextProductionStage,
63885
+ materializeProductionStage: () => materializeProductionStage,
63886
+ PRODUCTION_STAGES_ROOT: () => PRODUCTION_STAGES_ROOT
63887
+ });
63872
63888
  import { constants as constants4 } from "node:fs";
63873
63889
  import { readFile as readFile21, access as access2, stat as stat5 } from "node:fs/promises";
63874
63890
  import { join as join20 } from "node:path";
@@ -64800,9 +64816,9 @@ async function submitProductionPlan(input) {
64800
64816
  throw new TypeError("Pending investigation must name unique authorized stage scopes");
64801
64817
  }
64802
64818
  if (stage.gaps.some((gap) => !pendingScopes.includes(gap.scope)))
64803
- throw new TypeError("Keep unresolved material gaps in pending_scopes; declaring investigation complete does not resolve unavailable material");
64819
+ throw refreshRequired(stage.id, "Keep unresolved material gaps in pending_scopes; restore the source if unavailable, then prepare the current stage to refresh its material snapshot");
64804
64820
  if (plan.articles.some((article) => article.sources.some((scope2) => stage.gaps.some((gap) => gap.scope === scope2)))) {
64805
- throw new TypeError("An article requires unavailable material. Resolve that source gap before issuing it; independent source plans may proceed");
64821
+ throw refreshRequired(stage.id, "An article requires unavailable material in the captured stage. Restore the source if needed, then prepare the current stage; independent source plans may proceed");
64806
64822
  }
64807
64823
  for (const source2 of stage.scopes)
64808
64824
  if (!stage.gaps.some((gap) => gap.scope === source2.scope) && await productionSourceBaseline(input.projectRoot, source2.scope) !== source2.baseline) {
@@ -64916,7 +64932,7 @@ var init_productionPlanning = __esm(() => {
64916
64932
  }).strict()),
64917
64933
  indexer_usage: exports_external.array(productionIndexerUsageSchema).default([]),
64918
64934
  replaces: exports_external.array(text5).default([]),
64919
- pending_scopes: exports_external.array(text5).optional()
64935
+ pending_scopes: exports_external.array(text5).describe("Exact authorized source refs from the current stage scopes; no prose or module descriptions. Omit on amendments to preserve remaining investigation.").optional()
64920
64936
  }).strict();
64921
64937
  });
64922
64938
 
@@ -67022,7 +67038,7 @@ var init_indexerMainRunStore = __esm(() => {
67022
67038
  // src/project/productionDeliveryScope.ts
67023
67039
  import { readFile as readFile34 } from "node:fs/promises";
67024
67040
  import { join as join36, posix as posix2 } from "node:path";
67025
- async function productionDeliverableArticles(root) {
67041
+ async function productionDeliverableArticles(root, phase = "delivery") {
67026
67042
  return withProductionFeedback({ operation: "delivery-scope" }, async () => {
67027
67043
  const stage = await readProductionStage(root);
67028
67044
  if (!stage)
@@ -67045,6 +67061,8 @@ async function productionDeliverableArticles(root) {
67045
67061
  continue;
67046
67062
  selected.set(article.article_id, { path: article.path, article_id: article.article_id });
67047
67063
  }
67064
+ if (phase === "review")
67065
+ return [...selected.values()];
67048
67066
  for (const article of selected.values()) {
67049
67067
  const markdown = await readFile34(await safeProjectTarget(root, join36("knowledge", article.path)), "utf8");
67050
67068
  for (const link of markdownReaderLinks(markdown)) {
@@ -67143,6 +67161,9 @@ async function clearCompletedLifecycle(projectRoot) {
67143
67161
  if (production) {
67144
67162
  if (production.delivery)
67145
67163
  throw new TypeError("Partial delivery must retain the production stage and its unfinished tasks; finish the build or explicitly resume writing.");
67164
+ if (dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state !== "ended") {
67165
+ throw new TypeError("Production still has unfinished work; keep its files and follow context status --format json.");
67166
+ }
67146
67167
  const candidates = await readCandidateRecords(projectRoot);
67147
67168
  await assertRequiredArticlesReviewed(projectRoot, candidates);
67148
67169
  if (candidates.some((candidate) => candidate.status === "draft") || (await readProjectCloseStatus(projectRoot)).state !== "ready") {
@@ -67182,6 +67203,7 @@ async function clearCompletedLifecycle(projectRoot) {
67182
67203
  var COMPLETED_RUNTIME_PATHS;
67183
67204
  var init_lifecycleCleanup = __esm(() => {
67184
67205
  init_productionStageStore();
67206
+ init_productionStage();
67185
67207
  init_indexerRequiredArticleReview();
67186
67208
  init_candidateLedger();
67187
67209
  init_close();
@@ -67217,7 +67239,7 @@ async function requestProductionDelivery(root) {
67217
67239
  if (stage.delivery)
67218
67240
  return true;
67219
67241
  const candidates = await readCandidateRecords(root);
67220
- const formal = await productionDeliverableArticles(root);
67242
+ const formal = await productionDeliverableArticles(root, "review");
67221
67243
  const selected = stage.tasks.filter((task) => task.status === "accepted" && (candidates.some((candidate) => candidate.candidate_id === task.accepted?.receipt) || formal.some((article) => article.article_id === task.article_id && article.path === task.path)));
67222
67244
  if (!selected.length)
67223
67245
  throw new TypeError("No completed articles are available. Continue the current writing task before requesting delivery.");
@@ -67271,7 +67293,7 @@ var init_productionDelivery = __esm(() => {
67271
67293
 
67272
67294
  // src/project/indexerRequiredArticleReview.ts
67273
67295
  async function assertRequiredArticlesReviewed(root, candidates) {
67274
- if ((await readMaintenance(root)).active)
67296
+ if ((await readMaintenance(root)).active || await readApprovedRevision(root))
67275
67297
  return;
67276
67298
  const rejected = candidates.filter((candidate) => candidate.status === "rejected" && candidate.indexer_candidate);
67277
67299
  const production = await readProductionStage(root);
@@ -67342,6 +67364,7 @@ var init_indexerRequiredArticleReview = __esm(() => {
67342
67364
  init_productionSubmissionFiles();
67343
67365
  init_productionPlanning();
67344
67366
  init_maintenanceStorage();
67367
+ init_approvedRevision();
67345
67368
  });
67346
67369
 
67347
67370
  // src/project/partialDelivery.ts
@@ -70817,6 +70840,14 @@ var siteMarkdownConfig, siteThemeScript, siteThemeCss = `
70817
70840
  .context-home-section, .context-home-powered { width: min(calc(100% - 36px), 680px); margin-left: auto; margin-right: auto; }
70818
70841
  .context-home-resource-grid { grid-template-columns: 1fr; }
70819
70842
  }
70843
+ @media (max-width: 959px) {
70844
+ .VPNavBarMenu { display: none !important; }
70845
+ .VPNavBarHamburger { display: flex !important; }
70846
+ .VPNavScreen { display: block !important; }
70847
+ .VPNavBarSearch { flex: 0 0 48px !important; width: 48px; padding: 0 4px !important; }
70848
+ .VPNavBarSearch #local-search, .VPNavBarSearch .DocSearch-Button { width: 40px; }
70849
+ .VPNavBarSearch .DocSearch-Button-Placeholder, .VPNavBarSearch .DocSearch-Button-Keys { display: none !important; }
70850
+ }
70820
70851
  @media (prefers-reduced-motion: reduce) {
70821
70852
  .context-home-map-card, .context-home-resource-card { animation: none; }
70822
70853
  .context-home-map-card:hover, .context-home-resource-card:hover { transform: none; }
@@ -70832,7 +70863,7 @@ var siteMarkdownConfig, siteThemeScript, siteThemeCss = `
70832
70863
  .context-sources a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
70833
70864
  .context-sources a:hover { color: var(--vp-c-brand-1); border-color: currentColor; }
70834
70865
  .context-diagram { overflow: auto; padding: 20px; background: var(--vp-c-bg); }
70835
- .context-diagram svg { max-width: none !important; }
70866
+ .context-diagram svg { height: auto; }
70836
70867
  .context-diagram .node rect, .context-diagram .node polygon, .context-diagram .node circle,
70837
70868
  .context-diagram .flowchart-link { stroke-width: 1px !important; }
70838
70869
  .context-rendered:not(.context-show-source) pre, .context-rendered:not(.context-show-source) > .copy,
@@ -70889,7 +70920,7 @@ var init_packageSiteTheme = __esm(() => {
70889
70920
  if (!silent) { const token = state.push('context_anchor', '', 0); token.content = match[1]; }
70890
70921
  state.line = line + 1;
70891
70922
  return true;
70892
- });
70923
+ }, { alt: ['paragraph'] });
70893
70924
  md.renderer.rules.context_anchor = (tokens, index) => '<a id="' + md.utils.escapeHtml(tokens[index].content) + '"></a>\n';
70894
70925
  }
70895
70926
  `;
@@ -71474,7 +71505,7 @@ title: LLM Docs
71474
71505
  await rm11(temporary, { recursive: true, force: true });
71475
71506
  }
71476
71507
  }
71477
- var PACKAGE_SITE_VERSION = "vitepress-site-v41-home-safe-spacing", require2, encodePath = (path2) => path2.split("/").map(encodeURIComponent).join("/"), mdLabel = (value) => value.replace(/[\\[\]<>`*]/gu, "\\$&").replace(/[\r\n]/gu, " ");
71508
+ var PACKAGE_SITE_VERSION = "vitepress-site-v42-section-anchor-blocks", require2, encodePath = (path2) => path2.split("/").map(encodeURIComponent).join("/"), mdLabel = (value) => value.replace(/[\\[\]<>`*]/gu, "\\$&").replace(/[\r\n]/gu, " ");
71478
71509
  var init_packageSite2 = __esm(() => {
71479
71510
  init_packageOutputPaths();
71480
71511
  init_workspaceChangelog();
@@ -73188,10 +73219,11 @@ async function buildProjectPackagesInternal(projectRoot, options) {
73188
73219
  if (!production && (!maintenanceActive || (await readRevisionDelivery(projectRoot))?.partial) && !await readTaskRollback(projectRoot))
73189
73220
  await completeRevisionDelivery(projectRoot);
73190
73221
  const { finishApprovedRevision } = await Promise.resolve().then(() => (init_approvedRevision(), exports_approvedRevision));
73191
- await finishApprovedRevision(projectRoot);
73192
73222
  const { readApprovedRevision: readApprovedRevision2 } = await Promise.resolve().then(() => (init_approvedRevision(), exports_approvedRevision));
73223
+ const revisionInterruptedProduction = !!production && !!await readApprovedRevision2(projectRoot);
73224
+ await finishApprovedRevision(projectRoot);
73193
73225
  const { readKnowledgeUpdate } = await Promise.resolve().then(() => (init_knowledgeUpdate(), exports_knowledgeUpdate));
73194
- if (!production?.delivery && !maintenanceActive && !await readTaskRollback(projectRoot) && !await readApprovedRevision2(projectRoot) && !await readKnowledgeUpdate(projectRoot) && (await readProjectCloseStatus(projectRoot)).state === "ready") {
73226
+ if (!revisionInterruptedProduction && !production?.delivery && !maintenanceActive && !await readTaskRollback(projectRoot) && !await readApprovedRevision2(projectRoot) && !await readKnowledgeUpdate(projectRoot) && (await readProjectCloseStatus(projectRoot)).state === "ready") {
73195
73227
  const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
73196
73228
  await clearCompletedLifecycle2(projectRoot);
73197
73229
  }
@@ -74082,7 +74114,7 @@ __export(exports_approvedRevision, {
74082
74114
  assertApprovedRevisionBase: () => assertApprovedRevisionBase,
74083
74115
  APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
74084
74116
  });
74085
- import { readFile as readFile56, realpath as realpath6 } from "node:fs/promises";
74117
+ import { readFile as readFile56, realpath as realpath6, rm as rm15 } from "node:fs/promises";
74086
74118
  import { join as join66, relative as relative19, isAbsolute as isAbsolute12 } from "node:path";
74087
74119
  function requestDigest(input) {
74088
74120
  const scopes = input.processed_scopes?.filter((scope2) => input.target.source_refs.some((ref) => ref === scope2.source_ref || ref.startsWith(`${scope2.source_ref}#`) || ref.startsWith(`${scope2.source_ref}/`)));
@@ -74537,6 +74569,11 @@ async function advanceApprovedRevision(projectRoot, request) {
74537
74569
  const { finishMaintenanceRevision: finishMaintenanceRevision2 } = await Promise.resolve().then(() => (init_knowledgeMaintenance(), exports_knowledgeMaintenance));
74538
74570
  if (await finishMaintenanceRevision2(projectRoot))
74539
74571
  return;
74572
+ const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
74573
+ if (await readProductionStage2(projectRoot)) {
74574
+ await rm15(join66(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
74575
+ return;
74576
+ }
74540
74577
  const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
74541
74578
  await clearCompletedLifecycle2(projectRoot);
74542
74579
  }
@@ -80853,7 +80890,7 @@ var init_documentRun = __esm(() => {
80853
80890
  });
80854
80891
 
80855
80892
  // src/lib/atomicFileBatch.ts
80856
- import { lstat as lstat7, mkdir as mkdir25, mkdtemp as mkdtemp3, rename as rename6, rm as rm15, writeFile as writeFile19 } from "node:fs/promises";
80893
+ import { lstat as lstat7, mkdir as mkdir25, mkdtemp as mkdtemp3, rename as rename6, rm as rm16, writeFile as writeFile19 } from "node:fs/promises";
80857
80894
  import { dirname as dirname31, join as join70, resolve as resolve23 } from "node:path";
80858
80895
  async function existingFileKind(path2) {
80859
80896
  try {
@@ -80916,7 +80953,7 @@ async function applyAtomicFileBatch(input) {
80916
80953
  } catch (error) {
80917
80954
  const rollbackFailures = [];
80918
80955
  for (const path2 of installed.reverse()) {
80919
- await rm15(path2, { force: true }).catch((rollbackError) => {
80956
+ await rm16(path2, { force: true }).catch((rollbackError) => {
80920
80957
  rollbackFailures.push(`remove ${path2}: ${String(rollbackError)}`);
80921
80958
  });
80922
80959
  }
@@ -80933,7 +80970,7 @@ async function applyAtomicFileBatch(input) {
80933
80970
  throw error;
80934
80971
  } finally {
80935
80972
  if (!preserveTransaction)
80936
- await rm15(transactionDir, { recursive: true, force: true });
80973
+ await rm16(transactionDir, { recursive: true, force: true });
80937
80974
  }
80938
80975
  }
80939
80976
  var init_atomicFileBatch = () => {};
@@ -87039,7 +87076,7 @@ var init_larkResourceCommand = __esm(() => {
87039
87076
 
87040
87077
  // src/lib/larkResourceMaterialization.ts
87041
87078
  import { createHash as createHash26 } from "node:crypto";
87042
- import { mkdtemp as mkdtemp4, readFile as readFile67, readdir as readdir18, rm as rm18 } from "node:fs/promises";
87079
+ import { mkdtemp as mkdtemp4, readFile as readFile67, readdir as readdir18, rm as rm19 } from "node:fs/promises";
87043
87080
  import { extname as extname13, join as join88 } from "node:path";
87044
87081
  import { tmpdir } from "node:os";
87045
87082
  function countByKind(items, status) {
@@ -87172,7 +87209,7 @@ async function downloadedFile(input) {
87172
87209
  const bytes = await readFile67(join88(tempRoot, path3));
87173
87210
  return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes) };
87174
87211
  } finally {
87175
- await rm18(tempRoot, { recursive: true, force: true });
87212
+ await rm19(tempRoot, { recursive: true, force: true });
87176
87213
  }
87177
87214
  }
87178
87215
  function parseCsv(value) {
@@ -87304,7 +87341,7 @@ ${markdownTable2(parseCsv(csv))}
87304
87341
  [CSV snapshot](${sourceAssetTarget(path3)}) <!-- ${resource.locator} -->`
87305
87342
  };
87306
87343
  } finally {
87307
- await rm18(tempRoot, { recursive: true, force: true });
87344
+ await rm19(tempRoot, { recursive: true, force: true });
87308
87345
  }
87309
87346
  }
87310
87347
  function basePageRecords(value) {
@@ -87438,7 +87475,7 @@ async function whiteboardMaterialization(resource, runner2, identity) {
87438
87475
  ], { cwd: tempRoot });
87439
87476
  rawPayload = JSON.parse(await readFile67(join88(tempRoot, "raw.json"), "utf8"));
87440
87477
  } finally {
87441
- await rm18(tempRoot, { recursive: true, force: true });
87478
+ await rm19(tempRoot, { recursive: true, force: true });
87442
87479
  }
87443
87480
  const digest6 = resourceDigest(resource);
87444
87481
  const previewPath = `materialized/${resource.kind}/${digest6}${extensionFor2(preview.mediaType, preview.path)}`;
@@ -89374,6 +89411,7 @@ var init_taskLocalSourceAdjustment = __esm(() => {
89374
89411
  // src/project/taskSourceAdjustment.ts
89375
89412
  var exports_taskSourceAdjustment = {};
89376
89413
  __export(exports_taskSourceAdjustment, {
89414
+ taskSourceAdjustmentSchema: () => taskSourceAdjustmentSchema,
89377
89415
  adjustCurrentTaskSources: () => adjustCurrentTaskSources
89378
89416
  });
89379
89417
  async function adjustCurrentTaskSources(projectRoot, value) {
@@ -89428,7 +89466,7 @@ async function adjustCurrentTaskSources(projectRoot, value) {
89428
89466
  });
89429
89467
  });
89430
89468
  }
89431
- var schema2;
89469
+ var schema2, taskSourceAdjustmentSchema;
89432
89470
  var init_taskSourceAdjustment = __esm(() => {
89433
89471
  init_src2();
89434
89472
  init_knowledgeMap2();
@@ -89455,6 +89493,7 @@ var init_taskSourceAdjustment = __esm(() => {
89455
89493
  instruction: exports_external.string().trim().min(1),
89456
89494
  refresh: exports_external.boolean().optional()
89457
89495
  }).strict();
89496
+ taskSourceAdjustmentSchema = exports_external.union([schema2, exports_external.object({ knowledge_map: knowledgeMapUpdateSchema }).strict()]);
89458
89497
  });
89459
89498
 
89460
89499
  // src/project/managedDocumentImport.ts
@@ -89846,7 +89885,7 @@ init_cliFeedback();
89846
89885
  init_errors3();
89847
89886
  init_exitCode();
89848
89887
  import { createHash as createHash21 } from "node:crypto";
89849
- import { mkdir as mkdir26, readdir as readdir16, readFile as readFile60, rm as rm16, stat as stat10, writeFile as writeFile20 } from "node:fs/promises";
89888
+ import { mkdir as mkdir26, readdir as readdir16, readFile as readFile60, rm as rm17, stat as stat10, writeFile as writeFile20 } from "node:fs/promises";
89850
89889
  import { basename as basename8, dirname as dirname32, extname as extname12, join as join72, relative as relative22, resolve as resolve24 } from "node:path";
89851
89890
 
89852
89891
  // src/project/documentCaptureAssets.ts
@@ -98092,13 +98131,13 @@ async function removeEmptySnapshotDirs(root, dir = root) {
98092
98131
  return;
98093
98132
  const remaining = await readdir16(dir);
98094
98133
  if (remaining.length === 0) {
98095
- await rm16(dir, { recursive: true, force: true });
98134
+ await rm17(dir, { recursive: true, force: true });
98096
98135
  }
98097
98136
  }
98098
98137
  async function cleanupStaleSnapshotFiles(input) {
98099
98138
  for (const path2 of input.previousPaths) {
98100
98139
  if (!input.currentPaths.has(path2)) {
98101
- await rm16(join72(input.materializedAtAbsPath, path2), { force: true });
98140
+ await rm17(join72(input.materializedAtAbsPath, path2), { force: true });
98102
98141
  }
98103
98142
  }
98104
98143
  await removeEmptySnapshotDirs(input.materializedAtAbsPath);
@@ -98471,7 +98510,7 @@ init_cliFeedback();
98471
98510
  init_errors3();
98472
98511
  init_exitCode();
98473
98512
  import { existsSync as existsSync21 } from "node:fs";
98474
- import { lstat as lstat8, mkdir as mkdir27, readFile as readFile62, readlink, realpath as realpath7, rm as rm17, symlink as symlink2 } from "node:fs/promises";
98513
+ import { lstat as lstat8, mkdir as mkdir27, readFile as readFile62, readlink, realpath as realpath7, rm as rm18, symlink as symlink2 } from "node:fs/promises";
98475
98514
  import { execFile as execFile8 } from "node:child_process";
98476
98515
  import { promisify as promisify8 } from "node:util";
98477
98516
  import { dirname as dirname33, isAbsolute as isAbsolute14, join as join76, relative as relative23, resolve as resolve26 } from "node:path";
@@ -98825,7 +98864,7 @@ async function ensureMaterializedSymlink(input) {
98825
98864
  const currentAbs = resolve26(dirname33(linkPath), current2);
98826
98865
  if (currentAbs === input.localAbs)
98827
98866
  return true;
98828
- await rm17(linkPath);
98867
+ await rm18(linkPath);
98829
98868
  }
98830
98869
  const relTarget = relative23(dirname33(linkPath), input.localAbs) || ".";
98831
98870
  await symlink2(relTarget, linkPath);
@@ -106229,12 +106268,13 @@ async function readProductionReviewCandidates(projectRoot) {
106229
106268
  init_productionFeedback();
106230
106269
  async function loadReviewCandidateAuthority(projectRoot) {
106231
106270
  return withProductionFeedback({ operation: "review" }, async () => {
106232
- const production = await readProductionReviewCandidates(projectRoot);
106233
- if (production)
106234
- return new Map(production.candidates.map((candidate) => [candidate.candidate_id, candidate]));
106235
106271
  const revision = await readApprovedRevision(projectRoot);
106236
- if (!revision)
106272
+ if (!revision) {
106273
+ const production = await readProductionReviewCandidates(projectRoot);
106274
+ if (production)
106275
+ return new Map(production.candidates.map((candidate) => [candidate.candidate_id, candidate]));
106237
106276
  throw new TypeError("No current production or article revision is available for Review");
106277
+ }
106238
106278
  if (!revision.review_ready && !revision.candidate)
106239
106279
  throw new TypeError("Complete the current article revision before Review");
106240
106280
  const observed = await observeApprovedRevisionBatch(projectRoot, revision);
@@ -108117,9 +108157,19 @@ function registerDocumentRevisionCommand(program2) {
108117
108157
  process.stdout.write(`${JSON.stringify(await cancelKnowledgeMaintenance2(requireProjectRoot2(), id3, options.discardRevision))}
108118
108158
  `);
108119
108159
  });
108120
- task.command("adjust").description("Adjust current source/module inputs or reader organization while preserving unrelated work").requiredOption("--input <file>", "YAML/JSON source scopes with instruction, or knowledge_map; - for stdin").option("--format <format>", "output format: json", "json").action(async (options) => {
108121
- if (options.format !== "json")
108122
- throw new TypeError("--format must be json");
108160
+ task.command("adjust").description("Adjust current source/module inputs or reader organization while preserving unrelated work").option("--input <file>", "YAML/JSON source scopes with instruction, or knowledge_map; - for stdin").option("--schema", "show source adjustment or knowledge map input schema").option("--format <format>", "output format: json", "json").action(async (options) => {
108161
+ if (options.schema) {
108162
+ const { taskSourceAdjustmentSchema: taskSourceAdjustmentSchema2 } = await Promise.resolve().then(() => (init_taskSourceAdjustment(), exports_taskSourceAdjustment));
108163
+ const { zodToJsonSchema: zodToJsonSchema3 } = await Promise.resolve().then(() => (init_esm(), exports_esm));
108164
+ const { writeSchemaOutput: writeSchemaOutput2, schemaOutputFormat: schemaOutputFormat2 } = await Promise.resolve().then(() => (init_schemaOutput(), exports_schemaOutput));
108165
+ writeSchemaOutput2(zodToJsonSchema3(taskSourceAdjustmentSchema2), schemaOutputFormat2(options.format));
108166
+ return;
108167
+ }
108168
+ if (options.format !== "json" || !options.input)
108169
+ throw new ContextError(ExitCode.UserError, "Use --input <file> --format json, or --schema.", {
108170
+ category: ErrorCategory.UserInputInvalid,
108171
+ next_action: { command: "context task adjust --schema --format json" }
108172
+ });
108123
108173
  assertActionInputWorkspace(process.cwd(), options.input);
108124
108174
  const value = await readYamlOrJsonInput({
108125
108175
  path: options.input,
@@ -108792,7 +108842,7 @@ function registerProjectActionCommands(program2) {
108792
108842
  // src/commands/cleanClaudePluginCache.ts
108793
108843
  init_cliFeedback();
108794
108844
  import { existsSync as existsSync27 } from "node:fs";
108795
- import { readdir as readdir23, rm as rm19 } from "node:fs/promises";
108845
+ import { readdir as readdir23, rm as rm20 } from "node:fs/promises";
108796
108846
  import { homedir } from "node:os";
108797
108847
  import { join as join98 } from "node:path";
108798
108848
  var ORPHAN_MARKER = ".orphaned_at";
@@ -108830,17 +108880,17 @@ async function cleanClaudePluginCache(opts = {}) {
108830
108880
  if (opts.dryRun) {
108831
108881
  lines.push(` - would remove: ${label2}`);
108832
108882
  } else {
108833
- await rm19(verDir, { recursive: true, force: true });
108883
+ await rm20(verDir, { recursive: true, force: true });
108834
108884
  removed += 1;
108835
108885
  lines.push(` ✓ removed: ${label2}`);
108836
108886
  }
108837
108887
  }
108838
108888
  if (!opts.dryRun && await isEmptyDir(plDir)) {
108839
- await rm19(plDir, { recursive: true, force: true });
108889
+ await rm20(plDir, { recursive: true, force: true });
108840
108890
  }
108841
108891
  }
108842
108892
  if (!opts.dryRun && await isEmptyDir(mpDir)) {
108843
- await rm19(mpDir, { recursive: true, force: true });
108893
+ await rm20(mpDir, { recursive: true, force: true });
108844
108894
  }
108845
108895
  }
108846
108896
  if (scanned === 0) {
@@ -108929,7 +108979,7 @@ init_errors3();
108929
108979
  init_exitCode();
108930
108980
  import { execFile as execFile10 } from "node:child_process";
108931
108981
  import { existsSync as existsSync29 } from "node:fs";
108932
- import { lstat as lstat11, mkdir as mkdir33, readlink as readlink2, realpath as realpath8, rm as rm20, symlink as symlink3 } from "node:fs/promises";
108982
+ import { lstat as lstat11, mkdir as mkdir33, readlink as readlink2, realpath as realpath8, rm as rm21, symlink as symlink3 } from "node:fs/promises";
108933
108983
  import { basename as basename11, dirname as dirname42, isAbsolute as isAbsolute19, relative as relative26, resolve as resolve34 } from "node:path";
108934
108984
  import { promisify as promisify10 } from "node:util";
108935
108985
  init_writeLock();
@@ -109025,7 +109075,9 @@ async function repositoryRecoveryPlan(input) {
109025
109075
  if (input.source !== undefined && selected.length === 0) {
109026
109076
  throw new ContextError(ExitCode.WorkspaceStateError, `repo source is not registered: ${input.source}`, {
109027
109077
  category: ErrorCategory.SourceNotFound,
109028
- sourceId: input.source
109078
+ sourceId: input.source,
109079
+ registered_names: registry2.repos.map((source2) => source2.name),
109080
+ next_action: { command: "context source recovery-plan --format json" }
109029
109081
  });
109030
109082
  }
109031
109083
  const grouped = new Map;
@@ -109118,14 +109170,14 @@ async function cloneCheckout(input) {
109118
109170
  try {
109119
109171
  await execFileAsync6("git", cloneArgs, { encoding: "utf8", maxBuffer: 4 * 1024 * 1024 });
109120
109172
  } catch {
109121
- await rm20(target, { recursive: true, force: true });
109173
+ await rm21(target, { recursive: true, force: true });
109122
109174
  try {
109123
109175
  await execFileAsync6("git", ["clone", "--no-checkout", "--depth=1", input.remote, target], {
109124
109176
  encoding: "utf8",
109125
109177
  maxBuffer: 4 * 1024 * 1024
109126
109178
  });
109127
109179
  } catch (error) {
109128
- await rm20(target, { recursive: true, force: true });
109180
+ await rm21(target, { recursive: true, force: true });
109129
109181
  const detail = error !== null && typeof error === "object" && "stderr" in error ? String(error.stderr ?? "").trim() : error instanceof Error ? error.message : String(error);
109130
109182
  throw new ContextError(ExitCode.ExternalToolError, `cannot clone registered repository: ${input.remote}`, {
109131
109183
  category: ErrorCategory.ExternalToolFailed,
@@ -109150,7 +109202,7 @@ async function cloneCheckout(input) {
109150
109202
  await verifyCheckout({ checkout: target, remote: input.remote, ref: input.ref, subpaths: input.subpaths });
109151
109203
  return target;
109152
109204
  } catch (error) {
109153
- await rm20(target, { recursive: true, force: true });
109205
+ await rm21(target, { recursive: true, force: true });
109154
109206
  throw error;
109155
109207
  }
109156
109208
  }
@@ -109166,7 +109218,7 @@ async function bindLocalAlias(input) {
109166
109218
  const actualReal = await realpath8(actual).catch(() => null);
109167
109219
  if (actualReal !== null && actualReal === await realpath8(input.checkout))
109168
109220
  return;
109169
- await rm20(alias);
109221
+ await rm21(alias);
109170
109222
  } else {
109171
109223
  const actual = await realpath8(alias);
109172
109224
  if (actual === await realpath8(input.checkout))
@@ -109257,10 +109309,15 @@ async function restoreRepositorySources(input) {
109257
109309
  }
109258
109310
  if (registryChanged)
109259
109311
  await writeRepoRegistry(input.projectRoot, registry2);
109312
+ const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
109313
+ const stage = await readProductionStage2(input.projectRoot);
109314
+ const restoredScopes = new Set(restored.filter((result) => result.ready).flatMap((result) => result.sources.map((name3) => `repo:${name3}`)));
109315
+ const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
109316
+ const refresh = stage && !stage.delivery && stage.scopes.some((source2) => restoredScopes.has(source2.scope)) && !(await readMaintenance2(input.projectRoot)).active;
109260
109317
  return {
109261
109318
  schema: "context.repository-source-recovery-result.v1",
109262
109319
  restored,
109263
- next_action: { command: "context status --format json" }
109320
+ next_action: { command: refresh ? `context action prepare-current --revision ${stage.id} --format json` : "context status --format json" }
109264
109321
  };
109265
109322
  });
109266
109323
  }
@@ -110035,7 +110092,7 @@ init_writeLock();
110035
110092
  var import_yaml47 = __toESM(require_dist(), 1);
110036
110093
  import { existsSync as existsSync31 } from "node:fs";
110037
110094
  import { createHash as createHash31 } from "node:crypto";
110038
- import { readFile as readFile81, readdir as readdir24, rm as rm21 } from "node:fs/promises";
110095
+ import { readFile as readFile81, readdir as readdir24, rm as rm22 } from "node:fs/promises";
110039
110096
  import { isAbsolute as isAbsolute21, join as join103, relative as relative28, resolve as resolve36, sep as sep8 } from "node:path";
110040
110097
  function sourceIdentity(source2) {
110041
110098
  if (source2.kind === "source.collection")
@@ -110426,7 +110483,7 @@ async function pruneExtractRuntime(projectRoot, source2) {
110426
110483
  const parsed = JSON.parse(await readFile81(path3, "utf8"));
110427
110484
  const refs = Array.isArray(parsed.source_refs) ? parsed.source_refs : [];
110428
110485
  if (parsed.source === source2.name || refs.some((ref2) => typeof ref2 === "string" && stringReferencesSource(ref2, source2))) {
110429
- await rm21(path3, { force: true });
110486
+ await rm22(path3, { force: true });
110430
110487
  }
110431
110488
  } catch {}
110432
110489
  }
@@ -111555,7 +111612,7 @@ init_errors3();
111555
111612
  init_exitCode();
111556
111613
  import { execFile as execFile11 } from "node:child_process";
111557
111614
  import { existsSync as existsSync34 } from "node:fs";
111558
- import { cp as cp2, mkdir as mkdir34, readdir as readdir26, readFile as readFile87, rename as rename8, rm as rm22, writeFile as writeFile25 } from "node:fs/promises";
111615
+ import { cp as cp2, mkdir as mkdir34, readdir as readdir26, readFile as readFile87, rename as rename8, rm as rm23, writeFile as writeFile25 } from "node:fs/promises";
111559
111616
  import { homedir as homedir2 } from "node:os";
111560
111617
  import { dirname as dirname45, join as join106 } from "node:path";
111561
111618
  import { promisify as promisify11 } from "node:util";
@@ -111707,7 +111764,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
111707
111764
  status: dryRun ? "planned" : "ran"
111708
111765
  });
111709
111766
  if (!dryRun)
111710
- await Promise.all(versions.map((version3) => rm22(join106(cacheRoot, version3), { recursive: true, force: true })));
111767
+ await Promise.all(versions.map((version3) => rm23(join106(cacheRoot, version3), { recursive: true, force: true })));
111711
111768
  }
111712
111769
  async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
111713
111770
  await pruneCodexPluginCacheForName(PLUGIN_NAME, currentVersion, dryRun, steps);
@@ -111743,15 +111800,15 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
111743
111800
  continue;
111744
111801
  removed.push(`${marketplace.name}/${PLUGIN_NAME}/${version3.name}`);
111745
111802
  if (!dryRun) {
111746
- await rm22(versionDir, { recursive: true, force: true });
111803
+ await rm23(versionDir, { recursive: true, force: true });
111747
111804
  }
111748
111805
  }
111749
111806
  if (!dryRun && await isEmptyDir2(pluginDir)) {
111750
- await rm22(pluginDir, { recursive: true, force: true });
111807
+ await rm23(pluginDir, { recursive: true, force: true });
111751
111808
  }
111752
111809
  const marketplaceDir = join106(cacheRoot, marketplace.name);
111753
111810
  if (!dryRun && await isEmptyDir2(marketplaceDir)) {
111754
- await rm22(marketplaceDir, { recursive: true, force: true });
111811
+ await rm23(marketplaceDir, { recursive: true, force: true });
111755
111812
  }
111756
111813
  }
111757
111814
  if (removed.length > 0) {
@@ -111775,7 +111832,7 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
111775
111832
  continue;
111776
111833
  removed.push(`${MARKETPLACE_NAME}/${pluginName}`);
111777
111834
  if (!dryRun) {
111778
- await rm22(pluginDir, { recursive: true, force: true });
111835
+ await rm23(pluginDir, { recursive: true, force: true });
111779
111836
  }
111780
111837
  }
111781
111838
  if (removed.length > 0) {
@@ -111801,7 +111858,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
111801
111858
  status: dryRun ? "planned" : "ran"
111802
111859
  });
111803
111860
  if (!dryRun) {
111804
- await Promise.all(staleVersions.map((version3) => rm22(join106(pluginDir, version3), { recursive: true, force: true })));
111861
+ await Promise.all(staleVersions.map((version3) => rm23(join106(pluginDir, version3), { recursive: true, force: true })));
111805
111862
  }
111806
111863
  }
111807
111864
  function enableCodexPluginConfig(content3) {
@@ -111897,7 +111954,7 @@ async function replaceDirectoryFromSource(source2, target) {
111897
111954
  await mkdir34(dirname45(target), { recursive: true });
111898
111955
  const temporary = `${target}.tmp-${process.pid}-${Date.now()}`;
111899
111956
  const previous3 = `${target}.previous-${process.pid}-${Date.now()}`;
111900
- await rm22(temporary, { recursive: true, force: true });
111957
+ await rm23(temporary, { recursive: true, force: true });
111901
111958
  await cp2(source2, temporary, { recursive: true, force: true });
111902
111959
  const hadPrevious = existsSync34(target);
111903
111960
  try {
@@ -111905,9 +111962,9 @@ async function replaceDirectoryFromSource(source2, target) {
111905
111962
  await rename8(target, previous3);
111906
111963
  await rename8(temporary, target);
111907
111964
  if (hadPrevious)
111908
- await rm22(previous3, { recursive: true, force: true });
111965
+ await rm23(previous3, { recursive: true, force: true });
111909
111966
  } catch (error) {
111910
- await rm22(temporary, { recursive: true, force: true });
111967
+ await rm23(temporary, { recursive: true, force: true });
111911
111968
  if (hadPrevious && !existsSync34(target) && existsSync34(previous3))
111912
111969
  await rename8(previous3, target);
111913
111970
  throw error;