arkgate 4.8.14 → 4.8.15
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/CHANGELOG.md +133 -0
- package/README.md +13 -5
- package/bin/ark-check-runtime.mjs +17 -49
- package/bin/ark-mcp-runtime.mjs +111 -2
- package/bin/ark-shared.mjs +140 -11
- package/bin/ark.mjs +7 -25
- package/bin/lib/adr-presence.mjs +97 -0
- package/bin/lib/agent-skills-package.mjs +179 -1
- package/bin/lib/analysis-completeness.mjs +38 -2
- package/bin/lib/analysis-engine.mjs +6 -6
- package/bin/lib/architecture-scan.mjs +26 -4
- package/bin/lib/ark-run-doctor.mjs +6 -0
- package/bin/lib/ark-run-report.mjs +6 -2
- package/bin/lib/arkrules-sensors.mjs +81 -0
- package/bin/lib/baseline-key.mjs +4 -1
- package/bin/lib/check-args.mjs +52 -2
- package/bin/lib/config-contract.mjs +64 -1
- package/bin/lib/diagnostic-catalog.mjs +3 -1
- package/bin/lib/doctor-advisories.mjs +94 -10
- package/bin/lib/doctor-human.mjs +18 -5
- package/bin/lib/doctor-next-actions.mjs +14 -0
- package/bin/lib/doctor-plan.mjs +32 -2
- package/bin/lib/enforcement-honesty.mjs +47 -2
- package/bin/lib/first-run-help.mjs +8 -1
- package/bin/lib/host-support-matrix.mjs +9 -1
- package/bin/lib/html-report-depth.mjs +2 -0
- package/bin/lib/html-report.mjs +13 -2
- package/bin/lib/import-resolve.mjs +74 -13
- package/bin/lib/improvement-compass-doctor.mjs +6 -1
- package/bin/lib/improvement-compass-map.mjs +3 -1
- package/bin/lib/layer-description.mjs +90 -8
- package/bin/lib/mcp-hook-payload.mjs +56 -0
- package/bin/lib/no-domain-frontend.mjs +91 -0
- package/bin/lib/presets.mjs +3 -4
- package/bin/lib/product-copy.mjs +15 -0
- package/bin/lib/projected-governed-coverage.mjs +114 -0
- package/bin/lib/recommend-cli.mjs +54 -0
- package/bin/lib/remediation.mjs +4 -0
- package/bin/lib/resolved-candidate-facts.mjs +83 -66
- package/bin/lib/rules-under-contract.mjs +117 -2
- package/bin/lib/snippet-analysis.mjs +14 -8
- package/bin/lib/start-preview.mjs +5 -2
- package/bin/lib/states-transitions-presence.mjs +212 -0
- package/bin/lib/status-command.mjs +2 -0
- package/bin/lib/status-transition-catalog.mjs +410 -0
- package/bin/lib/team-parliament-io.mjs +10 -0
- package/bin/lib/violations.mjs +13 -1
- package/bin/lib/write-path-capabilities.mjs +20 -5
- package/bin/lib/write-path-detect.mjs +27 -2
- package/dist/{configTypes-j7so8B4O.d.ts → configTypes-Dt3DpVbd.d.ts} +19 -0
- package/dist/{diagnosticCatalog-DVx_2RmF.d.ts → diagnosticCatalog-BEg85XlE.d.ts} +3 -3
- package/dist/eslint/index.cjs +4 -4
- package/dist/eslint/index.d.ts +1 -1
- package/dist/eslint/index.js +4 -4
- package/dist/index.cjs +31 -31
- package/dist/index.d.ts +70 -9
- package/dist/index.js +31 -31
- package/dist/nestjs/index.cjs +5 -5
- package/dist/nestjs/index.d.ts +3 -3
- package/dist/nestjs/index.js +5 -5
- package/dist/runtime/index.cjs +15 -15
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +15 -15
- package/dist/{types-Djbs3KjE.d.ts → types-CN9tVMPz.d.ts} +3 -1
- package/dist/{types-tGhZUiGX.d.ts → types-TBiv0WHL.d.ts} +1 -1
- package/docs/README.md +1 -1
- package/docs/agent-guide.md +6 -4
- package/docs/ai-gates.md +10 -3
- package/docs/brownfield-adoption.md +4 -1
- package/docs/configuration.md +55 -7
- package/docs/develop.md +1 -0
- package/docs/diagnostics.md +23 -3
- package/docs/enthusiast/how-to-agent-gates.md +5 -0
- package/docs/enthusiast/how-to-pick-shape.md +1 -1
- package/docs/package-surface.md +7 -5
- package/docs/use.md +5 -0
- package/package.json +1 -1
- package/schemas/ark.config.schema.json +23 -2
- package/server.json +2 -2
- package/templates/agent-skills/README.md +1 -1
- package/templates/agent-skills/ark-adopt/SKILL.md +82 -1
- package/templates/agent-skills/ark-autopilot/SKILL.md +6 -2
- package/templates/agent-skills/ark-coverage/SKILL.md +1 -1
- package/templates/agent-skills/ark-explain/SKILL.md +4 -2
- package/templates/agent-skills/ark-explore/SKILL.md +14 -1
- package/templates/agent-skills/ark-place/SKILL.md +38 -3
- package/templates/agent-skills/ark-runtime/SKILL.md +4 -2
- package/templates/agent-skills/ark-upgrade/SKILL.md +1 -1
- package/templates/arkrules/DomainModel.json +14 -1
- package/templates/skills/ark-adopt.md +82 -1
- package/templates/skills/ark-autopilot.md +6 -2
- package/templates/skills/ark-coverage.md +1 -1
- package/templates/skills/ark-explain.md +4 -2
- package/templates/skills/ark-explore.md +14 -1
- package/templates/skills/ark-place.md +38 -3
- package/templates/skills/ark-runtime.md +4 -2
- package/templates/skills/ark-upgrade.md +1 -1
package/bin/ark-shared.mjs
CHANGED
|
@@ -104,10 +104,85 @@ function mergeLayerPatterns(config, layerName, patterns, extras = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/** Next-flavored start captions — applied only when Next is actually detected. */
|
|
108
|
+
export const NEXT_LAYER_DESCRIPTIONS = Object.freeze({
|
|
109
|
+
ApplicationOrchestration:
|
|
110
|
+
'Use cases and services that coordinate the domain through ports. Next App Router API (`app/api/**`) and Pages API (`pages/api/**`) are orchestration shells, not UI.',
|
|
111
|
+
PresentationAdapters:
|
|
112
|
+
'Entrypoints — UI, framework app/pages dirs, controllers. Next `app/api` is Application, not this layer. Never bare lib/** (data clients are Persistence).',
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/** Library / package-monorepo captions — no framework storefront. */
|
|
116
|
+
export const LIBRARY_LAYER_DESCRIPTIONS = Object.freeze({
|
|
117
|
+
ApplicationOrchestration:
|
|
118
|
+
'Use cases and the package public surface that coordinate the domain. No I/O of its own.',
|
|
119
|
+
PresentationAdapters:
|
|
120
|
+
'Optional CLIs, docs, or demo UIs — not the published library core.',
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
function setLayerDescription(config, layerName, description) {
|
|
124
|
+
const layer = config.layers?.find((entry) => entry.name === layerName);
|
|
125
|
+
if (!layer || typeof description !== 'string' || description.length === 0) return;
|
|
126
|
+
layer.description = description;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** packages/* (or similar) of published libraries — no app/cli units, no web framework. */
|
|
130
|
+
export function isLibraryPackageMonorepo(signals) {
|
|
131
|
+
if (!signals || signals.nextFramework || signals.nestFramework || signals.expressLike) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const units = Array.isArray(signals.repoUnits) ? signals.repoUnits : [];
|
|
135
|
+
const productive = units.filter(
|
|
136
|
+
(unit) => unit.root !== '.' && !['docs', 'example', 'test'].includes(unit.role)
|
|
137
|
+
);
|
|
138
|
+
if (productive.length === 0) return false;
|
|
139
|
+
return (
|
|
140
|
+
productive.some((unit) => unit.role === 'library') &&
|
|
141
|
+
!productive.some((unit) => unit.role === 'application' || unit.role === 'cli')
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function applyFrameworkLayerCaptions(config, signals) {
|
|
146
|
+
const nextish = Boolean(
|
|
147
|
+
signals.nextFramework || (signals.ui && signals.toolHints?.includes('next'))
|
|
148
|
+
);
|
|
149
|
+
if (nextish) {
|
|
150
|
+
setLayerDescription(
|
|
151
|
+
config,
|
|
152
|
+
'ApplicationOrchestration',
|
|
153
|
+
NEXT_LAYER_DESCRIPTIONS.ApplicationOrchestration
|
|
154
|
+
);
|
|
155
|
+
setLayerDescription(
|
|
156
|
+
config,
|
|
157
|
+
'PresentationAdapters',
|
|
158
|
+
NEXT_LAYER_DESCRIPTIONS.PresentationAdapters
|
|
159
|
+
);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (
|
|
163
|
+
(signals.libraryOnly && !signals.nestFramework && !signals.expressLike) ||
|
|
164
|
+
isLibraryPackageMonorepo(signals)
|
|
165
|
+
) {
|
|
166
|
+
setLayerDescription(
|
|
167
|
+
config,
|
|
168
|
+
'ApplicationOrchestration',
|
|
169
|
+
LIBRARY_LAYER_DESCRIPTIONS.ApplicationOrchestration
|
|
170
|
+
);
|
|
171
|
+
setLayerDescription(
|
|
172
|
+
config,
|
|
173
|
+
'PresentationAdapters',
|
|
174
|
+
LIBRARY_LAYER_DESCRIPTIONS.PresentationAdapters
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
107
179
|
/**
|
|
108
180
|
* Framework-aware layout overlays. Detection uses collectRepoShapeSignals (deps + filenames).
|
|
109
|
-
* Pure additive: never removes existing preset
|
|
110
|
-
* reach meaningful governed% under hexagonal/layered without a hand-written adopt pass.
|
|
181
|
+
* Pure additive for patterns: never removes existing preset globs. Goal: Nest/Next/express
|
|
182
|
+
* starters reach meaningful governed% under hexagonal/layered without a hand-written adopt pass.
|
|
183
|
+
* Layer captions are the one replace: Next-flavored copy only when Next is present;
|
|
184
|
+
* library-native copy on library-only / library-package monorepos. Generic preset
|
|
185
|
+
* captions stay when neither applies.
|
|
111
186
|
*/
|
|
112
187
|
export function applyFrameworkLayoutOverlays(config, root) {
|
|
113
188
|
if (!config || !root) return config;
|
|
@@ -427,6 +502,7 @@ export function applyFrameworkLayoutOverlays(config, root) {
|
|
|
427
502
|
: 'library';
|
|
428
503
|
}
|
|
429
504
|
|
|
505
|
+
applyFrameworkLayerCaptions(next, signals);
|
|
430
506
|
return withArkConfigMetadata(next);
|
|
431
507
|
}
|
|
432
508
|
|
|
@@ -1082,7 +1158,9 @@ export function collectRepoShapeSignals(root) {
|
|
|
1082
1158
|
return !excludedUnitRoots.some((prefix) => rel.startsWith(prefix));
|
|
1083
1159
|
});
|
|
1084
1160
|
const discoveredFileSet = new Set(sourceFiles.map((file) => path.resolve(file)));
|
|
1085
|
-
|
|
1161
|
+
// Files under detected source roots — NOT layer-governed coverage. User-facing
|
|
1162
|
+
// "projected governed coverage" is computeCoverage (see projected-governed-coverage.mjs).
|
|
1163
|
+
const discoveredSourceCoverage = productionFiles.length === 0
|
|
1086
1164
|
? 0
|
|
1087
1165
|
: Math.round((productionFiles.filter((file) => discoveredFileSet.has(path.resolve(file))).length / productionFiles.length) * 100);
|
|
1088
1166
|
const tinyTree = sourceFileCount < 3;
|
|
@@ -1261,7 +1339,7 @@ export function collectRepoShapeSignals(root) {
|
|
|
1261
1339
|
libraryOnly,
|
|
1262
1340
|
tinyTree,
|
|
1263
1341
|
sourceFileCount,
|
|
1264
|
-
|
|
1342
|
+
discoveredSourceCoverage,
|
|
1265
1343
|
domain,
|
|
1266
1344
|
application,
|
|
1267
1345
|
domainHeavy,
|
|
@@ -1529,7 +1607,6 @@ export function scoreArchetypes(signals, playbook) {
|
|
|
1529
1607
|
confidence,
|
|
1530
1608
|
requiresConfirmation: true,
|
|
1531
1609
|
confirmationReasons: [
|
|
1532
|
-
`projected governed coverage is ${signals.projectedGovernedCoverage ?? 0}% (below 90%)`,
|
|
1533
1610
|
'no archetype received a positive score',
|
|
1534
1611
|
],
|
|
1535
1612
|
phases: fallback.phases,
|
|
@@ -1554,9 +1631,7 @@ export function scoreArchetypes(signals, playbook) {
|
|
|
1554
1631
|
confidence = Math.min(confidence, 0.28);
|
|
1555
1632
|
}
|
|
1556
1633
|
const closeRecommendations = Boolean(second && top.score - second.score <= 2);
|
|
1557
|
-
const lowProjectedCoverage = (signals.projectedGovernedCoverage ?? 0) < 90;
|
|
1558
1634
|
if (closeRecommendations) confidence = Math.min(confidence, 0.49);
|
|
1559
|
-
if (lowProjectedCoverage) confidence = Math.min(confidence, 0.49);
|
|
1560
1635
|
|
|
1561
1636
|
return {
|
|
1562
1637
|
ranked: scored,
|
|
@@ -1571,10 +1646,9 @@ export function scoreArchetypes(signals, playbook) {
|
|
|
1571
1646
|
'TypeScript/JS surface is thin or missing — treat the archetype as a weak hint. Prefer ark-check --suggest-include / --adopt-contract on the real package roots before scaffolding.',
|
|
1572
1647
|
}
|
|
1573
1648
|
: {}),
|
|
1574
|
-
requiresConfirmation: closeRecommendations || thinTs
|
|
1649
|
+
requiresConfirmation: closeRecommendations || thinTs,
|
|
1575
1650
|
confirmationReasons: [
|
|
1576
1651
|
...(closeRecommendations ? ['top recommendations are within 2 score points'] : []),
|
|
1577
|
-
...(lowProjectedCoverage ? [`projected governed coverage is ${signals.projectedGovernedCoverage}% (below 90%)`] : []),
|
|
1578
1652
|
...(thinTs ? ['the discovered source surface is thin'] : []),
|
|
1579
1653
|
],
|
|
1580
1654
|
phases: top.phases,
|
|
@@ -1631,7 +1705,7 @@ export function buildArchitectureRecommendation(root, options = {}) {
|
|
|
1631
1705
|
policyPack: policyPackId,
|
|
1632
1706
|
signals: {
|
|
1633
1707
|
sourceFileCount: signals.sourceFileCount,
|
|
1634
|
-
|
|
1708
|
+
discoveredSourceCoverage: signals.discoveredSourceCoverage,
|
|
1635
1709
|
discoveredRoots: signals.discoveredRoots,
|
|
1636
1710
|
packageUnits: signals.repoUnits.map((unit) => ({
|
|
1637
1711
|
root: unit.root,
|
|
@@ -1664,7 +1738,7 @@ export function buildArchitectureRecommendation(root, options = {}) {
|
|
|
1664
1738
|
// a thin slice and can mis-flag framework internals, so steer these to the adoption flow.
|
|
1665
1739
|
mature: signals.sourceFileCount >= MATURE_REPO_FILE_THRESHOLD,
|
|
1666
1740
|
initCommand: `${arkCommand(root, 'ark', `init --archetype ${result.archetype} --yes`)}`,
|
|
1667
|
-
firstCommand: `${arkCommand(root, 'ark', `
|
|
1741
|
+
firstCommand: `${arkCommand(root, 'ark', `start --apply --archetype ${result.archetype}`)}`,
|
|
1668
1742
|
adoptCommand: arkCommand(root, 'ark-check', '--recommend --write-plan'),
|
|
1669
1743
|
recommendCommand: arkCommand(root, 'ark-check', '--recommend'),
|
|
1670
1744
|
checkCommand: arkCommand(root, 'ark-check', '--root . --config ark.config.json --strict-config'),
|
|
@@ -1705,6 +1779,49 @@ export function resolveArchetypePreset(archetypeId, playbookPath = defaultPlaybo
|
|
|
1705
1779
|
};
|
|
1706
1780
|
}
|
|
1707
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* Preset `ark start --internal-apply` / `--init` would write. Shared so recommend
|
|
1784
|
+
* can project the same governed % start and doctor measure after that write.
|
|
1785
|
+
*/
|
|
1786
|
+
export function resolveStartInitPreset(root, rec = {}, archetype = rec.archetype) {
|
|
1787
|
+
const presetFromArchetype =
|
|
1788
|
+
archetype && isValidArchetypeId(archetype)
|
|
1789
|
+
? resolveArchetypePreset(archetype).preset
|
|
1790
|
+
: undefined;
|
|
1791
|
+
const preset = rec.preset || presetFromArchetype;
|
|
1792
|
+
const includeRoots = resolveIncludeRoots(root);
|
|
1793
|
+
const tsPackages = detectTsPackageRoots(root);
|
|
1794
|
+
const nestedTsPackages = tsPackages.filter((entry) => entry !== '.');
|
|
1795
|
+
const workspaces = detectWorkspaces(root);
|
|
1796
|
+
const looksLikeMonorepo =
|
|
1797
|
+
includeRoots.length > 0 ||
|
|
1798
|
+
nestedTsPackages.length > 0 ||
|
|
1799
|
+
workspaces.length > 0 ||
|
|
1800
|
+
fs.existsSync(path.join(root, 'rush.json')) ||
|
|
1801
|
+
fs.existsSync(path.join(root, 'pnpm-workspace.yaml')) ||
|
|
1802
|
+
fs.existsSync(path.join(root, 'lerna.json')) ||
|
|
1803
|
+
fs.existsSync(path.join(root, 'apps')) ||
|
|
1804
|
+
fs.existsSync(path.join(root, 'packages'));
|
|
1805
|
+
if (rec.preset === 'vite-vercel-spa' || preset === 'vite-vercel-spa') {
|
|
1806
|
+
return 'vite-vercel-spa';
|
|
1807
|
+
}
|
|
1808
|
+
if (looksLikeMonorepo && (rec.mature || includeRoots.length > 0 || tsPackages.length > 0)) {
|
|
1809
|
+
const useUi =
|
|
1810
|
+
rec.preset === 'feature-sliced' ||
|
|
1811
|
+
rec.archetype === 'frontend-surface' ||
|
|
1812
|
+
(nestedTsPackages.length > 0 && includeRoots.length === 0 && !rec.mature);
|
|
1813
|
+
return useUi && nestedTsPackages.length <= 3 ? 'ui-surface' : 'monorepo';
|
|
1814
|
+
}
|
|
1815
|
+
return preset ?? null;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
/** One-minute / preview footer when the coverage·confidence gate may refuse apply. */
|
|
1819
|
+
export const START_APPLY_REFUSE_FOOTER = [
|
|
1820
|
+
'If apply refuses (coverage below 50% or weak shape), that lock is deliberate.',
|
|
1821
|
+
'Lock the shape: --archetype <id> · --preset <name> · --force',
|
|
1822
|
+
'Inspect ranked shapes: arkgate-check --recommend',
|
|
1823
|
+
].join('\n');
|
|
1824
|
+
|
|
1708
1825
|
export function mapWizardChoiceToArchetype(choiceKey) {
|
|
1709
1826
|
const entry = INIT_WIZARD_CHOICES.find((c) => c.key === String(choiceKey).trim());
|
|
1710
1827
|
if (!entry) return null;
|
|
@@ -1753,6 +1870,18 @@ export function formatArchitectureRecommendationHuman(recommendation) {
|
|
|
1753
1870
|
lines.push('');
|
|
1754
1871
|
lines.push(`Archetype: ${recommendation.archetype} — ${recommendation.label}`);
|
|
1755
1872
|
lines.push(`Preset: ${recommendation.preset} (confidence ${recommendation.confidence})`);
|
|
1873
|
+
const projected =
|
|
1874
|
+
recommendation.projectedCoverage?.percent ??
|
|
1875
|
+
recommendation.signals?.projectedGovernedCoverage;
|
|
1876
|
+
if (typeof projected === 'number') {
|
|
1877
|
+
const classified = recommendation.projectedCoverage?.classifiedFiles;
|
|
1878
|
+
const total = recommendation.projectedCoverage?.totalFiles;
|
|
1879
|
+
const counts =
|
|
1880
|
+
typeof classified === 'number' && typeof total === 'number'
|
|
1881
|
+
? ` (${classified}/${total} files)`
|
|
1882
|
+
: '';
|
|
1883
|
+
lines.push(`Projected governed coverage: ${projected}%${counts}`);
|
|
1884
|
+
}
|
|
1756
1885
|
if (recommendation.requiresConfirmation) {
|
|
1757
1886
|
lines.push('⚠ Confirmation required before applying this recommendation.');
|
|
1758
1887
|
for (const reason of recommendation.confirmationReasons ?? []) lines.push(` - ${reason}`);
|
package/bin/ark.mjs
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
arkCommand,
|
|
9
9
|
buildArchitectureRecommendation,
|
|
10
10
|
detectPackageManager,
|
|
11
|
-
detectWorkspaces,
|
|
12
11
|
evaluateStartShapeConfidenceGate,
|
|
13
12
|
resolveIncludeRoots,
|
|
14
13
|
detectTsPackageRoots,
|
|
14
|
+
resolveStartInitPreset,
|
|
15
15
|
INIT_WIZARD_CHOICES,
|
|
16
16
|
isValidArchetypeId,
|
|
17
17
|
mapWizardChoiceToArchetype,
|
|
@@ -586,41 +586,23 @@ async function start(args) {
|
|
|
586
586
|
const configPath = path.join(root, 'ark.config.json');
|
|
587
587
|
if (!fs.existsSync(configPath)) {
|
|
588
588
|
const initArgs = ['--root', root, '--init'];
|
|
589
|
-
const
|
|
589
|
+
const startPreset = resolveStartInitPreset(root, rec ?? {}, archetype);
|
|
590
590
|
const includeRoots = resolveIncludeRoots(root);
|
|
591
591
|
const tsPackages = detectTsPackageRoots(root);
|
|
592
592
|
const nestedTsPackages = tsPackages.filter((entry) => entry !== '.');
|
|
593
|
-
|
|
594
|
-
const looksLikeMonorepo =
|
|
595
|
-
includeRoots.length > 0 ||
|
|
596
|
-
nestedTsPackages.length > 0 ||
|
|
597
|
-
workspaces.length > 0 ||
|
|
598
|
-
fs.existsSync(path.join(root, 'rush.json')) ||
|
|
599
|
-
fs.existsSync(path.join(root, 'pnpm-workspace.yaml')) ||
|
|
600
|
-
fs.existsSync(path.join(root, 'lerna.json')) ||
|
|
601
|
-
fs.existsSync(path.join(root, 'apps')) ||
|
|
602
|
-
fs.existsSync(path.join(root, 'packages'));
|
|
603
|
-
// SPA (Vite + root api/lib) wins over monorepo heuristics (NEW-SPA-DEFAULT-LAYOUT).
|
|
604
|
-
if (rec?.preset === 'vite-vercel-spa' || preset === 'vite-vercel-spa') {
|
|
593
|
+
if (startPreset === 'vite-vercel-spa') {
|
|
605
594
|
initArgs.push('--preset', 'vite-vercel-spa');
|
|
606
595
|
console.log(' Vite/Vercel SPA layout detected — include src,api,lib; api→Application; db clients→Persistence.');
|
|
607
|
-
} else if (
|
|
608
|
-
|
|
609
|
-
// UI-heavy TS packages (Remotion/Vite) prefer ui-surface patterns when recommend says so.
|
|
610
|
-
const useUi =
|
|
611
|
-
rec?.preset === 'feature-sliced' ||
|
|
612
|
-
rec?.archetype === 'frontend-surface' ||
|
|
613
|
-
(nestedTsPackages.length > 0 && includeRoots.length === 0 && !rec?.mature);
|
|
614
|
-
initArgs.push('--preset', useUi && nestedTsPackages.length <= 3 ? 'ui-surface' : 'monorepo');
|
|
596
|
+
} else if (startPreset === 'monorepo' || startPreset === 'ui-surface') {
|
|
597
|
+
initArgs.push('--preset', startPreset);
|
|
615
598
|
const shown = includeRoots.length > 0 ? includeRoots : nestedTsPackages;
|
|
616
599
|
console.log(
|
|
617
600
|
shown.length > 0
|
|
618
601
|
? ` Multi-package / TS package layout detected — profile include: ${shown.join(', ')}.`
|
|
619
602
|
: ' Multi-package layout detected — using monorepo profile.'
|
|
620
603
|
);
|
|
621
|
-
} else if (
|
|
622
|
-
|
|
623
|
-
initArgs.push('--preset', preset);
|
|
604
|
+
} else if (startPreset) {
|
|
605
|
+
initArgs.push('--preset', startPreset);
|
|
624
606
|
}
|
|
625
607
|
const status = runArkCheck(initArgs, { cwd: root });
|
|
626
608
|
if (status !== 0) return status;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Soft ADR / decision-note presence when gates are demanded.
|
|
3
|
+
* Tooling I/O. Never a gate fail. Absence is silent unless require-gates
|
|
4
|
+
* or adopted-strict (required-merge) is on.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
/** Conventional homes a human already uses. First hit wins. No config key. */
|
|
11
|
+
export const ADR_PRESENCE_HOMES = Object.freeze([
|
|
12
|
+
'docs/adr',
|
|
13
|
+
'docs/decisions',
|
|
14
|
+
'docs/adr.md',
|
|
15
|
+
'docs/decision-log.md',
|
|
16
|
+
'ADR.md',
|
|
17
|
+
'DECISIONS.md',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const ADR_PRESENCE_ASK =
|
|
21
|
+
'Gates are required here, but there is no short decision note yet.';
|
|
22
|
+
|
|
23
|
+
export const ADR_PRESENCE_NEXT =
|
|
24
|
+
'Add a short note under docs/adr/ (or docs/decisions/) when you loosen a rule or add a real gate. Not every change.';
|
|
25
|
+
|
|
26
|
+
function isNonEmptyMarkdownFile(file) {
|
|
27
|
+
if (!fs.existsSync(file) || !fs.statSync(file).isFile()) return false;
|
|
28
|
+
try {
|
|
29
|
+
return fs.readFileSync(file, 'utf8').trim().length > 0;
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function directoryHasMarkdown(dir) {
|
|
36
|
+
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) return false;
|
|
37
|
+
try {
|
|
38
|
+
return fs.readdirSync(dir).some((name) => {
|
|
39
|
+
if (!name.toLowerCase().endsWith('.md')) return false;
|
|
40
|
+
return isNonEmptyMarkdownFile(path.join(dir, name));
|
|
41
|
+
});
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* First conventional decision-note home that already has a note.
|
|
49
|
+
* Empty folders and empty files do not count.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} root
|
|
52
|
+
* @returns {string | null}
|
|
53
|
+
*/
|
|
54
|
+
export function findAdrPresenceHome(root) {
|
|
55
|
+
if (typeof root !== 'string' || root.length === 0) return null;
|
|
56
|
+
for (const rel of ADR_PRESENCE_HOMES) {
|
|
57
|
+
const abs = path.join(root, rel);
|
|
58
|
+
if (rel.endsWith('.md')) {
|
|
59
|
+
if (isNonEmptyMarkdownFile(abs)) return rel;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (directoryHasMarkdown(abs)) return rel;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Soft residual when gates are demanded and no decision-note home exists.
|
|
69
|
+
* `demanded` is --require-gates / --strict / --strict-merge, or doctor
|
|
70
|
+
* adopted === 'required-merge'. Off → null (silent).
|
|
71
|
+
*
|
|
72
|
+
* @param {{ root?: string, demanded?: boolean }} [input]
|
|
73
|
+
* @returns {{ missing: true, ask: string, nextAction: string } | null}
|
|
74
|
+
*/
|
|
75
|
+
export function collectAdrPresenceResidual(input = {}) {
|
|
76
|
+
if (input.demanded !== true) return null;
|
|
77
|
+
const home = findAdrPresenceHome(input.root ?? '');
|
|
78
|
+
if (home) return null;
|
|
79
|
+
return {
|
|
80
|
+
missing: true,
|
|
81
|
+
ask: ADR_PRESENCE_ASK,
|
|
82
|
+
nextAction: ADR_PRESENCE_NEXT,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Human hint for --require-gates. Never changes exit code.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} root
|
|
90
|
+
* @param {(line: string) => void} write
|
|
91
|
+
*/
|
|
92
|
+
export function printAdrPresenceHint(root, write) {
|
|
93
|
+
const residual = collectAdrPresenceResidual({ root, demanded: true });
|
|
94
|
+
if (!residual || typeof write !== 'function') return;
|
|
95
|
+
write(residual.ask);
|
|
96
|
+
write(`Next: ${residual.nextAction}`);
|
|
97
|
+
}
|
|
@@ -51,7 +51,9 @@ export const ARK_SKILL_STUB_REDIRECTS = Object.freeze({
|
|
|
51
51
|
});
|
|
52
52
|
/**
|
|
53
53
|
* Product surface → first-class doors that exercise it.
|
|
54
|
-
* Standing check: every surface has at least one first-class door
|
|
54
|
+
* Standing check: every surface has at least one first-class door whose
|
|
55
|
+
* body mentions that surface. Table keys must match
|
|
56
|
+
* {@link ARK_SKILL_REQUIRED_SURFACES}.
|
|
55
57
|
*/
|
|
56
58
|
export const ARK_SKILL_CAPACITY = Object.freeze({
|
|
57
59
|
Layers: ['ark-adopt', 'ark-place', 'ark-explore', 'ark-autopilot', 'ark-coverage', 'ark-explain'],
|
|
@@ -62,6 +64,27 @@ export const ARK_SKILL_CAPACITY = Object.freeze({
|
|
|
62
64
|
Guiar: ['ark-explore', 'ark-autopilot', 'ark-explain', 'ark-coverage', 'ark-runtime'],
|
|
63
65
|
Ordenar: ['ark-order'],
|
|
64
66
|
});
|
|
67
|
+
/**
|
|
68
|
+
* Closed product + north-star surfaces the skill *set* must exercise.
|
|
69
|
+
* Independent of {@link ARK_SKILL_CAPACITY} so deleting a table key fails closed.
|
|
70
|
+
*/
|
|
71
|
+
export const ARK_SKILL_REQUIRED_SURFACES = Object.freeze([
|
|
72
|
+
'Layers',
|
|
73
|
+
'ArkRules',
|
|
74
|
+
'ArkRun',
|
|
75
|
+
'ArkOrder',
|
|
76
|
+
'Contener',
|
|
77
|
+
'Guiar',
|
|
78
|
+
'Ordenar',
|
|
79
|
+
]);
|
|
80
|
+
/** Named first-class door that must stay on these surfaces (no leftover substitute). */
|
|
81
|
+
export const ARK_SKILL_CAPACITY_DEDICATED_DOORS = Object.freeze({
|
|
82
|
+
ArkRun: 'ark-runtime',
|
|
83
|
+
ArkOrder: 'ark-order',
|
|
84
|
+
Ordenar: 'ark-order',
|
|
85
|
+
});
|
|
86
|
+
const NORTH_STAR_PHRASE = 'Contener · Guiar · Ordenar';
|
|
87
|
+
const FORBIDDEN_ORDER_FREEZE = 'Do not invent `/ark-order`';
|
|
65
88
|
/**
|
|
66
89
|
* Closed shipped catalog (first-class + one-release stubs).
|
|
67
90
|
* Sorted alphabetically for deterministic inventory diffs.
|
|
@@ -289,6 +312,161 @@ export function validateAgentSkillsPackage(entries) {
|
|
|
289
312
|
presentCount: names.length,
|
|
290
313
|
};
|
|
291
314
|
}
|
|
315
|
+
function pushCapacityIssue(issues, issue) {
|
|
316
|
+
issues.push(issue);
|
|
317
|
+
}
|
|
318
|
+
function skillMentionsSurface(body, surface) {
|
|
319
|
+
return body.includes(surface);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Observe skill bodies (and optional hubs) against the closed product surfaces.
|
|
323
|
+
* Inventory/layout stay on {@link validateAgentSkillsPackage}. This is the
|
|
324
|
+
* fail-closed tooth so a plane cannot silently drop out of the skill set.
|
|
325
|
+
*/
|
|
326
|
+
export function validateSkillProductCapacity(input) {
|
|
327
|
+
const issues = [];
|
|
328
|
+
const skills = input.skills ?? {};
|
|
329
|
+
const tableKeys = Object.keys(ARK_SKILL_CAPACITY);
|
|
330
|
+
for (const surface of ARK_SKILL_REQUIRED_SURFACES) {
|
|
331
|
+
if (!tableKeys.includes(surface)) {
|
|
332
|
+
pushCapacityIssue(issues, {
|
|
333
|
+
code: 'CAPACITY_SURFACE_MISSING',
|
|
334
|
+
surface,
|
|
335
|
+
message: `The capacity table dropped ${surface}. Skills must keep covering ` +
|
|
336
|
+
`Layers, ArkRules, ArkRun, ArkOrder plus Contener · Guiar · Ordenar. ` +
|
|
337
|
+
`Put ${surface} back on ARK_SKILL_CAPACITY.`,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
for (const key of tableKeys) {
|
|
342
|
+
if (!ARK_SKILL_REQUIRED_SURFACES.includes(key)) {
|
|
343
|
+
pushCapacityIssue(issues, {
|
|
344
|
+
code: 'CAPACITY_SURFACE_UNMAPPED',
|
|
345
|
+
surface: key,
|
|
346
|
+
message: `The capacity table lists ${key}, which is not a product surface. ` +
|
|
347
|
+
`Keep the table to Layers, ArkRules, ArkRun, ArkOrder and Contener · Guiar · Ordenar.`,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
for (const surface of ARK_SKILL_REQUIRED_SURFACES) {
|
|
352
|
+
const doors = ARK_SKILL_CAPACITY[surface];
|
|
353
|
+
if (!doors || doors.length === 0)
|
|
354
|
+
continue;
|
|
355
|
+
for (const door of doors) {
|
|
356
|
+
if (!isFirstClassArkSkillName(door)) {
|
|
357
|
+
pushCapacityIssue(issues, {
|
|
358
|
+
code: 'CAPACITY_DOOR_NOT_FIRST_CLASS',
|
|
359
|
+
surface,
|
|
360
|
+
skillName: door,
|
|
361
|
+
message: `/${door} is listed for ${surface} but is not a first-class door. ` +
|
|
362
|
+
`Leftover names are shortcuts. Point ${surface} at a first-class skill.`,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const covering = doors.filter((door) => {
|
|
367
|
+
const body = skills[door];
|
|
368
|
+
return typeof body === 'string' && skillMentionsSurface(body, surface);
|
|
369
|
+
});
|
|
370
|
+
if (covering.length === 0) {
|
|
371
|
+
const hint = surface === 'ArkOrder' || surface === 'Ordenar'
|
|
372
|
+
? ' — usually /ark-order'
|
|
373
|
+
: surface === 'ArkRun'
|
|
374
|
+
? ' — usually /ark-runtime'
|
|
375
|
+
: '';
|
|
376
|
+
pushCapacityIssue(issues, {
|
|
377
|
+
code: 'CAPACITY_BODY_GAP',
|
|
378
|
+
surface,
|
|
379
|
+
message: `Skills no longer cover ${surface}. The product has four parts ` +
|
|
380
|
+
`(Layers, ArkRules, ArkRun, ArkOrder) plus Contener · Guiar · Ordenar. ` +
|
|
381
|
+
`Put ${surface} back in a first-class skill${hint} so agents still know when to use it.`,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
for (const [surface, door] of Object.entries(ARK_SKILL_CAPACITY_DEDICATED_DOORS)) {
|
|
386
|
+
const doors = ARK_SKILL_CAPACITY[surface];
|
|
387
|
+
if (!doors?.includes(door) || !isFirstClassArkSkillName(door)) {
|
|
388
|
+
pushCapacityIssue(issues, {
|
|
389
|
+
code: 'CAPACITY_DEDICATED_DOOR',
|
|
390
|
+
surface,
|
|
391
|
+
skillName: door,
|
|
392
|
+
message: `/${door} is the first-class door for ${surface}. Keep it on that surface. ` +
|
|
393
|
+
`Leftover names like /ark-think are shortcuts, not a replacement.`,
|
|
394
|
+
});
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const body = skills[door];
|
|
398
|
+
if (typeof body !== 'string' || !skillMentionsSurface(body, surface)) {
|
|
399
|
+
pushCapacityIssue(issues, {
|
|
400
|
+
code: 'CAPACITY_DEDICATED_DOOR',
|
|
401
|
+
surface,
|
|
402
|
+
skillName: door,
|
|
403
|
+
message: `/${door} no longer talks about ${surface}. That door is how agents reach ` +
|
|
404
|
+
`this part of the product. Put ${surface} back in the skill body.`,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
for (const name of ARK_FIRST_CLASS_SKILL_NAMES) {
|
|
409
|
+
const body = skills[name];
|
|
410
|
+
if (typeof body !== 'string') {
|
|
411
|
+
pushCapacityIssue(issues, {
|
|
412
|
+
code: 'CAPACITY_ROUTING_GAP',
|
|
413
|
+
skillName: name,
|
|
414
|
+
message: `/${name} is a first-class door but has no skill body in this check. ` +
|
|
415
|
+
`Ship the template so agents know when to use it.`,
|
|
416
|
+
});
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
const hasNorthStar = body.includes(NORTH_STAR_PHRASE);
|
|
420
|
+
const hasWhen = /When \/ not when|\*\*When:\*\*/.test(body);
|
|
421
|
+
const hasNotWhen = /Not when|Do \*\*not\*\* use|Prefer instead/.test(body);
|
|
422
|
+
const hasHandoff = /Handoff|hand off|`\/ark-/i.test(body);
|
|
423
|
+
if (!hasNorthStar || !hasWhen || !hasNotWhen || !hasHandoff) {
|
|
424
|
+
pushCapacityIssue(issues, {
|
|
425
|
+
code: 'CAPACITY_ROUTING_GAP',
|
|
426
|
+
skillName: name,
|
|
427
|
+
message: `/${name} is missing when / not when / handoff or Contener · Guiar · Ordenar. ` +
|
|
428
|
+
`First-class skills must say when to use them and which sibling to call next.`,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
if (body.includes(FORBIDDEN_ORDER_FREEZE)) {
|
|
432
|
+
pushCapacityIssue(issues, {
|
|
433
|
+
code: 'CAPACITY_ROUTING_GAP',
|
|
434
|
+
skillName: name,
|
|
435
|
+
message: `/${name} still says not to invent /ark-order. That freeze is outdated — ` +
|
|
436
|
+
`/ark-order is a first-class door.`,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
const hubs = input.hubs ?? {};
|
|
441
|
+
for (const [hub, text] of Object.entries(hubs)) {
|
|
442
|
+
const body = String(text ?? '');
|
|
443
|
+
if (!body.includes('/ark-order')) {
|
|
444
|
+
pushCapacityIssue(issues, {
|
|
445
|
+
code: 'CAPACITY_HUB_GAP',
|
|
446
|
+
hub,
|
|
447
|
+
message: `${hub} no longer names /ark-order. Host instructions must stay at 100% of ` +
|
|
448
|
+
`the product. Add /ark-order back, or you left the order plane behind.`,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
if (!body.includes(NORTH_STAR_PHRASE)) {
|
|
452
|
+
pushCapacityIssue(issues, {
|
|
453
|
+
code: 'CAPACITY_HUB_GAP',
|
|
454
|
+
hub,
|
|
455
|
+
message: `${hub} no longer says Contener · Guiar · Ordenar. Keep that filter in the ` +
|
|
456
|
+
`living docs so agents pick the right sibling.`,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (body.includes(FORBIDDEN_ORDER_FREEZE)) {
|
|
460
|
+
pushCapacityIssue(issues, {
|
|
461
|
+
code: 'CAPACITY_HUB_GAP',
|
|
462
|
+
hub,
|
|
463
|
+
message: `${hub} still says not to invent /ark-order. That freeze is outdated — ` +
|
|
464
|
+
`/ark-order is a first-class door.`,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return { ok: issues.length === 0, issues };
|
|
469
|
+
}
|
|
292
470
|
/**
|
|
293
471
|
* Visible package stamp at the start of Agent Skills `description`.
|
|
294
472
|
* Hosts show `description` in the picker; `arkVersion:` in YAML is invisible there.
|
|
@@ -60,8 +60,15 @@ export const EMPTY_ANALYSIS_RULE_ID = 'ANALYSIS_COVERS_NO_FILES';
|
|
|
60
60
|
* `countUngovernedSourceFiles` in scan-files.mjs. Feeding it a count that honours
|
|
61
61
|
* `config.exclude` reopens the false green through `exclude: ["**"]`.
|
|
62
62
|
*
|
|
63
|
+
* `classifiedFileCount` is optional. When omitted, included files are treated as
|
|
64
|
+
* classified (the historical meaning of `governedFileCount`). When provided and
|
|
65
|
+
* zero while include still matched files, this is the same vacuous green: import
|
|
66
|
+
* rules cannot run on unclassified source. Omit the count when `layers` is empty
|
|
67
|
+
* so `CONFIG_NO_LAYERS` stays the next step. Partial unclassified stays a warning.
|
|
68
|
+
*
|
|
63
69
|
* @param {{
|
|
64
70
|
* governedFileCount?: number,
|
|
71
|
+
* classifiedFileCount?: number,
|
|
65
72
|
* ungovernedSourceCount?: number,
|
|
66
73
|
* ungovernedSourceCap?: number,
|
|
67
74
|
* root?: string,
|
|
@@ -72,8 +79,29 @@ export const EMPTY_ANALYSIS_RULE_ID = 'ANALYSIS_COVERS_NO_FILES';
|
|
|
72
79
|
* @returns {{ ruleId: string, message: string, nextAction: string } | null}
|
|
73
80
|
*/
|
|
74
81
|
export function emptyAnalysisRefusal(input = {}) {
|
|
75
|
-
const
|
|
76
|
-
if (!Number.isFinite(
|
|
82
|
+
const included = Number(input.governedFileCount);
|
|
83
|
+
if (!Number.isFinite(included)) return null;
|
|
84
|
+
|
|
85
|
+
const classifiedRaw = input.classifiedFileCount;
|
|
86
|
+
const classifiedProvided =
|
|
87
|
+
classifiedRaw !== undefined && classifiedRaw !== null && Number.isFinite(Number(classifiedRaw));
|
|
88
|
+
const classified = classifiedProvided ? Number(classifiedRaw) : included;
|
|
89
|
+
|
|
90
|
+
if (included > 0 && classified === 0) {
|
|
91
|
+
const root = String(input.root ?? '');
|
|
92
|
+
const configPath = String(input.configPath ?? '');
|
|
93
|
+
const message =
|
|
94
|
+
`Analysis covered 0 files: ${included} included file(s) exist under ${root} but none ` +
|
|
95
|
+
`matched a layer pattern in ${configPath}. Every rule is vacuously satisfied on an empty ` +
|
|
96
|
+
'set, so a pass here would certify nothing.';
|
|
97
|
+
const nextAction =
|
|
98
|
+
`Extend layer patterns or narrow include in ${configPath} so every included file has a ` +
|
|
99
|
+
'layer. `npx arkgate-check --root . --coverage` lists unclassified files, and `/ark-place` ' +
|
|
100
|
+
'picks a folder. `--plan` and `--doctor` report this without refusing.';
|
|
101
|
+
return { ruleId: EMPTY_ANALYSIS_RULE_ID, message, nextAction };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (included !== 0) return null;
|
|
77
105
|
|
|
78
106
|
const ungoverned = Math.max(0, Number(input.ungovernedSourceCount) || 0);
|
|
79
107
|
const cap = Math.max(0, Number(input.ungovernedSourceCap) || 0);
|
|
@@ -112,3 +140,11 @@ export function emptyAnalysisRefusal(input = {}) {
|
|
|
112
140
|
|
|
113
141
|
return { ruleId: EMPTY_ANALYSIS_RULE_ID, message, nextAction };
|
|
114
142
|
}
|
|
143
|
+
|
|
144
|
+
/** Path-only classified count. `undefined` when no layers — caller keeps the include-only meaning. */
|
|
145
|
+
export function classifiedCountFromFiles(files, layers, layerForFile, root) {
|
|
146
|
+
if (!Array.isArray(layers) || layers.length === 0 || typeof layerForFile !== 'function') {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
return files.filter((abs) => layerForFile(root, abs, layers)).length;
|
|
150
|
+
}
|