#!/usr/bin/env node// Architecture gate: module graph, layer boundaries, cycles, complexity budgets.// Config: architecture.json | .agent-arch.json | ~/.agent-harness/architecture.jsonimportfsfrom'node:fs';importpathfrom'node:path';import{ parseArgs, list, readJson, readJsonc, writeJsonAtomic, wildcardToRegExp, stateDir, appendEvent, fail, homeDir }from'./lib.mjs';constSOURCE_EXT=['.ts','.tsx','.mts','.cts','.js','.jsx','.mjs','.cjs'];constDEFAULT_EXCLUDE=
ppath
out
fsdir out
stack dir
stack
current stack
entry fscurrent
skipentry
full pathcurrent entry
entry stackfull
entry outfull
out
explicit explicit
fsexplicit
pathexplicit explicit
candidates
pathcwd
pathcwd
pathcwd
path
found candidates fsp
found found found
out src
i
n src
state
i n
ch srci
next srci
state
ch next
i n srci outi i
ch next
outi outi i
i n srci srci srci outi i
i n outi outi i
ch ch ch state ch outi i
i
ch outi i n outi i
ch state outi state i
ch outi
i
out
clean src
specs
pattern
pattern
match
match patternsrc
cleanmatch
specsmatch
specs
spec spec
spec
norm pattern
re norm
reDeep
rerel reDeeprel rel norm
extCandidates
base
spec
base pathpathpathcwd fromRel spec
alias aliases
prefix alias
prefix specprefix
base pathcwd alias specprefix
base spec
ext extCandidates
candidate
fscandidate fscandidate
pathcwd candidate
looksLikeAsset spec
looksLikeAsset spec
spec pathcwd base
counter
index
low
onStack
stack
sccs
indexv counter
lowv counter
counter
stackv
onStackv
w graphv
indexw
w
lowv lowv loww
onStackw
lowv lowv indexw
lowv indexv
scc
w
w stack
onStackw
sccw
w v
selfLoop scc graphscc scc
scc selfLoop sccsscc
node graph indexnode node
sccs
starts
i i src i srci startsi
starts
lo
hi starts
lo hi
mid lo hi
startsmid offset lo mid
hi mid
lo
depth
count
hasContent
ch params
ch depth
ch depth
ch depth count
ch hasContent
hasContent count
clean src
starts src
issues
seen
pattern
pattern
match
match patternclean
name match
open clean match match
open
depth
end
maxDepth
i open i clean i
cleani depth maxDepth maxDepth depth
cleani depth depth end i
end
startLine starts match
endLine starts end
key
seenkey
seenkey
length endLine startLine
paramsRaw match match match
paramCount match paramsRaw
where
budgets length budgets
issues rel startLine
budgets paramCount budgets
issues rel startLine
budgets maxDepth budgets
issues rel startLine
issues
extensions config
excludeMatchers config compileMatcher
skipDirs
files cwd skipDirs
pathcwd f
extensionspathrel excludeMatchers rel
layers config layer layer
best
layer layers
layerrel best layer best best layer
best
forbidden config
rule
rule
rule
forbiddenPackages config
resolver cwd config
graph
externalDeps
issues
budgets config
stats files
hitForbidden forbidden rrel rtargetRel
hitForbidden
rel
fromLayer rel
toLayer targetRel
fromLayer toLayer fromLayer toLayer
allowed fromLayer
allowedtoLayer
rel
rel files
src fspathcwd rel
budgets
lines src
lines budgets
issues rel
issuesrel src budgets i
targets
spec src
rule forbiddenPackages
rule rulespec rule rulespec
issues rel
resolved rel spec
resolved
targetsresolved
stats
issuesrel resolved
resolved
normalized resolved
bucket externalDepsnormalized
bucketrel
externalDepsnormalized bucket
resolved
issues rel
issuesrel resolved
graphrel targets
stats externalDeps
config
scc graph
configmaxLength scc config
issues scc
files graph issues externalDeps stats layers l l l
failOn config
errors result i failOni
warnings result errorsi
byRule
issue errors byRuleissue byRuleissue
errors warnings byRule
issues
issue issues
layer result
count result layerf
result
name users result b a
positional flags process
command positional
cwd pathflags flags flags process
loaded cwd flags
command
target pathcwd flags flags flags
fstarget flags
srcDir fspathcwd d
template
fspathcwd template
target template
loaded
result cwd loaded
errors warnings byRule result loaded
result
result cwd
command
result cwd
warnings
errors
errors
runId
artifactDir pathcwd
summary
runId
cwd
loaded
errors
result
byRule
errors
warnings
pathartifactDir summary
pathartifactDir summary
cwd runId summary errors
flags
summary
result cwd
errors
warnings
errors
process