@rafter-security/cli 0.6.6 → 0.7.1

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.
Files changed (70) hide show
  1. package/README.md +29 -10
  2. package/dist/commands/agent/audit-skill.js +22 -20
  3. package/dist/commands/agent/audit.js +27 -0
  4. package/dist/commands/agent/components.js +800 -0
  5. package/dist/commands/agent/config.js +2 -1
  6. package/dist/commands/agent/disable.js +47 -0
  7. package/dist/commands/agent/enable.js +50 -0
  8. package/dist/commands/agent/exec.js +2 -0
  9. package/dist/commands/agent/index.js +6 -0
  10. package/dist/commands/agent/init.js +162 -163
  11. package/dist/commands/agent/install-hook.js +15 -14
  12. package/dist/commands/agent/list.js +72 -0
  13. package/dist/commands/agent/scan.js +4 -3
  14. package/dist/commands/agent/verify.js +1 -1
  15. package/dist/commands/backend/run.js +12 -3
  16. package/dist/commands/backend/scan-status.js +3 -2
  17. package/dist/commands/brief.js +22 -2
  18. package/dist/commands/ci/init.js +25 -21
  19. package/dist/commands/completion.js +4 -3
  20. package/dist/commands/docs/index.js +18 -0
  21. package/dist/commands/docs/list.js +37 -0
  22. package/dist/commands/docs/show.js +64 -0
  23. package/dist/commands/mcp/server.js +84 -0
  24. package/dist/commands/report.js +42 -41
  25. package/dist/commands/scan/index.js +7 -5
  26. package/dist/commands/skill/index.js +14 -0
  27. package/dist/commands/skill/install.js +89 -0
  28. package/dist/commands/skill/list.js +79 -0
  29. package/dist/commands/skill/registry.js +273 -0
  30. package/dist/commands/skill/remote.js +333 -0
  31. package/dist/commands/skill/review.js +975 -0
  32. package/dist/commands/skill/uninstall.js +65 -0
  33. package/dist/core/audit-logger.js +262 -21
  34. package/dist/core/config-manager.js +3 -0
  35. package/dist/core/docs-loader.js +148 -0
  36. package/dist/core/policy-loader.js +72 -1
  37. package/dist/core/risk-rules.js +16 -3
  38. package/dist/index.js +19 -9
  39. package/dist/scanners/gitleaks.js +6 -2
  40. package/package.json +1 -1
  41. package/resources/skills/rafter/SKILL.md +77 -97
  42. package/resources/skills/rafter/docs/backend.md +106 -0
  43. package/resources/skills/rafter/docs/cli-reference.md +199 -0
  44. package/resources/skills/rafter/docs/finding-triage.md +79 -0
  45. package/resources/skills/rafter/docs/guardrails.md +91 -0
  46. package/resources/skills/rafter/docs/shift-left.md +64 -0
  47. package/resources/skills/rafter-agent-security/SKILL.md +1 -1
  48. package/resources/skills/rafter-code-review/SKILL.md +91 -0
  49. package/resources/skills/rafter-code-review/docs/api.md +90 -0
  50. package/resources/skills/rafter-code-review/docs/asvs.md +120 -0
  51. package/resources/skills/rafter-code-review/docs/cwe-top25.md +78 -0
  52. package/resources/skills/rafter-code-review/docs/investigation-playbook.md +101 -0
  53. package/resources/skills/rafter-code-review/docs/llm.md +87 -0
  54. package/resources/skills/rafter-code-review/docs/web-app.md +84 -0
  55. package/resources/skills/rafter-secure-design/SKILL.md +103 -0
  56. package/resources/skills/rafter-secure-design/docs/api-design.md +97 -0
  57. package/resources/skills/rafter-secure-design/docs/auth.md +67 -0
  58. package/resources/skills/rafter-secure-design/docs/data-storage.md +90 -0
  59. package/resources/skills/rafter-secure-design/docs/dependencies.md +101 -0
  60. package/resources/skills/rafter-secure-design/docs/deployment.md +104 -0
  61. package/resources/skills/rafter-secure-design/docs/ingestion.md +98 -0
  62. package/resources/skills/rafter-secure-design/docs/standards-pointers.md +102 -0
  63. package/resources/skills/rafter-secure-design/docs/threat-modeling.md +128 -0
  64. package/resources/skills/rafter-skill-review/SKILL.md +106 -0
  65. package/resources/skills/rafter-skill-review/docs/authorship-provenance.md +82 -0
  66. package/resources/skills/rafter-skill-review/docs/changelog-review.md +99 -0
  67. package/resources/skills/rafter-skill-review/docs/data-practices.md +88 -0
  68. package/resources/skills/rafter-skill-review/docs/malware-indicators.md +79 -0
  69. package/resources/skills/rafter-skill-review/docs/prompt-injection.md +85 -0
  70. package/resources/skills/rafter-skill-review/docs/telemetry.md +78 -0
