ai-policy-pack-cli 0.1.2 → 0.1.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.
@@ -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
- }
@@ -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
@@ -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.2",
3
+ "version": "0.1.4",
4
4
  "description": "Multi-IDE AI policy pack generator for Cursor, Copilot, Antigravity, and Claude",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,5 +1,79 @@
1
1
  name: anhtdq
2
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
+ ## 5. Documentation Currency Policy
67
+
68
+ - Use `README.md` as the primary module-context document format; keep `AGENTS.md` focused on AI workflow/policy at repository root.
69
+ - Update module `README.md` only when behavior or contracts changed (API/DTO, business flow, schema/migration, module structure, or reusable patterns), not for trivial refactors.
70
+ - For tasks that trigger doc updates, refresh outdated sections and remove stale context in the same task before marking work complete.
71
+ - During pre-implementation, read the nearest module `README.md` to minimize broad code scanning and reduce context usage.
72
+ - Before declaring task completion, report whether docs were updated or intentionally skipped.
73
+
74
+ ---
75
+
76
+ **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.
3
77
  globalRules:
4
78
  - Before implementing, state assumptions explicitly. If uncertain, ask instead of guessing.
5
79
  - If multiple interpretations exist, surface them and confirm direction before coding.
@@ -21,6 +95,11 @@ globalRules:
21
95
  - For refactors, verify behavior before and after with stable checks.
22
96
  - For multi-step work, provide a short step plan with explicit verification at each step.
23
97
  - Do not claim completion until verification actually passes.
98
+ - Use README.md as the primary module-context document format and keep AGENTS.md focused on repository-level AI workflow policy.
99
+ - Update module README.md when behavior/contracts change; skip doc edits for trivial refactors.
100
+ - If docs are required, refresh stale sections in the same task before completion.
101
+ - Read the nearest module README.md before implementation to reduce unnecessary broad scanning.
102
+ - Before closing a task, explicitly report whether docs were updated or intentionally skipped.
24
103
  fileRules:
25
104
  - name: universal-code-rules
26
105
  patterns: