@harnesspm/cli 0.0.0-snapshot.cf808a1 → 0.0.0-snapshot.ebd6c58

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/dist/commands.js CHANGED
@@ -14,14 +14,15 @@ import { fetchLocked, locateLocked } from './fetch.js';
14
14
  import { createPatch, createUnit, KINDS, resolveTarget } from './new.js';
15
15
  import { reviewedState } from './reviewed.js';
16
16
  import { runMcp, runScript } from './run.js';
17
- import { pathTools } from './outputs.js';
17
+ import { DOCS_EXCLUDE, DOCS_PROBE, pathTools } from './outputs.js';
18
+ import { afterInit, EVERY_COMMAND, nextAfterNew, startText, version } from './start.js';
18
19
  import { alwaysOnText, blockRange, helpTarget, ruleBodyWithoutTitle } from './render.js';
19
20
  import { describeMembers, localRuleChanges, resolve, resolvePackageDir, rulesForDirectory } from './resolve.js';
20
21
  import { demoteHeadings } from './sections.js';
21
22
  import { tryFrontmatter } from './frontmatter.js';
22
23
  import { commandCaller, describeSend, outsideField, readIndex, readTelemetryState, sendEvent } from './telemetry.js';
23
24
  import { migrateSessionHook, userHeld, writeUserOutputs, writeUserSettings } from './user-outputs.js';
24
- import { HarnessError, NPX_ANY, OLD_PACKAGE_NAMES, PACKAGE_NAME, PACKAGE_NAMES, addExclude, codexRun, gitExcludeFile, inCloudSession, insideDir, isDir, isFile, isRecord, readJson, readJsonIfExists, readTextIfExists, relPosix, runner, shellWord, writeIfChanged } from './util.js';
25
+ import { HarnessError, NPX_ANY, OLD_PACKAGE_NAMES, PACKAGE_NAME, PACKAGE_NAMES, addExclude, codexRun, gitExclude, gitExcludeFile, gitIgnoreSource, inCloudSession, insideDir, isDir, isFile, isRecord, readJson, readJsonIfExists, readTextIfExists, relPosix, runner, shellWord, writeIfChanged } from './util.js';
25
26
  import { spawnSync } from 'node:child_process';