@@ -1,5 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import { ConfigManager } from "../../core/config-manager.js";
3
+ import { fmt } from "../../utils/formatter.js";
3
4
  export function createConfigCommand() {
4
5
  const config = new Command("config")
5
6
  .description("Manage agent configuration");
@@ -48,7 +49,7 @@ export function createConfigCommand() {
48
49
  // Use as string
49
50
  }
50
51
  manager.set(key, parsedValue);
51
- console.log(`✓ Set ${key} = ${JSON.stringify(parsedValue)}`);
52
+ console.log(fmt.success(`Set ${key} = ${JSON.stringify(parsedValue)}`));
52
53
  });
53
54
  return config;
54
55
  }
@@ -0,0 +1,47 @@
1
+ import { Command } from "commander";
2
+ import { resolveComponent, recordComponentState, getComponentRegistry } from "./components.js";
3
+ import { fmt } from "../../utils/formatter.js";
4
+ /**
5
+ * `rafter agent disable <component-id>...` — uninstall one or more specific components.
6
+ * For hook/MCP entries, removes rafter's entries from the shared config file. For skills
7
+ * and our own instruction files, deletes them. Other (non-rafter) entries are preserved.
8
+ *
9
+ * Exit codes: 0 success · 1 invalid id or uninstall failure.
10
+ */
11
+ export function createDisableCommand() {
12
+ return new Command("disable")
13
+ .description("Uninstall a specific agent component (e.g. claude-code.mcp, cursor.hooks)")
14
+ .argument("<components...>", "Component IDs to uninstall")
15
+ .action((components) => {
16
+ let exitCode = 0;
17
+ const seenIds = new Set();
18
+ for (const raw of components) {
19
+ if (seenIds.has(raw))
20
+ continue;
21
+ seenIds.add(raw);
22
+ const spec = resolveComponent(raw);
23
+ if (!spec) {
24
+ console.error(fmt.error(`Unknown component: ${raw}`));
25
+ console.error(fmt.info(`Run 'rafter agent list' to see available components. Known IDs: ${getComponentRegistry().map((c) => c.id).join(", ")}`));
26
+ exitCode = 1;
27
+ continue;
28
+ }
29
+ try {
30
+ const wasInstalled = spec.isInstalled();
31
+ spec.uninstall();
32
+ recordComponentState(spec.id, false);
33
+ if (wasInstalled) {
34
+ console.log(fmt.success(`Disabled ${spec.id} (removed from ${spec.path})`));
35
+ }
36
+ else {
37
+ console.log(fmt.info(`${spec.id} was not installed — no changes`));
38
+ }
39
+ }
40
+ catch (e) {
41
+ console.error(fmt.error(`Failed to disable ${spec.id}: ${e}`));
42
+ exitCode = 1;
43
+ }
44
+ }
45
+ process.exit(exitCode);
46
+ });
47
+ }
@@ -0,0 +1,50 @@
1
+ import { Command } from "commander";
2
+ import fs from "fs";
3
+ import { resolveComponent, recordComponentState, getComponentRegistry } from "./components.js";
4
+ import { fmt } from "../../utils/formatter.js";
5
+ /**
6
+ * `rafter agent enable <component-id>...` — install one or more specific components.
7
+ * This is the fine-grained complement to `rafter agent init --with-<platform>`; it
8
+ * targets a single (platform, kind) pair rather than a whole platform.
9
+ *
10
+ * Exit codes: 0 success · 1 invalid id or install failure · 2 platform not detected
11
+ * (unless --force is passed).
12
+ */
13
+ export function createEnableCommand() {
14
+ return new Command("enable")
15
+ .description("Install a specific agent component (e.g. claude-code.mcp, cursor.hooks)")
16
+ .argument("<components...>", "Component IDs to install")
17
+ .option("--force", "Install even if platform is not detected on this machine")
18
+ .action((components, opts) => {
19
+ let exitCode = 0;
20
+ const seenIds = new Set();
21
+ for (const raw of components) {
22
+ if (seenIds.has(raw))
23
+ continue;
24
+ seenIds.add(raw);
25
+ const spec = resolveComponent(raw);
26
+ if (!spec) {
27
+ console.error(fmt.error(`Unknown component: ${raw}`));
28
+ console.error(fmt.info(`Run 'rafter agent list' to see available components. Known IDs: ${getComponentRegistry().map((c) => c.id).join(", ")}`));
29
+ exitCode = 1;
30
+ continue;
31
+ }
32
+ const detected = fs.existsSync(spec.detectDir);
33
+ if (!detected && !opts.force) {
34
+ console.error(fmt.warning(`${spec.id}: platform not detected (${spec.detectDir}). Re-run with --force to install anyway.`));
35
+ exitCode = exitCode || 2;
36
+ continue;
37
+ }
38
+ try {
39
+ spec.install();
40
+ recordComponentState(spec.id, true);
41
+ console.log(fmt.success(`Enabled ${spec.id} → ${spec.path}`));
42
+ }
43
+ catch (e) {
44
+ console.error(fmt.error(`Failed to enable ${spec.id}: ${e}`));
45
+ exitCode = 1;
46
+ }
47
+ }
48
+ process.exit(exitCode);
49
+ });
50
+ }
@@ -112,6 +112,8 @@ async function promptApproval() {
112
112
  output: process.stdout
113
113
  });
