Skip to content

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

feat(init): next-steps epilogue; drop key ask from quickstart

Shrish Dwivedi02c49cc3f7c9
diff --git a/README.md b/README.md
index 78fb1e1e..708f13a5 100644
--- a/README.md
+++ b/README.md
@@ -43,13 +43,6 @@ Commit `graft/` so everyone who clones the repo (and their agents) gets the map:
git add graft && git commit -m "add context graph"
```
-Want richer, LLM-written summaries on top of the structural graph? Point Graft at an OpenRouter key and run the deep pass whenever you like:
-
-```bash
-export OPENROUTER_API_KEY=sk-or-... # https://openrouter.ai/keys
-graft build --deep
-```
-
Prefer not to install globally? `npx @nanonets/graft init` works the same way.
---
diff --git a/src/cli-epilogue.ts b/src/cli-epilogue.ts
new file mode 100644
index 00000000..46894394
--- /dev/null
+++ b/src/cli-epilogue.ts
@@ -0,0 +1,73 @@
+/**
+ * `graft init`'s closing epilogue: the ASCII wordmark + numbered next steps,
+ * printed to stderr after the per-file ✓/·/⚠ lines. Extracted out of cli.ts
+ * so the exact text — spacing is hand-aligned, not incidental — can be
+ * unit-tested without spawning the CLI.
+ */
+
+// The widest line (index 4, tied with index 2 at 26 chars) gets the live
+// node/edge stats appended, when a graph exists.
+const WORDMARK_LINES = [
+ " __ _",
+ " __ _ _ __ __ _ / _| |_",
+ " / _` | '__/ _` | |_| __|",
+ " | (_| | | | (_| | _| |_",
+ " \\__, |_| \\__,_|_| \\__|",
+ " |___/",
+];
+const STATS_LINE_INDEX = 4;
+
+interface Step {
+ label: string;
+ command: string;
+ /** Extra continuation lines under this step, left-padded to the same column. */
+ extra?: string[];
+}
+
+export interface InitEpilogueOptions {
+ /** Whether a graft graph exists on disk (built by this run, or a prior one). */
+ graphBuilt: boolean;
+ /** Node count from the built graph — only meaningful when `graphBuilt`. */
+ nodes?: number;
+ /** Edge count from the built graph — only meaningful when `graphBuilt`. */
+ edges?: number;
+}
+
+/** Renders the `graft init` next-steps epilogue (no trailing newline — the
+ * caller's `console.error` adds the one trailing newline). */
+export function formatInitEpilogue(opts: InitEpilogueOptions): string {
+ const { graphBuilt, nodes, edges } = opts;
+
+ const wordmark = [...WORDMARK_LINES];
+ if (graphBuilt && nodes !== undefined && edges !== undefined) {
+ wordmark[STATS_LINE_INDEX] =
+ `${wordmark[STATS_LINE_INDEX]} ${nodes.toLocaleString("en-US")} nodes · ${edges.toLocaleString("en-US")} edges`;
+ }
+
+ const steps: Step[] = [
+ ...(graphBuilt ? [] : [{ label: "build the graph", command: "graft build" }]),
+ { label: "commit the map", command: 'git add graft .claude && git commit -m "add graft"' },
+ { label: "restart your agent", command: "the next session picks up the skill + statusline" },
+ {
+ label: "try it",
+ command: 'graft ask "where is auth handled?"',
+ extra: ["graft callers <function> · graft viz"],
+ },
+ ];
+
+ const indent = " ";
+ const gap = " ";
+ const labelWidth = Math.max(...steps.map((s, i) => `${i + 1}. ${s.label}`.length));
+ const columnWidth = indent.length + labelWidth + gap.length;
+
+ const stepLines: string[] = [];
+ steps.forEach((s, i) => {
+ const prefix = `${indent}${i + 1}. ${s.label}`;
+ stepLines.push(prefix.padEnd(columnWidth) + s.command);
+ for (const extra of s.extra ?? []) {
+ stepLines.push(" ".repeat(columnWidth) + extra);
+ }
+ });
+
+ return [...wordmark, "", ...stepLines].join("\n");
+}
diff --git a/src/cli.ts b/src/cli.ts
index 40d250be..b18f48bd 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -24,6 +24,9 @@ import { formatGraphCheckReport } from "./graph/check.js";
import { runInit } from "./claude/init.js";
import { runHostsInit } from "./hosts/init.js";
import { hostIds } from "./hosts/registry.js";
+import { contextDirFor } from "./context/node-file.js";
+import { loadGraphCached } from "./graph/load.js";
+import { formatInitEpilogue } from "./cli-epilogue.js";
const program = new Command();
@@ -304,8 +307,18 @@ program
for (const m of r.mcp) console.error(`✓ mcp ${m.id}: ${m.path} (${m.action})`);
for (const h of r.hooks) console.error(`✓ hook ${h.id}: ${h.path} (${h.action})`);
}
- console.error("\nDone. Claude Code gets live hooks + statusline; other agents read their instruction files.");
- console.error("For LLM summaries: set OPENROUTER_API_KEY and run `graft build --deep`.");
+
+ const globalOpts = program.opts<{ dir?: string }>();
+ const outDir = contextDirFor(repo, globalOpts.dir);
+ const graph = loadGraphCached(outDir);
+ console.error(
+ "\n" +
+ formatInitEpilogue({
+ graphBuilt: graph !== null,
+ nodes: graph?.meta.nodeCount,
+ edges: graph?.meta.edgeCount,
+ }),
+ );
});
program.parseAsync().catch((err) => {
diff --git a/test/claude-init.test.ts b/test/claude-init.test.ts
index 19cdcd7a..6a7729c6 100644
--- a/test/claude-init.test.ts
+++ b/test/claude-init.test.ts
@@ -3,8 +3,9 @@ import assert from 'node:assert/strict';
import { mkdtempSync, readFileSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
-import { execFileSync } from 'node:child_process';
+import { execFileSync, spawnSync } from 'node:child_process';
import { runInit } from '../src/claude/init.js';
+import { formatInitEpilogue } from '../src/cli-epilogue.js';
function fresh(): string { return mkdtempSync(join(tmpdir(), 'graft-init-')); }
@@ -87,3 +88,45 @@ test('postinstall is silent under CI', () => {
const out = runPostinstall({ INIT_CWD: fresh(), CI: '1' });
assert.equal(out.trim(), '');
});
+
+test('formatInitEpilogue: graph built shows stats, wordmark, and the 3-step list', () => {
+ const out = formatInitEpilogue({ graphBuilt: true, nodes: 6398, edges: 10912 });
+ assert.match(out, /\|___\/\s*$/m);
+ assert.ok(out.includes('6,398 nodes · 10,912 edges'));
+ assert.ok(out.includes('1. commit the map'));
+ assert.ok(out.includes('2. restart your agent'));
+ assert.ok(out.includes('3. try it'));
+ assert.ok(out.includes('graft ask'));
+ assert.ok(!out.includes('build the graph'));
+ assert.ok(!out.includes('OPENROUTER'));
+});
+
+test('formatInitEpilogue: graph not built shows "build the graph" as step 1, no stats, same column alignment', () => {
+ const built = formatInitEpilogue({ graphBuilt: true, nodes: 4, edges: 4 });
+ const notBuilt = formatInitEpilogue({ graphBuilt: false });
+ assert.ok(notBuilt.includes('1. build the graph'));
+ assert.ok(notBuilt.includes('2. commit the map'));
+ assert.ok(notBuilt.includes('3. restart your agent'));
+ assert.ok(notBuilt.includes('4. try it'));
+ assert.ok(!notBuilt.includes('nodes ·'));
+ // the command column (after "restart your agent", the longest label) lines up
+ // identically whether there are 3 or 4 numbered steps.
+ const col = (text: string, marker: string) => text.split('\n').find((l) => l.includes(marker))!.indexOf('the next session');
+ assert.equal(col(built, 'restart your agent'), col(notBuilt, 'restart your agent'));
+});
+
+test('CLI: graft init epilogue has the wordmark + next steps, and never mentions OPENROUTER', () => {
+ const d = fresh();
+ const res = spawnSync(
+ process.execPath,
+ ['--import', 'tsx', 'src/cli.ts', 'init', d, '--no-build', '--no-agents'],
+ { encoding: 'utf8' },
+ );
+ assert.equal(res.status, 0, res.stderr);
+ assert.ok(res.stderr.includes('|___/'), 'wordmark present');
+ assert.ok(res.stderr.includes('commit the map'));
+ assert.ok(res.stderr.includes('graft ask'));
+ assert.ok(!res.stderr.includes('OPENROUTER'));
+ // --no-build, never built before → "build the graph" is step 1
+ assert.ok(res.stderr.includes('1. build the graph'));
+});