26
27
  const printWarnings = (out, warnings) => {
27
28
  for (const w of [...new Set(warnings)])
@@ -42,15 +43,22 @@ function grantStep(projectDir, inTerminal) {
42
43
  const firstThree = (items) => `${items.slice(0, 3).join('; ')}${items.length > 3 ? '; …' : ''}`;
43
44
  const heldList = (report) => `${plural(report.held.length, 'entry', 'entries')} that an agent cannot grant (${firstThree(report.held)})${report.why !== undefined ? `, because ${report.why}` : ''}`;
44
45
  const unwrittenList = ({ entries, branch }) => `${plural(entries.length, 'entry', 'entries')} that ${branch} records (${firstThree(entries)})`;
45
- function printPending(out, report, projectDir) {
46
- for (const line of [...new Set(report.pending)])
47
- out.log(`⏳ pending: ${line}`);
48
- if (report.unwritten)
49
- out.log(`⏳ not written yet: ${unwrittenList(report.unwritten)}. Run \`${NPX_ANY} sync\`.`);
50
- if (report.held.length > 0) {
51
- out.log(`⏳ held back: ${heldList(report)}.`);
52
- out.log(` ${grantStep(projectDir, `Ask the person to run \`${NPX_ANY} sync\` or \`${NPX_ANY} approve\` in their own terminal.`)}`);
53
- }
46
+ /** The person's step for everything an agent cannot grant itself (spec 6.2, rule 4). */
47
+ const APPROVE = `A person runs \`${NPX_ANY} approve\` in their own terminal.`;
48
+ const WAITING = '⏳ Waiting for a person';
49
+ /**
50
+ * Everything that waits for a person, one line each with the step that ends the wait: packages to trust or versions to
51
+ * approve, and entries an agent's run held back (spec 6.2). What any sync writes is not a person's step.
52
+ */
53
+ function waitingLines(report, projectDir) {
54
+ return [...new Set(report.pending), ...(report.held.length > 0 ? [`${heldList(report)}. ${grantStep(projectDir, APPROVE)}`] : [])];
55
+ }
56
+ function printWaiting(out, lines) {
57
+ if (lines.length === 0)
58
+ return;
59
+ out.log(WAITING);
60
+ for (const line of lines)
61
+ out.log(` - ${line}`);
54
62
  }
55
63
  /** The repository to work on: the nearest folder with harnesspm.json, else the git root, else `cwd`. */
56
64
  export function findProjectDir(cwd) {
@@ -102,23 +110,36 @@ function resolveAll(projectDir, options) {
102
110
  * so that an install's sync cannot hide a missed sync from a later `sync --check` (spec 6.4, 10.1).
103
111
  */
104
112
  export function sync(cwd, out, options = {}) {
105
- const projectDir = findProjectDir(cwd);
106
113
  if (options.check && options.write)
107
114
  throw new HarnessError('Use either --check or --write, not both.');
108
- if (options.check) {
109
- const { team, full, warnings } = resolveAll(projectDir, { withAdded: false });
110
- const plan = computePlan(team, full);
111
- printWarnings(out, [...warnings, ...plan.warnings]);
112
- const problems = checkPlan(projectDir, plan);
113
- for (const p of problems)
114
- out.log(`❌ ${p}`);
115
- if (problems.length > 0) {
116
- out.log(`Run \`${NPX_ANY} sync\` and commit the result.`);
117
- return 1;
118
- }
119
- out.log('✅ harnesspm outputs are up to date');
115
+ if (options.check)
116
+ return syncCheck(findProjectDir(cwd), out);
117
+ const done = syncProject(cwd, out, options);
118
+ printWaiting(out, waitingLines(done.report, done.projectDir));
119
+ if (options.quiet)
120
120
  return 0;
121
+ if (done.keptCommitted)
122
+ out.log(`CI: committed outputs left as they are; \`${NPX_ANY} sync --check\` compares them, \`sync --write\` writes them.`);
123
+ out.log(done.changed > 0 ? `harnesspm: ${done.what}. Updated ${plural(done.changed, 'file')}.` : `harnesspm: ${done.what}. Nothing changed.`);
124
+ return 0;
125
+ }
126
+ function syncCheck(projectDir, out) {
127
+ const { team, full, warnings } = resolveAll(projectDir, { withAdded: false });
128
+ const plan = computePlan(team, full);
129
+ printWarnings(out, [...warnings, ...plan.warnings]);
130
+ const problems = checkPlan(projectDir, plan);
131
+ for (const p of problems)
132
+ out.log(`❌ ${p}`);
133
+ if (problems.length > 0) {
134
+ out.log(`Run \`${NPX_ANY} sync\` and commit the result.`);
135
+ return 1;
121
136
  }
137
+ out.log('✅ harnesspm outputs are up to date');
138
+ return 0;
139
+ }
140
+ /** Writes every output, as `sync` does, and prints only the warnings. */
141
+ function syncProject(cwd, out, options) {
142
+ const projectDir = findProjectDir(cwd);
122
143
  const resolved = resolveAll(projectDir, { withAdded: true });
123
144
  const { full, mode } = resolved;
124
145
  const warnings = [...resolved.warnings];
@@ -170,19 +191,13 @@ export function sync(cwd, out, options = {}) {
170
191
  if (process.env['CI'] !== 'true' && !model)
171
192
  changed.push(...migrateSessionHook());
172
193
  printWarnings(out, warnings);
173
- printPending(out, report, projectDir);
174
- if (options.quiet)
175
- return 0;
176
- if (keptCommitted)
177
- out.log(`CI: committed outputs left as they are; \`${NPX_ANY} sync --check\` compares them, \`sync --write\` writes them.`);
178
194
  const counts = `${plural(new Set(full.rules.map((r) => r.id)).size, 'rule')}, ${plural(full.skills.length, 'skill')}, ${plural(full.docs.length, 'doc')} from ${plural(full.packages.length, 'package')}`;
179
195
  const above = `Sessions that start here get the hooks of ${plural(children.length, 'project')} below: ${children.map((c) => path.basename(c)).join(', ')}`;
180
196
  const gone = 'No projects below this folder any more: removed what an earlier sync wrote for them';
181
197
  const below = `Added harnesses in ${plural(applied.length, 'repository', 'repositories')} below: ${applied.join(', ')}`;
182
198
  const parts = [...(children.length > 0 ? [above] : parentSync ? [gone] : []), ...(applied.length > 0 ? [below] : [])];
183
199
  const what = mode === 'none' ? (parts.length > 0 ? parts.join('. ') : 'Nothing to do in this folder') : mode === 'added-only' ? `Added harnesses only: ${counts}` : counts;
184
- out.log(changed.length > 0 ? `harnesspm: ${what}. Updated ${plural(changed.length, 'file')}.` : `harnesspm: ${what}. Nothing changed.`);
185
- return 0;
200
+ return { projectDir, report, what, mode, changed: changed.length, keptCommitted };
186
201
  }
187
202
  /**
188
203
  * Writes one project's outputs, as `sync` in it does. `keepCommitted` leaves the committed outputs as they are and
@@ -273,17 +288,75 @@ function harnesspmDependency(pkg) {
273
288
  }));
274
289
  }
275
290
  const dependsOnHarnesspm = (pkg) => harnesspmDependency(pkg) !== undefined;
276
- /** Lockfiles that an install changes, with the install that each one asks for. */
277
- const INSTALLS = {
278
- 'package-lock.json': 'npm ci',
279
- 'npm-shrinkwrap.json': 'npm ci',
280
- 'pnpm-lock.yaml': 'pnpm install',
281
- 'yarn.lock': 'yarn install',
282
- 'bun.lock': 'bun install',
283
- 'bun.lockb': 'bun install',
291
+ /** Lockfiles that an install changes, with the package manager that writes each one. */
292
+ const LOCKS = {
293
+ 'package-lock.json': 'npm',
294
+ 'npm-shrinkwrap.json': 'npm',
295
+ 'pnpm-lock.yaml': 'pnpm',
296
+ 'yarn.lock': 'yarn',
297
+ 'bun.lock': 'bun',
298
+ 'bun.lockb': 'bun',
299
+ };
300
+ /** The install that each package manager's lockfile asks for, and its command that adds a dev dependency. */
301
+ const MANAGERS = {
302
+ npm: { install: 'npm ci', add: 'npm i -D' },
303
+ pnpm: { install: 'pnpm install', add: 'pnpm add -D' },
304
+ yarn: { install: 'yarn install', add: 'yarn add -D' },
305
+ bun: { install: 'bun install', add: 'bun add -d' },
284
306
  };
285
307
  /** `init` names the lockfile the project has with the files to commit. */
286
- const LOCKFILES = Object.keys(INSTALLS);
308
+ const LOCKFILES = Object.keys(LOCKS);
309
+ const lockfileOf = (projectDir) => LOCKFILES.find((file) => isFile(path.join(projectDir, file)));
310
+ /** The project's package manager: by its lockfile, else by its `packageManager` field, else npm. */
311
+ function managerOf(projectDir, pkg) {
312
+ const lock = lockfileOf(projectDir);
313
+ if (lock !== undefined)
314
+ return LOCKS[lock];
315
+ const field = typeof pkg['packageManager'] === 'string' ? /^(npm|pnpm|yarn|bun)@/.exec(pkg['packageManager'])?.[1] : undefined;
316
+ return field ?? 'npm';
317
+ }
318
+ /**
319
+ * Yarn 2 and later install with Plug'n'Play unless `.yarnrc.yml` sets another `nodeLinker`. Plug'n'Play writes no
320
+ * `node_modules`, where harnesspm finds each package's harness, so harnesspm supports Yarn with `nodeLinker: node-modules`.
321
+ */
322
+ function yarnPnp(projectDir) {
323
+ if (isFile(path.join(projectDir, '.pnp.cjs')))
324
+ return true;
325
+ const rc = readTextIfExists(path.join(projectDir, '.yarnrc.yml'));
326
+ return rc !== undefined && !/^nodeLinker:\s*["']?node-modules\b/m.test(rc);
327
+ }
328
+ /**
329
+ * Adds harnesspm as a dev dependency with the project's package manager, at this version or a later compatible one
330
+ * (spec 10.1), and returns the command. A workspace root needs pnpm's `-w` and Yarn 1's `-W`. The package manager's
331
+ * own output goes to stderr, so the report on stdout stays as `init` prints it.
332
+ */
333
+ function installHarnesspm(projectDir, manager, pkg) {
334
+ const root = manager === 'pnpm' ? isFile(path.join(projectDir, 'pnpm-workspace.yaml')) : manager === 'yarn' && 'workspaces' in pkg && !isFile(path.join(projectDir, '.yarnrc.yml'));
335
+ const add = `${MANAGERS[manager].add}${root ? (manager === 'pnpm' ? ' -w' : ' -W') : ''}`;
336
+ const own = version();
337
+ const spec = `${PACKAGE_NAME}@${own.includes('-') ? own : `^${own}`}`;
338
+ const windows = process.platform === 'win32';
339
+ const [command, ...args] = add.split(' ');
340
+ const result = spawnSync(windows ? `${add} ${spec}` : command, windows ? [] : [...args, spec], { cwd: projectDir, stdio: ['ignore', 2, 2], shell: windows });
341
+ if (result.status !== 0) {
342
+ throw new HarnessError(`\`${add} ${spec}\` failed${result.error ? ` (${result.error.message})` : ''}, so init stopped before it changed anything. Add ${PACKAGE_NAME} as a dev dependency yourself, then run \`${NPX_ANY} init\` again.`);
343
+ }
344
+ return add;
345
+ }
346
+ /**
347
+ * Adds `/.harnesspm/` to the project folder's `.gitignore`, so formatters skip the docs copies (spec 4.3, note 8), unless
348
+ * a `.gitignore` already ignores the folder. Only `init` edits `.gitignore`, and only this line. False outside git.
349
+ */
350
+ function ignoreDocsCopies(projectDir) {
351
+ if (gitExclude(projectDir) === undefined)
352
+ return false;
353
+ const source = gitIgnoreSource(projectDir, DOCS_PROBE);
354
+ if (typeof source === 'string' && !path.isAbsolute(source) && path.basename(source) === '.gitignore')
355
+ return false;
356
+ const file = path.join(projectDir, '.gitignore');
357
+ const text = readTextIfExists(file) ?? '';
358
+ return writeIfChanged(file, `${text}${text === '' || text.endsWith('\n') ? '' : '\n'}${DOCS_EXCLUDE}\n`);
359
+ }
287
360
  /**
288
361
  * The project's install for a Claude Code cloud environment's setup script (spec 9.1), or undefined when it is not
289
362
  * known. It names the project by its absolute path, because the setup script does not start in the clone. A pinned
@@ -294,20 +367,20 @@ function setupLine(projectDir) {
294
367
  // A folder above projects: its sync, after the projects' installs (spec 4.10).
295
368
  if (isParentFolder(projectDir))
296
369
  return `cd ${/^[\w./-]+$/.test(projectDir) ? projectDir : `'${projectDir.replaceAll("'", "'\\''")}'`} && ${NPX_ANY} sync`;
297
- const lock = LOCKFILES.find((file) => isFile(path.join(projectDir, file)));
370
+ const lock = lockfileOf(projectDir);
298
371
  if (lock === undefined || !isFile(path.join(projectDir, CONFIG_FILE)))
299
372
  return undefined;
300
373
  const pkg = readJsonIfExists(path.join(projectDir, 'package.json'));
301
374
  const corepack = isRecord(pkg) && typeof pkg['packageManager'] === 'string' ? 'corepack enable && COREPACK_NPM_REGISTRY=https://registry.npmjs.org ' : '';
302
375
  const dir = /^[\w./-]+$/.test(projectDir) ? projectDir : `'${projectDir.replaceAll("'", "'\\''")}'`;
303
- return `cd ${dir} && ${corepack}${INSTALLS[lock]}`;
376
+ return `cd ${dir} && ${corepack}${MANAGERS[LOCKS[lock]].install}`;
304
377
  }
305
378
  /** The committed files (spec 1.7) that git sees as new or changed, in a fixed order. Empty outside git. */
306
379
  function filesToCommit(projectDir) {
307
380
  const { team, full } = resolveAll(projectDir, { withAdded: false });
308
381
  const committed = team ? computePlan(team, full).committed : undefined;
309
382
  const nested = committed ? [...committed.workspaces.filter((ws) => ws.agentsMd !== undefined).map((ws) => path.join(ws.dir, 'AGENTS.md')), ...committed.claudeMds.map((c) => c.file)] : [];
310
- const candidates = [...new Set(['AGENTS.md', 'CLAUDE.md', ...nested.map((file) => relPosix(projectDir, file)), CONFIG_FILE, LOCK_FILE, 'package.json', ...LOCKFILES])];
383
+ const candidates = [...new Set(['.gitignore', 'AGENTS.md', 'CLAUDE.md', ...nested.map((file) => relPosix(projectDir, file)), CONFIG_FILE, LOCK_FILE, 'package.json', ...LOCKFILES])];
311
384
  // The short format shows paths relative to the current folder, also in a subfolder of the repository.
312
385
  const result = spawnSync('git', ['status', '--short', '--untracked-files=all', '--', ...candidates], { cwd: projectDir, encoding: 'utf8' });
313
386
  if (result.status !== 0)
@@ -315,24 +388,75 @@ function filesToCommit(projectDir) {
315
388
  const changed = new Set(result.stdout.split('\n').filter((line) => line.length > 3).map((line) => line.slice(3).replace(/^.* -> /, '')));
316
389
  return candidates.filter((file) => changed.has(file));
317
390
  }
391
+ /** More tool lines than this, and `init` lists one line per package instead. */
392
+ const TOOL_LINES = 8;
393
+ /**
394
+ * The executable units of the packages that the project does not trust yet, as `init` lists them: each tool with what
395
+ * it does and whether it runs without a prompt, the hooks and MCP servers, or one line per package when there are many.
396
+ */
397
+ function untrustedTools(team) {
398
+ const rows = [];
399
+ const perPackage = [];
400
+ const packages = [];
401
+ for (const pkg of team.packages) {
402
+ if (pkg.layer !== 'dependencies' || team.config.trust[pkg.name] !== undefined)
403
+ continue;
404
+ const scripts = team.scripts.filter((s) => s.pkg === pkg);
405
+ const hooks = team.hooks.filter((h) => h.pkg === pkg);
406
+ const servers = team.mcp.filter((m) => m.pkg === pkg);
407
+ if (scripts.length + hooks.length + servers.length === 0)
408
+ continue;
409
+ packages.push(pkg.name);
410
+ const tools = scripts.filter((s) => s.description !== undefined);
411
+ for (const s of tools) {
412
+ const events = [...new Set(hooks.filter((h) => h.run === s.name).map((h) => h.event))];
413
+ rows.push([pkg.name, `${pkg.plugin}:${s.name} — ${s.description}${s.allow ? ' · no prompt' : ''}${events.length > 0 ? ` · a ${events.join(' and ')} hook runs it` : ''}`]);
414
+ }
415
+ for (const h of hooks)
416
+ if (!tools.some((s) => s.name === h.run))
417
+ rows.push([pkg.name, `a ${h.event} hook runs ${pkg.plugin}:${h.run}`]);
418
+ for (const m of servers)
419
+ rows.push([pkg.name, `MCP server ${pkg.plugin}:${m.name}`]);
420
+ const what = [plural(scripts.length, 'script'), plural(hooks.length, 'hook'), plural(servers.length, 'MCP server')].filter((w) => !w.startsWith('0 '));
421
+ perPackage.push([pkg.name, `${what.join(', ')}: \`${NPX_ANY} help ${helpTarget(pkg)}\``]);
422
+ }
423
+ const chosen = rows.length > TOOL_LINES ? perPackage : rows;
424
+ const width = Math.max(0, ...chosen.map(([name]) => name.length)) + 2;
425
+ return { lines: chosen.map(([name, text]) => ` ${name.padEnd(width)}${text}`), packages };
426
+ }
427
+ /**
428
+ * `harnesspm init` (spec 10.1): installs harnesspm when the project does not list it, writes the configuration, the
429
+ * install hook, the import in CLAUDE.md and the `.gitignore` line, syncs, and reports what waits for a person and what
430
+ * to commit.
431
+ */
318
432
  export function init(projectDir, out) {
319
433
  const pkgFile = path.join(projectDir, 'package.json');
320
434
  if (!isFile(pkgFile))
321
- throw new HarnessError('No package.json here. Run `npm init` first.');
322
- const raw = readTextIfExists(pkgFile);
323
- const pkg = readJson(pkgFile);
435
+ throw new HarnessError(`No package.json here, so there is no project to set up. \`${NPX_ANY}\` names the tasks for this folder.`);
436
+ let pkg = readJson(pkgFile);
324
437
  if (!isRecord(pkg))
325
438
  throw new HarnessError('package.json must be a JSON object');
326
- // The script that `init` adds calls the `harnesspm` command. Without the dependency, the next install fails with
327
- // "harnesspm: not found" (research/package-managers.md). So stop before anything changes.
328
- const dependency = harnesspmDependency(pkg);
439
+ const manager = managerOf(projectDir, pkg);
440
+ if (manager === 'yarn' && yarnPnp(projectDir)) {
441
+ throw new HarnessError(`This project uses Yarn Plug'n'Play, which writes no node_modules, where harnesspm finds each package's harness. Set \`nodeLinker: node-modules\` in .yarnrc.yml, run \`yarn install\`, then run \`${NPX_ANY} init\` again.`);
442
+ }
443
+ // The script that `init` adds calls the `harnesspm` command, so the project must list harnesspm: without it, the next
444
+ // install fails with "harnesspm: not found" (research/package-managers.md). Install it first, before anything changes.
445
+ let dependency = harnesspmDependency(pkg);
329
446
  if (dependency === undefined) {
330
- throw new HarnessError(`${PACKAGE_NAME} is not a dependency of this project, so the install script that \`init\` adds would fail. Run \`npm i -D ${PACKAGE_NAME}\` first, then \`${NPX_ANY} init\`.`);
447
+ const add = installHarnesspm(projectDir, manager, pkg);
448
+ pkg = readJson(pkgFile);
449
+ dependency = harnesspmDependency(pkg);
450
+ if (!isRecord(pkg) || dependency === undefined)
451
+ throw new HarnessError(`\`${add}\` did not list ${PACKAGE_NAME} in package.json. Add it as a dev dependency yourself, then run \`${NPX_ANY} init\` again.`);
452
+ out.log(`Installed ${PACKAGE_NAME} as a dev dependency (${add})`);
331
453
  }
454
+ const raw = readTextIfExists(pkgFile);
455
+ const wrote = [];
332
456
  const configFile = path.join(projectDir, CONFIG_FILE);
333
457
  if (!isFile(configFile)) {
334
458
  writeIfChanged(configFile, `${JSON.stringify({ $schema: CONFIG_SCHEMA }, null, 2)}\n`);
335
- out.log(`Created ${CONFIG_FILE}`);
459
+ wrote.push(CONFIG_FILE);
336
460
  }
337
461
  // A private package is never installed by others, so `postinstall` is safe there, and Yarn 2+ runs only
338
462
  // `postinstall`. A published package uses `prepare`, which does not run when others install it.
@@ -344,7 +468,7 @@ export function init(projectDir, out) {
344
468
  const current = typeof scripts[hookName] === 'string' ? scripts[hookName] : undefined;
345
469
  scripts[hookName] = current === undefined ? installHook(dependency) : `${current} && (${installHook(dependency)})`;
346
470
  changed = true;
347
- out.log(`Added \`harnesspm sync\` to the "${hookName}" script`);
471
+ wrote.push(`the "${hookName}" script (syncs on every install)`);
348
472
  }
349
473
  else {
350
474
  for (const name of HOOK_SCRIPTS) {
@@ -364,15 +488,40 @@ export function init(projectDir, out) {
364
488
  }
365
489
  const claude = claudeImport(projectDir);
366
490
  if (writeIfChanged(claude.file, claude.text))
367
- out.log(`${relPosix(projectDir, claude.file)} now imports AGENTS.md`);
368
- const code = sync(projectDir, out, { write: true });
369
- // Say which files belong in git, and that the rest stays out of it, so nobody has to work it out from `git status`.
370
- const toCommit = filesToCommit(projectDir);
371
- if (toCommit.length > 0)
372
- out.log(`To commit: ${toCommit.join(', ')}`);
373
- if (gitExcludeFile(projectDir) !== undefined)
374
- out.log('Links and settings for this machine stay out of git: .git/info/exclude lists them.');
375
- return code;
491
+ wrote.push(`${relPosix(projectDir, claude.file)} (imports AGENTS.md)`);
492
+ if (ignoreDocsCopies(projectDir))
493
+ wrote.push(`.gitignore (${DOCS_EXCLUDE})`);
494
+ if (wrote.length > 0)
495
+ out.log(`Wrote ${wrote.join(', ')}`);
496
+ const done = syncProject(projectDir, out, { write: true });
497
+ out.log(`harnesspm: ${done.what}.${done.mode === 'full' ? ' Agents find them through the block in AGENTS.md.' : ''}`);
498
+ // What waits for a person, with the tools of each package that is not trusted, so the person can decide on trust.
499
+ const { team } = resolveAll(projectDir, { withAdded: false });
500
+ const tools = team ? untrustedTools(team) : { lines: [], packages: [] };
501
+ const others = waitingLines(done.report, projectDir).filter((line) => !tools.packages.some((name) => line.startsWith(`${name}: `)));
502
+ const waiting = tools.lines.length + others.length > 0;
503
+ // Without an installed dependency, the sync wrote no units, and its warning says why.
504
+ const full = done.mode === 'full';
505
+ out.log('');
506
+ if (!waiting)
507
+ out.log(full ? 'Rules, docs, skills and tools work now. Nothing waits for a person.' : 'Nothing waits for a person.');
508
+ else {
509
+ if (full)
510
+ out.log('Rules, docs and skills work now.');
511
+ out.log(`${WAITING}${tools.lines.length > 0 ? ': these tools stay off until a person trusts their package.' : ''}`);
512
+ for (const line of tools.lines)
513
+ out.log(line);
514
+ if (tools.lines.length > 0) {
515
+ const step = inCloudSession() ? `. ${grantStep(projectDir, APPROVE)}` : `, then runs \`${NPX_ANY} approve\` in their own terminal.`;
516
+ out.log(` To turn one on, a person adds its package to "trust" in ${CONFIG_FILE}${step} An agent never changes "trust" itself.`);
517
+ }
518
+ for (const line of others)
519
+ out.log(` - ${line}`);
520
+ }
521
+ out.log('');
522
+ for (const line of afterInit(filesToCommit(projectDir), waiting))
523
+ out.log(line);
524
+ return 0;
376
525
  }
377
526
  /** Directories of editable added harnesses, which agents may write to (spec 8.5). */
378
527
  function writableDirs() {
@@ -591,9 +740,35 @@ function preview(projectDir, resolved) {
591
740
  function describeAdded(h) {
592
741
  return `${h.pkg.plugin} (${h.source.spec}, ${h.scope})${h.entry ? ', with an entry for this repository' : ''}`;
593
742
  }
743
+ /** `harnesspm status`: the project's report (spec 10.5). It always exits 0. */
594
744
  export function status(cwd, out) {
595
- const projectDir = findProjectDir(cwd);
596
- const resolved = resolveAll(projectDir, { withAdded: true });
745
+ report(cwd, out);
746
+ return 0;
747
+ }
748
+ /** `harnesspm doctor`: the same report, which exits 1 when a check fails; what waits for a person does not fail. */
749
+ export function doctor(cwd, out) {
750
+ return report(cwd, out) > 0 ? 1 : 0;
751
+ }
752
+ /** The command that runs harnesspm here: the installed one in a project that uses it (spec 10). */
753
+ const syncCommand = (_projectDir) => `${NPX_ANY} sync`;
754
+ /** A telemetry file inside the project, which harnesspm keeps out of git (spec 14.1). */
755
+ function telemetryFiles(projectDir) {
756
+ const send = readTelemetryState(projectDir).config?.send;
757
+ if (send === undefined || typeof send === 'string')
758
+ return [];
759
+ const rel = relPosix(projectDir, path.resolve(projectDir, send.file));
760
+ return rel.startsWith('../') || path.isAbsolute(rel) ? [] : [rel];
761
+ }
762
+ const linkPointsTo = (link, target) => {
763
+ try {
764
+ return fs.lstatSync(link).isSymbolicLink() && path.resolve(path.dirname(link), fs.readlinkSync(link)) === path.resolve(target);
765
+ }
766
+ catch {
767
+ return false;
768
+ }
769
+ };
770
+ /** The layers and the always-on size: the report's first lines. */
771
+ function summary(projectDir, resolved, plan, out) {
597
772
  const res = resolved.team ?? resolved.full;
598
773
  const deps = res.packages.filter((p) => p.layer === 'dependencies');
599
774
  const describe = (name, version) => `${name} ${version}`;
@@ -615,60 +790,31 @@ export function status(cwd, out) {
615
790
  if (own)
616
791
  projectParts.push(`harness/ (plugin ${own.plugin})`);
617
792
  out.log(`🏢 project ${projectParts.join(' · ')}`);
618
- out.log(`➕ added ${resolved.added.length > 0 ? resolved.added.map(describeAdded).join(' · ') : 'none'}`);
619
- const { plan, report } = preview(projectDir, resolved);
620
- printPending(out, report, projectDir);
621
- if (resolved.team) {
793
+ if (resolved.team && plan?.committed) {
622
794
  const changes = [...new Set(localRuleChanges(resolved.team, resolved.full).map(({ id }) => id))];
623
795
  if (changes.length > 0)
624
796
  out.log(`✏️ changed here ${changes.join(', ')} (by added harnesses; see CLAUDE.local.md)`);
625
797
  const agents = plan.committed.agentsMd;
626
- const bytes = Buffer.byteLength(agents);
627
798
  const claudeLines = agents.split('\n').length + (plan.localMd ?? '').split('\n').length;
628
- out.log(`📏 always-on Codex ${(bytes / 1024).toFixed(1)} KiB of 32 KiB · Claude Code ${claudeLines} lines`);
629
- if (bytes > CODEX_LIMIT)
630
- out.warn(`⚠️ AGENTS.md is over ${CODEX_OVER}. Move details into on-demand rules or docs.`);
631
- else if (bytes > 28 * 1024)
632
- out.warn("⚠️ AGENTS.md is close to Codex's 32 KiB limit. Move details into on-demand rules or docs.");
633
- for (const miss of [...lateBlocks(projectDir, plan), ...codexMisses(projectDir, plan)])
634
- out.warn(`⚠️ ${miss}`);
799
+ out.log(`📏 always-on Codex ${kib(Buffer.byteLength(agents))} of 32 KiB · Claude Code ${claudeLines} lines`);
635
800
  }
636
801
  const telemetry = readTelemetryState(projectDir);
637
802
  if (telemetry.config) {
638
803
  out.log(`📡 telemetry ${telemetry.send !== undefined ? `${[...telemetry.events].join(', ')} → ${describeSend(telemetry.send)}` : telemetry.off}`);
639
804
  }
640
- const local = checkLocalFiles(projectDir, telemetryFiles(projectDir));
641
- if (local && local.problems.length > 0)
642
- out.log(`🩺 local files ${plural(local.problems.length, 'problem')}. Run \`${syncCommand(projectDir).replace(/ sync$/, ' doctor')}\`.`);
643
- printWarnings(out, resolved.warnings);
644
- return 0;
645
- }
646
- /** The command that runs harnesspm here: the installed one in a project that uses it (spec 10). */
647
- const syncCommand = (_projectDir) => `${NPX_ANY} sync`;
648
- /** A telemetry file inside the project, which harnesspm keeps out of git (spec 14.1). */
649
- function telemetryFiles(projectDir) {
650
- const send = readTelemetryState(projectDir).config?.send;
651
- if (send === undefined || typeof send === 'string')
652
- return [];
653
- const rel = relPosix(projectDir, path.resolve(projectDir, send.file));
654
- return rel.startsWith('../') || path.isAbsolute(rel) ? [] : [rel];
655
805
  }
656
- const linkPointsTo = (link, target) => {
657
- try {
658
- return fs.lstatSync(link).isSymbolicLink() && path.resolve(path.dirname(link), fs.readlinkSync(link)) === path.resolve(target);
659
- }
660
- catch {
661
- return false;
662
- }
663
- };
664
806
  /**
665
- * `harnesspm doctor`: whether this repository is ready for harnesses, its own and a person's (spec 10.1).
666
- * It changes nothing. Exits 1 when a check fails; warnings do not fail.
807
+ * The project's report, which `status`, `doctor` and the bare command in a project print (spec 10.5): the layers and
808
+ * sizes, then whether the repository is ready for harnesses, its own and a person's, then what waits for a person. It
809
+ * changes nothing, and each problem names the command that fixes it. Returns the number of failed checks.
667
810
  */
668
- export function doctor(cwd, out) {
811
+ function report(cwd, out) {
669
812
  const projectDir = findProjectDir(cwd);
670
813
  const usesHarnesspm = isFile(path.join(projectDir, CONFIG_FILE));
671
814
  const sync = syncCommand(projectDir);
815
+ const resolved = resolveAll(projectDir, { withAdded: true });
816
+ const { plan, report: waiting } = preview(projectDir, resolved);
817
+ summary(projectDir, resolved, plan, out);
672
818
  const groups = [];
673
819
  // Per-machine files never reach a commit.
674
820
  const local = checkLocalFiles(projectDir, telemetryFiles(projectDir), sync);
@@ -698,13 +844,9 @@ export function doctor(cwd, out) {
698
844
  groups.push(['➕ Harnesses of your own', own]);
699
845
  // Outputs are in place.
700
846
  const outputs = [];
701
- const resolved = resolveAll(projectDir, { withAdded: true });
702
- const { plan, report } = preview(projectDir, resolved);
703
- if (!usesHarnesspm)
704
- outputs.push({ level: 'info', text: `This repository does not use harnesspm (no ${CONFIG_FILE}), so only added harnesses apply.` });
705
- else if (!resolved.team)
847
+ if (usesHarnesspm && !resolved.team)
706
848
  outputs.push({ level: 'warn', text: `The dependencies are not installed. Install them, then run \`${sync}\`.` });
707
- else {
849
+ else if (usesHarnesspm) {
708
850
  const forCheck = resolveAll(projectDir, { withAdded: false });
709
851
  const problems = checkPlan(projectDir, computePlan(forCheck.team, forCheck.full));
710
852
  for (const p of problems)
@@ -725,6 +867,9 @@ export function doctor(cwd, out) {
725
867
  outputs.push({ level: 'warn', text: `${plural(stale, 'per-machine output')} missing or out of date. Run \`${sync}\`.` });
726
868
  else if (total > 0)
727
869
  outputs.push({ level: 'ok', text: `${plural(total, 'per-machine output')} in place` });
870
+ // The repository's entries that any sync writes: not a person's step.
871
+ if (waiting.unwritten)
872
+ outputs.push({ level: 'warn', text: `${unwrittenList(waiting.unwritten)} are not written yet. Run \`${sync}\`.` });
728
873
  if (!plan.codexOurs)
729
874
  outputs.push({ level: 'warn', text: '.codex/ belongs to the repository, so harnesspm writes nothing there and Codex misses some units.' });
730
875
  const pkgJson = readJsonIfExists(path.join(projectDir, 'package.json'));
@@ -743,38 +888,36 @@ export function doctor(cwd, out) {
743
888
  const bytes = plan.committed !== undefined ? Buffer.byteLength(plan.committed.agentsMd) : 0;
744
889
  if (bytes > CODEX_LIMIT)
745
890
  outputs.push({ level: 'warn', text: `AGENTS.md is ${kib(bytes)}, over ${CODEX_OVER}. Move details into on-demand rules or docs.` });
891
+ else if (bytes > 28 * 1024)
892
+ outputs.push({ level: 'warn', text: "AGENTS.md is close to Codex's 32 KiB limit. Move details into on-demand rules or docs." });
746
893
  for (const miss of [...lateBlocks(projectDir, plan), ...codexMisses(projectDir, plan)])
747
894
  outputs.push({ level: 'warn', text: miss });
748
895
  }
749
896
  if (outputs.length > 0)
750
- groups.push(['📦 Outputs', outputs]);
751
- // Trust: pending entries are not errors (spec 10.4).
752
- const trust = [];
753
- // Each pending entry already says how to turn it on: trust the package, or approve a pinned version.
754
- for (const p of new Set(report.pending))
755
- trust.push({ level: 'warn', text: `Off: ${p}` });
756
- if (report.unwritten)
757
- trust.push({ level: 'warn', text: `${unwrittenList(report.unwritten)} are not written yet. Run \`${sync}\`.` });
758
- if (report.held.length > 0)
759
- trust.push({ level: 'warn', text: `${heldList(report)}. ${grantStep(projectDir, `Run \`${NPX_ANY} sync\` in your own terminal.`)}` });
760
- const telemetry = readTelemetryState(projectDir);
761
- // A held handler is in the list above, as `sync` lists it.
762
- const heldHandler = plan?.telemetryHeld !== undefined;
763
- if (telemetry.config && telemetry.send === undefined && !heldHandler)
764
- trust.push({ level: telemetry.off?.startsWith('held') ? 'warn' : 'info', text: `Telemetry ${telemetry.off}` });
765
- if (trust.length === 0 && plan)
766
- trust.push({ level: 'ok', text: 'Nothing waits for trust' });
767
- if (trust.length > 0)
768
- groups.push(['🛡️ Trust', trust]);
897
+ groups.push(['📝 Outputs', outputs]);
769
898
  for (const [title, findings] of groups) {
770
899
  out.log(title);
771
900
  for (const finding of findings)
772
901
  out.log(formatFinding(finding));
773
902
  }
903
+ // Each entry says how to turn it on: trust the package, approve a pinned version, or approve what an agent held back.
904
+ printWaiting(out, waitingLines(waiting, projectDir));
905
+ printWarnings(out, resolved.warnings);
774
906
  const failed = groups.flatMap(([, findings]) => findings).filter((f) => f.level === 'fail').length;
775
907
  out.log('');
776
908
  out.log(failed > 0 ? `❌ ${plural(failed, 'problem')}. Each line above says how to fix it.` : '✅ Ready. Nothing to fix.');
777
- return failed > 0 ? 1 : 0;
909
+ return failed;
910
+ }
911
+ /**
912
+ * The bare command (spec 10.1): in a project that uses harnesspm, its report; elsewhere, what the folder is and the
913
+ * tasks for it, each with the one command that starts it.
914
+ */
915
+ export function start(cwd, out) {
916
+ if (isFile(path.join(findProjectDir(cwd), CONFIG_FILE)))
917
+ return status(cwd, out);
918
+ for (const line of startText(cwd))
919
+ out.log(line);
920
+ return 0;
778
921
  }
779
922
  /** The unit `id` of a resolution, with the rules that apply in `cwd`. */
780
923
  function findUnit(res, cwd, id) {
@@ -914,8 +1057,8 @@ export function toolCommand(projectDir) {
914
1057
  }
915
1058
  /** The project's install, from the caller's folder. */
916
1059
  function installCommand(projectDir) {
917
- const lock = LOCKFILES.find((file) => isFile(path.join(projectDir, file)));
918
- const install = lock !== undefined ? INSTALLS[lock] : 'npm install';
1060
+ const lock = lockfileOf(projectDir);
1061
+ const install = lock !== undefined ? MANAGERS[LOCKS[lock]].install : 'npm install';
919
1062
  return callerInside(projectDir) ? install : `cd ${fromCaller(projectDir)} && ${install}`;
920
1063
  }
921
1064
  /**
@@ -1031,6 +1174,7 @@ function helpView(cwd, out) {
1031
1174
  command: toolCommand(projectDir),
1032
1175
  ...(base !== undefined ? { base } : {}),
1033
1176
  trusted: (pkg) => trustOf(pkg, res, lock).trusted,
1177
+ trust: (pkg) => trustOf(pkg, res, lock),
1034
1178
  paths: {
1035
1179
  rule: (rule) => shown(existing(projectPaths.rule(rule), rule.source)),
1036
1180
  docsIndex: (pkg) => {
@@ -1057,18 +1201,14 @@ function helpIntro(view, out) {
1057
1201
  }
1058
1202
  const count = (n, word) => (n === 1 ? `1 ${word}` : `${n} ${word}s`);
1059
1203
  /**
1060
- * The project's part of `help` (spec 10.1): one line per package, across workspaces, with what it covers and the
1061
- * `help <package>` command that prints the rest.
1204
+ * `help` in a project (spec 10.1): one line per package, across workspaces, with what it covers and the
1205
+ * `help <package>` command that prints the rest. Undefined outside a project that uses harnesspm.
1062
1206
  */
1063
- export function projectHelp(cwd, out, named) {
1207
+ export function projectHelp(cwd, out) {
1064
1208
  const view = helpView(cwd, out);
1065
- if (view === undefined) {
1066
- if (named)
1067
- out.log(`\n${fromCaller(findProjectDir(cwd))} does not use harnesspm: it has no ${CONFIG_FILE}.`);
1068
- return 0;
1069
- }
1209
+ if (view === undefined)
1210
+ return undefined;
1070
1211
  const { res, command } = view;
1071
- out.log('');
1072
1212
  helpIntro(view, out);
1073
1213
  out.log('');
1074
1214
  const lines = res.packages
@@ -1089,10 +1229,16 @@ export function projectHelp(cwd, out, named) {
1089
1229
  return `- ${name}${covers !== '' ? ` — ${covers}` : ''}. ${parts.length > 0 ? `${parts.join(', ')}: ` : ''}\`${command} help ${helpTarget(pkg)}\``;
1090
1230
  });
1091
1231
  out.log(lines.length > 0 ? lines.join('\n') : 'No harness units yet.');
1232
+ out.log('');
1092
1233
  if (lines.length > 0)
1093
- out.log(`\nA tool's options: \`${command} help <tool>\`. Run a tool: \`${command} run <tool> [args]\`.`);
1234
+ out.log(`A tool's options: \`${command} help <tool>\`. Run a tool: \`${command} run <tool> [args]\`.`);
1235
+ out.log(`${EVERY_COMMAND}.`);
1094
1236
  return 0;
1095
1237
  }
1238
+ /** Where `help` says that a folder named with `-C` does not use harnesspm. */
1239
+ export function notAProject(cwd) {
1240
+ return `${fromCaller(findProjectDir(cwd))} does not use harnesspm: it has no ${CONFIG_FILE}.`;
1241
+ }
1096
1242
  /** How a rule becomes active, in words (spec 2.5). */
1097
1243
  function activationLine(rule, file) {
1098
1244
  if (rule.activation === 'always')
@@ -1113,12 +1259,14 @@ function ruleHelp(view, rule, level) {
1113
1259
  const body = demoteHeadings(ruleBodyWithoutTitle(rule), level - 1);
1114
1260
  return [head, about, ...(body !== '' ? [body] : [])].join('\n\n');
1115
1261
  }
1116
- function trustNote(pkg) {
1117
- return `Not trusted in this project, so they stay off and \`run\` refuses them. A person turns them on with "${pkg.name}": true in "trust" in ${CONFIG_FILE}.`;
1262
+ /** Why a package's tools are off, and the person's step that turns them on (spec 6.2). */
1263
+ function trustNote(view, pkg) {
1264
+ const { reason = 'not trusted', action = '' } = view.trust(pkg);
1265
+ return `${reason.charAt(0).toUpperCase()}${reason.slice(1)}, so they stay off in this project and \`run\` refuses them. ${action}`;
1118
1266
  }
1119
1267
  function toolLines(view, script) {
1120
1268
  const ref = `${script.pkg.plugin}:${script.name}`;
1121
- const lines = [`- \`${view.command} run ${ref}${script.usage !== undefined && !script.usage.includes('\n') ? ` ${script.usage}` : ' [args]'}\`${script.description !== undefined ? ` — ${script.description}` : ''} (${script.id})`];
1269
+ const lines = [`- \`${view.command} run ${ref}${script.usage !== undefined && !script.usage.includes('\n') ? ` ${script.usage}` : ' [args]'}\`${script.description !== undefined ? ` — ${script.description}` : ''}${script.allow ? ' · no prompt' : ''} (${script.id})`];
1122
1270
  if (script.usage !== undefined && script.usage.includes('\n'))
1123
1271
  lines.push(...script.usage.split('\n').map((l) => ` ${l}`));
1124
1272
  return lines;
@@ -1145,10 +1293,10 @@ function packageHelp(view, pkg) {
1145
1293
  parts.push('## Docs', `- ${index} (${pkg.plugin}:docs)`);
1146
1294
  const scripts = res.scripts.filter((s) => s.pkg === pkg && s.description !== undefined);
1147
1295
  if (scripts.length > 0)
1148
- parts.push('## Tools', [...(trusted ? [] : [`⚠️ ${trustNote(pkg)}`]), ...scripts.flatMap((s) => toolLines(view, s))].join('\n'));
1296
+ parts.push('## Tools', [...(trusted ? [] : [`⚠️ ${trustNote(view, pkg)}`]), ...scripts.flatMap((s) => toolLines(view, s))].join('\n'));
1149
1297
  const servers = res.mcp.filter((m) => m.pkg === pkg);
1150
1298
  if (servers.length > 0)
1151
- parts.push('## MCP servers', [...(trusted ? [] : [`⚠️ ${trustNote(pkg)}`]), ...servers.map((m) => mcpLine(view, m))].join('\n'));
1299
+ parts.push('## MCP servers', [...(trusted ? [] : [`⚠️ ${trustNote(view, pkg)}`]), ...servers.map((m) => mcpLine(view, m))].join('\n'));
1152
1300
  const skills = res.skills.filter((k) => k.pkg === pkg);
1153
1301
  if (skills.length > 0) {
1154
1302
  const line = (skill) => {
@@ -1160,7 +1308,7 @@ function packageHelp(view, pkg) {
1160
1308
  }
1161
1309
  const hooks = res.hooks.filter((h) => h.pkg === pkg);
1162
1310
  if (hooks.length > 0)
1163
- parts.push('## Hooks', [...(trusted ? [] : [`⚠️ ${trustNote(pkg)}`]), ...hooks.map(hookLine)].join('\n'));
1311
+ parts.push('## Hooks', [...(trusted ? [] : [`⚠️ ${trustNote(view, pkg)}`]), ...hooks.map(hookLine)].join('\n'));
1164
1312
  if (parts.length === 1)
1165
1313
  parts.push('No harness units.');
1166
1314
  return parts.join('\n\n');
@@ -1180,9 +1328,11 @@ function scriptHelp(view, script) {
1180
1328
  lines.push(`Usage: none declared. Its package can add "usage" next to "description" in its manifest. harnesspm does not run the script to ask.`);
1181
1329
  if (script.answers !== undefined)
1182
1330
  lines.push(`Exit: 0 is ok. ${script.answers.join(', ')} ${script.answers.length > 1 ? 'are answers' : 'is an answer'}, such as "found problems", not a broken tool. Any other code is a failure.`);
1331
+ if (script.allow)
1332
+ lines.push('Allow: runs without a prompt in a project that trusts its package.');
1183
1333
  lines.push(`Run: ${view.command} run ${ref} [args]`);
1184
1334
  if (!view.trusted(script.pkg))
1185
- lines.push('', `⚠️ ${trustNote(script.pkg)}`);
1335
+ lines.push('', `⚠️ ${trustNote(view, script.pkg)}`);
1186
1336
  return lines.join('\n');
1187
1337
  }
1188
1338
  /**
@@ -1192,7 +1342,7 @@ function scriptHelp(view, script) {
1192
1342
  export function targetHelp(cwd, target, out) {
1193
1343
  const view = helpView(cwd, out);
1194
1344
  if (view === undefined)
1195
- throw new HarnessError(`No command "${target}", and ${fromCaller(findProjectDir(cwd))} does not use harnesspm, so it has no packages, rules or tools. Run \`harnesspm help\`.`);
1345
+ throw new HarnessError(`No command "${target}", and ${fromCaller(findProjectDir(cwd))} does not use harnesspm, so it has no packages, rules or tools. ${EVERY_COMMAND}.`);
1196
1346
  const { res } = view;
1197
1347
  const pkg = res.packages.find((p) => p.name === target || p.plugin === target);
1198
1348
  const rules = pkg === undefined ? view.rules.filter((r) => r.id === target) : [];
@@ -1245,15 +1395,6 @@ export function approve(cwd, name, out) {
1245
1395
  }
1246
1396
  return sync(projectDir, out, { write: true });
1247
1397
  }
1248
- /** What to do after `new`. `why` and `sync` reach the project's own harness only where the project uses harnesspm. */
1249
- function nextAfterNew(projectDir, added) {
1250
- const npx = NPX_ANY;
1251
- if (added)
1252
- return `Next: edit it, run \`${npx} sync\`, then save the change the way that harness's own AGENTS.md or CONTRIBUTING.md says.`;
1253
- if (isFile(path.join(projectDir, CONFIG_FILE)))
1254
- return `Next: edit it, then run \`${npx} sync\` and \`${npx} check\`.`;
1255
- return `Next: edit it, then run \`${npx} check\`. To see the harness in this repository's AGENTS.md too, run \`${npx} init\`.`;
1256
- }
1257
1398
  export function newUnit(cwd, kind, name, options, out) {
1258
1399
  const projectDir = findProjectDir(cwd);
1259
1400
  const show = (file) => (file.startsWith(projectDir + path.sep) ? relPosix(projectDir, file) : file);
@@ -1271,7 +1412,8 @@ export function newUnit(cwd, kind, name, options, out) {
1271
1412
  out.log(`Wrote in ${target.label}:`);
1272
1413
  for (const file of files)
1273
1414
  out.log(` ${show(file)}`);
1274
- out.log(nextAfterNew(projectDir, options.to !== undefined));
1415
+ for (const line of nextAfterNew(projectDir, options.to !== undefined))
1416
+ out.log(line);
1275
1417
  }
1276
1418
  sync(projectDir, out, { quiet: true, write: true });
1277
1419
  return 0;