114
114
  return new Promise((resolve) => {
115
+ // Handle EOF / non-interactive stdin (e.g. piped or closed stdin)
116
+ rl.on("close", () => resolve(false));
115
117
  rl.question("Approve this command? (yes/no): ", (answer) => {
116
118
  rl.close();
117
119
  const normalized = answer.trim().toLowerCase();
@@ -11,6 +11,9 @@ import { createVerifyCommand } from "./verify.js";
11
11
  import { createStatusCommand } from "./status.js";
12
12
  import { createUpdateGitleaksCommand } from "./update-gitleaks.js";
13
13
  import { createBaselineCommand } from "./baseline.js";
14
+ import { createListCommand } from "./list.js";
15
+ import { createEnableCommand } from "./enable.js";
16
+ import { createDisableCommand } from "./disable.js";
14
17
  export function createAgentCommand() {
15
18
  const agent = new Command("agent")
16
19
  .description("Agent security features");
@@ -27,5 +30,8 @@ export function createAgentCommand() {
27
30
  agent.addCommand(createStatusCommand());
28
31
  agent.addCommand(createUpdateGitleaksCommand());
29
32
  agent.addCommand(createBaselineCommand());
33
+ agent.addCommand(createListCommand());
34
+ agent.addCommand(createEnableCommand());
35
+ agent.addCommand(createDisableCommand());
30
36
  return agent;
31
37
  }