@musashishao/agent-kit 1.9.0 → 1.9.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 (125) hide show
  1. package/.agent/agents/ai-asset-factory.md +700 -0
  2. package/.agent/agents/ai-audio-factory.md +503 -0
  3. package/.agent/agents/game-developer.md +4 -4
  4. package/.agent/agents/orchestrator.md +113 -3
  5. package/.agent/agents/project-planner.md +67 -0
  6. package/.agent/agents/unity-mobile-master.md +949 -0
  7. package/.agent/mcp/config/registry.json +65 -51
  8. package/.agent/mcp/servers/notebooklm/README.md +114 -0
  9. package/.agent/mcp/servers/notebooklm/package.json +35 -0
  10. package/.agent/mcp/servers/notebooklm/src/auth/chrome.ts +225 -0
  11. package/.agent/mcp/servers/notebooklm/src/auth/index.ts +1 -0
  12. package/.agent/mcp/servers/notebooklm/src/index.ts +516 -0
  13. package/.agent/mcp/servers/notebooklm/src/services/index.ts +3 -0
  14. package/.agent/mcp/servers/notebooklm/src/services/library.ts +217 -0
  15. package/.agent/mcp/servers/notebooklm/src/services/notebooklm.ts +380 -0
  16. package/.agent/mcp/servers/notebooklm/tsconfig.json +15 -0
  17. package/.agent/mcp-gateway/README.md +169 -20
  18. package/.agent/mcp-gateway/package.json +22 -7
  19. package/.agent/mcp-gateway/src/auth/index.ts +55 -0
  20. package/.agent/mcp-gateway/src/auth/middleware.ts +242 -0
  21. package/.agent/mcp-gateway/src/auth/oauth.ts +462 -0
  22. package/.agent/mcp-gateway/src/auth/scopes.ts +227 -0
  23. package/.agent/mcp-gateway/src/index.ts +252 -105
  24. package/.agent/mcp-gateway/src/observability/index.ts +5 -0
  25. package/.agent/mcp-gateway/src/observability/otel.ts +405 -0
  26. package/.agent/mcp-gateway/src/transports/index.ts +5 -0
  27. package/.agent/mcp-gateway/src/transports/streamableHttp.ts +235 -0
  28. package/.agent/rules/CODEX.md +89 -0
  29. package/.agent/rules/CODE_RULES.md +73 -0
  30. package/.agent/rules/GEMINI.md +25 -0
  31. package/.agent/rules/MEMORY_STATE.md +110 -0
  32. package/.agent/rules/REFERENCE.md +33 -141
  33. package/.agent/rules/REF_SKILLS.md +116 -0
  34. package/.agent/rules/REF_WORKFLOWS.md +81 -0
  35. package/.agent/scripts/ak_cli.py +106 -5
  36. package/.agent/scripts/memory_manager.py +48 -9
  37. package/.agent/skills/anti-hallucination/SKILL.md +295 -0
  38. package/.agent/skills/anti-hallucination/scripts/check_hallucination.py +299 -0
  39. package/.agent/skills/bifurcation-analysis/SKILL.md +56 -0
  40. package/.agent/skills/brainstorming/SKILL.md +80 -6
  41. package/.agent/skills/decision-memory/SKILL.md +317 -0
  42. package/.agent/skills/emergence-detector/SKILL.md +230 -0
  43. package/.agent/skills/emergence-detector/scripts/check_emergence.py +265 -0
  44. package/.agent/skills/explained-qa/SKILL.md +142 -0
  45. package/.agent/skills/explained-qa/game-terminology.md +214 -0
  46. package/.agent/skills/game-development/ai-dialogue-engine/SKILL.md +442 -0
  47. package/.agent/skills/game-development/ai-graphics-generator/SKILL.md +463 -0
  48. package/.agent/skills/game-development/ai-playtest-framework/SKILL.md +570 -0
  49. package/.agent/skills/game-development/camera-systems/SKILL.md +607 -0
  50. package/.agent/skills/game-development/card-battle-engine/SKILL.md +618 -0
  51. package/.agent/skills/game-development/character-controller-3d/SKILL.md +908 -0
  52. package/.agent/skills/game-development/cloud-save-sync/SKILL.md +527 -0
  53. package/.agent/skills/game-development/combat-system/SKILL.md +748 -0
  54. package/.agent/skills/game-development/compliance-rating/SKILL.md +277 -0
  55. package/.agent/skills/game-development/crossplatform-build/SKILL.md +386 -0
  56. package/.agent/skills/game-development/cultivation-progression/SKILL.md +520 -0
  57. package/.agent/skills/game-development/data-driven-balance/SKILL.md +535 -0
  58. package/.agent/skills/game-development/game-analytics-integrator/SKILL.md +410 -0
  59. package/.agent/skills/game-development/game-audio-advanced/SKILL.md +646 -0
  60. package/.agent/skills/game-development/game-economy-designer/SKILL.md +375 -0
  61. package/.agent/skills/game-development/game-marketing/SKILL.md +85 -0
  62. package/.agent/skills/game-development/game-state-manager/SKILL.md +883 -0
  63. package/.agent/skills/game-development/hybrid-game-spec/SKILL.md +220 -0
  64. package/.agent/skills/game-development/inventory-quest/SKILL.md +747 -0
  65. package/.agent/skills/game-development/liveops/SKILL.md +308 -0
  66. package/.agent/skills/game-development/localization/SKILL.md +286 -0
  67. package/.agent/skills/game-development/mobile-input-patterns/SKILL.md +343 -0
  68. package/.agent/skills/game-development/monetization-strategy/SKILL.md +94 -0
  69. package/.agent/skills/game-development/multiplayer-master/SKILL.md +727 -0
  70. package/.agent/skills/game-development/narrative-branching/SKILL.md +593 -0
  71. package/.agent/skills/game-development/procedural-level-ai/SKILL.md +367 -0
  72. package/.agent/skills/game-development/prototyping-rapid/SKILL.md +205 -0
  73. package/.agent/skills/game-development/spec-ecosystem/SKILL.md +155 -0
  74. package/.agent/skills/game-development/spec-ecosystem/decision-log-format.md +129 -0
  75. package/.agent/skills/game-development/spec-ecosystem/templates/PLAN-template.md +178 -0
  76. package/.agent/skills/game-development/spec-ecosystem/templates/SPEC-template.md +110 -0
  77. package/.agent/skills/game-development/spec-ecosystem/templates/TASKS-template.md +156 -0
  78. package/.agent/skills/game-development/survival-systems/SKILL.md +493 -0
  79. package/.agent/skills/game-development/testing-qa/SKILL.md +270 -0
  80. package/.agent/skills/game-development/unity-mobile-optimization/SKILL.md +271 -0
  81. package/.agent/skills/intent-capture/SKILL.md +65 -0
  82. package/.agent/skills/mcp-composition/SKILL.md +362 -0
  83. package/.agent/skills/mcp-observability/SKILL.md +323 -0
  84. package/.agent/skills/mcp-security/SKILL.md +314 -0
  85. package/.agent/skills/trust-spectrum/SKILL.md +291 -0
  86. package/.agent/skills/vibe-coding-guard/SKILL.md +328 -0
  87. package/.agent/templates/AGENTS.game.md +63 -0
  88. package/.agent/templates/docs/WORKFLOW_GUIDE.en.md +100 -0
  89. package/.agent/templates/docs/WORKFLOW_GUIDE.vi.md +100 -0
  90. package/.agent/workflows/ai-agent.md +2 -0
  91. package/.agent/workflows/autofix.md +1 -0
  92. package/.agent/workflows/brainstorm.md +1 -0
  93. package/.agent/workflows/context.md +1 -0
  94. package/.agent/workflows/create.md +39 -8
  95. package/.agent/workflows/dashboard.md +1 -0
  96. package/.agent/workflows/debug.md +14 -0
  97. package/.agent/workflows/deploy.md +14 -0
  98. package/.agent/workflows/enhance.md +44 -0
  99. package/.agent/workflows/gamekit-init.md +177 -0
  100. package/.agent/workflows/gamekit-launch.md +338 -0
  101. package/.agent/workflows/gamekit-plan.md +204 -0
  102. package/.agent/workflows/gamekit-qa.md +153 -0
  103. package/.agent/workflows/gamekit-spec.md +243 -0
  104. package/.agent/workflows/gamekit-tasks.md +208 -0
  105. package/.agent/workflows/marketing.md +2 -0
  106. package/.agent/workflows/next.md +1 -0
  107. package/.agent/workflows/orchestrate.md +12 -0
  108. package/.agent/workflows/pentest.md +2 -0
  109. package/.agent/workflows/plan.md +42 -0
  110. package/.agent/workflows/preview.md +1 -0
  111. package/.agent/workflows/quality.md +1 -0
  112. package/.agent/workflows/saas.md +2 -0
  113. package/.agent/workflows/spec.md +42 -0
  114. package/.agent/workflows/status.md +1 -0
  115. package/.agent/workflows/test.md +14 -0
  116. package/.agent/workflows/ui-ux-pro-max.md +1 -0
  117. package/bin/cli.js +411 -111
  118. package/package.json +1 -2
  119. package/.agent/agents/game-asset-curator.md +0 -317
  120. package/.agent/agents/game-narrative-designer.md +0 -310
  121. package/.agent/agents/game-qa-agent.md +0 -441
  122. package/.agent/workflows/game-prototype.md +0 -154
  123. package/docs/AI_DATA_INFRASTRUCTURE.md +0 -288
  124. package/docs/CHANGELOG_AI_INFRA.md +0 -141
  125. package/docs/MIGRATION_GUIDE_V1.9.md +0 -55
