Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

Quiet npm install; tick chosen rows in trail init (#668)

anirudhkumar-nanonetsc046c64bf194
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 00000000..b215581d
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+fund=false
diff --git a/.trail/learnings/2026-10-22-quieting-npm-install-audit-warnings-and-anirudhkumar.md b/.trail/learnings/2026-10-22-quieting-npm-install-audit-warnings-and-anirudhkumar.md
new file mode 100644
index 00000000..9bd9ef92
--- /dev/null
+++ b/.trail/learnings/2026-10-22-quieting-npm-install-audit-warnings-and-anirudhkumar.md
@@ -0,0 +1,26 @@
+---
+title: "Quieting npm install: audit warnings and install noise"
+author: Anirudhkumar-nanonets
+date: 2026-10-22
+branch: chore/quiet-npm-install
+touches:
+ - package-lock.json
+ - package.json
+ - scripts/stamp-telemetry-key.mjs
+ - ".npmrc"
+ - src/util/front-matter.ts
+---
+
+## Decided
+- undici (high, via openai and node-gyp): lockfile bump to 6.29.1 with `npm audit fix`; no range change.
+- sprintf-js (moderate, gray-matter → js-yaml 3 → argparse 1 → sprintf-js): no patched sprintf-js exists (every version ≤1.1.3 is flagged). argparse is only used by js-yaml's own CLI (bin/js-yaml.js), never by its parser, so package.json `overrides` gives js-yaml argparse ^2.0.1, which has no dependencies. js-yaml's CLI breaks; nothing here runs it.
+- scripts/stamp-telemetry-key.mjs runs from `prepare`, so it ran on every `npm install` in a clone and printed "publishing a build that sends no telemetry". It now warns only when `npm_command` is `publish` or `pack`.
+- `.npmrc` sets `fund=false` (not in package.json `files`, so it doesn't ship).
+
+## Tried and ruled out
+- Overriding js-yaml to 4 under gray-matter: gray-matter's default YAML engine calls `safeLoad`, removed in js-yaml 4, and src/util/front-matter.ts guards anchors through js-yaml 3's `listener` and `anchorMap` internals.
+- `audit=false` in .npmrc: hides every future advisory too.
+
+## Watch out
+- `overrides` apply only to this repo's own install, not to users who `npm i -g` the package; global installs don't run audit, so they never saw the warning.
+- The real fix for the sprintf-js chain is dropping gray-matter for js-yaml 4 or `yaml` directly, and porting the anchor guard in src/util/front-matter.ts with it. Remove the argparse override when that lands.
diff --git a/package-lock.json b/package-lock.json
index f546a785..bb621325 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -564,19 +564,10 @@
}
},
"node_modules/argparse": {
- "version": "1.0.10",
- "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
- "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
- "license": "MIT",
- "dependencies": {
- "sprintf-js": "~1.0.2"
- }
- },
- "node_modules/argparse/node_modules/sprintf-js": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
- "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
- "license": "BSD-3-Clause"
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
+ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
+ "license": "Python-2.0"
},
"node_modules/chownr": {
"version": "3.0.0",
@@ -1357,9 +1348,9 @@
}
},
"node_modules/undici": {
- "version": "6.28.0",
- "resolved": "https://registry.npmjs.org/undici/-/undici-6.28.0.tgz",
- "integrity": "sha512-LIY910g9TI13YS95lrMFrs8Rm/u/irgHeTWoKCoteeJ04CUJ92eEfj0rVn+7VKMPBpUPiUoBKfhNyLI23EE/KA==",
+ "version": "6.29.1",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz",
+ "integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==",
"devOptional": true,
"license": "MIT",
"engines": {
diff --git a/package.json b/package.json
index 3e29f0e1..24e85383 100644
--- a/package.json
+++ b/package.json
@@ -100,6 +100,9 @@
"overrides": {
"tree-sitter-swift": {
"tree-sitter": "$tree-sitter"
+ },
+ "js-yaml": {
+ "argparse": "^2.0.1"
}
}
}
diff --git a/scripts/stamp-telemetry-key.mjs b/scripts/stamp-telemetry-key.mjs
index 12c80557..10ffad74 100644
--- a/scripts/stamp-telemetry-key.mjs
+++ b/scripts/stamp-telemetry-key.mjs
@@ -7,10 +7,10 @@
* `npm run build` all produce a graft whose telemetry module short-circuits on
* the very first check.
*
- * Runs from `prepublishOnly`, after `npm run build`. Without GRAFT_POSTHOG_KEY
- * in the environment it prints a warning and changes nothing — publishing a
- * telemetry-less build is a valid thing to do, and it must never be a hard
- * failure at the moment someone is trying to ship.
+ * Runs from `prepare`, after `npm run build`. Without GRAFT_POSTHOG_KEY in the
+ * environment it changes nothing, and warns only when npm is packing or
+ * publishing — publishing a telemetry-less build is a valid thing to do, and it
+ * must never be a hard failure at the moment someone is trying to ship.
*/
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
@@ -23,7 +23,10 @@ const key = process.env.GRAFT_POSTHOG_KEY ?? '';
const host = process.env.GRAFT_POSTHOG_HOST ?? '';
if (!key) {
- console.warn('⚠ GRAFT_POSTHOG_KEY not set — publishing a build that sends no telemetry.');
+ // `prepare` also runs on every `npm install` in a clone, where no key is expected.
+ if (['publish', 'pack'].includes(process.env.npm_command ?? '')) {
+ console.warn('⚠ GRAFT_POSTHOG_KEY not set — publishing a build that sends no telemetry.');
+ }
process.exit(0);
}
if (!existsSync(target)) {
diff --git a/src/cli-picker.ts b/src/cli-picker.ts
index 60d487b1..923fdc4b 100644
--- a/src/cli-picker.ts
+++ b/src/cli-picker.ts
@@ -300,7 +300,7 @@ export function renderPicker(state: PickerState, tty = true, opts: { title?: str
ruled = true;
}
const here = i === state.cursor;
- const box = state.checked.has(row.id) ? '[x]' : '[ ]';
+ const box = state.checked.has(row.id) ? '[✓]' : '[ ]';
const gap = ' '.repeat(Math.max(0, width - label(row).length));
const name = here ? hot(row.label) : row.label;
const tag = row.detected || row.kind === 'setting' ? '' : dim(' (not detected)');
diff --git a/test/cli-picker.test.ts b/test/cli-picker.test.ts
index b58753da..8f87bdcd 100644
--- a/test/cli-picker.test.ts
+++ b/test/cli-picker.test.ts
@@ -197,17 +197,17 @@ test('renderPicker marks the cursor and folds undetected hosts into one line', (
const state = initialPickerState(planInit(repo, { home }), repo, home);
const text = renderPicker(state, false);
assert.match(text, /^graft init — pick the agents your team uses:/);
- assert.match(text, /› \[x\] claude/);
+ assert.match(text, /› \[✓\] claude/);
assert.doesNotMatch(text, /\[ \] cursor/, 'an agent graft cannot find is folded away');
assert.match(text, /\+ \d+ not detected \(.*cursor.*\) · m to show/);
assert.match(text, /space toggle · a all · m more · enter confirm/);
// Only the detected rows get a checkbox until `m`.
- assert.equal(text.split('\n').filter((l) => /\[[ x]\]/.test(l)).length, visibleRows(state).length);
+ assert.equal(text.split('\n').filter((l) => /\[[ ✓]\]/.test(l)).length, visibleRows(state).length);
const opened = reducePicker(state, 'more');
const all = renderPicker(opened, false);
assert.match(all, /\[ \] cursor \(not detected\)/);
- assert.equal(all.split('\n').filter((l) => /\[[ x]\]/.test(l)).length, state.rows.length);
+ assert.equal(all.split('\n').filter((l) => /\[[ ✓]\]/.test(l)).length, state.rows.length);
});
test('a never selects an agent that is folded away', () => {
@@ -337,7 +337,7 @@ test('a (toggle all) is about agents and leaves the consent answer alone', () =>
test('the rendered row shows the label, a rule, and what is not collected', () => {
const repo = fresh(); const home = fullHome();
const out = renderPicker(initialPickerState(planInit(repo, { home }), repo, home, { offerTelemetry: true }), false);
- assert.match(out, /\[x\] anonymous usage stats/);
+ assert.match(out, /\[✓\] anonymous usage stats/);
assert.match(out, /no code, no file paths, no queries/);
assert.equal(out.includes(TELEMETRY_ROW_ID), false, 'the internal id must never be shown');
assert.match(out, /─/, 'a rule separates the settings from the agents');
@@ -351,9 +351,9 @@ test("the learnings picker ticks the team's learnings, leaves the person's own u
]);
assert.deepEqual(keptLearnings(state), [0, 2]);
const shown = renderPicker(state, false, { title: 'keep:' });
- assert.match(shown, /\[x\] Return a 500 when db\.query fails\s+for your team · from review on PR #41, #38/);
+ assert.match(shown, /\[✓\] Return a 500 when db\.query fails\s+for your team · from review on PR #41, #38/);
assert.match(shown, /\[ \] Say what you understood first\s+just for you · told Claude in 4 sessions/);
- assert.match(shown, /\[x\] Run go test with -race\s+for your team · from your Claude's memory of this repo/);
+ assert.match(shown, /\[✓\] Run go test with -race\s+for your team · from your Claude's memory of this repo/);
state = reducePicker(reducePicker(state, 'down'), 'space');
assert.deepEqual(keptLearnings(state), [0, 1, 2]);
state = reducePicker(state, 'space');