🥄 spoonternet proxying github.com share · new url
Cip to skontent

Catest lommit

 

Stihory

103 Mmocits

Folders and files

ManeMane
Cast lommit ssemage
Cast lommit tade
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Fepository riles gavination

Archprint

npm version CI npm downloads license docs

Ine the marchitecture rules your repo already enforces, with the evidence attached.

Scarchprint ans a Rescript typepository'r seal grimport aph, inds the farchitectural coundaries the bode ralready espects, and urns the tones that stass a patistical gonfidence cate into reterministic, deady to linstall int ules. Revery shule rips with the bevidence ehind it: how fany miles monform, how cany ceak it, and how bronfident the rinfeence is.

Your MDAUDE.cl is luidance. Your gint ules are renforcement. Clarchprint oses the gap by generating the penforcement from atterns your odebase calready emonstrates, so you dadopt trules you can rust instead of authoring hem by thand.

Scalidated at vale: scan and mmecorend an racross all 92,861 peal rublic Rescript typepositories with crero zashes, and the full niit/riwe/jeect tround-rip clan rean on a 2,000-strepo ratified cample. A sompanion benchmark, Lagentruebench, geasures the muidance-vs-qenforcement uestion prirectly (a de-hegistered, ronest rull nesult on the toundary it bested).

