ai-policy-pack-cli 0.1.1 → 0.1.3

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 CHANGED
@@ -26,7 +26,7 @@ npx ai-policy-pack-cli install --targets cursor,copilot,antigravity,claude --yes
26
26
  ### Install
27
27
 
28
28
  ```bash
29
- npx ai-policy-pack-cli install [--targets cursor,copilot,antigravity,claude] [--preset karpathy] [--yes] [--dry-run]
29
+ npx ai-policy-pack-cli install [--targets cursor,copilot,antigravity,claude] [--preset anhtdq] [--yes] [--dry-run]
30
30
  ```
31
31
 
32
32
  - Generates target files from preset
@@ -45,7 +45,7 @@ npx ai-policy-pack-cli verify
45
45
  ### Update
46
46
 
47
47
  ```bash
48
- npx ai-policy-pack-cli update [--preset karpathy] [--yes] [--dry-run]
48
+ npx ai-policy-pack-cli update [--preset anhtdq] [--yes] [--dry-run]
49
49
  ```
50
50
 
51
51
  - Re-applies current targets from manifest
@@ -55,7 +55,7 @@ npx ai-policy-pack-cli update [--preset karpathy] [--yes] [--dry-run]
55
55
 
56
56
  Current default preset:
57
57
 
58
- - `presets/karpathy/policy.yml`
58
+ - `presets/anhtdq/policy.yml`
59
59
 
60
60
  Preset layout:
61
61
 
@@ -8,16 +8,7 @@ export class AntigravityAdapter {
8
8
  "",
9
9
  "Shared rules for all compatible AI coding tools.",
10
10
  "",
11
- "## Core Rules",
12
- ...policy.globalRules.map((rule) => `- ${rule}`),
13
- "",
14
- "## Language-Specific Rules",
15
- ...policy.fileRules.flatMap((rule) => [
16
- `### ${rule.name}`,
17
- `Applies to: ${rule.patterns.join(", ")}`,
18
- ...rule.rules.map((item) => `- ${item}`),
19
- ""
20
- ])
11
+ policy.guidelineMarkdown
21
12
  ].join("\n");
22
13
  files.push({
23
14
  path: "AGENTS.md",
@@ -6,16 +6,7 @@ export class ClaudeAdapter {
6
6
  "",
7
7
  "Project instructions for Claude-compatible agents.",
8
8
  "",
9
- "## Core Rules",
10
- ...policy.globalRules.map((rule) => `- ${rule}`),
11
- "",
12
- "## File-Specific Rules",
13
- ...policy.fileRules.flatMap((rule) => [
14
- `### ${rule.name}`,
15
- `Applies to: ${rule.patterns.join(", ")}`,
16
- ...rule.rules.map((item) => `- ${item}`),
17
- ""
18
- ])
9
+ policy.guidelineMarkdown
19
10
  ].join("\n");
20
11
  return [
21
12
  {
@@ -8,28 +8,13 @@ export class CopilotAdapter {
8
8
  "",
9
9
  ...(override?.repoIntro ?? []),
10
10
  ...(override?.repoIntro?.length ? [""] : []),
11
- "## Core Rules",
12
- ...policy.globalRules.map((rule) => `- ${rule}`)
11
+ policy.guidelineMarkdown
13
12
  ].join("\n");
14
13
  files.push({
15
14
  path: ".github/copilot-instructions.md",
16
15
  content: `${repoWide}\n`
17
16
  });
18
- for (const fileRule of policy.fileRules) {
19
- const scoped = [
20
- "---",
21
- `applyTo: "${fileRule.patterns.join(",")}"`,
22
- "---",
23
- "",
24
- `# ${fileRule.name}`,
25
- "",
26
- ...fileRule.rules.map((rule) => `- ${rule}`)
27
- ].join("\n");
28
- files.push({
29
- path: `.github/instructions/${fileRule.name}.instructions.md`,
30
- content: `${scoped}\n`
31
- });
32
- }
17
+ void policy.fileRules;
33
18
  return files;
34
19
  }
35
20
  }
@@ -8,37 +8,15 @@ export class CursorAdapter {
8
8
  "alwaysApply: true",
9
9
  "---",
10
10
  "",
11
- "# Team Global Rules",
11
+ "# Team Global Guidelines",
12
12
  "",
13
- ...policy.globalRules.map((rule) => `- ${rule}`)
13
+ policy.guidelineMarkdown
14
14
  ].join("\n");
15
15
  files.push({
16
16
  path: ".cursor/rules/global-policy.mdc",
17
17
  content: `${globalContent}\n`
18
18
  });
19
- for (const fileRule of policy.fileRules) {
20
- const content = [
21
- "---",
22
- `description: ${fileRule.name} generated by ai-policy-pack`,
23
- `globs: ${fileRule.patterns.join(",")}`,
24
- "alwaysApply: false",
25
- "---",
26
- "",
27
- `# ${toTitleCase(fileRule.name)}`,
28
- "",
29
- ...fileRule.rules.map((rule) => `- ${rule}`)
30
- ].join("\n");
31
- files.push({
32
- path: `.cursor/rules/${fileRule.name}.mdc`,
33
- content: `${content}\n`
34
- });
35
- }
19
+ void policy.fileRules;
36
20
  return files;
37
21
  }
38
22
  }
