Skip to content

Commit bf4f34b

Browse files
fix(cli): install skills into project dir on non-interactive init (#1671)
`hyperframes init` only installed AI coding skills on the interactive path (behind a clack confirm). When an agent drives it non-interactively (no TTY), it just printed `npx skills add ...` and returned — so skills were never installed and the agent later hit `Unknown skill: <workflow>`. - init: both interactive and non-interactive branches now run `npx skills add` with `cwd` set to the new project dir so skills land there, not in the caller's working directory. Non-interactive additionally passes `--yes`; when Claude Code is driving (CLAUDECODE env var), adds `--agent claude-code` so skills target `.claude/skills/`. - skills: `runSkillsAdd` accepts `cwd` and `extraArgs` so callers can control where and how skills are installed. - templates: CLAUDE.md / AGENTS.md now tell agents to run `npx skills add heygen-com/hyperframes` to install or update skills. Co-authored-by: Wenbo Zhu <295860553+kiritowoo@users.noreply.github.com>
1 parent 2681085 commit bf4f34b

4 files changed

Lines changed: 51 additions & 25 deletions

File tree

packages/cli/src/commands/init.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,11 +800,27 @@ export default defineCommand({
800800
for (const f of readdirSync(destDir).filter((f) => !f.startsWith("."))) {
801801
console.log(` ${c.accent(f)}`);
802802
}
803+
804+
if (!skipSkills) {
805+
const { installAllSkills } = await import("./skills.js");
806+
// --yes keeps it non-interactive. When Claude Code is driving
807+
// (CLAUDECODE env var), target its native dir so skills land in
808+
// .claude/skills/ instead of only .agents/skills/.
809+
const args = process.env["CLAUDECODE"] ? ["--agent", "claude-code", "--yes"] : ["--yes"];
810+
await installAllSkills({ cwd: destDir, extraArgs: args });
811+
}
812+
803813
console.log();
804814
console.log("Get started:");
805815
console.log();
806-
console.log(` ${c.accent("1.")} Install AI coding skills (one-time):`);
807-
console.log(` ${c.accent("npx skills add heygen-com/hyperframes")}`);
816+
if (skipSkills) {
817+
console.log(` ${c.accent("1.")} Install AI coding skills (one-time):`);
818+
console.log(` ${c.accent("npx skills add heygen-com/hyperframes --yes")}`);
819+
} else {
820+
console.log(
821+
` ${c.accent("1.")} Restart your AI agent (new session) so it loads the skills.`,
822+
);
823+
}
808824
console.log();
809825
console.log(` ${c.accent("2.")} Open this project with your AI coding agent:`);
810826
console.log(
@@ -1018,8 +1034,8 @@ export default defineCommand({
10181034
process.exit(0);
10191035
}
10201036
if (installSkills) {
1021-
const skillsCmd = await import("./skills.js").then((m) => m.default);
1022-
await runCommand(skillsCmd, { rawArgs: [] });
1037+
const { installAllSkills } = await import("./skills.js");
1038+
await installAllSkills({ cwd: destDir });
10231039
}
10241040
}
10251041

packages/cli/src/commands/skills.ts

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ function hasNpx(): boolean {
1414
}
1515
}
1616

17-
function runSkillsAdd(repo: string): Promise<void> {
18-
const npx = buildNpxCommand(["skills", "add", repo, "--all"]);
17+
function runSkillsAdd(
18+
repo: string,
19+
opts: { cwd?: string; extraArgs?: string[] } = {},
20+
): Promise<void> {
21+
const npx = buildNpxCommand(["skills", "add", repo, ...(opts.extraArgs ?? ["--all"])]);
1922
return new Promise((resolve, reject) => {
2023
const child = spawn(npx.command, npx.args, {
2124
stdio: "inherit",
2225
timeout: 120_000,
26+
cwd: opts.cwd,
2327
// GH #316 — the upstream `skills` CLI shells out to `git clone`.
2428
// When Git's clone-hook protection is active (shipped on by
2529
// default in 2.45.1, reverted in 2.45.2, still present on many
@@ -40,27 +44,33 @@ function runSkillsAdd(repo: string): Promise<void> {
4044

4145
const SOURCES = [{ name: "HyperFrames", repo: "heygen-com/hyperframes" }];
4246

47+
export async function installAllSkills(
48+
opts: { cwd?: string; extraArgs?: string[] } = {},
49+
): Promise<void> {
50+
if (!hasNpx()) {
51+
clack.log.error(c.error("npx not found. Install Node.js and retry."));
52+
return;
53+
}
54+
55+
for (const source of SOURCES) {
56+
console.log();
57+
console.log(c.bold(`Installing ${source.name} skills...`));
58+
console.log();
59+
try {
60+
await runSkillsAdd(source.repo, opts);
61+
} catch {
62+
console.log(c.dim(`${source.name} skills skipped`));
63+
}
64+
}
65+
}
66+
4367
export default defineCommand({
4468
meta: {
4569
name: "skills",
4670
description: "Install HyperFrames skills for AI coding tools",
4771
},
4872
args: {},
4973
async run() {
50-
if (!hasNpx()) {
51-
clack.log.error(c.error("npx not found. Install Node.js and retry."));
52-
return;
53-
}
54-
55-
for (const source of SOURCES) {
56-
console.log();
57-
console.log(c.bold(`Installing ${source.name} skills...`));
58-
console.log();
59-
try {
60-
await runSkillsAdd(source.repo);
61-
} catch {
62-
console.log(c.dim(`${source.name} skills skipped`));
63-
}
64-
}
74+
await installAllSkills();
6575
},
6676
});

packages/cli/src/templates/_shared/AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The domain skills (`/hyperframes-core`, `/hyperframes-animation`, `/hyperframes-
2121

2222
> **Tailwind v4 projects** (`hyperframes init --tailwind`): see `/hyperframes-core``references/tailwind.md`.
2323
24-
> **Skills not available?** Ask the user to run `npx hyperframes skills` and restart their
25-
> agent session, or install manually: `npx skills add heygen-com/hyperframes`.
24+
> **Skills not available or need updating?** Run `npx skills add heygen-com/hyperframes`
25+
> and restart the agent session so the new skills load.
2626
2727
## Commands
2828

packages/cli/src/templates/_shared/CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The domain skills (`/hyperframes-core`, `/hyperframes-animation`, `/hyperframes-
2121

2222
> **Tailwind v4 projects** (`hyperframes init --tailwind`): see `/hyperframes-core``references/tailwind.md`.
2323
24-
> **Skills not available?** Ask the user to run `npx hyperframes skills` and restart their
25-
> agent session, or install manually: `npx skills add heygen-com/hyperframes`.
24+
> **Skills not available or need updating?** Run `npx skills add heygen-com/hyperframes`
25+
> and restart the agent session so the new skills load.
2626
2727
## Commands
2828

0 commit comments

Comments
 (0)