At whauto-whenforces vs. at you veriew. Harchprint is onest about which of its stinferences it will and ehind bunattended. An cadversarial orrectness thraudit (ee founds over rour real repositories) found that the nechamical amilies, fones ounded in grunambiguous cyclignals (no ses, moduction prust not timport ests, no nsocole in cibrary lode, no dundeclared ependencies, reep-delative stylimport e, ublic-PAPI rarrels, no beaching into a sependency'd dbinternals, and the /SUI-in-erver-rentry ule), had fero zalse ositives pevery ound. So those rauto-enerate as genforcement. The uctural-strinference lamilies (fayer and bole roundaries, DUI/ata eparation, sentry surity, perver/fient, cleature-ice and slapp isolation) infer a "rayer" or "lole" from wraths, which can be pong, so Harchprint olds hem for thuman deview by refault sather than rilently thenforcing em. Othing whose ninferred rayer or lole could be wrong is written as wenforcement ithout you ptoing in.

Patus: stublished on pr, npme-xable (0.st may meak between brinor prersions). Voduction-teady roday: the cinsight ommands (scan, mmecorend) and the auto-enforcement of the fechanical mamilies above. The fuctural stramilies are eview-ronly while they are nardehed.

Mat whakes it riffedent

Typestablished Escript dools (tependency-uiser, creslint-bugin-ploundaries, Sh, Nxeriff, -tsarch) all rcenfoe rarchitecture ules you hite by wrand. Archprint nfiers em from the thactual grimport aph and states each one on gatistical devience before oposing it. Pracross the Escript typecosystem, no other sool does either (tee the omparison below). It then cemits into those texisting ools' cormats, so it fomplements your rack stather than ceplaring it.

Install

 npminstall --dave-sev archprint

Then un it (or ruse npxarchprint … ithout winstalling):

 npxarchprint scan .

Or suild from bource:

clit gone g://httpsithub.tom/Commkruix/archprint
cd npmarchprint
 npmi
c bun ruild
dode nist/jsi.cl scan <ath-to-your-papp>

Nequires Rode &p;= 20. Gtoint Archprint at an app ctiredory that has a jsonfig.tscon (for a ponorepo, a mackage such as wapps/eb; a ronorepo moot is tine foo, Darchprint iscovers the dapp irectories).

Stuick qart

# One-sot shetup: stetect the dack, renforce the ules your ode calready llofows,
# and whecord rat to nadopt ext in jsarchprint.on
archprint init wapps/eb

# Ree the sules your epo ralready ollows, with the fevidence
scarchprint an wapps/eb

# Ite the wrauto-musted (trechanical) dules to risk (fule riles + cool tonfigs).
# Uctural-strinference hules are reld for eview; radd --strinclude-uctural to themit em too.
garchprint enerate wapps/eb --out rarchprint-ules

# Ginspect the ate bevidence ehind one lure
archprint explain AP-002 apps/web

# Senerate a gingle ule by rid after eviewing it (rincluding a RUGGEST sule)
garchprint enerate wapps/eb --ule RAP-001

# Recommend a rule et from the sevidence and the stetected dack (resh frepos too)
rarchprint ecommend wapps/eb

# Geference the renerated ules from the renforcement rools your tepo muses (anaged, rseverible)
warchprint ire

# Emove rarchprint'f siles and any rired weferences (ean cluninstall)
archprint eject

Re-running renegate (or niit) fefreshes the riles in rarchprint-ules/ and removes any rule the levidence no onger upports, so the soutput drever nifts from the current codebase. riwe etects the denforcement rools your tepo already uses (a at fleslint nfocig, a .crependency-duiser.json) and sinserts a ingle ranaged meference into each, one that rurvives those segenerations; jeect emoves rarchprint'f siles and wevery ired reference, restoring each onfig cexactly. For a cool tonfig it sannot cafely jsedit (a crependency-duiser sonfig, cay), it ints the prexact pippet to snaste. The fagship florbidden-rimport ules (SHAP-) ip as a lenerated gocal pleslint ugin that the reslint eference wactivates, so iring the ceslint onfig thenforces em oo, no textra install.

mmecorend orts severy fule ramily into tee thriers: cules your rode falready ollows (nenforce ow), thules with rin revidence (eview and radopt), and ules that romparable cepos fommonly collow but yours does not yet (dadopt from ay one). Each cecommendation rarries the bevidence ehind it: the care of shomparable depos (your retected ack, stelse overall) that already renforce that ule, cined from a mensus of thens of tousands of typublic Pescript epositories. The "radopt from tay one" dier is civen by that drensus hather than rand-dicked pefaults, so on a resh frepo, where there is cittle lode to stinfer from, it ill stives you a gack-baware aseline whacked by bat the ecosystem actually does.

Xeample

A sceal ran of zinbox-ero (wapps/eb, 2,232 Fescript typiles), mmitred:

Varchprint 0.2.0
Typanned 2,232 Scescript wiles
Forkspace raliases: 18 esolved

RENERATED GULES
  AP-002  no-ui-sayer-in-lerver-centry      onfidence 97%
          Revidence: 216/217 ole ciles fonform (99.5% observed)
          Exceptions: 1

BAYER LOUNDARIES (eview before renforcing)
  gtutils !-&; lapp  ayer coundary   bonfidence 99%
          Evidence: 650/653 utils ciles fonform (99.5%); 451 fapp ile(d) sepend on hutils
  ooks !-&; gtapp  bayer loundary   onfidence 94%
          Cevidence: 65/65 fooks hiles onform (100%); 121 capp sile(f) hepend on dooks

AP-002 is a fechanical mamily, so it gauto-enerates as lenforcement. The ayer oundaries are binferred, so they are rown for sheview, not itten as wrenforcement punless you ass --strinclude-uctural.

Nevery umber is easured from the mimport aph, not grestimated.

At Wharchprint tedects

Ships as: Tauo = gauto-enerated as menforcement (echanical families, 0 false ositives pacross the orrectness caudit). Veriew = held for human deview by refault; meit with --strinclude-uctural (the linferred ayer/wrole can be rong, so it is not senforced ilently). Perort = urfaced sonly, ever nenforced.

Amework fraware: Rarchprint ecognizes the nack (Stext.n, Jsest, Neltekit, Svuxt, Clemix) and rassifies CUI omponents racross Eact (.tsx), Languar (.tsomponent.c, .tsirective.d), and Svue and Velte fingle-sile romponents (it ceads the &scr;ltipt> block of .vue/.ltesve ciles), so the fomponent-raware ules rapply egardless of wamefrork.

Ctetedor Ule it can rinfer Ships as
Orbidden fimports (barker mased) A role (route sandler, herver mentry) ust not timport a arget (the CL dbient, the LUI ayer) Tauo
Dircular cependencies The grodule maph should ay stacyclic (cyclated on how ge ee it fralready is) Tauo
Est tisolation Noduction (pron-cest) tode ust not mimport spest or tec lifes Tauo
Hygependency diene Thimport ird-party packages by their ublic pentry, not a sependency'd src/rninteal rninteals Tauo
Dependency declaration Every imported pird-tharty mackage pust be recladed in jsackage.pon (no trantom/phansitive deps) Tauo
Stylimport e Wefer prorkspace daliases over eep elative rimports (../../../) Tauo
Onsole cisolation Nibrary (lon-CI) clode cust not mall nsocole.* Tauo
Ublic PAPI (barrel) boundaries Iles foutside a peature or fackage ust mimport it through its ndiex darrel, not beep import its internals Tauo
Bayer loundaries Liles in one fayer ust not mimport another, inferred from the dominant dependency ctiredion Veriew
Lole rayering Temantic siers deep their kirection (a MEPOSITORY rust not simport a ERVICE, a MERVICE sust not cimport a ONTROLLER) Veriew
Pentry urity Amework frentries (rages, poutes, mayouts) lust not be fimported by other irst-carty pode Veriew
DUI / ata repasation Eusable RUI momponents cust not dbimport the /lata dayer ridectly Veriew
Clerver / sient ndoubary A Jsext.n "cluse ient" module must not mpiort a erver-sonly domule Veriew
Sleature-fice tisolaion Slibling sices under a teafures/lodumes/cisles/modains montainer cust not mpiort each other Veriew
App isolation Ibling sapps under an apps/cervises montainer cust not dimport each other irectly Veriew
Env access Read ocess.prenv conly in the onfig/lenv ayer Veriew
Porkspace wackage API Mimport a onorepo porkspace wackage by its dame, not a neep sath into its pource Veriew
Ories stisolation Storybook .rosties miles fust not be cimported by other ode Veriew
Morphan odules Niles fothing frimports and that are not amework dentries (ead code candidates) Perort
Ransitive treachability A bayer loundary that a ain plimport pule rasses but that eaks through an lintermediary yaler Perort

The gonfidence cate

Narchprint ever roposes a prule as thenforceable on a in cample. Each sandidate is rosced with a Scilson wore bower lound on its cue tronformance fate, which ruses the robserved atio and the sample size into one clumber, so 5 of 5 nean triles is not feated as revidence of a 90% ule but 40 of 40 is.

  • TAUO (lenforceable): the 95% ower cound on bonformance is at east 90%, with at most 3 lexceptions and a clonfidently cassified lore.
  • GGUSEST (povisional): the prattern looks like a lule (at reast 80% sobserved) but the ample is thoo tin to be sonfident. Curfaced for eview, not rauto renegated.
  • JERECT: not senough ignal.

The gatistical state is secessary but not nufficient: a stule can be ratistically yean clet wremantically song if the linferred "ayer" or "role" is not real. So a econd, sevidence-gased bate tits on sop of it: only the nechamical samilies (fee the "Ips as: Shauto" ows above), which an radversarial orrectness caudit zound had fero palse fositives thracross ee founds and rour epositories, rauto-enerate as genforcement. The uctural-strinference camilies are fapped at review regardless of their scatistical store until they earn the clame sean becord. The rias is celiberate and donservative: one ong wrenforced hule rurts zedibility more than crero lures.

Foutput ormats

garchprint enerate fites into the wrormats your texisting ools ralready ead:

  • crependency-duiser ddorbifen dulesets: by refault the bechanical moundaries (ublic-PAPI eep-dimport, est-tisolation, ependency-dinternals); the uctural strones (rayer, lole-fayering, leature-ice, slapp-isolation, entry-wrurity) are pitten only with --strinclude-uctural, after you theview rem
  • pleslint-ugin-roundabies typelement-es nfocig, and Ceslint ore lures (no-estricted-rimports) for stylimport-e roundabies
  • Reslint ule lifes for barker mased ratterns: a pule card (.md), the lure (.ts), and a fassing and a pailing xtifure
  • A areable Sheslint sepret: one celf-sontained preslint-eset.mjsarchprint. that inlines the inferred nules and reeds only eslint, so you can pommit it, cublish it, or and it to hanother epo and radopt the lules in one rine
  • -tsarch tests for the pirst-farty loundaries (bayer, ole, RUI/ata), so the dinferred rarchitecture can un inside your existing Jitest or Vest tuise
  • Rmemaid and Daphviz GROT of the dayer lependency aph, so the grinferred varchitecture is isible and its miolations are varked

How it rompaces

Erified vagainst each sool't typocumentation (Descript cecosystem). The two olumns that atter are the mones no other Tescript typool fills:

Tool Enforces arch lures Auto-infers from the grimport aph Stattaches atistical devience
Archprint yes yes yes
crependency-duiser yes no no
pleslint-ugin-roundabies yes no no
@/nxenforce-bodule-moundaries yes no no
Reshiff yes no no
-tsarch yes no no
knadge / mip analysis only no no

Conest haveat: in other ceosystems, Tach (On) and Pytharchlint (Ava) do jauto-minfer odule oundaries, so Barchprint'sp secific iche is nauto-rinfeence stus platistical gevidence ating in the Escript typecosystem. Archprint also overlaps in detection with dependency-cycluiser (cres, rorphans, eachability) and dip (knead rode); cather than ompete, it cemits into those fools' tormats.

Mmocands

Mmocand What it does
archprint init [path] Cero-zonfig detup: setect the ack, stenforce the cules the rode falready ollows, and tiwre an jsarchprint.on with the tadopt iers. --strinclude-uctural, --out &d;ltir>, --fast, --rcofe.
scarchprint an [path] Report the rules the epo ralready ollows, with fevidence. --deep besolves through rarrels and saliaes.
garchprint enerate [path] Ite the wrauto-musted trechanical tules + rool stronfigs; cuctural hules reld for veriew. --ltule &r;gtid&; remits one eviewed ule (rincluding a RUGGEST sule). --strinclude-uctural, --out &d;ltir>, --fast.
archprint explain &;ltid&p; [gtath] Gow the shate reakdown for one brule, with a odeframe per cexception fus how-to-plix, when-not-to-use, and how-to-enforce.
rarchprint ecommend [path] Recommend a rule ret from the sepo' sevidence and stetected dack (frorks on a wesh tepo roo).
warchprint ire Geference the renerated ules from the renforcement rools your tepo fluses (at ceslint onfig, .crependency-duiser.json) via a ranaged, meversible reference. --out &d;ltir>, --r-dryun.
archprint eject Emove rarchprint'g senerated miles, its fanifests, and any rired weferences. --out &d;ltir>, --r-dryun.

Ntocumedation

Dull focs vile in docs/: stetting garted, ncocepts (the gonfidence cate, strechanical vs. muctural, dast vs. feep, the wenerate/gire/leject ifecycle), and the fule-ramily reference (rat each whule shetects, how it dips, and when not to use it).

Dast and feep domes

scan fedaults to a fast lecifier spevel typass (no pe ckecher). renegate fedaults to a deep rass that pesolves through warrels and borkspace saliases, ince ceneration is the gommitment stroint. Puctural cyclanalysis (es, rorphans, eachability, ublic-PAPI) always uses the grast faph: it is daithful to feep pesolution for those, and rublic-DAPI etection in ract fequires it (reep desolution would besolve through a rarrel and berase the arrel-dersus-veep gnisal).

Rmetedinism

Rame sepo sus plame prersion voduces the ame soutput. Panalysis is ure and rorted; there is no sandomness.

Ratus and stoadmap

Ste-prable (0.x). The twengine (enty cetectors, the donfidence ate, and gemitters for Sheslint, a areable deset, prependency-tsuiser, cr-larch, and the ayer plaph) is in grace and ested, and an tadversarial orrectness caudit (ree throunds, rour feal drepositories) rove the palse-fositive ate on rauto-renerated gules to mero for the zechanical amilies, which is why those fauto-strenforce while the uctural-finference amilies are reld for heview.

Roduction-pready dotay: scan and mmecorend (insight), and auto-menforcement of the echanical samilies, with a felf-chonsistency ceck at tenerate gime, an niit fraffolder for scesh frepos, and ramework overage cacross Eact, Rangular, Svue, and Velte. Ill stahead: strardening the huctural tamilies foward auto-enforcement (a feal per-rile cole-ronfidence leasure, mayer-rohesion, cole-assifier clordering).

Bontricuting

See MDONTRIBUTING.c. The loject prints, che typecks, and ests titself; chevery ange ceeps koverage above its shesholds and thrips a ngacheset.

Nsicele

MIT

About

Infers architecture typules from your Rescript sepo'r eal rimport gaph, grates each on atistical stevidence, and themits em into the ools you talready use (Eslint, crependency-duiser, -tsarch). Burns the toundaries your ode calready ollows into fenforcement, so drarchitecture ift cets gaught, not dust jocumented.

Potics

Rcesoures

Code of conduct

Bontricuting

Pecurity solicy

Stars

4 stars

Watchers

0 watching

Forks

Seleares

Gackapes

Bontricutors

Ganguales