archctx 0.5.3 → 0.5.5

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "archcontext.practice-catalog-manifest/v1",
3
3
  "catalogVersion": "2026.06.0",
4
- "productVersion": "0.5.3",
4
+ "productVersion": "0.5.5",
5
5
  "generatedAt": "1970-01-01T00:00:00.000Z",
6
6
  "entries": [
7
7
  {
@@ -389,5 +389,5 @@
389
389
  "structurizr.dsl",
390
390
  "twelve-factor"
391
391
  ],
392
- "catalogDigest": "sha256:22e027f21c1c9d5d3891bf20e49aeba02e0a19ff40c08d7835d5832774123c46"
392
+ "catalogDigest": "sha256:bb1b5d5eacd5faab73dfa99d6c5368ce70bdd1c0b99b0d7f8e1f13478a433beb"
393
393
  }
package/bin/archctx.mjs CHANGED
@@ -1213,7 +1213,7 @@ function productVersionManifest() {
1213
1213
  }
1214
1214
  };
1215
1215
  }
1216
- var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.5.3", ARCHCONTEXT_PACKAGE_MANAGER = "bun@1.4.0", ARCHCONTEXT_NODE_RANGE = ">=22.22 <26", LOCAL_RUNTIME_RPC_SCHEMA_VERSION = "archcontext.runtime-rpc/v1", ARCHCONTEXT_SCHEMA_SET_VERSION = "2026-07-11.explorer-view-v2";
1216
+ var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.5.5", ARCHCONTEXT_PACKAGE_MANAGER = "bun@1.4.0", ARCHCONTEXT_NODE_RANGE = ">=22.22 <26", LOCAL_RUNTIME_RPC_SCHEMA_VERSION = "archcontext.runtime-rpc/v1", ARCHCONTEXT_SCHEMA_SET_VERSION = "2026-07-11.explorer-view-v2";
1217
1217
 
1218
1218
  // packages/contracts/src/refactor.ts
