arkgate 2.5.0 → 2.6.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/CHANGELOG.md +26 -0
- package/bin/ark-check.mjs +194 -3867
- package/bin/ark-layer-match.mjs +168 -0
- package/bin/ark-shared.mjs +8 -131
- package/bin/lib/agent-gates.mjs +1550 -0
- package/bin/lib/doctor-plan.mjs +503 -0
- package/bin/lib/html-report.mjs +1301 -0
- package/bin/lib/presets.mjs +244 -0
- package/bin/lib/suggestions.mjs +109 -0
- package/bin/lib/violations.mjs +170 -0
- package/dist/eslint/index.cjs +32 -27
- package/dist/eslint/index.cjs.map +1 -1
- package/dist/eslint/index.d.cts +22 -6
- package/dist/eslint/index.d.ts +22 -6
- package/dist/eslint/index.js +32 -27
- package/dist/eslint/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.cjs +1 -1
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.js +1 -1
- package/dist/nestjs/index.js.map +1 -1
- package/package.json +2 -1
- package/server.json +2 -2
|
@@ -0,0 +1,1550 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent gate install, migrate, Codex, skills, adoption (roadmap #11).
|
|
3
|
+
*/
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
import crypto from 'node:crypto';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import {
|
|
12
|
+
arkCommand,
|
|
13
|
+
detectPackageManager,
|
|
14
|
+
execCommandParts,
|
|
15
|
+
execRunner,
|
|
16
|
+
presentLockfiles,
|
|
17
|
+
usableTypescript,
|
|
18
|
+
typescriptUsabilityHint,
|
|
19
|
+
DEFAULT_INTENT_PREFIXES,
|
|
20
|
+
DEFAULT_LAYER_DIRECTORIES,
|
|
21
|
+
DEFAULT_DOMAIN_FORBIDDEN_GLOBALS,
|
|
22
|
+
DEFAULT_RULES,
|
|
23
|
+
createElevenLayerConfig,
|
|
24
|
+
applyFrameworkLayoutOverlays
|
|
25
|
+
} from '../ark-shared.mjs';
|
|
26
|
+
|
|
27
|
+
/** Package root (parent of bin/). All modules live under bin/lib/. */
|
|
28
|
+
const __packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
29
|
+
const __arkCheckCli = path.join(__packageRoot, 'bin', 'ark-check.mjs');
|
|
30
|
+
|
|
31
|
+
export function readJson(file) {
|
|
32
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function readPackageJson(root) {
|
|
36
|
+
const file = path.join(root, 'package.json');
|
|
37
|
+
if (!fs.existsSync(file)) return null;
|
|
38
|
+
return readJson(file);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function hasCheckArchitectureScript(root) {
|
|
42
|
+
const pkg = readPackageJson(root);
|
|
43
|
+
return Boolean(pkg?.scripts?.['check:architecture']);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const REQUIRED_GATE_FILES = [
|
|
47
|
+
'AGENTS.md',
|
|
48
|
+
'.mcp.json',
|
|
49
|
+
];
|
|
50
|
+
const REQUIRED_GATE_WORKFLOW = '.github/workflows/*.yml running ark-check';
|
|
51
|
+
|
|
52
|
+
export function hasArkWorkflow(root) {
|
|
53
|
+
const workflowsDir = path.join(root, '.github', 'workflows');
|
|
54
|
+
if (!fs.existsSync(workflowsDir)) return false;
|
|
55
|
+
return fs
|
|
56
|
+
.readdirSync(workflowsDir)
|
|
57
|
+
.filter((file) => /\.ya?ml$/i.test(file))
|
|
58
|
+
.some((file) => {
|
|
59
|
+
try {
|
|
60
|
+
const content = fs.readFileSync(path.join(workflowsDir, file), 'utf8');
|
|
61
|
+
return /\bark-check\b/.test(content) || /\bcheck:architecture\b/.test(content);
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function missingGates(root) {
|
|
69
|
+
const missing = REQUIRED_GATE_FILES.filter(
|
|
70
|
+
(relativePath) => !fs.existsSync(path.join(root, relativePath))
|
|
71
|
+
);
|
|
72
|
+
if (!hasArkWorkflow(root)) missing.push(REQUIRED_GATE_WORKFLOW);
|
|
73
|
+
return missing;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function checkArchitectureScriptSnippet(root) {
|
|
77
|
+
// The package manager's runner resolves the installed binary; `node bin/ark-check.mjs`
|
|
78
|
+
// only works inside Ark's own repo. Package-manager aware so a pnpm/yarn repo isn't
|
|
79
|
+
// handed an `npx` alias that violates its "never npx" policy.
|
|
80
|
+
return `"check:architecture": "${arkCheckCommand(root)}"`;
|
|
81
|
+
}
|
|
82
|
+
export function ensureDirForFile(file) {
|
|
83
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function writeTemplate(root, relativePath, content, force) {
|
|
87
|
+
const fullPath = path.join(root, relativePath);
|
|
88
|
+
if (fs.existsSync(fullPath) && !force) {
|
|
89
|
+
return { relativePath, status: 'skipped' };
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
ensureDirForFile(fullPath);
|
|
93
|
+
fs.writeFileSync(fullPath, content);
|
|
94
|
+
return { relativePath, status: 'written' };
|
|
95
|
+
} catch {
|
|
96
|
+
return { relativePath, status: 'failed' };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Load a TypeScript module with a working JS API host (`sys` + AST + resolve).
|
|
102
|
+
* Prefer the project's install when API-compatible (TS 5/6 + any TS 7 that still
|
|
103
|
+
* exposes the classic JS host). TypeScript 7.0.x main entry is version-only
|
|
104
|
+
* (`{ version, versionMajorMinor }`); programmatic APIs live under
|
|
105
|
+
* `typescript/unstable/*` and are not yet the gate's host — we fall through to
|
|
106
|
+
* ArkGate's own `typescript` dependency (JS-API 5.x) or a bare import.
|
|
107
|
+
* Returns `{ ts, source, version, fallbackReason? }` or null.
|
|
108
|
+
*/
|
|
109
|
+
export async function loadTypeScript(root) {
|
|
110
|
+
const { createRequire } = await import('node:module');
|
|
111
|
+
const loaders = [];
|
|
112
|
+
try {
|
|
113
|
+
const req = createRequire(path.join(root, 'package.json'));
|
|
114
|
+
loaders.push({
|
|
115
|
+
label: 'project',
|
|
116
|
+
load: () => req('typescript'),
|
|
117
|
+
resolvePath: () => {
|
|
118
|
+
try {
|
|
119
|
+
return req.resolve('typescript');
|
|
120
|
+
} catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
} catch {
|
|
126
|
+
/* project has no package.json resolvable tree */
|
|
127
|
+
}
|
|
128
|
+
// Nested under arkgate (production dependency) — must work when project has only TS7.
|
|
129
|
+
try {
|
|
130
|
+
const req = createRequire(__arkCheckCli);
|
|
131
|
+
loaders.push({
|
|
132
|
+
label: 'arkgate',
|
|
133
|
+
load: () => req('typescript'),
|
|
134
|
+
resolvePath: () => {
|
|
135
|
+
try {
|
|
136
|
+
return req.resolve('typescript');
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
} catch {
|
|
143
|
+
/* ark install tree unavailable */
|
|
144
|
+
}
|
|
145
|
+
loaders.push({
|
|
146
|
+
label: 'import',
|
|
147
|
+
load: async () => {
|
|
148
|
+
const m = await import('typescript');
|
|
149
|
+
return m;
|
|
150
|
+
},
|
|
151
|
+
resolvePath: () => null,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
let projectRejected = null;
|
|
155
|
+
const triedPaths = new Set();
|
|
156
|
+
for (const { label, load, resolvePath } of loaders) {
|
|
157
|
+
try {
|
|
158
|
+
const resolved = typeof resolvePath === 'function' ? resolvePath() : null;
|
|
159
|
+
if (resolved && triedPaths.has(resolved)) {
|
|
160
|
+
// Same physical package already rejected (e.g. project === hoisted arkgate path).
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (resolved) triedPaths.add(resolved);
|
|
164
|
+
|
|
165
|
+
const mod = await load();
|
|
166
|
+
const ts = usableTypescript(mod);
|
|
167
|
+
if (ts) {
|
|
168
|
+
const version =
|
|
169
|
+
typeof ts.version === 'string'
|
|
170
|
+
? ts.version
|
|
171
|
+
: typeof mod?.version === 'string'
|
|
172
|
+
? mod.version
|
|
173
|
+
: undefined;
|
|
174
|
+
return {
|
|
175
|
+
ts,
|
|
176
|
+
source: label,
|
|
177
|
+
version,
|
|
178
|
+
...(projectRejected ? { fallbackReason: projectRejected } : {}),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (label === 'project' && mod) {
|
|
182
|
+
projectRejected = `project typescript is not API-compatible (${typescriptUsabilityHint(mod)}); using ArkGate's JS-API TypeScript fallback (TypeScript 7.0 main export is version-only). See docs/typescript-support.md.`;
|
|
183
|
+
}
|
|
184
|
+
} catch {
|
|
185
|
+
/* try next loader */
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Args for every emitted `ark-check` (AGENTS.md, package.json, Cursor rule, CI).
|
|
193
|
+
* If `.ark-baseline.json` exists, include `--baseline` so agent/local/CI paths
|
|
194
|
+
* match the ratchet — otherwise agents re-fail on frozen debt (field-test bug).
|
|
195
|
+
*/
|
|
196
|
+
export function checkArgsForRoot(root, { requireGates = false } = {}) {
|
|
197
|
+
const baselineFlag = fs.existsSync(path.join(root, '.ark-baseline.json'))
|
|
198
|
+
? ' --baseline .ark-baseline.json'
|
|
199
|
+
: '';
|
|
200
|
+
const gatesFlag = requireGates ? ' --require-gates' : '';
|
|
201
|
+
return `--root . --config ark.config.json --strict-config${baselineFlag}${gatesFlag}`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function packageManager(root) {
|
|
205
|
+
// CI always require-gates; baseline follows checkArgsForRoot.
|
|
206
|
+
const checkArgs = checkArgsForRoot(root, { requireGates: true });
|
|
207
|
+
// Same detection as every emitted command (execRunner): honors the packageManager field and
|
|
208
|
+
// won't let a stray pnpm-lock.yaml hijack an npm project (package-lock.json wins the tie).
|
|
209
|
+
const pm = detectPackageManager(root);
|
|
210
|
+
if (pm === 'pnpm') {
|
|
211
|
+
return {
|
|
212
|
+
cache: 'pnpm',
|
|
213
|
+
setup: ['corepack enable'],
|
|
214
|
+
install: 'pnpm install --frozen-lockfile',
|
|
215
|
+
// Same runner as execRunner(): skip pnpm's verify-deps gate (ERR_PNPM_IGNORED_BUILDS).
|
|
216
|
+
run: `pnpm --config.verify-deps-before-run=false exec ark-check ${checkArgs}`,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
if (pm === 'yarn') {
|
|
220
|
+
return {
|
|
221
|
+
cache: 'yarn',
|
|
222
|
+
setup: ['corepack enable'],
|
|
223
|
+
install: 'yarn install --frozen-lockfile',
|
|
224
|
+
run: `yarn ark-check ${checkArgs}`,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
cache: 'npm',
|
|
229
|
+
setup: [],
|
|
230
|
+
install: fs.existsSync(path.join(root, 'package-lock.json')) ? 'npm ci' : 'npm install',
|
|
231
|
+
run: `npx ark-check ${checkArgs}`,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// The runner prefix (npx / pnpm exec / yarn) is added per project by arkCheckCommand
|
|
236
|
+
// so a pnpm-only repo never gets an `npx` instruction — see execRunner() in ark-shared.mjs.
|
|
237
|
+
export function arkCheckCommand(root) {
|
|
238
|
+
return arkCommand(root, 'ark-check', checkArgsForRoot(root));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Canonical agent contract. AGENTS.md and the Cursor rule both derive from this single
|
|
242
|
+
// source so the steps can never drift out of sync between the two files. `steps(checkCommand)`
|
|
243
|
+
// is a builder because the check command's runner prefix varies with the package manager.
|
|
244
|
+
const AGENT_CONTRACT = {
|
|
245
|
+
manifestResource: 'ark://manifest',
|
|
246
|
+
steps: (checkCommand) => [
|
|
247
|
+
`Read the Ark contract from \`ark://manifest\` when the MCP server is available.`,
|
|
248
|
+
`Keep source files inside the layer boundaries declared in \`ark.config.json\`.`,
|
|
249
|
+
`Do not bypass Ark publishers, event contracts, or source metadata for runtime mutations.`,
|
|
250
|
+
`After edits, run \`${checkCommand}\`.`,
|
|
251
|
+
`If Ark reports violations, fix the architecture instead of weakening the gate.`,
|
|
252
|
+
],
|
|
253
|
+
// Cursor-only guidance: the write-time validate_code tool is available in
|
|
254
|
+
// Cursor's runtime but has no equivalent in a plain AGENTS.md read.
|
|
255
|
+
cursorValidateStep: `Validate the full post-edit file content with the \`validate_code\` tool before writing whenever your runtime supports it.`,
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export function layerPlacementTable() {
|
|
259
|
+
const rows = DEFAULT_INTENT_PREFIXES.map((entry) => {
|
|
260
|
+
const dirs = (DEFAULT_LAYER_DIRECTORIES[entry.layer] ?? [])
|
|
261
|
+
.map((directory) => `\`${directory}/\``)
|
|
262
|
+
.join(', ');
|
|
263
|
+
return `| ${entry.layer} | ${dirs} | ${entry.prefixes.map((p) => `\`${p}\``).join(', ')} |`;
|
|
264
|
+
}).join('\n');
|
|
265
|
+
return `| Layer | Conventional directories (under the source root) | Intent prefixes |
|
|
266
|
+
|-------|---------------------------------------------------|-----------------|
|
|
267
|
+
${rows}`;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function agentInstructions(root) {
|
|
271
|
+
const steps = AGENT_CONTRACT.steps(arkCheckCommand(root))
|
|
272
|
+
.map((step, index) => `${index + 1}. ${step}`)
|
|
273
|
+
.join('\n');
|
|
274
|
+
return `# Ark Enforcement
|
|
275
|
+
|
|
276
|
+
Before editing TypeScript or JavaScript source files:
|
|
277
|
+
|
|
278
|
+
${steps}
|
|
279
|
+
|
|
280
|
+
## Where new code belongs
|
|
281
|
+
|
|
282
|
+
\`ark.config.json\` is authoritative for this project. When creating a NEW kind of code
|
|
283
|
+
that no existing layer covers (a saga, a background job, a read model, ...), use the
|
|
284
|
+
default 11-layer placement below and add the layer to \`ark.config.json\` — do not invent
|
|
285
|
+
an ungoverned location:
|
|
286
|
+
|
|
287
|
+
${layerPlacementTable()}
|
|
288
|
+
|
|
289
|
+
The project is only considered Ark-enforced when the write gate, CI gate, and runtime path all pass.
|
|
290
|
+
`;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function mcpJson(root) {
|
|
294
|
+
return `${JSON.stringify({
|
|
295
|
+
mcpServers: {
|
|
296
|
+
ark: {
|
|
297
|
+
type: 'stdio',
|
|
298
|
+
// Prefer arkgate-mcp; ark-mcp alias still works for one major.
|
|
299
|
+
...execCommandParts(root, PREFERRED_MCP_BIN, ['--root', '.', '--config', 'ark.config.json']),
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
}, null, 2)}\n`;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Sample for docs/ — `ark-check --install-agent-gates --tools codex` auto-merges the real
|
|
306
|
+
// block (with absolute paths) into ~/.codex/config.toml. This copy is a reference only, so
|
|
307
|
+
// it flags the two gotchas of hand-editing the global config: absolute paths (config.toml is
|
|
308
|
+
// loaded without the project as cwd) and the required restart.
|
|
309
|
+
export function codexTomlSnippet(root) {
|
|
310
|
+
const { command, args } = execCommandParts(root, PREFERRED_MCP_BIN, [
|
|
311
|
+
'--root',
|
|
312
|
+
'/absolute/path/to/project',
|
|
313
|
+
'--config',
|
|
314
|
+
'/absolute/path/to/project/ark.config.json',
|
|
315
|
+
]);
|
|
316
|
+
const argsToml = args.map((value) => `"${value}"`).join(', ');
|
|
317
|
+
return `# Add to ~/.codex/config.toml (or $CODEX_HOME/config.toml), then RESTART Codex —
|
|
318
|
+
# it does not hot-load MCP servers. Use ABSOLUTE paths: config.toml is global, so
|
|
319
|
+
# "." would resolve against Codex's launch dir, not this project. Prefer:
|
|
320
|
+
# ark-check --install-agent-gates --tools codex (auto-merges the absolute paths)
|
|
321
|
+
[mcp_servers.ark]
|
|
322
|
+
command = "${command}"
|
|
323
|
+
args = [${argsToml}]
|
|
324
|
+
`;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Compact always-on rule for instruction-tier hosts (Windsurf, Cline, GitHub Copilot,
|
|
329
|
+
* Kiro, ...): agents that read a project rule file but have no MCP tools or hooks.
|
|
330
|
+
* Derived from the same AGENT_CONTRACT as AGENTS.md and the Cursor rule so the steps
|
|
331
|
+
* can never drift; points at AGENTS.md for the full placement table.
|
|
332
|
+
*/
|
|
333
|
+
export function instructionRule(root) {
|
|
334
|
+
const steps = AGENT_CONTRACT.steps(arkCheckCommand(root))
|
|
335
|
+
.map((step, index) => `${index + 1}. ${step}`)
|
|
336
|
+
.join('\n');
|
|
337
|
+
return `# Ark architecture contract
|
|
338
|
+
|
|
339
|
+
This project's architecture is governed by Ark (\`ark.config.json\` is authoritative).
|
|
340
|
+
Before writing or editing TypeScript or JavaScript source files:
|
|
341
|
+
|
|
342
|
+
${steps}
|
|
343
|
+
|
|
344
|
+
See \`AGENTS.md\` for the full contract and the layer placement table.
|
|
345
|
+
`;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export function cursorRule(root) {
|
|
349
|
+
return `---
|
|
350
|
+
description: Ark architecture contract
|
|
351
|
+
alwaysApply: true
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
Before writing or editing TypeScript or JavaScript source files, read the
|
|
355
|
+
\`${AGENT_CONTRACT.manifestResource}\` resource from the \`ark\` MCP server when available.
|
|
356
|
+
|
|
357
|
+
${AGENT_CONTRACT.cursorValidateStep} After edits, run:
|
|
358
|
+
|
|
359
|
+
\`\`\`bash
|
|
360
|
+
${arkCheckCommand(root)}
|
|
361
|
+
\`\`\`
|
|
362
|
+
|
|
363
|
+
If Ark reports violations, fix the architecture instead of bypassing the gate.
|
|
364
|
+
`;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Default CI Node when the project declares nothing. A current LTS, NOT the
|
|
368
|
+
// oldest supported: the npm-ci-lockfile-mismatch failure only happens when CI's
|
|
369
|
+
// npm is OLDER than the npm that wrote the lockfile, so defaulting high is safer.
|
|
370
|
+
const DEFAULT_CI_NODE_VERSION = '22';
|
|
371
|
+
|
|
372
|
+
// Decide the Node the generated CI should use, preferring the project's own
|
|
373
|
+
// declaration so CI's npm matches the dev's (a mismatch makes `npm ci` fail with
|
|
374
|
+
// "missing from lock file" — a red gate unrelated to architecture). In order:
|
|
375
|
+
// 1. .nvmrc / .node-version → setup-node's node-version-file (exact, best)
|
|
376
|
+
// 2. package.json engines.node → its concrete major
|
|
377
|
+
// 3. a current-LTS default
|
|
378
|
+
export function detectCiNode(root) {
|
|
379
|
+
for (const file of ['.nvmrc', '.node-version']) {
|
|
380
|
+
if (fs.existsSync(path.join(root, file))) return { kind: 'file', value: file };
|
|
381
|
+
}
|
|
382
|
+
const enginesNode = readPackageJson(root)?.engines?.node;
|
|
383
|
+
if (typeof enginesNode === 'string') {
|
|
384
|
+
const major = enginesNode.match(/\d+/)?.[0];
|
|
385
|
+
if (major) return { kind: 'version', value: major };
|
|
386
|
+
}
|
|
387
|
+
return { kind: 'default', value: DEFAULT_CI_NODE_VERSION };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export function githubWorkflow(pm, ciNode) {
|
|
391
|
+
// pnpm/yarn setup (corepack enable) MUST run before actions/setup-node so the package
|
|
392
|
+
// manager is on PATH when setup-node's `cache: pnpm|yarn` tries to resolve the store —
|
|
393
|
+
// otherwise the cache step fails on a fresh runner ("Unable to locate executable file: pnpm").
|
|
394
|
+
const setupSteps = pm.setup.map((command) => ` - run: ${command}`).join('\n');
|
|
395
|
+
// node-version-file keeps CI locked to the dev's exact toolchain; an explicit
|
|
396
|
+
// version comes from engines.node; the default carries a hint for the mismatch
|
|
397
|
+
// symptom since we can't know which npm wrote the lockfile.
|
|
398
|
+
const nodeSetup =
|
|
399
|
+
ciNode.kind === 'file'
|
|
400
|
+
? ` node-version-file: ${ciNode.value}`
|
|
401
|
+
: ciNode.kind === 'version'
|
|
402
|
+
? ` node-version: '${ciNode.value}'`
|
|
403
|
+
: ` # If the install step fails with "missing from lock file" / lockfile out
|
|
404
|
+
# of sync, your local package manager is newer than this Node's — add a
|
|
405
|
+
# .nvmrc with your Node version so CI matches the dev environment.
|
|
406
|
+
node-version: '${ciNode.value}'`;
|
|
407
|
+
return `name: Ark architecture gate
|
|
408
|
+
|
|
409
|
+
on:
|
|
410
|
+
pull_request:
|
|
411
|
+
push:
|
|
412
|
+
branches: [main, master]
|
|
413
|
+
|
|
414
|
+
jobs:
|
|
415
|
+
ark-check:
|
|
416
|
+
runs-on: ubuntu-latest
|
|
417
|
+
steps:
|
|
418
|
+
- name: Checkout
|
|
419
|
+
uses: actions/checkout@v4
|
|
420
|
+
${setupSteps ? `${setupSteps}\n` : ''} - name: Setup Node
|
|
421
|
+
uses: actions/setup-node@v4
|
|
422
|
+
with:
|
|
423
|
+
${nodeSetup}
|
|
424
|
+
cache: ${pm.cache}
|
|
425
|
+
- name: Install dependencies
|
|
426
|
+
run: ${pm.install}
|
|
427
|
+
- name: Ark architecture check
|
|
428
|
+
run: ${pm.run}
|
|
429
|
+
`;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export function claudeSettings(root) {
|
|
433
|
+
const runner = execRunner(root);
|
|
434
|
+
return `${JSON.stringify({
|
|
435
|
+
hooks: {
|
|
436
|
+
// Inject the contract at session start so the agent knows the architecture from
|
|
437
|
+
// the first token. Project-scoped by design; --session-context is also a silent
|
|
438
|
+
// no-op when no ark.config.json exists, so it can never leak into other projects.
|
|
439
|
+
SessionStart: [
|
|
440
|
+
{
|
|
441
|
+
hooks: [
|
|
442
|
+
{
|
|
443
|
+
type: 'command',
|
|
444
|
+
command: `${runner} ${PREFERRED_MCP_BIN} --session-context --root "$CLAUDE_PROJECT_DIR" --config ark.config.json`,
|
|
445
|
+
},
|
|
446
|
+
],
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
PreToolUse: [
|
|
450
|
+
{
|
|
451
|
+
matcher: 'Write|Edit|MultiEdit',
|
|
452
|
+
hooks: [
|
|
453
|
+
{
|
|
454
|
+
type: 'command',
|
|
455
|
+
command: `${runner} ${PREFERRED_MCP_BIN} --hook --root "$CLAUDE_PROJECT_DIR" --config ark.config.json`,
|
|
456
|
+
},
|
|
457
|
+
],
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
},
|
|
461
|
+
}, null, 2)}\n`;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Grok Build project config: MCP registration (commit-friendly relative paths — unlike
|
|
465
|
+
// Codex's global config.toml, Grok loads .grok/config.toml from the project).
|
|
466
|
+
export function grokProjectConfig(root) {
|
|
467
|
+
const { command, args } = execCommandParts(root, PREFERRED_MCP_BIN, [
|
|
468
|
+
'--root',
|
|
469
|
+
'.',
|
|
470
|
+
'--config',
|
|
471
|
+
'ark.config.json',
|
|
472
|
+
]);
|
|
473
|
+
const argsToml = args.map((value) => `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`).join(', ');
|
|
474
|
+
return `# Generated by ark-check --install-agent-gates (Grok Build project scope).
|
|
475
|
+
# Restart Grok (or /mcps → refresh) after changes. Also loads repo-root .mcp.json.
|
|
476
|
+
[mcp_servers.ark]
|
|
477
|
+
command = "${command.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"
|
|
478
|
+
args = [${argsToml}]
|
|
479
|
+
`;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Grok Build hooks: same arkgate-mcp contracts as Claude. Grok sets both
|
|
483
|
+
// GROK_WORKSPACE_ROOT and CLAUDE_PROJECT_DIR (Claude-compatible alias). Prefer
|
|
484
|
+
// GROK_* with fallback so hooks still work if only one is present.
|
|
485
|
+
// Matcher keeps Claude names (Write|Edit|MultiEdit) and Grok natives
|
|
486
|
+
// (write|search_replace) — Grok aliases both directions.
|
|
487
|
+
export function grokHooks(root) {
|
|
488
|
+
const runner = execRunner(root);
|
|
489
|
+
// Nested defaults: Grok native → Claude alias → project cwd (hook cwd is the workspace).
|
|
490
|
+
const grokRoot = '${GROK_WORKSPACE_ROOT:-${CLAUDE_PROJECT_DIR:-.}}';
|
|
491
|
+
return `${JSON.stringify({
|
|
492
|
+
hooks: {
|
|
493
|
+
SessionStart: [
|
|
494
|
+
{
|
|
495
|
+
hooks: [
|
|
496
|
+
{
|
|
497
|
+
type: 'command',
|
|
498
|
+
timeout: 30,
|
|
499
|
+
command: `${runner} ${PREFERRED_MCP_BIN} --session-context --root "${grokRoot}" --config ark.config.json`,
|
|
500
|
+
},
|
|
501
|
+
],
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
PreToolUse: [
|
|
505
|
+
{
|
|
506
|
+
matcher: 'Write|Edit|MultiEdit|write|search_replace',
|
|
507
|
+
hooks: [
|
|
508
|
+
{
|
|
509
|
+
type: 'command',
|
|
510
|
+
timeout: 30,
|
|
511
|
+
command: `${runner} ${PREFERRED_MCP_BIN} --hook --root "${grokRoot}" --config ark.config.json`,
|
|
512
|
+
},
|
|
513
|
+
],
|
|
514
|
+
},
|
|
515
|
+
],
|
|
516
|
+
},
|
|
517
|
+
}, null, 2)}\n`;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export function resolveTools(args) {
|
|
521
|
+
if (args.tools && args.tools.length > 0) {
|
|
522
|
+
return { tools: new Set(args.tools), source: 'explicit' };
|
|
523
|
+
}
|
|
524
|
+
const root = args.root;
|
|
525
|
+
const detected = new Set();
|
|
526
|
+
if (fs.existsSync(path.join(root, '.claude'))) detected.add('claude');
|
|
527
|
+
if (fs.existsSync(path.join(root, '.cursor'))) detected.add('cursor');
|
|
528
|
+
if (fs.existsSync(path.join(root, '.codex'))) detected.add('codex');
|
|
529
|
+
if (fs.existsSync(path.join(root, '.grok'))) detected.add('grok');
|
|
530
|
+
if (fs.existsSync(path.join(root, '.windsurf'))) detected.add('windsurf');
|
|
531
|
+
// .clinerules can also be a single FILE (older Cline convention); only a directory
|
|
532
|
+
// can receive .clinerules/ark.md, so a file must not trigger detection.
|
|
533
|
+
if (fs.statSync(path.join(root, '.clinerules'), { throwIfNoEntry: false })?.isDirectory()) {
|
|
534
|
+
detected.add('cline');
|
|
535
|
+
}
|
|
536
|
+
if (fs.existsSync(path.join(root, '.kiro'))) detected.add('kiro');
|
|
537
|
+
if (fs.existsSync(path.join(root, '.roo'))) detected.add('roo');
|
|
538
|
+
if (fs.existsSync(path.join(root, '.continue'))) detected.add('continue');
|
|
539
|
+
if (fs.existsSync(path.join(root, '.gemini'))) detected.add('gemini');
|
|
540
|
+
// copilot has no reliable directory signal (.github exists in most repos),
|
|
541
|
+
// so it is explicit-only via --tools.
|
|
542
|
+
// No signal at all: fall back to writing the primary tools' templates so a fresh
|
|
543
|
+
// project still gets a complete, reviewable starter set.
|
|
544
|
+
if (detected.size === 0) {
|
|
545
|
+
return { tools: new Set(['claude', 'cursor', 'codex']), source: 'default' };
|
|
546
|
+
}
|
|
547
|
+
return { tools: detected, source: 'detected' };
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const KNOWN_TOOLS = [
|
|
551
|
+
'claude',
|
|
552
|
+
'cursor',
|
|
553
|
+
'codex',
|
|
554
|
+
'grok',
|
|
555
|
+
'windsurf',
|
|
556
|
+
'cline',
|
|
557
|
+
'copilot',
|
|
558
|
+
'kiro',
|
|
559
|
+
'roo',
|
|
560
|
+
'continue',
|
|
561
|
+
'gemini',
|
|
562
|
+
];
|
|
563
|
+
|
|
564
|
+
// One canonical markdown per skill (templates/skills/*.md, shipped in the npm
|
|
565
|
+
// package); installed into each tool's slash-command location. The YAML
|
|
566
|
+
// frontmatter (name/description) is understood or harmlessly ignored by every
|
|
567
|
+
// host. Kiro has no command mechanism — its steering rule file is the only gate.
|
|
568
|
+
const SKILL_TOOL_TARGETS = {
|
|
569
|
+
claude: (name) => `.claude/skills/${name}/SKILL.md`,
|
|
570
|
+
cursor: (name) => `.cursor/commands/${name}.md`,
|
|
571
|
+
codex: (name) => `.codex/prompts/${name}.md`,
|
|
572
|
+
// Grok Build: project skills at .grok/skills/<name>/SKILL.md (slash-invocable).
|
|
573
|
+
grok: (name) => `.grok/skills/${name}/SKILL.md`,
|
|
574
|
+
windsurf: (name) => `.windsurf/workflows/${name}.md`,
|
|
575
|
+
cline: (name) => `.clinerules/workflows/${name}.md`,
|
|
576
|
+
copilot: (name) => `.github/prompts/${name}.prompt.md`,
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
// The version of the arkgate package these bins ship with. Used to
|
|
580
|
+
// stamp installed skills so a normal ark-check can tell "outdated skill from an
|
|
581
|
+
// older Ark" apart from "user-customized skill" — the stamp moves with the
|
|
582
|
+
// package, editing the body doesn't.
|
|
583
|
+
export function arkPackageVersion() {
|
|
584
|
+
try {
|
|
585
|
+
const pkg = readJson(path.join(__packageRoot, 'package.json'));
|
|
586
|
+
return typeof pkg.version === 'string' ? pkg.version : null;
|
|
587
|
+
} catch {
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// Insert `arkVersion: <v>` into a skill's YAML frontmatter (before its closing
|
|
593
|
+
// `---`). No frontmatter → returned unchanged. Idempotent for a given version.
|
|
594
|
+
export function stampSkill(content, version) {
|
|
595
|
+
if (!version) return content;
|
|
596
|
+
const lines = content.split('\n');
|
|
597
|
+
if (lines[0] !== '---') return content;
|
|
598
|
+
const closeIdx = lines.indexOf('---', 1);
|
|
599
|
+
if (closeIdx === -1) return content;
|
|
600
|
+
const existing = lines.findIndex(
|
|
601
|
+
(line, i) => i > 0 && i < closeIdx && /^arkVersion:/.test(line)
|
|
602
|
+
);
|
|
603
|
+
if (existing !== -1) {
|
|
604
|
+
lines[existing] = `arkVersion: ${version}`;
|
|
605
|
+
} else {
|
|
606
|
+
lines.splice(closeIdx, 0, `arkVersion: ${version}`);
|
|
607
|
+
}
|
|
608
|
+
return lines.join('\n');
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// Read the `arkVersion:` stamp from an installed skill file. Returns null when
|
|
612
|
+
// the file is absent or has no stamp (installed by a pre-stamp Ark, or hand-authored).
|
|
613
|
+
export function installedSkillVersion(filePath) {
|
|
614
|
+
let content;
|
|
615
|
+
try {
|
|
616
|
+
content = fs.readFileSync(filePath, 'utf8');
|
|
617
|
+
} catch {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
const match = content.match(/^arkVersion:\s*(.+)$/m);
|
|
621
|
+
return match ? match[1].trim() : null;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// Numeric-tuple compare of dotted versions; true when `a` is strictly older than
|
|
625
|
+
// `b`. Non-numeric/absent segments compare as 0, so "1.7" < "1.7.5".
|
|
626
|
+
export function isVersionOlder(a, b) {
|
|
627
|
+
const parse = (v) => String(v).split('.').map((n) => Number.parseInt(n, 10) || 0);
|
|
628
|
+
const av = parse(a);
|
|
629
|
+
const bv = parse(b);
|
|
630
|
+
const len = Math.max(av.length, bv.length);
|
|
631
|
+
for (let i = 0; i < len; i += 1) {
|
|
632
|
+
const x = av[i] ?? 0;
|
|
633
|
+
const y = bv[i] ?? 0;
|
|
634
|
+
if (x !== y) return x < y;
|
|
635
|
+
}
|
|
636
|
+
return false;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export function skillTemplates() {
|
|
640
|
+
const dir = path.join(__packageRoot, 'templates', 'skills');
|
|
641
|
+
// A missing/mispackaged templates dir would otherwise install zero skills with
|
|
642
|
+
// exit 0 — warn so a packaging regression (e.g. "templates" dropped from the
|
|
643
|
+
// package.json files array) is visible instead of a silent no-op.
|
|
644
|
+
let entries;
|
|
645
|
+
try {
|
|
646
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
647
|
+
} catch {
|
|
648
|
+
console.error(
|
|
649
|
+
`Warning: skill templates directory not found (${dir}); no /ark-* skills installed.`
|
|
650
|
+
);
|
|
651
|
+
return [];
|
|
652
|
+
}
|
|
653
|
+
return entries
|
|
654
|
+
.filter((entry) => entry.isFile() && /^[a-z0-9-]+\.md$/.test(entry.name))
|
|
655
|
+
.map((entry) => entry.name)
|
|
656
|
+
.sort()
|
|
657
|
+
.map((name) => [path.basename(name, '.md'), fs.readFileSync(path.join(dir, name), 'utf8')]);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// Skill names only, silent on a missing templates dir — for the freshness
|
|
661
|
+
// advisory below, which must not print packaging warnings on every check run.
|
|
662
|
+
export function skillTemplateNames() {
|
|
663
|
+
const dir = path.join(__packageRoot, 'templates', 'skills');
|
|
664
|
+
let entries;
|
|
665
|
+
try {
|
|
666
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
667
|
+
} catch {
|
|
668
|
+
return [];
|
|
669
|
+
}
|
|
670
|
+
return entries
|
|
671
|
+
.filter((entry) => entry.isFile() && /^[a-z0-9-]+\.md$/.test(entry.name))
|
|
672
|
+
.map((entry) => path.basename(entry.name, '.md'));
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// A normal ark-check run is the reliable discovery point for new /ark-* skills.
|
|
676
|
+
// Ark ships no install lifecycle script (a postinstall banner would be blocked by
|
|
677
|
+
// modern package managers' script-approval policy anyway, so careful users never
|
|
678
|
+
// saw it — and it broke hardened installs). When a project has adopted Ark agent
|
|
679
|
+
// gates (AGENTS.md present) but a detected tool is missing
|
|
680
|
+
// skills this version ships, surface it here so agents and CI actually notice.
|
|
681
|
+
// Advisory only — never affects the exit code. Copilot has no reliable directory
|
|
682
|
+
// signal, so it is not auto-detected (explicit --tools only), matching resolveTools.
|
|
683
|
+
// Where Codex loads slash-command prompts from. Codex reads $CODEX_HOME/prompts
|
|
684
|
+
// (defaulting to ~/.codex/prompts), NOT the repo — so home copies of the /ark-*
|
|
685
|
+
// skills drift out of date when a repo refresh only touches in-repo tool dirs.
|
|
686
|
+
export function codexPromptsDir() {
|
|
687
|
+
const base = process.env.CODEX_HOME || path.join(os.homedir(), '.codex');
|
|
688
|
+
return path.join(base, 'prompts');
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// Where Codex reads its MCP server registrations. Unlike Claude (.claude/settings.json)
|
|
692
|
+
// and Cursor (.cursor/mcp.json), Codex loads MCP servers only from $CODEX_HOME/config.toml
|
|
693
|
+
// (~/.codex/config.toml) — never from .mcp.json — so wiring Codex means editing the user's
|
|
694
|
+
// home config, not a repo file.
|
|
695
|
+
export function codexConfigPath() {
|
|
696
|
+
const base = process.env.CODEX_HOME || path.join(os.homedir(), '.codex');
|
|
697
|
+
return path.join(base, 'config.toml');
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// Merge the [mcp_servers.ark] table into Codex's config.toml so `ark://manifest` and the
|
|
701
|
+
// AI write gate are live from the first edit — the piece that was previously only shipped as
|
|
702
|
+
// a copy-me sample in docs/ark-codex-config.toml. Idempotent: an existing ark table is left
|
|
703
|
+
// untouched unless `force` replaces it; other content in the file is preserved. Returns a
|
|
704
|
+
// status for the install summary. The table match runs from the [mcp_servers.ark] header to
|
|
705
|
+
// the line before the next top-level table header (a line starting with `[`) or EOF.
|
|
706
|
+
//
|
|
707
|
+
// Unlike .mcp.json / .cursor/mcp.json (loaded relative to the project), config.toml is a
|
|
708
|
+
// GLOBAL file — Codex launches it without the project as cwd — so `--root .` would resolve
|
|
709
|
+
// against the wrong directory. The paths must be absolute, and TOML string values need the
|
|
710
|
+
// backslashes/quotes escaped (matters on Windows and for repo paths containing quotes).
|
|
711
|
+
export function wireCodexMcp(root, force) {
|
|
712
|
+
const file = codexConfigPath();
|
|
713
|
+
const esc = (s) => s.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
714
|
+
const absRoot = path.resolve(root);
|
|
715
|
+
const absConfig = path.join(absRoot, 'ark.config.json');
|
|
716
|
+
// Preferred product bin; absolute --root so Codex (cwd ≠ project) resolves correctly.
|
|
717
|
+
const preferredBin = 'arkgate-mcp';
|
|
718
|
+
const { command, args } = execCommandParts(root, preferredBin, [
|
|
719
|
+
'--root',
|
|
720
|
+
esc(absRoot),
|
|
721
|
+
'--config',
|
|
722
|
+
esc(absConfig),
|
|
723
|
+
]);
|
|
724
|
+
const argsToml = args.map((value) => `"${value}"`).join(', ');
|
|
725
|
+
const block = `[mcp_servers.ark]
|
|
726
|
+
command = "${command}"
|
|
727
|
+
args = [${argsToml}]`;
|
|
728
|
+
let existing = '';
|
|
729
|
+
try {
|
|
730
|
+
if (fs.existsSync(file)) existing = fs.readFileSync(file, 'utf8');
|
|
731
|
+
} catch (error) {
|
|
732
|
+
return { status: 'failed', file, message: error.message };
|
|
733
|
+
}
|
|
734
|
+
const tableRe = /(^|\n)\[mcp_servers\.ark\][^\n]*\n(?:(?!\[)[^\n]*\n?)*/;
|
|
735
|
+
const hasTable = tableRe.test(existing);
|
|
736
|
+
// Fail-closed: rewrite temp/upgrade roots and dual/wrong bins even without --force.
|
|
737
|
+
const mustRewrite = hasTable && codexArkBlockNeedsRewrite(existing, absRoot);
|
|
738
|
+
if (hasTable && !force && !mustRewrite) {
|
|
739
|
+
return { status: 'skipped', file };
|
|
740
|
+
}
|
|
741
|
+
let next;
|
|
742
|
+
if (hasTable) {
|
|
743
|
+
next = existing.replace(tableRe, (match) => `${match.startsWith('\n') ? '\n' : ''}${block}\n`);
|
|
744
|
+
} else {
|
|
745
|
+
const sep = existing.length === 0 ? '' : existing.endsWith('\n\n') ? '' : existing.endsWith('\n') ? '\n' : '\n\n';
|
|
746
|
+
next = `${existing}${sep}${block}\n`;
|
|
747
|
+
}
|
|
748
|
+
try {
|
|
749
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
750
|
+
fs.writeFileSync(file, next);
|
|
751
|
+
} catch (error) {
|
|
752
|
+
return { status: 'failed', file, message: error.message };
|
|
753
|
+
}
|
|
754
|
+
return {
|
|
755
|
+
status: hasTable ? 'updated' : 'written',
|
|
756
|
+
file,
|
|
757
|
+
...(mustRewrite && !force ? { reason: 'temp-or-stale-root' } : {}),
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// Detects stale/missing /ark-* skills in the Codex home prompts dir. Only nags
|
|
762
|
+
// when at least one ark-* prompt already lives there (evidence Codex was set up
|
|
763
|
+
// for this user) — never introduces Codex to someone who doesn't use it. Same
|
|
764
|
+
// guards as detectSkillGaps (adopted repo, not the Ark source tree).
|
|
765
|
+
export function detectCodexHomeGap(root) {
|
|
766
|
+
if (!fs.existsSync(path.join(root, 'AGENTS.md'))) return null;
|
|
767
|
+
if (fs.existsSync(path.join(root, 'templates', 'skills'))) return null;
|
|
768
|
+
const skillNames = skillTemplateNames();
|
|
769
|
+
if (skillNames.length === 0) return null;
|
|
770
|
+
const dir = codexPromptsDir();
|
|
771
|
+
if (!fs.existsSync(dir)) return null;
|
|
772
|
+
const present = skillNames.filter((name) => fs.existsSync(path.join(dir, `${name}.md`)));
|
|
773
|
+
if (present.length === 0) return null; // Codex home never set up for Ark — don't nag.
|
|
774
|
+
const version = arkPackageVersion();
|
|
775
|
+
const missing = skillNames.length - present.length;
|
|
776
|
+
let stale = 0;
|
|
777
|
+
if (version) {
|
|
778
|
+
for (const name of present) {
|
|
779
|
+
const installed = installedSkillVersion(path.join(dir, `${name}.md`));
|
|
780
|
+
if (installed === null || isVersionOlder(installed, version)) stale += 1;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return missing > 0 || stale > 0 ? { missing, stale } : null;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export function detectSkillGaps(root) {
|
|
787
|
+
if (!fs.existsSync(path.join(root, 'AGENTS.md'))) return [];
|
|
788
|
+
// The Ark source tree keeps the skill templates at templates/skills/ — it's the
|
|
789
|
+
// producer, not a consumer, so it must not nag itself to "install" its own skills.
|
|
790
|
+
if (fs.existsSync(path.join(root, 'templates', 'skills'))) return [];
|
|
791
|
+
const skillNames = skillTemplateNames();
|
|
792
|
+
if (skillNames.length === 0) return [];
|
|
793
|
+
const detected = [];
|
|
794
|
+
if (fs.existsSync(path.join(root, '.claude'))) detected.push('claude');
|
|
795
|
+
if (fs.existsSync(path.join(root, '.cursor'))) detected.push('cursor');
|
|
796
|
+
if (fs.existsSync(path.join(root, '.codex'))) detected.push('codex');
|
|
797
|
+
if (fs.existsSync(path.join(root, '.grok'))) detected.push('grok');
|
|
798
|
+
if (fs.existsSync(path.join(root, '.windsurf'))) detected.push('windsurf');
|
|
799
|
+
if (fs.statSync(path.join(root, '.clinerules'), { throwIfNoEntry: false })?.isDirectory()) {
|
|
800
|
+
detected.push('cline');
|
|
801
|
+
}
|
|
802
|
+
const version = arkPackageVersion();
|
|
803
|
+
const gaps = [];
|
|
804
|
+
for (const tool of detected) {
|
|
805
|
+
const target = SKILL_TOOL_TARGETS[tool];
|
|
806
|
+
if (!target) continue;
|
|
807
|
+
let missing = 0;
|
|
808
|
+
let stale = 0;
|
|
809
|
+
for (const name of skillNames) {
|
|
810
|
+
const file = path.join(root, target(name));
|
|
811
|
+
if (!fs.existsSync(file)) {
|
|
812
|
+
missing += 1;
|
|
813
|
+
} else if (version) {
|
|
814
|
+
// An installed skill with no stamp predates stamping (older Ark), or one
|
|
815
|
+
// stamped behind the current version is left over from an older install.
|
|
816
|
+
// Either way the shipped skill has moved on — offer a --force refresh.
|
|
817
|
+
const installed = installedSkillVersion(file);
|
|
818
|
+
if (installed === null || isVersionOlder(installed, version)) stale += 1;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (missing > 0 || stale > 0) gaps.push({ tool, missing, stale });
|
|
822
|
+
}
|
|
823
|
+
return gaps;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// Files carrying an emitted Ark command whose runner (npx / pnpm exec / yarn) should match
|
|
827
|
+
// the project's package manager. .mcp.json / .cursor/mcp.json hold it structurally
|
|
828
|
+
// (command/args); the rest hold it as text ("npx ark-check …", incl. .claude/settings.json
|
|
829
|
+
// hook strings and the package.json check:architecture script).
|
|
830
|
+
const COMMAND_GATE_TEXT_FILES = [
|
|
831
|
+
'.claude/settings.json', 'AGENTS.md', '.cursor/rules/ark.mdc', '.windsurf/rules/ark.md',
|
|
832
|
+
'.clinerules/ark.md', '.github/copilot-instructions.md', '.kiro/steering/ark.md',
|
|
833
|
+
'.roo/rules/ark.md', '.continue/rules/ark.md', 'GEMINI.md', 'package.json',
|
|
834
|
+
'.grok/hooks/ark-write-gate.json', '.grok/config.toml',
|
|
835
|
+
];
|
|
836
|
+
const COMMAND_GATE_JSON_FILES = ['.mcp.json', '.cursor/mcp.json'];
|
|
837
|
+
// Primary CLI names (product) + one-major aliases. migrate-commands must strip ALL of these
|
|
838
|
+
// before re-emitting a single preferred bin — otherwise a partial rename leaves
|
|
839
|
+
// args: ["ark-mcp", "arkgate-mcp", ...] which breaks stdio MCP hosts.
|
|
840
|
+
const ARK_MCP_BINS = new Set(['arkgate-mcp', 'ark-mcp']);
|
|
841
|
+
const ARK_CHECK_BINS = new Set(['arkgate-check', 'ark-check']);
|
|
842
|
+
const ARK_CLI_BINS = new Set(['arkgate', 'ark']);
|
|
843
|
+
const PREFERRED_MCP_BIN = 'arkgate-mcp';
|
|
844
|
+
const PREFERRED_CHECK_BIN = 'arkgate-check';
|
|
845
|
+
const PREFERRED_CLI_BIN = 'arkgate';
|
|
846
|
+
// Runner argv noise that is not a bin argument (pnpm exec form).
|
|
847
|
+
const MCP_RUNNER_ARGV = new Set(['exec', '--config.verify-deps-before-run=false']);
|
|
848
|
+
// The runner token immediately before an ark command in a text command string.
|
|
849
|
+
// Matches npm/yarn runners and both pnpm forms (legacy `pnpm exec` + verify-deps-safe form).
|
|
850
|
+
// Longer bin names first so `arkgate-check` is not partially matched as `ark`.
|
|
851
|
+
const RUNNER_BEFORE_ARK =
|
|
852
|
+
/\b(?:npx|pnpm --config\.verify-deps-before-run=false exec|pnpm exec|yarn)(?= (?:arkgate-check|arkgate-mcp|arkgate|ark-check|ark-mcp|ark)\b)/g;
|
|
853
|
+
|
|
854
|
+
/** Keep only MCP server flags from existing args (drop runner tokens + any ark* bin names). */
|
|
855
|
+
export function stripMcpServerArgs(args) {
|
|
856
|
+
if (!Array.isArray(args) || args.length === 0) {
|
|
857
|
+
return ['--root', '.', '--config', 'ark.config.json'];
|
|
858
|
+
}
|
|
859
|
+
const kept = args.filter(
|
|
860
|
+
(entry) =>
|
|
861
|
+
typeof entry === 'string' &&
|
|
862
|
+
!MCP_RUNNER_ARGV.has(entry) &&
|
|
863
|
+
!ARK_MCP_BINS.has(entry) &&
|
|
864
|
+
!ARK_CHECK_BINS.has(entry) &&
|
|
865
|
+
!ARK_CLI_BINS.has(entry)
|
|
866
|
+
);
|
|
867
|
+
return kept.length > 0 ? kept : ['--root', '.', '--config', 'ark.config.json'];
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/** True when mcpServers.ark.args list more than one Ark MCP bin (broken dual rename). */
|
|
871
|
+
export function mcpArgsHaveDuplicateBins(args) {
|
|
872
|
+
if (!Array.isArray(args)) return false;
|
|
873
|
+
const hits = args.filter((entry) => ARK_MCP_BINS.has(entry));
|
|
874
|
+
return hits.length > 1 || (hits.length === 1 && args.indexOf(hits[0]) !== args.lastIndexOf(hits[0]));
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export function brokenMcpGateFiles(root) {
|
|
878
|
+
const bad = [];
|
|
879
|
+
for (const rel of COMMAND_GATE_JSON_FILES) {
|
|
880
|
+
let json;
|
|
881
|
+
try {
|
|
882
|
+
json = JSON.parse(fs.readFileSync(path.join(root, rel), 'utf8'));
|
|
883
|
+
} catch {
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
const ark = json?.mcpServers?.ark;
|
|
887
|
+
if (ark && mcpArgsHaveDuplicateBins(ark.args)) bad.push(rel);
|
|
888
|
+
}
|
|
889
|
+
return bad;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/** Core layers whose optionality matters once they match files (presets share these names). */
|
|
893
|
+
const CORE_LAYER_NAMES = new Set([
|
|
894
|
+
'DomainModel',
|
|
895
|
+
'ApplicationOrchestration',
|
|
896
|
+
'PresentationAdapters',
|
|
897
|
+
'PersistenceAdapters',
|
|
898
|
+
]);
|
|
899
|
+
|
|
900
|
+
/** Temp / upgrade sandbox roots must never remain as Codex MCP --root. */
|
|
901
|
+
export function isTempOrUpgradeRoot(p) {
|
|
902
|
+
if (!p || typeof p !== 'string') return false;
|
|
903
|
+
const n = p.replace(/\\/g, '/');
|
|
904
|
+
return (
|
|
905
|
+
/\/var\/folders\//i.test(n) ||
|
|
906
|
+
/\/tmp\//i.test(n) ||
|
|
907
|
+
/\/Temp\//i.test(n) ||
|
|
908
|
+
/ark-upgrade/i.test(n) ||
|
|
909
|
+
/\/T\/(?:ark-|grok-)/i.test(n) ||
|
|
910
|
+
/[\\/]AppData[\\/]Local[\\/]Temp[\\/]/i.test(n)
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/** Extract --root value from Codex [mcp_servers.ark] args array text. */
|
|
915
|
+
export function extractCodexArkRootFromToml(tomlText) {
|
|
916
|
+
if (!tomlText || typeof tomlText !== 'string') return null;
|
|
917
|
+
const start = tomlText.search(/(^|\n)\[mcp_servers\.ark\]/);
|
|
918
|
+
if (start < 0) return null;
|
|
919
|
+
const rest = tomlText.slice(start);
|
|
920
|
+
const endMatch = rest.slice(1).search(/\n\[/);
|
|
921
|
+
const block = endMatch >= 0 ? rest.slice(0, endMatch + 1) : rest;
|
|
922
|
+
// args = ["arkgate-mcp", "--root", "/abs/path", ...]
|
|
923
|
+
const rootIdx = block.search(/"--root"\s*,\s*"/);
|
|
924
|
+
if (rootIdx < 0) {
|
|
925
|
+
// alternate: --root as adjacent string after any bin
|
|
926
|
+
const m = block.match(/"--root"\s*,\s*"([^"]+)"/);
|
|
927
|
+
return m ? m[1] : null;
|
|
928
|
+
}
|
|
929
|
+
const m = block.slice(rootIdx).match(/"--root"\s*,\s*"([^"]+)"/);
|
|
930
|
+
return m ? m[1] : null;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
export function codexArkBlockHasPreferredBin(tomlText) {
|
|
934
|
+
if (!tomlText) return false;
|
|
935
|
+
const start = tomlText.search(/(^|\n)\[mcp_servers\.ark\]/);
|
|
936
|
+
if (start < 0) return false;
|
|
937
|
+
const rest = tomlText.slice(start);
|
|
938
|
+
const endMatch = rest.slice(1).search(/\n\[/);
|
|
939
|
+
const block = endMatch >= 0 ? rest.slice(0, endMatch + 1) : rest;
|
|
940
|
+
const bins = [...block.matchAll(/"(arkgate-mcp|ark-mcp)"/g)].map((m) => m[1]);
|
|
941
|
+
if (bins.length > 1) return false;
|
|
942
|
+
return bins.length === 1 && bins[0] === PREFERRED_MCP_BIN;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
export function codexArkBlockNeedsRewrite(tomlText, absRoot) {
|
|
946
|
+
if (!tomlText || !tomlText.includes('[mcp_servers.ark]')) return true;
|
|
947
|
+
const rootArg = extractCodexArkRootFromToml(tomlText);
|
|
948
|
+
if (!rootArg || isTempOrUpgradeRoot(rootArg)) return true;
|
|
949
|
+
try {
|
|
950
|
+
if (path.resolve(rootArg) !== path.resolve(absRoot)) return true;
|
|
951
|
+
} catch {
|
|
952
|
+
return true;
|
|
953
|
+
}
|
|
954
|
+
if (!codexArkBlockHasPreferredBin(tomlText)) return true;
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Adoption completeness (separate from 0–100 fitness). Pure-ish: filesystem + config.
|
|
960
|
+
* @returns {{ gaps: object[], hosts: object[], mcp: object, codexHome: object|null, coreOptional: object[], originReport: object, baseline: object, layerBalance: object|null }}
|
|
961
|
+
*/
|
|
962
|
+
export function collectAdoptionGaps(root, config, coverage) {
|
|
963
|
+
const gaps = [];
|
|
964
|
+
const adopted = fs.existsSync(path.join(root, 'AGENTS.md'));
|
|
965
|
+
const isProducer = fs.existsSync(path.join(root, 'templates', 'skills'));
|
|
966
|
+
|
|
967
|
+
// --- Repo MCP dual-bin ---
|
|
968
|
+
const dualMcp = brokenMcpGateFiles(root);
|
|
969
|
+
const mcp = {
|
|
970
|
+
dualBinFiles: dualMcp,
|
|
971
|
+
ok: dualMcp.length === 0,
|
|
972
|
+
};
|
|
973
|
+
if (dualMcp.length > 0) {
|
|
974
|
+
gaps.push({
|
|
975
|
+
id: 'mcp-dual-bin',
|
|
976
|
+
severity: 'warn',
|
|
977
|
+
message: `Broken MCP argv in ${dualMcp.join(', ')}: more than one of ark-mcp/arkgate-mcp`,
|
|
978
|
+
fix: arkCommand(root, 'ark-check', '--install-agent-gates --migrate-commands'),
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// --- Host completeness (only when project already adopted gates) ---
|
|
983
|
+
const hosts = [];
|
|
984
|
+
if (adopted && !isProducer) {
|
|
985
|
+
const skillNames = skillTemplateNames();
|
|
986
|
+
const hostChecks = [
|
|
987
|
+
{
|
|
988
|
+
host: 'grok',
|
|
989
|
+
dir: '.grok',
|
|
990
|
+
skill: (n) => path.join(root, '.grok', 'skills', n, 'SKILL.md'),
|
|
991
|
+
extras: [
|
|
992
|
+
['.grok/hooks/ark-write-gate.json', 'write-gate hook'],
|
|
993
|
+
['.grok/config.toml', 'project MCP config'],
|
|
994
|
+
],
|
|
995
|
+
toolsFlag: 'grok',
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
host: 'claude',
|
|
999
|
+
dir: '.claude',
|
|
1000
|
+
skill: (n) => path.join(root, '.claude', 'skills', n, 'SKILL.md'),
|
|
1001
|
+
extras: [['.claude/settings.json', 'settings/hooks']],
|
|
1002
|
+
toolsFlag: 'claude',
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
host: 'cursor',
|
|
1006
|
+
dir: '.cursor',
|
|
1007
|
+
skill: (n) => path.join(root, '.cursor', 'commands', `${n}.md`),
|
|
1008
|
+
extras: [['.cursor/mcp.json', 'MCP config']],
|
|
1009
|
+
toolsFlag: 'cursor',
|
|
1010
|
+
},
|
|
1011
|
+
];
|
|
1012
|
+
for (const h of hostChecks) {
|
|
1013
|
+
if (!fs.existsSync(path.join(root, h.dir))) continue;
|
|
1014
|
+
const missingSkills = skillNames.filter((n) => !fs.existsSync(h.skill(n)));
|
|
1015
|
+
const missingExtras = h.extras.filter(([rel]) => !fs.existsSync(path.join(root, rel)));
|
|
1016
|
+
const complete = missingSkills.length === 0 && missingExtras.length === 0;
|
|
1017
|
+
hosts.push({
|
|
1018
|
+
host: h.host,
|
|
1019
|
+
present: true,
|
|
1020
|
+
complete,
|
|
1021
|
+
missingSkills: missingSkills.length,
|
|
1022
|
+
missingExtras: missingExtras.map(([, label]) => label),
|
|
1023
|
+
});
|
|
1024
|
+
if (!complete) {
|
|
1025
|
+
gaps.push({
|
|
1026
|
+
id: `host-${h.host}-incomplete`,
|
|
1027
|
+
severity: 'warn',
|
|
1028
|
+
message: `${h.host} dir present but incomplete (${missingSkills.length} skill(s) missing${
|
|
1029
|
+
missingExtras.length ? `; missing ${missingExtras.map(([, l]) => l).join(', ')}` : ''
|
|
1030
|
+
})`,
|
|
1031
|
+
fix: arkCommand(
|
|
1032
|
+
root,
|
|
1033
|
+
'ark-check',
|
|
1034
|
+
`--install-agent-gates --tools ${h.toolsFlag} --force`
|
|
1035
|
+
),
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// --- Codex home MCP (temp path / wrong root / dual bin) ---
|
|
1042
|
+
let codexHome = null;
|
|
1043
|
+
if (adopted && !isProducer) {
|
|
1044
|
+
const codexFile = codexConfigPath();
|
|
1045
|
+
let toml = '';
|
|
1046
|
+
try {
|
|
1047
|
+
if (fs.existsSync(codexFile)) toml = fs.readFileSync(codexFile, 'utf8');
|
|
1048
|
+
} catch {
|
|
1049
|
+
toml = '';
|
|
1050
|
+
}
|
|
1051
|
+
if (toml.includes('[mcp_servers.ark]')) {
|
|
1052
|
+
const rootArg = extractCodexArkRootFromToml(toml);
|
|
1053
|
+
const absRoot = path.resolve(root);
|
|
1054
|
+
const temp = isTempOrUpgradeRoot(rootArg);
|
|
1055
|
+
let wrongRoot = false;
|
|
1056
|
+
try {
|
|
1057
|
+
wrongRoot = rootArg ? path.resolve(rootArg) !== absRoot : true;
|
|
1058
|
+
} catch {
|
|
1059
|
+
wrongRoot = true;
|
|
1060
|
+
}
|
|
1061
|
+
const preferredBin = codexArkBlockHasPreferredBin(toml);
|
|
1062
|
+
const needsRewrite = codexArkBlockNeedsRewrite(toml, absRoot);
|
|
1063
|
+
codexHome = {
|
|
1064
|
+
file: codexFile,
|
|
1065
|
+
root: rootArg,
|
|
1066
|
+
tempPath: temp,
|
|
1067
|
+
wrongRoot,
|
|
1068
|
+
preferredBin,
|
|
1069
|
+
needsRewrite,
|
|
1070
|
+
};
|
|
1071
|
+
if (needsRewrite) {
|
|
1072
|
+
gaps.push({
|
|
1073
|
+
id: 'codex-home-mcp',
|
|
1074
|
+
severity: temp || wrongRoot ? 'warn' : 'info',
|
|
1075
|
+
message: temp
|
|
1076
|
+
? `Codex home MCP --root points at a temp/upgrade path (${rootArg})`
|
|
1077
|
+
: wrongRoot
|
|
1078
|
+
? `Codex home MCP --root is not this project (${rootArg || 'missing'} ≠ ${absRoot})`
|
|
1079
|
+
: `Codex home MCP should use a single ${PREFERRED_MCP_BIN} bin with absolute project paths`,
|
|
1080
|
+
fix: arkCommand(
|
|
1081
|
+
root,
|
|
1082
|
+
'ark-check',
|
|
1083
|
+
'--install-agent-gates --codex-home --force'
|
|
1084
|
+
),
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
// --- Core layers optional but populated ---
|
|
1091
|
+
const coreOptional = [];
|
|
1092
|
+
const layerRows = coverage?.layers ?? [];
|
|
1093
|
+
const countByName = new Map(layerRows.map((r) => [r.name, r.files]));
|
|
1094
|
+
for (const layer of config?.layers ?? []) {
|
|
1095
|
+
if (!CORE_LAYER_NAMES.has(layer.name)) continue;
|
|
1096
|
+
if (layer.optional !== true) continue;
|
|
1097
|
+
const files = countByName.get(layer.name) ?? 0;
|
|
1098
|
+
if (files > 0) {
|
|
1099
|
+
coreOptional.push({ layer: layer.name, files });
|
|
1100
|
+
gaps.push({
|
|
1101
|
+
id: `core-optional-${layer.name}`,
|
|
1102
|
+
severity: 'info',
|
|
1103
|
+
message: `Core layer ${layer.name} has ${files} file(s) but is still optional: true — contract is weaker than the tree`,
|
|
1104
|
+
fix: `Edit ark.config.json: remove optional on ${layer.name} (or set false), then ${arkCommand(root, 'ark-check', '--strict-config')}`,
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// --- Origin report ---
|
|
1110
|
+
const originJson = path.join(root, '.ark', 'reports', 'origin.json');
|
|
1111
|
+
const originReport = {
|
|
1112
|
+
present: fs.existsSync(originJson),
|
|
1113
|
+
path: '.ark/reports/origin.json',
|
|
1114
|
+
};
|
|
1115
|
+
if (adopted && !originReport.present && (coverage?.governed?.percent ?? 0) >= 50) {
|
|
1116
|
+
gaps.push({
|
|
1117
|
+
id: 'origin-report-missing',
|
|
1118
|
+
severity: 'info',
|
|
1119
|
+
message: 'No origin architecture snapshot under .ark/reports/ yet',
|
|
1120
|
+
fix: arkCommand(root, 'ark-check', '--report ark-report.html'),
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// --- Baseline policy ---
|
|
1125
|
+
const baselinePath = path.join(root, '.ark-baseline.json');
|
|
1126
|
+
const baselineExists = fs.existsSync(baselinePath);
|
|
1127
|
+
let frozenKeys = 0;
|
|
1128
|
+
if (baselineExists) {
|
|
1129
|
+
try {
|
|
1130
|
+
const raw = JSON.parse(fs.readFileSync(baselinePath, 'utf8'));
|
|
1131
|
+
frozenKeys = Array.isArray(raw.violations) ? raw.violations.length : 0;
|
|
1132
|
+
} catch {
|
|
1133
|
+
frozenKeys = 0;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
let primaryPathUsesBaseline = false;
|
|
1137
|
+
try {
|
|
1138
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
1139
|
+
const scripts = pkg.scripts && typeof pkg.scripts === 'object' ? pkg.scripts : {};
|
|
1140
|
+
primaryPathUsesBaseline = Object.values(scripts).some(
|
|
1141
|
+
(s) => typeof s === 'string' && s.includes('--baseline')
|
|
1142
|
+
);
|
|
1143
|
+
} catch {
|
|
1144
|
+
/* no package.json */
|
|
1145
|
+
}
|
|
1146
|
+
if (!primaryPathUsesBaseline) {
|
|
1147
|
+
try {
|
|
1148
|
+
const wfDir = path.join(root, '.github', 'workflows');
|
|
1149
|
+
if (fs.existsSync(wfDir)) {
|
|
1150
|
+
for (const f of fs.readdirSync(wfDir)) {
|
|
1151
|
+
if (!/\.ya?ml$/i.test(f)) continue;
|
|
1152
|
+
const text = fs.readFileSync(path.join(wfDir, f), 'utf8');
|
|
1153
|
+
if (text.includes('--baseline') && (text.includes('ark-check') || text.includes('arkgate-check'))) {
|
|
1154
|
+
primaryPathUsesBaseline = true;
|
|
1155
|
+
break;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
} catch {
|
|
1160
|
+
/* ignore */
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
const baseline = {
|
|
1164
|
+
exists: baselineExists,
|
|
1165
|
+
frozenKeys,
|
|
1166
|
+
primaryPathUsesBaseline,
|
|
1167
|
+
signal: baselineExists
|
|
1168
|
+
? frozenKeys === 0
|
|
1169
|
+
? 'keep-empty'
|
|
1170
|
+
: 'active-ratchet'
|
|
1171
|
+
: 'absent',
|
|
1172
|
+
};
|
|
1173
|
+
if (adopted && baselineExists && frozenKeys === 0 && !primaryPathUsesBaseline) {
|
|
1174
|
+
gaps.push({
|
|
1175
|
+
id: 'baseline-unused',
|
|
1176
|
+
severity: 'info',
|
|
1177
|
+
message:
|
|
1178
|
+
'Empty .ark-baseline.json exists but primary scripts/CI do not pass --baseline (policy unclear)',
|
|
1179
|
+
fix: 'Either add --baseline .ark-baseline.json to check:architecture / CI, or remove the unused baseline file',
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
// --- Educational layer balance (not a violation) ---
|
|
1184
|
+
let layerBalance = null;
|
|
1185
|
+
const total = layerRows.reduce((s, r) => s + (r.files || 0), 0);
|
|
1186
|
+
if (total >= 20) {
|
|
1187
|
+
const presentation = layerRows.find((r) => r.name === 'PresentationAdapters');
|
|
1188
|
+
const domain = layerRows.find((r) => r.name === 'DomainModel');
|
|
1189
|
+
if (presentation && domain) {
|
|
1190
|
+
const pShare = presentation.files / total;
|
|
1191
|
+
const dShare = domain.files / total;
|
|
1192
|
+
if (pShare >= 0.5 && dShare < 0.1) {
|
|
1193
|
+
layerBalance = {
|
|
1194
|
+
kind: 'presentation-heavy-thin-domain',
|
|
1195
|
+
presentationFiles: presentation.files,
|
|
1196
|
+
domainFiles: domain.files,
|
|
1197
|
+
totalFiles: total,
|
|
1198
|
+
educational:
|
|
1199
|
+
'Presentation holds most of the tree while DomainModel is thin — common for UI apps; consider extracting domain types/use-cases as the product grows. Educational only (not a gate failure).',
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
return {
|
|
1206
|
+
gaps,
|
|
1207
|
+
hosts,
|
|
1208
|
+
mcp,
|
|
1209
|
+
codexHome,
|
|
1210
|
+
coreOptional,
|
|
1211
|
+
originReport,
|
|
1212
|
+
baseline,
|
|
1213
|
+
layerBalance,
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// Gate files whose Ark command runner doesn't match this project's package manager — the
|
|
1218
|
+
// advisory (and --migrate-commands) target. Returns [] for npm/unknown projects (npx is right)
|
|
1219
|
+
// so the check is silent unless there's a real mismatch.
|
|
1220
|
+
export function staleRunnerGateFiles(root) {
|
|
1221
|
+
const want = execRunner(root);
|
|
1222
|
+
if (want === 'npx') return [];
|
|
1223
|
+
const stale = [];
|
|
1224
|
+
for (const rel of COMMAND_GATE_TEXT_FILES) {
|
|
1225
|
+
let text;
|
|
1226
|
+
try {
|
|
1227
|
+
text = fs.readFileSync(path.join(root, rel), 'utf8');
|
|
1228
|
+
} catch {
|
|
1229
|
+
continue;
|
|
1230
|
+
}
|
|
1231
|
+
RUNNER_BEFORE_ARK.lastIndex = 0;
|
|
1232
|
+
let match;
|
|
1233
|
+
while ((match = RUNNER_BEFORE_ARK.exec(text))) {
|
|
1234
|
+
if (match[0] !== want) {
|
|
1235
|
+
stale.push(rel);
|
|
1236
|
+
break;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
for (const rel of COMMAND_GATE_JSON_FILES) {
|
|
1241
|
+
let json;
|
|
1242
|
+
try {
|
|
1243
|
+
json = JSON.parse(fs.readFileSync(path.join(root, rel), 'utf8'));
|
|
1244
|
+
} catch {
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
const ark = json?.mcpServers?.ark;
|
|
1248
|
+
if (ark && ark.command && ark.command !== want.split(' ')[0]) stale.push(rel);
|
|
1249
|
+
}
|
|
1250
|
+
return stale;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
// When more than one lockfile is present the project is ambiguous. detectPackageManager()
|
|
1254
|
+
// resolves it (package-lock.json wins so a stray pnpm-lock.yaml can't hijack an npm project),
|
|
1255
|
+
// but the user should know it happened and how to make it explicit — otherwise a leftover
|
|
1256
|
+
// lockfile silently steers which runner every emitted command uses.
|
|
1257
|
+
export function warnLockfileConflict(root) {
|
|
1258
|
+
const locks = presentLockfiles(root);
|
|
1259
|
+
if (locks.length <= 1) return;
|
|
1260
|
+
const chosen = detectPackageManager(root);
|
|
1261
|
+
const files = { pnpm: 'pnpm-lock.yaml', yarn: 'yarn.lock', npm: 'package-lock.json' };
|
|
1262
|
+
console.log('');
|
|
1263
|
+
console.log(
|
|
1264
|
+
`Note: multiple lockfiles present (${locks.map((pm) => files[pm]).join(', ')}). Treating this`
|
|
1265
|
+
);
|
|
1266
|
+
console.log(
|
|
1267
|
+
`as a ${chosen} project — Ark commands use "${execRunner(root)}". If that's wrong, set`
|
|
1268
|
+
);
|
|
1269
|
+
console.log(
|
|
1270
|
+
'"packageManager" in package.json (e.g. "pnpm@9") to declare it, or remove the stray lockfile.'
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// --migrate-commands: rewrite ONLY the Ark command runner in existing gate files to the
|
|
1275
|
+
// project's package manager (no --force clobber). Closes the upgrade gap where a repo that
|
|
1276
|
+
// adopted before the package-manager-aware templates keeps a stale `npx`.
|
|
1277
|
+
// Also normalizes MCP JSON to a single preferred bin (arkgate-mcp), stripping any dual
|
|
1278
|
+
// ark-mcp + arkgate-mcp residue left by partial renames during package identity cutover.
|
|
1279
|
+
export function runMigrateCommands(root) {
|
|
1280
|
+
const runner = execRunner(root);
|
|
1281
|
+
const changed = [];
|
|
1282
|
+
for (const rel of COMMAND_GATE_TEXT_FILES) {
|
|
1283
|
+
const full = path.join(root, rel);
|
|
1284
|
+
let text;
|
|
1285
|
+
try {
|
|
1286
|
+
text = fs.readFileSync(full, 'utf8');
|
|
1287
|
+
} catch {
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
let next = text.replace(RUNNER_BEFORE_ARK, runner);
|
|
1291
|
+
// Prefer primary product bins in command strings (aliases still work if left alone).
|
|
1292
|
+
next = next
|
|
1293
|
+
.replace(/\bark-mcp\b/g, PREFERRED_MCP_BIN)
|
|
1294
|
+
.replace(/\bark-check\b/g, PREFERRED_CHECK_BIN);
|
|
1295
|
+
// Do not blanket-replace bare `ark` — it appears in prose ("Ark check", product name).
|
|
1296
|
+
if (next !== text) {
|
|
1297
|
+
fs.writeFileSync(full, next);
|
|
1298
|
+
changed.push(rel);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
for (const rel of COMMAND_GATE_JSON_FILES) {
|
|
1302
|
+
const full = path.join(root, rel);
|
|
1303
|
+
let json;
|
|
1304
|
+
try {
|
|
1305
|
+
json = JSON.parse(fs.readFileSync(full, 'utf8'));
|
|
1306
|
+
} catch {
|
|
1307
|
+
continue;
|
|
1308
|
+
}
|
|
1309
|
+
const ark = json?.mcpServers?.ark;
|
|
1310
|
+
if (!ark) continue;
|
|
1311
|
+
const binArgs = stripMcpServerArgs(ark.args);
|
|
1312
|
+
const parts = execCommandParts(root, PREFERRED_MCP_BIN, binArgs);
|
|
1313
|
+
if (ark.command !== parts.command || JSON.stringify(ark.args) !== JSON.stringify(parts.args)) {
|
|
1314
|
+
json.mcpServers.ark = { ...ark, ...parts };
|
|
1315
|
+
fs.writeFileSync(full, `${JSON.stringify(json, null, 2)}\n`);
|
|
1316
|
+
changed.push(rel);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
const pm = runner === 'pnpm exec' || runner.startsWith('pnpm ') ? 'pnpm' : runner;
|
|
1320
|
+
console.log(`Migrated ArkGate command runners to "${pm}" and normalized MCP bins in gate files.`);
|
|
1321
|
+
if (changed.length === 0) {
|
|
1322
|
+
console.log(' Nothing to change — runners and MCP bins already look correct.');
|
|
1323
|
+
} else {
|
|
1324
|
+
for (const rel of changed) console.log(` updated ${rel}`);
|
|
1325
|
+
console.log(
|
|
1326
|
+
` (runner + single MCP bin \`${PREFERRED_MCP_BIN}\`; customized non-command content is untouched.)`
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
warnLockfileConflict(root);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
export function runInstallAgentGates(args) {
|
|
1333
|
+
const root = args.root;
|
|
1334
|
+
if (args.migrateCommands) {
|
|
1335
|
+
runMigrateCommands(root);
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
if (args.tools) {
|
|
1339
|
+
const unknown = args.tools.filter((tool) => !KNOWN_TOOLS.includes(tool));
|
|
1340
|
+
if (args.tools.length === 0 || unknown.length > 0) {
|
|
1341
|
+
console.error(
|
|
1342
|
+
`--tools expects a comma-separated subset of: ${KNOWN_TOOLS.join(', ')}` +
|
|
1343
|
+
(unknown.length > 0 ? ` (unknown: ${unknown.join(', ')})` : '')
|
|
1344
|
+
);
|
|
1345
|
+
process.exitCode = 2;
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
const pm = packageManager(root);
|
|
1350
|
+
const hasCheckScript = hasCheckArchitectureScript(root);
|
|
1351
|
+
const { tools, source } = resolveTools(args);
|
|
1352
|
+
const toolSource =
|
|
1353
|
+
source === 'explicit'
|
|
1354
|
+
? 'from --tools'
|
|
1355
|
+
: source === 'detected'
|
|
1356
|
+
? 'auto-detected from config dirs'
|
|
1357
|
+
: 'default set — no agent config dirs found';
|
|
1358
|
+
console.log(`Agent gates for: ${[...tools].sort().join(', ')} (${toolSource})`);
|
|
1359
|
+
const templates = [];
|
|
1360
|
+
// --skills-only refreshes just the canonical /ark-* skills, which are safe to
|
|
1361
|
+
// overwrite (they track the package). The gate/instruction files (AGENTS.md,
|
|
1362
|
+
// settings.json, CI workflow, rules) are the ones users customize, so a plain
|
|
1363
|
+
// `--force` clobbers them — this is the safe way to pick up new skill versions.
|
|
1364
|
+
if (!args.skillsOnly) {
|
|
1365
|
+
// Base gates: tool-agnostic contract + CI backstop, always written.
|
|
1366
|
+
templates.push(['AGENTS.md', agentInstructions(root)]);
|
|
1367
|
+
templates.push(['.mcp.json', mcpJson(root)]);
|
|
1368
|
+
templates.push([
|
|
1369
|
+
'.github/workflows/ark-check.yml',
|
|
1370
|
+
githubWorkflow(pm, detectCiNode(root)),
|
|
1371
|
+
]);
|
|
1372
|
+
if (tools.has('cursor')) {
|
|
1373
|
+
templates.push(['.cursor/mcp.json', mcpJson(root)]);
|
|
1374
|
+
templates.push(['.cursor/rules/ark.mdc', cursorRule(root)]);
|
|
1375
|
+
}
|
|
1376
|
+
if (tools.has('claude')) {
|
|
1377
|
+
templates.push(['.claude/settings.json', claudeSettings(root)]);
|
|
1378
|
+
}
|
|
1379
|
+
if (tools.has('codex')) {
|
|
1380
|
+
templates.push(['docs/ark-codex-config.toml', codexTomlSnippet(root)]);
|
|
1381
|
+
}
|
|
1382
|
+
if (tools.has('grok')) {
|
|
1383
|
+
templates.push(['.grok/config.toml', grokProjectConfig(root)]);
|
|
1384
|
+
templates.push(['.grok/hooks/ark-write-gate.json', grokHooks(root)]);
|
|
1385
|
+
}
|
|
1386
|
+
// Instruction-tier hosts: one shared rule text, host-specific path.
|
|
1387
|
+
if (tools.has('windsurf')) {
|
|
1388
|
+
templates.push(['.windsurf/rules/ark.md', instructionRule(root)]);
|
|
1389
|
+
}
|
|
1390
|
+
if (tools.has('cline')) {
|
|
1391
|
+
templates.push(['.clinerules/ark.md', instructionRule(root)]);
|
|
1392
|
+
}
|
|
1393
|
+
if (tools.has('copilot')) {
|
|
1394
|
+
templates.push(['.github/copilot-instructions.md', instructionRule(root)]);
|
|
1395
|
+
}
|
|
1396
|
+
if (tools.has('kiro')) {
|
|
1397
|
+
templates.push(['.kiro/steering/ark.md', instructionRule(root)]);
|
|
1398
|
+
}
|
|
1399
|
+
if (tools.has('roo')) {
|
|
1400
|
+
templates.push(['.roo/rules/ark.md', instructionRule(root)]);
|
|
1401
|
+
}
|
|
1402
|
+
if (tools.has('continue')) {
|
|
1403
|
+
templates.push(['.continue/rules/ark.md', instructionRule(root)]);
|
|
1404
|
+
}
|
|
1405
|
+
// Gemini CLI reads GEMINI.md as its primary project context (it also reads
|
|
1406
|
+
// AGENTS.md, but GEMINI.md wins when both are present), so the rule lives there.
|
|
1407
|
+
if (tools.has('gemini')) {
|
|
1408
|
+
templates.push(['GEMINI.md', instructionRule(root)]);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
// /ark-* skills for every detected tool that supports project-level commands.
|
|
1412
|
+
// Stamp each with the shipping version so a later ark-check can flag skills
|
|
1413
|
+
// left behind by an older Ark (see detectSkillGaps) without nagging about
|
|
1414
|
+
// user edits to the body.
|
|
1415
|
+
const version = arkPackageVersion();
|
|
1416
|
+
const skills = skillTemplates().map(([name, content]) => [name, stampSkill(content, version)]);
|
|
1417
|
+
const skillPaths = new Set();
|
|
1418
|
+
for (const tool of tools) {
|
|
1419
|
+
const target = SKILL_TOOL_TARGETS[tool];
|
|
1420
|
+
if (!target) continue;
|
|
1421
|
+
for (const [name, content] of skills) {
|
|
1422
|
+
const relativePath = target(name);
|
|
1423
|
+
skillPaths.add(relativePath);
|
|
1424
|
+
templates.push([relativePath, content]);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
const results = templates.map(([relativePath, content]) =>
|
|
1429
|
+
writeTemplate(root, relativePath, content, args.force)
|
|
1430
|
+
);
|
|
1431
|
+
|
|
1432
|
+
console.log('Ark agent gate templates:');
|
|
1433
|
+
let staleSkipped = 0;
|
|
1434
|
+
for (const result of results) {
|
|
1435
|
+
const marker =
|
|
1436
|
+
result.status === 'written' ? 'wrote' : result.status === 'failed' ? 'FAILED' : 'skipped';
|
|
1437
|
+
// A skipped skill reads as "you're fine" — but it may be a version behind.
|
|
1438
|
+
// Say which, so the user isn't left guessing (and knows the safe refresh cmd).
|
|
1439
|
+
let note = '';
|
|
1440
|
+
if (result.status === 'skipped' && skillPaths.has(result.relativePath) && version) {
|
|
1441
|
+
const installed = installedSkillVersion(path.join(root, result.relativePath));
|
|
1442
|
+
if (installed === null || isVersionOlder(installed, version)) {
|
|
1443
|
+
staleSkipped += 1;
|
|
1444
|
+
note = ` (stale: ${installed ?? 'no stamp'} < ${version})`;
|
|
1445
|
+
} else {
|
|
1446
|
+
note = ' (up to date)';
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
console.log(` ${marker.padEnd(7)} ${result.relativePath}${note}`);
|
|
1450
|
+
}
|
|
1451
|
+
if (staleSkipped > 0 && !args.skillsOnly) {
|
|
1452
|
+
console.log('');
|
|
1453
|
+
console.log(
|
|
1454
|
+
` ${staleSkipped} skill(s) are outdated but were left untouched. Refresh them with:`
|
|
1455
|
+
);
|
|
1456
|
+
console.log(` ${arkCommand(root, 'ark-check', '--install-agent-gates --skills-only --force')}`);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
// --codex-home writes the canonical skills straight to $CODEX_HOME/prompts.
|
|
1460
|
+
// Codex reads prompts from there (not the repo), so this is the only way to
|
|
1461
|
+
// refresh them for a repo that isn't itself configured for Codex. It writes to
|
|
1462
|
+
// the user's home dir, hence explicit opt-in rather than part of a normal run.
|
|
1463
|
+
const homeResults = [];
|
|
1464
|
+
if (args.codexHome) {
|
|
1465
|
+
const dir = codexPromptsDir();
|
|
1466
|
+
console.log('');
|
|
1467
|
+
console.log(`Codex home skills (${dir}):`);
|
|
1468
|
+
try {
|
|
1469
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1470
|
+
} catch (error) {
|
|
1471
|
+
console.error(` FAILED to create ${dir} (${error.message})`);
|
|
1472
|
+
homeResults.push({ status: 'failed' });
|
|
1473
|
+
}
|
|
1474
|
+
if (homeResults.length === 0) {
|
|
1475
|
+
for (const [name, content] of skills) {
|
|
1476
|
+
const file = path.join(dir, `${name}.md`);
|
|
1477
|
+
if (fs.existsSync(file) && !args.force) {
|
|
1478
|
+
const installed = installedSkillVersion(file);
|
|
1479
|
+
const behind = installed === null || (version && isVersionOlder(installed, version));
|
|
1480
|
+
const note = behind
|
|
1481
|
+
? ` (stale: ${installed ?? 'no stamp'} < ${version}; use --force)`
|
|
1482
|
+
: ' (up to date)';
|
|
1483
|
+
console.log(` ${'skipped'.padEnd(7)} ${name}.md${note}`);
|
|
1484
|
+
homeResults.push({ status: 'skipped' });
|
|
1485
|
+
continue;
|
|
1486
|
+
}
|
|
1487
|
+
try {
|
|
1488
|
+
fs.writeFileSync(file, content);
|
|
1489
|
+
console.log(` ${'wrote'.padEnd(7)} ${name}.md`);
|
|
1490
|
+
homeResults.push({ status: 'written' });
|
|
1491
|
+
} catch (error) {
|
|
1492
|
+
console.log(` ${'FAILED'.padEnd(7)} ${name}.md (${error.message})`);
|
|
1493
|
+
homeResults.push({ status: 'failed' });
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
// Auto-wire the ark MCP server into Codex's home config.toml. Claude and Cursor get
|
|
1500
|
+
// machine-readable registrations (.claude/settings.json, .cursor/mcp.json) written as repo
|
|
1501
|
+
// templates above; Codex reads MCP servers only from ~/.codex/config.toml, so it needs a
|
|
1502
|
+
// home-dir merge instead. Fires whenever Codex is in play so `ark://manifest` is live
|
|
1503
|
+
// without a manual copy step.
|
|
1504
|
+
let codexMcp = null;
|
|
1505
|
+
if (tools.has('codex') || args.codexHome) {
|
|
1506
|
+
codexMcp = wireCodexMcp(root, args.force);
|
|
1507
|
+
console.log('');
|
|
1508
|
+
console.log(`Codex MCP registration (${codexMcp.file}):`);
|
|
1509
|
+
if (codexMcp.status === 'skipped') {
|
|
1510
|
+
console.log(` ${'skipped'.padEnd(7)} [mcp_servers.ark] already present (use --force to overwrite)`);
|
|
1511
|
+
} else if (codexMcp.status === 'failed') {
|
|
1512
|
+
console.log(` ${'FAILED'.padEnd(7)} [mcp_servers.ark] (${codexMcp.message})`);
|
|
1513
|
+
} else {
|
|
1514
|
+
const verb = codexMcp.status === 'updated' ? 'updated' : 'wrote';
|
|
1515
|
+
console.log(` ${verb.padEnd(7)} [mcp_servers.ark] with absolute paths`);
|
|
1516
|
+
console.log(' RESTART Codex — it does not hot-load MCP servers.');
|
|
1517
|
+
console.log(' Then expect: resource ark://manifest + tools validate_code, ark_check, ark_coverage, ark_place.');
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
const failed = [...results, ...homeResults, ...(codexMcp ? [codexMcp] : [])].filter((result) => result.status === 'failed');
|
|
1522
|
+
if (failed.length > 0) {
|
|
1523
|
+
console.error(`\nFailed to write ${failed.length} template(s).`);
|
|
1524
|
+
process.exitCode = 1;
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
console.log('');
|
|
1528
|
+
console.log('Next steps:');
|
|
1529
|
+
console.log(' 1. Review the generated files and commit the ones that match your tools.');
|
|
1530
|
+
console.log(` 2. Run: ${arkCheckCommand(root)}`);
|
|
1531
|
+
if (!hasCheckScript) {
|
|
1532
|
+
console.log(' 3. Add the package.json alias if you want `run check:architecture`:');
|
|
1533
|
+
console.log(` ${checkArchitectureScriptSnippet(root)}`);
|
|
1534
|
+
}
|
|
1535
|
+
if ((tools.has('codex') || args.codexHome)) {
|
|
1536
|
+
console.log('');
|
|
1537
|
+
if (codexMcp && codexMcp.status !== 'failed') {
|
|
1538
|
+
console.log(` Codex: ark MCP registered in ${codexMcp.file} — restart Codex so \`ark://manifest\` loads.`);
|
|
1539
|
+
}
|
|
1540
|
+
if (args.codexHome) {
|
|
1541
|
+
console.log(` Codex: refreshed the /ark-* skills in ${codexPromptsDir()} — Codex loads them from there.`);
|
|
1542
|
+
} else if (skills.length > 0) {
|
|
1543
|
+
console.log(' Codex loads slash-command prompts from $CODEX_HOME/prompts (~/.codex/prompts),');
|
|
1544
|
+
console.log(' not the repo. Install the /ark-* skills there with:');
|
|
1545
|
+
console.log(` ${arkCommand(root, 'ark-check', '--install-agent-gates --codex-home')}`);
|
|
1546
|
+
console.log(' (writes to your home dir; agents driving this setup should offer to run it).');
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
warnLockfileConflict(root);
|
|
1550
|
+
}
|