kiro-10x-better 1.0.2 → 1.0.4
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/README.md +10 -1
- package/bin/cli.mjs +225 -53
- package/package.json +1 -1
- package/templates/hooks/scripts/sync-stack-skills.cjs +88 -0
- package/templates/hooks/stack-skill-sync.json +40 -0
package/README.md
CHANGED
|
@@ -26,10 +26,19 @@ npx kiro-10x-better --global
|
|
|
26
26
|
| :--- | :--- |
|
|
27
27
|
| `-g`, `--global` | Install into `~/.kiro/` instead of `./.kiro/` |
|
|
28
28
|
| `-f`, `--force` | Overwrite existing `.kiro` files (default: skip existing) |
|
|
29
|
-
| `-y`, `--yes` | Skip interactive prompts
|
|
29
|
+
| `-y`, `--yes` | Skip interactive prompts (installs security + detected web skills) |
|
|
30
|
+
| `--core-only` | Skip external `npx skills add` calls (keeps local stack watcher hook) |
|
|
30
31
|
| `--with-skills` | Also install core `obra/superpowers` skills via `npx skills` |
|
|
32
|
+
| `--web` | Install Web App skills (`agent-browser` + `modern-web-guidance`) without prompting |
|
|
33
|
+
| `--security` | Install Security Audit skills without prompting |
|
|
31
34
|
| `-h`, `--help` | Show usage help and exit |
|
|
32
35
|
|
|
36
|
+
## Progressive Setup Flow
|
|
37
|
+
|
|
38
|
+
1. **Core Setup (Always Runs):** Installs steering rules, the 3 bundled skills, core safety/lint/verify hooks, the always-on `stack-skill-sync.json` watcher hook (`SessionStart`, `PostFileSave` on `package.json`, `PostToolUse` on `shell`), ignores, and global `permissions.yaml`.
|
|
39
|
+
2. **Web App Skills (`--web` / Auto-Detect):** Detects web frameworks (`next`, `react`, `vite`, `vue`, `svelte`, `astro`, `nuxt`, `remix`, `@tanstack/react-start`) in `package.json`. Under `--yes`, installs `agent-browser` + `modern-web-guidance` automatically when a web framework is detected (otherwise the always-on watcher installs them automatically as soon as one is added later).
|
|
40
|
+
3. **Security Audit Skills (`--security` / Smart `--yes`):** Enabled by default under `--yes` and `(Y/n)` interactively—installs `security-audit` (Cloudflare) + `security-review` (Sentry), appends `pnpm audit*` / `npm audit*` to `permissions.yaml`, and installs `better-auth-security-best-practices` immediately if `better-auth` is in `package.json` (or via the watcher hook whenever added later).
|
|
41
|
+
|
|
33
42
|
## What Gets Installed
|
|
34
43
|
|
|
35
44
|
- **Steering (`steering/core-rules.md`):** Karpathy-style minimal diffs, fast CLI preferences (`rg`, `ast-grep`, `jq`, `gh`), token-saving rules, and verification honesty.
|
package/bin/cli.mjs
CHANGED
|
@@ -9,6 +9,17 @@ import { fileURLToPath } from "node:url";
|
|
|
9
9
|
|
|
10
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
const TEMPLATES_DIR = path.resolve(__dirname, "..", "templates");
|
|
12
|
+
const WEB_FRAMEWORKS = [
|
|
13
|
+
"next",
|
|
14
|
+
"react",
|
|
15
|
+
"vite",
|
|
16
|
+
"vue",
|
|
17
|
+
"svelte",
|
|
18
|
+
"astro",
|
|
19
|
+
"nuxt",
|
|
20
|
+
"remix",
|
|
21
|
+
"@tanstack/react-start"
|
|
22
|
+
];
|
|
12
23
|
|
|
13
24
|
function printHelp() {
|
|
14
25
|
console.log(`kiro-10x-better — High-discipline Kiro CLI V3 setup
|
|
@@ -19,8 +30,11 @@ Usage:
|
|
|
19
30
|
Options:
|
|
20
31
|
-g, --global Install into ~/.kiro/ instead of ./.kiro/
|
|
21
32
|
-f, --force Overwrite existing files (default: skip existing)
|
|
22
|
-
-y, --yes Skip
|
|
33
|
+
-y, --yes Skip prompts (auto-installs security + detected web skills)
|
|
34
|
+
--core-only Skip external npx skills installs (keeps local watcher hook)
|
|
23
35
|
--with-skills Install core obra/superpowers skills via npx skills
|
|
36
|
+
--web Install Web App skills (agent-browser + modern-web-guidance)
|
|
37
|
+
--security Install Security Audit skills without prompting
|
|
24
38
|
-h, --help Show this help message and exit
|
|
25
39
|
`);
|
|
26
40
|
}
|
|
@@ -30,7 +44,10 @@ function parseArgs(argv) {
|
|
|
30
44
|
global: false,
|
|
31
45
|
force: false,
|
|
32
46
|
yes: false,
|
|
47
|
+
coreOnly: false,
|
|
33
48
|
withSkills: false,
|
|
49
|
+
web: false,
|
|
50
|
+
security: false,
|
|
34
51
|
help: false
|
|
35
52
|
};
|
|
36
53
|
|
|
@@ -48,9 +65,18 @@ function parseArgs(argv) {
|
|
|
48
65
|
case "-y":
|
|
49
66
|
flags.yes = true;
|
|
50
67
|
break;
|
|
68
|
+
case "--core-only":
|
|
69
|
+
flags.coreOnly = true;
|
|
70
|
+
break;
|
|
51
71
|
case "--with-skills":
|
|
52
72
|
flags.withSkills = true;
|
|
53
73
|
break;
|
|
74
|
+
case "--web":
|
|
75
|
+
flags.web = true;
|
|
76
|
+
break;
|
|
77
|
+
case "--security":
|
|
78
|
+
flags.security = true;
|
|
79
|
+
break;
|
|
54
80
|
case "--help":
|
|
55
81
|
case "-h":
|
|
56
82
|
flags.help = true;
|
|
@@ -63,7 +89,20 @@ function parseArgs(argv) {
|
|
|
63
89
|
return flags;
|
|
64
90
|
}
|
|
65
91
|
|
|
66
|
-
function
|
|
92
|
+
function readPackageDeps(cwd) {
|
|
93
|
+
const pkgPath = path.join(cwd, "package.json");
|
|
94
|
+
if (!fs.existsSync(pkgPath)) {
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8").replace(/^\uFEFF/, ""));
|
|
99
|
+
return { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
|
|
100
|
+
} catch {
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function detectProjectStack(cwd, deps) {
|
|
67
106
|
let pm = "npm";
|
|
68
107
|
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) {
|
|
69
108
|
pm = "pnpm";
|
|
@@ -72,21 +111,12 @@ function detectProjectStack(cwd) {
|
|
|
72
111
|
}
|
|
73
112
|
|
|
74
113
|
let linter = null;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
linter = "biome";
|
|
82
|
-
} else if ("eslint" in deps) {
|
|
83
|
-
linter = "eslint";
|
|
84
|
-
} else if ("prettier" in deps) {
|
|
85
|
-
linter = "prettier";
|
|
86
|
-
}
|
|
87
|
-
} catch {
|
|
88
|
-
// Ignore malformed package.json and fall back to defaults
|
|
89
|
-
}
|
|
114
|
+
if ("@biomejs/biome" in deps || "biome" in deps) {
|
|
115
|
+
linter = "biome";
|
|
116
|
+
} else if ("eslint" in deps) {
|
|
117
|
+
linter = "eslint";
|
|
118
|
+
} else if ("prettier" in deps) {
|
|
119
|
+
linter = "prettier";
|
|
90
120
|
}
|
|
91
121
|
|
|
92
122
|
const typescript = fs.existsSync(path.join(cwd, "tsconfig.json"));
|
|
@@ -243,47 +273,98 @@ function configureMediumEffort(homeKiroDir, tracker) {
|
|
|
243
273
|
}
|
|
244
274
|
}
|
|
245
275
|
|
|
246
|
-
|
|
276
|
+
function appendAllowRules(homeKiroDir, commands, tracker) {
|
|
277
|
+
const permPath = path.join(homeKiroDir, "settings", "permissions.yaml");
|
|
278
|
+
if (!fs.existsSync(permPath)) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const content = fs.readFileSync(permPath, "utf8");
|
|
283
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n";
|
|
284
|
+
const missing = commands.filter((cmd) => !content.includes(`command: "${cmd}"`));
|
|
285
|
+
if (missing.length === 0) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const block = missing
|
|
290
|
+
.map((cmd) => ` - tool: shell${eol} command: "${cmd}"`)
|
|
291
|
+
.join(eol);
|
|
292
|
+
|
|
293
|
+
let updatedContent;
|
|
294
|
+
const allowMatch = content.match(/^allow:[ \t]*\r?\n/m);
|
|
295
|
+
if (allowMatch) {
|
|
296
|
+
const insertPos = allowMatch.index + allowMatch[0].length;
|
|
297
|
+
updatedContent = `${content.slice(0, insertPos)}${block}${eol}${content.slice(insertPos)}`;
|
|
298
|
+
} else {
|
|
299
|
+
const prefix = content.length === 0 || content.endsWith("\n") ? "" : eol;
|
|
300
|
+
updatedContent = `${content}${prefix}allow:${eol}${block}${eol}`;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
fs.writeFileSync(permPath, updatedContent, "utf8");
|
|
304
|
+
tracker.created.push(`~/.kiro/settings/permissions.yaml (+${missing.length} allow rules)`);
|
|
305
|
+
console.log(` update ~/.kiro/settings/permissions.yaml (added ${missing.join(", ")})`);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async function promptYesNo(question, defaultYes = true) {
|
|
247
309
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
248
310
|
try {
|
|
249
311
|
const answer = await rl.question(question);
|
|
250
312
|
const normalized = answer.trim().toLowerCase();
|
|
251
|
-
|
|
313
|
+
if (normalized === "") {
|
|
314
|
+
return defaultYes;
|
|
315
|
+
}
|
|
316
|
+
return normalized === "y" || normalized === "yes";
|
|
252
317
|
} finally {
|
|
253
318
|
rl.close();
|
|
254
319
|
}
|
|
255
320
|
}
|
|
256
321
|
|
|
257
|
-
function
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
"
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
322
|
+
function runNpxSkills(args, isGlobal) {
|
|
323
|
+
const fullArgs = isGlobal ? [...args, "-g"] : [...args];
|
|
324
|
+
const manualCmd = `npx ${fullArgs.join(" ")}`;
|
|
325
|
+
console.log(`\nRunning: ${manualCmd}`);
|
|
326
|
+
try {
|
|
327
|
+
const res = spawnSync("npx", fullArgs, {
|
|
328
|
+
stdio: "inherit",
|
|
329
|
+
shell: process.platform === "win32"
|
|
330
|
+
});
|
|
331
|
+
if (res.error) {
|
|
332
|
+
console.error(`Warning: Failed to run "${manualCmd}": ${res.error.message}`);
|
|
333
|
+
console.error(`Run manually later: ${manualCmd}`);
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
if (res.status !== 0) {
|
|
337
|
+
console.error(`Warning: "${manualCmd}" exited with status ${res.status}`);
|
|
338
|
+
console.error(`Run manually later: ${manualCmd}`);
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
return true;
|
|
342
|
+
} catch (err) {
|
|
343
|
+
console.error(`Warning: Failed to run "${manualCmd}": ${err.message}`);
|
|
344
|
+
console.error(`Run manually later: ${manualCmd}`);
|
|
345
|
+
return false;
|
|
275
346
|
}
|
|
347
|
+
}
|
|
276
348
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
349
|
+
function runSkillsInstall(isGlobal) {
|
|
350
|
+
runNpxSkills(
|
|
351
|
+
[
|
|
352
|
+
"skills",
|
|
353
|
+
"add",
|
|
354
|
+
"obra/superpowers",
|
|
355
|
+
"-s",
|
|
356
|
+
"using-git-worktrees",
|
|
357
|
+
"-s",
|
|
358
|
+
"subagent-driven-development",
|
|
359
|
+
"-s",
|
|
360
|
+
"verification-before-completion",
|
|
361
|
+
"-s",
|
|
362
|
+
"systematic-debugging",
|
|
363
|
+
"-a",
|
|
364
|
+
"kiro-cli"
|
|
365
|
+
],
|
|
366
|
+
isGlobal
|
|
367
|
+
);
|
|
287
368
|
}
|
|
288
369
|
|
|
289
370
|
async function main() {
|
|
@@ -299,11 +380,12 @@ async function main() {
|
|
|
299
380
|
const prefixLabel = flags.global ? "~/.kiro" : ".kiro";
|
|
300
381
|
const tracker = { created: [], skipped: [] };
|
|
301
382
|
|
|
302
|
-
const
|
|
383
|
+
const pkgDeps = readPackageDeps(cwd);
|
|
384
|
+
const stack = flags.global ? null : detectProjectStack(cwd, pkgDeps);
|
|
303
385
|
|
|
304
386
|
console.log(`\nSetting up Kiro CLI V3 in ${targetKiroDir}\n`);
|
|
305
387
|
|
|
306
|
-
//
|
|
388
|
+
// Step 1: Fast Core Setup (steering, bundled skills, core + watcher hooks, ignores, permissions)
|
|
307
389
|
copyTemplateFile(
|
|
308
390
|
path.join("steering", "core-rules.md"),
|
|
309
391
|
path.join(targetKiroDir, "steering", "core-rules.md"),
|
|
@@ -320,8 +402,12 @@ async function main() {
|
|
|
320
402
|
path.join(targetKiroDir, "hooks", "scripts", "guard.cjs"),
|
|
321
403
|
{ force: flags.force, label: `${prefixLabel}/hooks/scripts/guard.cjs`, tracker }
|
|
322
404
|
);
|
|
405
|
+
copyTemplateFile(
|
|
406
|
+
path.join("hooks", "scripts", "sync-stack-skills.cjs"),
|
|
407
|
+
path.join(targetKiroDir, "hooks", "scripts", "sync-stack-skills.cjs"),
|
|
408
|
+
{ force: flags.force, label: `${prefixLabel}/hooks/scripts/sync-stack-skills.cjs`, tracker }
|
|
409
|
+
);
|
|
323
410
|
|
|
324
|
-
// Write configured hooks
|
|
325
411
|
writeTargetFile(
|
|
326
412
|
path.join(targetKiroDir, "hooks", "security-guard.json"),
|
|
327
413
|
buildSecurityGuardConfig(flags.global),
|
|
@@ -337,8 +423,12 @@ async function main() {
|
|
|
337
423
|
buildVerifyConfig(stack),
|
|
338
424
|
{ force: flags.force, label: `${prefixLabel}/hooks/verify-after-task.json`, tracker }
|
|
339
425
|
);
|
|
426
|
+
copyTemplateFile(
|
|
427
|
+
path.join("hooks", "stack-skill-sync.json"),
|
|
428
|
+
path.join(targetKiroDir, "hooks", "stack-skill-sync.json"),
|
|
429
|
+
{ force: flags.force, label: `${prefixLabel}/hooks/stack-skill-sync.json`, tracker }
|
|
430
|
+
);
|
|
340
431
|
|
|
341
|
-
// Project-only .gitignore & .kiroignore
|
|
342
432
|
if (!flags.global) {
|
|
343
433
|
updateGitignore(cwd, tracker);
|
|
344
434
|
copyTemplateFile("kiroignore", path.join(cwd, ".kiroignore"), {
|
|
@@ -348,7 +438,6 @@ async function main() {
|
|
|
348
438
|
});
|
|
349
439
|
}
|
|
350
440
|
|
|
351
|
-
// Global permissions.yaml (Kiro CLI V3 reads permissions.yaml only from ~/.kiro/settings/)
|
|
352
441
|
const shouldInstallPermissions = flags.global || flags.yes ||
|
|
353
442
|
(await promptYesNo("\nInstall global permissions.yaml to ~/.kiro/settings/permissions.yaml? (Y/n) "));
|
|
354
443
|
|
|
@@ -361,10 +450,88 @@ async function main() {
|
|
|
361
450
|
configureMediumEffort(homeKiroDir, tracker);
|
|
362
451
|
}
|
|
363
452
|
|
|
364
|
-
if (flags.withSkills) {
|
|
453
|
+
if (flags.withSkills && !flags.coreOnly) {
|
|
365
454
|
runSkillsInstall(flags.global);
|
|
366
455
|
}
|
|
367
456
|
|
|
457
|
+
// Step 2: Web App Skills (--web / Auto-Detect)
|
|
458
|
+
const hasWebFramework = !flags.global && WEB_FRAMEWORKS.some((fw) => fw in pkgDeps);
|
|
459
|
+
let installWeb = false;
|
|
460
|
+
if (flags.coreOnly) {
|
|
461
|
+
installWeb = false;
|
|
462
|
+
} else if (flags.web) {
|
|
463
|
+
installWeb = true;
|
|
464
|
+
} else if (flags.yes) {
|
|
465
|
+
installWeb = hasWebFramework;
|
|
466
|
+
} else {
|
|
467
|
+
const webPrompt = hasWebFramework
|
|
468
|
+
? "\nIs this a web app? Installs agent-browser + modern-web-guidance (Y/n): "
|
|
469
|
+
: "\nIs this a web app? Installs agent-browser + modern-web-guidance (y/N): ";
|
|
470
|
+
installWeb = await promptYesNo(webPrompt, hasWebFramework);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (installWeb) {
|
|
474
|
+
runNpxSkills(
|
|
475
|
+
[
|
|
476
|
+
"skills",
|
|
477
|
+
"add",
|
|
478
|
+
"vercel-labs/agent-browser",
|
|
479
|
+
"--skill",
|
|
480
|
+
"agent-browser",
|
|
481
|
+
"--skill",
|
|
482
|
+
"modern-web-guidance",
|
|
483
|
+
"-a",
|
|
484
|
+
"kiro-cli",
|
|
485
|
+
"-y"
|
|
486
|
+
],
|
|
487
|
+
flags.global
|
|
488
|
+
);
|
|
489
|
+
appendAllowRules(homeKiroDir, ["agent-browser *", "npx modern-web-guidance*"], tracker);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Step 3: Security Audit Skills (--security / Smart --yes)
|
|
493
|
+
let installSecurity = false;
|
|
494
|
+
if (flags.coreOnly) {
|
|
495
|
+
installSecurity = false;
|
|
496
|
+
} else if (flags.security || flags.yes) {
|
|
497
|
+
installSecurity = true;
|
|
498
|
+
} else {
|
|
499
|
+
installSecurity = await promptYesNo("\nAdd code security-audit skills? (Y/n): ", true);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (installSecurity) {
|
|
503
|
+
runNpxSkills(
|
|
504
|
+
["skills", "add", "cloudflare/security-audit-skill", "--skill", "security-audit", "-a", "kiro-cli", "-y"],
|
|
505
|
+
flags.global
|
|
506
|
+
);
|
|
507
|
+
runNpxSkills(
|
|
508
|
+
["skills", "add", "getsentry/skills", "--skill", "security-review", "-a", "kiro-cli", "-y"],
|
|
509
|
+
flags.global
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
if ("better-auth" in pkgDeps) {
|
|
513
|
+
runNpxSkills(
|
|
514
|
+
[
|
|
515
|
+
"skills",
|
|
516
|
+
"add",
|
|
517
|
+
"better-auth/skills",
|
|
518
|
+
"--skill",
|
|
519
|
+
"better-auth-security-best-practices",
|
|
520
|
+
"-a",
|
|
521
|
+
"kiro-cli",
|
|
522
|
+
"-y"
|
|
523
|
+
],
|
|
524
|
+
flags.global
|
|
525
|
+
);
|
|
526
|
+
} else {
|
|
527
|
+
console.log(
|
|
528
|
+
"ℹ better-auth not in package.json yet — added auto-watcher to install better-auth-security-best-practices if you add it later!"
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
appendAllowRules(homeKiroDir, ["pnpm audit*", "npm audit*"], tracker);
|
|
533
|
+
}
|
|
534
|
+
|
|
368
535
|
// Summary
|
|
369
536
|
const bundledSkills = fs
|
|
370
537
|
.readdirSync(path.join(TEMPLATES_DIR, "skills"), { withFileTypes: true })
|
|
@@ -380,6 +547,11 @@ async function main() {
|
|
|
380
547
|
`Detected Stack: pm=${stack.pm}, linter=${stack.linter ?? "none (disabled)"}, typescript=${stack.typescript ? "yes" : "no (disabled)"}`
|
|
381
548
|
);
|
|
382
549
|
}
|
|
550
|
+
if (installWeb) {
|
|
551
|
+
console.log(
|
|
552
|
+
"\nWeb tip: Run \"npm install -g agent-browser && agent-browser install\" once if you haven't installed the browser binary yet."
|
|
553
|
+
);
|
|
554
|
+
}
|
|
383
555
|
console.log("\nNext steps in Kiro CLI V3:");
|
|
384
556
|
console.log(" 1. Enable \"Approve for me\" and Workflows (chat.enableWorkflows) in Kiro settings.");
|
|
385
557
|
console.log(" 2. Set /effort medium for daily work (or high for complex debugging) and start a fresh kiro-cli session.");
|
package/package.json
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const fs = require("node:fs");
|
|
2
|
+
const path = require("node:path");
|
|
3
|
+
const os = require("node:os");
|
|
4
|
+
const { execFileSync } = require("node:child_process");
|
|
5
|
+
|
|
6
|
+
const WEB_FRAMEWORKS = new Set([
|
|
7
|
+
"next",
|
|
8
|
+
"react",
|
|
9
|
+
"vite",
|
|
10
|
+
"vue",
|
|
11
|
+
"svelte",
|
|
12
|
+
"astro",
|
|
13
|
+
"nuxt",
|
|
14
|
+
"remix",
|
|
15
|
+
"@tanstack/react-start"
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
function isSkillInstalled(skillName) {
|
|
19
|
+
const localSkill = path.join(process.cwd(), ".kiro", "skills", skillName, "SKILL.md");
|
|
20
|
+
const globalSkill = path.join(os.homedir(), ".kiro", "skills", skillName, "SKILL.md");
|
|
21
|
+
return fs.existsSync(localSkill) || fs.existsSync(globalSkill);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function ensureWebPermissions() {
|
|
25
|
+
const permPath = path.join(os.homedir(), ".kiro", "settings", "permissions.yaml");
|
|
26
|
+
if (!fs.existsSync(permPath)) return;
|
|
27
|
+
let content = fs.readFileSync(permPath, "utf8");
|
|
28
|
+
const rulesToAdd = [];
|
|
29
|
+
if (!content.includes('"agent-browser *"')) {
|
|
30
|
+
rulesToAdd.push(' - tool: shell\n command: "agent-browser *"');
|
|
31
|
+
}
|
|
32
|
+
if (!content.includes('"npx modern-web-guidance*"')) {
|
|
33
|
+
rulesToAdd.push(' - tool: shell\n command: "npx modern-web-guidance*"');
|
|
34
|
+
}
|
|
35
|
+
if (rulesToAdd.length > 0 && content.includes("allow:\n")) {
|
|
36
|
+
content = content.replace("allow:\n", `allow:\n${rulesToAdd.join("\n")}\n`);
|
|
37
|
+
fs.writeFileSync(permPath, content, "utf8");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const pkgPath = path.join(process.cwd(), "package.json");
|
|
43
|
+
if (!fs.existsSync(pkgPath)) process.exit(0);
|
|
44
|
+
|
|
45
|
+
// Fast exit (<1ms) if package.json mtime hasn't changed since last check
|
|
46
|
+
const stat = fs.statSync(pkgPath);
|
|
47
|
+
const kiroDir = path.join(process.cwd(), ".kiro");
|
|
48
|
+
const statePath = path.join(kiroDir, ".stack-sync-state.json");
|
|
49
|
+
if (fs.existsSync(statePath)) {
|
|
50
|
+
try {
|
|
51
|
+
const prev = JSON.parse(fs.readFileSync(statePath, "utf8"));
|
|
52
|
+
if (prev.mtimeMs === stat.mtimeMs) process.exit(0);
|
|
53
|
+
} catch {}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
57
|
+
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
|
|
58
|
+
const depNames = Object.keys(deps);
|
|
59
|
+
|
|
60
|
+
// 1. Auto-sync Web App skills when Next.js / React / Vite etc. is installed
|
|
61
|
+
const hasWeb = depNames.some((d) => WEB_FRAMEWORKS.has(d));
|
|
62
|
+
if (hasWeb && (!isSkillInstalled("agent-browser") || !isSkillInstalled("modern-web-guidance"))) {
|
|
63
|
+
console.log("[kiro-10x-better] Detected web framework in package.json — installing agent-browser + modern-web-guidance...");
|
|
64
|
+
execFileSync(
|
|
65
|
+
"npx",
|
|
66
|
+
["skills", "add", "vercel-labs/agent-browser", "--skill", "agent-browser", "--skill", "modern-web-guidance", "-a", "kiro-cli", "-y"],
|
|
67
|
+
{ stdio: "inherit", shell: process.platform === "win32", timeout: 50000 }
|
|
68
|
+
);
|
|
69
|
+
ensureWebPermissions();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 2. Auto-sync Better Auth security skill when better-auth is installed
|
|
73
|
+
if (deps["better-auth"] && !isSkillInstalled("better-auth-security-best-practices")) {
|
|
74
|
+
console.log("[kiro-10x-better] Detected better-auth in package.json — installing better-auth-security-best-practices...");
|
|
75
|
+
execFileSync(
|
|
76
|
+
"npx",
|
|
77
|
+
["skills", "add", "better-auth/skills", "--skill", "better-auth-security-best-practices", "-a", "kiro-cli", "-y"],
|
|
78
|
+
{ stdio: "inherit", shell: process.platform === "win32", timeout: 50000 }
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (fs.existsSync(kiroDir)) {
|
|
83
|
+
fs.writeFileSync(statePath, JSON.stringify({ mtimeMs: stat.mtimeMs }), "utf8");
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
// Never block Kiro CLI if offline or npx is unavailable
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "v1",
|
|
3
|
+
"hooks": [
|
|
4
|
+
{
|
|
5
|
+
"name": "sync-stack-skills-on-start",
|
|
6
|
+
"description": "Auto-installs Web and Better Auth skills when matching packages appear in package.json",
|
|
7
|
+
"trigger": "SessionStart",
|
|
8
|
+
"action": {
|
|
9
|
+
"type": "command",
|
|
10
|
+
"command": "node -e \"const fs=require('fs'),p=require('path'),os=require('os'),loc=p.join('.kiro','hooks','scripts','sync-stack-skills.cjs'),glob=p.join(os.homedir(),'.kiro','hooks','scripts','sync-stack-skills.cjs');require(fs.existsSync(loc)?p.resolve(loc):glob)\""
|
|
11
|
+
},
|
|
12
|
+
"timeout": 60,
|
|
13
|
+
"enabled": true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "sync-stack-skills-on-pkg-save",
|
|
17
|
+
"description": "Auto-installs Web and Better Auth skills when package.json is saved",
|
|
18
|
+
"trigger": "PostFileSave",
|
|
19
|
+
"matcher": "package\\.json$",
|
|
20
|
+
"action": {
|
|
21
|
+
"type": "command",
|
|
22
|
+
"command": "node -e \"const fs=require('fs'),p=require('path'),os=require('os'),loc=p.join('.kiro','hooks','scripts','sync-stack-skills.cjs'),glob=p.join(os.homedir(),'.kiro','hooks','scripts','sync-stack-skills.cjs');require(fs.existsSync(loc)?p.resolve(loc):glob)\""
|
|
23
|
+
},
|
|
24
|
+
"timeout": 60,
|
|
25
|
+
"enabled": true
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "sync-stack-skills-on-shell",
|
|
29
|
+
"description": "Checks package.json mtime after shell installs (e.g. create-next-app or pnpm add)",
|
|
30
|
+
"trigger": "PostToolUse",
|
|
31
|
+
"matcher": "shell",
|
|
32
|
+
"action": {
|
|
33
|
+
"type": "command",
|
|
34
|
+
"command": "node -e \"const fs=require('fs'),p=require('path'),os=require('os'),loc=p.join('.kiro','hooks','scripts','sync-stack-skills.cjs'),glob=p.join(os.homedir(),'.kiro','hooks','scripts','sync-stack-skills.cjs');require(fs.existsSync(loc)?p.resolve(loc):glob)\""
|
|
35
|
+
},
|
|
36
|
+
"timeout": 60,
|
|
37
|
+
"enabled": true
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|