archctx 0.10.0 → 0.11.0
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 +770 -420
- 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 = [];
|
|
@@ -3022,6 +3038,7 @@ var init_failure = __esm(() => {
|
|
|
3022
3038
|
"pending-source-changes": "CodeGraph repository index has pending or unreported source changes"
|
|
3023
3039
|
});
|
|
3024
3040
|
policies = {
|
|
3041
|
+
"history-shallow-repository": { code: "AC_PRECONDITION_FAILED", message: "Architecture history requires a complete Git repository.", action: "unshallow-repository" },
|
|
3025
3042
|
"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
3043
|
"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
3044
|
"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: {} },
|
|
@@ -3424,6 +3441,7 @@ var init_failure = __esm(() => {
|
|
|
3424
3441
|
],
|
|
3425
3442
|
operation: [
|
|
3426
3443
|
"rev-parse",
|
|
3444
|
+
"log",
|
|
3427
3445
|
"ls-tree",
|
|
3428
3446
|
"ls-files",
|
|
3429
3447
|
"cat-file"
|
|
@@ -4101,7 +4119,7 @@ function compareVersionTriples(left, right) {
|
|
|
4101
4119
|
}
|
|
4102
4120
|
return 0;
|
|
4103
4121
|
}
|
|
4104
|
-
var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.
|
|
4122
|
+
var ARCHCONTEXT_PRODUCT_NAME = "archctx", ARCHCONTEXT_PRODUCT_VERSION = "0.11.0", 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
4123
|
|
|
4106
4124
|
// packages/contracts/src/refactor.ts
|
|
4107
4125
|
function refactorNamespaceIssues(value, label = "product.id") {
|
|
@@ -5194,6 +5212,7 @@ var init_refactor = __esm(() => {
|
|
|
5194
5212
|
var init_src = __esm(() => {
|
|
5195
5213
|
init_control_plane_routes();
|
|
5196
5214
|
init_architecture();
|
|
5215
|
+
init_architecture_history();
|
|
5197
5216
|
init_architecture_debt();
|
|
5198
5217
|
init_docs_anchors();
|
|
5199
5218
|
init_github_governance();
|
|
@@ -15657,7 +15676,7 @@ import { basename, posix, resolve as resolve6 } from "node:path";
|
|
|
15657
15676
|
var composer = require_composer();
|
|
15658
15677
|
var Document = require_Document();
|
|
15659
15678
|
var Schema = require_Schema();
|
|
15660
|
-
var
|
|
15679
|
+
var errors2 = require_errors();
|
|
15661
15680
|
var Alias = require_Alias();
|
|
15662
15681
|
var identity = require_identity();
|
|
15663
15682
|
var Pair = require_Pair();
|
|
@@ -15673,9 +15692,9 @@ var visit2 = require_visit();
|
|
|
15673
15692
|
var $Composer = composer.Composer;
|
|
15674
15693
|
var $Document = Document.Document;
|
|
15675
15694
|
var $Schema = Schema.Schema;
|
|
15676
|
-
var $YAMLError =
|
|
15677
|
-
var $YAMLParseError =
|
|
15678
|
-
var $YAMLWarning =
|
|
15695
|
+
var $YAMLError = errors2.YAMLError;
|
|
15696
|
+
var $YAMLParseError = errors2.YAMLParseError;
|
|
15697
|
+
var $YAMLWarning = errors2.YAMLWarning;
|
|
15679
15698
|
var $Alias = Alias.Alias;
|
|
15680
15699
|
var $isAlias = identity.isAlias;
|
|
15681
15700
|
var $isCollection = identity.isCollection;
|
|
@@ -16019,6 +16038,114 @@ function sourceIncludeAnchors(patterns) {
|
|
|
16019
16038
|
});
|
|
16020
16039
|
return [...new Set(anchors)].sort(nativeByteCompare);
|
|
16021
16040
|
}
|
|
16041
|
+
// packages/core/projection-engine/src/architecture-history.ts
|
|
16042
|
+
init_src();
|
|
16043
|
+
var ARCHITECTURE_HISTORY_PATH = "docs/architecture/history.md";
|
|
16044
|
+
var HISTORY_DETAIL_EDGE_LIMIT = 20;
|
|
16045
|
+
var capabilityDomain = (id) => id === null ? null : /^capability\.([a-z0-9]+(?:-[a-z0-9]+)*)\.([a-z0-9]+(?:-[a-z0-9]+)*)$/.exec(id)?.[1] ?? null;
|
|
16046
|
+
var compare2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
16047
|
+
function renderHistoryMermaid(milestone, mode = "full") {
|
|
16048
|
+
if (!milestone.nodes)
|
|
16049
|
+
return null;
|
|
16050
|
+
const removed = mode === "changes" ? milestone.delta.removed.filter((node) => node.kind === "capability") : [];
|
|
16051
|
+
const nodes = mode === "changes" ? [...milestone.nodes, ...removed.map((node) => ({
|
|
16052
|
+
id: node.id,
|
|
16053
|
+
name: node.id,
|
|
16054
|
+
domain: capabilityDomain(node.id)
|
|
16055
|
+
}))].sort((a, b) => compare2(a.id, b.id)) : milestone.nodes;
|
|
16056
|
+
const keys = new Map(nodes.map((node, index) => [node.id, `n${index}`]));
|
|
16057
|
+
const label = (node) => ` ${keys.get(node.id)}["${node.name.replaceAll('"', "#quot;")}"]`;
|
|
16058
|
+
const domains = [...new Set(nodes.flatMap((node) => node.domain === null ? [] : [node.domain]))].sort();
|
|
16059
|
+
const lines = ["flowchart LR"];
|
|
16060
|
+
for (const domain of domains) {
|
|
16061
|
+
lines.push(` subgraph ${JSON.stringify(domain)}`);
|
|
16062
|
+
lines.push(...nodes.filter((node) => node.domain === domain).map((node) => ` ${label(node)}`));
|
|
16063
|
+
lines.push(" end");
|
|
16064
|
+
}
|
|
16065
|
+
lines.push(...nodes.filter((node) => node.domain === null).map(label));
|
|
16066
|
+
const added = mode === "changes" ? milestone.delta.edgesChanged.added : milestone.edges;
|
|
16067
|
+
lines.push(...added.map((edge) => ` ${keys.get(edge.source)} --> ${keys.get(edge.target)}`));
|
|
16068
|
+
if (mode === "changes")
|
|
16069
|
+
lines.push(...milestone.delta.edgesChanged.removed.map((edge) => ` ${keys.get(edge.source)} -.-> ${keys.get(edge.target)}`));
|
|
16070
|
+
if (removed.length) {
|
|
16071
|
+
lines.push(...removed.map((node) => ` class ${keys.get(node.id)} removed`));
|
|
16072
|
+
lines.push(" classDef removed stroke-dasharray: 4 4");
|
|
16073
|
+
}
|
|
16074
|
+
return lines.join(`
|
|
16075
|
+
`);
|
|
16076
|
+
}
|
|
16077
|
+
function renderHistoryDomainOverview(milestone) {
|
|
16078
|
+
if (!milestone.nodes)
|
|
16079
|
+
return null;
|
|
16080
|
+
const counts = new Map;
|
|
16081
|
+
const ensure = (domain) => {
|
|
16082
|
+
if (!counts.has(domain))
|
|
16083
|
+
counts.set(domain, 0);
|
|
16084
|
+
};
|
|
16085
|
+
for (const node of milestone.nodes) {
|
|
16086
|
+
const domain = node.domain ?? "ungrouped";
|
|
16087
|
+
counts.set(domain, (counts.get(domain) ?? 0) + 1);
|
|
16088
|
+
}
|
|
16089
|
+
const changed = new Set;
|
|
16090
|
+
for (const item of [...milestone.delta.added, ...milestone.delta.removed, ...milestone.delta.renamed]) {
|
|
16091
|
+
const domain = capabilityDomain(item.capability) ?? "ungrouped";
|
|
16092
|
+
ensure(domain);
|
|
16093
|
+
changed.add(domain);
|
|
16094
|
+
}
|
|
16095
|
+
const pairs = new Map;
|
|
16096
|
+
for (const [kind, edges] of [["added", milestone.delta.edgesChanged.added], ["removed", milestone.delta.edgesChanged.removed]]) {
|
|
16097
|
+
for (const edge of edges) {
|
|
16098
|
+
const source = capabilityDomain(edge.source) ?? "ungrouped", target = capabilityDomain(edge.target) ?? "ungrouped";
|
|
16099
|
+
ensure(source);
|
|
16100
|
+
ensure(target);
|
|
16101
|
+
changed.add(source);
|
|
16102
|
+
changed.add(target);
|
|
16103
|
+
if (source === target)
|
|
16104
|
+
continue;
|
|
16105
|
+
const key = JSON.stringify([source, target]);
|
|
16106
|
+
const pair = pairs.get(key) ?? { source, target, added: 0, removed: 0 };
|
|
16107
|
+
pair[kind]++;
|
|
16108
|
+
pairs.set(key, pair);
|
|
16109
|
+
}
|
|
16110
|
+
}
|
|
16111
|
+
const domains = [...counts.keys()].sort();
|
|
16112
|
+
const keys = new Map(domains.map((domain, index) => [domain, `d${index}`]));
|
|
16113
|
+
const lines = ["flowchart LR", ...domains.map((domain) => ` ${keys.get(domain)}["${domain} (${counts.get(domain)})"]`)];
|
|
16114
|
+
for (const pair of [...pairs.values()].sort((a, b) => compare2(a.source, b.source) || compare2(a.target, b.target))) {
|
|
16115
|
+
const arrow = pair.added === 0 ? "-.->" : "-->";
|
|
16116
|
+
lines.push(` ${keys.get(pair.source)} ${arrow}|+${pair.added} −${pair.removed}| ${keys.get(pair.target)}`);
|
|
16117
|
+
}
|
|
16118
|
+
if (changed.size) {
|
|
16119
|
+
lines.push(...domains.filter((domain) => changed.has(domain)).map((domain) => ` class ${keys.get(domain)} changed`));
|
|
16120
|
+
lines.push(" classDef changed stroke-width:3px");
|
|
16121
|
+
}
|
|
16122
|
+
return { mermaid: lines.join(`
|
|
16123
|
+
`), pairCount: pairs.size };
|
|
16124
|
+
}
|
|
16125
|
+
function projectHistoryMermaid(history) {
|
|
16126
|
+
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) })) };
|
|
16127
|
+
}
|
|
16128
|
+
function renderHistoryMarkdown(history) {
|
|
16129
|
+
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.`, ""];
|
|
16130
|
+
for (const milestone of [...history.milestones].reverse()) {
|
|
16131
|
+
lines.push(`## ${milestone.date.slice(0, 10)} · ${milestone.rev.slice(0, 12)}`, "", milestone.subject, "");
|
|
16132
|
+
if (milestone.error)
|
|
16133
|
+
lines.push(milestone.error.code, "");
|
|
16134
|
+
else {
|
|
16135
|
+
const delta = milestone.delta;
|
|
16136
|
+
const overview = renderHistoryDomainOverview(milestone);
|
|
16137
|
+
const edgeCount = delta.edgesChanged.added.length + delta.edgesChanged.removed.length;
|
|
16138
|
+
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, "```", "");
|
|
16139
|
+
if (edgeCount <= HISTORY_DETAIL_EDGE_LIMIT)
|
|
16140
|
+
lines.push("```mermaid", renderHistoryMermaid(milestone, "changes"), "```", "");
|
|
16141
|
+
else
|
|
16142
|
+
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.`, "");
|
|
16143
|
+
}
|
|
16144
|
+
}
|
|
16145
|
+
return `${lines.join(`
|
|
16146
|
+
`)}
|
|
16147
|
+
`;
|
|
16148
|
+
}
|
|
16022
16149
|
|
|
16023
16150
|
// packages/core/projection-engine/src/index.ts
|
|
16024
16151
|
init_src();
|
|
@@ -22198,7 +22325,7 @@ function sameOwners(left, right) {
|
|
|
22198
22325
|
|
|
22199
22326
|
// packages/core/module-statistics/src/index.ts
|
|
22200
22327
|
function evaluateDependencyConstraints(input) {
|
|
22201
|
-
const constraints = [...input.constraints].sort((left, right) =>
|
|
22328
|
+
const constraints = [...input.constraints].sort((left, right) => compare3(left.id, right.id));
|
|
22202
22329
|
const certification = certifyCodeFacts(input.codeFacts, input.worktreeDigest, input.truncated, input.importNodeLimitExceeded ?? false);
|
|
22203
22330
|
if (constraints.length === 0) {
|
|
22204
22331
|
return {
|
|
@@ -22276,7 +22403,7 @@ function evaluateDependencyConstraints(input) {
|
|
|
22276
22403
|
reasonCodes.add("unresolved-import");
|
|
22277
22404
|
if (input.workspacePackagesResolved === false)
|
|
22278
22405
|
reasonCodes.add("workspace-resolution-failed");
|
|
22279
|
-
const sortedViolations = [...violations.values()].sort((left, right) =>
|
|
22406
|
+
const sortedViolations = [...violations.values()].sort((left, right) => compare3(left.constraintId, right.constraintId) || compare3(left.fromPath, right.fromPath) || compare3(left.toPath, right.toPath));
|
|
22280
22407
|
return {
|
|
22281
22408
|
schemaVersion: "archcontext.dependency-constraint-evaluation/v1",
|
|
22282
22409
|
status: sortedViolations.length > 0 ? "violated" : reasonCodes.size > 0 ? "undetermined" : "pass",
|
|
@@ -22353,7 +22480,7 @@ function measureCapabilityDependencies(input) {
|
|
|
22353
22480
|
const cellKey = JSON.stringify([from.capability, to.capability]);
|
|
22354
22481
|
let cell = cells.get(cellKey);
|
|
22355
22482
|
if (cell === undefined) {
|
|
22356
|
-
const relationIds = [...new Set(declaringRelations.get(cellKey) ?? [])].sort(
|
|
22483
|
+
const relationIds = [...new Set(declaringRelations.get(cellKey) ?? [])].sort(compare3);
|
|
22357
22484
|
cell = { from: from.capability, to: to.capability, imports: 0, calls: null, declared: from.capability === to.capability || relationIds.length > 0, relationIds };
|
|
22358
22485
|
cells.set(cellKey, cell);
|
|
22359
22486
|
}
|
|
@@ -22361,14 +22488,14 @@ function measureCapabilityDependencies(input) {
|
|
|
22361
22488
|
attributedEdges.push({ fromPath: edge.from, toPath: edge.to, fromCapability: from.capability, toCapability: to.capability });
|
|
22362
22489
|
}
|
|
22363
22490
|
const edgeLimit = input.edgeLimit ?? CAPABILITY_DEPENDENCIES_EDGE_LIMIT;
|
|
22364
|
-
attributedEdges.sort((left, right) =>
|
|
22491
|
+
attributedEdges.sort((left, right) => compare3(left.fromPath, right.fromPath) || compare3(left.toPath, right.toPath));
|
|
22365
22492
|
const listed = attributedEdges.slice(0, edgeLimit);
|
|
22366
22493
|
return {
|
|
22367
22494
|
schemaVersion: CAPABILITY_DEPENDENCIES_SCHEMA_VERSION,
|
|
22368
22495
|
ownershipRule: "parent-chain",
|
|
22369
22496
|
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) =>
|
|
22497
|
+
capabilities: input.nodes.filter((node) => node.kind === "capability").map((node) => node.id).sort(compare3),
|
|
22498
|
+
matrix: [...cells.values()].sort((left, right) => compare3(left.from, right.from) || compare3(left.to, right.to)),
|
|
22372
22499
|
imports: {
|
|
22373
22500
|
coverage: certification.coverage,
|
|
22374
22501
|
reasonCodes: [...certification.reasonCodes].sort(),
|
|
@@ -22404,7 +22531,7 @@ function isRepositoryLocalSpecifier(specifier, workspacePackages) {
|
|
|
22404
22531
|
return true;
|
|
22405
22532
|
return workspacePackages.some((workspacePackage) => specifier === workspacePackage.name || specifier.startsWith(`${workspacePackage.name}/`));
|
|
22406
22533
|
}
|
|
22407
|
-
function
|
|
22534
|
+
function compare3(left, right) {
|
|
22408
22535
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
22409
22536
|
}
|
|
22410
22537
|
function measureModuleStatistics(input) {
|
|
@@ -22489,7 +22616,7 @@ function modelDigest(model, constraints) {
|
|
|
22489
22616
|
nodes: [...model.nodes].sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0),
|
|
22490
22617
|
relations: [...model.relations].sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0),
|
|
22491
22618
|
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) =>
|
|
22619
|
+
...constraints.length === 0 ? {} : { constraints: [...constraints].sort((left, right) => compare3(left.id, right.id)) }
|
|
22493
22620
|
});
|
|
22494
22621
|
}
|
|
22495
22622
|
function countViolationsByNode(evaluation) {
|
|
@@ -23118,17 +23245,21 @@ function assertNativeGitRevision(ref) {
|
|
|
23118
23245
|
throw new NativeContextError("native-context-ref-unsafe", { selector: "ref" });
|
|
23119
23246
|
}
|
|
23120
23247
|
function readOnlyGit(root, operation, args, options = {}) {
|
|
23121
|
-
if (!["rev-parse", "ls-tree", "ls-files", "cat-file"].includes(operation))
|
|
23248
|
+
if (!["rev-parse", "ls-tree", "ls-files", "cat-file", "log"].includes(operation))
|
|
23122
23249
|
throw new NativeContextError("native-context-git-read-failed", { category: "unsupported-operation" });
|
|
23123
23250
|
const unsafeArguments = () => {
|
|
23124
23251
|
throw new NativeContextError("native-context-git-read-failed", { operation, category: "unsupported-read-arguments" });
|
|
23125
23252
|
};
|
|
23126
23253
|
if (operation === "rev-parse") {
|
|
23127
|
-
if (args.length === 1 &&
|
|
23254
|
+
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
23255
|
assertNativeGitRevision(args[2]);
|
|
23129
23256
|
else
|
|
23130
23257
|
unsafeArguments();
|
|
23131
23258
|
}
|
|
23259
|
+
if (operation === "log") {
|
|
23260
|
+
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")
|
|
23261
|
+
unsafeArguments();
|
|
23262
|
+
}
|
|
23132
23263
|
if (operation === "ls-tree") {
|
|
23133
23264
|
const flags = args.slice(0, -1);
|
|
23134
23265
|
if (!flags.includes("-r") || !flags.includes("-z") || flags.some((flag) => !["-r", "-z", "-t", "-l"].includes(flag)) || new Set(flags).size !== flags.length)
|
|
@@ -23154,7 +23285,7 @@ function readOnlyGit(root, operation, args, options = {}) {
|
|
|
23154
23285
|
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
23286
|
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
23287
|
delete env[key];
|
|
23157
|
-
const result = spawnSync("git", ["--no-pager", "--no-replace-objects", "-c", "core.fsmonitor=false", operation, ...args], {
|
|
23288
|
+
const result = spawnSync("git", ["--no-pager", "--no-replace-objects", "-c", "core.fsmonitor=false", ...operation === "log" ? ["-c", "log.showSignature=false"] : [], operation, ...args], {
|
|
23158
23289
|
cwd: root,
|
|
23159
23290
|
env,
|
|
23160
23291
|
input: options.input,
|
|
@@ -23832,10 +23963,10 @@ function record5(value) {
|
|
|
23832
23963
|
function text(value) {
|
|
23833
23964
|
return typeof value === "string" && value.length > 0;
|
|
23834
23965
|
}
|
|
23835
|
-
function
|
|
23966
|
+
function node2(value) {
|
|
23836
23967
|
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
23968
|
}
|
|
23838
|
-
function
|
|
23969
|
+
function edge2(value) {
|
|
23839
23970
|
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
23971
|
}
|
|
23841
23972
|
function fileRecord(value) {
|
|
@@ -23882,12 +24013,12 @@ function decodeReader(output, root, request) {
|
|
|
23882
24013
|
}
|
|
23883
24014
|
return result;
|
|
23884
24015
|
};
|
|
23885
|
-
const names = table(wire.names, (value) => rows(value,
|
|
24016
|
+
const names = table(wire.names, (value) => rows(value, node2));
|
|
23886
24017
|
sameKeys(names, request.names);
|
|
23887
24018
|
for (const [name, nodes] of names)
|
|
23888
24019
|
if (nodes.some((item) => item.name !== name))
|
|
23889
24020
|
unavailable();
|
|
23890
|
-
const filesByPath = table(wire.filesByPath, (value) => rows(value,
|
|
24021
|
+
const filesByPath = table(wire.filesByPath, (value) => rows(value, node2));
|
|
23891
24022
|
const sources = new Map;
|
|
23892
24023
|
const sourcePaths = new Set(request.sources.map((source) => source.path));
|
|
23893
24024
|
for (const source of request.sources) {
|
|
@@ -23901,7 +24032,7 @@ function decodeReader(output, root, request) {
|
|
|
23901
24032
|
}
|
|
23902
24033
|
}
|
|
23903
24034
|
sameKeys(filesByPath, sourcePaths);
|
|
23904
|
-
const outgoing = table(wire.outgoing, (value) => rows(value,
|
|
24035
|
+
const outgoing = table(wire.outgoing, (value) => rows(value, edge2));
|
|
23905
24036
|
sameKeys(outgoing, sources.keys());
|
|
23906
24037
|
const targetIds = new Set;
|
|
23907
24038
|
for (const [id, edges] of outgoing)
|
|
@@ -23911,7 +24042,7 @@ function decodeReader(output, root, request) {
|
|
|
23911
24042
|
targetIds.add(item.target);
|
|
23912
24043
|
}
|
|
23913
24044
|
const targets = table(wire.targets, (value) => {
|
|
23914
|
-
if (++items > MAX_ITEMS || value !== null && !
|
|
24045
|
+
if (++items > MAX_ITEMS || value !== null && !node2(value))
|
|
23915
24046
|
return unavailable();
|
|
23916
24047
|
return value;
|
|
23917
24048
|
});
|
|
@@ -26417,10 +26548,10 @@ function selectedProducerFailureEnvelope(requestId, error, stage) {
|
|
|
26417
26548
|
// packages/local-runtime/runtime-daemon/src/refactor-scan.ts
|
|
26418
26549
|
init_src();
|
|
26419
26550
|
init_src();
|
|
26420
|
-
import { execFileSync as
|
|
26421
|
-
import { createHash as
|
|
26422
|
-
import { existsSync as existsSync8, readdirSync as
|
|
26423
|
-
import { join as
|
|
26551
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
26552
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
26553
|
+
import { existsSync as existsSync8, readdirSync as readdirSync7, readFileSync as readFileSync10 } from "node:fs";
|
|
26554
|
+
import { join as join7 } from "node:path";
|
|
26424
26555
|
|
|
26425
26556
|
// packages/core/refactor-assessment/src/index.ts
|
|
26426
26557
|
init_src();
|
|
@@ -27263,7 +27394,7 @@ function buildObservations(snapshot, structure, model) {
|
|
|
27263
27394
|
evidence: evidence.evidenceGap()
|
|
27264
27395
|
});
|
|
27265
27396
|
}
|
|
27266
|
-
return drafts.map((draft, index) => ({ draft, order: draft.kind === "cycle" ? index : 0 })).sort((left, right) =>
|
|
27397
|
+
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
27398
|
kind: draft.kind,
|
|
27268
27399
|
subjectSelectorId: draft.subjectSelectorId,
|
|
27269
27400
|
affectedNodeIds: draft.affectedNodeIds,
|
|
@@ -27453,13 +27584,13 @@ function signalIdFor(draft) {
|
|
|
27453
27584
|
}
|
|
27454
27585
|
function modelDigest2(model, constraints) {
|
|
27455
27586
|
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) =>
|
|
27587
|
+
nodes: [...model.nodes].sort((left, right) => compare4(left.id, right.id)),
|
|
27588
|
+
relations: [...model.relations].sort((left, right) => compare4(left.id, right.id)),
|
|
27589
|
+
flows: [...model.flows ?? []].sort((left, right) => compare4(left.id, right.id)),
|
|
27590
|
+
...constraints.length === 0 ? {} : { constraints: [...constraints].sort((left, right) => compare4(left.id, right.id)) }
|
|
27460
27591
|
});
|
|
27461
27592
|
}
|
|
27462
|
-
function
|
|
27593
|
+
function compare4(left, right) {
|
|
27463
27594
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
27464
27595
|
}
|
|
27465
27596
|
function isNumber(value) {
|
|
@@ -27471,8 +27602,117 @@ function isPresent2(value) {
|
|
|
27471
27602
|
|
|
27472
27603
|
// packages/local-runtime/model-store-yaml/src/index.ts
|
|
27473
27604
|
init_src();
|
|
27474
|
-
import { existsSync as existsSync7, lstatSync as lstatSync6, mkdirSync as
|
|
27475
|
-
import { dirname as dirname5, resolve as
|
|
27605
|
+
import { existsSync as existsSync7, lstatSync as lstatSync6, mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync9, rmSync as rmSync5 } from "node:fs";
|
|
27606
|
+
import { dirname as dirname5, resolve as resolve13 } from "node:path";
|
|
27607
|
+
|
|
27608
|
+
// packages/local-runtime/model-store-yaml/src/architecture-history.ts
|
|
27609
|
+
init_src();
|
|
27610
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync8, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
27611
|
+
import { join as join5 } from "node:path";
|
|
27612
|
+
import { randomUUID } from "node:crypto";
|
|
27613
|
+
|
|
27614
|
+
// packages/local-runtime/runtime-state-paths/src/index.ts
|
|
27615
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
27616
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
27617
|
+
import { readdirSync as readdirSync5, realpathSync as realpathSync4 } from "node:fs";
|
|
27618
|
+
import { homedir } from "node:os";
|
|
27619
|
+
import { isAbsolute as isAbsolute5, join as join4, resolve as resolve11 } from "node:path";
|
|
27620
|
+
var ARCHCONTEXT_STATE_DIR_ENV = "ARCHCONTEXT_STATE_DIR";
|
|
27621
|
+
var ARCHCONTEXT_LOCAL_STORE_PATH_ENV = "ARCHCONTEXT_LOCAL_STORE_PATH";
|
|
27622
|
+
function defaultArchContextStateRoot(env = process.env, platform = process.platform, home = homedir()) {
|
|
27623
|
+
const override = env[ARCHCONTEXT_STATE_DIR_ENV];
|
|
27624
|
+
if (override)
|
|
27625
|
+
return { path: resolve11(override), source: "environment" };
|
|
27626
|
+
if (platform === "darwin")
|
|
27627
|
+
return { path: join4(home, "Library", "Application Support", "ArchContext"), source: "os-user-data" };
|
|
27628
|
+
if (platform === "win32")
|
|
27629
|
+
return { path: join4(env.LOCALAPPDATA ?? join4(home, "AppData", "Local"), "ArchContext"), source: "os-user-data" };
|
|
27630
|
+
return { path: join4(env.XDG_DATA_HOME ?? join4(home, ".local", "share"), "archcontext"), source: "os-user-data" };
|
|
27631
|
+
}
|
|
27632
|
+
function runtimeStatePaths(root = process.cwd(), env = process.env) {
|
|
27633
|
+
const repositoryRoot = readGitPath(root, ["rev-parse", "--show-toplevel"]) ?? root;
|
|
27634
|
+
const canonicalRepositoryRoot = canonicalPath(repositoryRoot);
|
|
27635
|
+
const gitCommonDir = readGitPath(canonicalRepositoryRoot, ["rev-parse", "--git-common-dir"]);
|
|
27636
|
+
const repositoryAnchor = canonicalPath(gitCommonDir ? resolveMaybeRelative(canonicalRepositoryRoot, gitCommonDir) : canonicalRepositoryRoot);
|
|
27637
|
+
const workspaceAnchor = canonicalRepositoryRoot;
|
|
27638
|
+
const storageRepositoryId = stableStorageId("repo", repositoryAnchor);
|
|
27639
|
+
const storageWorkspaceId = stableStorageId("ws", workspaceAnchor);
|
|
27640
|
+
const stateRoot = defaultArchContextStateRoot(env);
|
|
27641
|
+
const repositoryStateDir = join4(stateRoot.path, REPOSITORIES_DIR, storageRepositoryId);
|
|
27642
|
+
const workspaceStateDir = join4(repositoryStateDir, WORKTREES_DIR, storageWorkspaceId);
|
|
27643
|
+
const legacyControlDir = resolve11(canonicalRepositoryRoot, ".archcontext", ".local");
|
|
27644
|
+
return {
|
|
27645
|
+
schemaVersion: "archcontext.runtime-state-paths/v1",
|
|
27646
|
+
stateRoot: stateRoot.path,
|
|
27647
|
+
source: stateRoot.source,
|
|
27648
|
+
repositoryRoot: canonicalRepositoryRoot,
|
|
27649
|
+
repositoryAnchor,
|
|
27650
|
+
workspaceAnchor,
|
|
27651
|
+
storageRepositoryId,
|
|
27652
|
+
storageWorkspaceId,
|
|
27653
|
+
repositoryId: storageRepositoryId,
|
|
27654
|
+
workspaceId: storageWorkspaceId,
|
|
27655
|
+
repositoryStateDir,
|
|
27656
|
+
workspaceStateDir,
|
|
27657
|
+
sharedCacheDir: join4(repositoryStateDir, "shared", "cache"),
|
|
27658
|
+
localStorePath: env[ARCHCONTEXT_LOCAL_STORE_PATH_ENV] ?? join4(workspaceStateDir, "runtime.sqlite"),
|
|
27659
|
+
...daemonControlPaths(workspaceStateDir),
|
|
27660
|
+
developerReviewRunStateDir: join4(workspaceStateDir, "developer-review-runs"),
|
|
27661
|
+
legacyControlDir,
|
|
27662
|
+
legacyLocalStorePath: join4(legacyControlDir, "runtime.sqlite")
|
|
27663
|
+
};
|
|
27664
|
+
}
|
|
27665
|
+
var REPOSITORIES_DIR = "repositories";
|
|
27666
|
+
var WORKTREES_DIR = "worktrees";
|
|
27667
|
+
function daemonControlPaths(workspaceStateDir) {
|
|
27668
|
+
return {
|
|
27669
|
+
daemonConnectionPath: join4(workspaceStateDir, "archctxd.json"),
|
|
27670
|
+
daemonLockPath: join4(workspaceStateDir, "archctxd.lock"),
|
|
27671
|
+
daemonLogPath: join4(workspaceStateDir, "archctxd.log")
|
|
27672
|
+
};
|
|
27673
|
+
}
|
|
27674
|
+
function listWorkspaceStateDirs(stateRoot) {
|
|
27675
|
+
return listDirectoryNames(join4(stateRoot, REPOSITORIES_DIR)).flatMap((storageRepositoryId) => listDirectoryNames(join4(stateRoot, REPOSITORIES_DIR, storageRepositoryId, WORKTREES_DIR)).map((storageWorkspaceId) => ({
|
|
27676
|
+
storageRepositoryId,
|
|
27677
|
+
storageWorkspaceId,
|
|
27678
|
+
workspaceStateDir: join4(stateRoot, REPOSITORIES_DIR, storageRepositoryId, WORKTREES_DIR, storageWorkspaceId)
|
|
27679
|
+
})));
|
|
27680
|
+
}
|
|
27681
|
+
function listDirectoryNames(path) {
|
|
27682
|
+
try {
|
|
27683
|
+
return readdirSync5(path, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
27684
|
+
} catch (error) {
|
|
27685
|
+
if (error.code === "ENOENT")
|
|
27686
|
+
return [];
|
|
27687
|
+
throw error;
|
|
27688
|
+
}
|
|
27689
|
+
}
|
|
27690
|
+
function readGitPath(root, args) {
|
|
27691
|
+
try {
|
|
27692
|
+
const value = execFileSync3("git", args, {
|
|
27693
|
+
cwd: root,
|
|
27694
|
+
encoding: "utf8",
|
|
27695
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
27696
|
+
}).trim();
|
|
27697
|
+
return value.length > 0 ? value : undefined;
|
|
27698
|
+
} catch {
|
|
27699
|
+
return;
|
|
27700
|
+
}
|
|
27701
|
+
}
|
|
27702
|
+
function resolveMaybeRelative(base, path) {
|
|
27703
|
+
return isAbsolute5(path) ? resolve11(path) : resolve11(base, path);
|
|
27704
|
+
}
|
|
27705
|
+
function canonicalPath(path) {
|
|
27706
|
+
const resolved = resolve11(path);
|
|
27707
|
+
try {
|
|
27708
|
+
return realpathSync4.native(resolved);
|
|
27709
|
+
} catch {
|
|
27710
|
+
return resolved;
|
|
27711
|
+
}
|
|
27712
|
+
}
|
|
27713
|
+
function stableStorageId(prefix, value) {
|
|
27714
|
+
return `${prefix}.${createHash6("sha256").update(value).digest("hex").slice(0, 16)}`;
|
|
27715
|
+
}
|
|
27476
27716
|
// schemas/repo/architecture-node.schema.json
|
|
27477
27717
|
var architecture_node_schema_default = {
|
|
27478
27718
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -27593,12 +27833,6 @@ var architecture_node_schema_default = {
|
|
|
27593
27833
|
extensions: { type: "object", additionalProperties: true }
|
|
27594
27834
|
}
|
|
27595
27835
|
};
|
|
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
27836
|
// schemas/repo/architecture-relation.schema.json
|
|
27603
27837
|
var architecture_relation_schema_default = {
|
|
27604
27838
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -27626,6 +27860,185 @@ var architecture_relation_schema_default = {
|
|
|
27626
27860
|
extensions: { type: "object", additionalProperties: true }
|
|
27627
27861
|
}
|
|
27628
27862
|
};
|
|
27863
|
+
|
|
27864
|
+
// packages/local-runtime/model-store-yaml/src/architecture-history.ts
|
|
27865
|
+
var compare5 = nativeByteCompare;
|
|
27866
|
+
var modelRoot = ".archcontext/model";
|
|
27867
|
+
var failed = (code, path) => ({ nodes: null, edges: null, structure: null, error: { code, ...path ? { path } : {} } });
|
|
27868
|
+
var edgeKey = (e) => JSON.stringify([e.source, e.target]);
|
|
27869
|
+
function stateForRevision(root, rev, parsed) {
|
|
27870
|
+
try {
|
|
27871
|
+
let context;
|
|
27872
|
+
try {
|
|
27873
|
+
context = readGitBlobTree(root, `${rev}:.archcontext`, { sizes: false });
|
|
27874
|
+
} catch (error) {
|
|
27875
|
+
if (!(error instanceof NativeContextError) || error.reasonCode !== "native-context-git-read-failed")
|
|
27876
|
+
throw error;
|
|
27877
|
+
if (readGitBlobTree(root, rev, { sizes: false }).some((entry) => entry.path === ".archcontext" && entry.type === "tree"))
|
|
27878
|
+
throw error;
|
|
27879
|
+
return failed("history-model-missing");
|
|
27880
|
+
}
|
|
27881
|
+
const manifest = context.find((entry) => entry.path === "manifest.yaml");
|
|
27882
|
+
if (manifest && manifest.type !== "blob")
|
|
27883
|
+
return failed("history-model-layout-unsupported");
|
|
27884
|
+
const read = (entry) => {
|
|
27885
|
+
if (!parsed.has(entry.objectId)) {
|
|
27886
|
+
const body = readGitBlobs(root, [entry])[0];
|
|
27887
|
+
try {
|
|
27888
|
+
parsed.set(entry.objectId, { value: parseJsonOrStableYaml(decodeUtf8(body), entry.path) });
|
|
27889
|
+
} catch {
|
|
27890
|
+
parsed.set(entry.objectId, { invalid: true });
|
|
27891
|
+
}
|
|
27892
|
+
}
|
|
27893
|
+
return parsed.get(entry.objectId);
|
|
27894
|
+
};
|
|
27895
|
+
if (manifest) {
|
|
27896
|
+
const data = read(manifest);
|
|
27897
|
+
if (data.value?.schemaVersion !== "archcontext.manifest/v1" || data.value.model?.layout !== "split" || data.value.model.root !== modelRoot)
|
|
27898
|
+
return failed("history-model-layout-unsupported");
|
|
27899
|
+
}
|
|
27900
|
+
if (!context.some((entry) => entry.path === "model" && entry.type === "tree"))
|
|
27901
|
+
return failed("history-model-missing");
|
|
27902
|
+
const all = readGitBlobTree(root, `${rev}:${modelRoot}`, { sizes: false }).map((entry) => ({ ...entry, path: `${modelRoot}/${entry.path}` }));
|
|
27903
|
+
const nodesDir = all.find((entry) => entry.path === `${modelRoot}/nodes` && entry.type === "tree");
|
|
27904
|
+
if (!nodesDir)
|
|
27905
|
+
return failed("history-model-missing");
|
|
27906
|
+
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));
|
|
27907
|
+
const missing = [...new Map(files.filter((file) => !parsed.has(file.objectId)).map((file) => [file.objectId, file])).values()];
|
|
27908
|
+
const blobs = readGitBlobs(root, missing);
|
|
27909
|
+
missing.forEach((file, index) => {
|
|
27910
|
+
try {
|
|
27911
|
+
parsed.set(file.objectId, { value: parseJsonOrStableYaml(decodeUtf8(blobs[index]), file.path) });
|
|
27912
|
+
} catch {
|
|
27913
|
+
parsed.set(file.objectId, { invalid: true });
|
|
27914
|
+
}
|
|
27915
|
+
});
|
|
27916
|
+
const nodes = [], relations = [];
|
|
27917
|
+
const paths = new Map;
|
|
27918
|
+
for (const file of files) {
|
|
27919
|
+
const result = read(file);
|
|
27920
|
+
const isNode = file.path.startsWith(`${modelRoot}/nodes/`);
|
|
27921
|
+
if (result.invalid || result.value === undefined || !validateJsonSchema(isNode ? architecture_node_schema_default : architecture_relation_schema_default, result.value).valid)
|
|
27922
|
+
return failed("history-model-invalid", file.path);
|
|
27923
|
+
if (isNode) {
|
|
27924
|
+
const value = result.value;
|
|
27925
|
+
if (paths.has(value.id))
|
|
27926
|
+
return failed("history-model-invalid", file.path);
|
|
27927
|
+
paths.set(value.id, file.path);
|
|
27928
|
+
nodes.push(value);
|
|
27929
|
+
} else
|
|
27930
|
+
relations.push(result.value);
|
|
27931
|
+
}
|
|
27932
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
27933
|
+
for (const node of nodes) {
|
|
27934
|
+
const visited = new Set;
|
|
27935
|
+
let cursor = node;
|
|
27936
|
+
while (cursor) {
|
|
27937
|
+
if (visited.has(cursor.id))
|
|
27938
|
+
return failed("history-model-invalid", paths.get(node.id));
|
|
27939
|
+
visited.add(cursor.id);
|
|
27940
|
+
cursor = cursor.parent ? byId.get(cursor.parent) : undefined;
|
|
27941
|
+
}
|
|
27942
|
+
}
|
|
27943
|
+
const nearest = (id) => {
|
|
27944
|
+
let node = byId.get(id);
|
|
27945
|
+
while (node) {
|
|
27946
|
+
if (node.kind === "capability")
|
|
27947
|
+
return node.id;
|
|
27948
|
+
node = node.parent ? byId.get(node.parent) : undefined;
|
|
27949
|
+
}
|
|
27950
|
+
return;
|
|
27951
|
+
};
|
|
27952
|
+
const edges = new Map;
|
|
27953
|
+
for (const relation of relations) {
|
|
27954
|
+
const source = nearest(relation.source), target = nearest(relation.target);
|
|
27955
|
+
if (source && target && source !== target) {
|
|
27956
|
+
const edge = { source, target };
|
|
27957
|
+
edges.set(edgeKey(edge), edge);
|
|
27958
|
+
}
|
|
27959
|
+
}
|
|
27960
|
+
return {
|
|
27961
|
+
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)),
|
|
27962
|
+
edges: [...edges.values()].sort((a, b) => compare5(a.source, b.source) || compare5(a.target, b.target)),
|
|
27963
|
+
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))
|
|
27964
|
+
};
|
|
27965
|
+
} catch (error) {
|
|
27966
|
+
if (error instanceof NativeContextError && error.reasonCode === "native-context-limit-exceeded")
|
|
27967
|
+
return failed("history-model-too-large");
|
|
27968
|
+
throw error;
|
|
27969
|
+
}
|
|
27970
|
+
}
|
|
27971
|
+
function difference(before, after, baseRev) {
|
|
27972
|
+
const a = new Map(before.structure.map((node) => [node.id, node])), b = new Map(after.structure.map((node) => [node.id, node]));
|
|
27973
|
+
const ae = new Map(before.edges.map((edge) => [edgeKey(edge), edge])), be = new Map(after.edges.map((edge) => [edgeKey(edge), edge]));
|
|
27974
|
+
return {
|
|
27975
|
+
baseRev,
|
|
27976
|
+
added: after.structure.filter((node) => !a.has(node.id)).map(({ id, kind, capability }) => ({ id, kind, capability })),
|
|
27977
|
+
removed: before.structure.filter((node) => !b.has(node.id)).map(({ id, kind, capability }) => ({ id, kind, capability })),
|
|
27978
|
+
renamed: after.structure.flatMap((node) => {
|
|
27979
|
+
const old = a.get(node.id);
|
|
27980
|
+
return old && old.name !== node.name ? [{ id: node.id, kind: node.kind, capability: node.capability, from: old.name, to: node.name }] : [];
|
|
27981
|
+
}),
|
|
27982
|
+
edgesChanged: { added: after.edges.filter((edge) => !ae.has(edgeKey(edge))), removed: before.edges.filter((edge) => !be.has(edgeKey(edge))) }
|
|
27983
|
+
};
|
|
27984
|
+
}
|
|
27985
|
+
function readArchitectureHistory(cwd, options = {}) {
|
|
27986
|
+
const root = readNativeGitRoot(cwd);
|
|
27987
|
+
if (decodeUtf8(readOnlyGit(root, "rev-parse", ["--is-shallow-repository"])).trim() === "true")
|
|
27988
|
+
throw new FailureError("AC_PRECONDITION_FAILED", "history-shallow-repository");
|
|
27989
|
+
const head = resolveNativeGitSnapshot(root, options.ref ?? "HEAD").commitSha;
|
|
27990
|
+
const output = decodeUtf8(readOnlyGit(root, "log", ["--first-parent", "--reverse", "-z", "--format=%H%x00%cI%x00%s", head, "--", modelRoot, ".archcontext/manifest.yaml"]));
|
|
27991
|
+
const fields = output ? output.split("\x00") : [];
|
|
27992
|
+
if (fields.length && fields.pop() !== "")
|
|
27993
|
+
throw new NativeContextError("native-context-git-read-failed", { operation: "log", category: "malformed-record" });
|
|
27994
|
+
if (fields.length % 3 !== 0)
|
|
27995
|
+
throw new NativeContextError("native-context-git-read-failed", { operation: "log", category: "malformed-record" });
|
|
27996
|
+
for (let i = 0;i < fields.length; i += 3)
|
|
27997
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(fields[i]))
|
|
27998
|
+
throw new NativeContextError("native-context-git-read-failed", { operation: "log", category: "malformed-record" });
|
|
27999
|
+
const parsed = new Map;
|
|
28000
|
+
const milestones = [];
|
|
28001
|
+
let previous = { nodes: [], edges: [], structure: [] };
|
|
28002
|
+
let havePrevious = false, priorError, previousMilestone = null;
|
|
28003
|
+
const cacheDir = join5(runtimeStatePaths(root, options.env).sharedCacheDir, "architecture-history", ARCHITECTURE_HISTORY_DERIVATION_VERSION);
|
|
28004
|
+
for (let i = 0;i < fields.length; i += 3) {
|
|
28005
|
+
const [rev, date, subject] = fields.slice(i, i + 3);
|
|
28006
|
+
const cache = join5(cacheDir, `${rev}.json`);
|
|
28007
|
+
let state;
|
|
28008
|
+
try {
|
|
28009
|
+
state = decodeArchitectureHistoryState(JSON.parse(readFileSync8(cache, "utf8")));
|
|
28010
|
+
} catch {}
|
|
28011
|
+
if (!state) {
|
|
28012
|
+
state = stateForRevision(root, rev, parsed);
|
|
28013
|
+
mkdirSync5(cacheDir, { recursive: true });
|
|
28014
|
+
const temporary = `${cache}.${randomUUID()}.tmp`;
|
|
28015
|
+
writeFileSync4(temporary, JSON.stringify(state));
|
|
28016
|
+
renameSync3(temporary, cache);
|
|
28017
|
+
}
|
|
28018
|
+
if (state.error) {
|
|
28019
|
+
if (priorError !== state.error.code)
|
|
28020
|
+
milestones.push({ rev, date, subject, nodes: null, edges: null, delta: null, error: state.error });
|
|
28021
|
+
priorError = state.error.code;
|
|
28022
|
+
continue;
|
|
28023
|
+
}
|
|
28024
|
+
const recovered = priorError !== undefined;
|
|
28025
|
+
priorError = undefined;
|
|
28026
|
+
const delta = difference(previous, state, previousMilestone);
|
|
28027
|
+
if (!havePrevious || recovered || delta.added.length || delta.removed.length || delta.renamed.length || delta.edgesChanged.added.length || delta.edgesChanged.removed.length) {
|
|
28028
|
+
milestones.push({ rev, date, subject, nodes: state.nodes, edges: state.edges, delta });
|
|
28029
|
+
previousMilestone = rev;
|
|
28030
|
+
previous = state;
|
|
28031
|
+
havePrevious = true;
|
|
28032
|
+
}
|
|
28033
|
+
}
|
|
28034
|
+
const offset = options.offset ?? 0, limit = options.limit ?? 200;
|
|
28035
|
+
return { schemaVersion: ARCHITECTURE_HISTORY_SCHEMA_VERSION, head, total: milestones.length, offset, limit, milestones: milestones.slice(offset, offset + limit) };
|
|
28036
|
+
}
|
|
28037
|
+
// packages/local-runtime/model-store-yaml/src/native-context.ts
|
|
28038
|
+
init_src();
|
|
28039
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
28040
|
+
import { constants, closeSync as closeSync4, fstatSync as fstatSync2, lstatSync as lstatSync5, openSync as openSync4, readSync as readSync2, realpathSync as realpathSync5 } from "node:fs";
|
|
28041
|
+
import { join as join6, resolve as resolve12 } from "node:path";
|
|
27629
28042
|
// schemas/repo/architecture-flow.schema.json
|
|
27630
28043
|
var architecture_flow_schema_default = {
|
|
27631
28044
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -27730,7 +28143,7 @@ var SCHEMAS = { node: architecture_node_schema_default, relation: architecture_r
|
|
|
27730
28143
|
var MANIFEST = ".archcontext/manifest.yaml";
|
|
27731
28144
|
var MODEL_KINDS = ["nodes", "relations", "flows"];
|
|
27732
28145
|
function contentDigest(bytes) {
|
|
27733
|
-
return `sha256:${
|
|
28146
|
+
return `sha256:${createHash7("sha256").update(bytes).digest("hex")}`;
|
|
27734
28147
|
}
|
|
27735
28148
|
function record6(value) {
|
|
27736
28149
|
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype ? value : undefined;
|
|
@@ -27858,23 +28271,23 @@ function observePath(root, path, directory = false) {
|
|
|
27858
28271
|
const segments = path.split("/");
|
|
27859
28272
|
for (let index = -1;index < segments.length; index += 1) {
|
|
27860
28273
|
if (index >= 0)
|
|
27861
|
-
absolute =
|
|
28274
|
+
absolute = join6(absolute, segments[index]);
|
|
27862
28275
|
let stat;
|
|
27863
28276
|
try {
|
|
27864
28277
|
stat = lstatSync5(absolute, { bigint: true });
|
|
27865
28278
|
} catch (error) {
|
|
27866
28279
|
if (error.code === "ENOENT")
|
|
27867
|
-
return { exists: false, identity: identities.join("/") + "/missing", absolute:
|
|
28280
|
+
return { exists: false, identity: identities.join("/") + "/missing", absolute: resolve12(root, path) };
|
|
27868
28281
|
throw new NativeContextError("native-context-input-unreadable", { path, category: "stat" });
|
|
27869
28282
|
}
|
|
27870
28283
|
const needsDirectory = index < segments.length - 1 || directory;
|
|
27871
28284
|
if (stat.isSymbolicLink() || (needsDirectory ? !stat.isDirectory() : !stat.isFile()))
|
|
27872
28285
|
throw new NativeContextError("native-context-entry-kind-unsupported", { path, category: stat.isSymbolicLink() ? "link" : "non-regular" });
|
|
27873
|
-
if (index >= 0 &&
|
|
28286
|
+
if (index >= 0 && realpathSync5.native(absolute) !== absolute)
|
|
27874
28287
|
throw new NativeContextError("native-context-path-unsafe", { path, category: "filesystem-path-alias" });
|
|
27875
28288
|
if (needsDirectory && index >= 0) {
|
|
27876
28289
|
try {
|
|
27877
|
-
lstatSync5(
|
|
28290
|
+
lstatSync5(join6(absolute, ".git"));
|
|
27878
28291
|
throw new NativeContextError("native-context-entry-kind-unsupported", { path: segments.slice(0, index + 1).join("/"), category: "nested-repository" });
|
|
27879
28292
|
} catch (error) {
|
|
27880
28293
|
if (error instanceof NativeContextError)
|
|
@@ -28218,7 +28631,7 @@ function readNativeContext(start, selector, hooks) {
|
|
|
28218
28631
|
`, "utf8"));
|
|
28219
28632
|
return data;
|
|
28220
28633
|
}
|
|
28221
|
-
const worktreeRoot =
|
|
28634
|
+
const worktreeRoot = realpathSync5.native(root);
|
|
28222
28635
|
const head = resolveNativeGitSnapshot(worktreeRoot, "HEAD");
|
|
28223
28636
|
const snapshot = { source: "worktree", headSha: head.commitSha, headTreeOid: head.treeOid, validation: "stable-read" };
|
|
28224
28637
|
const first = new WorktreeSource(worktreeRoot, hooks, 1, head.treeOid);
|
|
@@ -28254,7 +28667,7 @@ init_src();
|
|
|
28254
28667
|
|
|
28255
28668
|
// packages/local-runtime/codegraph-adapter/src/ref-impact-facts.ts
|
|
28256
28669
|
init_src();
|
|
28257
|
-
import { createHash as
|
|
28670
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
28258
28671
|
import { createRequire as createRequire3 } from "node:module";
|
|
28259
28672
|
var nonDeclarations = new Set(["file", "import", "export", "parameter"]);
|
|
28260
28673
|
var requireFromAdapter2 = createRequire3(import.meta.url);
|
|
@@ -28288,7 +28701,7 @@ function bindSnapshotRefImpactFacts(root, model, ref, graph) {
|
|
|
28288
28701
|
for (let i = 0;i < files.length; i++) {
|
|
28289
28702
|
const file = files[i], body = blobs[i];
|
|
28290
28703
|
const content = decodeUtf8(body);
|
|
28291
|
-
if (
|
|
28704
|
+
if (createHash8("sha256").update(content).digest("hex") !== file.contentHash)
|
|
28292
28705
|
return;
|
|
28293
28706
|
lineCounts.set(file.path, content.split(`
|
|
28294
28707
|
`).length);
|
|
@@ -28767,10 +29180,10 @@ function initializeArchContextModel(root, productName = "ArchContext Project") {
|
|
|
28767
29180
|
});
|
|
28768
29181
|
files.push({ path: ".archcontext/projections/targets.json", body: `${JSON.stringify(createDefaultProjectionTargetManifest(), null, 2)}
|
|
28769
29182
|
` });
|
|
28770
|
-
|
|
29183
|
+
mkdirSync6(root, { recursive: true });
|
|
28771
29184
|
const existing = files.filter((file) => {
|
|
28772
29185
|
assertPathHasNoSymlinkSegments(root, file.path);
|
|
28773
|
-
return lstatIfExists(
|
|
29186
|
+
return lstatIfExists(resolve13(root, file.path)) !== undefined;
|
|
28774
29187
|
}).map((file) => file.path);
|
|
28775
29188
|
if (existing.length > 0)
|
|
28776
29189
|
throw new ArchContextInitRefusedError(existing);
|
|
@@ -28783,7 +29196,7 @@ function initializeArchContextModel(root, productName = "ArchContext Project") {
|
|
|
28783
29196
|
rebuildGeneratedProjection(root);
|
|
28784
29197
|
} catch (error) {
|
|
28785
29198
|
for (const path of created.reverse())
|
|
28786
|
-
rmSync5(
|
|
29199
|
+
rmSync5(resolve13(root, path), { force: true });
|
|
28787
29200
|
throw error;
|
|
28788
29201
|
}
|
|
28789
29202
|
}
|
|
@@ -28791,7 +29204,7 @@ function rebuildGeneratedProjection(root) {
|
|
|
28791
29204
|
for (const operation of planGeneratedProjection(root)) {
|
|
28792
29205
|
if (operation.operation === "delete_entity") {
|
|
28793
29206
|
assertPathHasNoSymlinkSegments(root, dirname5(operation.path));
|
|
28794
|
-
rmSync5(
|
|
29207
|
+
rmSync5(resolve13(root, operation.path), { force: true });
|
|
28795
29208
|
} else {
|
|
28796
29209
|
writeFileWithoutFollowingSymlinks({ root, path: operation.path, body: withTrailingNewline(operation.body), expectedHash: operation.expectedHash });
|
|
28797
29210
|
}
|
|
@@ -28799,12 +29212,12 @@ function rebuildGeneratedProjection(root) {
|
|
|
28799
29212
|
}
|
|
28800
29213
|
function planGeneratedProjection(root) {
|
|
28801
29214
|
const desiredBody = GENERATED_ARCHITECTURE_BODY;
|
|
28802
|
-
const desiredAbsolute =
|
|
29215
|
+
const desiredAbsolute = resolve13(root, GENERATED_ARCHITECTURE_PATH);
|
|
28803
29216
|
const operations = [];
|
|
28804
|
-
if (!existsSync7(desiredAbsolute) ||
|
|
29217
|
+
if (!existsSync7(desiredAbsolute) || readFileSync9(desiredAbsolute, "utf8") !== desiredBody) {
|
|
28805
29218
|
operations.push({
|
|
28806
29219
|
path: GENERATED_ARCHITECTURE_PATH,
|
|
28807
|
-
expectedHash: existsSync7(desiredAbsolute) ? digestJson({ body:
|
|
29220
|
+
expectedHash: existsSync7(desiredAbsolute) ? digestJson({ body: readFileSync9(desiredAbsolute, "utf8") }) : "missing",
|
|
28808
29221
|
body: desiredBody,
|
|
28809
29222
|
operation: "render_projection"
|
|
28810
29223
|
});
|
|
@@ -28812,7 +29225,7 @@ function planGeneratedProjection(root) {
|
|
|
28812
29225
|
for (const path of collectGeneratedProjectionFiles(root)) {
|
|
28813
29226
|
if (path === GENERATED_ARCHITECTURE_PATH)
|
|
28814
29227
|
continue;
|
|
28815
|
-
const body =
|
|
29228
|
+
const body = readFileSync9(resolve13(root, path), "utf8");
|
|
28816
29229
|
operations.push({
|
|
28817
29230
|
path,
|
|
28818
29231
|
expectedHash: digestJson({ body }),
|
|
@@ -28824,9 +29237,9 @@ function planGeneratedProjection(root) {
|
|
|
28824
29237
|
}
|
|
28825
29238
|
function collectGeneratedProjectionFiles(root) {
|
|
28826
29239
|
const generatedRoot = ".archcontext/generated";
|
|
28827
|
-
if (!existsSync7(
|
|
29240
|
+
if (!existsSync7(resolve13(root, generatedRoot)))
|
|
28828
29241
|
return [];
|
|
28829
|
-
const walk = (relativeDir) =>
|
|
29242
|
+
const walk = (relativeDir) => readdirSync6(resolve13(root, relativeDir), { withFileTypes: true }).flatMap((entry) => {
|
|
28830
29243
|
const child = `${relativeDir}/${entry.name}`;
|
|
28831
29244
|
if (entry.isDirectory())
|
|
28832
29245
|
return walk(child);
|
|
@@ -28837,7 +29250,7 @@ function collectGeneratedProjectionFiles(root) {
|
|
|
28837
29250
|
|
|
28838
29251
|
class YamlModelStore {
|
|
28839
29252
|
async loadManifest(workspace) {
|
|
28840
|
-
return
|
|
29253
|
+
return readFileSync9(resolve13(workspace.root, ".archcontext/manifest.yaml"), "utf8");
|
|
28841
29254
|
}
|
|
28842
29255
|
async loadModel(workspace) {
|
|
28843
29256
|
return listModelFiles(workspace.root);
|
|
@@ -28848,7 +29261,7 @@ class YamlModelStore {
|
|
|
28848
29261
|
const nodeSchemaErrors = [];
|
|
28849
29262
|
for (const required of [".archcontext/manifest.yaml", ".archcontext/product.yaml"]) {
|
|
28850
29263
|
try {
|
|
28851
|
-
|
|
29264
|
+
readFileSync9(resolve13(workspace.root, required), "utf8");
|
|
28852
29265
|
} catch {
|
|
28853
29266
|
const error = `missing ${required}`;
|
|
28854
29267
|
errors.push(error);
|
|
@@ -28945,7 +29358,7 @@ function listModelFiles(root) {
|
|
|
28945
29358
|
"docs/adr"
|
|
28946
29359
|
]);
|
|
28947
29360
|
return paths.map((path) => {
|
|
28948
|
-
const body =
|
|
29361
|
+
const body = readFileSync9(resolve13(root, path), "utf8");
|
|
28949
29362
|
return {
|
|
28950
29363
|
path,
|
|
28951
29364
|
body,
|
|
@@ -28957,7 +29370,7 @@ function listModelFiles(root) {
|
|
|
28957
29370
|
function collectArchContextFiles(root, entries) {
|
|
28958
29371
|
const files = [];
|
|
28959
29372
|
for (const entry of entries) {
|
|
28960
|
-
const absolute =
|
|
29373
|
+
const absolute = resolve13(root, entry);
|
|
28961
29374
|
if (!existsSync7(absolute))
|
|
28962
29375
|
continue;
|
|
28963
29376
|
const stat = readdirOrFile(absolute);
|
|
@@ -28971,8 +29384,8 @@ function collectArchContextFiles(root, entries) {
|
|
|
28971
29384
|
return [...new Set(files)].sort();
|
|
28972
29385
|
function walk(relativeDir) {
|
|
28973
29386
|
const out = [];
|
|
28974
|
-
const dir =
|
|
28975
|
-
for (const entry of
|
|
29387
|
+
const dir = resolve13(root, relativeDir);
|
|
29388
|
+
for (const entry of readdirSync6(dir, { withFileTypes: true })) {
|
|
28976
29389
|
const child = `${relativeDir}/${entry.name}`;
|
|
28977
29390
|
if (entry.isDirectory())
|
|
28978
29391
|
out.push(...walk(child));
|
|
@@ -28989,7 +29402,7 @@ function isCollectableModelFile(path) {
|
|
|
28989
29402
|
}
|
|
28990
29403
|
function readdirOrFile(path) {
|
|
28991
29404
|
try {
|
|
28992
|
-
|
|
29405
|
+
readdirSync6(path);
|
|
28993
29406
|
return "directory";
|
|
28994
29407
|
} catch {
|
|
28995
29408
|
return "file";
|
|
@@ -32452,10 +32865,10 @@ function evaluateWorktreeDependencyConstraints(input) {
|
|
|
32452
32865
|
});
|
|
32453
32866
|
}
|
|
32454
32867
|
function reviewWorkspacePackages(root) {
|
|
32455
|
-
if (!existsSync8(
|
|
32868
|
+
if (!existsSync8(join7(root, "package.json")))
|
|
32456
32869
|
return { packages: [], resolved: true };
|
|
32457
32870
|
try {
|
|
32458
|
-
const manifest = JSON.parse(
|
|
32871
|
+
const manifest = JSON.parse(readFileSync10(join7(root, "package.json"), "utf8"));
|
|
32459
32872
|
const declared = Array.isArray(manifest.workspaces) ? manifest.workspaces : manifest.workspaces?.packages ?? [];
|
|
32460
32873
|
if (!Array.isArray(declared))
|
|
32461
32874
|
throw new Error("workspaces must be a list");
|
|
@@ -32468,10 +32881,10 @@ function reviewWorkspacePackages(root) {
|
|
|
32468
32881
|
const parent = /^([^*?[\]{}!]+)\/\*$/.exec(pattern)?.[1];
|
|
32469
32882
|
if (parent === undefined)
|
|
32470
32883
|
throw new Error(`unsupported workspace pattern: ${entry}`);
|
|
32471
|
-
return
|
|
32884
|
+
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
32885
|
});
|
|
32473
32886
|
const packages = directories.flatMap((directory) => {
|
|
32474
|
-
const packageManifest = JSON.parse(
|
|
32887
|
+
const packageManifest = JSON.parse(readFileSync10(join7(root, ...directory.split("/"), "package.json"), "utf8"));
|
|
32475
32888
|
if (typeof packageManifest.name !== "string")
|
|
32476
32889
|
return [];
|
|
32477
32890
|
const exports = typeof packageManifest.exports === "string" ? { ".": packageManifest.exports } : Object.fromEntries(Object.entries(packageManifest.exports ?? {}).filter((entry) => typeof entry[1] === "string"));
|
|
@@ -32497,7 +32910,7 @@ function modelNodes(files) {
|
|
|
32497
32910
|
function readWorktreeFiles(root) {
|
|
32498
32911
|
let output;
|
|
32499
32912
|
try {
|
|
32500
|
-
output =
|
|
32913
|
+
output = execFileSync4("git", ["ls-files", "--cached", "--others", "--exclude-standard", "-z"], {
|
|
32501
32914
|
cwd: root,
|
|
32502
32915
|
encoding: "utf8",
|
|
32503
32916
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -32513,7 +32926,7 @@ function countFilesOutsideHead(root) {
|
|
|
32513
32926
|
return readWorktreeFiles(root).filter((path) => !head.has(path)).length;
|
|
32514
32927
|
}
|
|
32515
32928
|
function declaredWorkspacePackages(root) {
|
|
32516
|
-
return existsSync8(
|
|
32929
|
+
return existsSync8(join7(root, "package.json")) ? readWorkspacePackages(root) : [];
|
|
32517
32930
|
}
|
|
32518
32931
|
function assertRequestedStateIsCurrent(request, worktree) {
|
|
32519
32932
|
if (request.expectedHeadSha !== undefined && request.expectedHeadSha !== worktree.headSha) {
|
|
@@ -32525,13 +32938,13 @@ function assertRequestedStateIsCurrent(request, worktree) {
|
|
|
32525
32938
|
}
|
|
32526
32939
|
var REFACTOR_NAMESPACE_MANIFEST_PATH = ".archcontext/manifest.yaml";
|
|
32527
32940
|
function readRefactorNamespace(root) {
|
|
32528
|
-
const path =
|
|
32941
|
+
const path = join7(root, REFACTOR_NAMESPACE_MANIFEST_PATH);
|
|
32529
32942
|
if (!existsSync8(path)) {
|
|
32530
32943
|
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
32944
|
}
|
|
32532
32945
|
let manifest;
|
|
32533
32946
|
try {
|
|
32534
|
-
manifest = parseJsonOrStableYaml(
|
|
32947
|
+
manifest = parseJsonOrStableYaml(readFileSync10(path, "utf8"), REFACTOR_NAMESPACE_MANIFEST_PATH);
|
|
32535
32948
|
} catch (error) {
|
|
32536
32949
|
throw new RefactorScanError("AC_SCHEMA_INVALID", `${REFACTOR_NAMESPACE_MANIFEST_PATH} is unreadable: ${error instanceof Error ? error.message : String(error)}`, "product-id-invalid");
|
|
32537
32950
|
}
|
|
@@ -32573,7 +32986,7 @@ function readCodeFacts(root, worktreeDigest, edgeLimit) {
|
|
|
32573
32986
|
}
|
|
32574
32987
|
function attestCodeGraphBinary(root) {
|
|
32575
32988
|
const invocation = codeGraphCliInvocation(CODEGRAPH_BINARY, root);
|
|
32576
|
-
const version =
|
|
32989
|
+
const version = execFileSync4(invocation.command, [...invocation.argsPrefix, "--version"], {
|
|
32577
32990
|
cwd: root,
|
|
32578
32991
|
encoding: "utf8",
|
|
32579
32992
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -32582,7 +32995,7 @@ function attestCodeGraphBinary(root) {
|
|
|
32582
32995
|
const binaryPath = invocation.argsPrefix[0] ?? invocation.command;
|
|
32583
32996
|
return {
|
|
32584
32997
|
version,
|
|
32585
|
-
binaryDigest: `sha256:${
|
|
32998
|
+
binaryDigest: `sha256:${createHash9("sha256").update(readFileSync10(binaryPath)).digest("hex")}`
|
|
32586
32999
|
};
|
|
32587
33000
|
}
|
|
32588
33001
|
|
|
@@ -32679,8 +33092,8 @@ function unavailable2(reasons) {
|
|
|
32679
33092
|
// packages/local-runtime/runtime-daemon/src/docs-anchors.ts
|
|
32680
33093
|
init_src();
|
|
32681
33094
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
32682
|
-
import { readFileSync as
|
|
32683
|
-
import { resolve as
|
|
33095
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
33096
|
+
import { resolve as resolve16 } from "node:path";
|
|
32684
33097
|
|
|
32685
33098
|
// packages/local-runtime/runtime-daemon/src/projection-service.ts
|
|
32686
33099
|
init_src();
|
|
@@ -33957,8 +34370,8 @@ class ChangeSetRecoveryUnresolvedError extends FailureError {
|
|
|
33957
34370
|
|
|
33958
34371
|
// packages/local-runtime/runtime-daemon/src/projection-freshness.ts
|
|
33959
34372
|
init_src();
|
|
33960
|
-
import { readFileSync as
|
|
33961
|
-
import { posix as posix3, resolve as
|
|
34373
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
34374
|
+
import { posix as posix3, resolve as resolve14 } from "node:path";
|
|
33962
34375
|
function evaluateProjectionFreshness(input) {
|
|
33963
34376
|
const { model, profile, manifest, sourceFootprints, scope } = input;
|
|
33964
34377
|
return scope.kind === "tree" ? evaluateArchitectureProjectionSnapshotFreshness({ model, profile, manifest, sourceFootprints, currentSourceTreeDigest: scope.currentSourceTreeDigest }) : evaluateArchitectureProjectionFreshness({ model, profile, manifest, sourceFootprints, nodeIds: scope.nodeIds });
|
|
@@ -33983,7 +34396,7 @@ function measureProjectionFreshness(root, options = {}) {
|
|
|
33983
34396
|
assertProjectionFreshnessChangedPaths(options.changedPaths);
|
|
33984
34397
|
const manifest = options.manifest ?? loadArchitectureProjectionManifestStamps(root);
|
|
33985
34398
|
if (manifest.status === "manifest-unreadable") {
|
|
33986
|
-
assertArchitectureDocsProjectionManifestAccepted(
|
|
34399
|
+
assertArchitectureDocsProjectionManifestAccepted(readFileSync11(resolve14(root, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH), "utf8"));
|
|
33987
34400
|
}
|
|
33988
34401
|
const model = loadNativeModelFromArchContext(root);
|
|
33989
34402
|
const profile = manifest.status === "present" ? loadArchitectureDocumentationProfile(root) : undefined;
|
|
@@ -34129,15 +34542,15 @@ function publicOperationResult(requestId, result) {
|
|
|
34129
34542
|
}
|
|
34130
34543
|
|
|
34131
34544
|
// packages/local-runtime/runtime-daemon/src/projection-service.ts
|
|
34132
|
-
import { existsSync as existsSync9, readFileSync as
|
|
34133
|
-
import { resolve as
|
|
34545
|
+
import { existsSync as existsSync9, readFileSync as readFileSync12 } from "node:fs";
|
|
34546
|
+
import { resolve as resolve15 } from "node:path";
|
|
34134
34547
|
|
|
34135
34548
|
// packages/local-runtime/runtime-daemon/src/projection-inputs.ts
|
|
34136
|
-
import { execFileSync as
|
|
34549
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
34137
34550
|
init_src();
|
|
34138
34551
|
function readCurrentBranch(root) {
|
|
34139
34552
|
try {
|
|
34140
|
-
const branch =
|
|
34553
|
+
const branch = execFileSync5("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
34141
34554
|
cwd: root,
|
|
34142
34555
|
encoding: "utf8",
|
|
34143
34556
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -34453,7 +34866,7 @@ function architectureModelIgnoredEnvelope(requestId, root) {
|
|
|
34453
34866
|
});
|
|
34454
34867
|
}
|
|
34455
34868
|
function committedArchitectureDocsProfile(root) {
|
|
34456
|
-
return existsSync9(
|
|
34869
|
+
return existsSync9(resolve15(root, ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH)) ? loadArchitectureDocumentationProfile(root) : "default";
|
|
34457
34870
|
}
|
|
34458
34871
|
function withProjectionMetadata(envelope, provenance, runtimeSnapshot, majorChange, refreshSignals, receiptDigest) {
|
|
34459
34872
|
if (!envelope.ok)
|
|
@@ -34867,8 +35280,8 @@ function runProjectionCheckCommandUnchecked(request, root) {
|
|
|
34867
35280
|
return publicFailureEnvelope("projection.run", "AC_SCHEMA_INVALID", "projection-check-mode-invalid");
|
|
34868
35281
|
}
|
|
34869
35282
|
const manifestPath = ".archcontext/manifest.yaml";
|
|
34870
|
-
if (existsSync9(
|
|
34871
|
-
const diagnostics = manifestDecisionDiagnostics([{ path: manifestPath, body:
|
|
35283
|
+
if (existsSync9(resolve15(root, manifestPath))) {
|
|
35284
|
+
const diagnostics = manifestDecisionDiagnostics([{ path: manifestPath, body: readFileSync12(resolve15(root, manifestPath), "utf8") }]);
|
|
34872
35285
|
if (diagnostics.length)
|
|
34873
35286
|
return publicFailureEnvelope("projection.run", "AC_SCHEMA_INVALID", "native-context-model-invalid", { path: manifestPath, invariant: diagnostics[0] });
|
|
34874
35287
|
}
|
|
@@ -35758,7 +36171,7 @@ function fileContentReader(root) {
|
|
|
35758
36171
|
return (path) => {
|
|
35759
36172
|
let content = cache.get(path);
|
|
35760
36173
|
if (content === undefined) {
|
|
35761
|
-
content =
|
|
36174
|
+
content = readFileSync13(resolve16(root, path), "utf8").replace(/\r\n/g, `
|
|
35762
36175
|
`);
|
|
35763
36176
|
cache.set(path, content);
|
|
35764
36177
|
}
|
|
@@ -35826,7 +36239,7 @@ function proseAnchorSymbols(reader, files, contents) {
|
|
|
35826
36239
|
|
|
35827
36240
|
// packages/local-runtime/runtime-daemon/src/architecture-debt.ts
|
|
35828
36241
|
import { existsSync as existsSync10 } from "node:fs";
|
|
35829
|
-
import { join as
|
|
36242
|
+
import { join as join8 } from "node:path";
|
|
35830
36243
|
function readArchitectureDebt(root, input = {}) {
|
|
35831
36244
|
try {
|
|
35832
36245
|
const { evidence } = readArchitectureDebtEvidence(root, input);
|
|
@@ -35852,7 +36265,7 @@ function readArchitectureDebtEvidence(root, input) {
|
|
|
35852
36265
|
const changedPaths = [...new Set(input.changedPaths ?? [])].sort();
|
|
35853
36266
|
if (changedPaths.some((path) => !isRepoRelativePosixPath(path)))
|
|
35854
36267
|
throw new ArchitectureDebtReadError("AC_SCHEMA_INVALID", "changedPaths must contain repository-relative POSIX paths", "changed-path-invalid");
|
|
35855
|
-
if (!existsSync10(
|
|
36268
|
+
if (!existsSync10(join8(root, ".archcontext/manifest.yaml")))
|
|
35856
36269
|
throw new ArchitectureDebtReadError("AC_MODEL_ADOPTION_REQUIRED", "Architecture debt requires an adopted architecture model", "model-missing");
|
|
35857
36270
|
const model = loadNativeModelFromArchContext(root);
|
|
35858
36271
|
const files = listGitVisibleFiles(root);
|
|
@@ -35995,7 +36408,7 @@ function runNativeContextCommand(args, cwd, reader = exportNativeContext) {
|
|
|
35995
36408
|
// packages/surfaces/cli/src/ref-impact.ts
|
|
35996
36409
|
init_src();
|
|
35997
36410
|
import { openSync as openSync5, closeSync as closeSync5, readSync as readSync3 } from "node:fs";
|
|
35998
|
-
import { resolve as
|
|
36411
|
+
import { resolve as resolve17 } from "node:path";
|
|
35999
36412
|
var invalid2 = (category) => {
|
|
36000
36413
|
throw new NativeContextError("native-context-arguments-invalid", { category });
|
|
36001
36414
|
};
|
|
@@ -36038,7 +36451,7 @@ function runRefImpactCommand(args, cwd, reader = readRefImpact) {
|
|
|
36038
36451
|
let text;
|
|
36039
36452
|
let fd;
|
|
36040
36453
|
try {
|
|
36041
|
-
fd = path === "-" ? 0 : openSync5(
|
|
36454
|
+
fd = path === "-" ? 0 : openSync5(resolve17(cwd, path), "r");
|
|
36042
36455
|
const bytes = Buffer.alloc(REF_IMPACT_LIMITS.diffBytes + 1);
|
|
36043
36456
|
let length = 0;
|
|
36044
36457
|
while (length < bytes.length) {
|
|
@@ -36074,6 +36487,31 @@ function runRefImpactCommand(args, cwd, reader = readRefImpact) {
|
|
|
36074
36487
|
}
|
|
36075
36488
|
}
|
|
36076
36489
|
|
|
36490
|
+
// packages/surfaces/cli/src/architecture-history.ts
|
|
36491
|
+
init_src();
|
|
36492
|
+
function runArchitectureHistoryCommand(args, cwd) {
|
|
36493
|
+
if (args.includes("--help") || args.includes("-h"))
|
|
36494
|
+
return okEnvelope("history", { usage: "archctx history [--ref <rev>] [--format json|mermaid] [--offset <n>] [--limit <n>] --json" });
|
|
36495
|
+
const values = new Map;
|
|
36496
|
+
for (let i = 0;i < args.length; i++) {
|
|
36497
|
+
const flag = args[i];
|
|
36498
|
+
if (flag === "--json")
|
|
36499
|
+
continue;
|
|
36500
|
+
if (!["--ref", "--format", "--offset", "--limit"].includes(flag) || values.has(flag) || args[i + 1] === undefined)
|
|
36501
|
+
return errorEnvelope("history", "AC_SCHEMA_INVALID", "Invalid history arguments", "cli-input-invalid");
|
|
36502
|
+
values.set(flag, args[++i]);
|
|
36503
|
+
}
|
|
36504
|
+
const format = values.get("--format") ?? "json", offsetText = values.get("--offset") ?? "0", limitText = values.get("--limit") ?? "200";
|
|
36505
|
+
if (!/^[0-9]+$/.test(offsetText) || !/^[0-9]+$/.test(limitText) || !Number.isSafeInteger(Number(offsetText)) || !Number.isSafeInteger(Number(limitText)) || Number(limitText) > 1000 || !["json", "mermaid"].includes(format))
|
|
36506
|
+
return errorEnvelope("history", "AC_SCHEMA_INVALID", "Invalid history arguments", "cli-input-invalid");
|
|
36507
|
+
try {
|
|
36508
|
+
const history = readArchitectureHistory(cwd, { ref: values.get("--ref"), offset: Number(offsetText), limit: Number(limitText) });
|
|
36509
|
+
return okEnvelope("history", format === "mermaid" ? projectHistoryMermaid(history) : history);
|
|
36510
|
+
} catch (error) {
|
|
36511
|
+
return toEnvelope("history", error, "cli");
|
|
36512
|
+
}
|
|
36513
|
+
}
|
|
36514
|
+
|
|
36077
36515
|
// packages/local-runtime/runtime-daemon/src/index.ts
|
|
36078
36516
|
init_src();
|
|
36079
36517
|
|
|
@@ -36110,7 +36548,7 @@ async function exportChangeSetReceipt(store, root, journalId) {
|
|
|
36110
36548
|
// packages/local-runtime/runtime-daemon/src/architecture-debt.ts
|
|
36111
36549
|
init_src();
|
|
36112
36550
|
import { existsSync as existsSync11 } from "node:fs";
|
|
36113
|
-
import { join as
|
|
36551
|
+
import { join as join9 } from "node:path";
|
|
36114
36552
|
function readArchitectureDebt2(root, input = {}) {
|
|
36115
36553
|
try {
|
|
36116
36554
|
const { evidence } = readArchitectureDebtEvidence2(root, input);
|
|
@@ -36124,7 +36562,7 @@ function readArchitectureDebt2(root, input = {}) {
|
|
|
36124
36562
|
}
|
|
36125
36563
|
function readCompleteTaskArchitectureDebt(root, practices) {
|
|
36126
36564
|
try {
|
|
36127
|
-
if (!existsSync11(
|
|
36565
|
+
if (!existsSync11(join9(root, ".archcontext/manifest.yaml"))) {
|
|
36128
36566
|
return checkedDebt2({
|
|
36129
36567
|
scope: { kind: "repository", changedPaths: [], capabilityIds: [] },
|
|
36130
36568
|
unavailable: Object.fromEntries(ARCHITECTURE_DEBT_CHECKS.map((check) => [check, ["model-not-adopted"]]))
|
|
@@ -36156,7 +36594,7 @@ function readArchitectureDebtEvidence2(root, input) {
|
|
|
36156
36594
|
const changedPaths = [...new Set(input.changedPaths ?? [])].sort();
|
|
36157
36595
|
if (changedPaths.some((path) => !isRepoRelativePosixPath(path)))
|
|
36158
36596
|
throw new ArchitectureDebtReadError2("AC_SCHEMA_INVALID", "changedPaths must contain repository-relative POSIX paths", "changed-path-invalid");
|
|
36159
|
-
if (!existsSync11(
|
|
36597
|
+
if (!existsSync11(join9(root, ".archcontext/manifest.yaml")))
|
|
36160
36598
|
throw new ArchitectureDebtReadError2("AC_MODEL_ADOPTION_REQUIRED", "Architecture debt requires an adopted architecture model", "model-missing");
|
|
36161
36599
|
const model = loadNativeModelFromArchContext(root);
|
|
36162
36600
|
const files = listGitVisibleFiles(root);
|
|
@@ -37789,8 +38227,8 @@ function validateRuntimeAgentProposalPlan(input) {
|
|
|
37789
38227
|
}
|
|
37790
38228
|
|
|
37791
38229
|
// packages/local-runtime/runtime-daemon/src/external-documentation.ts
|
|
37792
|
-
import { existsSync as existsSync14, readdirSync as
|
|
37793
|
-
import { resolve as
|
|
38230
|
+
import { existsSync as existsSync14, readdirSync as readdirSync10, readFileSync as readFileSync16, statSync as statSync4 } from "node:fs";
|
|
38231
|
+
import { resolve as resolve20 } from "node:path";
|
|
37794
38232
|
|
|
37795
38233
|
// packages/core/context-compiler/src/index.ts
|
|
37796
38234
|
init_src();
|
|
@@ -37798,11 +38236,11 @@ init_src();
|
|
|
37798
38236
|
// packages/core/practice-catalog/src/index.ts
|
|
37799
38237
|
init_src();
|
|
37800
38238
|
init_src();
|
|
37801
|
-
import { existsSync as existsSync12, lstatSync as lstatSync7, readdirSync as
|
|
37802
|
-
import { dirname as dirname6, relative as relative5, resolve as
|
|
38239
|
+
import { existsSync as existsSync12, lstatSync as lstatSync7, readdirSync as readdirSync8, readFileSync as readFileSync14, realpathSync as realpathSync6 } from "node:fs";
|
|
38240
|
+
import { dirname as dirname6, relative as relative5, resolve as resolve18, sep as sep3 } from "node:path";
|
|
37803
38241
|
import { fileURLToPath } from "node:url";
|
|
37804
38242
|
var PRACTICE_CATALOG_VERSION = "2026.06.0";
|
|
37805
|
-
var BUILTIN_PRACTICE_ASSETS_DIR =
|
|
38243
|
+
var BUILTIN_PRACTICE_ASSETS_DIR = resolve18(dirname6(fileURLToPath(import.meta.url)), "../assets");
|
|
37806
38244
|
var ALLOWED_CHECK_IDS = new Set([
|
|
37807
38245
|
"compatibility-contract-required",
|
|
37808
38246
|
"no-new-cycle",
|
|
@@ -37854,13 +38292,13 @@ var PRACTICE_ROOT_KEYS = new Set([
|
|
|
37854
38292
|
"overlay"
|
|
37855
38293
|
]);
|
|
37856
38294
|
function loadPracticeCatalog(options = {}) {
|
|
37857
|
-
const root = options.root ?
|
|
38295
|
+
const root = options.root ? resolve18(options.root) : process.cwd();
|
|
37858
38296
|
const builtInAssetsDir = options.builtInAssetsDir ?? BUILTIN_PRACTICE_ASSETS_DIR;
|
|
37859
38297
|
const errors = [];
|
|
37860
38298
|
const warnings = [];
|
|
37861
|
-
const builtIn = loadAssetFiles(
|
|
37862
|
-
const profiles = loadProfileFiles(
|
|
37863
|
-
const sources = loadSourceFiles(
|
|
38299
|
+
const builtIn = loadAssetFiles(resolve18(builtInAssetsDir, "practices"), "curated-static", errors);
|
|
38300
|
+
const profiles = loadProfileFiles(resolve18(builtInAssetsDir, "profiles"), errors);
|
|
38301
|
+
const sources = loadSourceFiles(resolve18(builtInAssetsDir, "sources"), errors);
|
|
37864
38302
|
const overlays = options.includeRepoOverlay === false ? [] : loadRepoOverlayAssets(root, errors);
|
|
37865
38303
|
const merged = mergeCatalogAssets(builtIn, overlays, errors, options.now ?? new Date().toISOString());
|
|
37866
38304
|
const sourceIds = new Set(sources.map((source) => source.id));
|
|
@@ -38046,7 +38484,7 @@ function loadProfileFiles(dir, errors) {
|
|
|
38046
38484
|
return profiles.sort((a, b) => a.id.localeCompare(b.id));
|
|
38047
38485
|
}
|
|
38048
38486
|
function loadRepoOverlayAssets(root, errors) {
|
|
38049
|
-
const overlayRoot =
|
|
38487
|
+
const overlayRoot = resolve18(root, ".archcontext/practices");
|
|
38050
38488
|
if (!existsSync12(overlayRoot))
|
|
38051
38489
|
return [];
|
|
38052
38490
|
const out = [];
|
|
@@ -38409,8 +38847,8 @@ function listDataFiles(dir, allowedRoot, errors) {
|
|
|
38409
38847
|
return;
|
|
38410
38848
|
}
|
|
38411
38849
|
if (stat.isDirectory()) {
|
|
38412
|
-
for (const entry of
|
|
38413
|
-
walk(
|
|
38850
|
+
for (const entry of readdirSync8(current, { withFileTypes: true }))
|
|
38851
|
+
walk(resolve18(current, entry.name));
|
|
38414
38852
|
return;
|
|
38415
38853
|
}
|
|
38416
38854
|
if (!/\.(ya?ml|json)$/.test(current))
|
|
@@ -38425,7 +38863,7 @@ function listDataFiles(dir, allowedRoot, errors) {
|
|
|
38425
38863
|
}
|
|
38426
38864
|
function parseDataFile(path, errors) {
|
|
38427
38865
|
try {
|
|
38428
|
-
const body =
|
|
38866
|
+
const body = readFileSync14(path, "utf8").replace(/^\uFEFF/, "").trim();
|
|
38429
38867
|
const withoutDocumentMarker = body.startsWith("---") ? body.replace(/^---\s*/, "").trim() : body;
|
|
38430
38868
|
return JSON.parse(withoutDocumentMarker);
|
|
38431
38869
|
} catch (error) {
|
|
@@ -38452,14 +38890,14 @@ function assertRealChild(root, path) {
|
|
|
38452
38890
|
}
|
|
38453
38891
|
function safeRealpath(path) {
|
|
38454
38892
|
try {
|
|
38455
|
-
return
|
|
38893
|
+
return realpathSync6.native(path);
|
|
38456
38894
|
} catch {
|
|
38457
|
-
return
|
|
38895
|
+
return resolve18(path);
|
|
38458
38896
|
}
|
|
38459
38897
|
}
|
|
38460
38898
|
function isRealChild(rootReal, pathReal) {
|
|
38461
38899
|
const rel = relative5(rootReal, pathReal);
|
|
38462
|
-
return rel === "" || !rel.startsWith("..") && !rel.includes(`..${sep3}`) && !
|
|
38900
|
+
return rel === "" || !rel.startsWith("..") && !rel.includes(`..${sep3}`) && !resolve18(rel).startsWith("..");
|
|
38463
38901
|
}
|
|
38464
38902
|
function displayPath(path) {
|
|
38465
38903
|
return path.split(sep3).join("/");
|
|
@@ -39023,8 +39461,8 @@ function checkResult(input, result) {
|
|
|
39023
39461
|
}
|
|
39024
39462
|
// packages/core/practice-engine/src/enforcement.ts
|
|
39025
39463
|
init_src();
|
|
39026
|
-
import { existsSync as existsSync13, lstatSync as lstatSync8, readdirSync as
|
|
39027
|
-
import { basename as basename4, join as
|
|
39464
|
+
import { existsSync as existsSync13, lstatSync as lstatSync8, readdirSync as readdirSync9, readFileSync as readFileSync15 } from "node:fs";
|
|
39465
|
+
import { basename as basename4, join as join10, relative as relative6, resolve as resolve19, sep as sep4 } from "node:path";
|
|
39028
39466
|
var ENFORCEMENT_RANK = { advisory: 0, checkpoint: 1, complete: 2 };
|
|
39029
39467
|
var POLICY_MODES = new Set(["advisory", "active", "fail-open", "fail-closed"]);
|
|
39030
39468
|
var DEFAULT_POLICY = {
|
|
@@ -39047,7 +39485,7 @@ function shouldEvaluatePracticeEnforcement(policy) {
|
|
|
39047
39485
|
return practiceEnforcementPolicyMode(policy) !== "advisory";
|
|
39048
39486
|
}
|
|
39049
39487
|
function loadPracticeEnforcementPolicy(root) {
|
|
39050
|
-
const path =
|
|
39488
|
+
const path = resolve19(root, ".archcontext/policies/practices.yaml");
|
|
39051
39489
|
if (!existsSync13(path))
|
|
39052
39490
|
return defaultPracticeEnforcementPolicy();
|
|
39053
39491
|
assertRepoPolicyFile(root, path, ".archcontext/policies/practices.yaml");
|
|
@@ -39055,7 +39493,7 @@ function loadPracticeEnforcementPolicy(root) {
|
|
|
39055
39493
|
return validatePracticeEnforcementPolicy(parsed, ".archcontext/policies/practices.yaml");
|
|
39056
39494
|
}
|
|
39057
39495
|
function loadPracticeWaivers(root) {
|
|
39058
|
-
const dir =
|
|
39496
|
+
const dir = resolve19(root, ".archcontext/waivers");
|
|
39059
39497
|
if (!existsSync13(dir))
|
|
39060
39498
|
return [];
|
|
39061
39499
|
const stat = lstatSync8(dir);
|
|
@@ -39065,10 +39503,10 @@ function loadPracticeWaivers(root) {
|
|
|
39065
39503
|
throw new Error("practice-waiver-path-not-directory");
|
|
39066
39504
|
const waivers = [];
|
|
39067
39505
|
const ownerRegistry = loadPracticeWaiverOwnerRegistry(root);
|
|
39068
|
-
for (const entry of
|
|
39506
|
+
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
39069
39507
|
if (!entry.isFile() || !/\.(?:ya?ml|json)$/.test(entry.name))
|
|
39070
39508
|
continue;
|
|
39071
|
-
const path =
|
|
39509
|
+
const path = join10(dir, entry.name);
|
|
39072
39510
|
const relativePath = `.archcontext/waivers/${entry.name}`;
|
|
39073
39511
|
assertRepoPolicyFile(root, path, relativePath);
|
|
39074
39512
|
waivers.push(validatePracticeWaiver(parseJsonYamlFile(path), relativePath, { allowedOwners: ownerRegistry.owners }));
|
|
@@ -39076,17 +39514,17 @@ function loadPracticeWaivers(root) {
|
|
|
39076
39514
|
return waivers.sort((left, right) => waiverDigest(left).localeCompare(waiverDigest(right)));
|
|
39077
39515
|
}
|
|
39078
39516
|
function loadPracticeWaiverOwnerRegistry(root) {
|
|
39079
|
-
const modelDir =
|
|
39517
|
+
const modelDir = resolve19(root, ".archcontext/model/nodes");
|
|
39080
39518
|
const sources = [];
|
|
39081
39519
|
const subjects = [];
|
|
39082
39520
|
if (existsSync13(modelDir)) {
|
|
39083
39521
|
if (lstatSync8(modelDir).isSymbolicLink())
|
|
39084
39522
|
throw new Error("practice-owner-registry-symlink-denied");
|
|
39085
39523
|
for (const path of collectFiles(root, ".archcontext/model/nodes")) {
|
|
39086
|
-
const absolute =
|
|
39524
|
+
const absolute = resolve19(root, path);
|
|
39087
39525
|
if (lstatSync8(absolute).isSymbolicLink())
|
|
39088
39526
|
throw new Error(`practice-owner-registry-symlink-denied: ${path}`);
|
|
39089
|
-
const body =
|
|
39527
|
+
const body = readFileSync15(absolute, "utf8");
|
|
39090
39528
|
const lifecycleOwners = extractOwnershipOwners(body, "lifecycle");
|
|
39091
39529
|
const dataOwners = extractOwnershipOwners(body, "data");
|
|
39092
39530
|
for (const kind of ["lifecycle", "data"]) {
|
|
@@ -39361,14 +39799,14 @@ function isVagueReason(reason) {
|
|
|
39361
39799
|
return /^(temporary|cleanup later|todo|tbd|later|just in case)$/i.test(trimmed);
|
|
39362
39800
|
}
|
|
39363
39801
|
function parseJsonYamlFile(path) {
|
|
39364
|
-
const body =
|
|
39802
|
+
const body = readFileSync15(path, "utf8").replace(/^\uFEFF/, "").trim();
|
|
39365
39803
|
const withoutDocumentMarker = body.startsWith("---") ? body.replace(/^---\s*/, "").trim() : body;
|
|
39366
39804
|
return JSON.parse(withoutDocumentMarker);
|
|
39367
39805
|
}
|
|
39368
39806
|
function collectFiles(root, relativeDir) {
|
|
39369
|
-
const dir =
|
|
39807
|
+
const dir = resolve19(root, relativeDir);
|
|
39370
39808
|
const out = [];
|
|
39371
|
-
for (const entry of
|
|
39809
|
+
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
39372
39810
|
const child = `${relativeDir}/${entry.name}`;
|
|
39373
39811
|
if (entry.isDirectory())
|
|
39374
39812
|
out.push(...collectFiles(root, child));
|
|
@@ -39454,8 +39892,8 @@ function assertRepoPolicyFile(root, path, relativePath) {
|
|
|
39454
39892
|
assertRepoRelativePath(relativePath);
|
|
39455
39893
|
if (lstatSync8(path).isSymbolicLink())
|
|
39456
39894
|
throw new Error(`practice-policy-symlink-denied: ${relativePath}`);
|
|
39457
|
-
const rootResolved =
|
|
39458
|
-
const pathResolved =
|
|
39895
|
+
const rootResolved = resolve19(root);
|
|
39896
|
+
const pathResolved = resolve19(path);
|
|
39459
39897
|
const rel = relative6(rootResolved, pathResolved);
|
|
39460
39898
|
if (rel === "" || rel.startsWith("..") || rel.includes(`..${sep4}`))
|
|
39461
39899
|
throw new Error(`practice-policy-path-escape: ${relativePath}`);
|
|
@@ -40815,7 +41253,7 @@ function readExactPackageVersion(root, packageName) {
|
|
|
40815
41253
|
return;
|
|
40816
41254
|
}
|
|
40817
41255
|
function readPackageLockExactVersion(root, packageName) {
|
|
40818
|
-
const lock = readJsonFile(
|
|
41256
|
+
const lock = readJsonFile(resolve20(root, "package-lock.json"));
|
|
40819
41257
|
if (!lock || typeof lock !== "object" || Array.isArray(lock))
|
|
40820
41258
|
return;
|
|
40821
41259
|
const packages = lock.packages;
|
|
@@ -40833,7 +41271,7 @@ function readPackageLockExactVersion(root, packageName) {
|
|
|
40833
41271
|
return;
|
|
40834
41272
|
}
|
|
40835
41273
|
function packageManifestPaths(root) {
|
|
40836
|
-
const paths = [
|
|
41274
|
+
const paths = [resolve20(root, "package.json")];
|
|
40837
41275
|
const rootManifest = readJsonFile(paths[0]);
|
|
40838
41276
|
for (const pattern of workspacePatternsFromManifest(rootManifest)) {
|
|
40839
41277
|
for (const path of expandWorkspacePackageJson(root, pattern))
|
|
@@ -40856,15 +41294,15 @@ function expandWorkspacePackageJson(root, pattern) {
|
|
|
40856
41294
|
if (pattern.includes("**") || pattern.startsWith("/") || pattern.includes("\\"))
|
|
40857
41295
|
return [];
|
|
40858
41296
|
if (!pattern.includes("*")) {
|
|
40859
|
-
const path =
|
|
41297
|
+
const path = resolve20(root, pattern, "package.json");
|
|
40860
41298
|
return existsSync14(path) ? [path] : [];
|
|
40861
41299
|
}
|
|
40862
41300
|
if (!pattern.endsWith("/*"))
|
|
40863
41301
|
return [];
|
|
40864
|
-
const base =
|
|
41302
|
+
const base = resolve20(root, pattern.slice(0, -2));
|
|
40865
41303
|
if (!existsSync14(base) || !statSync4(base).isDirectory())
|
|
40866
41304
|
return [];
|
|
40867
|
-
return
|
|
41305
|
+
return readdirSync10(base, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => resolve20(base, entry.name, "package.json")).filter((path) => existsSync14(path));
|
|
40868
41306
|
}
|
|
40869
41307
|
function exactVersionFromManifest(manifest, packageName) {
|
|
40870
41308
|
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest))
|
|
@@ -40883,7 +41321,7 @@ function readJsonFile(path) {
|
|
|
40883
41321
|
if (!existsSync14(path))
|
|
40884
41322
|
return;
|
|
40885
41323
|
try {
|
|
40886
|
-
return JSON.parse(
|
|
41324
|
+
return JSON.parse(readFileSync16(path, "utf8"));
|
|
40887
41325
|
} catch {
|
|
40888
41326
|
return;
|
|
40889
41327
|
}
|
|
@@ -40906,7 +41344,7 @@ function readContext7LockfileState(root) {
|
|
|
40906
41344
|
expectedHash: "missing"
|
|
40907
41345
|
};
|
|
40908
41346
|
}
|
|
40909
|
-
const body =
|
|
41347
|
+
const body = readFileSync16(path, "utf8");
|
|
40910
41348
|
const parsed = JSON.parse(body);
|
|
40911
41349
|
if (parsed.schemaVersion !== CONTEXT7_LOCKFILE_SCHEMA_VERSION || parsed.provider !== "context7" || !Array.isArray(parsed.libraries)) {
|
|
40912
41350
|
throw new Error("Invalid Context7 lockfile");
|
|
@@ -40942,7 +41380,7 @@ function writeContext7Lockfile(root, lock, expectedHash) {
|
|
|
40942
41380
|
|
|
40943
41381
|
// packages/core/application/src/index.ts
|
|
40944
41382
|
import { existsSync as existsSync15, statSync as statSync5 } from "node:fs";
|
|
40945
|
-
import { extname, resolve as
|
|
41383
|
+
import { extname, resolve as resolve21 } from "node:path";
|
|
40946
41384
|
init_src();
|
|
40947
41385
|
async function prepareTask(input) {
|
|
40948
41386
|
const confidence = computeRefactorConfidence({
|
|
@@ -41135,7 +41573,7 @@ function classifyCheckpointPath(root, path) {
|
|
|
41135
41573
|
return "ignored";
|
|
41136
41574
|
if (isGeneratedCheckpointPath(path))
|
|
41137
41575
|
return "generated";
|
|
41138
|
-
const absolute =
|
|
41576
|
+
const absolute = resolve21(root, path);
|
|
41139
41577
|
if (!existsSync15(absolute))
|
|
41140
41578
|
return "deleted";
|
|
41141
41579
|
try {
|
|
@@ -41433,14 +41871,14 @@ function parsePracticeCheckpointBaselineState(state, repositoryId, taskSessionId
|
|
|
41433
41871
|
init_src();
|
|
41434
41872
|
init_src();
|
|
41435
41873
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
41436
|
-
import { chmodSync as chmodSync3, existsSync as existsSync18, lstatSync as lstatSync9, mkdirSync as
|
|
41874
|
+
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
41875
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
41438
|
-
import { basename as basename5, dirname as dirname7, join as
|
|
41876
|
+
import { basename as basename5, dirname as dirname7, join as join13, resolve as resolve22, sep as sep5 } from "node:path";
|
|
41439
41877
|
|
|
41440
41878
|
// 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
|
|
41879
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
41880
|
+
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";
|
|
41881
|
+
import { join as join12 } from "node:path";
|
|
41444
41882
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
41445
41883
|
var WINDOWS_CREATE_TIMEOUT_MS = 60000;
|
|
41446
41884
|
var WINDOWS_READ_TIMEOUT_MS = 1e4;
|
|
@@ -41524,7 +41962,7 @@ function windowsControlFile(operation, path, body) {
|
|
|
41524
41962
|
let output;
|
|
41525
41963
|
const startedAt = performance.now();
|
|
41526
41964
|
try {
|
|
41527
|
-
output =
|
|
41965
|
+
output = execFileSync6(join12(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), [
|
|
41528
41966
|
"-NoLogo",
|
|
41529
41967
|
"-NoProfile",
|
|
41530
41968
|
"-NonInteractive",
|
|
@@ -41579,7 +42017,7 @@ function createPrivateControlFile(path, body) {
|
|
|
41579
42017
|
}
|
|
41580
42018
|
const fd = openSync6(path, "wx", 384);
|
|
41581
42019
|
try {
|
|
41582
|
-
|
|
42020
|
+
writeFileSync5(fd, body, "utf8");
|
|
41583
42021
|
} catch (error) {
|
|
41584
42022
|
rmSync6(path, { force: true });
|
|
41585
42023
|
throw error;
|
|
@@ -41599,7 +42037,7 @@ function readPrivateControlFile(path) {
|
|
|
41599
42037
|
const stat = fstatSync3(fd);
|
|
41600
42038
|
if (!stat.isFile() || (stat.mode & 63) !== 0)
|
|
41601
42039
|
return;
|
|
41602
|
-
return
|
|
42040
|
+
return readFileSync17(fd, "utf8");
|
|
41603
42041
|
} finally {
|
|
41604
42042
|
closeSync6(fd);
|
|
41605
42043
|
}
|
|
@@ -42136,111 +42574,6 @@ function daemonReadiness(root) {
|
|
|
42136
42574
|
|
|
42137
42575
|
// packages/local-runtime/runtime-daemon/src/daemon-control.ts
|
|
42138
42576
|
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
42577
|
function defaultDeveloperReviewRunStateDir(root = process.cwd()) {
|
|
42245
42578
|
return runtimeStatePaths(root).developerReviewRunStateDir;
|
|
42246
42579
|
}
|
|
@@ -42453,9 +42786,9 @@ class DeveloperReviewRunService {
|
|
|
42453
42786
|
challengeId: input.challenge.challengeId,
|
|
42454
42787
|
tempRoot: input.tempRoot
|
|
42455
42788
|
});
|
|
42456
|
-
|
|
42457
|
-
|
|
42458
|
-
|
|
42789
|
+
mkdirSync7(paths.stateDir, { recursive: true });
|
|
42790
|
+
mkdirSync7(paths.runRoot, { recursive: true });
|
|
42791
|
+
mkdirSync7(paths.worktreeTempRoot, { recursive: true });
|
|
42459
42792
|
const createdAt = this.clock();
|
|
42460
42793
|
writeDeveloperReviewRunOwnerMarker({
|
|
42461
42794
|
runRoot: paths.runRoot,
|
|
@@ -42579,7 +42912,7 @@ class DeveloperReviewRunService {
|
|
|
42579
42912
|
this.assertRunning();
|
|
42580
42913
|
const sourceRoot = findRepositoryRoot(input.repositoryRoot);
|
|
42581
42914
|
const safeChallengeId = safeControlFileSegment(input.challengeId);
|
|
42582
|
-
const manifestPath =
|
|
42915
|
+
const manifestPath = join13(defaultDeveloperReviewRunStateDir(sourceRoot), `${safeChallengeId}.json`);
|
|
42583
42916
|
const manifest = readDeveloperReviewRunManifest(manifestPath);
|
|
42584
42917
|
if (!manifest)
|
|
42585
42918
|
throw developerReviewRunNotOwned("persisted-manifest-missing");
|
|
@@ -42606,7 +42939,7 @@ class DeveloperReviewRunService {
|
|
|
42606
42939
|
for (const entry of readdirSync11(stateDir).sort()) {
|
|
42607
42940
|
if (!entry.endsWith(".json"))
|
|
42608
42941
|
continue;
|
|
42609
|
-
const manifestPath =
|
|
42942
|
+
const manifestPath = join13(stateDir, entry);
|
|
42610
42943
|
const stats = lstatIfExists2(manifestPath);
|
|
42611
42944
|
if (!stats || !stats.isFile()) {
|
|
42612
42945
|
recovery.rejected.push(`${entry}: not-a-regular-file`);
|
|
@@ -42634,7 +42967,7 @@ class DeveloperReviewRunService {
|
|
|
42634
42967
|
for (const entry of readdirSync11(stateDir).sort()) {
|
|
42635
42968
|
if (!entry.endsWith(".lock"))
|
|
42636
42969
|
continue;
|
|
42637
|
-
const lockPath =
|
|
42970
|
+
const lockPath = join13(stateDir, entry);
|
|
42638
42971
|
const stats = lstatIfExists2(lockPath);
|
|
42639
42972
|
if (!stats || !stats.isFile()) {
|
|
42640
42973
|
recovery.rejected.push(`${entry}: not-a-regular-file`);
|
|
@@ -42663,15 +42996,15 @@ function createDeveloperReviewRunPaths(input) {
|
|
|
42663
42996
|
const runId = `${safeChallengeId}-${randomBytes2(6).toString("hex")}`;
|
|
42664
42997
|
const stateDir = defaultDeveloperReviewRunStateDir(input.sourceRoot);
|
|
42665
42998
|
const tempParent = input.tempRoot ? resolve22(input.tempRoot) : tmpdir3();
|
|
42666
|
-
|
|
42667
|
-
const runRoot = mkdtempSync3(
|
|
42999
|
+
mkdirSync7(tempParent, { recursive: true });
|
|
43000
|
+
const runRoot = mkdtempSync3(join13(tempParent, `${DEVELOPER_REVIEW_RUN_ROOT_PREFIX}${safeChallengeId.slice(0, 32)}-`));
|
|
42668
43001
|
return {
|
|
42669
43002
|
runId,
|
|
42670
43003
|
stateDir,
|
|
42671
43004
|
runRoot,
|
|
42672
|
-
worktreeTempRoot:
|
|
42673
|
-
manifestPath:
|
|
42674
|
-
lockPath:
|
|
43005
|
+
worktreeTempRoot: join13(runRoot, "worktrees"),
|
|
43006
|
+
manifestPath: join13(stateDir, `${safeChallengeId}.json`),
|
|
43007
|
+
lockPath: join13(stateDir, `${safeChallengeId}.lock`)
|
|
42675
43008
|
};
|
|
42676
43009
|
}
|
|
42677
43010
|
function writeDeveloperReviewRunOwnerMarker(input) {
|
|
@@ -42685,7 +43018,7 @@ function writeDeveloperReviewRunOwnerMarker(input) {
|
|
|
42685
43018
|
pid: process.pid,
|
|
42686
43019
|
createdAt: input.createdAt
|
|
42687
43020
|
};
|
|
42688
|
-
writePrivateJson(
|
|
43021
|
+
writePrivateJson(join13(input.runRoot, DEVELOPER_REVIEW_RUN_OWNER_MARKER_FILE), marker, "wx");
|
|
42689
43022
|
}
|
|
42690
43023
|
function readDeveloperReviewRunOwnerMarker(path) {
|
|
42691
43024
|
const stats = lstatIfExists2(path);
|
|
@@ -42709,8 +43042,8 @@ function resolveOwnedDeveloperReviewRunTargets(run) {
|
|
|
42709
43042
|
if (!runIdSuffix || !DEVELOPER_REVIEW_RUN_ID_SUFFIX.test(runIdSuffix))
|
|
42710
43043
|
throw developerReviewRunNotOwned("run-id");
|
|
42711
43044
|
const stateDir = defaultDeveloperReviewRunStateDir(run.sourceRoot);
|
|
42712
|
-
const manifestPath =
|
|
42713
|
-
const lockPath =
|
|
43045
|
+
const manifestPath = join13(stateDir, `${safeChallengeId}.json`);
|
|
43046
|
+
const lockPath = join13(stateDir, `${safeChallengeId}.lock`);
|
|
42714
43047
|
if (resolve22(run.manifestPath) !== manifestPath)
|
|
42715
43048
|
throw developerReviewRunNotOwned("manifest-path");
|
|
42716
43049
|
if (resolve22(run.lockPath) !== lockPath)
|
|
@@ -42732,7 +43065,7 @@ function resolveOwnedDeveloperReviewRunTargets(run) {
|
|
|
42732
43065
|
if (!runRootName.startsWith(runRootPrefix) || !DEVELOPER_REVIEW_RUN_ROOT_SUFFIX.test(runRootName.slice(runRootPrefix.length))) {
|
|
42733
43066
|
throw developerReviewRunNotOwned("run-root-name");
|
|
42734
43067
|
}
|
|
42735
|
-
const worktreeTempRoot =
|
|
43068
|
+
const worktreeTempRoot = join13(runRoot, "worktrees");
|
|
42736
43069
|
if (resolve22(run.worktreeTempRoot) !== worktreeTempRoot)
|
|
42737
43070
|
throw developerReviewRunNotOwned("worktree-temp-root");
|
|
42738
43071
|
if (resolve22(run.codeGraphTemporaryState.root) !== runRoot)
|
|
@@ -42742,7 +43075,7 @@ function resolveOwnedDeveloperReviewRunTargets(run) {
|
|
|
42742
43075
|
return { stateDir, manifestPath, lockPath };
|
|
42743
43076
|
if (!runRootStats.isDirectory())
|
|
42744
43077
|
throw developerReviewRunNotOwned("run-root-not-a-directory");
|
|
42745
|
-
const marker = readDeveloperReviewRunOwnerMarker(
|
|
43078
|
+
const marker = readDeveloperReviewRunOwnerMarker(join13(runRoot, DEVELOPER_REVIEW_RUN_OWNER_MARKER_FILE));
|
|
42746
43079
|
if (!marker)
|
|
42747
43080
|
throw developerReviewRunNotOwned("run-root-owner-marker-missing");
|
|
42748
43081
|
if (marker.runId !== run.runId || marker.challengeId !== run.challengeId)
|
|
@@ -42779,8 +43112,8 @@ function writeDeveloperReviewRunManifest(manifest) {
|
|
|
42779
43112
|
writePrivateJson(manifest.manifestPath, manifest);
|
|
42780
43113
|
}
|
|
42781
43114
|
function writePrivateJson(path, value, flag = "w") {
|
|
42782
|
-
|
|
42783
|
-
|
|
43115
|
+
mkdirSync7(dirname7(path), { recursive: true });
|
|
43116
|
+
writeFileSync6(path, JSON.stringify(value, null, 2), { mode: 384, flag });
|
|
42784
43117
|
chmodSync3(path, 384);
|
|
42785
43118
|
}
|
|
42786
43119
|
function readDeveloperReviewRunManifest(path) {
|
|
@@ -42792,7 +43125,7 @@ function readDeveloperReviewRunManifest(path) {
|
|
|
42792
43125
|
}
|
|
42793
43126
|
function readJsonObject(path) {
|
|
42794
43127
|
try {
|
|
42795
|
-
const parsed = JSON.parse(
|
|
43128
|
+
const parsed = JSON.parse(readFileSync18(path, "utf8"));
|
|
42796
43129
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
42797
43130
|
} catch {
|
|
42798
43131
|
return;
|
|
@@ -44389,8 +44722,8 @@ function uniqueStrings2(values) {
|
|
|
44389
44722
|
// packages/local-runtime/runtime-daemon/src/ledger-admin.ts
|
|
44390
44723
|
init_src();
|
|
44391
44724
|
init_src();
|
|
44392
|
-
import { existsSync as existsSync20, readFileSync as
|
|
44393
|
-
import { join as
|
|
44725
|
+
import { existsSync as existsSync20, readFileSync as readFileSync20 } from "node:fs";
|
|
44726
|
+
import { join as join15, resolve as resolve24 } from "node:path";
|
|
44394
44727
|
|
|
44395
44728
|
// packages/core/reconcile-engine/src/index.ts
|
|
44396
44729
|
function reconcileArchitectureLedgerDrift(input) {
|
|
@@ -44467,11 +44800,11 @@ init_src();
|
|
|
44467
44800
|
|
|
44468
44801
|
// packages/local-runtime/local-store-sqlite/src/index.ts
|
|
44469
44802
|
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
|
|
44803
|
+
import { createHash as createHash10, randomUUID as randomUUID2 } from "node:crypto";
|
|
44804
|
+
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
44805
|
import { readdir, readFile } from "node:fs/promises";
|
|
44473
44806
|
import { createRequire as createRequire4 } from "node:module";
|
|
44474
|
-
import { dirname as dirname8, isAbsolute as isAbsolute6, join as
|
|
44807
|
+
import { dirname as dirname8, isAbsolute as isAbsolute6, join as join14, relative as relative7, resolve as resolve23 } from "node:path";
|
|
44475
44808
|
init_src();
|
|
44476
44809
|
// schemas/runtime/explorer-projection-v2.schema.json
|
|
44477
44810
|
var explorer_projection_v2_schema_default = {
|
|
@@ -45888,8 +46221,8 @@ function migrateLegacyLocalStoreIfNeeded(root = process.cwd(), env = process.env
|
|
|
45888
46221
|
}
|
|
45889
46222
|
assertTrustedLegacyLocalStoreSource(paths);
|
|
45890
46223
|
const lock = acquireLegacyMigrationLock(paths);
|
|
45891
|
-
const stagingDir =
|
|
45892
|
-
const stagingPath =
|
|
46224
|
+
const stagingDir = join14(paths.workspaceStateDir, `.runtime.sqlite.migration-${process.pid}-${randomUUID2()}`);
|
|
46225
|
+
const stagingPath = join14(stagingDir, "runtime.sqlite");
|
|
45893
46226
|
try {
|
|
45894
46227
|
if (targetExists)
|
|
45895
46228
|
quarantinedFiles.push(...quarantineExistingLocalStore(paths));
|
|
@@ -45981,7 +46314,7 @@ class SqliteLocalStore {
|
|
|
45981
46314
|
}
|
|
45982
46315
|
async beginSnapshot(snapshot) {
|
|
45983
46316
|
const db = await this.database();
|
|
45984
|
-
const snapshotId = `snapshot_${
|
|
46317
|
+
const snapshotId = `snapshot_${randomUUID2()}`;
|
|
45985
46318
|
db.prepare(`INSERT INTO snapshots
|
|
45986
46319
|
(id, repository_id, head_sha, worktree_digest, state, created_at)
|
|
45987
46320
|
VALUES (?, ?, ?, ?, ?, ?)`).run(snapshotId, snapshot.repositoryId, snapshot.headSha, snapshot.worktreeDigest, "pending", nowIso());
|
|
@@ -46319,7 +46652,7 @@ class SqliteLocalStore {
|
|
|
46319
46652
|
}
|
|
46320
46653
|
async beginChangeSet(root, draft) {
|
|
46321
46654
|
const db = await this.database();
|
|
46322
|
-
const journalId = `changeset_${
|
|
46655
|
+
const journalId = `changeset_${randomUUID2()}`;
|
|
46323
46656
|
db.prepare(`INSERT INTO changeset_journal
|
|
46324
46657
|
(journal_id, changeset_id, root, status, metadata_json, files_json, created_at, updated_at)
|
|
46325
46658
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(journalId, draft.id, root, "pending", stableJson(changeSetMetadata(draft)), "[]", nowIso(), nowIso());
|
|
@@ -49243,7 +49576,7 @@ function ftsMatchKind(query, doc) {
|
|
|
49243
49576
|
function recordArchitectureLedgerOperation(db, input) {
|
|
49244
49577
|
db.prepare(`INSERT INTO architecture_ledger_operations
|
|
49245
49578
|
(operation_id, storage_repository_id, storage_workspace_id, operation_kind, duration_ms, row_count, rebuild_reason, created_at)
|
|
49246
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(`ledger_operation_${
|
|
49579
|
+
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
49580
|
}
|
|
49248
49581
|
function stableLedgerId(prefix, ...parts) {
|
|
49249
49582
|
return `${prefix}.${createHash10("sha256").update(parts.join("\x00")).digest("hex").slice(0, 24)}`;
|
|
@@ -49811,7 +50144,7 @@ function publishStagedLocalStore(stagingPath, targetPath) {
|
|
|
49811
50144
|
if (existsSync19(path))
|
|
49812
50145
|
throw new Error(`Cannot publish migrated SQLite over existing target file: ${path}`);
|
|
49813
50146
|
}
|
|
49814
|
-
|
|
50147
|
+
renameSync4(stagingPath, targetPath);
|
|
49815
50148
|
makePrivateFile(targetPath);
|
|
49816
50149
|
fsyncDirectory2(dirname8(targetPath));
|
|
49817
50150
|
}
|
|
@@ -49832,7 +50165,7 @@ function acquireLegacyMigrationLock(paths) {
|
|
|
49832
50165
|
ensurePrivateDir(dirname8(lockPath));
|
|
49833
50166
|
try {
|
|
49834
50167
|
const fd = openSync8(lockPath, "wx", 384);
|
|
49835
|
-
|
|
50168
|
+
writeFileSync7(fd, JSON.stringify({
|
|
49836
50169
|
schemaVersion: "archcontext.legacy-local-store-migration-lock/v1",
|
|
49837
50170
|
pid: process.pid,
|
|
49838
50171
|
root: paths.repositoryRoot,
|
|
@@ -49858,7 +50191,7 @@ function releaseLegacyMigrationLock(lock) {
|
|
|
49858
50191
|
}
|
|
49859
50192
|
function isStaleMigrationLock(lockPath) {
|
|
49860
50193
|
try {
|
|
49861
|
-
const parsed = JSON.parse(
|
|
50194
|
+
const parsed = JSON.parse(readFileSync19(lockPath, "utf8"));
|
|
49862
50195
|
if (typeof parsed.pid !== "number" || parsed.pid <= 0)
|
|
49863
50196
|
return true;
|
|
49864
50197
|
return !isProcessAlive(parsed.pid);
|
|
@@ -49909,7 +50242,7 @@ function acquireLocalStoreWriterOwnership(databasePath) {
|
|
|
49909
50242
|
throw error;
|
|
49910
50243
|
}
|
|
49911
50244
|
makePrivateFile(lockPath);
|
|
49912
|
-
const token =
|
|
50245
|
+
const token = randomUUID2();
|
|
49913
50246
|
writeOwnerRecord(recordPath, { pid: process.pid, databasePath, acquiredAt: nowIso(), token });
|
|
49914
50247
|
let released = false;
|
|
49915
50248
|
return {
|
|
@@ -49943,17 +50276,17 @@ function sleepSync(ms) {
|
|
|
49943
50276
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
49944
50277
|
}
|
|
49945
50278
|
function writeOwnerRecord(recordPath, record) {
|
|
49946
|
-
const tempPath = `${recordPath}.${process.pid}-${
|
|
50279
|
+
const tempPath = `${recordPath}.${process.pid}-${randomUUID2()}.tmp`;
|
|
49947
50280
|
try {
|
|
49948
|
-
|
|
49949
|
-
|
|
50281
|
+
writeFileSync7(tempPath, JSON.stringify(record, null, 2), { encoding: "utf8", mode: 384, flag: "wx" });
|
|
50282
|
+
renameSync4(tempPath, recordPath);
|
|
49950
50283
|
} catch {
|
|
49951
50284
|
rmSync9(tempPath, { force: true });
|
|
49952
50285
|
}
|
|
49953
50286
|
}
|
|
49954
50287
|
function readOwnerRecord(recordPath) {
|
|
49955
50288
|
try {
|
|
49956
|
-
const parsed = JSON.parse(
|
|
50289
|
+
const parsed = JSON.parse(readFileSync19(recordPath, "utf8"));
|
|
49957
50290
|
return parsed && typeof parsed === "object" ? parsed : undefined;
|
|
49958
50291
|
} catch {
|
|
49959
50292
|
return;
|
|
@@ -49961,7 +50294,7 @@ function readOwnerRecord(recordPath) {
|
|
|
49961
50294
|
}
|
|
49962
50295
|
function readLegacyOwnerLockPid(legacyPath) {
|
|
49963
50296
|
try {
|
|
49964
|
-
const pid = JSON.parse(
|
|
50297
|
+
const pid = JSON.parse(readFileSync19(legacyPath, "utf8"))?.pid;
|
|
49965
50298
|
return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : undefined;
|
|
49966
50299
|
} catch {
|
|
49967
50300
|
return;
|
|
@@ -49976,21 +50309,21 @@ function changeSetJournalRecoveryErrorMessage(metadataJson) {
|
|
|
49976
50309
|
return "pending ChangeSet journal without a recorded recovery error";
|
|
49977
50310
|
}
|
|
49978
50311
|
function quarantineExistingLocalStore(paths) {
|
|
49979
|
-
const quarantineDir =
|
|
50312
|
+
const quarantineDir = join14(paths.workspaceStateDir, "quarantine", `runtime.sqlite-${Date.now()}-${randomUUID2()}`);
|
|
49980
50313
|
ensurePrivateDir(quarantineDir);
|
|
49981
50314
|
const quarantinedFiles = [];
|
|
49982
50315
|
for (const suffix of SQLITE_SIDECAR_SUFFIXES) {
|
|
49983
50316
|
const source = `${paths.localStorePath}${suffix}`;
|
|
49984
50317
|
if (!existsSync19(source))
|
|
49985
50318
|
continue;
|
|
49986
|
-
const target =
|
|
49987
|
-
|
|
50319
|
+
const target = join14(quarantineDir, `runtime.sqlite${suffix}`);
|
|
50320
|
+
renameSync4(source, target);
|
|
49988
50321
|
quarantinedFiles.push(target);
|
|
49989
50322
|
}
|
|
49990
50323
|
const markerPath = legacyMigrationMarkerPath(paths);
|
|
49991
50324
|
if (existsSync19(markerPath)) {
|
|
49992
|
-
const target =
|
|
49993
|
-
|
|
50325
|
+
const target = join14(quarantineDir, LEGACY_MIGRATION_MARKER_FILE);
|
|
50326
|
+
renameSync4(markerPath, target);
|
|
49994
50327
|
quarantinedFiles.push(target);
|
|
49995
50328
|
}
|
|
49996
50329
|
fsyncDirectory2(quarantineDir);
|
|
@@ -49998,16 +50331,16 @@ function quarantineExistingLocalStore(paths) {
|
|
|
49998
50331
|
return quarantinedFiles;
|
|
49999
50332
|
}
|
|
50000
50333
|
function legacyMigrationMarkerPath(paths) {
|
|
50001
|
-
return
|
|
50334
|
+
return join14(paths.workspaceStateDir, LEGACY_MIGRATION_MARKER_FILE);
|
|
50002
50335
|
}
|
|
50003
50336
|
function legacyMigrationLockPath(paths) {
|
|
50004
|
-
return
|
|
50337
|
+
return join14(paths.workspaceStateDir, LEGACY_MIGRATION_LOCK_FILE);
|
|
50005
50338
|
}
|
|
50006
50339
|
function writePrivateJson2(path, value) {
|
|
50007
50340
|
ensurePrivateDir(dirname8(path));
|
|
50008
50341
|
const fd = openSync8(path, "w", 384);
|
|
50009
50342
|
try {
|
|
50010
|
-
|
|
50343
|
+
writeFileSync7(fd, JSON.stringify(value, null, 2), "utf8");
|
|
50011
50344
|
fsyncSync3(fd);
|
|
50012
50345
|
} finally {
|
|
50013
50346
|
closeSync7(fd);
|
|
@@ -50016,7 +50349,7 @@ function writePrivateJson2(path, value) {
|
|
|
50016
50349
|
fsyncDirectory2(dirname8(path));
|
|
50017
50350
|
}
|
|
50018
50351
|
function ensurePrivateDir(path) {
|
|
50019
|
-
|
|
50352
|
+
mkdirSync8(path, { recursive: true, mode: 448 });
|
|
50020
50353
|
if (process.platform !== "win32") {
|
|
50021
50354
|
try {
|
|
50022
50355
|
chmodSync4(path, 448);
|
|
@@ -50379,7 +50712,7 @@ function recoverJournalFiles(root, files) {
|
|
|
50379
50712
|
try {
|
|
50380
50713
|
const stat = lstatSync10(absolute);
|
|
50381
50714
|
if (stat.isFile() && !stat.isSymbolicLink()) {
|
|
50382
|
-
const bytes =
|
|
50715
|
+
const bytes = readFileSync19(absolute), body = bytes.toString("utf8");
|
|
50383
50716
|
if (Buffer.from(body, "utf8").equals(bytes))
|
|
50384
50717
|
current = digestJson({ body });
|
|
50385
50718
|
}
|
|
@@ -50398,7 +50731,7 @@ function recoverJournalFiles(root, files) {
|
|
|
50398
50731
|
if (file.existed) {
|
|
50399
50732
|
if (file.backupPath && existsSync19(file.backupPath)) {
|
|
50400
50733
|
rmSync9(absolute, { recursive: true, force: true });
|
|
50401
|
-
|
|
50734
|
+
renameSync4(file.backupPath, absolute);
|
|
50402
50735
|
} else if (!existsSync19(absolute) && firstExistedByPath.get(pathKey(absolute)) === true) {
|
|
50403
50736
|
missing.push(file.path);
|
|
50404
50737
|
continue;
|
|
@@ -50456,7 +50789,7 @@ async function readRelationFiles(root, relationsDir) {
|
|
|
50456
50789
|
for (const entry of entries) {
|
|
50457
50790
|
if (!entry.isFile() || !/\.(json|ya?ml)$/.test(entry.name))
|
|
50458
50791
|
continue;
|
|
50459
|
-
const relativePath =
|
|
50792
|
+
const relativePath = join14(relationsDir, entry.name).split("\\").join("/");
|
|
50460
50793
|
relations.push(parseCrossRepoRelationFile(await readFile(resolve23(root, relativePath), "utf8"), relativePath));
|
|
50461
50794
|
}
|
|
50462
50795
|
return relations.sort((a, b) => a.id.localeCompare(b.id));
|
|
@@ -50588,7 +50921,7 @@ class LedgerAdminService {
|
|
|
50588
50921
|
}
|
|
50589
50922
|
const paths = runtimeStatePaths(repositoryRoot);
|
|
50590
50923
|
const backupCreatedAt = this.context.clock();
|
|
50591
|
-
const backupPath = uniqueRuntimeBackupPath(
|
|
50924
|
+
const backupPath = uniqueRuntimeBackupPath(join15(paths.workspaceStateDir, "backups", "ledger-migrate", safePathSegment(backupCreatedAt), "runtime.sqlite"));
|
|
50592
50925
|
const backup = await this.context.localStore.backupArchitectureLedger({ backupPath });
|
|
50593
50926
|
const append = await this.context.appendArchitectureEventsWithFeed(repositoryRoot, {
|
|
50594
50927
|
writer: "runtime-daemon",
|
|
@@ -51087,7 +51420,7 @@ function obsoleteManagedProjectionPaths(currentFiles, projectedFiles) {
|
|
|
51087
51420
|
}
|
|
51088
51421
|
function expectedFileHash(root, path) {
|
|
51089
51422
|
const absolute = resolve24(root, path);
|
|
51090
|
-
return existsSync20(absolute) ? digestJson({ body:
|
|
51423
|
+
return existsSync20(absolute) ? digestJson({ body: readFileSync20(absolute, "utf8") }) : "missing";
|
|
51091
51424
|
}
|
|
51092
51425
|
function architectureProjectionRollbackBackup(files, options = {}) {
|
|
51093
51426
|
const manifest = {
|
|
@@ -51142,12 +51475,12 @@ function isEmptyArchitectureLedgerState(state) {
|
|
|
51142
51475
|
// packages/local-runtime/runtime-daemon/src/architecture-book.ts
|
|
51143
51476
|
init_src();
|
|
51144
51477
|
import { existsSync as existsSync22 } from "node:fs";
|
|
51145
|
-
import { join as
|
|
51478
|
+
import { join as join17 } from "node:path";
|
|
51146
51479
|
|
|
51147
51480
|
// packages/local-runtime/runtime-daemon/src/refactor-decisions.ts
|
|
51148
51481
|
init_src();
|
|
51149
|
-
import { existsSync as existsSync21, lstatSync as lstatSync11, readdirSync as readdirSync12, readFileSync as
|
|
51150
|
-
import { join as
|
|
51482
|
+
import { existsSync as existsSync21, lstatSync as lstatSync11, readdirSync as readdirSync12, readFileSync as readFileSync21 } from "node:fs";
|
|
51483
|
+
import { join as join16 } from "node:path";
|
|
51151
51484
|
var REFACTOR_DECISION_SET_SCHEMA_VERSION = "archcontext.refactor-decision-set/v1";
|
|
51152
51485
|
var REFACTOR_DECISION_FILE_NAME = /^recommendation\.[a-f0-9]{16}\.json$/;
|
|
51153
51486
|
var CHANGESET_TRANSIENT_DECISION_NAME = /^recommendation\.[a-f0-9]{16}\.json\.(archctx-backup|archctx-tmp-[0-9]+-[0-9]+)$/;
|
|
@@ -51186,11 +51519,11 @@ function readRefactorDecisionSet(root) {
|
|
|
51186
51519
|
const name = path.slice(prefix.length);
|
|
51187
51520
|
if (name.includes("/"))
|
|
51188
51521
|
throw decisionReadError(`${path} must sit directly in ${REFACTOR_DECISION_DIRECTORY}`);
|
|
51189
|
-
if (!lstatSync11(
|
|
51522
|
+
if (!lstatSync11(join16(absoluteDirectory, name)).isFile())
|
|
51190
51523
|
throw decisionReadError(`${path} must be a regular file, not a directory or symlink`);
|
|
51191
51524
|
let decision;
|
|
51192
51525
|
try {
|
|
51193
|
-
decision = parseRefactorDecisionFile(path,
|
|
51526
|
+
decision = parseRefactorDecisionFile(path, readFileSync21(join16(absoluteDirectory, name), "utf8"));
|
|
51194
51527
|
} catch (error) {
|
|
51195
51528
|
throw decisionReadError(error instanceof Error ? error.message : String(error));
|
|
51196
51529
|
}
|
|
@@ -51279,7 +51612,7 @@ function buildRefactorDecision(input) {
|
|
|
51279
51612
|
function refactorDecisionWrite(root, decision) {
|
|
51280
51613
|
const path = refactorDecisionPath(decision.recommendationId);
|
|
51281
51614
|
const absolute = assertPathHasNoSymlinkSegments(root, path);
|
|
51282
|
-
const expectedHash = existsSync21(absolute) ? digestJson({ body:
|
|
51615
|
+
const expectedHash = existsSync21(absolute) ? digestJson({ body: readFileSync21(absolute, "utf8") }) : "missing";
|
|
51283
51616
|
return { path, expectedHash, body: serializeRefactorDecision(decision) };
|
|
51284
51617
|
}
|
|
51285
51618
|
function refactorDecisionIdentityIssues(decision, namespace) {
|
|
@@ -51469,7 +51802,7 @@ class ArchitectureBookService {
|
|
|
51469
51802
|
const gitScope = await this.context.architectureLedgerGitScope(root);
|
|
51470
51803
|
let refactorDecisionStatuses = new Map;
|
|
51471
51804
|
const repositoryRoot = findRepositoryRoot(root);
|
|
51472
|
-
if (replay.events.some(eventCarriesRefactorRecommendation) || existsSync22(
|
|
51805
|
+
if (replay.events.some(eventCarriesRefactorRecommendation) || existsSync22(join17(repositoryRoot, REFACTOR_DECISION_DIRECTORY))) {
|
|
51473
51806
|
try {
|
|
51474
51807
|
const decisions = readRefactorDecisionSet(repositoryRoot);
|
|
51475
51808
|
refactorDecisionStatuses = new Map(decisions.decisions.map((decision) => [decision.recommendationId, decision.status]));
|
|
@@ -51825,8 +52158,8 @@ init_src();
|
|
|
51825
52158
|
init_src();
|
|
51826
52159
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
51827
52160
|
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
|
|
52161
|
+
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";
|
|
52162
|
+
import { basename as basename6, dirname as dirname9, join as join18 } from "node:path";
|
|
51830
52163
|
|
|
51831
52164
|
// packages/local-runtime/runtime-daemon/src/investigation-transport.ts
|
|
51832
52165
|
import { spawn } from "node:child_process";
|
|
@@ -52068,7 +52401,7 @@ var AUDIT_EGRESS_POLICY_DIGEST = digestJson(AUDIT_EGRESS_POLICY);
|
|
|
52068
52401
|
function auditConsentBinding(root, env) {
|
|
52069
52402
|
const paths = runtimeStatePaths(root, env);
|
|
52070
52403
|
return {
|
|
52071
|
-
path:
|
|
52404
|
+
path: join18(paths.repositoryStateDir, AUDIT_CONSENT_FILE),
|
|
52072
52405
|
storageRepositoryId: paths.storageRepositoryId,
|
|
52073
52406
|
repositoryAnchor: paths.repositoryAnchor,
|
|
52074
52407
|
origin: readSanitizedOrigin(paths.repositoryRoot)
|
|
@@ -52116,7 +52449,7 @@ function readAuditConsentUnchecked(root, env = process.env) {
|
|
|
52116
52449
|
try {
|
|
52117
52450
|
if (!lstatSync12(binding.path).isFile())
|
|
52118
52451
|
return { granted: false, path: binding.path, reason: "unreadable" };
|
|
52119
|
-
record = JSON.parse(
|
|
52452
|
+
record = JSON.parse(readFileSync22(binding.path, "utf8"));
|
|
52120
52453
|
} catch {
|
|
52121
52454
|
return { granted: false, path: binding.path, reason: "unreadable" };
|
|
52122
52455
|
}
|
|
@@ -52154,13 +52487,13 @@ function grantAuditConsentUnchecked(root, env = process.env, now = new Date().to
|
|
|
52154
52487
|
}
|
|
52155
52488
|
function writePrivateJsonAtomically(path, value) {
|
|
52156
52489
|
const directory = dirname9(path);
|
|
52157
|
-
|
|
52158
|
-
const tempPath =
|
|
52490
|
+
mkdirSync9(directory, { recursive: true, mode: 448 });
|
|
52491
|
+
const tempPath = join18(directory, `.${basename6(path)}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`);
|
|
52159
52492
|
try {
|
|
52160
|
-
|
|
52493
|
+
writeFileSync8(tempPath, `${JSON.stringify(value, null, 2)}
|
|
52161
52494
|
`, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
52162
52495
|
chmodSync5(tempPath, 384);
|
|
52163
|
-
|
|
52496
|
+
renameSync5(tempPath, path);
|
|
52164
52497
|
} catch (error) {
|
|
52165
52498
|
rmSync10(tempPath, { force: true });
|
|
52166
52499
|
throw error;
|
|
@@ -52193,9 +52526,9 @@ function auditConsentRequiredEnvelope(requestId, reason) {
|
|
|
52193
52526
|
|
|
52194
52527
|
// packages/local-runtime/runtime-daemon/src/github-issue-executor.ts
|
|
52195
52528
|
import { execFile } from "node:child_process";
|
|
52196
|
-
import { mkdtempSync as mkdtempSync4, rmSync as rmSync11, writeFileSync as
|
|
52529
|
+
import { mkdtempSync as mkdtempSync4, rmSync as rmSync11, writeFileSync as writeFileSync9 } from "node:fs";
|
|
52197
52530
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
52198
|
-
import { join as
|
|
52531
|
+
import { join as join19 } from "node:path";
|
|
52199
52532
|
var DEFAULT_GH_EXECUTOR_TIMEOUT_MS = 30000;
|
|
52200
52533
|
var GITHUB_ISSUE_LIST_LIMIT = 100;
|
|
52201
52534
|
function createNodeGithubIssueExecutor(options = {}) {
|
|
@@ -52260,10 +52593,10 @@ function runGh(args, env, timeoutMs) {
|
|
|
52260
52593
|
});
|
|
52261
52594
|
}
|
|
52262
52595
|
async function withGithubIssueBodyFile(body, fn, deps = {}) {
|
|
52263
|
-
const writeFile = deps.writeFile ??
|
|
52264
|
-
const dir = mkdtempSync4(
|
|
52596
|
+
const writeFile = deps.writeFile ?? writeFileSync9;
|
|
52597
|
+
const dir = mkdtempSync4(join19(tmpdir4(), "archctx-gh-issue-body-"));
|
|
52265
52598
|
try {
|
|
52266
|
-
const bodyFile =
|
|
52599
|
+
const bodyFile = join19(dir, "body.md");
|
|
52267
52600
|
writeFile(bodyFile, body, { mode: 384 });
|
|
52268
52601
|
return await fn(bodyFile);
|
|
52269
52602
|
} finally {
|
|
@@ -53247,10 +53580,10 @@ function runtimeProjectionOwnedOutputDigest(projection) {
|
|
|
53247
53580
|
}
|
|
53248
53581
|
// packages/local-runtime/runtime-daemon/src/projection-writer.ts
|
|
53249
53582
|
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
|
|
53583
|
+
import { createHash as createHash11, randomUUID as randomUUID3 } from "node:crypto";
|
|
53584
|
+
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
53585
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
53253
|
-
import { extname as extname2, join as
|
|
53586
|
+
import { extname as extname2, join as join20, resolve as resolve25 } from "node:path";
|
|
53254
53587
|
init_src();
|
|
53255
53588
|
var PROJECTION_PUBLISH_REQUEST_ID = "projection.publish";
|
|
53256
53589
|
var PROJECTION_PUBLISH_STATUS_REQUEST_ID = "projection.publish-status";
|
|
@@ -53263,6 +53596,10 @@ var PROJECTION_WRITER_MAX_ITERATIONS = 3;
|
|
|
53263
53596
|
var PROJECTION_WRITER_TARGETS = ["agent-context", "architecture-docs"];
|
|
53264
53597
|
var PUBLISHER_TIMEOUT_MS = 120000;
|
|
53265
53598
|
var PR_BODY_MAX_LISTED_PATHS = 200;
|
|
53599
|
+
function renderRecentHistory(root, ref, env) {
|
|
53600
|
+
const { total } = readArchitectureHistory(root, { ref, limit: 0, env });
|
|
53601
|
+
return renderHistoryMarkdown(readArchitectureHistory(root, { ref, offset: Math.max(0, total - 20), limit: 20, env }));
|
|
53602
|
+
}
|
|
53266
53603
|
|
|
53267
53604
|
class ProjectionWriterFailure extends Error {
|
|
53268
53605
|
code;
|
|
@@ -53280,8 +53617,8 @@ class ProjectionWriterFailure extends Error {
|
|
|
53280
53617
|
}
|
|
53281
53618
|
function projectionWriterPaths(repositoryRoot, remote, base, env = process.env) {
|
|
53282
53619
|
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:
|
|
53620
|
+
const dir = join20(runtimeStatePaths(repositoryRoot, env).repositoryStateDir, "projection-writer", key);
|
|
53621
|
+
return { dir, baseRef: `refs/archctx/projection-writer/${key}/base`, worktree: join20(dir, "worktree"), state: join20(dir, "state.json"), lock: join20(dir, "lock") };
|
|
53285
53622
|
}
|
|
53286
53623
|
async function runProjectionPublishCommand(options) {
|
|
53287
53624
|
const env = options.env ?? process.env;
|
|
@@ -53326,7 +53663,7 @@ async function runProjectionPublishCommand(options) {
|
|
|
53326
53663
|
});
|
|
53327
53664
|
let lock;
|
|
53328
53665
|
try {
|
|
53329
|
-
|
|
53666
|
+
mkdirSync10(paths.dir, { recursive: true, mode: 448 });
|
|
53330
53667
|
lock = acquireProjectionWriterLock(paths.lock, startedAt);
|
|
53331
53668
|
} catch (error) {
|
|
53332
53669
|
const failure = asWriterFailure(error);
|
|
@@ -53435,6 +53772,12 @@ async function runLockedProjectionPublish(input) {
|
|
|
53435
53772
|
if (!["noop", "applied", "applied-partial"].includes(projectionStatus)) {
|
|
53436
53773
|
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
53774
|
}
|
|
53775
|
+
const historyBody = renderRecentHistory(paths.worktree, baseSha, options.env);
|
|
53776
|
+
const historyPath = join20(paths.worktree, ARCHITECTURE_HISTORY_PATH);
|
|
53777
|
+
mkdirSync10(join20(paths.worktree, "docs/architecture"), { recursive: true });
|
|
53778
|
+
const historyTemp = `${historyPath}.${randomUUID3()}.tmp`;
|
|
53779
|
+
writeFileSync10(historyTemp, historyBody);
|
|
53780
|
+
renameSync6(historyTemp, historyPath);
|
|
53438
53781
|
const changed = worktreeChangedPaths(paths.worktree);
|
|
53439
53782
|
if (changed.length === 0) {
|
|
53440
53783
|
const tip = lsRemoteBranch(repositoryRoot, pushRemote, base, env);
|
|
@@ -53446,6 +53789,7 @@ async function runLockedProjectionPublish(input) {
|
|
|
53446
53789
|
return finish("up-to-date", { projectionStatus });
|
|
53447
53790
|
}
|
|
53448
53791
|
const written = new Set(result.files.filter((file) => file.action !== "unchanged").map((file) => file.path));
|
|
53792
|
+
written.add(ARCHITECTURE_HISTORY_PATH);
|
|
53449
53793
|
const offending = changed.filter((path) => !written.has(path) || !isProjectionOwnedPath(path, ownedPatterns));
|
|
53450
53794
|
if (offending.length > 0) {
|
|
53451
53795
|
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 +53892,10 @@ function projectionPublishBody(input) {
|
|
|
53548
53892
|
async function publishPullRequest(publisher, input) {
|
|
53549
53893
|
if (publisher.kind === "none")
|
|
53550
53894
|
return { ok: true, pullRequest: null };
|
|
53551
|
-
const dir = mkdtempSync5(
|
|
53895
|
+
const dir = mkdtempSync5(join20(tmpdir5(), "archctx-projection-pr-body-"));
|
|
53552
53896
|
try {
|
|
53553
|
-
const bodyFile =
|
|
53554
|
-
|
|
53897
|
+
const bodyFile = join20(dir, "body.md");
|
|
53898
|
+
writeFileSync10(bodyFile, projectionPublishBody(input), { mode: 384 });
|
|
53555
53899
|
const pullRequest = await publisher.ensurePullRequest({
|
|
53556
53900
|
worktree: input.worktree,
|
|
53557
53901
|
remote: input.remote,
|
|
@@ -53690,11 +54034,13 @@ function runProjectionVerifyPrCommand(options) {
|
|
|
53690
54034
|
} catch {
|
|
53691
54035
|
agentContextDiffering = [...classified.agentContextPaths];
|
|
53692
54036
|
}
|
|
54037
|
+
const historyDiffering = changedPaths.includes(ARCHITECTURE_HISTORY_PATH) && readFileAtRevision(root, headSha, ARCHITECTURE_HISTORY_PATH) !== renderRecentHistory(root, headSha) ? [ARCHITECTURE_HISTORY_PATH] : [];
|
|
53693
54038
|
const differingPaths = [...new Set([
|
|
53694
54039
|
...result.files.filter((file) => file.action !== "unchanged").map((file) => file.path),
|
|
53695
|
-
...agentContextDiffering
|
|
54040
|
+
...agentContextDiffering,
|
|
54041
|
+
...historyDiffering
|
|
53696
54042
|
])].sort();
|
|
53697
|
-
const renderEquivalent = result.status === "noop" && agentContextDiffering.length === 0;
|
|
54043
|
+
const renderEquivalent = result.status === "noop" && agentContextDiffering.length === 0 && historyDiffering.length === 0;
|
|
53698
54044
|
return verification({
|
|
53699
54045
|
verdict: renderEquivalent ? "generated-only-render-equivalent" : "generated-only-not-render-equivalent",
|
|
53700
54046
|
generatedOnly: true,
|
|
@@ -53713,7 +54059,7 @@ function classifyPullRequestPaths(root, mergeBase, headSha, changedPaths) {
|
|
|
53713
54059
|
const humanEdited = [];
|
|
53714
54060
|
const agentContext = [];
|
|
53715
54061
|
for (const path of changedPaths) {
|
|
53716
|
-
if (path === ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH)
|
|
54062
|
+
if (path === ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH || path === ARCHITECTURE_HISTORY_PATH)
|
|
53717
54063
|
continue;
|
|
53718
54064
|
const atBase = baseTargets.get(path);
|
|
53719
54065
|
const atHead = headTargets.get(path);
|
|
@@ -54052,7 +54398,7 @@ function acquireProjectionWriterLock(lockPath, startedAt) {
|
|
|
54052
54398
|
return { kind: "busy", pid: holder.pid };
|
|
54053
54399
|
}
|
|
54054
54400
|
rmSync12(lockPath, { force: true });
|
|
54055
|
-
const record = JSON.stringify({ pid: process.pid, startedAt, token:
|
|
54401
|
+
const record = JSON.stringify({ pid: process.pid, startedAt, token: randomUUID3() }, null, 2);
|
|
54056
54402
|
createPrivateControlFile(lockPath, record);
|
|
54057
54403
|
return { kind: "acquired", record, release() {
|
|
54058
54404
|
try {
|
|
@@ -54108,7 +54454,7 @@ function readProjectionWriterState(path, remote, base) {
|
|
|
54108
54454
|
return emptyProjectionWriterState(remote, base);
|
|
54109
54455
|
let value;
|
|
54110
54456
|
try {
|
|
54111
|
-
value = JSON.parse(
|
|
54457
|
+
value = JSON.parse(readFileSync23(path, "utf8"));
|
|
54112
54458
|
} catch (error) {
|
|
54113
54459
|
throw new ProjectionWriterFailure("AC_PRECONDITION_FAILED", "projection-writer-state-invalid", `projection writer state is unreadable at ${path}: ${errorMessage(error)}`);
|
|
54114
54460
|
}
|
|
@@ -54130,9 +54476,9 @@ function readProjectionWriterState(path, remote, base) {
|
|
|
54130
54476
|
}
|
|
54131
54477
|
function writeProjectionWriterState(path, state) {
|
|
54132
54478
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
54133
|
-
|
|
54479
|
+
writeFileSync10(temporary, `${JSON.stringify(state, null, 2)}
|
|
54134
54480
|
`, { encoding: "utf8", mode: 384 });
|
|
54135
|
-
|
|
54481
|
+
renameSync6(temporary, path);
|
|
54136
54482
|
}
|
|
54137
54483
|
function prepareProjectionWriterWorktree(repositoryRoot, worktree, sha) {
|
|
54138
54484
|
git(repositoryRoot, ["worktree", "prune"]);
|
|
@@ -54145,7 +54491,7 @@ function prepareProjectionWriterWorktree(repositoryRoot, worktree, sha) {
|
|
|
54145
54491
|
git(worktree, ["clean", "-ffdq"]);
|
|
54146
54492
|
}
|
|
54147
54493
|
function isRegisteredWorktree(repositoryRoot, worktree) {
|
|
54148
|
-
if (!existsSync24(
|
|
54494
|
+
if (!existsSync24(join20(worktree, ".git")))
|
|
54149
54495
|
return false;
|
|
54150
54496
|
const wanted = canonical(worktree);
|
|
54151
54497
|
return git(repositoryRoot, ["worktree", "list", "--porcelain", "-z"]).split("\x00").filter((line) => line.startsWith("worktree ")).some((line) => canonical(line.slice("worktree ".length)) === wanted);
|
|
@@ -54397,7 +54743,7 @@ function runFlowSelectorCheckCommand(cwd, options = {}) {
|
|
|
54397
54743
|
}
|
|
54398
54744
|
// packages/local-runtime/runtime-daemon/src/recommendations.ts
|
|
54399
54745
|
import { existsSync as existsSync25 } from "node:fs";
|
|
54400
|
-
import { join as
|
|
54746
|
+
import { join as join21 } from "node:path";
|
|
54401
54747
|
|
|
54402
54748
|
// packages/local-runtime/runtime-daemon/src/refactor-verify.ts
|
|
54403
54749
|
init_src();
|
|
@@ -54999,7 +55345,7 @@ class RecommendationsService {
|
|
|
54999
55345
|
});
|
|
55000
55346
|
}
|
|
55001
55347
|
readGitOnlyDecision(repositoryRoot, recommendationId, surface) {
|
|
55002
|
-
if (!existsSync25(
|
|
55348
|
+
if (!existsSync25(join21(repositoryRoot, REFACTOR_DECISION_DIRECTORY)))
|
|
55003
55349
|
return;
|
|
55004
55350
|
let decisions;
|
|
55005
55351
|
try {
|
|
@@ -55669,7 +56015,7 @@ function lifecycleEnvelope(input) {
|
|
|
55669
56015
|
});
|
|
55670
56016
|
}
|
|
55671
56017
|
function refactorDecisionsInPlay(repositoryRoot, records) {
|
|
55672
|
-
return records.some(isRefactorRecommendation) || existsSync25(
|
|
56018
|
+
return records.some(isRefactorRecommendation) || existsSync25(join21(repositoryRoot, REFACTOR_DECISION_DIRECTORY));
|
|
55673
56019
|
}
|
|
55674
56020
|
function ledgerAuditDecisionRefused(surface, record, recommendations, decisions) {
|
|
55675
56021
|
let head = record.recommendationId;
|
|
@@ -55791,14 +56137,14 @@ function recommendationActorKind(input) {
|
|
|
55791
56137
|
init_src();
|
|
55792
56138
|
init_src();
|
|
55793
56139
|
init_src();
|
|
55794
|
-
import { existsSync as existsSync26, readFileSync as
|
|
56140
|
+
import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
|
|
55795
56141
|
import { resolve as resolve27 } from "node:path";
|
|
55796
56142
|
init_src();
|
|
55797
56143
|
|
|
55798
56144
|
// packages/local-runtime/runtime-daemon/src/committed-change-acceptance.ts
|
|
55799
56145
|
init_src();
|
|
55800
56146
|
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
|
|
56147
|
+
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
56148
|
import { resolve as resolve26 } from "node:path";
|
|
55803
56149
|
init_src();
|
|
55804
56150
|
var SEMANTIC_MODEL_DIRECTORIES = ["nodes", "relations", "flows"];
|
|
@@ -55877,7 +56223,7 @@ function readRegularFileBytes(absolute, path) {
|
|
|
55877
56223
|
try {
|
|
55878
56224
|
if (!fstatSync4(fd).isFile())
|
|
55879
56225
|
throw new FailureError("AC_PRECONDITION_FAILED", "semantic-model-entry-not-regular");
|
|
55880
|
-
return
|
|
56226
|
+
return readFileSync24(fd);
|
|
55881
56227
|
} finally {
|
|
55882
56228
|
closeSync9(fd);
|
|
55883
56229
|
}
|
|
@@ -56380,7 +56726,7 @@ class ChangeSetAuthorityService {
|
|
|
56380
56726
|
const absolute = resolve27(session.workspace.root, path);
|
|
56381
56727
|
const body = `${JSON.stringify(waiver, null, 2)}
|
|
56382
56728
|
`;
|
|
56383
|
-
const expectedHash = existsSync26(absolute) ? digestJson({ body:
|
|
56729
|
+
const expectedHash = existsSync26(absolute) ? digestJson({ body: readFileSync25(absolute, "utf8") }) : "missing";
|
|
56384
56730
|
const draft = this.changeSetEngine.plan({
|
|
56385
56731
|
id: input.id ?? `changeset.practice-waiver-${waiverId.replace(/[^A-Za-z0-9_-]/g, "-")}`,
|
|
56386
56732
|
base: {
|
|
@@ -56820,7 +57166,7 @@ function architectureLedgerWriteAppendsEvents(mode) {
|
|
|
56820
57166
|
// packages/local-runtime/runtime-daemon/src/rpc-server.ts
|
|
56821
57167
|
init_src();
|
|
56822
57168
|
import { createServer as createServer2 } from "node:http";
|
|
56823
|
-
import { closeSync as closeSync10, existsSync as existsSync27, mkdirSync as
|
|
57169
|
+
import { closeSync as closeSync10, existsSync as existsSync27, mkdirSync as mkdirSync11 } from "node:fs";
|
|
56824
57170
|
import { dirname as dirname10 } from "node:path";
|
|
56825
57171
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
56826
57172
|
var DEFAULT_DAEMON_IDLE_TIMEOUT_MS = 30 * 60000;
|
|
@@ -56891,8 +57237,8 @@ class ArchctxRuntimeRpcServer {
|
|
|
56891
57237
|
const root = this.options.root ?? process.cwd();
|
|
56892
57238
|
const connectionPath = this.options.connectionPath ?? defaultDaemonConnectionPath(root);
|
|
56893
57239
|
const lockPath = this.options.lockPath ?? defaultDaemonLockPath(root);
|
|
56894
|
-
|
|
56895
|
-
|
|
57240
|
+
mkdirSync11(dirname10(connectionPath), { recursive: true });
|
|
57241
|
+
mkdirSync11(dirname10(lockPath), { recursive: true });
|
|
56896
57242
|
this.lockFd = acquireDaemonLock(lockPath, root);
|
|
56897
57243
|
const token = this.options.token ?? randomBytes5(18).toString("base64url");
|
|
56898
57244
|
const server = createServer2((request, response) => {
|
|
@@ -57211,7 +57557,7 @@ async function readRpcRequestBody(request, limits) {
|
|
|
57211
57557
|
}
|
|
57212
57558
|
|
|
57213
57559
|
// packages/local-runtime/runtime-daemon/src/index.ts
|
|
57214
|
-
import { existsSync as existsSync28, readFileSync as
|
|
57560
|
+
import { existsSync as existsSync28, readFileSync as readFileSync26 } from "node:fs";
|
|
57215
57561
|
import { resolve as resolve28 } from "node:path";
|
|
57216
57562
|
init_src();
|
|
57217
57563
|
|
|
@@ -57406,7 +57752,7 @@ class ArchctxDaemon {
|
|
|
57406
57752
|
const model = loadNativeModelFromArchContext(root);
|
|
57407
57753
|
const canonical = renderAgentContextProjection({ model, sourceDigest: digestJson({ model }), existingFiles: loadAgentContextProjectionFiles(root, model) });
|
|
57408
57754
|
const canonicalBody = canonical.files.find((candidate) => candidate.path === file.path)?.body;
|
|
57409
|
-
if (canonicalBody === undefined || projectionOwnedWriteBody(canonicalBody,
|
|
57755
|
+
if (canonicalBody === undefined || projectionOwnedWriteBody(canonicalBody, readFileSync26(resolve28(root, file.path), "utf8")) !== file.body) {
|
|
57410
57756
|
throw new Error(`Root contract requires canonical marker-only content: ${file.path}`);
|
|
57411
57757
|
}
|
|
57412
57758
|
}
|
|
@@ -58724,8 +59070,8 @@ function isArchContextGeneratedProjectionPath2(path) {
|
|
|
58724
59070
|
|
|
58725
59071
|
// packages/surfaces/cli/src/github-review-state.ts
|
|
58726
59072
|
init_src();
|
|
58727
|
-
import { chmodSync as chmodSync6, existsSync as existsSync29, mkdirSync as
|
|
58728
|
-
import { dirname as dirname11, join as
|
|
59073
|
+
import { chmodSync as chmodSync6, existsSync as existsSync29, mkdirSync as mkdirSync12, readFileSync as readFileSync27, rmSync as rmSync13, writeFileSync as writeFileSync11 } from "node:fs";
|
|
59074
|
+
import { dirname as dirname11, join as join23 } from "node:path";
|
|
58729
59075
|
var text2 = { type: "string", minLength: 1 };
|
|
58730
59076
|
var digest2 = { type: "string", pattern: "^sha256:[0-9a-f]{64}$" };
|
|
58731
59077
|
var record7 = (properties, required = Object.keys(properties)) => ({ type: "object", additionalProperties: false, properties, required });
|
|
@@ -58756,7 +59102,7 @@ var stateSchema = record7({
|
|
|
58756
59102
|
}, ["schemaVersion", "status", "challenge", "challengeDigest", "updatedAt"]);
|
|
58757
59103
|
function defaultGithubDeveloperReviewStatePath(cwd, pullRequestNumber) {
|
|
58758
59104
|
const suffix = pullRequestNumber ? `github-developer-review-pr-${pullRequestNumber}.json` : "github-developer-review.json";
|
|
58759
|
-
return
|
|
59105
|
+
return join23(runtimeStatePaths(cwd).workspaceStateDir, suffix);
|
|
58760
59106
|
}
|
|
58761
59107
|
function metadata(state) {
|
|
58762
59108
|
const { submission, ...rest } = state;
|
|
@@ -58810,8 +59156,8 @@ async function writeGithubDeveloperReviewState(cwd, state, secrets = []) {
|
|
|
58810
59156
|
assertNoCliSecretMaterial(state.submission);
|
|
58811
59157
|
assertNoReviewSecrets(state.submission, secrets);
|
|
58812
59158
|
}
|
|
58813
|
-
|
|
58814
|
-
|
|
59159
|
+
mkdirSync12(dirname11(path), { recursive: true });
|
|
59160
|
+
writeFileSync11(path, serialized, { mode: 384 });
|
|
58815
59161
|
if (process.platform !== "win32")
|
|
58816
59162
|
chmodSync6(path, 384);
|
|
58817
59163
|
return { state: { ...validated, ...state.submission === undefined ? {} : { submission: state.submission } }, path };
|
|
@@ -58821,7 +59167,7 @@ function readGithubDeveloperReviewState(path) {
|
|
|
58821
59167
|
return;
|
|
58822
59168
|
let parsed;
|
|
58823
59169
|
try {
|
|
58824
|
-
parsed = JSON.parse(
|
|
59170
|
+
parsed = JSON.parse(readFileSync27(path, "utf8"));
|
|
58825
59171
|
} catch {
|
|
58826
59172
|
throw new Error("github-review-state-metadata-invalid");
|
|
58827
59173
|
}
|
|
@@ -58836,7 +59182,7 @@ function discardLegacyGithubDeveloperReviewState(path) {
|
|
|
58836
59182
|
return false;
|
|
58837
59183
|
let parsed;
|
|
58838
59184
|
try {
|
|
58839
|
-
parsed = JSON.parse(
|
|
59185
|
+
parsed = JSON.parse(readFileSync27(path, "utf8"));
|
|
58840
59186
|
} catch {
|
|
58841
59187
|
throw new Error("github-review-state-metadata-invalid");
|
|
58842
59188
|
}
|
|
@@ -58938,13 +59284,14 @@ function localEgressStatus2(env = process.env, live = {}) {
|
|
|
58938
59284
|
|
|
58939
59285
|
// packages/surfaces/cli/src/main.ts
|
|
58940
59286
|
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
|
|
59287
|
+
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";
|
|
59288
|
+
import { dirname as dirname16, join as join28, parse, resolve as resolve37 } from "path";
|
|
58943
59289
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
58944
59290
|
|
|
58945
59291
|
// packages/contracts/src/index.ts
|
|
58946
59292
|
init_control_plane_routes();
|
|
58947
59293
|
init_architecture();
|
|
59294
|
+
init_architecture_history();
|
|
58948
59295
|
init_architecture_debt();
|
|
58949
59296
|
init_docs_anchors();
|
|
58950
59297
|
init_github_governance();
|
|
@@ -58966,12 +59313,12 @@ init_changeset_recovery();
|
|
|
58966
59313
|
|
|
58967
59314
|
// packages/core/changeset-engine/src/index.ts
|
|
58968
59315
|
init_src();
|
|
58969
|
-
import { chmodSync as chmodSync7, closeSync as closeSync11, existsSync as existsSync30, fsyncSync as fsyncSync4, lstatSync as lstatSync14, mkdirSync as
|
|
59316
|
+
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
59317
|
import { dirname as dirname12, isAbsolute as isAbsolute7, relative as relative8, resolve as resolve29, sep as sep6 } from "node:path";
|
|
58971
59318
|
var EMPTY_PATH_SET2 = new Set;
|
|
58972
59319
|
function planManifestFieldsOperation(root, fields) {
|
|
58973
59320
|
const absolute = assertPathHasNoSymlinkSegments2(root, MANIFEST_UPDATE_PATH);
|
|
58974
|
-
const body =
|
|
59321
|
+
const body = readFileSync28(absolute, "utf8");
|
|
58975
59322
|
const operation = { op: "update_manifest_fields", path: MANIFEST_UPDATE_PATH, expectedHash: digestJson({ body }), fields };
|
|
58976
59323
|
assertManifestUpdateOperation(operation);
|
|
58977
59324
|
renderManifestFieldsUpdate(body, fields);
|
|
@@ -59079,7 +59426,7 @@ function assertAllowedArchContextPath2(root, relativePath, scope) {
|
|
|
59079
59426
|
|
|
59080
59427
|
// packages/core/architecture-domain/src/index.ts
|
|
59081
59428
|
import { createHash as createHash12 } from "node:crypto";
|
|
59082
|
-
import { readFileSync as
|
|
59429
|
+
import { readFileSync as readFileSync29, realpathSync as realpathSync10, statSync as statSync8 } from "node:fs";
|
|
59083
59430
|
import { resolve as resolve31 } from "node:path";
|
|
59084
59431
|
init_src();
|
|
59085
59432
|
var DEFAULT_IGNORES2 = new Set([
|
|
@@ -59132,7 +59479,7 @@ function computeWorktreeDigest2(root, files, options = {}) {
|
|
|
59132
59479
|
return {
|
|
59133
59480
|
path,
|
|
59134
59481
|
size: statSync8(absolute).size,
|
|
59135
|
-
digest: createHash12("sha256").update(
|
|
59482
|
+
digest: createHash12("sha256").update(readFileSync29(absolute)).digest("hex")
|
|
59136
59483
|
};
|
|
59137
59484
|
});
|
|
59138
59485
|
return digestJson(payload);
|
|
@@ -59447,7 +59794,7 @@ var UNTRUSTED_TOOL_ESCAPE_KEYS2 = new Set([
|
|
|
59447
59794
|
]);
|
|
59448
59795
|
|
|
59449
59796
|
// packages/cloud/hardening/src/index.ts
|
|
59450
|
-
import { readdirSync as readdirSync14, readFileSync as
|
|
59797
|
+
import { readdirSync as readdirSync14, readFileSync as readFileSync30, statSync as statSync9 } from "node:fs";
|
|
59451
59798
|
import { resolve as resolve32 } from "node:path";
|
|
59452
59799
|
init_src2();
|
|
59453
59800
|
init_src();
|
|
@@ -59495,7 +59842,7 @@ function uninstallMarker(content, host) {
|
|
|
59495
59842
|
`).trim();
|
|
59496
59843
|
}
|
|
59497
59844
|
function dependencyAudit(root) {
|
|
59498
|
-
const packageJson = JSON.parse(
|
|
59845
|
+
const packageJson = JSON.parse(readFileSync30(resolve32(root, "package.json"), "utf8"));
|
|
59499
59846
|
const issues = [];
|
|
59500
59847
|
if (packageJson.engines?.node !== ARCHCONTEXT_NODE_RANGE) {
|
|
59501
59848
|
issues.push(`node engine must equal ${ARCHCONTEXT_NODE_RANGE}`);
|
|
@@ -59509,7 +59856,7 @@ function secretScan(root) {
|
|
|
59509
59856
|
continue;
|
|
59510
59857
|
if (file === "packages/cloud/hardening/src/index.ts" || file.includes("/test/"))
|
|
59511
59858
|
continue;
|
|
59512
|
-
const body =
|
|
59859
|
+
const body = readFileSync30(resolve32(root, file), "utf8");
|
|
59513
59860
|
if (/(sk-[A-Za-z0-9]{20,}|ghp_[A-Za-z0-9]{20,}|BEGIN PRIVATE KEY)/.test(body))
|
|
59514
59861
|
findings.push(file);
|
|
59515
59862
|
}
|
|
@@ -59558,10 +59905,10 @@ function listFiles(root) {
|
|
|
59558
59905
|
|
|
59559
59906
|
// packages/local-runtime/local-store-sqlite/src/index.ts
|
|
59560
59907
|
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
|
|
59908
|
+
import { createHash as createHash14, randomUUID as randomUUID4 } from "node:crypto";
|
|
59909
|
+
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
59910
|
import { createRequire as createRequire5 } from "node:module";
|
|
59564
|
-
import { dirname as dirname13, isAbsolute as isAbsolute9, join as
|
|
59911
|
+
import { dirname as dirname13, isAbsolute as isAbsolute9, join as join24, relative as relative10, resolve as resolve33 } from "node:path";
|
|
59565
59912
|
init_src();
|
|
59566
59913
|
var runtimeRequire2 = createRequire5(import.meta.url);
|
|
59567
59914
|
var SQLITE_SIDECAR_SUFFIXES2 = ["", "-wal", "-shm"];
|
|
@@ -60480,8 +60827,8 @@ function recoverRuntimeStateTarget(input) {
|
|
|
60480
60827
|
}
|
|
60481
60828
|
assertRuntimeStateRecoveryDaemonStopped(paths);
|
|
60482
60829
|
const lock = acquireLegacyMigrationLock2(paths);
|
|
60483
|
-
const stagingDir =
|
|
60484
|
-
const stagingPath =
|
|
60830
|
+
const stagingDir = join24(paths.workspaceStateDir, `.runtime.sqlite.recovery-${process.pid}-${randomUUID4()}`);
|
|
60831
|
+
const stagingPath = join24(stagingDir, "runtime.sqlite");
|
|
60485
60832
|
let quarantineDirectory;
|
|
60486
60833
|
let quarantineFiles = [];
|
|
60487
60834
|
let receiptPath;
|
|
@@ -60500,7 +60847,7 @@ function recoverRuntimeStateTarget(input) {
|
|
|
60500
60847
|
throw new Error(`runtime-state-recovery-target-fingerprint-mismatch:${lockedSnapshot.fingerprint}`);
|
|
60501
60848
|
}
|
|
60502
60849
|
assertRuntimeStateRecoveryDiskBudget(inspection.availableBytes, inspection.requiredFreeBytes);
|
|
60503
|
-
quarantineDirectory =
|
|
60850
|
+
quarantineDirectory = join24(paths.workspaceStateDir, "quarantine", `runtime-state-recovery-${Date.now()}-${randomUUID4()}`);
|
|
60504
60851
|
ensurePrivateDir2(quarantineDirectory);
|
|
60505
60852
|
assertRuntimeStateRecoveryPrivatePermissions(quarantineDirectory, 448);
|
|
60506
60853
|
quarantineFiles = copyRuntimeStateRecoveryFiles(lockedSnapshot.files, quarantineDirectory);
|
|
@@ -60513,7 +60860,7 @@ function recoverRuntimeStateTarget(input) {
|
|
|
60513
60860
|
assertRuntimeStateRecoveryPrivatePermissions(stagingDir, 448);
|
|
60514
60861
|
migrateSqliteDatabaseSync2(stagingPath);
|
|
60515
60862
|
const stagingIntegrity = assertCurrentLocalStore2(stagingPath);
|
|
60516
|
-
receiptPath =
|
|
60863
|
+
receiptPath = join24(quarantineDirectory, RUNTIME_STATE_RECOVERY_RECEIPT_FILE);
|
|
60517
60864
|
writeRuntimeStateRecoveryReceipt(receiptPath, {
|
|
60518
60865
|
status: "quarantine-verified",
|
|
60519
60866
|
paths,
|
|
@@ -60577,7 +60924,7 @@ function completeRuntimeStateRecovery(input) {
|
|
|
60577
60924
|
if (resolve33(input.recovery.receiptPath) !== expectedReceiptPath) {
|
|
60578
60925
|
throw new Error("runtime-state-recovery-completion-receipt-path-mismatch");
|
|
60579
60926
|
}
|
|
60580
|
-
const parsed = JSON.parse(
|
|
60927
|
+
const parsed = JSON.parse(readFileSync31(expectedReceiptPath, "utf8"));
|
|
60581
60928
|
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
60929
|
throw new Error("runtime-state-recovery-completion-receipt-mismatch");
|
|
60583
60930
|
}
|
|
@@ -60631,8 +60978,8 @@ function migrateLegacyLocalStoreIfNeeded2(root = process.cwd(), env = process.en
|
|
|
60631
60978
|
}
|
|
60632
60979
|
assertTrustedLegacyLocalStoreSource2(paths);
|
|
60633
60980
|
const lock = acquireLegacyMigrationLock2(paths);
|
|
60634
|
-
const stagingDir =
|
|
60635
|
-
const stagingPath =
|
|
60981
|
+
const stagingDir = join24(paths.workspaceStateDir, `.runtime.sqlite.migration-${process.pid}-${randomUUID4()}`);
|
|
60982
|
+
const stagingPath = join24(stagingDir, "runtime.sqlite");
|
|
60636
60983
|
try {
|
|
60637
60984
|
if (targetExists)
|
|
60638
60985
|
quarantinedFiles.push(...quarantineExistingLocalStore2(paths));
|
|
@@ -61368,13 +61715,13 @@ function runtimeStateRecoveryInspection(paths, migration, status, reasonCode, fi
|
|
|
61368
61715
|
};
|
|
61369
61716
|
}
|
|
61370
61717
|
function runtimeStateRecoveryStartupProbe(paths, sourceFiles) {
|
|
61371
|
-
const probeDirectory =
|
|
61372
|
-
const probePath =
|
|
61718
|
+
const probeDirectory = join24(paths.workspaceStateDir, `.runtime.sqlite.recovery-probe-${process.pid}-${randomUUID4()}`);
|
|
61719
|
+
const probePath = join24(probeDirectory, "runtime.sqlite");
|
|
61373
61720
|
try {
|
|
61374
61721
|
ensurePrivateDir2(probeDirectory);
|
|
61375
61722
|
assertRuntimeStateRecoveryPrivatePermissions(probeDirectory, 448);
|
|
61376
61723
|
for (const source of sourceFiles.filter((file) => file.name.startsWith("runtime.sqlite") && file.name !== LEGACY_MIGRATION_MARKER_FILE2)) {
|
|
61377
|
-
const target =
|
|
61724
|
+
const target = join24(probeDirectory, source.name);
|
|
61378
61725
|
copyFileSync2(source.path, target);
|
|
61379
61726
|
makePrivateFile2(target);
|
|
61380
61727
|
}
|
|
@@ -61466,7 +61813,7 @@ function runtimeStateRecoveryAvailableBytes(path) {
|
|
|
61466
61813
|
}
|
|
61467
61814
|
function copyRuntimeStateRecoveryFiles(sourceFiles, quarantineDirectory) {
|
|
61468
61815
|
return sourceFiles.map((source) => {
|
|
61469
|
-
const target =
|
|
61816
|
+
const target = join24(quarantineDirectory, source.name);
|
|
61470
61817
|
copyFileSync2(source.path, target);
|
|
61471
61818
|
makePrivateFile2(target);
|
|
61472
61819
|
assertRuntimeStateRecoveryPrivatePermissions(target, 384);
|
|
@@ -61512,7 +61859,7 @@ function removeRuntimeStateRecoveryTargetFamily(paths) {
|
|
|
61512
61859
|
}
|
|
61513
61860
|
function restoreRuntimeStateRecoveryFiles(files, paths) {
|
|
61514
61861
|
for (const file of files) {
|
|
61515
|
-
const target = file.name === LEGACY_MIGRATION_MARKER_FILE2 ? legacyMigrationMarkerPath2(paths) :
|
|
61862
|
+
const target = file.name === LEGACY_MIGRATION_MARKER_FILE2 ? legacyMigrationMarkerPath2(paths) : join24(dirname13(paths.localStorePath), file.name);
|
|
61516
61863
|
copyFileSync2(file.path, target);
|
|
61517
61864
|
makePrivateFile2(target);
|
|
61518
61865
|
fsyncFile2(target);
|
|
@@ -61680,7 +62027,7 @@ function publishStagedLocalStore2(stagingPath, targetPath) {
|
|
|
61680
62027
|
if (existsSync32(path))
|
|
61681
62028
|
throw new Error(`Cannot publish migrated SQLite over existing target file: ${path}`);
|
|
61682
62029
|
}
|
|
61683
|
-
|
|
62030
|
+
renameSync8(stagingPath, targetPath);
|
|
61684
62031
|
makePrivateFile2(targetPath);
|
|
61685
62032
|
fsyncDirectory3(dirname13(targetPath));
|
|
61686
62033
|
}
|
|
@@ -61701,7 +62048,7 @@ function acquireLegacyMigrationLock2(paths) {
|
|
|
61701
62048
|
ensurePrivateDir2(dirname13(lockPath));
|
|
61702
62049
|
try {
|
|
61703
62050
|
const fd = openSync12(lockPath, "wx", 384);
|
|
61704
|
-
|
|
62051
|
+
writeFileSync13(fd, JSON.stringify({
|
|
61705
62052
|
schemaVersion: "archcontext.legacy-local-store-migration-lock/v1",
|
|
61706
62053
|
pid: process.pid,
|
|
61707
62054
|
root: paths.repositoryRoot,
|
|
@@ -61727,7 +62074,7 @@ function releaseLegacyMigrationLock2(lock) {
|
|
|
61727
62074
|
}
|
|
61728
62075
|
function isStaleMigrationLock2(lockPath) {
|
|
61729
62076
|
try {
|
|
61730
|
-
const parsed = JSON.parse(
|
|
62077
|
+
const parsed = JSON.parse(readFileSync31(lockPath, "utf8"));
|
|
61731
62078
|
if (typeof parsed.pid !== "number" || parsed.pid <= 0)
|
|
61732
62079
|
return true;
|
|
61733
62080
|
return !isProcessAlive(parsed.pid);
|
|
@@ -61737,21 +62084,21 @@ function isStaleMigrationLock2(lockPath) {
|
|
|
61737
62084
|
}
|
|
61738
62085
|
var LOCAL_STORE_WRITER_OWNED_ERROR = "local-store-writer-owned";
|
|
61739
62086
|
function quarantineExistingLocalStore2(paths) {
|
|
61740
|
-
const quarantineDir =
|
|
62087
|
+
const quarantineDir = join24(paths.workspaceStateDir, "quarantine", `runtime.sqlite-${Date.now()}-${randomUUID4()}`);
|
|
61741
62088
|
ensurePrivateDir2(quarantineDir);
|
|
61742
62089
|
const quarantinedFiles = [];
|
|
61743
62090
|
for (const suffix of SQLITE_SIDECAR_SUFFIXES2) {
|
|
61744
62091
|
const source = `${paths.localStorePath}${suffix}`;
|
|
61745
62092
|
if (!existsSync32(source))
|
|
61746
62093
|
continue;
|
|
61747
|
-
const target =
|
|
61748
|
-
|
|
62094
|
+
const target = join24(quarantineDir, `runtime.sqlite${suffix}`);
|
|
62095
|
+
renameSync8(source, target);
|
|
61749
62096
|
quarantinedFiles.push(target);
|
|
61750
62097
|
}
|
|
61751
62098
|
const markerPath = legacyMigrationMarkerPath2(paths);
|
|
61752
62099
|
if (existsSync32(markerPath)) {
|
|
61753
|
-
const target =
|
|
61754
|
-
|
|
62100
|
+
const target = join24(quarantineDir, LEGACY_MIGRATION_MARKER_FILE2);
|
|
62101
|
+
renameSync8(markerPath, target);
|
|
61755
62102
|
quarantinedFiles.push(target);
|
|
61756
62103
|
}
|
|
61757
62104
|
fsyncDirectory3(quarantineDir);
|
|
@@ -61759,16 +62106,16 @@ function quarantineExistingLocalStore2(paths) {
|
|
|
61759
62106
|
return quarantinedFiles;
|
|
61760
62107
|
}
|
|
61761
62108
|
function legacyMigrationMarkerPath2(paths) {
|
|
61762
|
-
return
|
|
62109
|
+
return join24(paths.workspaceStateDir, LEGACY_MIGRATION_MARKER_FILE2);
|
|
61763
62110
|
}
|
|
61764
62111
|
function legacyMigrationLockPath2(paths) {
|
|
61765
|
-
return
|
|
62112
|
+
return join24(paths.workspaceStateDir, LEGACY_MIGRATION_LOCK_FILE2);
|
|
61766
62113
|
}
|
|
61767
62114
|
function writePrivateJson3(path, value) {
|
|
61768
62115
|
ensurePrivateDir2(dirname13(path));
|
|
61769
62116
|
const fd = openSync12(path, "w", 384);
|
|
61770
62117
|
try {
|
|
61771
|
-
|
|
62118
|
+
writeFileSync13(fd, JSON.stringify(value, null, 2), "utf8");
|
|
61772
62119
|
fsyncSync5(fd);
|
|
61773
62120
|
} finally {
|
|
61774
62121
|
closeSync12(fd);
|
|
@@ -61777,7 +62124,7 @@ function writePrivateJson3(path, value) {
|
|
|
61777
62124
|
fsyncDirectory3(dirname13(path));
|
|
61778
62125
|
}
|
|
61779
62126
|
function ensurePrivateDir2(path) {
|
|
61780
|
-
|
|
62127
|
+
mkdirSync14(path, { recursive: true, mode: 448 });
|
|
61781
62128
|
if (process.platform !== "win32") {
|
|
61782
62129
|
try {
|
|
61783
62130
|
chmodSync8(path, 448);
|
|
@@ -61823,8 +62170,8 @@ function isIgnorableDirectoryFsyncError3(error) {
|
|
|
61823
62170
|
|
|
61824
62171
|
// packages/local-runtime/git-adapter/src/index.ts
|
|
61825
62172
|
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
|
|
62173
|
+
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";
|
|
62174
|
+
import { dirname as dirname14, join as join25, resolve as resolve34 } from "node:path";
|
|
61828
62175
|
init_src();
|
|
61829
62176
|
var GIT_CAT_FILE_MAX_BYTES2 = 512 * 1024 * 1024;
|
|
61830
62177
|
function findRepositoryRoot2(start) {
|
|
@@ -61874,7 +62221,7 @@ function listGitVisibleFiles2(root, pathspec) {
|
|
|
61874
62221
|
}
|
|
61875
62222
|
return [...new Set(output.split("\x00").filter(Boolean))].filter((path) => {
|
|
61876
62223
|
try {
|
|
61877
|
-
return lstatSync16(
|
|
62224
|
+
return lstatSync16(join25(root, path)).isFile();
|
|
61878
62225
|
} catch {
|
|
61879
62226
|
return false;
|
|
61880
62227
|
}
|
|
@@ -61894,14 +62241,14 @@ function readHeadSha2(root) {
|
|
|
61894
62241
|
|
|
61895
62242
|
// packages/local-runtime/runtime-state-paths/src/index.ts
|
|
61896
62243
|
import { readdirSync as readdirSync16, realpathSync as realpathSync12 } from "node:fs";
|
|
61897
|
-
import { isAbsolute as isAbsolute10, join as
|
|
62244
|
+
import { isAbsolute as isAbsolute10, join as join26, resolve as resolve35 } from "node:path";
|
|
61898
62245
|
var REPOSITORIES_DIR2 = "repositories";
|
|
61899
62246
|
var WORKTREES_DIR2 = "worktrees";
|
|
61900
62247
|
function listWorkspaceStateDirs2(stateRoot) {
|
|
61901
|
-
return listDirectoryNames2(
|
|
62248
|
+
return listDirectoryNames2(join26(stateRoot, REPOSITORIES_DIR2)).flatMap((storageRepositoryId) => listDirectoryNames2(join26(stateRoot, REPOSITORIES_DIR2, storageRepositoryId, WORKTREES_DIR2)).map((storageWorkspaceId) => ({
|
|
61902
62249
|
storageRepositoryId,
|
|
61903
62250
|
storageWorkspaceId,
|
|
61904
|
-
workspaceStateDir:
|
|
62251
|
+
workspaceStateDir: join26(stateRoot, REPOSITORIES_DIR2, storageRepositoryId, WORKTREES_DIR2, storageWorkspaceId)
|
|
61905
62252
|
})));
|
|
61906
62253
|
}
|
|
61907
62254
|
function listDirectoryNames2(path) {
|
|
@@ -61917,9 +62264,9 @@ function listDirectoryNames2(path) {
|
|
|
61917
62264
|
// packages/local-runtime/codegraph-adapter/src/index.ts
|
|
61918
62265
|
init_src();
|
|
61919
62266
|
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
|
|
62267
|
+
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
62268
|
import { createRequire as createRequire6 } from "node:module";
|
|
61922
|
-
import { basename as basename7, delimiter as delimiter2, dirname as dirname15, isAbsolute as isAbsolute11, join as
|
|
62269
|
+
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
62270
|
init_src();
|
|
61924
62271
|
var REQUIRED_CODEGRAPH_PACKAGE2 = "@colbymchenry/codegraph";
|
|
61925
62272
|
var REQUIRED_CODEGRAPH_VERSION2 = productVersionManifest().runtime.codeGraph.requiredVersion;
|
|
@@ -61956,13 +62303,13 @@ function codeGraphCliInvocation2(binary, cwd, pathValue = process.env.PATH ?? ""
|
|
|
61956
62303
|
}
|
|
61957
62304
|
function resolveExecutable2(binary, cwd, pathValue) {
|
|
61958
62305
|
if (binary.includes("/") || binary.includes("\\")) {
|
|
61959
|
-
const path = isAbsolute11(binary) ? binary :
|
|
62306
|
+
const path = isAbsolute11(binary) ? binary : join27(cwd, binary);
|
|
61960
62307
|
return existsSync34(path) ? realpathSync13.native(path) : undefined;
|
|
61961
62308
|
}
|
|
61962
62309
|
for (const dir of pathValue.split(delimiter2)) {
|
|
61963
62310
|
if (!dir)
|
|
61964
62311
|
continue;
|
|
61965
|
-
const path =
|
|
62312
|
+
const path = join27(dir, binary);
|
|
61966
62313
|
if (isExecutablePath2(path))
|
|
61967
62314
|
return realpathSync13.native(path);
|
|
61968
62315
|
}
|
|
@@ -61982,7 +62329,7 @@ function isExecutablePath2(path) {
|
|
|
61982
62329
|
function resolvePackagedCodeGraphShim2() {
|
|
61983
62330
|
try {
|
|
61984
62331
|
const manifestPath = requireFromAdapter3.resolve(`${REQUIRED_CODEGRAPH_PACKAGE2}/package.json`);
|
|
61985
|
-
const manifest = JSON.parse(
|
|
62332
|
+
const manifest = JSON.parse(readFileSync33(manifestPath, "utf8"));
|
|
61986
62333
|
const relativeBin = manifest.bin?.codegraph;
|
|
61987
62334
|
if (manifest.version !== REQUIRED_CODEGRAPH_VERSION2 || !relativeBin)
|
|
61988
62335
|
return;
|
|
@@ -62022,7 +62369,7 @@ class CodeGraphIndexBuildInProgressError2 extends Error {
|
|
|
62022
62369
|
function codeGraphIndexBuildInProgress2(workspaceRoot) {
|
|
62023
62370
|
let raw;
|
|
62024
62371
|
try {
|
|
62025
|
-
raw =
|
|
62372
|
+
raw = readFileSync33(join27(workspaceRoot, ".codegraph", "codegraph.lock"), "utf8").trim();
|
|
62026
62373
|
} catch {
|
|
62027
62374
|
return false;
|
|
62028
62375
|
}
|
|
@@ -62183,7 +62530,7 @@ function inspectRepositoryCodeFacts2(root, options = {}) {
|
|
|
62183
62530
|
};
|
|
62184
62531
|
}
|
|
62185
62532
|
function codeGraphIndexAvailable2(workspaceRoot) {
|
|
62186
|
-
return existsSync34(
|
|
62533
|
+
return existsSync34(join27(workspaceRoot, ".codegraph"));
|
|
62187
62534
|
}
|
|
62188
62535
|
var NON_DECLARATION_KINDS2 = new Set(["file", "import", "export", "parameter"]);
|
|
62189
62536
|
var RUNTIME_BUILTIN_CALL_NAMES2 = new Set([
|
|
@@ -63264,6 +63611,7 @@ var CLI_COMMAND_FLAGS = {
|
|
|
63264
63611
|
repo: { value: ["--name", "--repository-id", "--root"], boolean: [] },
|
|
63265
63612
|
resolve: { value: ["--path", "--paths-from"], boolean: [] },
|
|
63266
63613
|
impact: { value: ["--base", "--head", "--depth", "--paths-from"], boolean: [] },
|
|
63614
|
+
history: { value: ["--ref", "--format", "--offset", "--limit"], boolean: [] },
|
|
63267
63615
|
review: { value: ["--head-sha", "--posture", "--task", "--task-session-id"], boolean: [] },
|
|
63268
63616
|
state: { value: ["--expected-target-fingerprint", "--expected-worktree-digest"], boolean: ["--accept-external-projection", "--dry-run", "--from-git", "--write"] },
|
|
63269
63617
|
status: { value: [], boolean: [] },
|
|
@@ -63531,6 +63879,8 @@ function runCapabilitiesCommand() {
|
|
|
63531
63879
|
async function runCliUnchecked(command = "help", args = [], cwd, deps = {}) {
|
|
63532
63880
|
if (command === "impact")
|
|
63533
63881
|
return runRefImpactCommand(args, cwd);
|
|
63882
|
+
if (command === "history")
|
|
63883
|
+
return runArchitectureHistoryCommand(args, cwd);
|
|
63534
63884
|
if (command === "export" && args[0] === "native")
|
|
63535
63885
|
return runNativeContextCommand(args.slice(1), cwd);
|
|
63536
63886
|
const preflight = preflightCliArguments(command, args);
|
|
@@ -63845,7 +64195,7 @@ async function runCliUnchecked(command = "help", args = [], cwd, deps = {}) {
|
|
|
63845
64195
|
ok: true,
|
|
63846
64196
|
requestId: "help",
|
|
63847
64197
|
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"],
|
|
64198
|
+
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
64199
|
examples: CLI_HELP_EXAMPLES
|
|
63850
64200
|
}
|
|
63851
64201
|
};
|
|
@@ -65239,7 +65589,7 @@ function auditGithubIssuesEnabled(cwd) {
|
|
|
65239
65589
|
return false;
|
|
65240
65590
|
let raw;
|
|
65241
65591
|
try {
|
|
65242
|
-
raw =
|
|
65592
|
+
raw = readFileSync34(manifestPath, "utf8");
|
|
65243
65593
|
} catch {
|
|
65244
65594
|
return false;
|
|
65245
65595
|
}
|
|
@@ -65812,7 +66162,7 @@ async function digestReviewChallenge(challenge) {
|
|
|
65812
66162
|
return reviewChallengeV2Digest(challenge);
|
|
65813
66163
|
}
|
|
65814
66164
|
function defaultGithubConnectionPath(cwd) {
|
|
65815
|
-
return
|
|
66165
|
+
return join28(dirname16(defaultDaemonConnectionPath(cwd)), "github-connection.json");
|
|
65816
66166
|
}
|
|
65817
66167
|
function sanitizeGithubConnection(record, connectionPath) {
|
|
65818
66168
|
return {
|
|
@@ -65836,7 +66186,7 @@ async function readReviewChallengeV2Arg(args, cwd, commandName = "github verify-
|
|
|
65836
66186
|
if (!inline && !challengePath)
|
|
65837
66187
|
return { ok: false, message: `${commandName} requires --challenge-json or --challenge-path` };
|
|
65838
66188
|
try {
|
|
65839
|
-
const raw = inline ??
|
|
66189
|
+
const raw = inline ?? readFileSync34(resolve37(cwd, challengePath), "utf8");
|
|
65840
66190
|
const parsed = JSON.parse(raw);
|
|
65841
66191
|
const attestation = await Promise.resolve().then(() => (init_src6(), {}));
|
|
65842
66192
|
const assertReviewChallengeV2 = assertReviewChallengeV22;
|
|
@@ -66150,7 +66500,7 @@ async function doctorReport(cwd, args = []) {
|
|
|
66150
66500
|
function doctorManifest(root) {
|
|
66151
66501
|
const path = ".archcontext/manifest.yaml";
|
|
66152
66502
|
try {
|
|
66153
|
-
return { warnings: manifestDecisionDiagnostics2([{ path, body:
|
|
66503
|
+
return { warnings: manifestDecisionDiagnostics2([{ path, body: readFileSync34(resolve37(root, path), "utf8") }]) };
|
|
66154
66504
|
} catch {
|
|
66155
66505
|
return { warnings: [] };
|
|
66156
66506
|
}
|
|
@@ -66348,8 +66698,8 @@ function runtimePathsReport(cwd) {
|
|
|
66348
66698
|
...paths,
|
|
66349
66699
|
legacyLocalStore: inspectLegacyLocalStoreMigration(cwd),
|
|
66350
66700
|
runtimeRepositoryId: repositoryFingerprint2(paths.repositoryRoot),
|
|
66351
|
-
repositoryTruthDir:
|
|
66352
|
-
codeGraphIndexDir:
|
|
66701
|
+
repositoryTruthDir: join28(paths.repositoryRoot, ".archcontext"),
|
|
66702
|
+
codeGraphIndexDir: join28(paths.repositoryRoot, ".codegraph"),
|
|
66353
66703
|
npmGlobalInstallState: "forbidden",
|
|
66354
66704
|
overrides: {
|
|
66355
66705
|
stateRootEnv: "ARCHCONTEXT_STATE_DIR",
|
|
@@ -66638,8 +66988,8 @@ async function startBackgroundDaemon(args, cwd) {
|
|
|
66638
66988
|
const recovery = discovered.recovery;
|
|
66639
66989
|
const connectionPath = defaultDaemonConnectionPath(cwd);
|
|
66640
66990
|
const controlDir = dirname16(connectionPath);
|
|
66641
|
-
const logPath =
|
|
66642
|
-
|
|
66991
|
+
const logPath = join28(controlDir, "archctxd.log");
|
|
66992
|
+
mkdirSync17(controlDir, { recursive: true });
|
|
66643
66993
|
const logFd = openSync14(logPath, "a", 384);
|
|
66644
66994
|
try {
|
|
66645
66995
|
let childExit;
|
|
@@ -66963,7 +67313,7 @@ function sleep2(ms) {
|
|
|
66963
67313
|
}
|
|
66964
67314
|
function readFileTail(path, maxBytes = 4096) {
|
|
66965
67315
|
try {
|
|
66966
|
-
const content =
|
|
67316
|
+
const content = readFileSync34(path, "utf8");
|
|
66967
67317
|
return content.slice(Math.max(0, content.length - maxBytes)).replace(/\s+/g, " ").trim();
|
|
66968
67318
|
} catch {
|
|
66969
67319
|
return "<unavailable>";
|
|
@@ -67065,7 +67415,7 @@ function cliArgumentFailure(requestId, message) {
|
|
|
67065
67415
|
};
|
|
67066
67416
|
}
|
|
67067
67417
|
function loadResolveModel(cwd) {
|
|
67068
|
-
if (!existsSync35(
|
|
67418
|
+
if (!existsSync35(join28(cwd, ".archcontext/manifest.yaml"))) {
|
|
67069
67419
|
throw new NativeContextError("native-context-model-missing", { path: ".archcontext/manifest.yaml" });
|
|
67070
67420
|
}
|
|
67071
67421
|
let model;
|
|
@@ -67121,7 +67471,7 @@ async function readResolvePathsFrom(args, cwd, deps) {
|
|
|
67121
67471
|
return { problem: "resolve --paths-from requires a file path or - for stdin" };
|
|
67122
67472
|
let content;
|
|
67123
67473
|
try {
|
|
67124
|
-
content = source === "-" ? await (deps.readStdin ? deps.readStdin() :
|
|
67474
|
+
content = source === "-" ? await (deps.readStdin ? deps.readStdin() : readFileSync34(0, "utf8")) : readFileSync34(resolve37(cwd, source), "utf8");
|
|
67125
67475
|
} catch (error) {
|
|
67126
67476
|
return { problem: `resolve --paths-from ${source} is not readable: ${error instanceof Error ? error.message : String(error)}` };
|
|
67127
67477
|
}
|
|
@@ -67209,7 +67559,7 @@ function readRepositoryInputFile(cwd, flag, file) {
|
|
|
67209
67559
|
const absolute = assertPathHasNoSymlinkSegments2(cwd, file);
|
|
67210
67560
|
if (!statSync12(absolute).isFile())
|
|
67211
67561
|
return { problem: `plan ${flag} ${file} is not a regular file` };
|
|
67212
|
-
return { content:
|
|
67562
|
+
return { content: readFileSync34(absolute, "utf8") };
|
|
67213
67563
|
} catch (error) {
|
|
67214
67564
|
return { problem: `plan ${flag} ${file} is not readable: ${error instanceof Error ? error.message : String(error)}` };
|
|
67215
67565
|
}
|
|
@@ -67230,7 +67580,7 @@ function runHashCommand(args, cwd) {
|
|
|
67230
67580
|
if (!existsSync35(absolute) || !statSync12(absolute).isFile()) {
|
|
67231
67581
|
return errorEnvelope("hash", "AC_SCHEMA_INVALID", `hash --path is not an existing file: ${path}`);
|
|
67232
67582
|
}
|
|
67233
|
-
return okEnvelope("hash", { path, hash: digestJson({ body:
|
|
67583
|
+
return okEnvelope("hash", { path, hash: digestJson({ body: readFileSync34(absolute, "utf8") }) });
|
|
67234
67584
|
}
|
|
67235
67585
|
async function readCliPlanOperations(args, cwd, deps) {
|
|
67236
67586
|
if (args.includes("--operations-file")) {
|
|
@@ -67240,7 +67590,7 @@ async function readCliPlanOperations(args, cwd, deps) {
|
|
|
67240
67590
|
const file = readFlag(args, "--operations-file");
|
|
67241
67591
|
if (!file)
|
|
67242
67592
|
return "plan --operations-file requires a path";
|
|
67243
|
-
const read = file === "-" ? { content: await (deps.readStdin ? deps.readStdin() :
|
|
67593
|
+
const read = file === "-" ? { content: await (deps.readStdin ? deps.readStdin() : readFileSync34(0, "utf8")) } : readRepositoryInputFile(cwd, "--operations-file", file);
|
|
67244
67594
|
if ("problem" in read)
|
|
67245
67595
|
return read.problem;
|
|
67246
67596
|
let parsed;
|
|
@@ -67302,7 +67652,7 @@ async function readCliPlanBody(args, cwd, deps) {
|
|
|
67302
67652
|
return { problem: "plan --body requires a value (use - to read stdin)" };
|
|
67303
67653
|
if (inline !== "-")
|
|
67304
67654
|
return inline;
|
|
67305
|
-
return deps.readStdin ? deps.readStdin() :
|
|
67655
|
+
return deps.readStdin ? deps.readStdin() : readFileSync34(0, "utf8");
|
|
67306
67656
|
}
|
|
67307
67657
|
function readFlag(args, flag) {
|
|
67308
67658
|
const index = args.indexOf(flag);
|