1219
1219
  function refactorProposalDigest(proposal) {
@@ -2552,7 +2552,7 @@ var init_src2 = __esm(() => {
2552
2552
 
2553
2553
  // node_modules/.bun/@colbymchenry+codegraph@1.5.0/node_modules/@colbymchenry/codegraph/npm-sdk.js
2554
2554
  var require_npm_sdk = __commonJS(function(exports, module) {
2555
- var __dirname = "/Users/ancienttwo/Projects/arch-context/node_modules/.bun/@colbymchenry+codegraph@1.5.0/node_modules/@colbymchenry/codegraph";
2555
+ var __dirname = "/private/tmp/archctx-book-freshness/node_modules/.bun/@colbymchenry+codegraph@1.5.0/node_modules/@colbymchenry/codegraph";
2556
2556
  var path = __require("path");
2557
2557
  var os = __require("os");
2558
2558
  var fs = __require("fs");
@@ -34403,9 +34403,16 @@ class ArchctxDaemon {
34403
34403
  });
34404
34404
  }
34405
34405
  if (command === "recommendations") {
34406
+ const gitScope = await this.architectureLedgerGitScope(root);
34406
34407
  return okEnvelope("book.recommendations", {
34407
34408
  ...queryArchitectureLedgerBookRecommendations({ events: replay.events, openOnly: input.openOnly, explain: input.explain, ...budget }),
34408
- freshness,
34409
+ freshness: {
34410
+ ...freshness,
34411
+ repository: gitScope.repository,
34412
+ worktree: gitScope.worktree,
34413
+ headSha: gitScope.worktree.headSha,
34414
+ worktreeDigest: gitScope.worktree.worktreeDigest
34415
+ },
34409
34416
  provenance
34410
34417
  });
34411
34418
  }
@@ -40191,7 +40198,7 @@ async function runCliUnchecked(command2 = "help", args2 = [], cwd, deps = {}) {
40191
40198
  case "status":
40192
40199
  return (await runtime()).runtimeStatus(cwd);
40193
40200
  case "projection":
40194
- return runProjectionProtocolCommand(args2, cwd, await runtime());
40201
+ return await runProjectionProtocolCommand(args2, cwd, await runtime());
40195
40202
  case "repo": {
40196
40203
  const subcommand = args2[0] ?? "list";
40197
40204
  if (subcommand === "add") {
@@ -40218,7 +40225,7 @@ async function runCliUnchecked(command2 = "help", args2 = [], cwd, deps = {}) {
40218
40225
  case "ledger":
40219
40226
  return runLedgerCommand(args2, cwd, runtime);
40220
40227
  case "book":
40221
- return runBookCommand(args2, cwd, await runtime());
40228
+ return await runBookCommand(args2, cwd, await runtime());
40222
40229
  case "recommendations":
40223
40230
  return runRecommendationsCommand(args2, cwd, await runtime());
40224
40231
  case "refactor":
@@ -41126,7 +41133,7 @@ function architectureProjectionProfile(args2) {
41126
41133
  }
41127
41134
  return profile;
41128
41135
  }
41129
- async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projection3, profile, generatedAt, acceptedChange) {
41136
+ async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projection3, profile, generatedAt, acceptedChange, protocolRequest) {
41130
41137
  if (profile !== REPO_HARNESS_PROJECTION_PROFILE) {
41131
41138
  return errorEnvelope("docs.adopt", "AC_SCHEMA_INVALID", `docs adopt requires --profile ${REPO_HARNESS_PROJECTION_PROFILE}`);
41132
41139
  }
@@ -41165,15 +41172,20 @@ async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projectio
41165
41172
  return errorEnvelope("docs.adopt", "AC_PRECONDITION_FAILED", "projection-adoption-preview-mismatch");
41166
41173
  }
41167
41174
  const simulatedByPath = new Map(projection3.loaded.existingFiles.map((file) => [file.path, file]));
41168
- for (const file of [...projection3.plan.files, ...adoption2.files])
41175
+ for (const file of [...projection3.files, ...adoption2.files])
41169
41176
  simulatedByPath.set(file.path, file);
41170
- const canonicalFirst = buildArchitectureDocsProjection(root, generatedAt, profile, [...simulatedByPath.values()], acceptedChange);
41177
+ const canonicalFirst = buildArchitectureDocsProjection(root, generatedAt, profile, [...simulatedByPath.values()]);
41171
41178
  const canonicalExistingByPath = new Map(simulatedByPath);
41172
41179
  for (const file of canonicalFirst.files)
41173
41180
  canonicalExistingByPath.set(file.path, file);
41174
- const canonical = buildArchitectureDocsProjection(root, generatedAt, profile, [...canonicalExistingByPath.values()], acceptedChange);
41181
+ const canonical = buildArchitectureDocsProjection(root, generatedAt, profile, [...canonicalExistingByPath.values()]);
41175
41182
  if (!canonical.plan.drift.ok || canonical.plan.rejected.length > 0 || canonical.plan.projectionDigest !== canonicalFirst.plan.projectionDigest) {
41176
- return errorEnvelope("docs.adopt", "AC_PRECONDITION_FAILED", "projection-adoption-fixed-point-unproven");
41183
+ const reasons = canonical.plan.rejected.map((entry) => entry.reasonCode).join(",") || "none";
41184
+ const drift = canonical.plan.drift.diffs.map((entry) => `${entry.path}:${entry.reasonCode}`).join(",") || "none";
41185
+ return errorEnvelope("docs.adopt", "AC_PRECONDITION_FAILED", `projection-adoption-fixed-point-unproven: drift=${drift}; rejected=${reasons}; digest=${canonical.plan.projectionDigest === canonicalFirst.plan.projectionDigest ? "stable" : "changed"}`);
41186
+ }
41187
+ if (protocolRequest) {
41188
+ return applyProjectionProtocolFixedPoint(protocolRequest, projection3, canonical, adoption2.changeSetId, root, daemon);
41177
41189
  }
41178
41190
  const filesByPath = new Map;
41179
41191
  for (const file of canonical.files)
@@ -41197,6 +41209,93 @@ async function runArchitectureDocsAdoptionCommand(args2, root, daemon, projectio
41197
41209
  apply: applied.data
41198
41210
  });
41199
41211
  }
41212
+ async function applyProjectionProtocolFixedPoint(request, input, fixedPoint, changeSetId, root, daemon) {
41213
+ const committedFiles = projectionProtocolFilesForExpectedOutput(root, fixedPoint);
41214
+ const committedSignals = request.acceptedChange ? input.plan.refreshSignals.map((signal) => ({
41215
+ ...signal,
41216
+ resultingDigests: fixedPoint.plan.architectureDigests
41217
+ })) : fixedPoint.plan.refreshSignals;
41218
+ const applyIdentity = request.acceptedChange ? createProjectionApplyIdentity({
41219
+ repositoryId: request.expected.repositoryId,
41220
+ workspaceId: request.expected.workspaceId,
41221
+ acceptedChange: request.acceptedChange,
41222
+ changeSetId,
41223
+ idempotencyKey: `idem_${changeSetId}`,
41224
+ files: committedFiles,
41225
+ refreshSignals: committedSignals
41226
+ }) : undefined;
41227
+ const appliedResult = projectionProtocolResult(request, input, "applied", fixedPoint, applyIdentity, {
41228
+ files: committedFiles,
41229
+ refreshSignals: committedSignals
41230
+ });
41231
+ let recoveryBinding;
41232
+ if (applyIdentity) {
41233
+ try {
41234
+ recoveryBinding = createProjectionApplyRecoveryBinding(request, fixedPoint, appliedResult);
41235
+ } catch (error) {
41236
+ return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
41237
+ }
41238
+ }
41239
+ const applyReceipt = applyIdentity ? {
41240
+ schemaVersion: "archcontext.projection-apply-receipt/v1",
41241
+ identity: applyIdentity,
41242
+ result: appliedResult,
41243
+ recovery: recoveryBinding
41244
+ } : undefined;
41245
+ const planned = await daemon.planUpdate(root, {
41246
+ id: changeSetId,
41247
+ reason: { taskSessionId: request.requestId },
41248
+ operations: [architectureDocsRenderProjectionOperation(root, fixedPoint.files)],
41249
+ worktreeDigestPrecondition: {
41250
+ profile: "architecture-documentation-projection",
41251
+ expectedDigest: request.expected.worktreeDigest
41252
+ }
41253
+ });
41254
+ if (!planned.ok)
41255
+ return planned;
41256
+ const applied = await daemon.applyUpdate(root, {
41257
+ id: changeSetId,
41258
+ approved: true,
41259
+ expectedWorktreeDigest: request.expected.worktreeDigest,
41260
+ worktreeDigestProfile: "architecture-documentation-projection",
41261
+ ...applyReceipt ? { projectionApplyReceipt: applyReceipt } : {}
41262
+ });
41263
+ if (!applied.ok)
41264
+ return applied;
41265
+ if (!applyReceipt)
41266
+ return projectionProtocolResultEnvelope(appliedResult);
41267
+ let postApplyMatches = false;
41268
+ try {
41269
+ postApplyMatches = architectureDocumentationProjectionWorktreeDigest(root, loadNativeModelFromArchContext(root)) === request.expected.worktreeDigest;
41270
+ if (!postApplyMatches) {
41271
+ process.stderr.write(`warning: projection post-apply worktree digest diverged from the accepted snapshot; refresh delivery deferred to reconcile
41272
+ `);
41273
+ }
41274
+ } catch (error) {
41275
+ process.stderr.write(`warning: projection post-apply verification failed: ${error instanceof Error ? error.message : String(error)}
41276
+ `);
41277
+ postApplyMatches = false;
41278
+ }
41279
+ if (!postApplyMatches) {
41280
+ return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied-reconcile-required", []));
41281
+ }
41282
+ const delivery = await daemon.recoverProjectionApply(root, {
41283
+ schemaVersion: PROJECTION_APPLY_RECOVERY_INTENT_SCHEMA_VERSION,
41284
+ requestId: request.requestId,
41285
+ profile: REPO_HARNESS_PROJECTION_PROFILE,
41286
+ receipt: {
41287
+ lookupKey: applyReceipt.identity.lookupKey,
41288
+ applyId: applyReceipt.identity.applyId
41289
+ }
41290
+ });
41291
+ if (!delivery.ok)
41292
+ return delivery;
41293
+ const delivered = delivery.data;
41294
+ if (delivered.found !== true || delivered.refreshSignalsDelivered !== true) {
41295
+ return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", "committed projection apply receipt was not available for first delivery");
41296
+ }
41297
+ return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied", delivered.receipt.result.refreshSignals, request.requestId));
41298
+ }
41200
41299
  async function runProjectionProtocolCommand(args2, cwd, daemon) {
41201
41300
  const subcommand = args2[0] ?? "run";
41202
41301
  if (subcommand === "recover")
@@ -41254,19 +41353,10 @@ async function runProjectionProtocolCommand(args2, cwd, daemon) {
41254
41353
  expectedWorktreeDigest,
41255
41354
  "--task-session-id",
41256
41355
  request.requestId
41257
- ], root, daemon, projection3, REPO_HARNESS_PROJECTION_PROFILE, generatedAt, request.acceptedChange);
41356
+ ], root, daemon, projection3, REPO_HARNESS_PROJECTION_PROFILE, generatedAt, request.acceptedChange, request);
41258
41357
  if (!adopted.ok)
41259
41358
  return adopted;
41260
- let output;
41261
- try {
41262
- output = buildArchitectureDocsProjection(root, generatedAt, REPO_HARNESS_PROJECTION_PROFILE, undefined, request.acceptedChange);
41263
- if (!output.plan.drift.ok || output.plan.rejected.length > 0) {
41264
- return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", "projection adoption did not reach the architecture-docs fixed point");
41265
- }
41266
- } catch (error) {
41267
- return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
41268
- }
41269
- return projectionProtocolEnvelope(request, projection3, "applied", output);
41359
+ return adopted;
41270
41360
  }
41271
41361
  if (request.mode === "apply" && !projection3.plan.drift.ok) {
41272
41362
  const changeSetId = `changeset.docs-projection-${projection3.plan.projectionDigest.replace(/^sha256:/, "").slice(0, 16)}`;
@@ -41279,91 +41369,7 @@ async function runProjectionProtocolCommand(args2, cwd, daemon) {
41279
41369
  } catch (error) {
41280
41370
  return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
41281
41371
  }
41282
- const committedFiles = projectionProtocolFilesForExpectedOutput(root, fixedPointProjection);
41283
- const committedSignals = request.acceptedChange ? projection3.plan.refreshSignals.map((signal) => ({
41284
- ...signal,
41285
- resultingDigests: fixedPointProjection.plan.architectureDigests
41286
- })) : fixedPointProjection.plan.refreshSignals;
41287
- const applyIdentity = request.acceptedChange ? createProjectionApplyIdentity({
41288
- repositoryId: request.expected.repositoryId,
41289
- workspaceId: request.expected.workspaceId,
41290
- acceptedChange: request.acceptedChange,
41291
- changeSetId,
41292
- idempotencyKey: `idem_${changeSetId}`,
41293
- files: committedFiles,
41294
- refreshSignals: committedSignals
41295
- }) : undefined;
41296
- const appliedResult = projectionProtocolResult(request, projection3, "applied", fixedPointProjection, applyIdentity, {
41297
- files: committedFiles,
41298
- refreshSignals: committedSignals
41299
- });
41300
- let recoveryBinding;
41301
- if (applyIdentity) {
41302
- try {
41303
- recoveryBinding = createProjectionApplyRecoveryBinding(request, fixedPointProjection, appliedResult);
41304
- } catch (error) {
41305
- return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", error instanceof Error ? error.message : String(error));
41306
- }
41307
- }
41308
- const applyReceipt = applyIdentity ? {
41309
- schemaVersion: "archcontext.projection-apply-receipt/v1",
41310
- identity: applyIdentity,
41311
- result: appliedResult,
41312
- recovery: recoveryBinding
41313
- } : undefined;
41314
- const planned = await daemon.planUpdate(root, {
41315
- id: changeSetId,
41316
- reason: { taskSessionId: request.requestId },
41317
- operations: [architectureDocsRenderProjectionOperation(root, fixedPointProjection.files)],
41318
- worktreeDigestPrecondition: {
41319
- profile: "architecture-documentation-projection",
41320
- expectedDigest: request.expected.worktreeDigest
41321
- }
41322
- });
41323
- if (!planned.ok)
41324
- return planned;
41325
- const applied = await daemon.applyUpdate(root, {
41326
- id: changeSetId,
41327
- approved: true,
41328
- expectedWorktreeDigest: request.expected.worktreeDigest,
41329
- worktreeDigestProfile: "architecture-documentation-projection",
41330
- ...applyReceipt ? { projectionApplyReceipt: applyReceipt } : {}
41331
- });
41332
- if (!applied.ok)
41333
- return applied;
41334
- if (!applyReceipt)
41335
- return projectionProtocolResultEnvelope(appliedResult);
41336
- let postApplyMatches = false;
41337
- try {
41338
- postApplyMatches = architectureDocumentationProjectionWorktreeDigest(root, loadNativeModelFromArchContext(root)) === request.expected.worktreeDigest;
41339
- if (!postApplyMatches) {
41340
- process.stderr.write(`warning: projection post-apply worktree digest diverged from the accepted snapshot; refresh delivery deferred to reconcile
41341
- `);
41342
- }
41343
- } catch (error) {
41344
- process.stderr.write(`warning: projection post-apply verification failed: ${error instanceof Error ? error.message : String(error)}
41345
- `);
41346
- postApplyMatches = false;
41347
- }
41348
- if (!postApplyMatches) {
41349
- return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied-reconcile-required", []));
41350
- }
41351
- const delivery = await daemon.recoverProjectionApply(root, {
41352
- schemaVersion: PROJECTION_APPLY_RECOVERY_INTENT_SCHEMA_VERSION,
41353
- requestId: request.requestId,
41354
- profile: REPO_HARNESS_PROJECTION_PROFILE,
41355
- receipt: {
41356
- lookupKey: applyReceipt.identity.lookupKey,
41357
- applyId: applyReceipt.identity.applyId
41358
- }
41359
- });
41360
- if (!delivery.ok)
41361
- return delivery;
41362
- const delivered = delivery.data;
41363
- if (delivered.found !== true || delivered.refreshSignalsDelivered !== true) {
41364
- return errorEnvelope("projection.run", "AC_PRECONDITION_FAILED", "committed projection apply receipt was not available for first delivery");
41365
- }
41366
- return projectionProtocolResultEnvelope(projectionResultDelivery(appliedResult, "applied", delivered.receipt.result.refreshSignals, request.requestId));
41372
+ return applyProjectionProtocolFixedPoint(request, projection3, fixedPointProjection, changeSetId, root, daemon);
41367
41373
  }
41368
41374
  const status = projection3.plan.drift.ok ? "noop" : "planned";
41369
41375
  return projectionProtocolEnvelope(request, projection3, status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archctx",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Local architecture context CLI for agentic coding workflows.",
5
5
  "private": false,
6
6
  "type": "module",