@@ -0,0 +1,81 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # REF_WORKFLOWS.md - Workflows & Scripts Reference
6
+
7
+ > This module contains lookup tables for workflows and scripts.
8
+
9
+ ---
10
+
11
+ ## Workflows (22)
12
+
13
+ | Command | Purpose |
14
+ |---------|---------|
15
+ | `/ai-agent` | Build AI agent workflow (NEW) |
16
+ | `/marketing` | Marketing campaign planning (NEW) |
17
+ | `/pentest` | Penetration testing workflow (NEW) |
18
+ | `/saas` | SaaS launch workflow (NEW) |
19
+ | `/gamekit-init` | Initialize game project with Spec Ecosystem structure |
20
+ | `/gamekit-spec` | Create game specification with Explained Q&A + GDD |
21
+ | `/gamekit-plan` | Generate implementation plan from approved spec |
22
+ | `/gamekit-tasks` | Generate executable task list from approved plan |
23
+ | `/gamekit-qa` | **Playtest and QA loop for iterative refinement (NEW)** |
24
+ | `/gamekit-launch` | **Mobile game launch: Build → Store → Post-launch (NEW)** |
25
+ | `/autofix` | Autonomous self-healing loop |
26
+ | `/brainstorm` | Structured brainstorming |
27
+ | `/context` | Optimal context generation |
28
+ | `/create` | Create new applications |
29
+ | `/dashboard` | Visual project dashboards |
30
+ | `/debug` | Systematic investigation |
31
+ | `/deploy` | Production deployment |
32
+ | `/enhance` | Add/update features |
33
+ | `/next` | Next development steps |
34
+ | `/orchestrate` | Multi-agent coordination |
35
+ | `/plan` | Project planning |
36
+ | `/preview` | Dev server management |
37
+ | `/quality` | Context/output optimization |
38
+ | `/spec` | Specification documents |
39
+ | `/status` | Project/agent status |
40
+ | `/test` | Create and run tests |
41
+ | `/ui-ux-pro-max` | Professional UI/UX planning |
42
+
43
+ ---
44
+
45
+ ## Available Scripts (12 total)
46
+
47
+ | Script | Skill | When to Use |
48
+ |--------|-------|-------------|
49
+ | `security_scan.py` | vulnerability-scanner | Always on deploy |
50
+ | `dependency_analyzer.py` | vulnerability-scanner | Weekly / Deploy |
51
+ | `lint_runner.py` | lint-and-validate | Every code change |
52
+ | `test_runner.py` | testing-patterns | After logic change |
53
+ | `schema_validator.py` | database-design | After DB change |
54
+ | `ux_audit.py` | frontend-design | After UI change |
55
+ | `accessibility_checker.py` | frontend-design | After UI change |
56
+ | `seo_checker.py` | seo-fundamentals | After page change |
57
+ | `bundle_analyzer.py` | performance-profiling | Before deploy |
58
+ | `mobile_audit.py` | mobile-design | After mobile change |
59
+ | `lighthouse_audit.py` | performance-profiling | Before deploy |
60
+ | `playwright_runner.py` | webapp-testing | Before deploy |
61
+ | `prompt_injection_scanner.py` | ai-security-guardrails | Security audit / Deploy |
62
+ | `pii_scanner.py` | privacy-preserving-dev | Privacy audit / Deploy |
63
+ | `otel_validator.py` | observability-patterns | Observability check |
64
+ | `trace_analyzer.py` | opentelemetry-expert | Performance optimization |
65
+
66
+ ---
67
+
68
+ ## Script Locations
69
+
70
+ | Script | Path |
71
+ |--------|------|
72
+ | Full verify | `scripts/verify_all.py` |
73
+ | Security scan | `.agent/skills/vulnerability-scanner/scripts/security_scan.py` |
74
+ | UX audit | `.agent/skills/frontend-design/scripts/ux_audit.py` |
75
+ | Mobile audit | `.agent/skills/mobile-design/scripts/mobile_audit.py` |
76
+ | Lighthouse | `.agent/skills/performance-profiling/scripts/lighthouse_audit.py` |
77
+ | Playwright | `.agent/skills/webapp-testing/scripts/playwright_runner.py` |
78
+ | Prompt injection | `.agent/skills/ai-security-guardrails/scripts/prompt_injection_scanner.py` |
79
+ | PII scan | `.agent/skills/privacy-preserving-dev/scripts/pii_scanner.py` |
80
+ | OTel validator | `.agent/skills/observability-patterns/scripts/otel_validator.py` |
81
+ | Trace analyzer | `.agent/skills/opentelemetry-expert/scripts/trace_analyzer.py` |
@@ -14,6 +14,7 @@ Usage:
14
14
  ak memory # Manage JSON memory