39
- function toTitleCase(value) {
40
- return value
41
- .split("-")
42
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
43
- .join(" ");
44
- }
@@ -6,7 +6,7 @@ import { renderForTargets } from "../core/render.js";
6
6
  import { CliError } from "../core/errors.js";
7
7
  export async function runInstallCommand(args, deps) {
8
8
  const targets = await resolveTargets(args);
9
- const presetName = args.preset ?? "karpathy";
9
+ const presetName = args.preset ?? "anhtdq";
10
10
  const policy = await loadPolicyPreset(deps.cwd, presetName, deps.packageRoot);
11
11
  const files = renderForTargets(policy, targets);
12
12
  deps.logger.info(`Preset: ${policy.name}`);
@@ -4,12 +4,14 @@ export function validatePolicyPreset(input) {
4
4
  }
5
5
  const name = expectString(input.name, "name");
6
6
  const description = optionalString(input.description, "description");
7
+ const guidelineMarkdown = expectString(input.guidelineMarkdown, "guidelineMarkdown");
7
8
  const globalRules = expectStringArray(input.globalRules, "globalRules");
8
9
  const fileRules = expectFileRules(input.fileRules);
9
10
  const targetOverrides = expectTargetOverrides(input.targetOverrides);
10
11
  return {
11
12
  name,
12
13
  description,
14
+ guidelineMarkdown,
13
15
  globalRules,
14
16
  fileRules,
15
17
  targetOverrides
@@ -4,7 +4,7 @@ import { renderForTargets } from "../src/core/render.js";
4
4
  const CWD = "d:/ATS/Project/AI/rulecusor";
5
5
  describe("adapters render", () => {
6
6
  it("renders target-specific files", async () => {
7
- const policy = await loadPolicyPreset(CWD, "karpathy", CWD);
7
+ const policy = await loadPolicyPreset(CWD, "anhtdq", CWD);
8
8
  const files = renderForTargets(policy, ["cursor", "copilot", "antigravity", "claude"]);
9
9
  const paths = files.map((item) => item.path).sort();
10
10
  expect(paths).toContain(".cursor/rules/global-policy.mdc");
@@ -8,7 +8,7 @@ describe("parseArgs", () => {
8
8
  "--targets",
9
9
  "cursor,copilot",
10
10
  "--preset",
11
- "karpathy",
11
+ "anhtdq",
12
12
  "--yes",
13
13
  "--dry-run",
14
14
  "--force"
@@ -16,7 +16,7 @@ describe("parseArgs", () => {
16
16
  expect(parsed).toEqual({
17
17
  command: "install",
18
18
  targets: ["cursor", "copilot"],
19
- preset: "karpathy",
19
+ preset: "anhtdq",
20
20
  yes: true,
21
21
  dryRun: true,
22
22
  force: true
@@ -24,6 +24,6 @@ describe("runtime path behavior", () => {
24
24
  packageVersion: "0.1.0",
25
25
  logger: silentLogger
26
26
  });
27
- await expect(fs.readFile(path.join(projectWorkspace, ".cursor/rules/global-policy.mdc"), "utf8")).resolves.toContain("Team Global Rules");
27
+ await expect(fs.readFile(path.join(projectWorkspace, ".cursor/rules/global-policy.mdc"), "utf8")).resolves.toContain("Think Before Coding");
28
28
  });
29
29
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-policy-pack-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Multi-IDE AI policy pack generator for Cursor, Copilot, Antigravity, and Claude",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,102 @@
1
+ name: anhtdq
2
+ description: Behavioral guardrails to reduce common LLM coding mistakes across all code
3
+ guidelineMarkdown: |
4
+ Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
5
+
6
+ **Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
7
+
8
+ ## 1. Think Before Coding
9
+
10
+ **Don't assume. Don't hide confusion. Surface tradeoffs.**
11
+
12
+ Before implementing:
13
+ - State your assumptions explicitly. If uncertain, ask.
14
+ - If multiple interpretations exist, present them - don't pick silently.
15
+ - If a simpler approach exists, say so. Push back when warranted.
16
+ - If something is unclear, stop. Name what's confusing. Ask.
17
+
18
+ ## 2. Simplicity First
19
+
20
+ **Minimum code that solves the problem. Nothing speculative.**
21
+
22
+ - No features beyond what was asked.
23
+ - No abstractions for single-use code.
24
+ - No "flexibility" or "configurability" that wasn't requested.
25
+ - No error handling for impossible scenarios.
26
+ - If you write 200 lines and it could be 50, rewrite it.
27
+
28
+ Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
29
+
30
+ ## 3. Surgical Changes
31
+
32
+ **Touch only what you must. Clean up only your own mess.**
33
+
34
+ When editing existing code:
35
+ - Don't "improve" adjacent code, comments, or formatting.
36
+ - Don't refactor things that aren't broken.
37
+ - Match existing style, even if you'd do it differently.
38
+ - If you notice unrelated dead code, mention it - don't delete it.
39
+
40
+ When your changes create orphans:
41
+ - Remove imports/variables/functions that YOUR changes made unused.
42
+ - Don't remove pre-existing dead code unless asked.
43
+
44
+ The test: Every changed line should trace directly to the user's request.
45
+
46
+ ## 4. Goal-Driven Execution
47
+
48
+ **Define success criteria. Loop until verified.**
49
+
50
+ Transform tasks into verifiable goals:
51
+ - "Add validation" -> "Write tests for invalid inputs, then make them pass"
52
+ - "Fix the bug" -> "Write a test that reproduces it, then make it pass"
53
+ - "Refactor X" -> "Ensure tests pass before and after"
54
+
55
+ For multi-step tasks, state a brief plan:
56
+ ```
57
+ 1. [Step] -> verify: [check]
58
+ 2. [Step] -> verify: [check]
59
+ 3. [Step] -> verify: [check]
60
+ ```
61
+
62
+ Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
63
+
64
+ ---
65
+
66
+ **These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
67
+ globalRules:
68
+ - Before implementing, state assumptions explicitly. If uncertain, ask instead of guessing.
69
+ - If multiple interpretations exist, surface them and confirm direction before coding.
70
+ - If a simpler approach exists, recommend it and explain the tradeoff.
71
+ - If requirements are unclear or contradictory, stop and ask a focused clarification question.
72
+ - Implement the minimum code that solves the requested problem.
73
+ - Do not add speculative features or future-proof abstractions unless explicitly requested.
74
+ - Do not add configurability that is not required by the task.
75
+ - Do not add error handling for impossible scenarios.
76
+ - If implementation feels overcomplicated, simplify until it is easy to reason about.
77
+ - Touch only lines required by the requested change.
78
+ - Do not refactor unrelated modules or formatting during focused tasks.
79
+ - Match existing project patterns and style unless user asks to change conventions.
80
+ - If unrelated dead code is discovered, mention it but do not delete it automatically.
81
+ - Remove only orphaned code introduced by your own change.
82
+ - Define clear success criteria before implementation.
83
+ - Convert requests into verifiable goals with checks or tests.
84
+ - For bug fixes, reproduce with a failing test/check first, then fix, then verify pass.
85
+ - For refactors, verify behavior before and after with stable checks.
86
+ - For multi-step work, provide a short step plan with explicit verification at each step.
87
+ - Do not claim completion until verification actually passes.
88
+ fileRules:
89
+ - name: universal-code-rules
90
+ patterns:
91
+ - "**/*"
92
+ rules:
93
+ - Apply these standards to all code and configuration files unless the user explicitly narrows scope.
94
+ - Prefer readable, straightforward code and avoid hidden magic.
95
+ - Keep changes cohesive, easy to review, and directly traceable to the request.
96
+ targetOverrides:
97
+ antigravity:
98
+ geminiRules:
99
+ - Keep AGENTS.md as shared cross-tool policy and use GEMINI.md only for Antigravity-specific overrides.
100
+ copilot:
101
+ repoIntro:
102
+ - Follow repository build, test, and lint commands from project documentation before submitting changes.
@@ -1,30 +0,0 @@
1
- name: karpathy
2
- description: Karpathy-inspired guardrails adapted for multi-IDE agents
3
- globalRules:
4
- - State assumptions and ask clarifying questions before coding when requirements are ambiguous.
5
- - Prefer the simplest implementation that solves the user's request; avoid speculative abstractions.
6
- - Keep changes surgical and scoped to the requested task; avoid unrelated refactors.
7
- - Define explicit success criteria and verify changes with tests or commands before claiming completion.
8
- - Remove dead code created by your own change but do not clean unrelated legacy code unless asked.
9
- fileRules:
10
- - name: typescript-standards
11
- patterns:
12
- - "**/*.ts"
13
- - "**/*.tsx"
14
- rules:
15
- - Favor strict typing and avoid any unless there is a documented reason.
16
- - Keep functions focused and small; split logic when a function mixes responsibilities.
17
- - Add concise comments only when code intent is not obvious.
18
- - name: python-standards
19
- patterns:
20
- - "**/*.py"
21
- rules:
22
- - Prefer explicit names over abbreviations and keep functions single-purpose.
23
- - Handle expected exceptions explicitly and include actionable error messages.
24
- targetOverrides:
25
- antigravity:
26
- geminiRules:
27
- - Use GEMINI.md for tool-specific overrides and AGENTS.md for shared team policy.
28
- copilot:
29
- repoIntro:
30
- - Follow repository build, test, and lint commands from project docs before submitting changes.