archctx 0.10.0 → 0.11.1
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/assets/catalog.yaml +2 -2
- package/bin/archctx.mjs +885 -438
- package/package.json +1 -1
package/bin/archctx.mjs
CHANGED
|
@@ -173,6 +173,22 @@ var init_architecture = __esm(() => {
|
|
|
173
173
|
];
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
+
// packages/contracts/src/architecture-history.ts
|
|
177
|
+
function decodeArchitectureHistoryState(value) {
|
|
178
|
+
if (!object(value))
|
|
179
|
+
return;
|
|
180
|
+
if (value.nodes === null && value.edges === null && value.structure === null && error(value.error))
|
|
181
|
+
return value;
|
|
182
|
+
if (value.error === undefined && list(value.nodes, node) && list(value.edges, edge) && list(value.structure, structure))
|
|
183
|
+
return value;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
var ARCHITECTURE_HISTORY_SCHEMA_VERSION = "archcontext.architecture-history/v1", ARCHITECTURE_HISTORY_MERMAID_SCHEMA_VERSION = "archcontext.architecture-history-mermaid/v1", ARCHITECTURE_HISTORY_DERIVATION_VERSION = "v3", object = (v) => typeof v === "object" && v !== null && !Array.isArray(v), string = (v) => typeof v === "string", edge = (v) => object(v) && string(v.source) && string(v.target), kind = (v) => v === "capability" || v === "module" || v === "component", item = (v) => object(v) && string(v.id) && kind(v.kind) && (v.capability === null || string(v.capability)) && (v.kind !== "capability" || v.capability === v.id), structure = (v) => item(v) && object(v) && string(v.name), node = (v) => object(v) && string(v.id) && string(v.name) && (v.domain === null || string(v.domain)), errors, error = (v) => object(v) && string(v.code) && errors.includes(v.code) && (v.path === undefined || string(v.path) && isRepoRelativePosixPath(v.path)), list = (v, check) => Array.isArray(v) && v.every(check);
|
|
187
|
+
var init_architecture_history = __esm(() => {
|
|
188
|
+
init_schema();
|
|
189
|
+
errors = ["history-model-layout-unsupported", "history-model-missing", "history-model-invalid", "history-model-too-large"];
|
|
190
|
+
});
|
|
191
|
+
|
|
176
192
|
// packages/contracts/src/architecture-debt.ts
|
|
177
193
|
function architectureDebtReportIssues(report) {
|
|
178
194
|
const issues = [];
|
|
@@ -2691,6 +2707,10 @@ function localFactValue(rule, value) {
|
|
|
2691
2707
|
return value;
|
|
2692
2708
|
if (rule === "head" && /^[a-f0-9]{40}$/.test(value))
|
|
2693
2709
|
return value;
|
|
2710
|
+
if (rule === "repoPath" && isRepoRelativePosixPath(value))
|
|
2711
|
+
return value;
|
|
2712
|
+
if (rule === "exportsSubpath" && value.startsWith("."))
|
|
2713
|
+
return value;
|
|
2694
2714
|
if (localEnums[rule]?.includes(value))
|
|
2695
2715
|
return value;
|
|
2696
2716
|
}
|
|
@@ -3022,9 +3042,10 @@ var init_failure = __esm(() => {
|
|
|
3022
3042
|
"pending-source-changes": "CodeGraph repository index has pending or unreported source changes"
|
|
3023
3043
|
});
|
|
3024
3044
|
policies = {
|
|
3045
|
+
"history-shallow-repository": { code: "AC_PRECONDITION_FAILED", message: "Architecture history requires a complete Git repository.", action: "unshallow-repository" },
|
|
3025
3046
|
"code-facts-read-not-ready": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The existing CodeGraph index does not attest to the current source population.", facts: { issues: "codeFactsIssues" }, action: "codegraph-sync", retryable: false },
|
|
3026
3047
|
"code-facts-snapshot-changed": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "Source or index inputs changed while reading the private snapshot.", action: "retry-read", retryable: true, facts: {} },
|
|
3027
|
-
"code-facts-snapshot-limit-exceeded": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The private CodeGraph snapshot exceeds its 512 MiB or 100000 entry limit.", action: "reduce-snapshot-size", retryable: false, facts: {} },
|
|
3048
|
+
"code-facts-snapshot-limit-exceeded": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The private CodeGraph snapshot copy exceeds its 512 MiB or 100000 entry limit.", action: "reduce-snapshot-size", retryable: false, facts: { limit: "snapshotLimit", maxBytes: "uint", maxEntries: "uint", sourceBytes: "uint", sourceEntries: "uint", gitBytes: "uint", gitEntries: "uint", gitObjectEntries: "uint", indexBytes: "uint", indexEntries: "uint" } },
|
|
3028
3049
|
"code-facts-snapshot-layout-unsupported": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "The repository layout cannot be safely isolated for a zero-write CodeGraph read.", action: "inspect-repository-layout", retryable: false, facts: {} },
|
|
3029
3050
|
"daemon-root-missing": { code: "AC_RUNTIME_UNAVAILABLE", message: "The daemon start worktree no longer exists. Stop this daemon using its workspace state directory.", action: "stop-targeted-daemon", retryable: false, facts: {} },
|
|
3030
3051
|
"changeset-receipt-journal-unavailable": { code: "AC_PRECONDITION_FAILED", message: "No committed ChangeSet journal exists for this repository and journal id.", action: "select-committed-journal" },
|
|
@@ -3157,6 +3178,7 @@ var init_failure = __esm(() => {
|
|
|
3157
3178
|
"changeset-rollback-conflict": { code: "AC_PRECONDITION_FAILED", message: "ChangeSet rollback is incomplete because the projection manifest changed externally. Preserve the pending journal and backup for manual recovery.", facts: { journalId: "optional:id", changeSetId: "id", manualRecoveryRequired: "boolean" } },
|
|
3158
3179
|
"deps-input-invalid": { code: "AC_SCHEMA_INVALID", message: "Deps input invalid.", facts: { field: "optional:depsField", issue: "optional:depsIssue" } },
|
|
3159
3180
|
"deps-workspace-invalid": { code: "AC_SCHEMA_INVALID", message: "Deps workspace invalid.", facts: {} },
|
|
3181
|
+
"workspace-exports-unsupported": { code: "AC_SCHEMA_INVALID", message: "A workspace package.json exports value has an unsupported shape.", facts: { manifestPath: "repoPath", subpath: "exportsSubpath" } },
|
|
3160
3182
|
"deps-model-unreadable": { code: "AC_MODEL_ADOPTION_REQUIRED", message: "Deps model unreadable.", facts: {} },
|
|
3161
3183
|
"code-facts-unavailable": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "Code facts unavailable.", facts: {} },
|
|
3162
3184
|
"projection-check-mode-invalid": { code: "AC_SCHEMA_INVALID", message: "Projection check mode invalid.", facts: {} },
|
|
@@ -3304,6 +3326,7 @@ var init_failure = __esm(() => {
|
|
|
3304
3326
|
depsField: ["from", "into", "importNodeLimit", "edgeLimit"],
|
|
3305
3327
|
depsIssue: ["unknown-node", "invalid-limit", "missing-value"],
|
|
3306
3328
|
snapshotField: ["repositoryId", "workspaceId", "headSha", "worktreeDigest"],
|
|
3329
|
+
snapshotLimit: ["bytes", "entries"],
|
|
3307
3330
|
jobsField: ["workerId"],
|
|
3308
3331
|
observedDomain: ["observed"],
|
|
3309
3332
|
inputAvailability: ["unavailable"],
|
|
@@ -3424,6 +3447,7 @@ var init_failure = __esm(() => {
|
|
|
3424
3447
|
],
|
|
3425
3448
|
operation: [
|
|
3426
3449
|
"rev-parse",
|
|
3450
|
+
"log",
|
|
3427
3451
|
"ls-tree",
|
|
3428
3452
|
"ls-files",
|
|
3429
3453
|
"cat-file"
|
|
@@ -4101,7 +4125,7 @@ function compareVersionTriples(left, right) {
|
|
|
4101
4125
|
}
|
|
4102
4126
|
return 0;
|
|
4103
4127
|
}
|
|
4104
|
-
var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.
|
|
4128
|
+
var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.11.1", ARCHCONTEXT_PACKAGE_MANAGER = "bun@1.4.3", ARCHCONTEXT_NODE_RANGE = ">=22.22 <26", LOCAL_RUNTIME_RPC_SCHEMA_VERSION = "archcontext.runtime-rpc/v2", ARCHCONTEXT_SCHEMA_SET_VERSION = "2026-07-11.explorer-view-v2";
|
|
4105
4129
|
|
|
4106
4130
|
// packages/contracts/src/refactor.ts
|
|
4107
4131
|
function refactorNamespaceIssues(value, label = "product.id") {
|
|
@@ -5194,6 +5218,7 @@ var init_refactor = __esm(() => {
|
|
|
5194
5218
|
var init_src = __esm(() => {
|
|
5195
5219
|
init_control_plane_routes();
|
|
5196
5220
|
init_architecture();
|
|
5221
|
+
init_architecture_history();
|
|
5197
5222
|
init_architecture_debt();
|
|
5198
5223
|
init_docs_anchors();
|
|
5199
5224
|
init_github_governance();
|
|
@@ -15657,7 +15682,7 @@ import { basename, posix, resolve as resolve6 } from "node:path";
|
|
|
15657
15682
|
var composer = require_composer();
|
|
15658
15683
|
var Document = require_Document();
|
|
15659
15684
|
var Schema = require_Schema();
|
|
15660
|
-
var
|
|
15685
|
+
var errors2 = require_errors();
|
|
15661
15686
|
var Alias = require_Alias();
|
|
15662
15687
|
var identity = require_identity();
|
|
15663
15688
|
var Pair = require_Pair();
|
|
@@ -15673,9 +15698,9 @@ var visit2 = require_visit();
|
|
|
15673
15698
|
var $Composer = composer.Composer;
|
|
15674
15699
|
var $Document = Document.Document;
|
|
15675
15700
|
var $Schema = Schema.Schema;
|
|
15676
|
-
var $YAMLError =
|
|
15677
|
-
var $YAMLParseError =
|
|
15678
|
-
var $YAMLWarning =
|
|
15701
|
+
var $YAMLError = errors2.YAMLError;
|
|
15702
|
+
var $YAMLParseError = errors2.YAMLParseError;
|
|
15703
|
+
var $YAMLWarning = errors2.YAMLWarning;
|
|
15679
15704
|
var $Alias = Alias.Alias;
|
|
15680
15705
|
var $isAlias = identity.isAlias;
|
|
15681
15706
|
var $isCollection = identity.isCollection;
|
|
@@ -16019,6 +16044,114 @@ function sourceIncludeAnchors(patterns) {
|
|
|
16019
16044
|
});
|
|
16020
16045
|
return [...new Set(anchors)].sort(nativeByteCompare);
|
|
16021
16046
|
}
|
|
16047
|
+
// packages/core/projection-engine/src/architecture-history.ts
|
|
16048
|
+
init_src();
|
|
16049
|
+
var ARCHITECTURE_HISTORY_PATH = "docs/architecture/history.md";
|
|
16050
|
+
var HISTORY_DETAIL_EDGE_LIMIT = 20;
|
|
16051
|
+
var capabilityDomain = (id) => id === null ? null : /^capability\.([a-z0-9]+(?:-[a-z0-9]+)*)\.([a-z0-9]+(?:-[a-z0-9]+)*)$/.exec(id)?.[1] ?? null;
|
|
16052
|
+
var compare2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
16053
|
+
function renderHistoryMermaid(milestone, mode = "full") {
|
|
16054
|
+
if (!milestone.nodes)
|
|
16055
|
+
return null;
|
|
16056
|
+
const removed = mode === "changes" ? milestone.delta.removed.filter((node) => node.kind === "capability") : [];
|
|
16057
|
+
const nodes = mode === "changes" ? [...milestone.nodes, ...removed.map((node) => ({
|
|
16058
|
+
id: node.id,
|
|
16059
|
+
name: node.id,
|
|
16060
|
+
domain: capabilityDomain(node.id)
|
|
16061
|
+
}))].sort((a, b) => compare2(a.id, b.id)) : milestone.nodes;
|
|
16062
|
+
const keys = new Map(nodes.map((node, index) => [node.id, `n${index}`]));
|
|
16063
|
+
const label = (node) => ` ${keys.get(node.id)}["${node.name.replaceAll('"', "#quot;")}"]`;
|
|
16064
|
+
const domains = [...new Set(nodes.flatMap((node) => node.domain === null ? [] : [node.domain]))].sort();
|
|
16065
|
+
const lines = ["flowchart LR"];
|
|
16066
|
+
for (const domain of domains) {
|
|
16067
|
+
lines.push(` subgraph ${JSON.stringify(domain)}`);
|
|
16068
|
+
lines.push(...nodes.filter((node) => node.domain === domain).map((node) => ` ${label(node)}`));
|
|
16069
|
+
lines.push(" end");
|
|
16070
|
+
}
|
|
16071
|
+
lines.push(...nodes.filter((node) => node.domain === null).map(label));
|
|
16072
|
+
const added = mode === "changes" ? milestone.delta.edgesChanged.added : milestone.edges;
|
|
16073
|
+
lines.push(...added.map((edge) => ` ${keys.get(edge.source)} --> ${keys.get(edge.target)}`));
|
|
16074
|
+
if (mode === "changes")
|
|
16075
|
+
lines.push(...milestone.delta.edgesChanged.removed.map((edge) => ` ${keys.get(edge.source)} -.-> ${keys.get(edge.target)}`));
|
|
16076
|
+
if (removed.length) {
|
|
16077
|
+
lines.push(...removed.map((node) => ` class ${keys.get(node.id)} removed`));
|
|
16078
|
+
lines.push(" classDef removed stroke-dasharray: 4 4");
|
|
16079
|
+
}
|
|
16080
|
+
return lines.join(`
|
|
16081
|
+
`);
|
|
16082
|
+
}
|
|
16083
|
+
function renderHistoryDomainOverview(milestone) {
|
|
16084
|
+
if (!milestone.nodes)
|
|
16085
|
+
return null;
|
|
16086
|
+
const counts = new Map;
|
|
16087
|
+
const ensure = (domain) => {
|
|
16088
|
+
if (!counts.has(domain))
|
|
16089
|
+
counts.set(domain, 0);
|
|
16090
|
+
};
|
|
16091
|
+
for (const node of milestone.nodes) {
|
|
16092
|
+
const domain = node.domain ?? "ungrouped";
|
|
16093
|
+
counts.set(domain, (counts.get(domain) ?? 0) + 1);
|
|
16094
|
+
}
|
|
16095
|
+
const changed = new Set;
|
|
16096
|
+
for (const item of [...milestone.delta.added, ...milestone.delta.removed, ...milestone.delta.renamed]) {
|
|
16097
|
+
const domain = capabilityDomain(item.capability) ?? "ungrouped";
|
|
16098
|
+
ensure(domain);
|
|
16099
|
+
changed.add(domain);
|
|
16100
|
+
}
|
|
16101
|
+
const pairs = new Map;
|
|
16102
|
+
for (const [kind, edges] of [["added", milestone.delta.edgesChanged.added], ["removed", milestone.delta.edgesChanged.removed]]) {
|
|
16103
|
+
for (const edge of edges) {
|
|
16104
|
+
const source = capabilityDomain(edge.source) ?? "ungrouped", target = capabilityDomain(edge.target) ?? "ungrouped";
|
|
16105
|
+
ensure(source);
|
|
16106
|
+
ensure(target);
|
|
16107
|
+
changed.add(source);
|
|
16108
|
+
changed.add(target);
|
|
16109
|
+
if (source === target)
|
|
16110
|
+
continue;
|
|
16111
|
+
const key = JSON.stringify([source, target]);
|
|
16112
|
+
const pair = pairs.get(key) ?? { source, target, added: 0, removed: 0 };
|
|
16113
|
+
pair[kind]++;
|
|
16114
|
+
pairs.set(key, pair);
|
|
16115
|
+
}
|
|
16116
|
+
}
|
|
16117
|
+
const domains = [...counts.keys()].sort();
|
|
16118
|
+
const keys = new Map(domains.map((domain, index) => [domain, `d${index}`]));
|
|
16119
|
+
const lines = ["flowchart LR", ...domains.map((domain) => ` ${keys.get(domain)}["${domain} (${counts.get(domain)})"]`)];
|
|
16120
|
+
for (const pair of [...pairs.values()].sort((a, b) => compare2(a.source, b.source) || compare2(a.target, b.target))) {
|
|
16121
|
+
const arrow = pair.added === 0 ? "-.->" : "-->";
|
|
16122
|
+
lines.push(` ${keys.get(pair.source)} ${arrow}|+${pair.added} −${pair.removed}| ${keys.get(pair.target)}`);
|
|
16123
|
+
}
|
|
16124
|
+
if (changed.size) {
|
|
16125
|
+
lines.push(...domains.filter((domain) => changed.has(domain)).map((domain) => ` class ${keys.get(domain)} changed`));
|
|
16126
|
+
lines.push(" classDef changed stroke-width:3px");
|
|
16127
|
+
}
|
|
16128
|
+
return { mermaid: lines.join(`
|
|
16129
|
+
`), pairCount: pairs.size };
|
|
16130
|
+
}
|
|
16131
|
+
function projectHistoryMermaid(history) {
|
|
16132
|
+
return { schemaVersion: ARCHITECTURE_HISTORY_MERMAID_SCHEMA_VERSION, head: history.head, total: history.total, offset: history.offset, limit: history.limit, diagrams: history.milestones.map((milestone) => ({ rev: milestone.rev, mermaid: renderHistoryMermaid(milestone) })) };
|
|
16133
|
+
}
|
|
16134
|
+
function renderHistoryMarkdown(history) {
|
|
16135
|
+
const lines = ["<!-- Generated by ArchContext (archctx history). Do not edit by hand. -->", "", `Architecture history contains ${history.total} milestones. Run \`archctx history\` for the full list.`, ""];
|
|
16136
|
+
for (const milestone of [...history.milestones].reverse()) {
|
|
16137
|
+
lines.push(`## ${milestone.date.slice(0, 10)} · ${milestone.rev.slice(0, 12)}`, "", milestone.subject, "");
|
|
16138
|
+
if (milestone.error)
|
|
16139
|
+
lines.push(milestone.error.code, "");
|
|
16140
|
+
else {
|
|
16141
|
+
const delta = milestone.delta;
|
|
16142
|
+
const overview = renderHistoryDomainOverview(milestone);
|
|
16143
|
+
const edgeCount = delta.edgesChanged.added.length + delta.edgesChanged.removed.length;
|
|
16144
|
+
lines.push(`Added ${delta.added.length} · Removed ${delta.removed.length} · Renamed ${delta.renamed.length} · Edges +${delta.edgesChanged.added.length} −${delta.edgesChanged.removed.length}`, "", "```mermaid", overview.mermaid, "```", "");
|
|
16145
|
+
if (edgeCount <= HISTORY_DETAIL_EDGE_LIMIT)
|
|
16146
|
+
lines.push("```mermaid", renderHistoryMermaid(milestone, "changes"), "```", "");
|
|
16147
|
+
else
|
|
16148
|
+
lines.push(`${edgeCount} changed edges across ${overview.pairCount} domain pairs; run archctx history --ref ${milestone.rev.slice(0, 12)} --format mermaid for the full shape.`, "");
|
|
16149
|
+
}
|
|
16150
|
+
}
|
|
16151
|
+
return `${lines.join(`
|
|
16152
|
+
`)}
|
|
16153
|
+
`;
|
|
16154
|
+
}
|
|
16022
16155
|
|
|
16023
16156
|
// packages/core/projection-engine/src/index.ts
|
|
16024
16157
|
init_src();
|
|
@@ -22198,7 +22331,7 @@ function sameOwners(left, right) {
|
|
|
22198
22331
|
|
|
22199
22332
|
// packages/core/module-statistics/src/index.ts
|
|
22200
22333
|
function evaluateDependencyConstraints(input) {
|
|
22201
|
-
const constraints = [...input.constraints].sort((left, right) =>
|
|
22334
|
+
const constraints = [...input.constraints].sort((left, right) => compare3(left.id, right.id));
|
|
22202
22335
|
const certification = certifyCodeFacts(input.codeFacts, input.worktreeDigest, input.truncated, input.importNodeLimitExceeded ?? false);
|
|
22203
22336
|
if (constraints.length === 0) {
|
|
22204
22337
|
return {
|
|
@@ -22276,7 +22409,7 @@ function evaluateDependencyConstraints(input) {
|
|
|
22276
22409
|
reasonCodes.add("unresolved-import");
|
|
22277
22410
|
if (input.workspacePackagesResolved === false)
|
|
22278
22411
|
reasonCodes.add("workspace-resolution-failed");
|
|
22279
|
-
const sortedViolations = [...violations.values()].sort((left, right) =>
|
|
22412
|
+
const sortedViolations = [...violations.values()].sort((left, right) => compare3(left.constraintId, right.constraintId) || compare3(left.fromPath, right.fromPath) || compare3(left.toPath, right.toPath));
|
|
22280
22413
|
return {
|
|
22281
22414
|
schemaVersion: "archcontext.dependency-constraint-evaluation/v1",
|
|
22282
22415
|
status: sortedViolations.length > 0 ? "violated" : reasonCodes.size > 0 ? "undetermined" : "pass",
|
|
@@ -22353,7 +22486,7 @@ function measureCapabilityDependencies(input) {
|
|
|
22353
22486
|
const cellKey = JSON.stringify([from.capability, to.capability]);
|
|
22354
22487
|
let cell = cells.get(cellKey);
|
|
22355
22488
|
if (cell === undefined) {
|
|
22356
|
-
const relationIds = [...new Set(declaringRelations.get(cellKey) ?? [])].sort(
|
|
22489
|
+
const relationIds = [...new Set(declaringRelations.get(cellKey) ?? [])].sort(compare3);
|
|
22357
22490
|
cell = { from: from.capability, to: to.capability, imports: 0, calls: null, declared: from.capability === to.capability || relationIds.length > 0, relationIds };
|
|
22358
22491
|
cells.set(cellKey, cell);
|
|
22359
22492
|
}
|
|
@@ -22361,14 +22494,14 @@ function measureCapabilityDependencies(input) {
|
|
|
22361
22494
|
attributedEdges.push({ fromPath: edge.from, toPath: edge.to, fromCapability: from.capability, toCapability: to.capability });
|
|
22362
22495
|
}
|
|
22363
22496
|
const edgeLimit = input.edgeLimit ?? CAPABILITY_DEPENDENCIES_EDGE_LIMIT;
|
|
22364
|
-
attributedEdges.sort((left, right) =>
|
|
22497
|
+
attributedEdges.sort((left, right) => compare3(left.fromPath, right.fromPath) || compare3(left.toPath, right.toPath));
|
|
22365
22498
|
const listed = attributedEdges.slice(0, edgeLimit);
|
|
22366
22499
|
return {
|
|
22367
22500
|
schemaVersion: CAPABILITY_DEPENDENCIES_SCHEMA_VERSION,
|
|
22368
22501
|
ownershipRule: "parent-chain",
|
|
22369
22502
|
filter: { from: input.from ?? null, into: input.into ?? null },
|
|
22370
|
-
capabilities: input.nodes.filter((node) => node.kind === "capability").map((node) => node.id).sort(
|
|
22371
|
-
matrix: [...cells.values()].sort((left, right) =>
|
|
22503
|
+
capabilities: input.nodes.filter((node) => node.kind === "capability").map((node) => node.id).sort(compare3),
|
|
22504
|
+
matrix: [...cells.values()].sort((left, right) => compare3(left.from, right.from) || compare3(left.to, right.to)),
|
|
22372
22505
|
imports: {
|
|
22373
22506
|
coverage: certification.coverage,
|
|
22374
22507
|
reasonCodes: [...certification.reasonCodes].sort(),
|
|
@@ -22404,7 +22537,7 @@ function isRepositoryLocalSpecifier(specifier, workspacePackages) {
|
|
|
22404
22537
|
return true;
|
|
22405
22538
|
return workspacePackages.some((workspacePackage) => specifier === workspacePackage.name || specifier.startsWith(`${workspacePackage.name}/`));
|
|
22406
22539
|
}
|
|
22407
|
-
function
|
|
22540
|
+
function compare3(left, right) {
|
|
22408
22541
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
22409
22542
|
}
|
|
22410
22543
|
function measureModuleStatistics(input) {
|
|
@@ -22489,7 +22622,7 @@ function modelDigest(model, constraints) {
|
|
|
22489
22622
|
nodes: [...model.nodes].sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0),
|
|
22490
22623
|
relations: [...model.relations].sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0),
|
|
22491
22624
|
flows: [...model.flows ?? []].sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0),
|
|
22492
|
-
...constraints.length === 0 ? {} : { constraints: [...constraints].sort((left, right) =>
|
|
22625
|
+
...constraints.length === 0 ? {} : { constraints: [...constraints].sort((left, right) => compare3(left.id, right.id)) }
|
|
22493
22626
|
});
|
|
22494
22627
|
}
|
|
22495
22628
|
function countViolationsByNode(evaluation) {
|
|
@@ -23118,17 +23251,21 @@ function assertNativeGitRevision(ref) {
|
|
|
23118
23251
|
throw new NativeContextError("native-context-ref-unsafe", { selector: "ref" });
|
|
23119
23252
|
}
|
|
23120
23253
|
function readOnlyGit(root, operation, args, options = {}) {
|
|
23121
|
-
if (!["rev-parse", "ls-tree", "ls-files", "cat-file"].includes(operation))
|
|
23254
|
+
if (!["rev-parse", "ls-tree", "ls-files", "cat-file", "log"].includes(operation))
|
|
23122
23255
|
throw new NativeContextError("native-context-git-read-failed", { category: "unsupported-operation" });
|
|
23123
23256
|
const unsafeArguments = () => {
|
|
23124
23257
|
throw new NativeContextError("native-context-git-read-failed", { operation, category: "unsupported-read-arguments" });
|
|
23125
23258
|
};
|
|
23126
23259
|
if (operation === "rev-parse") {
|
|
23127
|
-
if (args.length === 1 &&
|
|
23260
|
+
if (args.length === 1 && ["--show-toplevel", "--is-shallow-repository"].includes(args[0])) {} else if (args.length === 1 && isGitRevisionArgument(args[0])) {} else if (args.length === 3 && args[0] === "--verify" && args[1] === "--end-of-options")
|
|
23128
23261
|
assertNativeGitRevision(args[2]);
|
|
23129
23262
|
else
|
|
23130
23263
|
unsafeArguments();
|
|
23131
23264
|
}
|
|
23265
|
+
if (operation === "log") {
|
|
23266
|
+
if (args.length !== 8 || args[0] !== "--first-parent" || args[1] !== "--reverse" || args[2] !== "-z" || args[3] !== "--format=%H%x00%cI%x00%s" || !OBJECT_ID.test(args[4]) || args[5] !== "--" || args[6] !== ".archcontext/model" || args[7] !== ".archcontext/manifest.yaml")
|
|
23267
|
+
unsafeArguments();
|
|
23268
|
+
}
|
|
23132
23269
|
if (operation === "ls-tree") {
|
|
23133
23270
|
const flags = args.slice(0, -1);
|
|
23134
23271
|
if (!flags.includes("-r") || !flags.includes("-z") || flags.some((flag) => !["-r", "-z", "-t", "-l"].includes(flag)) || new Set(flags).size !== flags.length)
|
|
@@ -23154,7 +23291,7 @@ function readOnlyGit(root, operation, args, options = {}) {
|
|
|
23154
23291
|
const env = { ...process.env, LC_ALL: "C", GIT_NO_REPLACE_OBJECTS: "1", GIT_NO_LAZY_FETCH: "1", GIT_OPTIONAL_LOCKS: "0", GIT_PAGER: "cat", GIT_ALLOW_PROTOCOL: "", GIT_TERMINAL_PROMPT: "0" };
|
|
23155
23292
|
for (const key of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE", "GIT_OBJECT_DIRECTORY", "GIT_ALTERNATE_OBJECT_DIRECTORIES", "GIT_NAMESPACE"])
|
|
23156
23293
|
delete env[key];
|
|
23157
|
-
const result = spawnSync("git", ["--no-pager", "--no-replace-objects", "-c", "core.fsmonitor=false", operation, ...args], {
|
|
23294
|
+
const result = spawnSync("git", ["--no-pager", "--no-replace-objects", "-c", "core.fsmonitor=false", ...operation === "log" ? ["-c", "log.showSignature=false"] : [], operation, ...args], {
|
|
23158
23295
|
cwd: root,
|
|
23159
23296
|
env,
|
|
23160
23297
|
input: options.input,
|
|
@@ -23485,9 +23622,43 @@ function readWorkspacePackages(root) {
|
|
|
23485
23622
|
return (manifest.workspaces ?? []).flatMap((entry) => expandWorkspaceEntry(root, entry)).map((directory) => {
|
|
23486
23623
|
const path = join2(root, ...directory.split("/"), "package.json");
|
|
23487
23624
|
const packageManifest = JSON.parse(readFileSync6(path, "utf8"));
|
|
23488
|
-
return { name: packageManifest.name, root: directory, exports: packageManifest.exports
|
|
23625
|
+
return { name: packageManifest.name, root: directory, exports: normalizePackageExports(packageManifest.exports, `${directory}/package.json`) };
|
|
23489
23626
|
}).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
|
|
23490
23627
|
}
|
|
23628
|
+
var EXPORT_CONDITIONS = ["types", "import", "default", "require"];
|
|
23629
|
+
function normalizePackageExports(exportsField, manifestPath) {
|
|
23630
|
+
if (exportsField === undefined)
|
|
23631
|
+
return {};
|
|
23632
|
+
const unsupported = (subpath) => new FailureError("AC_SCHEMA_INVALID", "workspace-exports-unsupported", { manifestPath, subpath });
|
|
23633
|
+
const target = (value, subpath) => {
|
|
23634
|
+
if (typeof value === "string")
|
|
23635
|
+
return value;
|
|
23636
|
+
if (value === null)
|
|
23637
|
+
return;
|
|
23638
|
+
if (typeof value !== "object")
|
|
23639
|
+
throw unsupported(subpath);
|
|
23640
|
+
const candidates = Array.isArray(value) ? value : EXPORT_CONDITIONS.filter((condition) => Object.hasOwn(value, condition)).map((condition) => value[condition]);
|
|
23641
|
+
for (const candidate of candidates) {
|
|
23642
|
+
const resolved = target(candidate, subpath);
|
|
23643
|
+
if (resolved !== undefined)
|
|
23644
|
+
return resolved;
|
|
23645
|
+
}
|
|
23646
|
+
return;
|
|
23647
|
+
};
|
|
23648
|
+
const keys = exportsField !== null && typeof exportsField === "object" && !Array.isArray(exportsField) ? Object.keys(exportsField) : [];
|
|
23649
|
+
const subpathKeys = keys.filter((key) => key.startsWith("."));
|
|
23650
|
+
if (subpathKeys.length === 0) {
|
|
23651
|
+
const root = target(exportsField, ".");
|
|
23652
|
+
return root === undefined ? {} : { ".": root };
|
|
23653
|
+
}
|
|
23654
|
+
if (subpathKeys.length !== keys.length)
|
|
23655
|
+
throw unsupported(".");
|
|
23656
|
+
const entries = subpathKeys.flatMap((subpath) => {
|
|
23657
|
+
const resolved = target(exportsField[subpath], subpath);
|
|
23658
|
+
return resolved === undefined ? [] : [[subpath, resolved]];
|
|
23659
|
+
});
|
|
23660
|
+
return Object.fromEntries(entries);
|
|
23661
|
+
}
|
|
23491
23662
|
function expandWorkspaceEntry(root, entry) {
|
|
23492
23663
|
if (!entry.includes("*"))
|
|
23493
23664
|
return [entry];
|
|
@@ -23832,10 +24003,10 @@ function record5(value) {
|
|
|
23832
24003
|
function text(value) {
|
|
23833
24004
|
return typeof value === "string" && value.length > 0;
|
|
23834
24005
|
}
|
|
23835
|
-
function
|
|
24006
|
+
function node2(value) {
|
|
23836
24007
|
return record5(value) && ["id", "kind", "name", "qualifiedName", "filePath", "language"].every((key) => typeof value[key] === "string") && text(value.id) && ["startLine", "endLine", "startColumn", "endColumn", "updatedAt"].every((key) => typeof value[key] === "number" && Number.isFinite(value[key]));
|
|
23837
24008
|
}
|
|
23838
|
-
function
|
|
24009
|
+
function edge2(value) {
|
|
23839
24010
|
return record5(value) && text(value.source) && text(value.target) && (value.kind === "calls" || value.kind === "references") && (value.line === undefined || typeof value.line === "number" && Number.isFinite(value.line)) && (value.column === undefined || typeof value.column === "number" && Number.isFinite(value.column)) && (value.metadata === undefined || record5(value.metadata));
|
|
23840
24011
|
}
|
|
23841
24012
|
function fileRecord(value) {
|
|
@@ -23882,12 +24053,12 @@ function decodeReader(output, root, request) {
|
|
|
23882
24053
|
}
|
|
23883
24054
|
return result;
|
|
23884
24055
|
};
|
|
23885
|
-
const names = table(wire.names, (value) => rows(value,
|
|
24056
|
+
const names = table(wire.names, (value) => rows(value, node2));
|
|
23886
24057
|
sameKeys(names, request.names);
|
|
23887
24058
|
for (const [name, nodes] of names)
|
|
23888
24059
|
if (nodes.some((item) => item.name !== name))
|
|
23889
24060
|
unavailable();
|
|
23890
|
-
const filesByPath = table(wire.filesByPath, (value) => rows(value,
|
|
24061
|
+
const filesByPath = table(wire.filesByPath, (value) => rows(value, node2));
|
|
23891
24062
|
const sources = new Map;
|
|
23892
24063
|
const sourcePaths = new Set(request.sources.map((source) => source.path));
|
|
23893
24064
|
for (const source of request.sources) {
|
|
@@ -23901,7 +24072,7 @@ function decodeReader(output, root, request) {
|
|
|
23901
24072
|
}
|
|
23902
24073
|
}
|
|
23903
24074
|
sameKeys(filesByPath, sourcePaths);
|
|
23904
|
-
const outgoing = table(wire.outgoing, (value) => rows(value,
|
|
24075
|
+
const outgoing = table(wire.outgoing, (value) => rows(value, edge2));
|
|
23905
24076
|
sameKeys(outgoing, sources.keys());
|
|
23906
24077
|
const targetIds = new Set;
|
|
23907
24078
|
for (const [id, edges] of outgoing)
|
|
@@ -23911,7 +24082,7 @@ function decodeReader(output, root, request) {
|
|
|
23911
24082
|
targetIds.add(item.target);
|
|
23912
24083
|
}
|
|
23913
24084
|
const targets = table(wire.targets, (value) => {
|
|
23914
|
-
if (++items > MAX_ITEMS || value !== null && !
|
|
24085
|
+
if (++items > MAX_ITEMS || value !== null && !node2(value))
|
|
23915
24086
|
return unavailable();
|
|
23916
24087
|
return value;
|
|
23917
24088
|
});
|
|
@@ -25804,9 +25975,6 @@ function withExistingCodeGraphSnapshot(root, queries, callback, options = {}) {
|
|
|
25804
25975
|
const gitDir = gitPath("--git-dir");
|
|
25805
25976
|
const commonDir = gitPath("--git-common-dir");
|
|
25806
25977
|
assertSnapshotGitReadSafety(originalRoot);
|
|
25807
|
-
if (existsSync6(join3(commonDir, "objects/info/alternates"))) {
|
|
25808
|
-
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
25809
|
-
}
|
|
25810
25978
|
const temporaryParent = realpathSync3.native(tmpdir2());
|
|
25811
25979
|
const temporaryRelative = relative4(originalRoot, temporaryParent);
|
|
25812
25980
|
if (!temporaryRelative || temporaryRelative !== ".." && !temporaryRelative.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) && !isAbsolute4(temporaryRelative)) {
|
|
@@ -25876,28 +26044,50 @@ function assertSnapshotGitReadSafety(root) {
|
|
|
25876
26044
|
}
|
|
25877
26045
|
}
|
|
25878
26046
|
}
|
|
26047
|
+
function pinSnapshotHooks(snapshotRepository) {
|
|
26048
|
+
const gitDir = join3(snapshotRepository, ".git");
|
|
26049
|
+
const hooks = join3(gitDir, "archctx-empty-hooks");
|
|
26050
|
+
mkdirSync4(hooks);
|
|
26051
|
+
const path = process.platform === "win32" ? hooks.replaceAll("\\", "/") : hooks;
|
|
26052
|
+
const options = { cwd: snapshotRepository, encoding: "utf8", stdio: "pipe", timeout: 5000 };
|
|
26053
|
+
const pinned = spawnSync4("git", ["config", "--file", join3(gitDir, "config"), "--replace-all", "core.hooksPath", path], options);
|
|
26054
|
+
const effective = spawnSync4("git", ["config", "--get", "core.hooksPath"], options);
|
|
26055
|
+
if (pinned.status !== 0 || effective.status !== 0 || effective.stdout.replace(/\r?\n$/, "") !== path) {
|
|
26056
|
+
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
26057
|
+
}
|
|
26058
|
+
}
|
|
25879
26059
|
function mirrorCodeGraphInputs(root, gitDir, commonDir, destination) {
|
|
25880
26060
|
const hash = createHash5("sha256");
|
|
26061
|
+
const measured = { sourceBytes: 0, sourceEntries: 0, gitBytes: 0, gitEntries: 0, gitObjectEntries: 0, indexBytes: 0, indexEntries: 0 };
|
|
25881
26062
|
let bytes = 0;
|
|
25882
26063
|
let entries = 0;
|
|
25883
|
-
|
|
26064
|
+
let limit;
|
|
26065
|
+
const fingerprint = (source, target) => {
|
|
25884
26066
|
const stat = lstatSync4(source, { bigint: true });
|
|
25885
26067
|
if (++entries > CODEGRAPH_SNAPSHOT_MAX_ENTRIES)
|
|
25886
|
-
|
|
26068
|
+
limit ??= "entries";
|
|
25887
26069
|
hash.update(JSON.stringify([source, target, String(stat.ino), String(stat.size), String(stat.mtimeNs), String(stat.ctimeNs)]));
|
|
26070
|
+
return stat;
|
|
26071
|
+
};
|
|
26072
|
+
const visit = (part, source, target, skip = new Set) => {
|
|
26073
|
+
const stat = fingerprint(source, target);
|
|
26074
|
+
measured[`${part}Entries`]++;
|
|
25888
26075
|
if (stat.isDirectory()) {
|
|
25889
|
-
if (destination)
|
|
26076
|
+
if (destination && !limit)
|
|
25890
26077
|
mkdirSync4(join3(destination, target), { recursive: true });
|
|
25891
26078
|
for (const name of readdirSync4(source).sort()) {
|
|
25892
26079
|
if (!skip.has(name))
|
|
25893
|
-
visit(join3(source, name), join3(target, name));
|
|
26080
|
+
visit(part, join3(source, name), join3(target, name));
|
|
25894
26081
|
}
|
|
25895
26082
|
} else if (stat.isFile()) {
|
|
25896
26083
|
if (basename3(target) === ".git")
|
|
25897
26084
|
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
26085
|
+
measured[`${part}Bytes`] += Number(stat.size);
|
|
25898
26086
|
bytes += Number(stat.size);
|
|
25899
26087
|
if (bytes > CODEGRAPH_SNAPSHOT_MAX_BYTES)
|
|
25900
|
-
|
|
26088
|
+
limit ??= "bytes";
|
|
26089
|
+
if (limit)
|
|
26090
|
+
return;
|
|
25901
26091
|
const data = Buffer.alloc(Number(stat.size));
|
|
25902
26092
|
const fd = openSync3(source, "r");
|
|
25903
26093
|
try {
|
|
@@ -25922,6 +26112,33 @@ function mirrorCodeGraphInputs(root, gitDir, commonDir, destination) {
|
|
|
25922
26112
|
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
25923
26113
|
}
|
|
25924
26114
|
};
|
|
26115
|
+
const visitObjects = (source, target) => {
|
|
26116
|
+
const stat = fingerprint(source, target);
|
|
26117
|
+
measured.gitObjectEntries++;
|
|
26118
|
+
if (stat.isDirectory()) {
|
|
26119
|
+
for (const name of readdirSync4(source).sort())
|
|
26120
|
+
visitObjects(join3(source, name), join3(target, name));
|
|
26121
|
+
} else if (!stat.isFile()) {
|
|
26122
|
+
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
26123
|
+
}
|
|
26124
|
+
};
|
|
26125
|
+
const visitRepository = (source, target, skip) => {
|
|
26126
|
+
const objects = join3(source, "objects");
|
|
26127
|
+
if (existsSync6(join3(objects, "info/alternates")))
|
|
26128
|
+
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
26129
|
+
visit("git", source, target, new Set([...skip, "objects", "hooks", "archctx-empty-hooks"]));
|
|
26130
|
+
visitObjects(objects, join3(target, "objects"));
|
|
26131
|
+
const original = realpathSync3.native(objects);
|
|
26132
|
+
const alternate = process.platform === "win32" ? original.replaceAll("\\", "/") : original;
|
|
26133
|
+
if (/[\r\n]/.test(alternate))
|
|
26134
|
+
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
26135
|
+
if (destination && !limit) {
|
|
26136
|
+
mkdirSync4(join3(destination, target, "objects/pack"), { recursive: true });
|
|
26137
|
+
mkdirSync4(join3(destination, target, "objects/info"), { recursive: true });
|
|
26138
|
+
writeFileSync3(join3(destination, target, "objects/info/alternates"), `${alternate}
|
|
26139
|
+
`);
|
|
26140
|
+
}
|
|
26141
|
+
};
|
|
25925
26142
|
const sourceFiles = codeGraphSourceScanner()(root);
|
|
25926
26143
|
const files = new Set([...sourceFiles, ...listGitVisibleFiles(root)]);
|
|
25927
26144
|
const directories = new Set(["."]);
|
|
@@ -25942,7 +26159,7 @@ function mirrorCodeGraphInputs(root, gitDir, commonDir, destination) {
|
|
|
25942
26159
|
files.add(path);
|
|
25943
26160
|
}
|
|
25944
26161
|
if (directory !== "." && existsSync6(join3(root, directory, ".git"))) {
|
|
25945
|
-
|
|
26162
|
+
visitRepository(join3(root, directory, ".git"), join3(directory, ".git"), new Set);
|
|
25946
26163
|
assertSnapshotGitReadSafety(join3(root, directory));
|
|
25947
26164
|
repositories.add(directory);
|
|
25948
26165
|
}
|
|
@@ -25952,20 +26169,30 @@ function mirrorCodeGraphInputs(root, gitDir, commonDir, destination) {
|
|
|
25952
26169
|
if (file.split(/[\\/]/).some((part) => part === ".git" || part === ".codegraph")) {
|
|
25953
26170
|
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-layout-unsupported");
|
|
25954
26171
|
}
|
|
25955
|
-
visit(join3(root, file), file);
|
|
26172
|
+
visit("source", join3(root, file), file);
|
|
25956
26173
|
}
|
|
25957
|
-
|
|
26174
|
+
visitRepository(commonDir, ".git", new Set(["worktrees"]));
|
|
25958
26175
|
if (gitDir !== commonDir)
|
|
25959
|
-
visit(gitDir, ".git", new Set(["commondir", "gitdir"]));
|
|
26176
|
+
visit("git", gitDir, ".git", new Set(["commondir", "gitdir"]));
|
|
25960
26177
|
for (const suffix of ["", "-wal"]) {
|
|
25961
26178
|
const source = join3(root, ".codegraph", `codegraph.db${suffix}`);
|
|
25962
26179
|
hash.update(JSON.stringify([suffix, existsSync6(source)]));
|
|
25963
26180
|
if (existsSync6(source))
|
|
25964
|
-
visit(source, join3(".codegraph", `codegraph.db${suffix}`));
|
|
26181
|
+
visit("index", source, join3(".codegraph", `codegraph.db${suffix}`));
|
|
26182
|
+
}
|
|
26183
|
+
if (limit) {
|
|
26184
|
+
throw new FailureError("AC_CODE_FACTS_UNAVAILABLE", "code-facts-snapshot-limit-exceeded", {
|
|
26185
|
+
limit,
|
|
26186
|
+
maxBytes: CODEGRAPH_SNAPSHOT_MAX_BYTES,
|
|
26187
|
+
maxEntries: CODEGRAPH_SNAPSHOT_MAX_ENTRIES,
|
|
26188
|
+
...measured
|
|
26189
|
+
});
|
|
25965
26190
|
}
|
|
25966
26191
|
if (destination)
|
|
25967
|
-
for (const repository of repositories)
|
|
26192
|
+
for (const repository of repositories) {
|
|
26193
|
+
pinSnapshotHooks(join3(destination, repository));
|
|
25968
26194
|
assertSnapshotGitReadSafety(join3(destination, repository));
|
|
26195
|
+
}
|
|
25969
26196
|
return hash.digest("hex");
|
|
25970
26197
|
}
|
|
25971
26198
|
var CODEGRAPH_NO_DOWNLOAD_ENV = { CODEGRAPH_NO_DOWNLOAD: "1" };
|
|
@@ -26417,10 +26644,10 @@ function selectedProducerFailureEnvelope(requestId, error, stage) {
|
|
|
26417
26644
|
// packages/local-runtime/runtime-daemon/src/refactor-scan.ts
|
|
26418
26645
|
init_src();
|
|
26419
26646
|
init_src();
|
|
26420
|
-
import { execFileSync as
|
|
26421
|
-
import { createHash as
|
|
26422
|
-
import { existsSync as existsSync8, readdirSync as
|
|
26423
|
-
import { join as
|
|
26647
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
26648
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
26649
|
+
import { existsSync as existsSync8, readdirSync as readdirSync7, readFileSync as readFileSync10 } from "node:fs";
|
|
26650
|
+
import { join as join7 } from "node:path";
|
|
26424
26651
|
|
|
26425
26652
|
// packages/core/refactor-assessment/src/index.ts
|
|
26426
26653
|
init_src();
|
|
@@ -27263,7 +27490,7 @@ function buildObservations(snapshot, structure, model) {
|
|
|
27263
27490
|
evidence: evidence.evidenceGap()
|
|
27264
27491
|
});
|
|
27265
27492
|
}
|
|
27266
|
-
return drafts.map((draft, index) => ({ draft, order: draft.kind === "cycle" ? index : 0 })).sort((left, right) =>
|
|
27493
|
+
return drafts.map((draft, index) => ({ draft, order: draft.kind === "cycle" ? index : 0 })).sort((left, right) => compare4(left.draft.kind, right.draft.kind) || left.order - right.order || compare4(left.draft.subjectSelectorId, right.draft.subjectSelectorId)).map(({ draft }) => ({
|
|
27267
27494
|
kind: draft.kind,
|
|
27268
27495
|
subjectSelectorId: draft.subjectSelectorId,
|
|
27269
27496
|
affectedNodeIds: draft.affectedNodeIds,
|
|
@@ -27453,13 +27680,13 @@ function signalIdFor(draft) {
|
|
|
27453
27680
|
}
|
|
27454
27681
|
function modelDigest2(model, constraints) {
|
|
27455
27682
|
return digestJson({
|
|
27456
|
-
nodes: [...model.nodes].sort((left, right) =>
|
|
27457
|
-
relations: [...model.relations].sort((left, right) =>
|
|
27458
|
-
flows: [...model.flows ?? []].sort((left, right) =>
|
|
27459
|
-
...constraints.length === 0 ? {} : { constraints: [...constraints].sort((left, right) =>
|
|
27683
|
+
nodes: [...model.nodes].sort((left, right) => compare4(left.id, right.id)),
|
|
27684
|
+
relations: [...model.relations].sort((left, right) => compare4(left.id, right.id)),
|
|
27685
|
+
flows: [...model.flows ?? []].sort((left, right) => compare4(left.id, right.id)),
|
|
27686
|
+
...constraints.length === 0 ? {} : { constraints: [...constraints].sort((left, right) => compare4(left.id, right.id)) }
|
|
27460
27687
|
});
|
|
27461
27688
|
}
|
|
27462
|
-
function
|
|
27689
|
+
function compare4(left, right) {
|
|
27463
27690
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
27464
27691
|
}
|
|
27465
27692
|
function isNumber(value) {
|
|
@@ -27471,8 +27698,117 @@ function isPresent2(value) {
|
|
|
27471
27698
|
|
|
27472
27699
|
// packages/local-runtime/model-store-yaml/src/index.ts
|
|
27473
27700
|
init_src();
|
|
27474
|
-
import { existsSync as existsSync7, lstatSync as lstatSync6, mkdirSync as
|
|
27475
|
-
import { dirname as dirname5, resolve as
|
|
27701
|
+
import { existsSync as existsSync7, lstatSync as lstatSync6, mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync9, rmSync as rmSync5 } from "node:fs";
|
|
27702
|
+
import { dirname as dirname5, resolve as resolve13 } from "node:path";
|
|
27703
|
+
|
|
27704
|
+
// packages/local-runtime/model-store-yaml/src/architecture-history.ts
|
|
27705
|
+
init_src();
|
|
27706
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync8, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
27707
|
+
import { join as join5 } from "node:path";
|
|
27708
|
+
import { randomUUID } from "node:crypto";
|
|
27709
|
+
|
|
27710
|
+
// packages/local-runtime/runtime-state-paths/src/index.ts
|
|
27711
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
27712
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
27713
|
+
import { readdirSync as readdirSync5, realpathSync as realpathSync4 } from "node:fs";
|
|
27714
|
+
import { homedir } from "node:os";
|
|
27715
|
+
import { isAbsolute as isAbsolute5, join as join4, resolve as resolve11 } from "node:path";
|
|
27716
|
+
var ARCHCONTEXT_STATE_DIR_ENV = "ARCHCONTEXT_STATE_DIR";
|
|
27717
|
+
var ARCHCONTEXT_LOCAL_STORE_PATH_ENV = "ARCHCONTEXT_LOCAL_STORE_PATH";
|
|
27718
|
+
function defaultArchContextStateRoot(env = process.env, platform = process.platform, home = homedir()) {
|
|
27719
|
+
const override = env[ARCHCONTEXT_STATE_DIR_ENV];
|
|
27720
|
+
if (override)
|
|
27721
|
+
return { path: resolve11(override), source: "environment" };
|
|
27722
|
+
if (platform === "darwin")
|
|
27723
|
+
return { path: join4(home, "Library", "Application Support", "ArchContext"), source: "os-user-data" };
|
|
27724
|
+
if (platform === "win32")
|
|
27725
|
+
return { path: join4(env.LOCALAPPDATA ?? join4(home, "AppData", "Local"), "ArchContext"), source: "os-user-data" };
|
|
27726
|
+
return { path: join4(env.XDG_DATA_HOME ?? join4(home, ".local", "share"), "archcontext"), source: "os-user-data" };
|
|
27727
|
+
}
|
|
27728
|
+
function runtimeStatePaths(root = process.cwd(), env = process.env) {
|
|
27729
|
+
const repositoryRoot = readGitPath(root, ["rev-parse", "--show-toplevel"]) ?? root;
|
|
27730
|
+
const canonicalRepositoryRoot = canonicalPath(repositoryRoot);
|
|
27731
|
+
const gitCommonDir = readGitPath(canonicalRepositoryRoot, ["rev-parse", "--git-common-dir"]);
|
|
27732
|
+
const repositoryAnchor = canonicalPath(gitCommonDir ? resolveMaybeRelative(canonicalRepositoryRoot, gitCommonDir) : canonicalRepositoryRoot);
|
|
27733
|
+
const workspaceAnchor = canonicalRepositoryRoot;
|
|
27734
|
+
const storageRepositoryId = stableStorageId("repo", repositoryAnchor);
|
|
27735
|
+
const storageWorkspaceId = stableStorageId("ws", workspaceAnchor);
|
|
27736
|
+
const stateRoot = defaultArchContextStateRoot(env);
|
|
27737
|
+
const repositoryStateDir = join4(stateRoot.path, REPOSITORIES_DIR, storageRepositoryId);
|
|
27738
|
+
const workspaceStateDir = join4(repositoryStateDir, WORKTREES_DIR, storageWorkspaceId);
|
|
27739
|
+
const legacyControlDir = resolve11(canonicalRepositoryRoot, ".archcontext", ".local");
|
|
27740
|
+
return {
|
|
27741
|
+
schemaVersion: "archcontext.runtime-state-paths/v1",
|
|
27742
|
+
stateRoot: stateRoot.path,
|
|
27743
|
+
source: stateRoot.source,
|
|
27744
|
+
repositoryRoot: canonicalRepositoryRoot,
|
|
27745
|
+
repositoryAnchor,
|
|
27746
|
+
workspaceAnchor,
|
|
27747
|
+
storageRepositoryId,
|
|
27748
|
+
storageWorkspaceId,
|
|
27749
|
+
repositoryId: storageRepositoryId,
|
|
27750
|
+
workspaceId: storageWorkspaceId,
|
|
27751
|
+
repositoryStateDir,
|
|
27752
|
+
workspaceStateDir,
|
|
27753
|
+
sharedCacheDir: join4(repositoryStateDir, "shared", "cache"),
|
|
27754
|
+
localStorePath: env[ARCHCONTEXT_LOCAL_STORE_PATH_ENV] ?? join4(workspaceStateDir, "runtime.sqlite"),
|
|
27755
|
+
...daemonControlPaths(workspaceStateDir),
|
|
27756
|
+
developerReviewRunStateDir: join4(workspaceStateDir, "developer-review-runs"),
|
|
27757
|
+
legacyControlDir,
|
|
27758
|
+
legacyLocalStorePath: join4(legacyControlDir, "runtime.sqlite")
|
|
27759
|
+
};
|
|
27760
|
+
}
|
|
27761
|
+
var REPOSITORIES_DIR = "repositories";
|
|
27762
|
+
var WORKTREES_DIR = "worktrees";
|
|
27763
|
+
function daemonControlPaths(workspaceStateDir) {
|
|
27764
|
+
return {
|
|
27765
|
+
daemonConnectionPath: join4(workspaceStateDir, "archctxd.json"),
|
|
27766
|
+
daemonLockPath: join4(workspaceStateDir, "archctxd.lock"),
|
|
27767
|
+
daemonLogPath: join4(workspaceStateDir, "archctxd.log")
|
|
27768
|
+
};
|
|
27769
|
+
}
|
|
27770
|
+
function listWorkspaceStateDirs(stateRoot) {
|
|
27771
|
+
return listDirectoryNames(join4(stateRoot, REPOSITORIES_DIR)).flatMap((storageRepositoryId) => listDirectoryNames(join4(stateRoot, REPOSITORIES_DIR, storageRepositoryId, WORKTREES_DIR)).map((storageWorkspaceId) => ({
|
|
27772
|
+
storageRepositoryId,
|
|
27773
|
+
storageWorkspaceId,
|
|
27774
|
+
workspaceStateDir: join4(stateRoot, REPOSITORIES_DIR, storageRepositoryId, WORKTREES_DIR, storageWorkspaceId)
|
|
27775
|
+
})));
|
|
27776
|
+
}
|
|
27777
|
+
function listDirectoryNames(path) {
|
|
27778
|
+
try {
|
|
27779
|
+
return readdirSync5(path, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
27780
|
+
} catch (error) {
|
|
27781
|
+
if (error.code === "ENOENT")
|
|
27782
|
+
return [];
|
|
27783
|
+
throw error;
|
|
27784
|
+
}
|
|
27785
|
+
}
|
|
27786
|
+
function readGitPath(root, args) {
|
|
27787
|
+
try {
|
|
27788
|
+
const value = execFileSync3("git", args, {
|
|
27789
|
+
cwd: root,
|
|
27790
|
+
encoding: "utf8",
|
|
27791
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
27792
|
+
}).trim();
|
|
27793
|
+
return value.length > 0 ? value : undefined;
|
|
27794
|
+
} catch {
|
|
27795
|
+
return;
|
|
27796
|
+
}
|
|
27797
|
+
}
|
|
27798
|
+
function resolveMaybeRelative(base, path) {
|
|
27799
|
+
return isAbsolute5(path) ? resolve11(path) : resolve11(base, path);
|
|
27800
|
+
}
|
|
27801
|
+
function canonicalPath(path) {
|
|
27802
|
+
const resolved = resolve11(path);
|
|
27803
|
+
try {
|
|
27804
|
+
return realpathSync4.native(resolved);
|
|
27805
|
+
} catch {
|
|
27806
|
+
return resolved;
|
|
27807
|
+
}
|
|
27808
|
+
}
|
|
27809
|
+
function stableStorageId(prefix, value) {
|
|
27810
|
+
return `${prefix}.${createHash6("sha256").update(value).digest("hex").slice(0, 16)}`;
|
|
27811
|
+
}
|
|
27476
27812
|
// schemas/repo/architecture-node.schema.json
|
|
27477
27813
|
var architecture_node_schema_default = {
|
|
27478
27814
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -27593,12 +27929,6 @@ var architecture_node_schema_default = {
|
|
|
27593
27929
|
extensions: { type: "object", additionalProperties: true }
|
|
27594
27930
|
}
|
|
27595
27931
|
};
|
|
27596
|
-
|
|
27597
|
-
// packages/local-runtime/model-store-yaml/src/native-context.ts
|
|
27598
|
-
init_src();
|
|
27599
|
-
import { createHash as createHash6 } from "node:crypto";
|
|
27600
|
-
import { constants, closeSync as closeSync4, fstatSync as fstatSync2, lstatSync as lstatSync5, openSync as openSync4, readSync as readSync2, realpathSync as realpathSync4 } from "node:fs";
|
|
27601
|
-
import { join as join4, resolve as resolve11 } from "node:path";
|
|
27602
27932
|
// schemas/repo/architecture-relation.schema.json
|
|
27603
27933
|
var architecture_relation_schema_default = {
|
|
27604
27934
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -27626,6 +27956,185 @@ var architecture_relation_schema_default = {
|
|
|
27626
27956
|
extensions: { type: "object", additionalProperties: true }
|
|
27627
27957
|
}
|
|
27628
27958
|
};
|
|
27959
|
+
|
|
27960
|
+
// packages/local-runtime/model-store-yaml/src/architecture-history.ts
|
|
27961
|
+
var compare5 = nativeByteCompare;
|
|
27962
|
+
var modelRoot = ".archcontext/model";
|
|
27963
|
+
var failed = (code, path) => ({ nodes: null, edges: null, structure: null, error: { code, ...path ? { path } : {} } });
|
|
27964
|
+
var edgeKey = (e) => JSON.stringify([e.source, e.target]);
|
|
27965
|
+
function stateForRevision(root, rev, parsed) {
|
|
27966
|
+
try {
|
|
27967
|
+
let context;
|
|
27968
|
+
try {
|
|
27969
|
+
context = readGitBlobTree(root, `${rev}:.archcontext`, { sizes: false });
|
|
27970
|
+
} catch (error) {
|
|
27971
|
+
if (!(error instanceof NativeContextError) || error.reasonCode !== "native-context-git-read-failed")
|
|
27972
|
+
throw error;
|
|
27973
|
+
if (readGitBlobTree(root, rev, { sizes: false }).some((entry) => entry.path === ".archcontext" && entry.type === "tree"))
|
|
27974
|
+
throw error;
|
|
27975
|
+
return failed("history-model-missing");
|
|
27976
|
+
}
|
|
27977
|
+
const manifest = context.find((entry) => entry.path === "manifest.yaml");
|
|
27978
|
+
if (manifest && manifest.type !== "blob")
|
|
27979
|
+
return failed("history-model-layout-unsupported");
|
|
27980
|
+
const read = (entry) => {
|
|
27981
|
+
if (!parsed.has(entry.objectId)) {
|
|
27982
|
+
const body = readGitBlobs(root, [entry])[0];
|
|
27983
|
+
try {
|
|
27984
|
+
parsed.set(entry.objectId, { value: parseJsonOrStableYaml(decodeUtf8(body), entry.path) });
|
|
27985
|
+
} catch {
|
|
27986
|
+
parsed.set(entry.objectId, { invalid: true });
|
|
27987
|
+
}
|
|
27988
|
+
}
|
|
27989
|
+
return parsed.get(entry.objectId);
|
|
27990
|
+
};
|
|
27991
|
+
if (manifest) {
|
|
27992
|
+
const data = read(manifest);
|
|
27993
|
+
if (data.value?.schemaVersion !== "archcontext.manifest/v1" || data.value.model?.layout !== "split" || data.value.model.root !== modelRoot)
|
|
27994
|
+
return failed("history-model-layout-unsupported");
|
|
27995
|
+
}
|
|
27996
|
+
if (!context.some((entry) => entry.path === "model" && entry.type === "tree"))
|
|
27997
|
+
return failed("history-model-missing");
|
|
27998
|
+
const all = readGitBlobTree(root, `${rev}:${modelRoot}`, { sizes: false }).map((entry) => ({ ...entry, path: `${modelRoot}/${entry.path}` }));
|
|
27999
|
+
const nodesDir = all.find((entry) => entry.path === `${modelRoot}/nodes` && entry.type === "tree");
|
|
28000
|
+
if (!nodesDir)
|
|
28001
|
+
return failed("history-model-missing");
|
|
28002
|
+
const files = all.filter((entry) => entry.type === "blob" && (entry.path.startsWith(`${modelRoot}/nodes/`) || entry.path.startsWith(`${modelRoot}/relations/`)) && /\.ya?ml$/.test(entry.path)).sort((a, b) => compare5(a.path, b.path));
|
|
28003
|
+
const missing = [...new Map(files.filter((file) => !parsed.has(file.objectId)).map((file) => [file.objectId, file])).values()];
|
|
28004
|
+
const blobs = readGitBlobs(root, missing);
|
|
28005
|
+
missing.forEach((file, index) => {
|
|
28006
|
+
try {
|
|
28007
|
+
parsed.set(file.objectId, { value: parseJsonOrStableYaml(decodeUtf8(blobs[index]), file.path) });
|
|
28008
|
+
} catch {
|
|
28009
|
+
parsed.set(file.objectId, { invalid: true });
|
|
28010
|
+
}
|
|
28011
|
+
});
|
|
28012
|
+
const nodes = [], relations = [];
|
|
28013
|
+
const paths = new Map;
|
|
28014
|
+
for (const file of files) {
|
|
28015
|
+
const result = read(file);
|
|
28016
|
+
const isNode = file.path.startsWith(`${modelRoot}/nodes/`);
|
|
28017
|
+
if (result.invalid || result.value === undefined || !validateJsonSchema(isNode ? architecture_node_schema_default : architecture_relation_schema_default, result.value).valid)
|
|
28018
|
+
return failed("history-model-invalid", file.path);
|
|
28019
|
+
if (isNode) {
|
|
28020
|
+
const value = result.value;
|
|
28021
|
+
if (paths.has(value.id))
|
|
28022
|
+
return failed("history-model-invalid", file.path);
|
|
28023
|
+
paths.set(value.id, file.path);
|
|
28024
|
+
nodes.push(value);
|
|
28025
|
+
} else
|
|
28026
|
+
relations.push(result.value);
|
|
28027
|
+
}
|
|
28028
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
28029
|
+
for (const node of nodes) {
|
|
28030
|
+
const visited = new Set;
|
|
28031
|
+
let cursor = node;
|
|
28032
|
+
while (cursor) {
|
|
28033
|
+
if (visited.has(cursor.id))
|
|
28034
|
+
return failed("history-model-invalid", paths.get(node.id));
|
|
28035
|
+
visited.add(cursor.id);
|
|
28036
|
+
cursor = cursor.parent ? byId.get(cursor.parent) : undefined;
|
|
28037
|
+
}
|
|
28038
|
+
}
|
|
28039
|
+
const nearest = (id) => {
|
|
28040
|
+
let node = byId.get(id);
|
|
28041
|
+
while (node) {
|
|
28042
|
+
if (node.kind === "capability")
|
|
28043
|
+
return node.id;
|
|
28044
|
+
node = node.parent ? byId.get(node.parent) : undefined;
|
|
28045
|
+
}
|
|
28046
|
+
return;
|
|
28047
|
+
};
|
|
28048
|
+
const edges = new Map;
|
|
28049
|
+
for (const relation of relations) {
|
|
28050
|
+
const source = nearest(relation.source), target = nearest(relation.target);
|
|
28051
|
+
if (source && target && source !== target) {
|
|
28052
|
+
const edge = { source, target };
|
|
28053
|
+
edges.set(edgeKey(edge), edge);
|
|
28054
|
+
}
|
|
28055
|
+
}
|
|
28056
|
+
return {
|
|
28057
|
+
nodes: nodes.filter((node) => node.kind === "capability").map((node) => ({ id: node.id, name: node.name, domain: /^capability\.([a-z0-9]+(?:-[a-z0-9]+)*)\.([a-z0-9]+(?:-[a-z0-9]+)*)$/.exec(node.id)?.[1] ?? null })).sort((a, b) => compare5(a.id, b.id)),
|
|
28058
|
+
edges: [...edges.values()].sort((a, b) => compare5(a.source, b.source) || compare5(a.target, b.target)),
|
|
28059
|
+
structure: nodes.filter((node) => ["capability", "module", "component"].includes(node.kind)).map((node) => ({ id: node.id, kind: node.kind, name: node.name, capability: nearest(node.id) ?? null })).sort((a, b) => compare5(a.id, b.id))
|
|
28060
|
+
};
|
|
28061
|
+
} catch (error) {
|
|
28062
|
+
if (error instanceof NativeContextError && error.reasonCode === "native-context-limit-exceeded")
|
|
28063
|
+
return failed("history-model-too-large");
|
|
28064
|
+
throw error;
|
|
28065
|
+
}
|
|
28066
|
+
}
|
|
28067
|
+
function difference(before, after, baseRev) {
|
|
28068
|
+
const a = new Map(before.structure.map((node) => [node.id, node])), b = new Map(after.structure.map((node) => [node.id, node]));
|
|
28069
|
+
const ae = new Map(before.edges.map((edge) => [edgeKey(edge), edge])), be = new Map(after.edges.map((edge) => [edgeKey(edge), edge]));
|
|
28070
|
+
return {
|
|
28071
|
+
baseRev,
|
|
28072
|
+
added: after.structure.filter((node) => !a.has(node.id)).map(({ id, kind, capability }) => ({ id, kind, capability })),
|
|
28073
|
+
removed: before.structure.filter((node) => !b.has(node.id)).map(({ id, kind, capability }) => ({ id, kind, capability })),
|
|
28074
|
+
renamed: after.structure.flatMap((node) => {
|
|
28075
|
+
const old = a.get(node.id);
|
|
28076
|
+
return old && old.name !== node.name ? [{ id: node.id, kind: node.kind, capability: node.capability, from: old.name, to: node.name }] : [];
|
|
28077
|
+
}),
|
|
28078
|
+
edgesChanged: { added: after.edges.filter((edge) => !ae.has(edgeKey(edge))), removed: before.edges.filter((edge) => !be.has(edgeKey(edge))) }
|
|
28079
|
+
};
|
|
28080
|
+
}
|
|
28081
|
+
function readArchitectureHistory(cwd, options = {}) {
|
|
28082
|
+
const root = readNativeGitRoot(cwd);
|
|
28083
|
+
if (decodeUtf8(readOnlyGit(root, "rev-parse", ["--is-shallow-repository"])).trim() === "true")
|
|
28084
|
+
throw new FailureError("AC_PRECONDITION_FAILED", "history-shallow-repository");
|
|
28085
|
+
const head = resolveNativeGitSnapshot(root, options.ref ?? "HEAD").commitSha;
|
|
28086
|
+
const output = decodeUtf8(readOnlyGit(root, "log", ["--first-parent", "--reverse", "-z", "--format=%H%x00%cI%x00%s", head, "--", modelRoot, ".archcontext/manifest.yaml"]));
|
|
28087
|
+
const fields = output ? output.split("\x00") : [];
|
|
28088
|
+
if (fields.length && fields.pop() !== "")
|
|
28089
|
+
throw new NativeContextError("native-context-git-read-failed", { operation: "log", category: "malformed-record" });
|
|
28090
|
+
if (fields.length % 3 !== 0)
|
|
28091
|
+
throw new NativeContextError("native-context-git-read-failed", { operation: "log", category: "malformed-record" });
|
|
28092
|
+
for (let i = 0;i < fields.length; i += 3)
|
|
28093
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(fields[i]))
|
|
28094
|
+
throw new NativeContextError("native-context-git-read-failed", { operation: "log", category: "malformed-record" });
|
|
28095
|
+
const parsed = new Map;
|
|
28096
|
+
const milestones = [];
|
|
28097
|
+
let previous = { nodes: [], edges: [], structure: [] };
|
|
28098
|
+
let havePrevious = false, priorError, previousMilestone = null;
|
|
28099
|
+
const cacheDir = join5(runtimeStatePaths(root, options.env).sharedCacheDir, "architecture-history", ARCHITECTURE_HISTORY_DERIVATION_VERSION);
|
|
28100
|
+
for (let i = 0;i < fields.length; i += 3) {
|
|
28101
|
+
const [rev, date, subject] = fields.slice(i, i + 3);
|
|
28102
|
+
const cache = join5(cacheDir, `${rev}.json`);
|
|
28103
|
+
let state;
|
|
28104
|
+
try {
|
|
28105
|
+
state = decodeArchitectureHistoryState(JSON.parse(readFileSync8(cache, "utf8")));
|
|
28106
|
+
} catch {}
|
|
28107
|
+
if (!state) {
|
|
28108
|
+
state = stateForRevision(root, rev, parsed);
|
|
28109
|
+
mkdirSync5(cacheDir, { recursive: true });
|
|
28110
|
+
const temporary = `${cache}.${randomUUID()}.tmp`;
|
|
28111
|
+
writeFileSync4(temporary, JSON.stringify(state));
|
|
28112
|
+
renameSync3(temporary, cache);
|
|
28113
|
+
}
|
|
28114
|
+
if (state.error) {
|
|
28115
|
+
if (priorError !== state.error.code)
|
|
28116
|
+
milestones.push({ rev, date, subject, nodes: null, edges: null, delta: null, error: state.error });
|
|
28117
|
+
priorError = state.error.code;
|
|
28118
|
+
continue;
|
|
28119
|
+
}
|
|
28120
|
+
const recovered = priorError !== undefined;
|
|
28121
|
+
priorError = undefined;
|
|
28122
|
+
const delta = difference(previous, state, previousMilestone);
|
|
28123
|
+
if (!havePrevious || recovered || delta.added.length || delta.removed.length || delta.renamed.length || delta.edgesChanged.added.length || delta.edgesChanged.removed.length) {
|
|
28124
|
+
milestones.push({ rev, date, subject, nodes: state.nodes, edges: state.edges, delta });
|
|
28125
|
+
previousMilestone = rev;
|
|
28126
|
+
previous = state;
|
|
28127
|
+
havePrevious = true;
|
|
28128
|
+
}
|
|
28129
|
+
}
|
|
28130
|
+
const offset = options.offset ?? 0, limit = options.limit ?? 200;
|
|
28131
|
+
return { schemaVersion: ARCHITECTURE_HISTORY_SCHEMA_VERSION, head, total: milestones.length, offset, limit, milestones: milestones.slice(offset, offset + limit) };
|
|
28132
|
+
}
|
|
28133
|
+
// packages/local-runtime/model-store-yaml/src/native-context.ts
|
|
28134
|
+
init_src();
|
|
28135
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
28136
|
+
import { constants, closeSync as closeSync4, fstatSync as fstatSync2, lstatSync as lstatSync5, openSync as openSync4, readSync as readSync2, realpathSync as realpathSync5 } from "node:fs";
|
|
28137
|
+
import { join as join6, resolve as resolve12 } from "node:path";
|
|
27629
28138
|
// schemas/repo/architecture-flow.schema.json
|
|
27630
28139
|
var architecture_flow_schema_default = {
|
|
27631
28140
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -27730,7 +28239,7 @@ var SCHEMAS = { node: architecture_node_schema_default, relation: architecture_r
|
|
|
27730
28239
|
var MANIFEST = ".archcontext/manifest.yaml";
|
|
27731
28240
|
var MODEL_KINDS = ["nodes", "relations", "flows"];
|
|
27732
28241
|
function contentDigest(bytes) {
|
|
27733
|
-
return `sha256:${
|
|
28242
|
+
return `sha256:${createHash7("sha256").update(bytes).digest("hex")}`;
|
|
27734
28243
|
}
|
|
27735
28244
|
function record6(value) {
|
|
27736
28245
|
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype ? value : undefined;
|
|
@@ -27858,23 +28367,23 @@ function observePath(root, path, directory = false) {
|
|
|
27858
28367
|
const segments = path.split("/");
|
|
27859
28368
|
for (let index = -1;index < segments.length; index += 1) {
|
|
27860
28369
|
if (index >= 0)
|
|
27861
|
-
absolute =
|
|
28370
|
+
absolute = join6(absolute, segments[index]);
|
|
27862
28371
|
let stat;
|
|
27863
28372
|
try {
|
|
27864
28373
|
stat = lstatSync5(absolute, { bigint: true });
|
|
27865
28374
|
} catch (error) {
|
|
27866
28375
|
if (error.code === "ENOENT")
|
|
27867
|
-
return { exists: false, identity: identities.join("/") + "/missing", absolute:
|
|
28376
|
+
return { exists: false, identity: identities.join("/") + "/missing", absolute: resolve12(root, path) };
|
|
27868
28377
|
throw new NativeContextError("native-context-input-unreadable", { path, category: "stat" });
|
|
27869
28378
|
}
|
|
27870
28379
|
const needsDirectory = index < segments.length - 1 || directory;
|
|
27871
28380
|
if (stat.isSymbolicLink() || (needsDirectory ? !stat.isDirectory() : !stat.isFile()))
|
|
27872
28381
|
throw new NativeContextError("native-context-entry-kind-unsupported", { path, category: stat.isSymbolicLink() ? "link" : "non-regular" });
|
|
27873
|
-
if (index >= 0 &&
|
|
28382
|
+
if (index >= 0 && realpathSync5.native(absolute) !== absolute)
|
|
27874
28383
|
throw new NativeContextError("native-context-path-unsafe", { path, category: "filesystem-path-alias" });
|
|
27875
28384
|
if (needsDirectory && index >= 0) {
|
|
27876
28385
|
try {
|
|
27877
|
-
lstatSync5(
|
|
28386
|
+
lstatSync5(join6(absolute, ".git"));
|
|
27878
28387
|
throw new NativeContextError("native-context-entry-kind-unsupported", { path: segments.slice(0, index + 1).join("/"), category: "nested-repository" });
|
|
27879
28388
|
} catch (error) {
|
|
27880
28389
|
if (error instanceof NativeContextError)
|
|
@@ -28218,7 +28727,7 @@ function readNativeContext(start, selector, hooks) {
|
|
|
28218
28727
|
`, "utf8"));
|
|
28219
28728
|
return data;
|
|
28220
28729
|
}
|
|
28221
|
-
const worktreeRoot =
|
|
28730
|
+
const worktreeRoot = realpathSync5.native(root);
|
|
28222
28731
|
const head = resolveNativeGitSnapshot(worktreeRoot, "HEAD");
|
|
28223
28732
|
const snapshot = { source: "worktree", headSha: head.commitSha, headTreeOid: head.treeOid, validation: "stable-read" };
|
|
28224
28733
|
const first = new WorktreeSource(worktreeRoot, hooks, 1, head.treeOid);
|
|
@@ -28254,7 +28763,7 @@ init_src();
|
|
|
28254
28763
|
|
|
28255
28764
|
// packages/local-runtime/codegraph-adapter/src/ref-impact-facts.ts
|
|
28256
28765
|
init_src();
|
|
28257
|
-
import { createHash as
|
|
28766
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
28258
28767
|
import { createRequire as createRequire3 } from "node:module";
|
|
28259
28768
|
var nonDeclarations = new Set(["file", "import", "export", "parameter"]);
|
|
28260
28769
|
var requireFromAdapter2 = createRequire3(import.meta.url);
|
|
@@ -28288,7 +28797,7 @@ function bindSnapshotRefImpactFacts(root, model, ref, graph) {
|
|
|
28288
28797
|
for (let i = 0;i < files.length; i++) {
|
|
28289
28798
|
const file = files[i], body = blobs[i];
|
|
28290
28799
|
const content = decodeUtf8(body);
|
|
28291
|
-
if (
|
|
28800
|
+
if (createHash8("sha256").update(content).digest("hex") !== file.contentHash)
|
|
28292
28801
|
return;
|
|
28293
28802
|
lineCounts.set(file.path, content.split(`
|
|
28294
28803
|
`).length);
|
|
@@ -28767,10 +29276,10 @@ function initializeArchContextModel(root, productName = "ArchContext Project") {
|
|
|
28767
29276
|
});
|
|
28768
29277
|
files.push({ path: ".archcontext/projections/targets.json", body: `${JSON.stringify(createDefaultProjectionTargetManifest(), null, 2)}
|
|
28769
29278
|
` });
|
|
28770
|
-
|
|
29279
|
+
mkdirSync6(root, { recursive: true });
|
|
28771
29280
|
const existing = files.filter((file) => {
|
|
28772
29281
|
assertPathHasNoSymlinkSegments(root, file.path);
|
|
28773
|
-
return lstatIfExists(
|
|
29282
|
+
return lstatIfExists(resolve13(root, file.path)) !== undefined;
|
|
28774
29283
|
}).map((file) => file.path);
|
|
28775
29284
|
if (existing.length > 0)
|
|
28776
29285
|
throw new ArchContextInitRefusedError(existing);
|
|
@@ -28783,7 +29292,7 @@ function initializeArchContextModel(root, productName = "ArchContext Project") {
|
|
|
28783
29292
|
rebuildGeneratedProjection(root);
|
|
28784
29293
|
} catch (error) {
|
|
28785
29294
|
for (const path of created.reverse())
|
|
28786
|
-
rmSync5(
|
|
29295
|
+
rmSync5(resolve13(root, path), { force: true });
|
|
28787
29296
|
throw error;
|
|
28788
29297
|
}
|
|
28789
29298
|
}
|
|
@@ -28791,7 +29300,7 @@ function rebuildGeneratedProjection(root) {
|
|
|
28791
29300
|
for (const operation of planGeneratedProjection(root)) {
|
|
28792
29301
|
if (operation.operation === "delete_entity") {
|
|
28793
29302
|
assertPathHasNoSymlinkSegments(root, dirname5(operation.path));
|
|
28794
|
-
rmSync5(
|
|
29303
|
+
rmSync5(resolve13(root, operation.path), { force: true });
|
|
28795
29304
|
} else {
|
|
28796
29305
|
writeFileWithoutFollowingSymlinks({ root, path: operation.path, body: withTrailingNewline(operation.body), expectedHash: operation.expectedHash });
|
|
28797
29306
|
}
|
|
@@ -28799,12 +29308,12 @@ function rebuildGeneratedProjection(root) {
|
|
|
28799
29308
|
}
|
|
28800
29309
|
function planGeneratedProjection(root) {
|
|
28801
29310
|
const desiredBody = GENERATED_ARCHITECTURE_BODY;
|
|
28802
|
-
const desiredAbsolute =
|
|
29311
|
+
const desiredAbsolute = resolve13(root, GENERATED_ARCHITECTURE_PATH);
|
|
28803
29312
|
const operations = [];
|
|
28804
|
-
if (!existsSync7(desiredAbsolute) ||
|
|
29313
|
+
if (!existsSync7(desiredAbsolute) || readFileSync9(desiredAbsolute, "utf8") !== desiredBody) {
|
|
28805
29314
|
operations.push({
|
|
28806
29315
|
path: GENERATED_ARCHITECTURE_PATH,
|
|
28807
|
-
expectedHash: existsSync7(desiredAbsolute) ? digestJson({ body:
|
|
29316
|
+
expectedHash: existsSync7(desiredAbsolute) ? digestJson({ body: readFileSync9(desiredAbsolute, "utf8") }) : "missing",
|
|
28808
29317
|
body: desiredBody,
|
|
28809
29318
|
operation: "render_projection"
|
|
28810
29319
|
});
|
|
@@ -28812,7 +29321,7 @@ function planGeneratedProjection(root) {
|
|
|
28812
29321
|
for (const path of collectGeneratedProjectionFiles(root)) {
|
|
28813
29322
|
if (path === GENERATED_ARCHITECTURE_PATH)
|
|
28814
29323
|
continue;
|
|
28815
|
-
const body =
|
|
29324
|
+
const body = readFileSync9(resolve13(root, path), "utf8");
|
|
28816
29325
|
operations.push({
|
|
28817
29326
|
path,
|
|
28818
29327
|
expectedHash: digestJson({ body }),
|
|
@@ -28824,9 +29333,9 @@ function planGeneratedProjection(root) {
|
|
|
28824
29333
|
}
|
|
28825
29334
|
function collectGeneratedProjectionFiles(root) {
|
|
28826
29335
|
const generatedRoot = ".archcontext/generated";
|
|
28827
|
-
if (!existsSync7(
|
|
29336
|
+
if (!existsSync7(resolve13(root, generatedRoot)))
|
|
28828
29337
|
return [];
|
|
28829
|
-
const walk = (relativeDir) =>
|
|
29338
|
+
const walk = (relativeDir) => readdirSync6(resolve13(root, relativeDir), { withFileTypes: true }).flatMap((entry) => {
|
|
28830
29339
|
const child = `${relativeDir}/${entry.name}`;
|
|
28831
29340
|
if (entry.isDirectory())
|
|
28832
29341
|
return walk(child);
|
|
@@ -28837,7 +29346,7 @@ function collectGeneratedProjectionFiles(root) {
|
|
|
28837
29346
|
|
|
28838
29347
|
class YamlModelStore {
|
|
28839
29348
|
async loadManifest(workspace) {
|
|
28840
|
-
return
|
|
29349
|
+
return readFileSync9(resolve13(workspace.root, ".archcontext/manifest.yaml"), "utf8");
|
|
28841
29350
|
}
|
|
28842
29351
|
async loadModel(workspace) {
|
|
28843
29352
|
return listModelFiles(workspace.root);
|
|
@@ -28848,7 +29357,7 @@ class YamlModelStore {
|
|
|
28848
29357
|
const nodeSchemaErrors = [];
|
|
28849
29358
|
for (const required of [".archcontext/manifest.yaml", ".archcontext/product.yaml"]) {
|
|
28850
29359
|
try {
|
|
28851
|
-
|
|
29360
|
+
readFileSync9(resolve13(workspace.root, required), "utf8");
|
|
28852
29361
|
} catch {
|
|
28853
29362
|
const error = `missing ${required}`;
|
|
28854
29363
|
errors.push(error);
|
|
@@ -28945,7 +29454,7 @@ function listModelFiles(root) {
|
|
|
28945
29454
|
"docs/adr"
|
|
28946
29455
|
]);
|
|
28947
29456
|
return paths.map((path) => {
|
|
28948
|
-
const body =
|
|
29457
|
+
const body = readFileSync9(resolve13(root, path), "utf8");
|
|
28949
29458
|
return {
|
|
28950
29459
|
path,
|
|
28951
29460
|
body,
|
|
@@ -28957,7 +29466,7 @@ function listModelFiles(root) {
|
|
|
28957
29466
|
function collectArchContextFiles(root, entries) {
|
|
28958
29467
|
const files = [];
|
|
28959
29468
|
for (const entry of entries) {
|
|
28960
|
-
const absolute =
|
|
29469
|
+
const absolute = resolve13(root, entry);
|
|
28961
29470
|
if (!existsSync7(absolute))
|
|
28962
29471
|
continue;
|
|
28963
29472
|
const stat = readdirOrFile(absolute);
|
|
@@ -28971,8 +29480,8 @@ function collectArchContextFiles(root, entries) {
|
|
|
28971
29480
|
return [...new Set(files)].sort();
|
|
28972
29481
|
function walk(relativeDir) {
|
|
28973
29482
|
const out = [];
|
|
28974
|
-
const dir =
|
|
28975
|
-
for (const entry of
|
|
29483
|
+
const dir = resolve13(root, relativeDir);
|
|
29484
|
+
for (const entry of readdirSync6(dir, { withFileTypes: true })) {
|
|
28976
29485
|
const child = `${relativeDir}/${entry.name}`;
|
|
28977
29486
|
if (entry.isDirectory())
|
|
28978
29487
|
out.push(...walk(child));
|
|
@@ -28989,7 +29498,7 @@ function isCollectableModelFile(path) {
|
|
|
28989
29498
|
}
|
|
28990
29499
|
function readdirOrFile(path) {
|
|
28991
29500
|
try {
|
|
28992
|
-
|
|
29501
|
+
readdirSync6(path);
|
|
28993
29502
|
return "directory";
|
|
28994
29503
|
} catch {
|
|
28995
29504
|
return "file";
|
|
@@ -32452,10 +32961,10 @@ function evaluateWorktreeDependencyConstraints(input) {
|
|
|
32452
32961
|
});
|
|
32453
32962
|
}
|
|
32454
32963
|
function reviewWorkspacePackages(root) {
|
|
32455
|
-
if (!existsSync8(
|
|
32964
|
+
if (!existsSync8(join7(root, "package.json")))
|
|
32456
32965
|
return { packages: [], resolved: true };
|
|
32457
32966
|
try {
|
|
32458
|
-
const manifest = JSON.parse(
|
|
32967
|
+
const manifest = JSON.parse(readFileSync10(join7(root, "package.json"), "utf8"));
|
|
32459
32968
|
const declared = Array.isArray(manifest.workspaces) ? manifest.workspaces : manifest.workspaces?.packages ?? [];
|
|
32460
32969
|
if (!Array.isArray(declared))
|
|
32461
32970
|
throw new Error("workspaces must be a list");
|
|
@@ -32468,14 +32977,13 @@ function reviewWorkspacePackages(root) {
|
|
|
32468
32977
|
const parent = /^([^*?[\]{}!]+)\/\*$/.exec(pattern)?.[1];
|
|
32469
32978
|
if (parent === undefined)
|
|
32470
32979
|
throw new Error(`unsupported workspace pattern: ${entry}`);
|
|
32471
|
-
return
|
|
32980
|
+
return readdirSync7(join7(root, parent), { withFileTypes: true }).filter((child) => child.isDirectory() && existsSync8(join7(root, parent, child.name, "package.json"))).map((child) => `${parent}/${child.name}`);
|
|
32472
32981
|
});
|
|
32473
32982
|
const packages = directories.flatMap((directory) => {
|
|
32474
|
-
const packageManifest = JSON.parse(
|
|
32983
|
+
const packageManifest = JSON.parse(readFileSync10(join7(root, ...directory.split("/"), "package.json"), "utf8"));
|
|
32475
32984
|
if (typeof packageManifest.name !== "string")
|
|
32476
32985
|
return [];
|
|
32477
|
-
|
|
32478
|
-
return [{ name: packageManifest.name, root: directory, exports }];
|
|
32986
|
+
return [{ name: packageManifest.name, root: directory, exports: normalizePackageExports(packageManifest.exports, `${directory}/package.json`) }];
|
|
32479
32987
|
});
|
|
32480
32988
|
return { packages: packages.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0), resolved: true };
|
|
32481
32989
|
} catch {
|
|
@@ -32497,7 +33005,7 @@ function modelNodes(files) {
|
|
|
32497
33005
|
function readWorktreeFiles(root) {
|
|
32498
33006
|
let output;
|
|
32499
33007
|
try {
|
|
32500
|
-
output =
|
|
33008
|
+
output = execFileSync4("git", ["ls-files", "--cached", "--others", "--exclude-standard", "-z"], {
|
|
32501
33009
|
cwd: root,
|
|
32502
33010
|
encoding: "utf8",
|
|
32503
33011
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -32513,7 +33021,7 @@ function countFilesOutsideHead(root) {
|
|
|
32513
33021
|
return readWorktreeFiles(root).filter((path) => !head.has(path)).length;
|
|
32514
33022
|
}
|
|
32515
33023
|
function declaredWorkspacePackages(root) {
|
|
32516
|
-
return existsSync8(
|
|
33024
|
+
return existsSync8(join7(root, "package.json")) ? readWorkspacePackages(root) : [];
|
|
32517
33025
|
}
|
|
32518
33026
|
function assertRequestedStateIsCurrent(request, worktree) {
|
|
32519
33027
|
if (request.expectedHeadSha !== undefined && request.expectedHeadSha !== worktree.headSha) {
|
|
@@ -32525,13 +33033,13 @@ function assertRequestedStateIsCurrent(request, worktree) {
|
|
|
32525
33033
|
}
|
|
32526
33034
|
var REFACTOR_NAMESPACE_MANIFEST_PATH = ".archcontext/manifest.yaml";
|
|
32527
33035
|
function readRefactorNamespace(root) {
|
|
32528
|
-
const path =
|
|
33036
|
+
const path = join7(root, REFACTOR_NAMESPACE_MANIFEST_PATH);
|
|
32529
33037
|
if (!existsSync8(path)) {
|
|
32530
33038
|
throw new RefactorScanError("AC_MODEL_ADOPTION_REQUIRED", `${REFACTOR_NAMESPACE_MANIFEST_PATH} is missing; refactor recommendations are scoped by its product.id; run archctx init`, "product-id-missing");
|
|
32531
33039
|
}
|
|
32532
33040
|
let manifest;
|
|
32533
33041
|
try {
|
|
32534
|
-
manifest = parseJsonOrStableYaml(
|
|
33042
|
+
manifest = parseJsonOrStableYaml(readFileSync10(path, "utf8"), REFACTOR_NAMESPACE_MANIFEST_PATH);
|
|
32535
33043
|
} catch (error) {
|
|
32536
33044
|
throw new RefactorScanError("AC_SCHEMA_INVALID", `${REFACTOR_NAMESPACE_MANIFEST_PATH} is unreadable: ${error instanceof Error ? error.message : String(error)}`, "product-id-invalid");
|
|
32537
33045
|
}
|
|
@@ -32573,7 +33081,7 @@ function readCodeFacts(root, worktreeDigest, edgeLimit) {
|
|
|
32573
33081
|
}
|
|
32574
33082
|
function attestCodeGraphBinary(root) {
|
|
32575
33083
|
const invocation = codeGraphCliInvocation(CODEGRAPH_BINARY, root);
|
|
32576
|
-
const version =
|
|
33084
|
+
const version = execFileSync4(invocation.command, [...invocation.argsPrefix, "--version"], {
|
|
32577
33085
|
cwd: root,
|
|
32578
33086
|
encoding: "utf8",
|
|
32579
33087
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -32582,7 +33090,7 @@ function attestCodeGraphBinary(root) {
|
|
|
32582
33090
|
const binaryPath = invocation.argsPrefix[0] ?? invocation.command;
|
|
32583
33091
|
return {
|
|
32584
33092
|
version,
|
|
32585
|
-
binaryDigest: `sha256:${
|
|
33093
|
+
binaryDigest: `sha256:${createHash9("sha256").update(readFileSync10(binaryPath)).digest("hex")}`
|
|
32586
33094
|
};
|
|
32587
33095
|
}
|
|
32588
33096
|
|
|
@@ -32679,8 +33187,8 @@ function unavailable2(reasons) {
|
|
|
32679
33187
|
// packages/local-runtime/runtime-daemon/src/docs-anchors.ts
|
|
32680
33188
|
init_src();
|
|
32681
33189
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
32682
|
-
import { readFileSync as
|
|
32683
|
-
import { resolve as
|
|
33190
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
33191
|
+
import { resolve as resolve16 } from "node:path";
|
|
32684
33192
|
|
|
32685
33193
|
// packages/local-runtime/runtime-daemon/src/projection-service.ts
|
|
32686
33194
|
init_src();
|
|
@@ -33957,8 +34465,8 @@ class ChangeSetRecoveryUnresolvedError extends FailureError {
|
|
|
33957
34465
|
|
|
33958
34466
|
// packages/local-runtime/runtime-daemon/src/projection-freshness.ts
|
|
33959
34467
|
init_src();
|
|
33960
|
-
import { readFileSync as
|
|
33961
|
-
import { posix as posix3, resolve as
|
|
34468
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
34469
|
+
import { posix as posix3, resolve as resolve14 } from "node:path";
|
|
33962
34470
|
function evaluateProjectionFreshness(input) {
|
|
33963
34471
|
const { model, profile, manifest, sourceFootprints, scope } = input;
|
|
33964
34472
|
return scope.kind === "tree" ? evaluateArchitectureProjectionSnapshotFreshness({ model, profile, manifest, sourceFootprints, currentSourceTreeDigest: scope.currentSourceTreeDigest }) : evaluateArchitectureProjectionFreshness({ model, profile, manifest, sourceFootprints, nodeIds: scope.nodeIds });
|
|
@@ -33983,7 +34491,7 @@ function measureProjectionFreshness(root, options = {}) {
|
|
|
33983
34491
|
assertProjectionFreshnessChangedPaths(options.changedPaths);
|
|
33984
34492
|
const manifest = options.manifest ?? loadArchitectureProjectionManifestStamps(root);
|
|
33985
34493
|
if (manifest.status === "manifest-unreadable") {
|
|
33986
|
-
assertArchitectureDocsProjectionManifestAccepted(
|
|
34494
|
+
assertArchitectureDocsProjectionManifestAccepted(readFileSync11(resolve14(root, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH), "utf8"));
|
|
33987
34495
|
}
|
|
33988
34496
|
const model = loadNativeModelFromArchContext(root);
|
|
33989
34497
|
const profile = manifest.status === "present" ? loadArchitectureDocumentationProfile(root) : undefined;
|
|
@@ -34129,15 +34637,15 @@ function publicOperationResult(requestId, result) {
|
|
|
34129
34637
|
}
|
|
34130
34638
|
|
|
34131
34639
|
// packages/local-runtime/runtime-daemon/src/projection-service.ts
|
|
34132
|
-
import { existsSync as existsSync9, readFileSync as
|
|
34133
|
-
import { resolve as
|
|
34640
|
+
import { existsSync as existsSync9, readFileSync as readFileSync12 } from "node:fs";
|
|
34641
|
+
import { resolve as resolve15 } from "node:path";
|
|
34134
34642
|
|
|
34135
34643
|
// packages/local-runtime/runtime-daemon/src/projection-inputs.ts
|
|
34136
|
-
import { execFileSync as
|
|
34644
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
34137
34645
|
init_src();
|
|
34138
34646
|
function readCurrentBranch(root) {
|
|
34139
34647
|
try {
|
|
34140
|
-
const branch =
|
|
34648
|
+
const branch = execFileSync5("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
34141
34649
|
cwd: root,
|
|
34142
34650
|
encoding: "utf8",
|
|
34143
34651
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -34453,7 +34961,7 @@ function architectureModelIgnoredEnvelope(requestId, root) {
|
|
|
34453
34961
|
});
|
|
34454
34962
|
}
|
|
34455
34963
|
function committedArchitectureDocsProfile(root) {
|
|
34456
|
-
return existsSync9(
|
|
34964
|
+
return existsSync9(resolve15(root, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH)) ? loadArchitectureDocumentationProfile(root) : "default";
|
|
34457
34965
|
}
|
|
34458
34966
|
function withProjectionMetadata(envelope, provenance, runtimeSnapshot, majorChange, refreshSignals, receiptDigest) {
|
|
34459
34967
|
if (!envelope.ok)
|
|
@@ -34867,8 +35375,8 @@ function runProjectionCheckCommandUnchecked(request, root) {
|
|
|
34867
35375
|
return publicFailureEnvelope("projection.run", "AC_SCHEMA_INVALID", "projection-check-mode-invalid");
|
|
34868
35376
|
}
|
|
34869
35377
|
const manifestPath = ".archcontext/manifest.yaml";
|
|
34870
|
-
if (existsSync9(
|
|
34871
|
-
const diagnostics = manifestDecisionDiagnostics([{ path: manifestPath, body:
|
|
35378
|
+
if (existsSync9(resolve15(root, manifestPath))) {
|
|
35379
|
+
const diagnostics = manifestDecisionDiagnostics([{ path: manifestPath, body: readFileSync12(resolve15(root, manifestPath), "utf8") }]);
|
|
34872
35380
|
if (diagnostics.length)
|
|
34873
35381
|
return publicFailureEnvelope("projection.run", "AC_SCHEMA_INVALID", "native-context-model-invalid", { path: manifestPath, invariant: diagnostics[0] });
|
|
34874
35382
|
}
|
|
@@ -35758,7 +36266,7 @@ function fileContentReader(root) {
|
|
|
35758
36266
|
return (path) => {
|
|
35759
36267
|
let content = cache.get(path);
|
|
35760
36268
|
if (content === undefined) {
|
|
35761
|
-
content =
|
|
36269
|
+
content = readFileSync13(resolve16(root, path), "utf8").replace(/\r\n/g, `
|
|
35762
36270
|
`);
|
|
35763
36271
|
cache.set(path, content);
|
|
35764
36272
|
}
|
|
@@ -35826,7 +36334,7 @@ function proseAnchorSymbols(reader, files, contents) {
|
|
|
35826
36334
|
|
|
35827
36335
|
// packages/local-runtime/runtime-daemon/src/architecture-debt.ts
|
|
35828
36336
|
import { existsSync as existsSync10 } from "node:fs";
|
|
35829
|
-
import { join as
|
|
36337
|
+
import { join as join8 } from "node:path";
|
|
35830
36338
|
function readArchitectureDebt(root, input = {}) {
|
|
35831
36339
|
try {
|
|
35832
36340
|
const { evidence } = readArchitectureDebtEvidence(root, input);
|
|
@@ -35852,7 +36360,7 @@ function readArchitectureDebtEvidence(root, input) {
|
|
|
35852
36360
|
const changedPaths = [...new Set(input.changedPaths ?? [])].sort();
|
|
35853
36361
|
if (changedPaths.some((path) => !isRepoRelativePosixPath(path)))
|
|
35854
36362
|
throw new ArchitectureDebtReadError("AC_SCHEMA_INVALID", "changedPaths must contain repository-relative POSIX paths", "changed-path-invalid");
|
|
35855
|
-
if (!existsSync10(
|
|
36363
|
+
if (!existsSync10(join8(root, ".archcontext/manifest.yaml")))
|
|
35856
36364
|
throw new ArchitectureDebtReadError("AC_MODEL_ADOPTION_REQUIRED", "Architecture debt requires an adopted architecture model", "model-missing");
|
|
35857
36365
|
const model = loadNativeModelFromArchContext(root);
|
|
35858
36366
|
const files = listGitVisibleFiles(root);
|
|
@@ -35995,7 +36503,7 @@ function runNativeContextCommand(args, cwd, reader = exportNativeContext) {
|
|
|
35995
36503
|
// packages/surfaces/cli/src/ref-impact.ts
|
|
35996
36504
|
init_src();
|
|
35997
36505
|
import { openSync as openSync5, closeSync as closeSync5, readSync as readSync3 } from "node:fs";
|
|
35998
|
-
import { resolve as
|
|
36506
|
+
import { resolve as resolve17 } from "node:path";
|
|
35999
36507
|
var invalid2 = (category) => {
|
|
36000
36508
|
throw new NativeContextError("native-context-arguments-invalid", { category });
|
|
36001
36509
|
};
|
|
@@ -36038,7 +36546,7 @@ function runRefImpactCommand(args, cwd, reader = readRefImpact) {
|
|
|
36038
36546
|
let text;
|
|
36039
36547
|
let fd;
|
|
36040
36548
|
try {
|
|
36041
|
-
fd = path === "-" ? 0 : openSync5(
|
|
36549
|
+
fd = path === "-" ? 0 : openSync5(resolve17(cwd, path), "r");
|
|
36042
36550
|
const bytes = Buffer.alloc(REF_IMPACT_LIMITS.diffBytes + 1);
|
|
36043
36551
|
let length = 0;
|
|
36044
36552
|
while (length < bytes.length) {
|
|
@@ -36074,6 +36582,31 @@ function runRefImpactCommand(args, cwd, reader = readRefImpact) {
|
|
|
36074
36582
|
}
|
|
36075
36583
|
}
|
|
36076
36584
|
|
|
36585
|
+
// packages/surfaces/cli/src/architecture-history.ts
|
|
36586
|
+
init_src();
|
|
36587
|
+
function runArchitectureHistoryCommand(args, cwd) {
|
|
36588
|
+
if (args.includes("--help") || args.includes("-h"))
|
|
36589
|
+
return okEnvelope("history", { usage: "archctx history [--ref <rev>] [--format json|mermaid] [--offset <n>] [--limit <n>] --json" });
|
|
36590
|
+
const values = new Map;
|
|
36591
|
+
for (let i = 0;i < args.length; i++) {
|
|
36592
|
+
const flag = args[i];
|
|
36593
|
+
if (flag === "--json")
|
|
36594
|
+
continue;
|
|
36595
|
+
if (!["--ref", "--format", "--offset", "--limit"].includes(flag) || values.has(flag) || args[i + 1] === undefined)
|
|
36596
|
+
return errorEnvelope("history", "AC_SCHEMA_INVALID", "Invalid history arguments", "cli-input-invalid");
|
|
36597
|
+
values.set(flag, args[++i]);
|
|
36598
|
+
}
|
|
36599
|
+
const format = values.get("--format") ?? "json", offsetText = values.get("--offset") ?? "0", limitText = values.get("--limit") ?? "200";
|
|
36600
|
+
if (!/^[0-9]+$/.test(offsetText) || !/^[0-9]+$/.test(limitText) || !Number.isSafeInteger(Number(offsetText)) || !Number.isSafeInteger(Number(limitText)) || Number(limitText) > 1000 || !["json", "mermaid"].includes(format))
|
|
36601
|
+
return errorEnvelope("history", "AC_SCHEMA_INVALID", "Invalid history arguments", "cli-input-invalid");
|
|
36602
|
+
try {
|
|
36603
|
+
const history = readArchitectureHistory(cwd, { ref: values.get("--ref"), offset: Number(offsetText), limit: Number(limitText) });
|
|
36604
|
+
return okEnvelope("history", format === "mermaid" ? projectHistoryMermaid(history) : history);
|
|
36605
|
+
} catch (error) {
|
|
36606
|
+
return toEnvelope("history", error, "cli");
|
|
36607
|
+
}
|
|
36608
|
+
}
|
|
36609
|
+
|
|
36077
36610
|
// packages/local-runtime/runtime-daemon/src/index.ts
|
|
36078
36611
|
init_src();
|
|
36079
36612
|
|
|
@@ -36110,7 +36643,7 @@ async function exportChangeSetReceipt(store, root, journalId) {
|
|
|
36110
36643
|
// packages/local-runtime/runtime-daemon/src/architecture-debt.ts
|
|
36111
36644
|
init_src();
|
|
36112
36645
|
import { existsSync as existsSync11 } from "node:fs";
|
|
36113
|
-
import { join as
|
|
36646
|
+
import { join as join9 } from "node:path";
|
|
36114
36647
|
function readArchitectureDebt2(root, input = {}) {
|
|
36115
36648
|
try {
|
|
36116
36649
|
const { evidence } = readArchitectureDebtEvidence2(root, input);
|
|
@@ -36124,7 +36657,7 @@ function readArchitectureDebt2(root, input = {}) {
|
|
|
36124
36657
|
}
|
|
36125
36658
|
function readCompleteTaskArchitectureDebt(root, practices) {
|
|
36126
36659
|
try {
|
|
36127
|
-
if (!existsSync11(
|
|
36660
|
+
if (!existsSync11(join9(root, ".archcontext/manifest.yaml"))) {
|
|
36128
36661
|
return checkedDebt2({
|
|
36129
36662
|
scope: { kind: "repository", changedPaths: [], capabilityIds: [] },
|
|
36130
36663
|
unavailable: Object.fromEntries(ARCHITECTURE_DEBT_CHECKS.map((check) => [check, ["model-not-adopted"]]))
|
|
@@ -36156,7 +36689,7 @@ function readArchitectureDebtEvidence2(root, input) {
|
|
|
36156
36689
|
const changedPaths = [...new Set(input.changedPaths ?? [])].sort();
|
|
36157
36690
|
if (changedPaths.some((path) => !isRepoRelativePosixPath(path)))
|
|
36158
36691
|
throw new ArchitectureDebtReadError2("AC_SCHEMA_INVALID", "changedPaths must contain repository-relative POSIX paths", "changed-path-invalid");
|
|
36159
|
-
if (!existsSync11(
|
|
36692
|
+
if (!existsSync11(join9(root, ".archcontext/manifest.yaml")))
|
|
36160
36693
|
throw new ArchitectureDebtReadError2("AC_MODEL_ADOPTION_REQUIRED", "Architecture debt requires an adopted architecture model", "model-missing");
|
|
36161
36694
|
const model = loadNativeModelFromArchContext(root);
|
|
36162
36695
|
const files = listGitVisibleFiles(root);
|
|
@@ -37789,8 +38322,8 @@ function validateRuntimeAgentProposalPlan(input) {
|
|
|
37789
38322
|
}
|
|
37790
38323
|
|
|
37791
38324
|
// packages/local-runtime/runtime-daemon/src/external-documentation.ts
|
|
37792
|
-
import { existsSync as existsSync14, readdirSync as
|
|
37793
|
-
import { resolve as
|
|
38325
|
+
import { existsSync as existsSync14, readdirSync as readdirSync10, readFileSync as readFileSync16, statSync as statSync4 } from "node:fs";
|
|
38326
|
+
import { resolve as resolve20 } from "node:path";
|
|
37794
38327
|
|
|
37795
38328
|
// packages/core/context-compiler/src/index.ts
|
|
37796
38329
|
init_src();
|
|
@@ -37798,11 +38331,11 @@ init_src();
|
|
|
37798
38331
|
// packages/core/practice-catalog/src/index.ts
|
|
37799
38332
|
init_src();
|
|
37800
38333
|
init_src();
|
|
37801
|
-
import { existsSync as existsSync12, lstatSync as lstatSync7, readdirSync as
|
|
37802
|
-
import { dirname as dirname6, relative as relative5, resolve as
|
|
38334
|
+
import { existsSync as existsSync12, lstatSync as lstatSync7, readdirSync as readdirSync8, readFileSync as readFileSync14, realpathSync as realpathSync6 } from "node:fs";
|
|
38335
|
+
import { dirname as dirname6, relative as relative5, resolve as resolve18, sep as sep3 } from "node:path";
|
|
37803
38336
|
import { fileURLToPath } from "node:url";
|
|
37804
38337
|
var PRACTICE_CATALOG_VERSION = "2026.06.0";
|
|
37805
|
-
var BUILTIN_PRACTICE_ASSETS_DIR =
|
|
38338
|
+
var BUILTIN_PRACTICE_ASSETS_DIR = resolve18(dirname6(fileURLToPath(import.meta.url)), "../assets");
|
|
37806
38339
|
var ALLOWED_CHECK_IDS = new Set([
|
|
37807
38340
|
"compatibility-contract-required",
|
|
37808
38341
|
"no-new-cycle",
|
|
@@ -37854,13 +38387,13 @@ var PRACTICE_ROOT_KEYS = new Set([
|
|
|
37854
38387
|
"overlay"
|
|
37855
38388
|
]);
|
|
37856
38389
|
function loadPracticeCatalog(options = {}) {
|
|
37857
|
-
const root = options.root ?
|
|
38390
|
+
const root = options.root ? resolve18(options.root) : process.cwd();
|
|
37858
38391
|
const builtInAssetsDir = options.builtInAssetsDir ?? BUILTIN_PRACTICE_ASSETS_DIR;
|
|
37859
38392
|
const errors = [];
|
|
37860
38393
|
const warnings = [];
|
|
37861
|
-
const builtIn = loadAssetFiles(
|
|
37862
|
-
const profiles = loadProfileFiles(
|
|
37863
|
-
const sources = loadSourceFiles(
|
|
38394
|
+
const builtIn = loadAssetFiles(resolve18(builtInAssetsDir, "practices"), "curated-static", errors);
|
|
38395
|
+
const profiles = loadProfileFiles(resolve18(builtInAssetsDir, "profiles"), errors);
|
|
38396
|
+
const sources = loadSourceFiles(resolve18(builtInAssetsDir, "sources"), errors);
|
|
37864
38397
|
const overlays = options.includeRepoOverlay === false ? [] : loadRepoOverlayAssets(root, errors);
|
|
37865
38398
|
const merged = mergeCatalogAssets(builtIn, overlays, errors, options.now ?? new Date().toISOString());
|
|
37866
38399
|
const sourceIds = new Set(sources.map((source) => source.id));
|
|
@@ -38046,7 +38579,7 @@ function loadProfileFiles(dir, errors) {
|
|
|
38046
38579
|
return profiles.sort((a, b) => a.id.localeCompare(b.id));
|
|
38047
38580
|
}
|
|
38048
38581
|
function loadRepoOverlayAssets(root, errors) {
|
|
38049
|
-
const overlayRoot =
|
|
38582
|
+
const overlayRoot = resolve18(root, ".archcontext/practices");
|
|
38050
38583
|
if (!existsSync12(overlayRoot))
|
|
38051
38584
|
return [];
|
|
38052
38585
|
const out = [];
|
|
@@ -38409,8 +38942,8 @@ function listDataFiles(dir, allowedRoot, errors) {
|
|
|
38409
38942
|
return;
|
|
38410
38943
|
}
|
|
38411
38944
|
if (stat.isDirectory()) {
|
|
38412
|
-
for (const entry of
|
|
38413
|
-
walk(
|
|
38945
|
+
for (const entry of readdirSync8(current, { withFileTypes: true }))
|
|
38946
|
+
walk(resolve18(current, entry.name));
|
|
38414
38947
|
return;
|
|
38415
38948
|
}
|
|
38416
38949
|
if (!/\.(ya?ml|json)$/.test(current))
|
|
@@ -38425,7 +38958,7 @@ function listDataFiles(dir, allowedRoot, errors) {
|
|
|
38425
38958
|
}
|
|
38426
38959
|
function parseDataFile(path, errors) {
|
|
38427
38960
|
try {
|
|
38428
|
-
const body =
|
|
38961
|
+
const body = readFileSync14(path, "utf8").replace(/^\uFEFF/, "").trim();
|
|
38429
38962
|
const withoutDocumentMarker = body.startsWith("---") ? body.replace(/^---\s*/, "").trim() : body;
|
|
38430
38963
|
return JSON.parse(withoutDocumentMarker);
|
|
38431
38964
|
} catch (error) {
|
|
@@ -38452,14 +38985,14 @@ function assertRealChild(root, path) {
|
|
|
38452
38985
|
}
|
|
38453
38986
|
function safeRealpath(path) {
|
|
38454
38987
|
try {
|
|
38455
|
-
return
|
|
38988
|
+
return realpathSync6.native(path);
|
|
38456
38989
|
} catch {
|
|
38457
|
-
return
|
|
38990
|
+
return resolve18(path);
|
|
38458
38991
|
}
|
|
38459
38992
|
}
|
|
38460
38993
|
function isRealChild(rootReal, pathReal) {
|
|
38461
38994
|
const rel = relative5(rootReal, pathReal);
|
|
38462
|
-
return rel === "" || !rel.startsWith("..") && !rel.includes(`..${sep3}`) && !
|
|
38995
|
+
return rel === "" || !rel.startsWith("..") && !rel.includes(`..${sep3}`) && !resolve18(rel).startsWith("..");
|
|
38463
38996
|
}
|
|
38464
38997
|
function displayPath(path) {
|
|
38465
38998
|
return path.split(sep3).join("/");
|
|
@@ -39023,8 +39556,8 @@ function checkResult(input, result) {
|
|
|
39023
39556
|
}
|
|
39024
39557
|
// packages/core/practice-engine/src/enforcement.ts
|
|
39025
39558
|
init_src();
|
|
39026
|
-
import { existsSync as existsSync13, lstatSync as lstatSync8, readdirSync as
|
|
39027
|
-
import { basename as basename4, join as
|
|
39559
|
+
import { existsSync as existsSync13, lstatSync as lstatSync8, readdirSync as readdirSync9, readFileSync as readFileSync15 } from "node:fs";
|
|
39560
|
+
import { basename as basename4, join as join10, relative as relative6, resolve as resolve19, sep as sep4 } from "node:path";
|
|
39028
39561
|
var ENFORCEMENT_RANK = { advisory: 0, checkpoint: 1, complete: 2 };
|
|
39029
39562
|
var POLICY_MODES = new Set(["advisory", "active", "fail-open", "fail-closed"]);
|
|
39030
39563
|
var DEFAULT_POLICY = {
|
|
@@ -39047,7 +39580,7 @@ function shouldEvaluatePracticeEnforcement(policy) {
|
|
|
39047
39580
|
return practiceEnforcementPolicyMode(policy) !== "advisory";
|
|
39048
39581
|
}
|
|
39049
39582
|
function loadPracticeEnforcementPolicy(root) {
|
|
39050
|
-
const path =
|
|
39583
|
+
const path = resolve19(root, ".archcontext/policies/practices.yaml");
|
|
39051
39584
|
if (!existsSync13(path))
|
|
39052
39585
|
return defaultPracticeEnforcementPolicy();
|
|
39053
39586
|
assertRepoPolicyFile(root, path, ".archcontext/policies/practices.yaml");
|
|
@@ -39055,7 +39588,7 @@ function loadPracticeEnforcementPolicy(root) {
|
|
|
39055
39588
|
return validatePracticeEnforcementPolicy(parsed, ".archcontext/policies/practices.yaml");
|
|
39056
39589
|
}
|
|
39057
39590
|
function loadPracticeWaivers(root) {
|
|
39058
|
-
const dir =
|
|
39591
|
+
const dir = resolve19(root, ".archcontext/waivers");
|
|
39059
39592
|
if (!existsSync13(dir))
|
|
39060
39593
|
return [];
|
|
39061
39594
|
const stat = lstatSync8(dir);
|
|
@@ -39065,10 +39598,10 @@ function loadPracticeWaivers(root) {
|
|
|
39065
39598
|
throw new Error("practice-waiver-path-not-directory");
|
|
39066
39599
|
const waivers = [];
|
|
39067
39600
|
const ownerRegistry = loadPracticeWaiverOwnerRegistry(root);
|
|
39068
|
-
for (const entry of
|
|
39601
|
+
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
39069
39602
|
if (!entry.isFile() || !/\.(?:ya?ml|json)$/.test(entry.name))
|
|
39070
39603
|
continue;
|
|
39071
|
-
const path =
|
|
39604
|
+
const path = join10(dir, entry.name);
|
|
39072
39605
|
const relativePath = `.archcontext/waivers/${entry.name}`;
|
|
39073
39606
|
assertRepoPolicyFile(root, path, relativePath);
|
|
39074
39607
|
waivers.push(validatePracticeWaiver(parseJsonYamlFile(path), relativePath, { allowedOwners: ownerRegistry.owners }));
|
|
@@ -39076,17 +39609,17 @@ function loadPracticeWaivers(root) {
|
|
|
39076
39609
|
return waivers.sort((left, right) => waiverDigest(left).localeCompare(waiverDigest(right)));
|
|
39077
39610
|
}
|
|
39078
39611
|
function loadPracticeWaiverOwnerRegistry(root) {
|
|
39079
|
-
const modelDir =
|
|
39612
|
+
const modelDir = resolve19(root, ".archcontext/model/nodes");
|
|
39080
39613
|
const sources = [];
|
|
39081
39614
|
const subjects = [];
|
|
39082
39615
|
if (existsSync13(modelDir)) {
|
|
39083
39616
|
if (lstatSync8(modelDir).isSymbolicLink())
|
|
39084
39617
|
throw new Error("practice-owner-registry-symlink-denied");
|
|
39085
39618
|
for (const path of collectFiles(root, ".archcontext/model/nodes")) {
|
|
39086
|
-
const absolute =
|
|
39619
|
+
const absolute = resolve19(root, path);
|
|
39087
39620
|
if (lstatSync8(absolute).isSymbolicLink())
|
|
39088
39621
|
throw new Error(`practice-owner-registry-symlink-denied: ${path}`);
|
|
39089
|
-
const body =
|
|
39622
|
+
const body = readFileSync15(absolute, "utf8");
|
|
39090
39623
|
const lifecycleOwners = extractOwnershipOwners(body, "lifecycle");
|
|
39091
39624
|
const dataOwners = extractOwnershipOwners(body, "data");
|
|
39092
39625
|
for (const kind of ["lifecycle", "data"]) {
|
|
@@ -39361,14 +39894,14 @@ function isVagueReason(reason) {
|
|
|
39361
39894
|
return /^(temporary|cleanup later|todo|tbd|later|just in case)$/i.test(trimmed);
|
|
39362
39895
|
}
|
|
39363
39896
|
function parseJsonYamlFile(path) {
|
|
39364
|
-
const body =
|
|
39897
|
+
const body = readFileSync15(path, "utf8").replace(/^\uFEFF/, "").trim();
|
|
39365
39898
|
const withoutDocumentMarker = body.startsWith("---") ? body.replace(/^---\s*/, "").trim() : body;
|
|
39366
39899
|
return JSON.parse(withoutDocumentMarker);
|
|
39367
39900
|
}
|
|
39368
39901
|
function collectFiles(root, relativeDir) {
|
|
39369
|
-
const dir =
|
|
39902
|
+
const dir = resolve19(root, relativeDir);
|
|
39370
39903
|
const out = [];
|
|
39371
|
-
for (const entry of
|
|
39904
|
+
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
39372
39905
|
const child = `${relativeDir}/${entry.name}`;
|
|
39373
39906
|
if (entry.isDirectory())
|
|
39374
39907
|
out.push(...collectFiles(root, child));
|
|
@@ -39454,8 +39987,8 @@ function assertRepoPolicyFile(root, path, relativePath) {
|
|
|
39454
39987
|
assertRepoRelativePath(relativePath);
|
|
39455
39988
|
if (lstatSync8(path).isSymbolicLink())
|
|
39456
39989
|
throw new Error(`practice-policy-symlink-denied: ${relativePath}`);
|
|
39457
|
-
const rootResolved =
|
|
39458
|
-
const pathResolved =
|
|
39990
|
+
const rootResolved = resolve19(root);
|
|
39991
|
+
const pathResolved = resolve19(path);
|
|
39459
39992
|
const rel = relative6(rootResolved, pathResolved);
|
|
39460
39993
|
if (rel === "" || rel.startsWith("..") || rel.includes(`..${sep4}`))
|
|
39461
39994
|
throw new Error(`practice-policy-path-escape: ${relativePath}`);
|
|
@@ -40815,7 +41348,7 @@ function readExactPackageVersion(root, packageName) {
|
|
|
40815
41348
|
return;
|
|
40816
41349
|
}
|
|
40817
41350
|
function readPackageLockExactVersion(root, packageName) {
|
|
40818
|
-
const lock = readJsonFile(
|
|
41351
|
+
const lock = readJsonFile(resolve20(root, "package-lock.json"));
|
|
40819
41352
|
if (!lock || typeof lock !== "object" || Array.isArray(lock))
|
|
40820
41353
|
return;
|
|
40821
41354
|
const packages = lock.packages;
|
|
@@ -40833,7 +41366,7 @@ function readPackageLockExactVersion(root, packageName) {
|
|
|
40833
41366
|
return;
|
|
40834
41367
|
}
|
|
40835
41368
|
function packageManifestPaths(root) {
|
|
40836
|
-
const paths = [
|
|
41369
|
+
const paths = [resolve20(root, "package.json")];
|
|
40837
41370
|
const rootManifest = readJsonFile(paths[0]);
|
|
40838
41371
|
for (const pattern of workspacePatternsFromManifest(rootManifest)) {
|
|
40839
41372
|
for (const path of expandWorkspacePackageJson(root, pattern))
|
|
@@ -40856,15 +41389,15 @@ function expandWorkspacePackageJson(root, pattern) {
|
|
|
40856
41389
|
if (pattern.includes("**") || pattern.startsWith("/") || pattern.includes("\\"))
|
|
40857
41390
|
return [];
|
|
40858
41391
|
if (!pattern.includes("*")) {
|
|
40859
|
-
const path =
|
|
41392
|
+
const path = resolve20(root, pattern, "package.json");
|
|
40860
41393
|
return existsSync14(path) ? [path] : [];
|
|
40861
41394
|
}
|
|
40862
41395
|
if (!pattern.endsWith("/*"))
|
|
40863
41396
|
return [];
|
|
40864
|
-
const base =
|
|
41397
|
+
const base = resolve20(root, pattern.slice(0, -2));
|
|
40865
41398
|
if (!existsSync14(base) || !statSync4(base).isDirectory())
|
|
40866
41399
|
return [];
|
|
40867
|
-
return
|
|
41400
|
+
return readdirSync10(base, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => resolve20(base, entry.name, "package.json")).filter((path) => existsSync14(path));
|
|
40868
41401
|
}
|
|
40869
41402
|
function exactVersionFromManifest(manifest, packageName) {
|
|
40870
41403
|
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest))
|
|
@@ -40883,7 +41416,7 @@ function readJsonFile(path) {
|
|
|
40883
41416
|
if (!existsSync14(path))
|
|
40884
41417
|
return;
|
|
40885
41418
|
try {
|
|
40886
|
-
return JSON.parse(
|
|
41419
|
+
return JSON.parse(readFileSync16(path, "utf8"));
|
|
40887
41420
|
} catch {
|
|
40888
41421
|
return;
|
|
40889
41422
|
}
|
|
@@ -40906,7 +41439,7 @@ function readContext7LockfileState(root) {
|
|
|
40906
41439
|
expectedHash: "missing"
|
|
40907
41440
|
};
|
|
40908
41441
|
}
|
|
40909
|
-
const body =
|
|
41442
|
+
const body = readFileSync16(path, "utf8");
|
|
40910
41443
|
const parsed = JSON.parse(body);
|
|
40911
41444
|
if (parsed.schemaVersion !== CONTEXT7_LOCKFILE_SCHEMA_VERSION || parsed.provider !== "context7" || !Array.isArray(parsed.libraries)) {
|
|
40912
41445
|
throw new Error("Invalid Context7 lockfile");
|
|
@@ -40942,7 +41475,7 @@ function writeContext7Lockfile(root, lock, expectedHash) {
|
|
|
40942
41475
|
|
|
40943
41476
|
// packages/core/application/src/index.ts
|
|
40944
41477
|
import { existsSync as existsSync15, statSync as statSync5 } from "node:fs";
|
|
40945
|
-
import { extname, resolve as
|
|
41478
|
+
import { extname, resolve as resolve21 } from "node:path";
|
|
40946
41479
|
init_src();
|
|
40947
41480
|
async function prepareTask(input) {
|
|
40948
41481
|
const confidence = computeRefactorConfidence({
|
|
@@ -41135,7 +41668,7 @@ function classifyCheckpointPath(root, path) {
|
|
|
41135
41668
|
return "ignored";
|
|
41136
41669
|
if (isGeneratedCheckpointPath(path))
|
|
41137
41670
|
return "generated";
|
|
41138
|
-
const absolute =
|
|
41671
|
+
const absolute = resolve21(root, path);
|
|
41139
41672
|
if (!existsSync15(absolute))
|
|
41140
41673
|
return "deleted";
|
|
41141
41674
|
try {
|
|
@@ -41433,14 +41966,14 @@ function parsePracticeCheckpointBaselineState(state, repositoryId, taskSessionId
|
|
|
41433
41966
|
init_src();
|
|
41434
41967
|
init_src();
|
|
41435
41968
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
41436
|
-
import { chmodSync as chmodSync3, existsSync as existsSync18, lstatSync as lstatSync9, mkdirSync as
|
|
41969
|
+
import { chmodSync as chmodSync3, existsSync as existsSync18, lstatSync as lstatSync9, mkdirSync as mkdirSync7, mkdtempSync as mkdtempSync3, readdirSync as readdirSync11, readFileSync as readFileSync18, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
41437
41970
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
41438
|
-
import { basename as basename5, dirname as dirname7, join as
|
|
41971
|
+
import { basename as basename5, dirname as dirname7, join as join13, resolve as resolve22, sep as sep5 } from "node:path";
|
|
41439
41972
|
|
|
41440
41973
|
// packages/local-runtime/control-file-security/src/index.ts
|
|
41441
|
-
import { execFileSync as
|
|
41442
|
-
import { closeSync as closeSync6, constants as constants2, existsSync as existsSync16, fstatSync as fstatSync3, openSync as openSync6, readFileSync as
|
|
41443
|
-
import { join as
|
|
41974
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
41975
|
+
import { closeSync as closeSync6, constants as constants2, existsSync as existsSync16, fstatSync as fstatSync3, openSync as openSync6, readFileSync as readFileSync17, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
41976
|
+
import { join as join12 } from "node:path";
|
|
41444
41977
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
41445
41978
|
var WINDOWS_CREATE_TIMEOUT_MS = 60000;
|
|
41446
41979
|
var WINDOWS_READ_TIMEOUT_MS = 1e4;
|
|
@@ -41524,7 +42057,7 @@ function windowsControlFile(operation, path, body) {
|
|
|
41524
42057
|
let output;
|
|
41525
42058
|
const startedAt = performance.now();
|
|
41526
42059
|
try {
|
|
41527
|
-
output =
|
|
42060
|
+
output = execFileSync6(join12(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), [
|
|
41528
42061
|
"-NoLogo",
|
|
41529
42062
|
"-NoProfile",
|
|
41530
42063
|
"-NonInteractive",
|
|
@@ -41579,7 +42112,7 @@ function createPrivateControlFile(path, body) {
|
|
|
41579
42112
|
}
|
|
41580
42113
|
const fd = openSync6(path, "wx", 384);
|
|
41581
42114
|
try {
|
|
41582
|
-
|
|
42115
|
+
writeFileSync5(fd, body, "utf8");
|
|
41583
42116
|
} catch (error) {
|
|
41584
42117
|
rmSync6(path, { force: true });
|
|
41585
42118
|
throw error;
|
|
@@ -41599,7 +42132,7 @@ function readPrivateControlFile(path) {
|
|
|
41599
42132
|
const stat = fstatSync3(fd);
|
|
41600
42133
|
if (!stat.isFile() || (stat.mode & 63) !== 0)
|
|
41601
42134
|
return;
|
|
41602
|
-
return
|
|
42135
|
+
return readFileSync17(fd, "utf8");
|
|
41603
42136
|
} finally {
|
|
41604
42137
|
closeSync6(fd);
|
|
41605
42138
|
}
|
|
@@ -42136,111 +42669,6 @@ function daemonReadiness(root) {
|
|
|
42136
42669
|
|
|
42137
42670
|
// packages/local-runtime/runtime-daemon/src/daemon-control.ts
|
|
42138
42671
|
import { existsSync as existsSync17, openSync as openSync7, rmSync as rmSync7 } from "node:fs";
|
|
42139
|
-
|
|
42140
|
-
// packages/local-runtime/runtime-state-paths/src/index.ts
|
|
42141
|
-
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
42142
|
-
import { createHash as createHash9 } from "node:crypto";
|
|
42143
|
-
import { readdirSync as readdirSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
42144
|
-
import { homedir } from "node:os";
|
|
42145
|
-
import { isAbsolute as isAbsolute5, join as join11, resolve as resolve21 } from "node:path";
|
|
42146
|
-
var ARCHCONTEXT_STATE_DIR_ENV = "ARCHCONTEXT_STATE_DIR";
|
|
42147
|
-
var ARCHCONTEXT_LOCAL_STORE_PATH_ENV = "ARCHCONTEXT_LOCAL_STORE_PATH";
|
|
42148
|
-
function defaultArchContextStateRoot(env = process.env, platform = process.platform, home = homedir()) {
|
|
42149
|
-
const override = env[ARCHCONTEXT_STATE_DIR_ENV];
|
|
42150
|
-
if (override)
|
|
42151
|
-
return { path: resolve21(override), source: "environment" };
|
|
42152
|
-
if (platform === "darwin")
|
|
42153
|
-
return { path: join11(home, "Library", "Application Support", "ArchContext"), source: "os-user-data" };
|
|
42154
|
-
if (platform === "win32")
|
|
42155
|
-
return { path: join11(env.LOCALAPPDATA ?? join11(home, "AppData", "Local"), "ArchContext"), source: "os-user-data" };
|
|
42156
|
-
return { path: join11(env.XDG_DATA_HOME ?? join11(home, ".local", "share"), "archcontext"), source: "os-user-data" };
|
|
42157
|
-
}
|
|
42158
|
-
function runtimeStatePaths(root = process.cwd(), env = process.env) {
|
|
42159
|
-
const repositoryRoot = readGitPath(root, ["rev-parse", "--show-toplevel"]) ?? root;
|
|
42160
|
-
const canonicalRepositoryRoot = canonicalPath(repositoryRoot);
|
|
42161
|
-
const gitCommonDir = readGitPath(canonicalRepositoryRoot, ["rev-parse", "--git-common-dir"]);
|
|
42162
|
-
const repositoryAnchor = canonicalPath(gitCommonDir ? resolveMaybeRelative(canonicalRepositoryRoot, gitCommonDir) : canonicalRepositoryRoot);
|
|
42163
|
-
const workspaceAnchor = canonicalRepositoryRoot;
|
|
42164
|
-
const storageRepositoryId = stableStorageId("repo", repositoryAnchor);
|
|
42165
|
-
const storageWorkspaceId = stableStorageId("ws", workspaceAnchor);
|
|
42166
|
-
const stateRoot = defaultArchContextStateRoot(env);
|
|
42167
|
-
const repositoryStateDir = join11(stateRoot.path, REPOSITORIES_DIR, storageRepositoryId);
|
|
42168
|
-
const workspaceStateDir = join11(repositoryStateDir, WORKTREES_DIR, storageWorkspaceId);
|
|
42169
|
-
const legacyControlDir = resolve21(canonicalRepositoryRoot, ".archcontext", ".local");
|
|
42170
|
-
return {
|
|
42171
|
-
schemaVersion: "archcontext.runtime-state-paths/v1",
|
|
42172
|
-
stateRoot: stateRoot.path,
|
|
42173
|
-
source: stateRoot.source,
|
|
42174
|
-
repositoryRoot: canonicalRepositoryRoot,
|
|
42175
|
-
repositoryAnchor,
|
|
42176
|
-
workspaceAnchor,
|
|
42177
|
-
storageRepositoryId,
|
|
42178
|
-
storageWorkspaceId,
|
|
42179
|
-
repositoryId: storageRepositoryId,
|
|
42180
|
-
workspaceId: storageWorkspaceId,
|
|
42181
|
-
repositoryStateDir,
|
|
42182
|
-
workspaceStateDir,
|
|
42183
|
-
sharedCacheDir: join11(repositoryStateDir, "shared", "cache"),
|
|
42184
|
-
localStorePath: env[ARCHCONTEXT_LOCAL_STORE_PATH_ENV] ?? join11(workspaceStateDir, "runtime.sqlite"),
|
|
42185
|
-
...daemonControlPaths(workspaceStateDir),
|
|
42186
|
-
developerReviewRunStateDir: join11(workspaceStateDir, "developer-review-runs"),
|
|
42187
|
-
legacyControlDir,
|
|
42188
|
-
legacyLocalStorePath: join11(legacyControlDir, "runtime.sqlite")
|
|
42189
|
-
};
|
|
42190
|
-
}
|
|
42191
|
-
var REPOSITORIES_DIR = "repositories";
|
|
42192
|
-
var WORKTREES_DIR = "worktrees";
|
|
42193
|
-
function daemonControlPaths(workspaceStateDir) {
|
|
42194
|
-
return {
|
|
42195
|
-
daemonConnectionPath: join11(workspaceStateDir, "archctxd.json"),
|
|
42196
|
-
daemonLockPath: join11(workspaceStateDir, "archctxd.lock"),
|
|
42197
|
-
daemonLogPath: join11(workspaceStateDir, "archctxd.log")
|
|
42198
|
-
};
|
|
42199
|
-
}
|
|
42200
|
-
function listWorkspaceStateDirs(stateRoot) {
|
|
42201
|
-
return listDirectoryNames(join11(stateRoot, REPOSITORIES_DIR)).flatMap((storageRepositoryId) => listDirectoryNames(join11(stateRoot, REPOSITORIES_DIR, storageRepositoryId, WORKTREES_DIR)).map((storageWorkspaceId) => ({
|
|
42202
|
-
storageRepositoryId,
|
|
42203
|
-
storageWorkspaceId,
|
|
42204
|
-
workspaceStateDir: join11(stateRoot, REPOSITORIES_DIR, storageRepositoryId, WORKTREES_DIR, storageWorkspaceId)
|
|
42205
|
-
})));
|
|
42206
|
-
}
|
|
42207
|
-
function listDirectoryNames(path) {
|
|
42208
|
-
try {
|
|
42209
|
-
return readdirSync10(path, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
42210
|
-
} catch (error) {
|
|
42211
|
-
if (error.code === "ENOENT")
|
|
42212
|
-
return [];
|
|
42213
|
-
throw error;
|
|
42214
|
-
}
|
|
42215
|
-
}
|
|
42216
|
-
function readGitPath(root, args) {
|
|
42217
|
-
try {
|
|
42218
|
-
const value = execFileSync6("git", args, {
|
|
42219
|
-
cwd: root,
|
|
42220
|
-
encoding: "utf8",
|
|
42221
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
42222
|
-
}).trim();
|
|
42223
|
-
return value.length > 0 ? value : undefined;
|
|
42224
|
-
} catch {
|
|
42225
|
-
return;
|
|
42226
|
-
}
|
|
42227
|
-
}
|
|
42228
|
-
function resolveMaybeRelative(base, path) {
|
|
42229
|
-
return isAbsolute5(path) ? resolve21(path) : resolve21(base, path);
|
|
42230
|
-
}
|
|
42231
|
-
function canonicalPath(path) {
|
|
42232
|
-
const resolved = resolve21(path);
|
|
42233
|
-
try {
|
|
42234
|
-
return realpathSync6.native(resolved);
|
|
42235
|
-
} catch {
|
|
42236
|
-
return resolved;
|
|
42237
|
-
}
|
|
42238
|
-
}
|
|
42239
|
-
function stableStorageId(prefix, value) {
|
|
42240
|
-
return `${prefix}.${createHash9("sha256").update(value).digest("hex").slice(0, 16)}`;
|
|
42241
|
-
}
|
|
42242
|
-
|
|
42243
|
-
// packages/local-runtime/runtime-daemon/src/daemon-control.ts
|
|
42244
42672
|
function defaultDeveloperReviewRunStateDir(root = process.cwd()) {
|
|
42245
42673
|
return runtimeStatePaths(root).developerReviewRunStateDir;
|
|
42246
42674
|
}
|
|
@@ -42453,9 +42881,9 @@ class DeveloperReviewRunService {
|
|
|
42453
42881
|
challengeId: input.challenge.challengeId,
|
|
42454
42882
|
tempRoot: input.tempRoot
|
|
42455
42883
|
});
|
|
42456
|
-
|
|
42457
|
-
|
|
42458
|
-
|
|
42884
|
+
mkdirSync7(paths.stateDir, { recursive: true });
|
|
42885
|
+
mkdirSync7(paths.runRoot, { recursive: true });
|
|
42886
|
+
mkdirSync7(paths.worktreeTempRoot, { recursive: true });
|
|
42459
42887
|
const createdAt = this.clock();
|
|
42460
42888
|
writeDeveloperReviewRunOwnerMarker({
|
|
42461
42889
|
runRoot: paths.runRoot,
|
|
@@ -42579,7 +43007,7 @@ class DeveloperReviewRunService {
|
|
|
42579
43007
|
this.assertRunning();
|
|
42580
43008
|
const sourceRoot = findRepositoryRoot(input.repositoryRoot);
|
|
42581
43009
|
const safeChallengeId = safeControlFileSegment(input.challengeId);
|
|
42582
|
-
const manifestPath =
|
|
43010
|
+
const manifestPath = join13(defaultDeveloperReviewRunStateDir(sourceRoot), `${safeChallengeId}.json`);
|
|
42583
43011
|
const manifest = readDeveloperReviewRunManifest(manifestPath);
|
|
42584
43012
|
if (!manifest)
|
|
42585
43013
|
throw developerReviewRunNotOwned("persisted-manifest-missing");
|
|
@@ -42606,7 +43034,7 @@ class DeveloperReviewRunService {
|
|
|
42606
43034
|
for (const entry of readdirSync11(stateDir).sort()) {
|
|
42607
43035
|
if (!entry.endsWith(".json"))
|
|
42608
43036
|
continue;
|
|
42609
|
-
const manifestPath =
|
|
43037
|
+
const manifestPath = join13(stateDir, entry);
|
|
42610
43038
|
const stats = lstatIfExists2(manifestPath);
|
|
42611
43039
|
if (!stats || !stats.isFile()) {
|
|
42612
43040
|
recovery.rejected.push(`${entry}: not-a-regular-file`);
|
|
@@ -42634,7 +43062,7 @@ class DeveloperReviewRunService {
|
|
|
42634
43062
|
for (const entry of readdirSync11(stateDir).sort()) {
|
|
42635
43063
|
if (!entry.endsWith(".lock"))
|
|
42636
43064
|
continue;
|
|
42637
|
-
const lockPath =
|
|
43065
|
+
const lockPath = join13(stateDir, entry);
|
|
42638
43066
|
const stats = lstatIfExists2(lockPath);
|
|
42639
43067
|
if (!stats || !stats.isFile()) {
|
|
42640
43068
|
recovery.rejected.push(`${entry}: not-a-regular-file`);
|
|
@@ -42663,15 +43091,15 @@ function createDeveloperReviewRunPaths(input) {
|
|
|
42663
43091
|
const runId = `${safeChallengeId}-${randomBytes2(6).toString("hex")}`;
|
|
42664
43092
|
const stateDir = defaultDeveloperReviewRunStateDir(input.sourceRoot);
|
|
42665
43093
|
const tempParent = input.tempRoot ? resolve22(input.tempRoot) : tmpdir3();
|
|
42666
|
-
|
|
42667
|
-
const runRoot = mkdtempSync3(
|
|
43094
|
+
mkdirSync7(tempParent, { recursive: true });
|
|
43095
|
+
const runRoot = mkdtempSync3(join13(tempParent, `${DEVELOPER_REVIEW_RUN_ROOT_PREFIX}${safeChallengeId.slice(0, 32)}-`));
|
|
42668
43096
|
return {
|
|
42669
43097
|
runId,
|
|
42670
43098
|
stateDir,
|
|
42671
43099
|
runRoot,
|
|
42672
|
-
worktreeTempRoot:
|
|
42673
|
-
manifestPath:
|
|
42674
|
-
lockPath:
|
|
43100
|
+
worktreeTempRoot: join13(runRoot, "worktrees"),
|
|
43101
|
+
manifestPath: join13(stateDir, `${safeChallengeId}.json`),
|
|
43102
|
+
lockPath: join13(stateDir, `${safeChallengeId}.lock`)
|
|
42675
43103
|
};
|
|
42676
43104
|
}
|
|
42677
43105
|
function writeDeveloperReviewRunOwnerMarker(input) {
|
|
@@ -42685,7 +43113,7 @@ function writeDeveloperReviewRunOwnerMarker(input) {
|
|
|
42685
43113
|
pid: process.pid,
|
|
42686
43114
|
createdAt: input.createdAt
|
|
42687
43115
|
};
|
|
42688
|
-
writePrivateJson(
|
|
43116
|
+
writePrivateJson(join13(input.runRoot, DEVELOPER_REVIEW_RUN_OWNER_MARKER_FILE), marker, "wx");
|
|
42689
43117
|
}
|
|
42690
43118
|
function readDeveloperReviewRunOwnerMarker(path) {
|
|
42691
43119
|
const stats = lstatIfExists2(path);
|
|
@@ -42709,8 +43137,8 @@ function resolveOwnedDeveloperReviewRunTargets(run) {
|
|
|
42709
43137
|
if (!runIdSuffix || !DEVELOPER_REVIEW_RUN_ID_SUFFIX.test(runIdSuffix))
|
|
42710
43138
|
throw developerReviewRunNotOwned("run-id");
|
|
42711
43139
|
const stateDir = defaultDeveloperReviewRunStateDir(run.sourceRoot);
|
|
42712
|
-
const manifestPath =
|
|
42713
|
-
const lockPath =
|
|
43140
|
+
const manifestPath = join13(stateDir, `${safeChallengeId}.json`);
|
|
43141
|
+
const lockPath = join13(stateDir, `${safeChallengeId}.lock`);
|
|
42714
43142
|
if (resolve22(run.manifestPath) !== manifestPath)
|
|
42715
43143
|
throw developerReviewRunNotOwned("manifest-path");
|
|
42716
43144
|
if (resolve22(run.lockPath) !== lockPath)
|
|
@@ -42732,7 +43160,7 @@ function resolveOwnedDeveloperReviewRunTargets(run) {
|
|
|
42732
43160
|
if (!runRootName.startsWith(runRootPrefix) || !DEVELOPER_REVIEW_RUN_ROOT_SUFFIX.test(runRootName.slice(runRootPrefix.length))) {
|
|
42733
43161
|
throw developerReviewRunNotOwned("run-root-name");
|
|
42734
43162
|
}
|
|
42735
|
-
const worktreeTempRoot =
|
|
43163
|
+
const worktreeTempRoot = join13(runRoot, "worktrees");
|
|
42736
43164
|
if (resolve22(run.worktreeTempRoot) !== worktreeTempRoot)
|
|
42737
43165
|
throw developerReviewRunNotOwned("worktree-temp-root");
|
|
42738
43166
|
if (resolve22(run.codeGraphTemporaryState.root) !== runRoot)
|
|
@@ -42742,7 +43170,7 @@ function resolveOwnedDeveloperReviewRunTargets(run) {
|
|
|
42742
43170
|
return { stateDir, manifestPath, lockPath };
|
|
42743
43171
|
if (!runRootStats.isDirectory())
|
|
42744
43172
|
throw developerReviewRunNotOwned("run-root-not-a-directory");
|
|
42745
|
-
const marker = readDeveloperReviewRunOwnerMarker(
|
|
43173
|
+
const marker = readDeveloperReviewRunOwnerMarker(join13(runRoot, DEVELOPER_REVIEW_RUN_OWNER_MARKER_FILE));
|
|
42746
43174
|
if (!marker)
|
|
42747
43175
|
throw developerReviewRunNotOwned("run-root-owner-marker-missing");
|
|
42748
43176
|
if (marker.runId !== run.runId || marker.challengeId !== run.challengeId)
|
|
@@ -42779,8 +43207,8 @@ function writeDeveloperReviewRunManifest(manifest) {
|
|
|
42779
43207
|
writePrivateJson(manifest.manifestPath, manifest);
|
|
42780
43208
|
}
|
|
42781
43209
|
function writePrivateJson(path, value, flag = "w") {
|
|
42782
|
-
|
|
42783
|
-
|
|
43210
|
+
mkdirSync7(dirname7(path), { recursive: true });
|
|
43211
|
+
writeFileSync6(path, JSON.stringify(value, null, 2), { mode: 384, flag });
|
|
42784
43212
|
chmodSync3(path, 384);
|
|
42785
43213
|
}
|
|
42786
43214
|
function readDeveloperReviewRunManifest(path) {
|
|
@@ -42792,7 +43220,7 @@ function readDeveloperReviewRunManifest(path) {
|
|
|
42792
43220
|
}
|
|
42793
43221
|
function readJsonObject(path) {
|
|
42794
43222
|
try {
|
|
42795
|
-
const parsed = JSON.parse(
|
|
43223
|
+
const parsed = JSON.parse(readFileSync18(path, "utf8"));
|
|
42796
43224
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
42797
43225
|
} catch {
|
|
42798
43226
|
return;
|
|
@@ -44389,8 +44817,8 @@ function uniqueStrings2(values) {
|
|
|
44389
44817
|
// packages/local-runtime/runtime-daemon/src/ledger-admin.ts
|
|
44390
44818
|
init_src();
|
|
44391
44819
|
init_src();
|
|
44392
|
-
import { existsSync as existsSync20, readFileSync as
|
|
44393
|
-
import { join as
|
|
44820
|
+
import { existsSync as existsSync20, readFileSync as readFileSync20 } from "node:fs";
|
|
44821
|
+
import { join as join15, resolve as resolve24 } from "node:path";
|
|
44394
44822
|
|
|
44395
44823
|
// packages/core/reconcile-engine/src/index.ts
|
|
44396
44824
|
function reconcileArchitectureLedgerDrift(input) {
|
|
@@ -44467,11 +44895,11 @@ init_src();
|
|
|
44467
44895
|
|
|
44468
44896
|
// packages/local-runtime/local-store-sqlite/src/index.ts
|
|
44469
44897
|
init_src();
|
|
44470
|
-
import { createHash as createHash10, randomUUID } from "node:crypto";
|
|
44471
|
-
import { chmodSync as chmodSync4, closeSync as closeSync7, copyFileSync, existsSync as existsSync19, fsyncSync as fsyncSync3, lstatSync as lstatSync10, mkdirSync as
|
|
44898
|
+
import { createHash as createHash10, randomUUID as randomUUID2 } from "node:crypto";
|
|
44899
|
+
import { chmodSync as chmodSync4, closeSync as closeSync7, copyFileSync, existsSync as existsSync19, fsyncSync as fsyncSync3, lstatSync as lstatSync10, mkdirSync as mkdirSync8, openSync as openSync8, readFileSync as readFileSync19, readSync as readSync4, realpathSync as realpathSync7, renameSync as renameSync4, rmSync as rmSync9, statfsSync, statSync as statSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
44472
44900
|
import { readdir, readFile } from "node:fs/promises";
|
|
44473
44901
|
import { createRequire as createRequire4 } from "node:module";
|
|
44474
|
-
import { dirname as dirname8, isAbsolute as isAbsolute6, join as
|
|
44902
|
+
import { dirname as dirname8, isAbsolute as isAbsolute6, join as join14, relative as relative7, resolve as resolve23 } from "node:path";
|
|
44475
44903
|
init_src();
|
|
44476
44904
|
// schemas/runtime/explorer-projection-v2.schema.json
|
|
44477
44905
|
var explorer_projection_v2_schema_default = {
|
|
@@ -45888,8 +46316,8 @@ function migrateLegacyLocalStoreIfNeeded(root = process.cwd(), env = process.env
|
|
|
45888
46316
|
}
|
|
45889
46317
|
assertTrustedLegacyLocalStoreSource(paths);
|
|
45890
46318
|
const lock = acquireLegacyMigrationLock(paths);
|
|
45891
|
-
const stagingDir =
|
|
45892
|
-
const stagingPath =
|
|
46319
|
+
const stagingDir = join14(paths.workspaceStateDir, `.runtime.sqlite.migration-${process.pid}-${randomUUID2()}`);
|
|
46320
|
+
const stagingPath = join14(stagingDir, "runtime.sqlite");
|
|
45893
46321
|
try {
|
|
45894
46322
|
if (targetExists)
|
|
45895
46323
|
quarantinedFiles.push(...quarantineExistingLocalStore(paths));
|
|
@@ -45981,7 +46409,7 @@ class SqliteLocalStore {
|
|
|
45981
46409
|
}
|
|
45982
46410
|
async beginSnapshot(snapshot) {
|
|
45983
46411
|
const db = await this.database();
|
|
45984
|
-
const snapshotId = `snapshot_${
|
|
46412
|
+
const snapshotId = `snapshot_${randomUUID2()}`;
|
|
45985
46413
|
db.prepare(`INSERT INTO snapshots
|
|
45986
46414
|
(id, repository_id, head_sha, worktree_digest, state, created_at)
|
|
45987
46415
|
VALUES (?, ?, ?, ?, ?, ?)`).run(snapshotId, snapshot.repositoryId, snapshot.headSha, snapshot.worktreeDigest, "pending", nowIso());
|
|
@@ -46319,7 +46747,7 @@ class SqliteLocalStore {
|
|
|
46319
46747
|
}
|
|
46320
46748
|
async beginChangeSet(root, draft) {
|
|
46321
46749
|
const db = await this.database();
|
|
46322
|
-
const journalId = `changeset_${
|
|
46750
|
+
const journalId = `changeset_${randomUUID2()}`;
|
|
46323
46751
|
db.prepare(`INSERT INTO changeset_journal
|
|
46324
46752
|
(journal_id, changeset_id, root, status, metadata_json, files_json, created_at, updated_at)
|
|
46325
46753
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(journalId, draft.id, root, "pending", stableJson(changeSetMetadata(draft)), "[]", nowIso(), nowIso());
|
|
@@ -49243,7 +49671,7 @@ function ftsMatchKind(query, doc) {
|
|
|
49243
49671
|
function recordArchitectureLedgerOperation(db, input) {
|
|
49244
49672
|
db.prepare(`INSERT INTO architecture_ledger_operations
|
|
49245
49673
|
(operation_id, storage_repository_id, storage_workspace_id, operation_kind, duration_ms, row_count, rebuild_reason, created_at)
|
|
49246
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(`ledger_operation_${
|
|
49674
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(`ledger_operation_${randomUUID2()}`, input.scope.repository.storageRepositoryId, architectureLedgerWorkspaceKey(input.scope.worktree), input.operationKind, Math.max(0, Math.trunc(input.durationMs)), input.rowCount, input.rebuildReason, nowIso());
|
|
49247
49675
|
}
|
|
49248
49676
|
function stableLedgerId(prefix, ...parts) {
|
|
49249
49677
|
return `${prefix}.${createHash10("sha256").update(parts.join("\x00")).digest("hex").slice(0, 24)}`;
|
|
@@ -49811,7 +50239,7 @@ function publishStagedLocalStore(stagingPath, targetPath) {
|
|
|
49811
50239
|
if (existsSync19(path))
|
|
49812
50240
|
throw new Error(`Cannot publish migrated SQLite over existing target file: ${path}`);
|
|
49813
50241
|
}
|
|
49814
|
-
|
|
50242
|
+
renameSync4(stagingPath, targetPath);
|
|
49815
50243
|
makePrivateFile(targetPath);
|
|
49816
50244
|
fsyncDirectory2(dirname8(targetPath));
|
|
49817
50245
|
}
|
|
@@ -49832,7 +50260,7 @@ function acquireLegacyMigrationLock(paths) {
|
|
|
49832
50260
|
ensurePrivateDir(dirname8(lockPath));
|
|
49833
50261
|
try {
|
|
49834
50262
|
const fd = openSync8(lockPath, "wx", 384);
|
|
49835
|
-
|
|
50263
|
+
writeFileSync7(fd, JSON.stringify({
|
|
49836
50264
|
schemaVersion: "archcontext.legacy-local-store-migration-lock/v1",
|
|
49837
50265
|
pid: process.pid,
|
|
49838
50266
|
root: paths.repositoryRoot,
|
|
@@ -49858,7 +50286,7 @@ function releaseLegacyMigrationLock(lock) {
|
|
|
49858
50286
|
}
|
|
49859
50287
|
function isStaleMigrationLock(lockPath) {
|
|
49860
50288
|
try {
|
|
49861
|
-
const parsed = JSON.parse(
|
|
50289
|
+
const parsed = JSON.parse(readFileSync19(lockPath, "utf8"));
|
|
49862
50290
|
if (typeof parsed.pid !== "number" || parsed.pid <= 0)
|
|
49863
50291
|
return true;
|
|
49864
50292
|
return !isProcessAlive(parsed.pid);
|
|
@@ -49909,7 +50337,7 @@ function acquireLocalStoreWriterOwnership(databasePath) {
|
|
|
49909
50337
|
throw error;
|
|
49910
50338
|
}
|
|
49911
50339
|
makePrivateFile(lockPath);
|
|
49912
|
-
const token =
|
|
50340
|
+
const token = randomUUID2();
|
|
49913
50341
|
writeOwnerRecord(recordPath, { pid: process.pid, databasePath, acquiredAt: nowIso(), token });
|
|
49914
50342
|
let released = false;
|
|
49915
50343
|
return {
|
|
@@ -49943,17 +50371,17 @@ function sleepSync(ms) {
|
|
|
49943
50371
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
49944
50372
|
}
|
|
49945
50373
|
function writeOwnerRecord(recordPath, record) {
|
|
49946
|
-
const tempPath = `${recordPath}.${process.pid}-${
|
|
50374
|
+
const tempPath = `${recordPath}.${process.pid}-${randomUUID2()}.tmp`;
|
|
49947
50375
|
try {
|
|
49948
|
-
|
|
49949
|
-
|
|
50376
|
+
writeFileSync7(tempPath, JSON.stringify(record, null, 2), { encoding: "utf8", mode: 384, flag: "wx" });
|
|
50377
|
+
renameSync4(tempPath, recordPath);
|
|
49950
50378
|
} catch {
|
|
49951
50379
|
rmSync9(tempPath, { force: true });
|
|
49952
50380
|
}
|
|
49953
50381
|
}
|
|
49954
50382
|
function readOwnerRecord(recordPath) {
|
|
49955
50383
|
try {
|
|
49956
|
-
const parsed = JSON.parse(
|
|
50384
|
+
const parsed = JSON.parse(readFileSync19(recordPath, "utf8"));
|
|
49957
50385
|
return parsed && typeof parsed === "object" ? parsed : undefined;
|
|
49958
50386
|
} catch {
|
|
49959
50387
|
return;
|
|
@@ -49961,7 +50389,7 @@ function readOwnerRecord(recordPath) {
|
|
|
49961
50389
|
}
|
|
49962
50390
|
function readLegacyOwnerLockPid(legacyPath) {
|
|
49963
50391
|
try {
|
|
49964
|
-
const pid = JSON.parse(
|
|
50392
|
+
const pid = JSON.parse(readFileSync19(legacyPath, "utf8"))?.pid;
|
|
49965
50393
|
return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : undefined;
|
|
49966
50394
|
} catch {
|
|
49967
50395
|
return;
|
|
@@ -49976,21 +50404,21 @@ function changeSetJournalRecoveryErrorMessage(metadataJson) {
|
|
|
49976
50404
|
return "pending ChangeSet journal without a recorded recovery error";
|
|
49977
50405
|
}
|
|
49978
50406
|
function quarantineExistingLocalStore(paths) {
|
|
49979
|
-
const quarantineDir =
|
|
50407
|
+
const quarantineDir = join14(paths.workspaceStateDir, "quarantine", `runtime.sqlite-${Date.now()}-${randomUUID2()}`);
|
|
49980
50408
|
ensurePrivateDir(quarantineDir);
|
|
49981
50409
|
const quarantinedFiles = [];
|
|
49982
50410
|
for (const suffix of SQLITE_SIDECAR_SUFFIXES) {
|
|
49983
50411
|
const source = `${paths.localStorePath}${suffix}`;
|
|
49984
50412
|
if (!existsSync19(source))
|
|
49985
50413
|
continue;
|
|
49986
|
-
const target =
|
|
49987
|
-
|
|
50414
|
+
const target = join14(quarantineDir, `runtime.sqlite${suffix}`);
|
|
50415
|
+
renameSync4(source, target);
|
|
49988
50416
|
quarantinedFiles.push(target);
|
|
49989
50417
|
}
|
|
49990
50418
|
const markerPath = legacyMigrationMarkerPath(paths);
|
|
49991
50419
|
if (existsSync19(markerPath)) {
|
|
49992
|
-
const target =
|
|
49993
|
-
|
|
50420
|
+
const target = join14(quarantineDir, LEGACY_MIGRATION_MARKER_FILE);
|
|
50421
|
+
renameSync4(markerPath, target);
|
|
49994
50422
|
quarantinedFiles.push(target);
|
|
49995
50423
|
}
|
|
49996
50424
|
fsyncDirectory2(quarantineDir);
|
|
@@ -49998,16 +50426,16 @@ function quarantineExistingLocalStore(paths) {
|
|
|
49998
50426
|
return quarantinedFiles;
|
|
49999
50427
|
}
|
|
50000
50428
|
function legacyMigrationMarkerPath(paths) {
|
|
50001
|
-
return
|
|
50429
|
+
return join14(paths.workspaceStateDir, LEGACY_MIGRATION_MARKER_FILE);
|
|
50002
50430
|
}
|
|
50003
50431
|
function legacyMigrationLockPath(paths) {
|
|
50004
|
-
return
|
|
50432
|
+
return join14(paths.workspaceStateDir, LEGACY_MIGRATION_LOCK_FILE);
|
|
50005
50433
|
}
|
|
50006
50434
|
function writePrivateJson2(path, value) {
|
|
50007
50435
|
ensurePrivateDir(dirname8(path));
|
|
50008
50436
|
const fd = openSync8(path, "w", 384);
|
|
50009
50437
|
try {
|
|
50010
|
-
|
|
50438
|
+
writeFileSync7(fd, JSON.stringify(value, null, 2), "utf8");
|
|
50011
50439
|
fsyncSync3(fd);
|
|
50012
50440
|
} finally {
|
|
50013
50441
|
closeSync7(fd);
|
|
@@ -50016,7 +50444,7 @@ function writePrivateJson2(path, value) {
|
|
|
50016
50444
|
fsyncDirectory2(dirname8(path));
|
|
50017
50445
|
}
|
|
50018
50446
|
function ensurePrivateDir(path) {
|
|
50019
|
-
|
|
50447
|
+
mkdirSync8(path, { recursive: true, mode: 448 });
|
|
50020
50448
|
if (process.platform !== "win32") {
|
|
50021
50449
|
try {
|
|
50022
50450
|
chmodSync4(path, 448);
|
|
@@ -50379,7 +50807,7 @@ function recoverJournalFiles(root, files) {
|
|
|
50379
50807
|
try {
|
|
50380
50808
|
const stat = lstatSync10(absolute);
|
|
50381
50809
|
if (stat.isFile() && !stat.isSymbolicLink()) {
|
|
50382
|
-
const bytes =
|
|
50810
|
+
const bytes = readFileSync19(absolute), body = bytes.toString("utf8");
|
|
50383
50811
|
if (Buffer.from(body, "utf8").equals(bytes))
|
|
50384
50812
|
current = digestJson({ body });
|
|
50385
50813
|
}
|
|
@@ -50398,7 +50826,7 @@ function recoverJournalFiles(root, files) {
|
|
|
50398
50826
|
if (file.existed) {
|
|
50399
50827
|
if (file.backupPath && existsSync19(file.backupPath)) {
|
|
50400
50828
|
rmSync9(absolute, { recursive: true, force: true });
|
|
50401
|
-
|
|
50829
|
+
renameSync4(file.backupPath, absolute);
|
|
50402
50830
|
} else if (!existsSync19(absolute) && firstExistedByPath.get(pathKey(absolute)) === true) {
|
|
50403
50831
|
missing.push(file.path);
|
|
50404
50832
|
continue;
|
|
@@ -50456,7 +50884,7 @@ async function readRelationFiles(root, relationsDir) {
|
|
|
50456
50884
|
for (const entry of entries) {
|
|
50457
50885
|
if (!entry.isFile() || !/\.(json|ya?ml)$/.test(entry.name))
|
|
50458
50886
|
continue;
|
|
50459
|
-
const relativePath =
|
|
50887
|
+
const relativePath = join14(relationsDir, entry.name).split("\\").join("/");
|
|
50460
50888
|
relations.push(parseCrossRepoRelationFile(await readFile(resolve23(root, relativePath), "utf8"), relativePath));
|
|
50461
50889
|
}
|
|
50462
50890
|
return relations.sort((a, b) => a.id.localeCompare(b.id));
|
|
@@ -50588,7 +51016,7 @@ class LedgerAdminService {
|
|
|
50588
51016
|
}
|
|
50589
51017
|
const paths = runtimeStatePaths(repositoryRoot);
|
|
50590
51018
|
const backupCreatedAt = this.context.clock();
|
|
50591
|
-
const backupPath = uniqueRuntimeBackupPath(
|
|
51019
|
+
const backupPath = uniqueRuntimeBackupPath(join15(paths.workspaceStateDir, "backups", "ledger-migrate", safePathSegment(backupCreatedAt), "runtime.sqlite"));
|
|
50592
51020
|
const backup = await this.context.localStore.backupArchitectureLedger({ backupPath });
|
|
50593
51021
|
const append = await this.context.appendArchitectureEventsWithFeed(repositoryRoot, {
|
|
50594
51022
|
writer: "runtime-daemon",
|
|
@@ -51087,7 +51515,7 @@ function obsoleteManagedProjectionPaths(currentFiles, projectedFiles) {
|
|
|
51087
51515
|
}
|
|
51088
51516
|
function expectedFileHash(root, path) {
|
|
51089
51517
|
const absolute = resolve24(root, path);
|
|
51090
|
-
return existsSync20(absolute) ? digestJson({ body:
|
|
51518
|
+
return existsSync20(absolute) ? digestJson({ body: readFileSync20(absolute, "utf8") }) : "missing";
|
|
51091
51519
|
}
|
|
51092
51520
|
function architectureProjectionRollbackBackup(files, options = {}) {
|
|
51093
51521
|
const manifest = {
|
|
@@ -51142,12 +51570,12 @@ function isEmptyArchitectureLedgerState(state) {
|
|
|
51142
51570
|
// packages/local-runtime/runtime-daemon/src/architecture-book.ts
|
|
51143
51571
|
init_src();
|
|
51144
51572
|
import { existsSync as existsSync22 } from "node:fs";
|
|
51145
|
-
import { join as
|
|
51573
|
+
import { join as join17 } from "node:path";
|
|
51146
51574
|
|
|
51147
51575
|
// packages/local-runtime/runtime-daemon/src/refactor-decisions.ts
|
|
51148
51576
|
init_src();
|
|
51149
|
-
import { existsSync as existsSync21, lstatSync as lstatSync11, readdirSync as readdirSync12, readFileSync as
|
|
51150
|
-
import { join as
|
|
51577
|
+
import { existsSync as existsSync21, lstatSync as lstatSync11, readdirSync as readdirSync12, readFileSync as readFileSync21 } from "node:fs";
|
|
51578
|
+
import { join as join16 } from "node:path";
|
|
51151
51579
|
var REFACTOR_DECISION_SET_SCHEMA_VERSION = "archcontext.refactor-decision-set/v1";
|
|
51152
51580
|
var REFACTOR_DECISION_FILE_NAME = /^recommendation\.[a-f0-9]{16}\.json$/;
|
|
51153
51581
|
var CHANGESET_TRANSIENT_DECISION_NAME = /^recommendation\.[a-f0-9]{16}\.json\.(archctx-backup|archctx-tmp-[0-9]+-[0-9]+)$/;
|
|
@@ -51186,11 +51614,11 @@ function readRefactorDecisionSet(root) {
|
|
|
51186
51614
|
const name = path.slice(prefix.length);
|
|
51187
51615
|
if (name.includes("/"))
|
|
51188
51616
|
throw decisionReadError(`${path} must sit directly in ${REFACTOR_DECISION_DIRECTORY}`);
|
|
51189
|
-
if (!lstatSync11(
|
|
51617
|
+
if (!lstatSync11(join16(absoluteDirectory, name)).isFile())
|
|
51190
51618
|
throw decisionReadError(`${path} must be a regular file, not a directory or symlink`);
|
|
51191
51619
|
let decision;
|
|
51192
51620
|
try {
|
|
51193
|
-
decision = parseRefactorDecisionFile(path,
|
|
51621
|
+
decision = parseRefactorDecisionFile(path, readFileSync21(join16(absoluteDirectory, name), "utf8"));
|
|
51194
51622
|
} catch (error) {
|
|
51195
51623
|
throw decisionReadError(error instanceof Error ? error.message : String(error));
|
|
51196
51624
|
}
|
|
@@ -51279,7 +51707,7 @@ function buildRefactorDecision(input) {
|
|
|
51279
51707
|
function refactorDecisionWrite(root, decision) {
|
|
51280
51708
|
const path = refactorDecisionPath(decision.recommendationId);
|
|
51281
51709
|
const absolute = assertPathHasNoSymlinkSegments(root, path);
|
|
51282
|
-
const expectedHash = existsSync21(absolute) ? digestJson({ body:
|
|
51710
|
+
const expectedHash = existsSync21(absolute) ? digestJson({ body: readFileSync21(absolute, "utf8") }) : "missing";
|
|
51283
51711
|
return { path, expectedHash, body: serializeRefactorDecision(decision) };
|
|
51284
51712
|
}
|
|
51285
51713
|
function refactorDecisionIdentityIssues(decision, namespace) {
|
|
@@ -51469,7 +51897,7 @@ class ArchitectureBookService {
|
|
|
51469
51897
|
const gitScope = await this.context.architectureLedgerGitScope(root);
|
|
51470
51898
|
let refactorDecisionStatuses = new Map;
|
|
51471
51899
|
const repositoryRoot = findRepositoryRoot(root);
|
|
51472
|
-
if (replay.events.some(eventCarriesRefactorRecommendation) || existsSync22(
|
|
51900
|
+
if (replay.events.some(eventCarriesRefactorRecommendation) || existsSync22(join17(repositoryRoot, REFACTOR_DECISION_DIRECTORY))) {
|
|
51473
51901
|
try {
|
|
51474
51902
|
const decisions = readRefactorDecisionSet(repositoryRoot);
|
|
51475
51903
|
refactorDecisionStatuses = new Map(decisions.decisions.map((decision) => [decision.recommendationId, decision.status]));
|
|
@@ -51825,8 +52253,8 @@ init_src();
|
|
|
51825
52253
|
init_src();
|
|
51826
52254
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
51827
52255
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
51828
|
-
import { chmodSync as chmodSync5, existsSync as existsSync23, lstatSync as lstatSync12, mkdirSync as
|
|
51829
|
-
import { basename as basename6, dirname as dirname9, join as
|
|
52256
|
+
import { chmodSync as chmodSync5, existsSync as existsSync23, lstatSync as lstatSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync22, renameSync as renameSync5, rmSync as rmSync10, writeFileSync as writeFileSync8 } from "node:fs";
|
|
52257
|
+
import { basename as basename6, dirname as dirname9, join as join18 } from "node:path";
|
|
51830
52258
|
|
|
51831
52259
|
// packages/local-runtime/runtime-daemon/src/investigation-transport.ts
|
|
51832
52260
|
import { spawn } from "node:child_process";
|
|
@@ -52068,7 +52496,7 @@ var AUDIT_EGRESS_POLICY_DIGEST = digestJson(AUDIT_EGRESS_POLICY);
|
|
|
52068
52496
|
function auditConsentBinding(root, env) {
|
|
52069
52497
|
const paths = runtimeStatePaths(root, env);
|
|
52070
52498
|
return {
|
|
52071
|
-
path:
|
|
52499
|
+
path: join18(paths.repositoryStateDir, AUDIT_CONSENT_FILE),
|
|
52072
52500
|
storageRepositoryId: paths.storageRepositoryId,
|
|
52073
52501
|
repositoryAnchor: paths.repositoryAnchor,
|
|
52074
52502
|
origin: readSanitizedOrigin(paths.repositoryRoot)
|
|
@@ -52116,7 +52544,7 @@ function readAuditConsentUnchecked(root, env = process.env) {
|
|
|
52116
52544
|
try {
|
|
52117
52545
|
if (!lstatSync12(binding.path).isFile())
|
|
52118
52546
|
return { granted: false, path: binding.path, reason: "unreadable" };
|
|
52119
|
-
record = JSON.parse(
|
|
52547
|
+
record = JSON.parse(readFileSync22(binding.path, "utf8"));
|
|
52120
52548
|
} catch {
|
|
52121
52549
|
return { granted: false, path: binding.path, reason: "unreadable" };
|
|
52122
52550
|
}
|
|
@@ -52154,13 +52582,13 @@ function grantAuditConsentUnchecked(root, env = process.env, now = new Date().to
|
|
|
52154
52582
|
}
|
|
52155
52583
|
function writePrivateJsonAtomically(path, value) {
|
|
52156
52584
|
const directory = dirname9(path);
|
|
52157
|
-
|
|
52158
|
-
const tempPath =
|
|
52585
|
+
mkdirSync9(directory, { recursive: true, mode: 448 });
|
|
52586
|
+
const tempPath = join18(directory, `.${basename6(path)}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`);
|
|
52159
52587
|
try {
|
|
52160
|
-
|
|
52588
|
+
writeFileSync8(tempPath, `${JSON.stringify(value, null, 2)}
|
|
52161
52589
|
`, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
52162
52590
|
chmodSync5(tempPath, 384);
|
|
52163
|
-
|
|
52591
|
+
renameSync5(tempPath, path);
|
|
52164
52592
|
} catch (error) {
|
|
52165
52593
|
rmSync10(tempPath, { force: true });
|
|
52166
52594
|
throw error;
|
|
@@ -52193,9 +52621,9 @@ function auditConsentRequiredEnvelope(requestId, reason) {
|
|
|
52193
52621
|
|
|
52194
52622
|
// packages/local-runtime/runtime-daemon/src/github-issue-executor.ts
|
|
52195
52623
|
import { execFile } from "node:child_process";
|
|
52196
|
-
import { mkdtempSync as mkdtempSync4, rmSync as rmSync11, writeFileSync as
|
|
52624
|
+
import { mkdtempSync as mkdtempSync4, rmSync as rmSync11, writeFileSync as writeFileSync9 } from "node:fs";
|
|
52197
52625
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
52198
|
-
import { join as
|
|
52626
|
+
import { join as join19 } from "node:path";
|
|
52199
52627
|
var DEFAULT_GH_EXECUTOR_TIMEOUT_MS = 30000;
|
|
52200
52628
|
var GITHUB_ISSUE_LIST_LIMIT = 100;
|
|
52201
52629
|
function createNodeGithubIssueExecutor(options = {}) {
|
|
@@ -52260,10 +52688,10 @@ function runGh(args, env, timeoutMs) {
|
|
|
52260
52688
|
});
|
|
52261
52689
|
}
|
|
52262
52690
|
async function withGithubIssueBodyFile(body, fn, deps = {}) {
|
|
52263
|
-
const writeFile = deps.writeFile ??
|
|
52264
|
-
const dir = mkdtempSync4(
|
|
52691
|
+
const writeFile = deps.writeFile ?? writeFileSync9;
|
|
52692
|
+
const dir = mkdtempSync4(join19(tmpdir4(), "archctx-gh-issue-body-"));
|
|
52265
52693
|
try {
|
|
52266
|
-
const bodyFile =
|
|
52694
|
+
const bodyFile = join19(dir, "body.md");
|
|
52267
52695
|
writeFile(bodyFile, body, { mode: 384 });
|
|
52268
52696
|
return await fn(bodyFile);
|
|
52269
52697
|
} finally {
|
|
@@ -53247,10 +53675,10 @@ function runtimeProjectionOwnedOutputDigest(projection) {
|
|
|
53247
53675
|
}
|
|
53248
53676
|
// packages/local-runtime/runtime-daemon/src/projection-writer.ts
|
|
53249
53677
|
import { execFile as execFile2, spawnSync as spawnSync6 } from "node:child_process";
|
|
53250
|
-
import { createHash as createHash11, randomUUID as
|
|
53251
|
-
import { closeSync as closeSync8, existsSync as existsSync24, mkdirSync as
|
|
53678
|
+
import { createHash as createHash11, randomUUID as randomUUID3 } from "node:crypto";
|
|
53679
|
+
import { closeSync as closeSync8, existsSync as existsSync24, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync5, openSync as openSync9, readFileSync as readFileSync23, readSync as readSync5, realpathSync as realpathSync8, renameSync as renameSync6, rmSync as rmSync12, writeFileSync as writeFileSync10 } from "node:fs";
|
|
53252
53680
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
53253
|
-
import { extname as extname2, join as
|
|
53681
|
+
import { extname as extname2, join as join20, resolve as resolve25 } from "node:path";
|
|
53254
53682
|
init_src();
|
|
53255
53683
|
var PROJECTION_PUBLISH_REQUEST_ID = "projection.publish";
|
|
53256
53684
|
var PROJECTION_PUBLISH_STATUS_REQUEST_ID = "projection.publish-status";
|
|
@@ -53263,6 +53691,10 @@ var PROJECTION_WRITER_MAX_ITERATIONS = 3;
|
|
|
53263
53691
|
var PROJECTION_WRITER_TARGETS = ["agent-context", "architecture-docs"];
|
|
53264
53692
|
var PUBLISHER_TIMEOUT_MS = 120000;
|
|
53265
53693
|
var PR_BODY_MAX_LISTED_PATHS = 200;
|
|
53694
|
+
function renderRecentHistory(root, ref, env) {
|
|
53695
|
+
const { total } = readArchitectureHistory(root, { ref, limit: 0, env });
|
|
53696
|
+
return renderHistoryMarkdown(readArchitectureHistory(root, { ref, offset: Math.max(0, total - 20), limit: 20, env }));
|
|
53697
|
+
}
|
|
53266
53698
|
|
|
53267
53699
|
class ProjectionWriterFailure extends Error {
|
|
53268
53700
|
code;
|
|
@@ -53280,8 +53712,8 @@ class ProjectionWriterFailure extends Error {
|
|
|
53280
53712
|
}
|
|
53281
53713
|
function projectionWriterPaths(repositoryRoot, remote, base, env = process.env) {
|
|
53282
53714
|
const key = createHash11("sha256").update(`${remote}\x00${base}`, "utf8").digest("hex").slice(0, 16);
|
|
53283
|
-
const dir =
|
|
53284
|
-
return { dir, baseRef: `refs/archctx/projection-writer/${key}/base`, worktree:
|
|
53715
|
+
const dir = join20(runtimeStatePaths(repositoryRoot, env).repositoryStateDir, "projection-writer", key);
|
|
53716
|
+
return { dir, baseRef: `refs/archctx/projection-writer/${key}/base`, worktree: join20(dir, "worktree"), state: join20(dir, "state.json"), lock: join20(dir, "lock") };
|
|
53285
53717
|
}
|
|
53286
53718
|
async function runProjectionPublishCommand(options) {
|
|
53287
53719
|
const env = options.env ?? process.env;
|
|
@@ -53326,7 +53758,7 @@ async function runProjectionPublishCommand(options) {
|
|
|
53326
53758
|
});
|
|
53327
53759
|
let lock;
|
|
53328
53760
|
try {
|
|
53329
|
-
|
|
53761
|
+
mkdirSync10(paths.dir, { recursive: true, mode: 448 });
|
|
53330
53762
|
lock = acquireProjectionWriterLock(paths.lock, startedAt);
|
|
53331
53763
|
} catch (error) {
|
|
53332
53764
|
const failure = asWriterFailure(error);
|
|
@@ -53435,6 +53867,12 @@ async function runLockedProjectionPublish(input) {
|
|
|
53435
53867
|
if (!["noop", "applied", "applied-partial"].includes(projectionStatus)) {
|
|
53436
53868
|
throw new ProjectionWriterFailure("AC_PRECONDITION_FAILED", "projection-apply-status-unsupported", `projection apply ended with status ${projectionStatus}; the writer publishes only noop, applied and applied-partial results`);
|
|
53437
53869
|
}
|
|
53870
|
+
const historyBody = renderRecentHistory(paths.worktree, baseSha, options.env);
|
|
53871
|
+
const historyPath = join20(paths.worktree, ARCHITECTURE_HISTORY_PATH);
|
|
53872
|
+
mkdirSync10(join20(paths.worktree, "docs/architecture"), { recursive: true });
|
|
53873
|
+
const historyTemp = `${historyPath}.${randomUUID3()}.tmp`;
|
|
53874
|
+
writeFileSync10(historyTemp, historyBody);
|
|
53875
|
+
renameSync6(historyTemp, historyPath);
|
|
53438
53876
|
const changed = worktreeChangedPaths(paths.worktree);
|
|
53439
53877
|
if (changed.length === 0) {
|
|
53440
53878
|
const tip = lsRemoteBranch(repositoryRoot, pushRemote, base, env);
|
|
@@ -53446,6 +53884,7 @@ async function runLockedProjectionPublish(input) {
|
|
|
53446
53884
|
return finish("up-to-date", { projectionStatus });
|
|
53447
53885
|
}
|
|
53448
53886
|
const written = new Set(result.files.filter((file) => file.action !== "unchanged").map((file) => file.path));
|
|
53887
|
+
written.add(ARCHITECTURE_HISTORY_PATH);
|
|
53449
53888
|
const offending = changed.filter((path) => !written.has(path) || !isProjectionOwnedPath(path, ownedPatterns));
|
|
53450
53889
|
if (offending.length > 0) {
|
|
53451
53890
|
return failed(new ProjectionWriterFailure("AC_POLICY_VIOLATION", "projection-writer-non-owned-change", `projection apply changed paths the writer may not publish: ${offending.join(", ")}`), { projectionStatus });
|
|
@@ -53548,10 +53987,10 @@ function projectionPublishBody(input) {
|
|
|
53548
53987
|
async function publishPullRequest(publisher, input) {
|
|
53549
53988
|
if (publisher.kind === "none")
|
|
53550
53989
|
return { ok: true, pullRequest: null };
|
|
53551
|
-
const dir = mkdtempSync5(
|
|
53990
|
+
const dir = mkdtempSync5(join20(tmpdir5(), "archctx-projection-pr-body-"));
|
|
53552
53991
|
try {
|
|
53553
|
-
const bodyFile =
|
|
53554
|
-
|
|
53992
|
+
const bodyFile = join20(dir, "body.md");
|
|
53993
|
+
writeFileSync10(bodyFile, projectionPublishBody(input), { mode: 384 });
|
|
53555
53994
|
const pullRequest = await publisher.ensurePullRequest({
|
|
53556
53995
|
worktree: input.worktree,
|
|
53557
53996
|
remote: input.remote,
|
|
@@ -53690,11 +54129,13 @@ function runProjectionVerifyPrCommand(options) {
|
|
|
53690
54129
|
} catch {
|
|
53691
54130
|
agentContextDiffering = [...classified.agentContextPaths];
|
|
53692
54131
|
}
|
|
54132
|
+
const historyDiffering = changedPaths.includes(ARCHITECTURE_HISTORY_PATH) && readFileAtRevision(root, headSha, ARCHITECTURE_HISTORY_PATH) !== renderRecentHistory(root, headSha) ? [ARCHITECTURE_HISTORY_PATH] : [];
|
|
53693
54133
|
const differingPaths = [...new Set([
|
|
53694
54134
|
...result.files.filter((file) => file.action !== "unchanged").map((file) => file.path),
|
|
53695
|
-
...agentContextDiffering
|
|
54135
|
+
...agentContextDiffering,
|
|
54136
|
+
...historyDiffering
|
|
53696
54137
|
])].sort();
|
|
53697
|
-
const renderEquivalent = result.status === "noop" && agentContextDiffering.length === 0;
|
|
54138
|
+
const renderEquivalent = result.status === "noop" && agentContextDiffering.length === 0 && historyDiffering.length === 0;
|
|
53698
54139
|
return verification({
|
|
53699
54140
|
verdict: renderEquivalent ? "generated-only-render-equivalent" : "generated-only-not-render-equivalent",
|
|
53700
54141
|
generatedOnly: true,
|
|
@@ -53713,7 +54154,7 @@ function classifyPullRequestPaths(root, mergeBase, headSha, changedPaths) {
|
|
|
53713
54154
|
const humanEdited = [];
|
|
53714
54155
|
const agentContext = [];
|
|
53715
54156
|
for (const path of changedPaths) {
|
|
53716
|
-
if (path === ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH)
|
|
54157
|
+
if (path === ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH || path === ARCHITECTURE_HISTORY_PATH)
|
|
53717
54158
|
continue;
|
|
53718
54159
|
const atBase = baseTargets.get(path);
|
|
53719
54160
|
const atHead = headTargets.get(path);
|
|
@@ -54052,7 +54493,7 @@ function acquireProjectionWriterLock(lockPath, startedAt) {
|
|
|
54052
54493
|
return { kind: "busy", pid: holder.pid };
|
|
54053
54494
|
}
|
|
54054
54495
|
rmSync12(lockPath, { force: true });
|
|
54055
|
-
const record = JSON.stringify({ pid: process.pid, startedAt, token:
|
|
54496
|
+
const record = JSON.stringify({ pid: process.pid, startedAt, token: randomUUID3() }, null, 2);
|
|
54056
54497
|
createPrivateControlFile(lockPath, record);
|
|
54057
54498
|
return { kind: "acquired", record, release() {
|
|
54058
54499
|
try {
|
|
@@ -54108,7 +54549,7 @@ function readProjectionWriterState(path, remote, base) {
|
|
|
54108
54549
|
return emptyProjectionWriterState(remote, base);
|
|
54109
54550
|
let value;
|
|
54110
54551
|
try {
|
|
54111
|
-
value = JSON.parse(
|
|
54552
|
+
value = JSON.parse(readFileSync23(path, "utf8"));
|
|
54112
54553
|
} catch (error) {
|
|
54113
54554
|
throw new ProjectionWriterFailure("AC_PRECONDITION_FAILED", "projection-writer-state-invalid", `projection writer state is unreadable at ${path}: ${errorMessage(error)}`);
|
|
54114
54555
|
}
|
|
@@ -54130,9 +54571,9 @@ function readProjectionWriterState(path, remote, base) {
|
|
|
54130
54571
|
}
|
|
54131
54572
|
function writeProjectionWriterState(path, state) {
|
|
54132
54573
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
54133
|
-
|
|
54574
|
+
writeFileSync10(temporary, `${JSON.stringify(state, null, 2)}
|
|
54134
54575
|
`, { encoding: "utf8", mode: 384 });
|
|
54135
|
-
|
|
54576
|
+
renameSync6(temporary, path);
|
|
54136
54577
|
}
|
|
54137
54578
|
function prepareProjectionWriterWorktree(repositoryRoot, worktree, sha) {
|
|
54138
54579
|
git(repositoryRoot, ["worktree", "prune"]);
|
|
@@ -54145,7 +54586,7 @@ function prepareProjectionWriterWorktree(repositoryRoot, worktree, sha) {
|
|
|
54145
54586
|
git(worktree, ["clean", "-ffdq"]);
|
|
54146
54587
|
}
|
|
54147
54588
|
function isRegisteredWorktree(repositoryRoot, worktree) {
|
|
54148
|
-
if (!existsSync24(
|
|
54589
|
+
if (!existsSync24(join20(worktree, ".git")))
|
|
54149
54590
|
return false;
|
|
54150
54591
|
const wanted = canonical(worktree);
|
|
54151
54592
|
return git(repositoryRoot, ["worktree", "list", "--porcelain", "-z"]).split("\x00").filter((line) => line.startsWith("worktree ")).some((line) => canonical(line.slice("worktree ".length)) === wanted);
|
|
@@ -54300,6 +54741,8 @@ function readWorkspaces2(root) {
|
|
|
54300
54741
|
try {
|
|
54301
54742
|
return declaredWorkspacePackages(root);
|
|
54302
54743
|
} catch (error) {
|
|
54744
|
+
if (error instanceof FailureError)
|
|
54745
|
+
throw error;
|
|
54303
54746
|
throw new CapabilityDependenciesError("AC_SCHEMA_INVALID", `workspace packages are unreadable: ${error instanceof Error ? error.message : String(error)}`, "deps-workspace-invalid");
|
|
54304
54747
|
}
|
|
54305
54748
|
}
|
|
@@ -54397,7 +54840,7 @@ function runFlowSelectorCheckCommand(cwd, options = {}) {
|
|
|
54397
54840
|
}
|
|
54398
54841
|
// packages/local-runtime/runtime-daemon/src/recommendations.ts
|
|
54399
54842
|
import { existsSync as existsSync25 } from "node:fs";
|
|
54400
|
-
import { join as
|
|
54843
|
+
import { join as join21 } from "node:path";
|
|
54401
54844
|
|
|
54402
54845
|
// packages/local-runtime/runtime-daemon/src/refactor-verify.ts
|
|
54403
54846
|
init_src();
|
|
@@ -54999,7 +55442,7 @@ class RecommendationsService {
|
|
|
54999
55442
|
});
|
|
55000
55443
|
}
|
|
55001
55444
|
readGitOnlyDecision(repositoryRoot, recommendationId, surface) {
|
|
55002
|
-
if (!existsSync25(
|
|
55445
|
+
if (!existsSync25(join21(repositoryRoot, REFACTOR_DECISION_DIRECTORY)))
|
|
55003
55446
|
return;
|
|
55004
55447
|
let decisions;
|
|
55005
55448
|
try {
|
|
@@ -55669,7 +56112,7 @@ function lifecycleEnvelope(input) {
|
|
|
55669
56112
|
});
|
|
55670
56113
|
}
|
|
55671
56114
|
function refactorDecisionsInPlay(repositoryRoot, records) {
|
|
55672
|
-
return records.some(isRefactorRecommendation) || existsSync25(
|
|
56115
|
+
return records.some(isRefactorRecommendation) || existsSync25(join21(repositoryRoot, REFACTOR_DECISION_DIRECTORY));
|
|
55673
56116
|
}
|
|
55674
56117
|
function ledgerAuditDecisionRefused(surface, record, recommendations, decisions) {
|
|
55675
56118
|
let head = record.recommendationId;
|
|
@@ -55791,14 +56234,14 @@ function recommendationActorKind(input) {
|
|
|
55791
56234
|
init_src();
|
|
55792
56235
|
init_src();
|
|
55793
56236
|
init_src();
|
|
55794
|
-
import { existsSync as existsSync26, readFileSync as
|
|
56237
|
+
import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
|
|
55795
56238
|
import { resolve as resolve27 } from "node:path";
|
|
55796
56239
|
init_src();
|
|
55797
56240
|
|
|
55798
56241
|
// packages/local-runtime/runtime-daemon/src/committed-change-acceptance.ts
|
|
55799
56242
|
init_src();
|
|
55800
56243
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
55801
|
-
import { closeSync as closeSync9, constants as fsConstants3, fstatSync as fstatSync4, lstatSync as lstatSync13, openSync as openSync10, readdirSync as readdirSync13, readFileSync as
|
|
56244
|
+
import { closeSync as closeSync9, constants as fsConstants3, fstatSync as fstatSync4, lstatSync as lstatSync13, openSync as openSync10, readdirSync as readdirSync13, readFileSync as readFileSync24 } from "node:fs";
|
|
55802
56245
|
import { resolve as resolve26 } from "node:path";
|
|
55803
56246
|
init_src();
|
|
55804
56247
|
var SEMANTIC_MODEL_DIRECTORIES = ["nodes", "relations", "flows"];
|
|
@@ -55877,7 +56320,7 @@ function readRegularFileBytes(absolute, path) {
|
|
|
55877
56320
|
try {
|
|
55878
56321
|
if (!fstatSync4(fd).isFile())
|
|
55879
56322
|
throw new FailureError("AC_PRECONDITION_FAILED", "semantic-model-entry-not-regular");
|
|
55880
|
-
return
|
|
56323
|
+
return readFileSync24(fd);
|
|
55881
56324
|
} finally {
|
|
55882
56325
|
closeSync9(fd);
|
|
55883
56326
|
}
|
|
@@ -56380,7 +56823,7 @@ class ChangeSetAuthorityService {
|
|
|
56380
56823
|
const absolute = resolve27(session.workspace.root, path);
|
|
56381
56824
|
const body = `${JSON.stringify(waiver, null, 2)}
|
|
56382
56825
|
`;
|
|
56383
|
-
const expectedHash = existsSync26(absolute) ? digestJson({ body:
|
|
56826
|
+
const expectedHash = existsSync26(absolute) ? digestJson({ body: readFileSync25(absolute, "utf8") }) : "missing";
|
|
56384
56827
|
const draft = this.changeSetEngine.plan({
|
|
56385
56828
|
id: input.id ?? `changeset.practice-waiver-${waiverId.replace(/[^A-Za-z0-9_-]/g, "-")}`,
|
|
56386
56829
|
base: {
|
|
@@ -56820,7 +57263,7 @@ function architectureLedgerWriteAppendsEvents(mode) {
|
|
|
56820
57263
|
// packages/local-runtime/runtime-daemon/src/rpc-server.ts
|
|
56821
57264
|
init_src();
|
|
56822
57265
|
import { createServer as createServer2 } from "node:http";
|
|
56823
|
-
import { closeSync as closeSync10, existsSync as existsSync27, mkdirSync as
|
|
57266
|
+
import { closeSync as closeSync10, existsSync as existsSync27, mkdirSync as mkdirSync11 } from "node:fs";
|
|
56824
57267
|
import { dirname as dirname10 } from "node:path";
|
|
56825
57268
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
56826
57269
|
var DEFAULT_DAEMON_IDLE_TIMEOUT_MS = 30 * 60000;
|
|
@@ -56891,8 +57334,8 @@ class ArchctxRuntimeRpcServer {
|
|
|
56891
57334
|
const root = this.options.root ?? process.cwd();
|
|
56892
57335
|
const connectionPath = this.options.connectionPath ?? defaultDaemonConnectionPath(root);
|
|
56893
57336
|
const lockPath = this.options.lockPath ?? defaultDaemonLockPath(root);
|
|
56894
|
-
|
|
56895
|
-
|
|
57337
|
+
mkdirSync11(dirname10(connectionPath), { recursive: true });
|
|
57338
|
+
mkdirSync11(dirname10(lockPath), { recursive: true });
|
|
56896
57339
|
this.lockFd = acquireDaemonLock(lockPath, root);
|
|
56897
57340
|
const token = this.options.token ?? randomBytes5(18).toString("base64url");
|
|
56898
57341
|
const server = createServer2((request, response) => {
|
|
@@ -57211,7 +57654,7 @@ async function readRpcRequestBody(request, limits) {
|
|
|
57211
57654
|
}
|
|
57212
57655
|
|
|
57213
57656
|
// packages/local-runtime/runtime-daemon/src/index.ts
|
|
57214
|
-
import { existsSync as existsSync28, readFileSync as
|
|
57657
|
+
import { existsSync as existsSync28, readFileSync as readFileSync26 } from "node:fs";
|
|
57215
57658
|
import { resolve as resolve28 } from "node:path";
|
|
57216
57659
|
init_src();
|
|
57217
57660
|
|
|
@@ -57406,7 +57849,7 @@ class ArchctxDaemon {
|
|
|
57406
57849
|
const model = loadNativeModelFromArchContext(root);
|
|
57407
57850
|
const canonical = renderAgentContextProjection({ model, sourceDigest: digestJson({ model }), existingFiles: loadAgentContextProjectionFiles(root, model) });
|
|
57408
57851
|
const canonicalBody = canonical.files.find((candidate) => candidate.path === file.path)?.body;
|
|
57409
|
-
if (canonicalBody === undefined || projectionOwnedWriteBody(canonicalBody,
|
|
57852
|
+
if (canonicalBody === undefined || projectionOwnedWriteBody(canonicalBody, readFileSync26(resolve28(root, file.path), "utf8")) !== file.body) {
|
|
57410
57853
|
throw new Error(`Root contract requires canonical marker-only content: ${file.path}`);
|
|
57411
57854
|
}
|
|
57412
57855
|
}
|
|
@@ -58724,8 +59167,8 @@ function isArchContextGeneratedProjectionPath2(path) {
|
|
|
58724
59167
|
|
|
58725
59168
|
// packages/surfaces/cli/src/github-review-state.ts
|
|
58726
59169
|
init_src();
|
|
58727
|
-
import { chmodSync as chmodSync6, existsSync as existsSync29, mkdirSync as
|
|
58728
|
-
import { dirname as dirname11, join as
|
|
59170
|
+
import { chmodSync as chmodSync6, existsSync as existsSync29, mkdirSync as mkdirSync12, readFileSync as readFileSync27, rmSync as rmSync13, writeFileSync as writeFileSync11 } from "node:fs";
|
|
59171
|
+
import { dirname as dirname11, join as join23 } from "node:path";
|
|
58729
59172
|
var text2 = { type: "string", minLength: 1 };
|
|
58730
59173
|
var digest2 = { type: "string", pattern: "^sha256:[0-9a-f]{64}$" };
|
|
58731
59174
|
var record7 = (properties, required = Object.keys(properties)) => ({ type: "object", additionalProperties: false, properties, required });
|
|
@@ -58756,7 +59199,7 @@ var stateSchema = record7({
|
|
|
58756
59199
|
}, ["schemaVersion", "status", "challenge", "challengeDigest", "updatedAt"]);
|
|
58757
59200
|
function defaultGithubDeveloperReviewStatePath(cwd, pullRequestNumber) {
|
|
58758
59201
|
const suffix = pullRequestNumber ? `github-developer-review-pr-${pullRequestNumber}.json` : "github-developer-review.json";
|
|
58759
|
-
return
|
|
59202
|
+
return join23(runtimeStatePaths(cwd).workspaceStateDir, suffix);
|
|
58760
59203
|
}
|
|
58761
59204
|
function metadata(state) {
|
|
58762
59205
|
const { submission, ...rest } = state;
|
|
@@ -58810,8 +59253,8 @@ async function writeGithubDeveloperReviewState(cwd, state, secrets = []) {
|
|
|
58810
59253
|
assertNoCliSecretMaterial(state.submission);
|
|
58811
59254
|
assertNoReviewSecrets(state.submission, secrets);
|
|
58812
59255
|
}
|
|
58813
|
-
|
|
58814
|
-
|
|
59256
|
+
mkdirSync12(dirname11(path), { recursive: true });
|
|
59257
|
+
writeFileSync11(path, serialized, { mode: 384 });
|
|
58815
59258
|
if (process.platform !== "win32")
|
|
58816
59259
|
chmodSync6(path, 384);
|
|
58817
59260
|
return { state: { ...validated, ...state.submission === undefined ? {} : { submission: state.submission } }, path };
|
|
@@ -58821,7 +59264,7 @@ function readGithubDeveloperReviewState(path) {
|
|
|
58821
59264
|
return;
|
|
58822
59265
|
let parsed;
|
|
58823
59266
|
try {
|
|
58824
|
-
parsed = JSON.parse(
|
|
59267
|
+
parsed = JSON.parse(readFileSync27(path, "utf8"));
|
|
58825
59268
|
} catch {
|
|
58826
59269
|
throw new Error("github-review-state-metadata-invalid");
|
|
58827
59270
|
}
|
|
@@ -58836,7 +59279,7 @@ function discardLegacyGithubDeveloperReviewState(path) {
|
|
|
58836
59279
|
return false;
|
|
58837
59280
|
let parsed;
|
|
58838
59281
|
try {
|
|
58839
|
-
parsed = JSON.parse(
|
|
59282
|
+
parsed = JSON.parse(readFileSync27(path, "utf8"));
|
|
58840
59283
|
} catch {
|
|
58841
59284
|
throw new Error("github-review-state-metadata-invalid");
|
|
58842
59285
|
}
|
|
@@ -58938,13 +59381,14 @@ function localEgressStatus2(env = process.env, live = {}) {
|
|
|
58938
59381
|
|
|
58939
59382
|
// packages/surfaces/cli/src/main.ts
|
|
58940
59383
|
import { spawn as spawn2, spawnSync as spawnSync9 } from "child_process";
|
|
58941
|
-
import { accessSync as accessSync3, closeSync as closeSync14, constants as constants3, existsSync as existsSync35, mkdirSync as
|
|
58942
|
-
import { dirname as dirname16, join as
|
|
59384
|
+
import { accessSync as accessSync3, closeSync as closeSync14, constants as constants3, existsSync as existsSync35, mkdirSync as mkdirSync17, openSync as openSync14, readFileSync as readFileSync34, rmSync as rmSync18, statSync as statSync12 } from "fs";
|
|
59385
|
+
import { dirname as dirname16, join as join28, parse, resolve as resolve37 } from "path";
|
|
58943
59386
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
58944
59387
|
|
|
58945
59388
|
// packages/contracts/src/index.ts
|
|
58946
59389
|
init_control_plane_routes();
|
|
58947
59390
|
init_architecture();
|
|
59391
|
+
init_architecture_history();
|
|
58948
59392
|
init_architecture_debt();
|
|
58949
59393
|
init_docs_anchors();
|
|
58950
59394
|
init_github_governance();
|
|
@@ -58966,12 +59410,12 @@ init_changeset_recovery();
|
|
|
58966
59410
|
|
|
58967
59411
|
// packages/core/changeset-engine/src/index.ts
|
|
58968
59412
|
init_src();
|
|
58969
|
-
import { chmodSync as chmodSync7, closeSync as closeSync11, existsSync as existsSync30, fsyncSync as fsyncSync4, lstatSync as lstatSync14, mkdirSync as
|
|
59413
|
+
import { chmodSync as chmodSync7, closeSync as closeSync11, existsSync as existsSync30, fsyncSync as fsyncSync4, lstatSync as lstatSync14, mkdirSync as mkdirSync13, openSync as openSync11, readFileSync as readFileSync28, renameSync as renameSync7, rmSync as rmSync14, writeFileSync as writeFileSync12 } from "node:fs";
|
|
58970
59414
|
import { dirname as dirname12, isAbsolute as isAbsolute7, relative as relative8, resolve as resolve29, sep as sep6 } from "node:path";
|
|
58971
59415
|
var EMPTY_PATH_SET2 = new Set;
|
|
58972
59416
|
function planManifestFieldsOperation(root, fields) {
|
|
58973
59417
|
const absolute = assertPathHasNoSymlinkSegments2(root, MANIFEST_UPDATE_PATH);
|
|
58974
|
-
const body =
|
|
59418
|
+
const body = readFileSync28(absolute, "utf8");
|
|
58975
59419
|
const operation = { op: "update_manifest_fields", path: MANIFEST_UPDATE_PATH, expectedHash: digestJson({ body }), fields };
|
|
58976
59420
|
assertManifestUpdateOperation(operation);
|
|
58977
59421
|
renderManifestFieldsUpdate(body, fields);
|
|
@@ -59079,7 +59523,7 @@ function assertAllowedArchContextPath2(root, relativePath, scope) {
|
|
|
59079
59523
|
|
|
59080
59524
|
// packages/core/architecture-domain/src/index.ts
|
|
59081
59525
|
import { createHash as createHash12 } from "node:crypto";
|
|
59082
|
-
import { readFileSync as
|
|
59526
|
+
import { readFileSync as readFileSync29, realpathSync as realpathSync10, statSync as statSync8 } from "node:fs";
|
|
59083
59527
|
import { resolve as resolve31 } from "node:path";
|
|
59084
59528
|
init_src();
|
|
59085
59529
|
var DEFAULT_IGNORES2 = new Set([
|
|
@@ -59132,7 +59576,7 @@ function computeWorktreeDigest2(root, files, options = {}) {
|
|
|
59132
59576
|
return {
|
|
59133
59577
|
path,
|
|
59134
59578
|
size: statSync8(absolute).size,
|
|
59135
|
-
digest: createHash12("sha256").update(
|
|
59579
|
+
digest: createHash12("sha256").update(readFileSync29(absolute)).digest("hex")
|
|
59136
59580
|
};
|
|
59137
59581
|
});
|
|
59138
59582
|
return digestJson(payload);
|
|
@@ -59447,7 +59891,7 @@ var UNTRUSTED_TOOL_ESCAPE_KEYS2 = new Set([
|
|
|
59447
59891
|
]);
|
|
59448
59892
|
|
|
59449
59893
|
// packages/cloud/hardening/src/index.ts
|
|
59450
|
-
import { readdirSync as readdirSync14, readFileSync as
|
|
59894
|
+
import { readdirSync as readdirSync14, readFileSync as readFileSync30, statSync as statSync9 } from "node:fs";
|
|
59451
59895
|
import { resolve as resolve32 } from "node:path";
|
|
59452
59896
|
init_src2();
|
|
59453
59897
|
init_src();
|
|
@@ -59495,7 +59939,7 @@ function uninstallMarker(content, host) {
|
|
|
59495
59939
|
`).trim();
|
|
59496
59940
|
}
|
|
59497
59941
|
function dependencyAudit(root) {
|
|
59498
|
-
const packageJson = JSON.parse(
|
|
59942
|
+
const packageJson = JSON.parse(readFileSync30(resolve32(root, "package.json"), "utf8"));
|
|
59499
59943
|
const issues = [];
|
|
59500
59944
|
if (packageJson.engines?.node !== ARCHCONTEXT_NODE_RANGE) {
|
|
59501
59945
|
issues.push(`node engine must equal ${ARCHCONTEXT_NODE_RANGE}`);
|
|
@@ -59509,7 +59953,7 @@ function secretScan(root) {
|
|
|
59509
59953
|
continue;
|
|
59510
59954
|
if (file === "packages/cloud/hardening/src/index.ts" || file.includes("/test/"))
|
|
59511
59955
|
continue;
|
|
59512
|
-
const body =
|
|
59956
|
+
const body = readFileSync30(resolve32(root, file), "utf8");
|
|
59513
59957
|
if (/(sk-[A-Za-z0-9]{20,}|ghp_[A-Za-z0-9]{20,}|BEGIN PRIVATE KEY)/.test(body))
|
|
59514
59958
|
findings.push(file);
|
|
59515
59959
|
}
|
|
@@ -59558,10 +60002,10 @@ function listFiles(root) {
|
|
|
59558
60002
|
|
|
59559
60003
|
// packages/local-runtime/local-store-sqlite/src/index.ts
|
|
59560
60004
|
init_src();
|
|
59561
|
-
import { createHash as createHash14, randomUUID as
|
|
59562
|
-
import { chmodSync as chmodSync8, closeSync as closeSync12, copyFileSync as copyFileSync2, existsSync as existsSync32, fsyncSync as fsyncSync5, lstatSync as lstatSync15, mkdirSync as
|
|
60005
|
+
import { createHash as createHash14, randomUUID as randomUUID4 } from "node:crypto";
|
|
60006
|
+
import { chmodSync as chmodSync8, closeSync as closeSync12, copyFileSync as copyFileSync2, existsSync as existsSync32, fsyncSync as fsyncSync5, lstatSync as lstatSync15, mkdirSync as mkdirSync14, openSync as openSync12, readFileSync as readFileSync31, readSync as readSync6, realpathSync as realpathSync11, renameSync as renameSync8, rmSync as rmSync15, statfsSync as statfsSync2, statSync as statSync10, writeFileSync as writeFileSync13 } from "node:fs";
|
|
59563
60007
|
import { createRequire as createRequire5 } from "node:module";
|
|
59564
|
-
import { dirname as dirname13, isAbsolute as isAbsolute9, join as
|
|
60008
|
+
import { dirname as dirname13, isAbsolute as isAbsolute9, join as join24, relative as relative10, resolve as resolve33 } from "node:path";
|
|
59565
60009
|
init_src();
|
|
59566
60010
|
var runtimeRequire2 = createRequire5(import.meta.url);
|
|
59567
60011
|
var SQLITE_SIDECAR_SUFFIXES2 = ["", "-wal", "-shm"];
|
|
@@ -60480,8 +60924,8 @@ function recoverRuntimeStateTarget(input) {
|
|
|
60480
60924
|
}
|
|
60481
60925
|
assertRuntimeStateRecoveryDaemonStopped(paths);
|
|
60482
60926
|
const lock = acquireLegacyMigrationLock2(paths);
|
|
60483
|
-
const stagingDir =
|
|
60484
|
-
const stagingPath =
|
|
60927
|
+
const stagingDir = join24(paths.workspaceStateDir, `.runtime.sqlite.recovery-${process.pid}-${randomUUID4()}`);
|
|
60928
|
+
const stagingPath = join24(stagingDir, "runtime.sqlite");
|
|
60485
60929
|
let quarantineDirectory;
|
|
60486
60930
|
let quarantineFiles = [];
|
|
60487
60931
|
let receiptPath;
|
|
@@ -60500,7 +60944,7 @@ function recoverRuntimeStateTarget(input) {
|
|
|
60500
60944
|
throw new Error(`runtime-state-recovery-target-fingerprint-mismatch:${lockedSnapshot.fingerprint}`);
|
|
60501
60945
|
}
|
|
60502
60946
|
assertRuntimeStateRecoveryDiskBudget(inspection.availableBytes, inspection.requiredFreeBytes);
|
|
60503
|
-
quarantineDirectory =
|
|
60947
|
+
quarantineDirectory = join24(paths.workspaceStateDir, "quarantine", `runtime-state-recovery-${Date.now()}-${randomUUID4()}`);
|
|
60504
60948
|
ensurePrivateDir2(quarantineDirectory);
|
|
60505
60949
|
assertRuntimeStateRecoveryPrivatePermissions(quarantineDirectory, 448);
|
|
60506
60950
|
quarantineFiles = copyRuntimeStateRecoveryFiles(lockedSnapshot.files, quarantineDirectory);
|
|
@@ -60513,7 +60957,7 @@ function recoverRuntimeStateTarget(input) {
|
|
|
60513
60957
|
assertRuntimeStateRecoveryPrivatePermissions(stagingDir, 448);
|
|
60514
60958
|
migrateSqliteDatabaseSync2(stagingPath);
|
|
60515
60959
|
const stagingIntegrity = assertCurrentLocalStore2(stagingPath);
|
|
60516
|
-
receiptPath =
|
|
60960
|
+
receiptPath = join24(quarantineDirectory, RUNTIME_STATE_RECOVERY_RECEIPT_FILE);
|
|
60517
60961
|
writeRuntimeStateRecoveryReceipt(receiptPath, {
|
|
60518
60962
|
status: "quarantine-verified",
|
|
60519
60963
|
paths,
|
|
@@ -60577,7 +61021,7 @@ function completeRuntimeStateRecovery(input) {
|
|
|
60577
61021
|
if (resolve33(input.recovery.receiptPath) !== expectedReceiptPath) {
|
|
60578
61022
|
throw new Error("runtime-state-recovery-completion-receipt-path-mismatch");
|
|
60579
61023
|
}
|
|
60580
|
-
const parsed = JSON.parse(
|
|
61024
|
+
const parsed = JSON.parse(readFileSync31(expectedReceiptPath, "utf8"));
|
|
60581
61025
|
if (parsed.schemaVersion !== "archcontext.runtime-state-recovery-receipt/v1" || parsed.status !== "target-published-rebuild-required" || parsed.targetFingerprint !== input.recovery.targetFingerprintBefore || parsed.expectedWorktreeDigest !== input.recovery.expectedWorktreeDigest) {
|
|
60582
61026
|
throw new Error("runtime-state-recovery-completion-receipt-mismatch");
|
|
60583
61027
|
}
|
|
@@ -60631,8 +61075,8 @@ function migrateLegacyLocalStoreIfNeeded2(root = process.cwd(), env = process.en
|
|
|
60631
61075
|
}
|
|
60632
61076
|
assertTrustedLegacyLocalStoreSource2(paths);
|
|
60633
61077
|
const lock = acquireLegacyMigrationLock2(paths);
|
|
60634
|
-
const stagingDir =
|
|
60635
|
-
const stagingPath =
|
|
61078
|
+
const stagingDir = join24(paths.workspaceStateDir, `.runtime.sqlite.migration-${process.pid}-${randomUUID4()}`);
|
|
61079
|
+
const stagingPath = join24(stagingDir, "runtime.sqlite");
|
|
60636
61080
|
try {
|
|
60637
61081
|
if (targetExists)
|
|
60638
61082
|
quarantinedFiles.push(...quarantineExistingLocalStore2(paths));
|
|
@@ -61368,13 +61812,13 @@ function runtimeStateRecoveryInspection(paths, migration, status, reasonCode, fi
|
|
|
61368
61812
|
};
|
|
61369
61813
|
}
|
|
61370
61814
|
function runtimeStateRecoveryStartupProbe(paths, sourceFiles) {
|
|
61371
|
-
const probeDirectory =
|
|
61372
|
-
const probePath =
|
|
61815
|
+
const probeDirectory = join24(paths.workspaceStateDir, `.runtime.sqlite.recovery-probe-${process.pid}-${randomUUID4()}`);
|
|
61816
|
+
const probePath = join24(probeDirectory, "runtime.sqlite");
|
|
61373
61817
|
try {
|
|
61374
61818
|
ensurePrivateDir2(probeDirectory);
|
|
61375
61819
|
assertRuntimeStateRecoveryPrivatePermissions(probeDirectory, 448);
|
|
61376
61820
|
for (const source of sourceFiles.filter((file) => file.name.startsWith("runtime.sqlite") && file.name !== LEGACY_MIGRATION_MARKER_FILE2)) {
|
|
61377
|
-
const target =
|
|
61821
|
+
const target = join24(probeDirectory, source.name);
|
|
61378
61822
|
copyFileSync2(source.path, target);
|
|
61379
61823
|
makePrivateFile2(target);
|
|
61380
61824
|
}
|
|
@@ -61466,7 +61910,7 @@ function runtimeStateRecoveryAvailableBytes(path) {
|
|
|
61466
61910
|
}
|
|
61467
61911
|
function copyRuntimeStateRecoveryFiles(sourceFiles, quarantineDirectory) {
|
|
61468
61912
|
return sourceFiles.map((source) => {
|
|
61469
|
-
const target =
|
|
61913
|
+
const target = join24(quarantineDirectory, source.name);
|
|
61470
61914
|
copyFileSync2(source.path, target);
|
|
61471
61915
|
makePrivateFile2(target);
|
|
61472
61916
|
assertRuntimeStateRecoveryPrivatePermissions(target, 384);
|
|
@@ -61512,7 +61956,7 @@ function removeRuntimeStateRecoveryTargetFamily(paths) {
|
|
|
61512
61956
|
}
|
|
61513
61957
|
function restoreRuntimeStateRecoveryFiles(files, paths) {
|
|
61514
61958
|
for (const file of files) {
|
|
61515
|
-
const target = file.name === LEGACY_MIGRATION_MARKER_FILE2 ? legacyMigrationMarkerPath2(paths) :
|
|
61959
|
+
const target = file.name === LEGACY_MIGRATION_MARKER_FILE2 ? legacyMigrationMarkerPath2(paths) : join24(dirname13(paths.localStorePath), file.name);
|
|
61516
61960
|
copyFileSync2(file.path, target);
|
|
61517
61961
|
makePrivateFile2(target);
|
|
61518
61962
|
fsyncFile2(target);
|
|
@@ -61680,7 +62124,7 @@ function publishStagedLocalStore2(stagingPath, targetPath) {
|
|
|
61680
62124
|
if (existsSync32(path))
|
|
61681
62125
|
throw new Error(`Cannot publish migrated SQLite over existing target file: ${path}`);
|
|
61682
62126
|
}
|
|
61683
|
-
|
|
62127
|
+
renameSync8(stagingPath, targetPath);
|
|
61684
62128
|
makePrivateFile2(targetPath);
|
|
61685
62129
|
fsyncDirectory3(dirname13(targetPath));
|
|
61686
62130
|
}
|
|
@@ -61701,7 +62145,7 @@ function acquireLegacyMigrationLock2(paths) {
|
|
|
61701
62145
|
ensurePrivateDir2(dirname13(lockPath));
|
|
61702
62146
|
try {
|
|
61703
62147
|
const fd = openSync12(lockPath, "wx", 384);
|
|
61704
|
-
|
|
62148
|
+
writeFileSync13(fd, JSON.stringify({
|
|
61705
62149
|
schemaVersion: "archcontext.legacy-local-store-migration-lock/v1",
|
|
61706
62150
|
pid: process.pid,
|
|
61707
62151
|
root: paths.repositoryRoot,
|
|
@@ -61727,7 +62171,7 @@ function releaseLegacyMigrationLock2(lock) {
|
|
|
61727
62171
|
}
|
|
61728
62172
|
function isStaleMigrationLock2(lockPath) {
|
|
61729
62173
|
try {
|
|
61730
|
-
const parsed = JSON.parse(
|
|
62174
|
+
const parsed = JSON.parse(readFileSync31(lockPath, "utf8"));
|
|
61731
62175
|
if (typeof parsed.pid !== "number" || parsed.pid <= 0)
|
|
61732
62176
|
return true;
|
|
61733
62177
|
return !isProcessAlive(parsed.pid);
|
|
@@ -61737,21 +62181,21 @@ function isStaleMigrationLock2(lockPath) {
|
|
|
61737
62181
|
}
|
|
61738
62182
|
var LOCAL_STORE_WRITER_OWNED_ERROR = "local-store-writer-owned";
|
|
61739
62183
|
function quarantineExistingLocalStore2(paths) {
|
|
61740
|
-
const quarantineDir =
|
|
62184
|
+
const quarantineDir = join24(paths.workspaceStateDir, "quarantine", `runtime.sqlite-${Date.now()}-${randomUUID4()}`);
|
|
61741
62185
|
ensurePrivateDir2(quarantineDir);
|
|
61742
62186
|
const quarantinedFiles = [];
|
|
61743
62187
|
for (const suffix of SQLITE_SIDECAR_SUFFIXES2) {
|
|
61744
62188
|
const source = `${paths.localStorePath}${suffix}`;
|
|
61745
62189
|
if (!existsSync32(source))
|
|
61746
62190
|
continue;
|
|
61747
|
-
const target =
|
|
61748
|
-
|
|
62191
|
+
const target = join24(quarantineDir, `runtime.sqlite${suffix}`);
|
|
62192
|
+
renameSync8(source, target);
|
|
61749
62193
|
quarantinedFiles.push(target);
|
|
61750
62194
|
}
|
|
61751
62195
|
const markerPath = legacyMigrationMarkerPath2(paths);
|
|
61752
62196
|
if (existsSync32(markerPath)) {
|
|
61753
|
-
const target =
|
|
61754
|
-
|
|
62197
|
+
const target = join24(quarantineDir, LEGACY_MIGRATION_MARKER_FILE2);
|
|
62198
|
+
renameSync8(markerPath, target);
|
|
61755
62199
|
quarantinedFiles.push(target);
|
|
61756
62200
|
}
|
|
61757
62201
|
fsyncDirectory3(quarantineDir);
|
|
@@ -61759,16 +62203,16 @@ function quarantineExistingLocalStore2(paths) {
|
|
|
61759
62203
|
return quarantinedFiles;
|
|
61760
62204
|
}
|
|
61761
62205
|
function legacyMigrationMarkerPath2(paths) {
|
|
61762
|
-
return
|
|
62206
|
+
return join24(paths.workspaceStateDir, LEGACY_MIGRATION_MARKER_FILE2);
|
|
61763
62207
|
}
|
|
61764
62208
|
function legacyMigrationLockPath2(paths) {
|
|
61765
|
-
return
|
|
62209
|
+
return join24(paths.workspaceStateDir, LEGACY_MIGRATION_LOCK_FILE2);
|
|
61766
62210
|
}
|
|
61767
62211
|
function writePrivateJson3(path, value) {
|
|
61768
62212
|
ensurePrivateDir2(dirname13(path));
|
|
61769
62213
|
const fd = openSync12(path, "w", 384);
|
|
61770
62214
|
try {
|
|
61771
|
-
|
|
62215
|
+
writeFileSync13(fd, JSON.stringify(value, null, 2), "utf8");
|
|
61772
62216
|
fsyncSync5(fd);
|
|
61773
62217
|
} finally {
|
|
61774
62218
|
closeSync12(fd);
|
|
@@ -61777,7 +62221,7 @@ function writePrivateJson3(path, value) {
|
|
|
61777
62221
|
fsyncDirectory3(dirname13(path));
|
|
61778
62222
|
}
|
|
61779
62223
|
function ensurePrivateDir2(path) {
|
|
61780
|
-
|
|
62224
|
+
mkdirSync14(path, { recursive: true, mode: 448 });
|
|
61781
62225
|
if (process.platform !== "win32") {
|
|
61782
62226
|
try {
|
|
61783
62227
|
chmodSync8(path, 448);
|
|
@@ -61823,8 +62267,8 @@ function isIgnorableDirectoryFsyncError3(error) {
|
|
|
61823
62267
|
|
|
61824
62268
|
// packages/local-runtime/git-adapter/src/index.ts
|
|
61825
62269
|
import { execFileSync as execFileSync10, spawnSync as spawnSync7 } from "node:child_process";
|
|
61826
|
-
import { existsSync as existsSync33, lstatSync as lstatSync16, mkdirSync as
|
|
61827
|
-
import { dirname as dirname14, join as
|
|
62270
|
+
import { existsSync as existsSync33, lstatSync as lstatSync16, mkdirSync as mkdirSync15, mkdtempSync as mkdtempSync6, readdirSync as readdirSync15, readFileSync as readFileSync32, rmSync as rmSync16 } from "node:fs";
|
|
62271
|
+
import { dirname as dirname14, join as join25, resolve as resolve34 } from "node:path";
|
|
61828
62272
|
init_src();
|
|
61829
62273
|
var GIT_CAT_FILE_MAX_BYTES2 = 512 * 1024 * 1024;
|
|
61830
62274
|
function findRepositoryRoot2(start) {
|
|
@@ -61874,7 +62318,7 @@ function listGitVisibleFiles2(root, pathspec) {
|
|
|
61874
62318
|
}
|
|
61875
62319
|
return [...new Set(output.split("\x00").filter(Boolean))].filter((path) => {
|
|
61876
62320
|
try {
|
|
61877
|
-
return lstatSync16(
|
|
62321
|
+
return lstatSync16(join25(root, path)).isFile();
|
|
61878
62322
|
} catch {
|
|
61879
62323
|
return false;
|
|
61880
62324
|
}
|
|
@@ -61894,14 +62338,14 @@ function readHeadSha2(root) {
|
|
|
61894
62338
|
|
|
61895
62339
|
// packages/local-runtime/runtime-state-paths/src/index.ts
|
|
61896
62340
|
import { readdirSync as readdirSync16, realpathSync as realpathSync12 } from "node:fs";
|
|
61897
|
-
import { isAbsolute as isAbsolute10, join as
|
|
62341
|
+
import { isAbsolute as isAbsolute10, join as join26, resolve as resolve35 } from "node:path";
|
|
61898
62342
|
var REPOSITORIES_DIR2 = "repositories";
|
|
61899
62343
|
var WORKTREES_DIR2 = "worktrees";
|
|
61900
62344
|
function listWorkspaceStateDirs2(stateRoot) {
|
|
61901
|
-
return listDirectoryNames2(
|
|
62345
|
+
return listDirectoryNames2(join26(stateRoot, REPOSITORIES_DIR2)).flatMap((storageRepositoryId) => listDirectoryNames2(join26(stateRoot, REPOSITORIES_DIR2, storageRepositoryId, WORKTREES_DIR2)).map((storageWorkspaceId) => ({
|
|
61902
62346
|
storageRepositoryId,
|
|
61903
62347
|
storageWorkspaceId,
|
|
61904
|
-
workspaceStateDir:
|
|
62348
|
+
workspaceStateDir: join26(stateRoot, REPOSITORIES_DIR2, storageRepositoryId, WORKTREES_DIR2, storageWorkspaceId)
|
|
61905
62349
|
})));
|
|
61906
62350
|
}
|
|
61907
62351
|
function listDirectoryNames2(path) {
|
|
@@ -61917,9 +62361,9 @@ function listDirectoryNames2(path) {
|
|
|
61917
62361
|
// packages/local-runtime/codegraph-adapter/src/index.ts
|
|
61918
62362
|
init_src();
|
|
61919
62363
|
import { execFileSync as execFileSync11, spawnSync as spawnSync8 } from "node:child_process";
|
|
61920
|
-
import { accessSync as accessSync2, closeSync as closeSync13, constants as fsConstants4, existsSync as existsSync34, lstatSync as lstatSync17, mkdirSync as
|
|
62364
|
+
import { accessSync as accessSync2, closeSync as closeSync13, constants as fsConstants4, existsSync as existsSync34, lstatSync as lstatSync17, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync7, openSync as openSync13, readFileSync as readFileSync33, readdirSync as readdirSync17, readSync as readSync7, realpathSync as realpathSync13, rmSync as rmSync17, statSync as statSync11, writeFileSync as writeFileSync14 } from "node:fs";
|
|
61921
62365
|
import { createRequire as createRequire6 } from "node:module";
|
|
61922
|
-
import { basename as basename7, delimiter as delimiter2, dirname as dirname15, isAbsolute as isAbsolute11, join as
|
|
62366
|
+
import { basename as basename7, delimiter as delimiter2, dirname as dirname15, isAbsolute as isAbsolute11, join as join27, posix as posix4, relative as relative11, resolve as resolve36 } from "node:path";
|
|
61923
62367
|
init_src();
|
|
61924
62368
|
var REQUIRED_CODEGRAPH_PACKAGE2 = "@colbymchenry/codegraph";
|
|
61925
62369
|
var REQUIRED_CODEGRAPH_VERSION2 = productVersionManifest().runtime.codeGraph.requiredVersion;
|
|
@@ -61956,13 +62400,13 @@ function codeGraphCliInvocation2(binary, cwd, pathValue = process.env.PATH ?? ""
|
|
|
61956
62400
|
}
|
|
61957
62401
|
function resolveExecutable2(binary, cwd, pathValue) {
|
|
61958
62402
|
if (binary.includes("/") || binary.includes("\\")) {
|
|
61959
|
-
const path = isAbsolute11(binary) ? binary :
|
|
62403
|
+
const path = isAbsolute11(binary) ? binary : join27(cwd, binary);
|
|
61960
62404
|
return existsSync34(path) ? realpathSync13.native(path) : undefined;
|
|
61961
62405
|
}
|
|
61962
62406
|
for (const dir of pathValue.split(delimiter2)) {
|
|
61963
62407
|
if (!dir)
|
|
61964
62408
|
continue;
|
|
61965
|
-
const path =
|
|
62409
|
+
const path = join27(dir, binary);
|
|
61966
62410
|
if (isExecutablePath2(path))
|
|
61967
62411
|
return realpathSync13.native(path);
|
|
61968
62412
|
}
|
|
@@ -61982,7 +62426,7 @@ function isExecutablePath2(path) {
|
|
|
61982
62426
|
function resolvePackagedCodeGraphShim2() {
|
|
61983
62427
|
try {
|
|
61984
62428
|
const manifestPath = requireFromAdapter3.resolve(`${REQUIRED_CODEGRAPH_PACKAGE2}/package.json`);
|
|
61985
|
-
const manifest = JSON.parse(
|
|
62429
|
+
const manifest = JSON.parse(readFileSync33(manifestPath, "utf8"));
|
|
61986
62430
|
const relativeBin = manifest.bin?.codegraph;
|
|
61987
62431
|
if (manifest.version !== REQUIRED_CODEGRAPH_VERSION2 || !relativeBin)
|
|
61988
62432
|
return;
|
|
@@ -62022,7 +62466,7 @@ class CodeGraphIndexBuildInProgressError2 extends Error {
|
|
|
62022
62466
|
function codeGraphIndexBuildInProgress2(workspaceRoot) {
|
|
62023
62467
|
let raw;
|
|
62024
62468
|
try {
|
|
62025
|
-
raw =
|
|
62469
|
+
raw = readFileSync33(join27(workspaceRoot, ".codegraph", "codegraph.lock"), "utf8").trim();
|
|
62026
62470
|
} catch {
|
|
62027
62471
|
return false;
|
|
62028
62472
|
}
|
|
@@ -62183,7 +62627,7 @@ function inspectRepositoryCodeFacts2(root, options = {}) {
|
|
|
62183
62627
|
};
|
|
62184
62628
|
}
|
|
62185
62629
|
function codeGraphIndexAvailable2(workspaceRoot) {
|
|
62186
|
-
return existsSync34(
|
|
62630
|
+
return existsSync34(join27(workspaceRoot, ".codegraph"));
|
|
62187
62631
|
}
|
|
62188
62632
|
var NON_DECLARATION_KINDS2 = new Set(["file", "import", "export", "parameter"]);
|
|
62189
62633
|
var RUNTIME_BUILTIN_CALL_NAMES2 = new Set([
|
|
@@ -63264,6 +63708,7 @@ var CLI_COMMAND_FLAGS = {
|
|
|
63264
63708
|
repo: { value: ["--name", "--repository-id", "--root"], boolean: [] },
|
|
63265
63709
|
resolve: { value: ["--path", "--paths-from"], boolean: [] },
|
|
63266
63710
|
impact: { value: ["--base", "--head", "--depth", "--paths-from"], boolean: [] },
|
|
63711
|
+
history: { value: ["--ref", "--format", "--offset", "--limit"], boolean: [] },
|
|
63267
63712
|
review: { value: ["--head-sha", "--posture", "--task", "--task-session-id"], boolean: [] },
|
|
63268
63713
|
state: { value: ["--expected-target-fingerprint", "--expected-worktree-digest"], boolean: ["--accept-external-projection", "--dry-run", "--from-git", "--write"] },
|
|
63269
63714
|
status: { value: [], boolean: [] },
|
|
@@ -63531,6 +63976,8 @@ function runCapabilitiesCommand() {
|
|
|
63531
63976
|
async function runCliUnchecked(command = "help", args = [], cwd, deps = {}) {
|
|
63532
63977
|
if (command === "impact")
|
|
63533
63978
|
return runRefImpactCommand(args, cwd);
|
|
63979
|
+
if (command === "history")
|
|
63980
|
+
return runArchitectureHistoryCommand(args, cwd);
|
|
63534
63981
|
if (command === "export" && args[0] === "native")
|
|
63535
63982
|
return runNativeContextCommand(args.slice(1), cwd);
|
|
63536
63983
|
const preflight = preflightCliArguments(command, args);
|
|
@@ -63845,7 +64292,7 @@ async function runCliUnchecked(command = "help", args = [], cwd, deps = {}) {
|
|
|
63845
64292
|
ok: true,
|
|
63846
64293
|
requestId: "help",
|
|
63847
64294
|
data: {
|
|
63848
|
-
commands: ["capabilities", "projection", "init", "sync", "validate", "context", "status", "daemon", "state", "repo", "landscape", "ledger", "book", "recommendations", "refactor", "explore", "prepare", "practices", "checkpoint", "hook", "hooks", "investigate", "agents", "jobs", "audit", "plan", "apply", "hash", "review", "complete", "github", "manifest", "config", "mcp", "install", "uninstall", "doctor", "update", "paths", "privacy-audit", "export", "import", "resolve", "impact", "tunnel", "flows", "deps", "constraints", "debt"],
|
|
64295
|
+
commands: ["capabilities", "projection", "init", "sync", "validate", "context", "status", "daemon", "state", "repo", "landscape", "ledger", "book", "recommendations", "refactor", "explore", "prepare", "practices", "checkpoint", "hook", "hooks", "investigate", "agents", "jobs", "audit", "plan", "apply", "hash", "review", "complete", "github", "manifest", "config", "mcp", "install", "uninstall", "doctor", "update", "paths", "privacy-audit", "export", "import", "resolve", "impact", "history", "tunnel", "flows", "deps", "constraints", "debt"],
|
|
63849
64296
|
examples: CLI_HELP_EXAMPLES
|
|
63850
64297
|
}
|
|
63851
64298
|
};
|
|
@@ -65239,7 +65686,7 @@ function auditGithubIssuesEnabled(cwd) {
|
|
|
65239
65686
|
return false;
|
|
65240
65687
|
let raw;
|
|
65241
65688
|
try {
|
|
65242
|
-
raw =
|
|
65689
|
+
raw = readFileSync34(manifestPath, "utf8");
|
|
65243
65690
|
} catch {
|
|
65244
65691
|
return false;
|
|
65245
65692
|
}
|
|
@@ -65812,7 +66259,7 @@ async function digestReviewChallenge(challenge) {
|
|
|
65812
66259
|
return reviewChallengeV2Digest(challenge);
|
|
65813
66260
|
}
|
|
65814
66261
|
function defaultGithubConnectionPath(cwd) {
|
|
65815
|
-
return
|
|
66262
|
+
return join28(dirname16(defaultDaemonConnectionPath(cwd)), "github-connection.json");
|
|
65816
66263
|
}
|
|
65817
66264
|
function sanitizeGithubConnection(record, connectionPath) {
|
|
65818
66265
|
return {
|
|
@@ -65836,7 +66283,7 @@ async function readReviewChallengeV2Arg(args, cwd, commandName = "github verify-
|
|
|
65836
66283
|
if (!inline && !challengePath)
|
|
65837
66284
|
return { ok: false, message: `${commandName} requires --challenge-json or --challenge-path` };
|
|
65838
66285
|
try {
|
|
65839
|
-
const raw = inline ??
|
|
66286
|
+
const raw = inline ?? readFileSync34(resolve37(cwd, challengePath), "utf8");
|
|
65840
66287
|
const parsed = JSON.parse(raw);
|
|
65841
66288
|
const attestation = await Promise.resolve().then(() => (init_src6(), {}));
|
|
65842
66289
|
const assertReviewChallengeV2 = assertReviewChallengeV22;
|
|
@@ -66150,7 +66597,7 @@ async function doctorReport(cwd, args = []) {
|
|
|
66150
66597
|
function doctorManifest(root) {
|
|
66151
66598
|
const path = ".archcontext/manifest.yaml";
|
|
66152
66599
|
try {
|
|
66153
|
-
return { warnings: manifestDecisionDiagnostics2([{ path, body:
|
|
66600
|
+
return { warnings: manifestDecisionDiagnostics2([{ path, body: readFileSync34(resolve37(root, path), "utf8") }]) };
|
|
66154
66601
|
} catch {
|
|
66155
66602
|
return { warnings: [] };
|
|
66156
66603
|
}
|
|
@@ -66348,8 +66795,8 @@ function runtimePathsReport(cwd) {
|
|
|
66348
66795
|
...paths,
|
|
66349
66796
|
legacyLocalStore: inspectLegacyLocalStoreMigration(cwd),
|
|
66350
66797
|
runtimeRepositoryId: repositoryFingerprint2(paths.repositoryRoot),
|
|
66351
|
-
repositoryTruthDir:
|
|
66352
|
-
codeGraphIndexDir:
|
|
66798
|
+
repositoryTruthDir: join28(paths.repositoryRoot, ".archcontext"),
|
|
66799
|
+
codeGraphIndexDir: join28(paths.repositoryRoot, ".codegraph"),
|
|
66353
66800
|
npmGlobalInstallState: "forbidden",
|
|
66354
66801
|
overrides: {
|
|
66355
66802
|
stateRootEnv: "ARCHCONTEXT_STATE_DIR",
|
|
@@ -66638,8 +67085,8 @@ async function startBackgroundDaemon(args, cwd) {
|
|
|
66638
67085
|
const recovery = discovered.recovery;
|
|
66639
67086
|
const connectionPath = defaultDaemonConnectionPath(cwd);
|
|
66640
67087
|
const controlDir = dirname16(connectionPath);
|
|
66641
|
-
const logPath =
|
|
66642
|
-
|
|
67088
|
+
const logPath = join28(controlDir, "archctxd.log");
|
|
67089
|
+
mkdirSync17(controlDir, { recursive: true });
|
|
66643
67090
|
const logFd = openSync14(logPath, "a", 384);
|
|
66644
67091
|
try {
|
|
66645
67092
|
let childExit;
|
|
@@ -66963,7 +67410,7 @@ function sleep2(ms) {
|
|
|
66963
67410
|
}
|
|
66964
67411
|
function readFileTail(path, maxBytes = 4096) {
|
|
66965
67412
|
try {
|
|
66966
|
-
const content =
|
|
67413
|
+
const content = readFileSync34(path, "utf8");
|
|
66967
67414
|
return content.slice(Math.max(0, content.length - maxBytes)).replace(/\s+/g, " ").trim();
|
|
66968
67415
|
} catch {
|
|
66969
67416
|
return "<unavailable>";
|
|
@@ -67065,7 +67512,7 @@ function cliArgumentFailure(requestId, message) {
|
|
|
67065
67512
|
};
|
|
67066
67513
|
}
|
|
67067
67514
|
function loadResolveModel(cwd) {
|
|
67068
|
-
if (!existsSync35(
|
|
67515
|
+
if (!existsSync35(join28(cwd, ".archcontext/manifest.yaml"))) {
|
|
67069
67516
|
throw new NativeContextError("native-context-model-missing", { path: ".archcontext/manifest.yaml" });
|
|
67070
67517
|
}
|
|
67071
67518
|
let model;
|
|
@@ -67121,7 +67568,7 @@ async function readResolvePathsFrom(args, cwd, deps) {
|
|
|
67121
67568
|
return { problem: "resolve --paths-from requires a file path or - for stdin" };
|
|
67122
67569
|
let content;
|
|
67123
67570
|
try {
|
|
67124
|
-
content = source === "-" ? await (deps.readStdin ? deps.readStdin() :
|
|
67571
|
+
content = source === "-" ? await (deps.readStdin ? deps.readStdin() : readFileSync34(0, "utf8")) : readFileSync34(resolve37(cwd, source), "utf8");
|
|
67125
67572
|
} catch (error) {
|
|
67126
67573
|
return { problem: `resolve --paths-from ${source} is not readable: ${error instanceof Error ? error.message : String(error)}` };
|
|
67127
67574
|
}
|
|
@@ -67209,7 +67656,7 @@ function readRepositoryInputFile(cwd, flag, file) {
|
|
|
67209
67656
|
const absolute = assertPathHasNoSymlinkSegments2(cwd, file);
|
|
67210
67657
|
if (!statSync12(absolute).isFile())
|
|
67211
67658
|
return { problem: `plan ${flag} ${file} is not a regular file` };
|
|
67212
|
-
return { content:
|
|
67659
|
+
return { content: readFileSync34(absolute, "utf8") };
|
|
67213
67660
|
} catch (error) {
|
|
67214
67661
|
return { problem: `plan ${flag} ${file} is not readable: ${error instanceof Error ? error.message : String(error)}` };
|
|
67215
67662
|
}
|
|
@@ -67230,7 +67677,7 @@ function runHashCommand(args, cwd) {
|
|
|
67230
67677
|
if (!existsSync35(absolute) || !statSync12(absolute).isFile()) {
|
|
67231
67678
|
return errorEnvelope("hash", "AC_SCHEMA_INVALID", `hash --path is not an existing file: ${path}`);
|
|
67232
67679
|
}
|
|
67233
|
-
return okEnvelope("hash", { path, hash: digestJson({ body:
|
|
67680
|
+
return okEnvelope("hash", { path, hash: digestJson({ body: readFileSync34(absolute, "utf8") }) });
|
|
67234
67681
|
}
|
|
67235
67682
|
async function readCliPlanOperations(args, cwd, deps) {
|
|
67236
67683
|
if (args.includes("--operations-file")) {
|
|
@@ -67240,7 +67687,7 @@ async function readCliPlanOperations(args, cwd, deps) {
|
|
|
67240
67687
|
const file = readFlag(args, "--operations-file");
|
|
67241
67688
|
if (!file)
|
|
67242
67689
|
return "plan --operations-file requires a path";
|
|
67243
|
-
const read = file === "-" ? { content: await (deps.readStdin ? deps.readStdin() :
|
|
67690
|
+
const read = file === "-" ? { content: await (deps.readStdin ? deps.readStdin() : readFileSync34(0, "utf8")) } : readRepositoryInputFile(cwd, "--operations-file", file);
|
|
67244
67691
|
if ("problem" in read)
|
|
67245
67692
|
return read.problem;
|
|
67246
67693
|
let parsed;
|
|
@@ -67302,7 +67749,7 @@ async function readCliPlanBody(args, cwd, deps) {
|
|
|
67302
67749
|
return { problem: "plan --body requires a value (use - to read stdin)" };
|
|
67303
67750
|
if (inline !== "-")
|
|
67304
67751
|
return inline;
|
|
67305
|
-
return deps.readStdin ? deps.readStdin() :
|
|
67752
|
+
return deps.readStdin ? deps.readStdin() : readFileSync34(0, "utf8");
|
|
67306
67753
|
}
|
|
67307
67754
|
function readFlag(args, flag) {
|
|
67308
67755
|
const index = args.indexOf(flag);
|