15
15
  ak autofix # Autonomous repair loop
16
16
  ak dashboard # Open visual dashboard
17
+ ak workflows # Show available workflows guide
17
18
  """
18
19
 
19
20
  import os
@@ -611,6 +612,11 @@ def cmd_memory(args: argparse.Namespace) -> int:
611
612
  if args.task: cmd_args.extend(["--task", args.task])
612
613
  if args.status: cmd_args.extend(["--status", args.status])
613
614
  if args.level: cmd_args.extend(["--level", args.level])
615
+ if args.point: cmd_args.extend(["--point", args.point])
616
+ if args.chosen: cmd_args.extend(["--chosen", args.chosen])
617
+ if args.rationale: cmd_args.extend(["--rationale", args.rationale])
618
+ if args.alternatives: cmd_args.extend(["--alternatives", args.alternatives])
619
+ if args.category: cmd_args.extend(["--category", args.category])
614
620
 
615
621
  return run_python_script(memory_script, cmd_args)
616
622
 
@@ -642,6 +648,92 @@ def cmd_dashboard(args: argparse.Namespace) -> int:
642
648
  return 1
643
649
 
644
650
 
651
+ # ============================================================================
652
+ # Command: workflows
653
+ # ============================================================================
654
+
655
+ def cmd_workflows(args: argparse.Namespace) -> int:
656
+ """Display available workflows guide."""
657
+ project_root = Path(args.project_root).resolve()
658
+ kit_path = get_kit_path()
659
+
660
+ # Get language from memory
661
+ language = "en"
662
+ user_json = project_root / ".agent" / "memory" / "user.json"
663
+ if user_json.exists():
664
+ try:
665
+ with open(user_json, "r", encoding="utf-8") as f:
666
+ user_data = json.load(f)
667
+ language = user_data.get("preferences", {}).get("language", "en")
668
+ except:
669
+ pass
670
+
671
+ # Try to find WORKFLOW_GUIDE.md with language suffix in various possible locations
672
+ guide_names = [f"WORKFLOW_GUIDE.{language}.md", "WORKFLOW_GUIDE.md"]
673
+
674
+ # Priority:
675
+ # 1. Project-local .agent/templates/docs/ (installed)
676
+ # 2. Kit-source .agent/templates/docs/ (repo source)
677
+ # 3. Top-level docs/ (fallback for dev)
678
+
679
+ search_dirs = [
680
+ project_root / ".agent" / "templates" / "docs",
681
+ kit_path / "templates" / "docs",
682
+ project_root / "docs",
683
+ kit_path.parent / "docs",
684
+ ]
685
+
686
+ guide_content = None
687
+ for sdir in search_dirs:
688
+ for name in guide_names:
689
+ path = sdir / name
690
+ if path.exists():
691
+ with open(path, "r", encoding="utf-8") as f:
692
+ guide_content = f.read()
693
+ break
694
+ if guide_content:
695
+ break
696
+
697
+ if guide_content:
698
+ print(BANNER)
699
+ print(f"📚 AGENT KIT WORKFLOW GUIDE ({language.upper()})")
700
+ print("=" * 60)
701
+ print(guide_content)
702
+ return 0
703
+ else:
704
+ # Fallback: list workflows from directory
705
+ print(BANNER)
706
+ print("📚 Available Workflows:")
707
+ print("=" * 60)
708
+
709
+ workflow_dir = kit_path / "workflows"
710
+ if not workflow_dir.exists():
711
+ workflow_dir = project_root / ".agent" / "workflows"
712
+
713
+ if workflow_dir.exists():
714
+ workflows = sorted(workflow_dir.glob("*.md"))
715
+ for wf in workflows:
716
+ name = wf.stem
717
+ # Read description from frontmatter
718
+ with open(wf, "r", encoding="utf-8") as f:
719
+ content = f.read()
720
+ desc = ""
721
+ if "description:" in content:
722
+ for line in content.split("\n"):
723
+ if line.startswith("description:"):
724
+ desc = line.split(":", 1)[1].strip()
725
+ break
726
+ print(f" /{name:20} {desc[:50]}")
727
+ print("")
728
+ print("💡 Use /<workflow-name> in AI chat to activate.")
729
+ print("📖 Full guide: docs/WORKFLOW_GUIDE.md")
730
+ else:
731
+ print("❌ Workflows directory not found")
732
+ return 1
733
+
734
+ return 0
735
+
736
+
645
737
  # ============================================================================
646
738
  # Main Entry Point
647
739
  # ============================================================================
@@ -699,13 +791,18 @@ Examples:
699
791
 
700
792
  # memory command
701
793
  memory_parser = subparsers.add_parser("memory", help="Manage JSON memory")
702
- memory_parser.add_argument("mem_command", choices=["init", "get", "set", "update-task", "set-level", "set-lang"])
703
- memory_parser.add_argument("--type", choices=["brain", "session", "user"], default="session")
794
+ memory_parser.add_argument("mem_command", choices=["init", "get", "set", "update-task", "set-level", "set-lang", "log-decision"])
795
+ memory_parser.add_argument("--type", choices=["brain", "session", "user", "decisions"], default="session")
704
796
  memory_parser.add_argument("--key", help="Key to get or set")
705
797
  memory_parser.add_argument("--value", help="Value to set")
706
- memory_parser.add_argument("--task", help="Task name")
707
- memory_parser.add_argument("--status", choices=["active", "completed"], help="Task status")
708
- memory_parser.add_argument("--level", choices=["newbie", "basic", "technical"], help="User level")
798
+ memory_parser.add_argument("--task", help="Task name for update-task")
799
+ memory_parser.add_argument("--status", choices=["active", "completed"], help="Status for update-task")
800
+ memory_parser.add_argument("--level", choices=["newbie", "basic", "technical"], help="Level for set-level")
801
+ memory_parser.add_argument("--point", help="Decision point for log-decision")
802
+ memory_parser.add_argument("--chosen", help="Chosen option for log-decision")
803
+ memory_parser.add_argument("--rationale", help="Rationale for log-decision")
804
+ memory_parser.add_argument("--alternatives", help="Comma-separated rejected alternatives")
805
+ memory_parser.add_argument("--category", default="general", help="Decision category")
709
806
 
710
807
  # autofix command
711
808
  autofix_parser = subparsers.add_parser("autofix", help="Autonomous repair loop")
@@ -714,6 +811,9 @@ Examples:
714
811
  # dashboard command
715
812
  subparsers.add_parser("dashboard", help="Open visual dashboard")
716
813
 
814
+ # workflows command
815
+ subparsers.add_parser("workflows", help="Show available workflows guide")
816
+
717
817
  args = parser.parse_args()
718
818
 
719
819
  if args.command is None:
@@ -729,6 +829,7 @@ Examples:
729
829
  "memory": cmd_memory,
730
830
  "autofix": cmd_autofix,
731
831
  "dashboard": cmd_dashboard,
832
+ "workflows": cmd_workflows,
732
833
  }
733
834
 
734
835
  handler = commands.get(args.command)
@@ -13,7 +13,8 @@ class MemoryManager:
13
13
  self.files = {
14
14
  "brain": self.memory_dir / "brain.json",
15
15
  "session": self.memory_dir / "session.json",
16
- "user": self.memory_dir / "user.json"
16
+ "user": self.memory_dir / "user.json",
17
+ "decisions": self.memory_dir / "decisions.json"
17
18
  }
18
19
 
19
20
  self._ensure_files()
@@ -43,6 +44,14 @@ class MemoryManager:
43
44
  "auto_sync": True,
44
45
  "language": "en"
45
46
  }
47
+ },
48
+ "decisions": {
49
+ "version": "1.0.0",
50
+ "decisions": [],
51
+ "metadata": {
52
+ "created_at": datetime.now().isoformat(),
53
+ "description": "Decision log for AI agent decisions with full rationale"
54
+ }
46
55
  }
47
56
  }
48
57
 
@@ -62,7 +71,12 @@ class MemoryManager:
62
71
  if memory_type not in self.files:
63
72
  raise ValueError(f"Unknown memory type: {memory_type}")
64
73
 
65
- data["last_updated" if memory_type == "brain" else "last_interaction"] = datetime.now().isoformat()
74
+ if memory_type == "brain":
75
+ data["last_updated"] = datetime.now().isoformat()
76
+ elif memory_type == "decisions":
77
+ pass # Keep version and metadata
78
+ else:
79
+ data["last_interaction"] = datetime.now().isoformat()
66
80
 
67
81
  with open(self.files[memory_type], "w") as f:
68
82
  json.dump(data, f, indent=2)
@@ -80,16 +94,41 @@ class MemoryManager:
80
94
  session["completed_tasks"].append(task_name)
81
95
  self.save("session", session)
82
96
 
97
+ def log_decision(self, point: str, chosen: str, rationale: str, alternatives: str = "", category: str = "general"):
98
+ """Explicitly log a technical or architectural decision."""
99
+ decisions_data = self.load("decisions")
100
+
101
+ new_decision = {
102
+ "id": f"dec-{datetime.now().strftime('%Y%m%d-%H%M%S')}",
103
+ "timestamp": datetime.now().isoformat(),
104
+ "category": category,
105
+ "decision_point": point,
106
+ "chosen_option": chosen,
107
+ "rejected_options": [alt.strip() for alt in alternatives.split(",")] if alternatives else [],
108
+ "rationale": rationale,
109
+ "metadata": {
110
+ "source": "ak cli"
111
+ }
112
+ }
113
+
114
+ decisions_data["decisions"].append(new_decision)
115
+ self.save("decisions", decisions_data)
116
+
83
117
  if __name__ == "__main__":
84
118
  import argparse
85
119
  parser = argparse.ArgumentParser(description="Manage Agent Kit JSON Memory")
86
- parser.add_argument("command", choices=["init", "get", "set", "update-task", "set-level", "set-lang"])
120
+ parser.add_argument("command", choices=["init", "get", "set", "update-task", "set-level", "set-lang", "log-decision"])
87
121
  parser.add_argument("--type", choices=["brain", "session", "user"], default="session")
88
122
  parser.add_argument("--key", help="Key to get or set")
89
123
  parser.add_argument("--value", help="Value to set")
90
124
  parser.add_argument("--task", help="Task name for update-task")
91
125
  parser.add_argument("--status", choices=["active", "completed"], help="Status for update-task")
92
126
  parser.add_argument("--level", choices=["newbie", "basic", "technical"], help="Level for set-level")
127
+ parser.add_argument("--point", help="Decision point for log-decision")
128
+ parser.add_argument("--chosen", help="Chosen option for log-decision")
129
+ parser.add_argument("--rationale", help="Rationale for log-decision")
130
+ parser.add_argument("--alternatives", help="Rejected alternatives for log-decision")
131
+ parser.add_argument("--category", default="general", help="Category for log-decision")
93
132
  parser.add_argument("--root", default=".", help="Project root")
94
133
 
95
134
  args = parser.parse_args()
@@ -107,12 +146,6 @@ if __name__ == "__main__":
107
146
  if args.task and args.status:
108
147
  manager.update_task(args.task, args.status)
109
148
  print(f"✅ Task '{args.task}' set to {args.status}")
110
- elif args.command == "set-level":
111
- if args.level:
112
- user = manager.load("user")
113
- user["skill_level"] = args.level
114
- manager.save("user", user)
115
- print(f"✅ User skill level set to: {args.level}")
116
149
  elif args.command == "set-lang":
117
150
  if args.value:
118
151
  user = manager.load("user")
@@ -136,3 +169,9 @@ if __name__ == "__main__":
136
169
  print(f"✅ Workflow descriptions updated to: {args.value}")
137
170
  except Exception as e:
138
171
  print(f"⚠️ Failed to localize workflows: {str(e)}")
172
+ elif args.command == "log-decision":
173
+ if args.point and args.chosen and args.rationale:
174
+ manager.log_decision(args.point, args.chosen, args.rationale, args.alternatives or "", args.category or "general")
175
+ print(f"✅ Decision logged: {args.point}")
176
+ else:
177
+ print("❌ Missing required arguments for log-decision: --point, --chosen, --rationale")
@@ -0,0 +1,295 @@
1
+ ---
2
+ name: anti-hallucination
3
+ description: "Multi-layer hallucination detection for AI-generated code. Detects phantom APIs, packages, and documentation mismatches. Use when validating AI code output."
4
+ version: "1.0.0"
5
+ ---
6
+
7
+ # 🔮 Anti-Hallucination Guard
8
+
9
+ > **"Code that looks right isn't always right"**
10
+
11
+ AI models can confidently generate code that references non-existent APIs, packages, or features. This skill provides multi-layer detection to catch hallucinations before they reach production.
12
+
13
+ ---
14
+
15
+ ## When to Use This Skill
16
+
17
+ - Validating AI-generated code
18
+ - Before committing AI outputs
19
+ - After major code generation tasks
20
+ - When code "looks right" but fails
21
+
22
+ ---
23
+
24
+ ## 1. Hallucination Types
25
+
26
+ | Type | Description | Detection Difficulty |
27
+ |------|-------------|---------------------|
28
+ | **Phantom Package** | Package doesn't exist in registry | 🟢 Easy |
29
+ | **Phantom API** | Method/function doesn't exist | 🟡 Medium |
30
+ | **Wrong Signature** | Correct API, wrong parameters | 🟠 Hard |
31
+ | **Stale Feature** | Feature removed in newer version | 🟠 Hard |
32
+ | **Made-up Option** | Config option that doesn't exist | 🔴 Very Hard |
33
+
34
+ ---
35
+
36
+ ## 2. Detection Layers
37
+
38
+ ### Layer 1: Package Existence
39
+
40
+ ```bash
41
+ # NPM packages
42
+ npm view <package-name> version
43
+
44
+ # Python packages
45
+ pip index versions <package-name>
46
+
47
+ # Bulk check
48
+ cat package.json | jq '.dependencies | keys[]' | xargs -I{} npm view {} version
49
+ ```
50
+
51
+ ```python
52
+ def check_package_exists(package: str, registry: str) -> bool:
53
+ if registry == "npm":
54
+ result = subprocess.run(
55
+ ["npm", "view", package, "version"],
56
+ capture_output=True
57
+ )
58
+ return result.returncode == 0
59
+ elif registry == "pypi":
60
+ response = requests.get(f"https://pypi.org/pypi/{package}/json")
61
+ return response.status_code == 200
62
+ return False
63
+ ```
64
+
65
+ ### Layer 2: API Validation
66
+
67
+ ```python
68
+ def validate_api_calls(code: str, language: str) -> List[Issue]:
69
+ issues = []
70
+
71
+ if language == "typescript":
72
+ # Use TypeScript compiler
73
+ result = subprocess.run(
74
+ ["tsc", "--noEmit", "--strict"],
75
+ capture_output=True
76
+ )
77
+ if result.returncode != 0:
78
+ issues.extend(parse_tsc_errors(result.stderr))
79
+
80
+ elif language == "python":
81
+ # Use mypy + pyright
82
+ result = subprocess.run(
83
+ ["pyright", "--outputjson"],
84
+ capture_output=True
85
+ )
86
+ issues.extend(parse_pyright_errors(result.stdout))
87
+
88
+ return issues
89
+ ```
90
+
91
+ ### Layer 3: Documentation Cross-Check
92
+
93
+ ```python
94
+ KNOWN_APIS = {
95
+ "fetch": {
96
+ "methods": ["json", "text", "blob", "arrayBuffer", "formData"],
97
+ "not_methods": ["advanced", "simple", "smart"] # Common hallucinations
98
+ },
99
+ "console": {
100
+ "methods": ["log", "error", "warn", "info", "table", "dir"],
101
+ "not_methods": ["print", "output", "display"]
102
+ }
103
+ }
104
+
105
+ def check_api_against_docs(api_call: str) -> Optional[Issue]:
106
+ obj, method = api_call.split(".")
107
+
108
+ if obj in KNOWN_APIS:
109
+ known = KNOWN_APIS[obj]
110
+ if method in known.get("not_methods", []):
111
+ return Issue(
112
+ type="PHANTOM_API",
113
+ detail=f"{obj}.{method} does not exist",
114
+ suggestion=f"Did you mean: {known['methods']}"
115
+ )
116
+ return None
117
+ ```
118
+
119
+ ### Layer 4: Version-Specific Check
120
+
121
+ ```python
122
+ def check_version_compatibility(package: str, version: str, api: str) -> bool:
123
+ """
124
+ Check if API exists in specific package version
125
+ """
126
+ # Get package documentation
127
+ docs = fetch_package_docs(package, version)
128
+
129
+ # Check if API is documented
130
+ return api in docs.get("exports", [])
131
+ ```
132
+
133
+ ---
134
+
135
+ ## 3. Common Hallucination Patterns
136
+
137
+ ### JavaScript/TypeScript
138
+
139
+ ```javascript
140
+ // ❌ HALLUCINATION: fetch.advanced doesn't exist
141
+ const data = await fetch.advanced(url, { retries: 3 });
142
+
143
+ // ✅ REAL: Use standard fetch with manual retry
144
+ const data = await fetch(url).then(r => r.json());
145
+ ```
146
+
147
+ ```javascript
148
+ // ❌ HALLUCINATION: console.print doesn't exist
149
+ console.print("Hello");
150
+
151
+ // ✅ REAL: Use console.log
152
+ console.log("Hello");
153
+ ```
154
+
155
+ ### Python
156
+
157
+ ```python
158
+ # ❌ HALLUCINATION: pandas.smart_read doesn't exist
159
+ df = pd.smart_read("data.csv", auto_detect=True)
160
+
161
+ # ✅ REAL: Use pandas.read_csv
162
+ df = pd.read_csv("data.csv")
163
+ ```
164
+
165
+ ### React
166
+
167
+ ```jsx
168
+ // ❌ HALLUCINATION: useAutoEffect doesn't exist
169
+ useAutoEffect(() => { ... }, [dep], { auto: true });
170
+
171
+ // ✅ REAL: Use useEffect
172
+ useEffect(() => { ... }, [dep]);
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 4. Hallucination Red Flags
178
+
179
+ | Red Flag | Description |
180
+ |----------|-------------|
181
+ | **Overly Convenient API** | API that does exactly what you need, perfectly |
182
+ | **Missing from Autocomplete** | IDE doesn't recognize it |
183
+ | **No Documentation** | Can't find in official docs |
184
+ | **Unusual Parameter** | Config option that seems too specific |
185
+ | **"Smart" Prefix** | smartFetch, autoProcess, etc. |
186
+
187
+ ---
188
+
189
+ ## 5. Detection Commands
190
+
191
+ ### Quick Check Script
192
+
193
+ ```bash
194
+ #!/bin/bash
195
+ # anti-hallucination-check.sh
196
+
197
+ echo "=== Package Check ==="
198
+ npm ls --all 2>&1 | grep -E "MISSING|INVALID|ERR"
199
+
200
+ echo "=== TypeScript Check ==="
201
+ npx tsc --noEmit 2>&1 | grep -E "error TS"
202
+
203
+ echo "=== Import Check ==="
204
+ grep -rn "from '" src/ | cut -d"'" -f2 | sort -u | while read pkg; do
205
+ if [[ ! $pkg == .* ]]; then
206
+ npm view $pkg version > /dev/null 2>&1 || echo "Missing: $pkg"
207
+ fi
208
+ done
209
+ ```
210
+
211
+ ### Python Check
212
+
213
+ ```bash
214
+ #!/bin/bash
215
+ # python-hallucination-check.sh
216
+
217
+ echo "=== Pyright Check ==="
218
+ pyright --outputjson 2>/dev/null | jq '.generalDiagnostics[] | {file, message}'
219
+
220
+ echo "=== Package Check ==="
221
+ pip check
222
+
223
+ echo "=== Import Check ==="
224
+ python -c "import ast; [print(n.name) for n in ast.walk(ast.parse(open('$1').read())) if isinstance(n, ast.Import)]"
225
+ ```
226
+
227
+ ---
228
+
229
+ ## 6. Integration Points
230
+
231
+ ### With Verification Gate
232
+
233
+ ```
234
+ AI Output
235
+
236
+ Anti-Hallucination Check
237
+
238
+ [Pass] → Verification Gate → Completion Claim
239
+ [Fail] → Reject → Request AI Fix
240
+ ```
241
+
242
+ ### With Emergence Detector
243
+
244
+ ```
245
+ Anti-Hallucination focuses on: "Is this API real?"
246
+ Emergence Detector focuses on: "Did AI add unwanted things?"
247
+ ```
248
+
249
+ ---
250
+
251
+ ## 7. Automated Checks
252
+
253
+ ### Pre-commit Hook
254
+
255
+ ```bash
256
+ #!/bin/bash
257
+ # .git/hooks/pre-commit
258
+
259
+ # Run anti-hallucination check
260
+ ./scripts/anti-hallucination-check.sh
261
+
262
+ if [ $? -ne 0 ]; then
263
+ echo "❌ Hallucination detected. Fix before commit."
264
+ exit 1
265
+ fi
266
+ ```
267
+
268
+ ### CI Pipeline
269
+
270
+ ```yaml
271
+ - name: Anti-Hallucination Check
272
+ run: |
273
+ npm ls --all 2>&1 | grep -qE "MISSING|INVALID" && exit 1
274
+ npx tsc --noEmit
275
+ ```
276
+
277
+ ---
278
+
279
+ ## 8. Response Protocol
280
+
281
+ | Detection | Severity | Action |
282
+ |-----------|----------|--------|
283
+ | Phantom Package | 🔴 Critical | Reject immediately |
284
+ | Phantom API | 🔴 Critical | Reject, find real API |
285
+ | Wrong Signature | 🟠 High | Fix parameters |
286
+ | Stale Feature | 🟡 Medium | Upgrade or downgrade |
287
+ | Made-up Option | 🟡 Medium | Remove option |
288
+
289
+ ---
290
+
291
+ ## Related Skills
292
+
293
+ - `emergence-detector` - Detect unexpected behaviors
294
+ - `verification-gate` - Evidence-based verification
295
+ - `trust-spectrum` - Agent trust management