@rfxlamia/skillkit 1.0.0 → 1.2.0
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/agents/agents/creative-copywriter.md +212 -0
- package/agents/agents/dario-amodei.md +135 -0
- package/agents/agents/doc-simplifier.md +63 -0
- package/agents/agents/kotlin-pro.md +433 -0
- package/agents/agents/red-team.md +136 -0
- package/agents/agents/sam-altman.md +121 -0
- package/agents/agents/seo-manager.md +184 -0
- package/package.json +7 -2
- package/skills/quick-spec/tests/__pycache__/test_skill.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/skillkit/.claude/settings.local.json +7 -0
- package/skills/skillkit/scripts/__pycache__/decision_helper.cpython-314.pyc +0 -0
- package/skills/skillkit/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
- package/skills/skillkit/scripts/__pycache__/quick_validate.cpython-314.pyc +0 -0
- package/skills/skillkit/scripts/__pycache__/test_generator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-312.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-314.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-312.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-314.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-312.pyc +0 -0
- package/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-314.pyc +0 -0
- package/skills/skillkit-help/SKILL.md +81 -0
- package/skills/skillkit-help/knowledge/application/09-case-studies.md +257 -0
- package/skills/skillkit-help/knowledge/application/12-testing-and-validation.md +276 -0
- package/skills/skillkit-help/knowledge/foundation/01-why-skills-exist.md +246 -0
- package/skills/skillkit-help/knowledge/foundation/02-skills-vs-subagents-comparison.md +312 -0
- package/skills/skillkit-help/knowledge/foundation/03-skills-vs-subagents-decision-tree.md +346 -0
- package/skills/skillkit-help/knowledge/foundation/06-platform-constraints.md +237 -0
- package/skills/skillkit-help/knowledge/foundation/08-when-not-to-use-skills.md +270 -0
- package/skills/skillkit-help/template/SKILL.md +52 -0
- package/skills/skills/adversarial-review/SKILL.md +219 -0
- package/skills/skills/baby-education/SKILL.md +260 -0
- package/skills/skills/baby-education/references/advanced-techniques.md +323 -0
- package/skills/skills/baby-education/references/transformations.md +345 -0
- package/skills/skills/been-there-done-that/SKILL.md +455 -0
- package/skills/skills/been-there-done-that/references/analysis-patterns.md +162 -0
- package/skills/skills/been-there-done-that/references/git-commands.md +132 -0
- package/skills/skills/been-there-done-that/references/tree-insertion-logic.md +145 -0
- package/skills/skills/coolhunter/SKILL.md +270 -0
- package/skills/skills/coolhunter/assets/elicitation-methods.csv +51 -0
- package/skills/skills/coolhunter/knowledge/elicitation-methods.md +312 -0
- package/skills/skills/coolhunter/references/workflow-execution.md +238 -0
- package/skills/skills/coolhunter/workflow-plan-coolhunter.md +232 -0
- package/skills/skills/creative-copywriting/SKILL.md +324 -0
- package/skills/skills/creative-copywriting/databases/README.md +60 -0
- package/skills/skills/creative-copywriting/databases/carousel-structures.csv +16 -0
- package/skills/skills/creative-copywriting/databases/emotional-arcs.csv +11 -0
- package/skills/skills/creative-copywriting/databases/hook-formulas.csv +51 -0
- package/skills/skills/creative-copywriting/databases/power-words.csv +201 -0
- package/skills/skills/creative-copywriting/databases/psychological-triggers.csv +21 -0
- package/skills/skills/creative-copywriting/databases/read-more-patterns.csv +26 -0
- package/skills/skills/creative-copywriting/databases/swipe-triggers.csv +31 -0
- package/skills/skills/creative-copywriting/references/carousel-psychology.md +223 -0
- package/skills/skills/creative-copywriting/references/hook-anatomy.md +169 -0
- package/skills/skills/creative-copywriting/references/power-word-science.md +134 -0
- package/skills/skills/creative-copywriting/references/storytelling-frameworks.md +157 -0
- package/skills/skills/diverse-content-gen/SKILL.md +201 -0
- package/skills/skills/diverse-content-gen/references/advanced-techniques.md +320 -0
- package/skills/skills/diverse-content-gen/references/research-findings.md +379 -0
- package/skills/skills/diverse-content-gen/references/task-workflows.md +241 -0
- package/skills/skills/diverse-content-gen/references/tool-integration.md +419 -0
- package/skills/skills/diverse-content-gen/references/troubleshooting.md +426 -0
- package/skills/skills/diverse-content-gen/references/vs-core-technique.md +240 -0
- package/skills/skills/framework-critical-thinking/SKILL.md +220 -0
- package/skills/skills/framework-critical-thinking/references/bias_detector.md +375 -0
- package/skills/skills/framework-critical-thinking/references/fallback_handler.md +239 -0
- package/skills/skills/framework-critical-thinking/references/memory_curator.md +161 -0
- package/skills/skills/framework-critical-thinking/references/metacognitive_monitor.md +297 -0
- package/skills/skills/framework-critical-thinking/references/producer_critic_orchestrator.md +333 -0
- package/skills/skills/framework-critical-thinking/references/reasoning_router.md +235 -0
- package/skills/skills/framework-critical-thinking/references/reasoning_validator.md +97 -0
- package/skills/skills/framework-critical-thinking/references/reflection_trigger.md +78 -0
- package/skills/skills/framework-critical-thinking/references/self_verification.md +388 -0
- package/skills/skills/framework-critical-thinking/references/uncertainty_quantifier.md +207 -0
- package/skills/skills/framework-initiative/SKILL.md +231 -0
- package/skills/skills/framework-initiative/references/examples.md +150 -0
- package/skills/skills/framework-initiative/references/impact-analysis.md +157 -0
- package/skills/skills/framework-initiative/references/intent-patterns.md +145 -0
- package/skills/skills/framework-initiative/references/star-framework.md +165 -0
- package/skills/skills/humanize-docs/SKILL.md +203 -0
- package/skills/skills/humanize-docs/references/advanced-techniques.md +13 -0
- package/skills/skills/humanize-docs/references/core-transformations.md +368 -0
- package/skills/skills/humanize-docs/references/detection-patterns.md +400 -0
- package/skills/skills/humanize-docs/references/examples-gallery.md +374 -0
- package/skills/skills/imagine/SKILL.md +190 -0
- package/skills/skills/imagine/references/artstyle-corporate-memphis.md +625 -0
- package/skills/skills/imagine/references/artstyle-crewdson-hyperrealism.md +295 -0
- package/skills/skills/imagine/references/artstyle-iphone-social-media.md +426 -0
- package/skills/skills/imagine/references/artstyle-sciencesaru.md +276 -0
- package/skills/skills/pre-deploy-checklist/README.md +26 -0
- package/skills/skills/pre-deploy-checklist/SKILL.md +153 -0
- package/skills/skills/pre-deploy-checklist/references/checklist-categories.md +174 -0
- package/skills/skills/pre-deploy-checklist/references/domain-prompts.md +216 -0
- package/skills/skills/prompt-engineering/SKILL.md +209 -0
- package/skills/skills/prompt-engineering/references/advanced-combinations.md +444 -0
- package/skills/skills/prompt-engineering/references/chain-of-thought.md +140 -0
- package/skills/skills/prompt-engineering/references/decision_matrix.md +220 -0
- package/skills/skills/prompt-engineering/references/few-shot.md +346 -0
- package/skills/skills/prompt-engineering/references/json-format.md +270 -0
- package/skills/skills/prompt-engineering/references/natural-language.md +420 -0
- package/skills/skills/prompt-engineering/references/pitfalls.md +365 -0
- package/skills/skills/prompt-engineering/references/prompt-chaining.md +498 -0
- package/skills/skills/prompt-engineering/references/react.md +108 -0
- package/skills/skills/prompt-engineering/references/self-consistency.md +322 -0
- package/skills/skills/prompt-engineering/references/tree-of-thoughts.md +386 -0
- package/skills/skills/prompt-engineering/references/xml-format.md +220 -0
- package/skills/skills/prompt-engineering/references/yaml-format.md +488 -0
- package/skills/skills/prompt-engineering/references/zero-shot.md +74 -0
- package/skills/skills/quick-spec/SKILL.md +280 -0
- package/skills/skills/quick-spec/assets/tech-spec-template.md +74 -0
- package/skills/skills/quick-spec/references/step-01-understand.md +189 -0
- package/skills/skills/quick-spec/references/step-02-investigate.md +144 -0
- package/skills/skills/quick-spec/references/step-03-generate.md +128 -0
- package/skills/skills/quick-spec/references/step-04-review.md +173 -0
- package/skills/skills/quick-spec/tests/__pycache__/test_skill.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/skills/quick-spec/tests/test_scenarios.md +83 -0
- package/skills/skills/quick-spec/tests/test_skill.py +136 -0
- package/skills/skills/readme-expert/SKILL.md +538 -0
- package/skills/skills/readme-expert/knowledge/INDEX.md +192 -0
- package/skills/skills/readme-expert/knowledge/application/quality-standards.md +470 -0
- package/skills/skills/readme-expert/knowledge/application/script-executor.md +604 -0
- package/skills/skills/readme-expert/knowledge/application/template-library.md +822 -0
- package/skills/skills/readme-expert/knowledge/foundation/codebase-scanner.md +361 -0
- package/skills/skills/readme-expert/knowledge/foundation/validation-checklist.md +481 -0
- package/skills/skills/red-teaming/SKILL.md +321 -0
- package/skills/skills/red-teaming/references/ai-llm-redteam.md +517 -0
- package/skills/skills/red-teaming/references/attack-techniques.md +410 -0
- package/skills/skills/red-teaming/references/cybersecurity-redteam.md +383 -0
- package/skills/skills/red-teaming/references/tools-frameworks.md +446 -0
- package/skills/skills/releasing/.skillkit-mode +1 -0
- package/skills/skills/releasing/SKILL.md +225 -0
- package/skills/skills/releasing/references/version-detection.md +108 -0
- package/skills/skills/screenwriter/SKILL.md +273 -0
- package/skills/skills/screenwriter/references/advanced-techniques.md +216 -0
- package/skills/skills/screenwriter/references/pipeline-integration.md +266 -0
- package/skills/skills/skillkit/.claude/settings.local.json +7 -0
- package/skills/skills/skillkit/.claude-plugin/plugin.json +27 -0
- package/skills/skills/skillkit/CHANGELOG.md +484 -0
- package/skills/skills/skillkit/SKILL.md +511 -0
- package/skills/skills/skillkit/commands/skillkit.md +6 -0
- package/skills/skills/skillkit/commands/validate-plan.md +6 -0
- package/skills/skills/skillkit/commands/verify.md +6 -0
- package/skills/skills/skillkit/knowledge/INDEX.md +352 -0
- package/skills/skills/skillkit/knowledge/application/09-case-studies.md +257 -0
- package/skills/skills/skillkit/knowledge/application/10-technical-architecture.md +324 -0
- package/skills/skills/skillkit/knowledge/application/11-adoption-strategy.md +267 -0
- package/skills/skills/skillkit/knowledge/application/12-testing-and-validation.md +276 -0
- package/skills/skills/skillkit/knowledge/application/13-competitive-landscape.md +198 -0
- package/skills/skills/skillkit/knowledge/foundation/01-why-skills-exist.md +246 -0
- package/skills/skills/skillkit/knowledge/foundation/02-skills-vs-subagents-comparison.md +312 -0
- package/skills/skills/skillkit/knowledge/foundation/03-skills-vs-subagents-decision-tree.md +346 -0
- package/skills/skills/skillkit/knowledge/foundation/04-hybrid-patterns.md +308 -0
- package/skills/skills/skillkit/knowledge/foundation/05-token-economics.md +275 -0
- package/skills/skills/skillkit/knowledge/foundation/06-platform-constraints.md +237 -0
- package/skills/skills/skillkit/knowledge/foundation/07-security-concerns.md +322 -0
- package/skills/skills/skillkit/knowledge/foundation/08-when-not-to-use-skills.md +270 -0
- package/skills/skills/skillkit/knowledge/plugin-guide.md +614 -0
- package/skills/skills/skillkit/knowledge/tools/14-validation-tools-guide.md +150 -0
- package/skills/skills/skillkit/knowledge/tools/15-cost-tools-guide.md +157 -0
- package/skills/skills/skillkit/knowledge/tools/16-security-tools-guide.md +122 -0
- package/skills/skills/skillkit/knowledge/tools/17-pattern-tools-guide.md +161 -0
- package/skills/skills/skillkit/knowledge/tools/18-decision-helper-guide.md +243 -0
- package/skills/skills/skillkit/knowledge/tools/19-test-generator-guide.md +275 -0
- package/skills/skills/skillkit/knowledge/tools/20-split-skill-guide.md +149 -0
- package/skills/skills/skillkit/knowledge/tools/21-quality-scorer-guide.md +226 -0
- package/skills/skills/skillkit/knowledge/tools/22-migration-helper-guide.md +356 -0
- package/skills/skills/skillkit/knowledge/tools/23-subagent-creation-guide.md +448 -0
- package/skills/skills/skillkit/knowledge/tools/24-behavioral-testing-guide.md +122 -0
- package/skills/skills/skillkit/references/proposal-generation.md +982 -0
- package/skills/skills/skillkit/references/rationalization-catalog.md +75 -0
- package/skills/skills/skillkit/references/research-methodology.md +661 -0
- package/skills/skills/skillkit/references/section-2-full-creation-workflow.md +452 -0
- package/skills/skills/skillkit/references/section-3-validation-workflow-existing-skill.md +63 -0
- package/skills/skills/skillkit/references/section-4-decision-workflow-skills-vs-subagents.md +64 -0
- package/skills/skills/skillkit/references/section-5-migration-workflow-doc-to-skill.md +58 -0
- package/skills/skills/skillkit/references/section-6-subagent-creation-workflow.md +499 -0
- package/skills/skills/skillkit/references/section-7-knowledge-reference-map.md +72 -0
- package/skills/skills/skillkit/scripts/__pycache__/decision_helper.cpython-314.pyc +0 -0
- package/skills/skills/skillkit/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
- package/skills/skills/skillkit/scripts/__pycache__/quick_validate.cpython-314.pyc +0 -0
- package/skills/skills/skillkit/scripts/__pycache__/test_generator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/skills/skillkit/scripts/decision_helper.py +799 -0
- package/skills/skills/skillkit/scripts/init_skill.py +400 -0
- package/skills/skills/skillkit/scripts/init_subagent.py +231 -0
- package/skills/skills/skillkit/scripts/migration_helper.py +669 -0
- package/skills/skills/skillkit/scripts/package_skill.py +211 -0
- package/skills/skills/skillkit/scripts/pattern_detector.py +381 -0
- package/skills/skills/skillkit/scripts/pattern_detector_new.py +382 -0
- package/skills/skills/skillkit/scripts/pressure_tester.py +157 -0
- package/skills/skills/skillkit/scripts/quality_scorer.py +999 -0
- package/skills/skills/skillkit/scripts/quick_validate.py +100 -0
- package/skills/skills/skillkit/scripts/security_scanner.py +474 -0
- package/skills/skills/skillkit/scripts/split_skill.py +540 -0
- package/skills/skills/skillkit/scripts/test_generator.py +695 -0
- package/skills/skills/skillkit/scripts/token_estimator.py +493 -0
- package/skills/skills/skillkit/scripts/utils/__init__.py +49 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-312.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-314.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-312.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-314.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-312.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-314.pyc +0 -0
- package/skills/skills/skillkit/scripts/utils/budget_tracker.py +388 -0
- package/skills/skills/skillkit/scripts/utils/output_formatter.py +263 -0
- package/skills/skills/skillkit/scripts/utils/reference_validator.py +401 -0
- package/skills/skills/skillkit/scripts/validate_skill.py +594 -0
- package/skills/skills/skillkit/tests/test_behavioral.py +39 -0
- package/skills/skills/skillkit/tests/test_scenarios.md +83 -0
- package/skills/skills/skillkit/tests/test_skill.py +136 -0
- package/skills/skills/skillkit-help/SKILL.md +81 -0
- package/skills/skills/skillkit-help/knowledge/application/09-case-studies.md +257 -0
- package/skills/skills/skillkit-help/knowledge/application/12-testing-and-validation.md +276 -0
- package/skills/skills/skillkit-help/knowledge/foundation/01-why-skills-exist.md +246 -0
- package/skills/skills/skillkit-help/knowledge/foundation/02-skills-vs-subagents-comparison.md +312 -0
- package/skills/skills/skillkit-help/knowledge/foundation/03-skills-vs-subagents-decision-tree.md +346 -0
- package/skills/skills/skillkit-help/knowledge/foundation/06-platform-constraints.md +237 -0
- package/skills/skills/skillkit-help/knowledge/foundation/08-when-not-to-use-skills.md +270 -0
- package/skills/skills/skillkit-help/template/SKILL.md +52 -0
- package/skills/skills/social-media-seo/SKILL.md +278 -0
- package/skills/skills/social-media-seo/databases/caption-styles.csv +31 -0
- package/skills/skills/social-media-seo/databases/engagement-tactics.csv +16 -0
- package/skills/skills/social-media-seo/databases/hashtag-strategies.csv +21 -0
- package/skills/skills/social-media-seo/databases/hook-formulas.csv +26 -0
- package/skills/skills/social-media-seo/databases/keyword-clusters.csv +11 -0
- package/skills/skills/social-media-seo/databases/thread-structures.csv +26 -0
- package/skills/skills/social-media-seo/databases/viral-patterns.csv +21 -0
- package/skills/skills/social-media-seo/references/analytics-guide.md +321 -0
- package/skills/skills/social-media-seo/references/instagram-seo.md +235 -0
- package/skills/skills/social-media-seo/references/threads-seo.md +305 -0
- package/skills/skills/social-media-seo/references/x-twitter-seo.md +337 -0
- package/skills/skills/social-media-seo/scripts/query_database.py +191 -0
- package/skills/skills/storyteller/SKILL.md +241 -0
- package/skills/skills/storyteller/references/transformation-methodology.md +293 -0
- package/skills/skills/storyteller/references/visual-vocabulary.md +177 -0
- package/skills/skills/thread-pro/SKILL.md +162 -0
- package/skills/skills/thread-pro/anti-ai-patterns.md +120 -0
- package/skills/skills/thread-pro/hook-formulas.md +138 -0
- package/skills/skills/thread-pro/references/anti-ai-patterns.md +120 -0
- package/skills/skills/thread-pro/references/hook-formulas.md +138 -0
- package/skills/skills/thread-pro/references/thread-structures.md +240 -0
- package/skills/skills/thread-pro/references/voice-injection.md +130 -0
- package/skills/skills/thread-pro/thread-structures.md +240 -0
- package/skills/skills/thread-pro/voice-injection.md +130 -0
- package/skills/skills/tinkering/SKILL.md +251 -0
- package/skills/skills/tinkering/references/graduation-checklist.md +100 -0
- package/skills/skills/validate-plan/.skillkit-mode +1 -0
- package/skills/skills/validate-plan/SKILL.md +406 -0
- package/skills/skills/validate-plan/references/dry-principles.md +251 -0
- package/skills/skills/validate-plan/references/gap-analysis-guide.md +320 -0
- package/skills/skills/validate-plan/references/tdd-patterns.md +413 -0
- package/skills/skills/validate-plan/references/yagni-checklist.md +330 -0
- package/skills/skills/verify-before-ship/.skillkit-mode +1 -0
- package/skills/skills/verify-before-ship/SKILL.md +116 -0
- package/skills/skills/verify-before-ship/references/anti-rationalization.md +212 -0
- package/skills/skills/verify-before-ship/references/verification-gates.md +305 -0
- package/skills-manifest.json +8 -2
- package/src/banner.js +1 -1
- package/src/cli.js +15 -4
- package/src/install.js +45 -29
- package/src/install.test.js +75 -7
- package/src/picker.js +15 -4
- package/src/picker.test.js +36 -1
- package/src/scope.js +8 -39
- package/src/scope.test.js +9 -13
- package/src/tools.js +76 -0
- package/src/tools.test.js +80 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Skill Packager - Creates a distributable .skill file of a skill folder
|
|
4
|
+
|
|
5
|
+
v1.2 Update: Enhanced validation before packaging
|
|
6
|
+
- Checks for broken references
|
|
7
|
+
- Detects orphaned files
|
|
8
|
+
- Validates cross-references before packing
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
python utils/package_skill.py <path/to/skill-folder> [output-directory] [--strict]
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
python utils/package_skill.py skills/public/my-skill
|
|
15
|
+
python utils/package_skill.py skills/public/my-skill ./dist
|
|
16
|
+
python utils/package_skill.py skills/public/my-skill ./dist --strict
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import sys
|
|
20
|
+
import zipfile
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from quick_validate import validate_skill
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from utils.reference_validator import SkillPackageValidator
|
|
26
|
+
except ImportError:
|
|
27
|
+
SkillPackageValidator = None # Graceful fallback
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def is_project_directory(path):
|
|
31
|
+
"""
|
|
32
|
+
Check if a directory appears to be a valid project directory.
|
|
33
|
+
|
|
34
|
+
A project directory is identified by common markers like:
|
|
35
|
+
- .git (git repository)
|
|
36
|
+
- package.json (Node.js project)
|
|
37
|
+
- pyproject.toml or setup.py (Python project)
|
|
38
|
+
- Cargo.toml (Rust project)
|
|
39
|
+
- go.mod (Go project)
|
|
40
|
+
- pom.xml or build.gradle (Java project)
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
path: Path object to check
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
bool: True if directory appears to be a project directory
|
|
47
|
+
"""
|
|
48
|
+
if not path.is_dir():
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
project_markers = [
|
|
52
|
+
'.git',
|
|
53
|
+
'package.json',
|
|
54
|
+
'pyproject.toml',
|
|
55
|
+
'setup.py',
|
|
56
|
+
'Cargo.toml',
|
|
57
|
+
'go.mod',
|
|
58
|
+
'pom.xml',
|
|
59
|
+
'build.gradle',
|
|
60
|
+
'composer.json', # PHP
|
|
61
|
+
'Gemfile', # Ruby
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
for marker in project_markers:
|
|
65
|
+
if (path / marker).exists():
|
|
66
|
+
return True
|
|
67
|
+
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def package_skill(skill_path, output_dir=None, strict=False):
|
|
72
|
+
"""
|
|
73
|
+
Package a skill folder into a .skill file.
|
|
74
|
+
|
|
75
|
+
v1.2 Enhancement: Pre-packaging reference validation
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
skill_path: Path to the skill folder
|
|
79
|
+
output_dir: Optional output directory for the .skill file (defaults to current directory)
|
|
80
|
+
strict: If True, fail on any reference issues. If False, warn only.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
Path to the created .skill file, or None if error
|
|
84
|
+
"""
|
|
85
|
+
skill_path = Path(skill_path).resolve()
|
|
86
|
+
|
|
87
|
+
# Validate skill folder exists
|
|
88
|
+
if not skill_path.exists():
|
|
89
|
+
print(f"❌ Error: Skill folder not found: {skill_path}")
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
if not skill_path.is_dir():
|
|
93
|
+
print(f"❌ Error: Path is not a directory: {skill_path}")
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
# Validate SKILL.md exists
|
|
97
|
+
skill_md = skill_path / "SKILL.md"
|
|
98
|
+
if not skill_md.exists():
|
|
99
|
+
print(f"❌ Error: SKILL.md not found in {skill_path}")
|
|
100
|
+
return None
|
|
101
|
+
|
|
102
|
+
# Run validation before packaging
|
|
103
|
+
print("🔍 Validating skill...")
|
|
104
|
+
valid, message = validate_skill(skill_path)
|
|
105
|
+
if not valid:
|
|
106
|
+
print(f"❌ Validation failed: {message}")
|
|
107
|
+
print(" Please fix the validation errors before packaging.")
|
|
108
|
+
return None
|
|
109
|
+
print(f"✅ {message}\n")
|
|
110
|
+
|
|
111
|
+
# v1.2: Enhanced reference validation before packaging
|
|
112
|
+
print("🔗 Checking file references and orphaned files...")
|
|
113
|
+
if SkillPackageValidator:
|
|
114
|
+
try:
|
|
115
|
+
pkg_validator = SkillPackageValidator(str(skill_path))
|
|
116
|
+
ref_result = pkg_validator.validate_for_packaging(strict=strict)
|
|
117
|
+
|
|
118
|
+
if ref_result.status == 'fail':
|
|
119
|
+
if strict:
|
|
120
|
+
print(f"❌ Reference validation failed: {ref_result.message}")
|
|
121
|
+
print(f" {ref_result.suggestion}")
|
|
122
|
+
return None
|
|
123
|
+
else:
|
|
124
|
+
print(f"⚠️ Warning: {ref_result.message}")
|
|
125
|
+
if ref_result.missing_files:
|
|
126
|
+
print(f" Missing files: {', '.join(ref_result.missing_files[:3])}")
|
|
127
|
+
if ref_result.orphaned_files:
|
|
128
|
+
print(f" Orphaned files: {', '.join(ref_result.orphaned_files[:3])}")
|
|
129
|
+
print(f" Tip: Use --strict to fail on reference issues\n")
|
|
130
|
+
else:
|
|
131
|
+
print(f"✅ References validated: {len(ref_result.valid_references)} files\n")
|
|
132
|
+
except Exception as e:
|
|
133
|
+
# Graceful fallback
|
|
134
|
+
print(f"⚠️ Reference validation skipped (utility unavailable)\n")
|
|
135
|
+
else:
|
|
136
|
+
# Fallback if validator not available
|
|
137
|
+
print(f"⚠️ Reference validation skipped (utility unavailable)\n")
|
|
138
|
+
|
|
139
|
+
# Determine output location (hybrid approach)
|
|
140
|
+
skill_name = skill_path.name
|
|
141
|
+
if output_dir:
|
|
142
|
+
# Priority 1: User-specified output directory
|
|
143
|
+
output_path = Path(output_dir).resolve()
|
|
144
|
+
output_path.mkdir(parents=True, exist_ok=True)
|
|
145
|
+
print(f"📁 Output directory (user-specified): {output_path}")
|
|
146
|
+
else:
|
|
147
|
+
# Priority 2: Check if parent directory is a valid project directory
|
|
148
|
+
parent_dir = skill_path.parent
|
|
149
|
+
if is_project_directory(parent_dir):
|
|
150
|
+
output_path = parent_dir
|
|
151
|
+
print(f"📁 Output directory (project directory detected): {output_path}")
|
|
152
|
+
else:
|
|
153
|
+
# Priority 3: Use current working directory
|
|
154
|
+
output_path = Path.cwd()
|
|
155
|
+
print(f"📁 Output directory (current working directory): {output_path}")
|
|
156
|
+
|
|
157
|
+
skill_filename = output_path / f"{skill_name}.skill"
|
|
158
|
+
|
|
159
|
+
# Create the .skill file (zip format)
|
|
160
|
+
try:
|
|
161
|
+
print(f"\n📦 Creating archive: {skill_filename.name}")
|
|
162
|
+
with zipfile.ZipFile(skill_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
163
|
+
# Walk through the skill directory
|
|
164
|
+
for file_path in skill_path.rglob('*'):
|
|
165
|
+
if file_path.is_file():
|
|
166
|
+
# Calculate the relative path within the zip
|
|
167
|
+
# Use skill_path (not skill_path.parent) to avoid wrapper folder
|
|
168
|
+
arcname = file_path.relative_to(skill_path)
|
|
169
|
+
zipf.write(file_path, arcname)
|
|
170
|
+
print(f" Added: {arcname}")
|
|
171
|
+
|
|
172
|
+
print(f"\n✅ Successfully packaged skill to: {skill_filename}")
|
|
173
|
+
return skill_filename
|
|
174
|
+
|
|
175
|
+
except Exception as e:
|
|
176
|
+
print(f"❌ Error creating .skill file: {e}")
|
|
177
|
+
return None
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def main():
|
|
181
|
+
import argparse
|
|
182
|
+
|
|
183
|
+
parser = argparse.ArgumentParser(
|
|
184
|
+
description='Package a skill folder into a distributable .skill file',
|
|
185
|
+
epilog='Example: python package_skill.py skills/public/my-skill ./dist --strict'
|
|
186
|
+
)
|
|
187
|
+
parser.add_argument('skill_path', help='Path to the skill folder')
|
|
188
|
+
parser.add_argument('output_dir', nargs='?', default=None,
|
|
189
|
+
help='Output directory for the .skill file (default: current directory)')
|
|
190
|
+
parser.add_argument('--strict', action='store_true',
|
|
191
|
+
help='Fail if any reference issues found (default: warn only)')
|
|
192
|
+
|
|
193
|
+
args = parser.parse_args()
|
|
194
|
+
|
|
195
|
+
print(f"📦 Packaging skill: {args.skill_path}")
|
|
196
|
+
if args.output_dir:
|
|
197
|
+
print(f" Output directory: {args.output_dir}")
|
|
198
|
+
if args.strict:
|
|
199
|
+
print(f" Mode: STRICT (fail on reference issues)")
|
|
200
|
+
print()
|
|
201
|
+
|
|
202
|
+
result = package_skill(args.skill_path, args.output_dir, strict=args.strict)
|
|
203
|
+
|
|
204
|
+
if result:
|
|
205
|
+
sys.exit(0)
|
|
206
|
+
else:
|
|
207
|
+
sys.exit(1)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
if __name__ == "__main__":
|
|
211
|
+
main()
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Workflow pattern detector and recommender for Claude skills.
|
|
4
|
+
Analyzes use cases and suggests appropriate proven patterns.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
python pattern_detector.py "convert PDF to Word" [--format json]
|
|
8
|
+
python pattern_detector.py --interactive
|
|
9
|
+
python pattern_detector.py --list [--format json]
|
|
10
|
+
|
|
11
|
+
References:
|
|
12
|
+
- File 04: Hybrid patterns and combinations
|
|
13
|
+
- File 09: Case studies and real-world examples
|
|
14
|
+
- Panduan Komprehensif: 8 proven patterns
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import sys
|
|
18
|
+
import json
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import Dict, List, Tuple
|
|
21
|
+
|
|
22
|
+
# Import shared utilities for standardized output
|
|
23
|
+
try:
|
|
24
|
+
from utils.output_formatter import add_format_argument, format_success_response, format_error_response, output_json
|
|
25
|
+
except ImportError:
|
|
26
|
+
# Fallback if utils not in path
|
|
27
|
+
sys.path.insert(0, str(Path(__file__).parent))
|
|
28
|
+
from utils.output_formatter import add_format_argument, format_success_response, format_error_response, output_json
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class PatternDetector:
|
|
32
|
+
"""Detect and recommend workflow patterns for skills."""
|
|
33
|
+
|
|
34
|
+
# 8 proven patterns from comprehensive research
|
|
35
|
+
PATTERNS = {
|
|
36
|
+
'read-process-write': {
|
|
37
|
+
'name': 'Read-Process-Write',
|
|
38
|
+
'description': 'File transformation and data cleanup',
|
|
39
|
+
'keywords': ['convert', 'transform', 'format', 'cleanup', 'process file', 'parse'],
|
|
40
|
+
'use_when': 'Clear input → output transformations',
|
|
41
|
+
'examples': ['PDF to Word conversion', 'Data cleanup', 'Format normalization']
|
|
42
|
+
},
|
|
43
|
+
'search-analyze-report': {
|
|
44
|
+
'name': 'Search-Analyze-Report',
|
|
45
|
+
'description': 'Codebase analysis and pattern detection',
|
|
46
|
+
'keywords': ['search', 'scan', 'find', 'analyze', 'detect', 'audit', 'grep'],
|
|
47
|
+
'use_when': 'Large-scale code/content analysis',
|
|
48
|
+
'examples': ['Security scanning', 'Code quality audit', 'Dependency analysis']
|
|
49
|
+
},
|
|
50
|
+
'script-automation': {
|
|
51
|
+
'name': 'Script Automation',
|
|
52
|
+
'description': 'Complex multi-step operations',
|
|
53
|
+
'keywords': ['automate', 'pipeline', 'workflow', 'test', 'ci/cd', 'orchestrate', 'run'],
|
|
54
|
+
'use_when': 'Complex automation required',
|
|
55
|
+
'examples': ['CI/CD pipeline', 'Test automation', 'Build orchestration']
|
|
56
|
+
},
|
|
57
|
+
'wizard-multi-step': {
|
|
58
|
+
'name': 'Wizard-Style Multi-Step',
|
|
59
|
+
'description': 'Setup wizards and guided processes',
|
|
60
|
+
'keywords': ['setup', 'init', 'configure', 'wizard', 'interactive', 'guide', 'create project'],
|
|
61
|
+
'use_when': 'Complex setup processes',
|
|
62
|
+
'examples': ['Project initialization', 'Configuration wizard', 'Onboarding']
|
|
63
|
+
},
|
|
64
|
+
'template-generation': {
|
|
65
|
+
'name': 'Template Generation',
|
|
66
|
+
'description': 'Structured document creation',
|
|
67
|
+
'keywords': ['generate', 'template', 'create document', 'report', 'fill', 'populate'],
|
|
68
|
+
'use_when': 'Repetitive document creation',
|
|
69
|
+
'examples': ['Report generation', 'Email templates', 'Documentation']
|
|
70
|
+
},
|
|
71
|
+
'iterative-refinement': {
|
|
72
|
+
'name': 'Iterative Refinement',
|
|
73
|
+
'description': 'Code review and quality analysis',
|
|
74
|
+
'keywords': ['review', 'refine', 'improve', 'iterate', 'quality', 'optimize'],
|
|
75
|
+
'use_when': 'Quality improvement cycles',
|
|
76
|
+
'examples': ['Code review', 'Architecture review', 'Performance tuning']
|
|
77
|
+
},
|
|
78
|
+
'context-aggregation': {
|
|
79
|
+
'name': 'Context Aggregation',
|
|
80
|
+
'description': 'Project summaries and documentation',
|
|
81
|
+
'keywords': ['summarize', 'aggregate', 'combine', 'collect', 'dashboard', 'overview'],
|
|
82
|
+
'use_when': 'Multi-source information synthesis',
|
|
83
|
+
'examples': ['Project status', 'Documentation gen', 'Knowledge base']
|
|
84
|
+
},
|
|
85
|
+
'validation-pipeline': {
|
|
86
|
+
'name': 'Validation Pipeline',
|
|
87
|
+
'description': 'Data quality and compliance checking',
|
|
88
|
+
'keywords': ['validate', 'check', 'verify', 'compliance', 'quality', 'assurance'],
|
|
89
|
+
'use_when': 'Quality assurance required',
|
|
90
|
+
'examples': ['Data validation', 'Compliance check', 'Configuration audit']
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
def analyze_use_case(self, description: str) -> List[Tuple[str, float]]:
|
|
95
|
+
"""
|
|
96
|
+
Analyze use case and recommend patterns.
|
|
97
|
+
|
|
98
|
+
Returns list of (pattern_id, confidence) sorted by confidence.
|
|
99
|
+
Reference: Panduan Komprehensif (8 patterns)
|
|
100
|
+
"""
|
|
101
|
+
desc_lower = description.lower()
|
|
102
|
+
scores = []
|
|
103
|
+
|
|
104
|
+
for pattern_id, pattern in self.PATTERNS.items():
|
|
105
|
+
# Count keyword matches
|
|
106
|
+
matches = sum(1 for kw in pattern['keywords'] if kw in desc_lower)
|
|
107
|
+
|
|
108
|
+
# Normalize by keyword count
|
|
109
|
+
confidence = matches / len(pattern['keywords']) if pattern['keywords'] else 0.0
|
|
110
|
+
|
|
111
|
+
scores.append((pattern_id, confidence))
|
|
112
|
+
|
|
113
|
+
# Sort by confidence (highest first)
|
|
114
|
+
scores.sort(key=lambda x: x[1], reverse=True)
|
|
115
|
+
return scores
|
|
116
|
+
|
|
117
|
+
def interactive_selection(self) -> str:
|
|
118
|
+
"""
|
|
119
|
+
Interactive questionnaire for pattern selection.
|
|
120
|
+
Returns recommended pattern ID.
|
|
121
|
+
"""
|
|
122
|
+
print("\n=== Workflow Pattern Selector ===\n")
|
|
123
|
+
print("Answer questions to find the best pattern:\n")
|
|
124
|
+
|
|
125
|
+
# Question 1: Primary pattern
|
|
126
|
+
print("1. What's your primary input/output pattern?")
|
|
127
|
+
print(" a) Files in → Files out (conversion/transformation)")
|
|
128
|
+
print(" b) Search/scan → Report (analysis)")
|
|
129
|
+
print(" c) Questions → Generated structure (wizard)")
|
|
130
|
+
print(" d) Multiple sources → Aggregated report (synthesis)")
|
|
131
|
+
choice = input(" Choice [a/b/c/d]: ").strip().lower()
|
|
132
|
+
|
|
133
|
+
if choice == 'a':
|
|
134
|
+
return 'read-process-write'
|
|
135
|
+
elif choice == 'b':
|
|
136
|
+
print("\n2. What type of analysis?")
|
|
137
|
+
print(" a) Code quality/security patterns")
|
|
138
|
+
print(" b) Validation/compliance checking")
|
|
139
|
+
choice2 = input(" Choice [a/b]: ").strip().lower()
|
|
140
|
+
return 'search-analyze-report' if choice2 == 'a' else 'validation-pipeline'
|
|
141
|
+
elif choice == 'c':
|
|
142
|
+
return 'wizard-multi-step'
|
|
143
|
+
elif choice == 'd':
|
|
144
|
+
return 'context-aggregation'
|
|
145
|
+
|
|
146
|
+
# Question 2: Automation
|
|
147
|
+
print("\n2. Does this involve multiple automation steps?")
|
|
148
|
+
choice = input(" [y/n]: ").strip().lower()
|
|
149
|
+
if choice == 'y':
|
|
150
|
+
return 'script-automation'
|
|
151
|
+
|
|
152
|
+
# Question 3: Templates
|
|
153
|
+
print("\n3. Are you generating documents from templates?")
|
|
154
|
+
choice = input(" [y/n]: ").strip().lower()
|
|
155
|
+
if choice == 'y':
|
|
156
|
+
return 'template-generation'
|
|
157
|
+
|
|
158
|
+
# Default
|
|
159
|
+
return 'iterative-refinement'
|
|
160
|
+
|
|
161
|
+
def generate_recommendation(self, pattern_id: str, confidence: float = None) -> str:
|
|
162
|
+
"""Generate detailed pattern recommendation."""
|
|
163
|
+
pattern = self.PATTERNS.get(pattern_id)
|
|
164
|
+
|
|
165
|
+
if not pattern:
|
|
166
|
+
return f"Error: Unknown pattern '{pattern_id}'"
|
|
167
|
+
|
|
168
|
+
lines = []
|
|
169
|
+
lines.append(f"\n{'='*60}")
|
|
170
|
+
lines.append(f"Recommended Pattern: {pattern['name']}")
|
|
171
|
+
lines.append('='*60 + '\n')
|
|
172
|
+
|
|
173
|
+
if confidence is not None:
|
|
174
|
+
lines.append(f"Match confidence: {confidence:.0%}\n")
|
|
175
|
+
|
|
176
|
+
lines.append(f"Description: {pattern['description']}\n")
|
|
177
|
+
lines.append(f"Use When: {pattern['use_when']}\n")
|
|
178
|
+
|
|
179
|
+
lines.append("Example Use Cases:")
|
|
180
|
+
for example in pattern['examples']:
|
|
181
|
+
lines.append(f" • {example}")
|
|
182
|
+
lines.append("")
|
|
183
|
+
|
|
184
|
+
lines.append("References:")
|
|
185
|
+
lines.append(" • File 04 (hybrid-patterns.md) - Combining patterns")
|
|
186
|
+
lines.append(" • File 09 (case-studies.md) - Real-world examples")
|
|
187
|
+
lines.append(" • Panduan Komprehensif - Detailed pattern docs\n")
|
|
188
|
+
|
|
189
|
+
return '\n'.join(lines)
|
|
190
|
+
|
|
191
|
+
def list_all_patterns(self) -> str:
|
|
192
|
+
"""List all available patterns with brief descriptions."""
|
|
193
|
+
lines = []
|
|
194
|
+
lines.append(f"\n{'='*60}")
|
|
195
|
+
lines.append("Available Workflow Patterns")
|
|
196
|
+
lines.append('='*60 + '\n')
|
|
197
|
+
|
|
198
|
+
for i, (pattern_id, pattern) in enumerate(self.PATTERNS.items(), 1):
|
|
199
|
+
lines.append(f"{i}. {pattern['name']}")
|
|
200
|
+
lines.append(f" {pattern['description']}")
|
|
201
|
+
lines.append(f" Use when: {pattern['use_when']}\n")
|
|
202
|
+
|
|
203
|
+
lines.append(f"Total: {len(self.PATTERNS)} proven patterns")
|
|
204
|
+
lines.append("\nReferences:")
|
|
205
|
+
lines.append(" • Panduan Komprehensif - Full pattern documentation")
|
|
206
|
+
lines.append(" • File 04 - Hybrid pattern combinations")
|
|
207
|
+
lines.append(" • File 09 - Case studies\n")
|
|
208
|
+
|
|
209
|
+
return '\n'.join(lines)
|
|
210
|
+
|
|
211
|
+
# ========== JSON OUTPUT METHODS ==========
|
|
212
|
+
|
|
213
|
+
def list_all_patterns_json(self) -> Dict:
|
|
214
|
+
"""List all patterns in JSON format."""
|
|
215
|
+
patterns_list = []
|
|
216
|
+
for pattern_id, pattern in self.PATTERNS.items():
|
|
217
|
+
patterns_list.append({
|
|
218
|
+
'id': pattern_id,
|
|
219
|
+
'name': pattern['name'],
|
|
220
|
+
'description': pattern['description'],
|
|
221
|
+
'use_when': pattern['use_when'],
|
|
222
|
+
'examples': pattern['examples'],
|
|
223
|
+
'keywords': pattern['keywords']
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
'patterns': patterns_list,
|
|
228
|
+
'total': len(self.PATTERNS),
|
|
229
|
+
'references': {
|
|
230
|
+
'comprehensive_guide': 'Panduan Komprehensif',
|
|
231
|
+
'hybrid_patterns': 'File 04',
|
|
232
|
+
'case_studies': 'File 09'
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
def generate_recommendation_json(self, pattern_id: str, confidence: float = None) -> Dict:
|
|
237
|
+
"""Generate pattern recommendation in JSON format."""
|
|
238
|
+
pattern = self.PATTERNS.get(pattern_id)
|
|
239
|
+
|
|
240
|
+
if not pattern:
|
|
241
|
+
return {
|
|
242
|
+
'error': f"Unknown pattern '{pattern_id}'"
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
result = {
|
|
246
|
+
'pattern_id': pattern_id,
|
|
247
|
+
'pattern_name': pattern['name'],
|
|
248
|
+
'description': pattern['description'],
|
|
249
|
+
'use_when': pattern['use_when'],
|
|
250
|
+
'examples': pattern['examples'],
|
|
251
|
+
'references': [
|
|
252
|
+
'File 04 (hybrid-patterns.md) - Combining patterns',
|
|
253
|
+
'File 09 (case-studies.md) - Real-world examples',
|
|
254
|
+
'Panduan Komprehensif - Detailed pattern docs'
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if confidence is not None:
|
|
259
|
+
result['confidence'] = round(confidence, 2)
|
|
260
|
+
|
|
261
|
+
return result
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def main():
|
|
265
|
+
"""CLI entry point."""
|
|
266
|
+
import argparse
|
|
267
|
+
|
|
268
|
+
parser = argparse.ArgumentParser(
|
|
269
|
+
description='Recommend workflow patterns for Claude skills',
|
|
270
|
+
epilog='References: Files 04, 09, Panduan Komprehensif'
|
|
271
|
+
)
|
|
272
|
+
parser.add_argument('description', nargs='?',
|
|
273
|
+
help='Use case description (or use --interactive)')
|
|
274
|
+
parser.add_argument('-i', '--interactive', action='store_true',
|
|
275
|
+
help='Interactive pattern selection mode')
|
|
276
|
+
parser.add_argument('-l', '--list', action='store_true',
|
|
277
|
+
help='List all available patterns')
|
|
278
|
+
add_format_argument(parser) # Standardized --format argument
|
|
279
|
+
|
|
280
|
+
args = parser.parse_args()
|
|
281
|
+
|
|
282
|
+
detector = PatternDetector()
|
|
283
|
+
|
|
284
|
+
# List mode
|
|
285
|
+
if args.list:
|
|
286
|
+
if args.format == 'json':
|
|
287
|
+
data = detector.list_all_patterns_json()
|
|
288
|
+
response = format_success_response(
|
|
289
|
+
data=data,
|
|
290
|
+
tool_name='pattern_detector'
|
|
291
|
+
)
|
|
292
|
+
output_json(response)
|
|
293
|
+
else:
|
|
294
|
+
print(detector.list_all_patterns())
|
|
295
|
+
sys.exit(0)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
# Interactive mode
|
|
299
|
+
if args.interactive or not args.description:
|
|
300
|
+
if args.format == 'json':
|
|
301
|
+
response = format_error_response(
|
|
302
|
+
error_type='InteractiveModeNotSupported',
|
|
303
|
+
message='Interactive mode does not support JSON output',
|
|
304
|
+
tool_name='pattern_detector',
|
|
305
|
+
help_text='Use analysis mode with description for JSON output'
|
|
306
|
+
)
|
|
307
|
+
output_json(response)
|
|
308
|
+
sys.exit(1)
|
|
309
|
+
pattern_id = detector.interactive_selection()
|
|
310
|
+
print(detector.generate_recommendation(pattern_id))
|
|
311
|
+
sys.exit(0)
|
|
312
|
+
|
|
313
|
+
# Analysis mode
|
|
314
|
+
matches = detector.analyze_use_case(args.description)
|
|
315
|
+
best_match, confidence = matches[0]
|
|
316
|
+
|
|
317
|
+
if confidence < 0.1:
|
|
318
|
+
if args.format == 'json':
|
|
319
|
+
response = format_error_response(
|
|
320
|
+
error_type='NoPatternMatch',
|
|
321
|
+
message='No clear pattern match found',
|
|
322
|
+
tool_name='pattern_detector',
|
|
323
|
+
help_text='Try providing more keywords in description, use --interactive mode, or --list to see all patterns',
|
|
324
|
+
details={'confidence': round(confidence, 2)}
|
|
325
|
+
)
|
|
326
|
+
output_json(response)
|
|
327
|
+
else:
|
|
328
|
+
print("No clear pattern match found.")
|
|
329
|
+
print("\nSuggestions:")
|
|
330
|
+
print(" - Try --interactive mode for guided selection")
|
|
331
|
+
print(" - Try --list to see all available patterns")
|
|
332
|
+
print(" - Provide more keywords in your description")
|
|
333
|
+
sys.exit(1)
|
|
334
|
+
|
|
335
|
+
# Show primary recommendation
|
|
336
|
+
if args.format == 'json':
|
|
337
|
+
recommendation = detector.generate_recommendation_json(best_match, confidence)
|
|
338
|
+
|
|
339
|
+
# Add alternatives if confidence is moderate
|
|
340
|
+
alternatives = []
|
|
341
|
+
if confidence < 0.5 and len(matches) > 1:
|
|
342
|
+
for pattern_id, score in matches[1:3]:
|
|
343
|
+
if score > 0:
|
|
344
|
+
pattern = detector.PATTERNS[pattern_id]
|
|
345
|
+
alternatives.append({
|
|
346
|
+
'pattern_id': pattern_id,
|
|
347
|
+
'pattern_name': pattern['name'],
|
|
348
|
+
'description': pattern['description'],
|
|
349
|
+
'confidence': round(score, 2)
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
data = {
|
|
353
|
+
'primary_recommendation': recommendation,
|
|
354
|
+
'alternatives': alternatives if alternatives else None
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
response = format_success_response(
|
|
358
|
+
data=data,
|
|
359
|
+
tool_name='pattern_detector'
|
|
360
|
+
)
|
|
361
|
+
output_json(response)
|
|
362
|
+
else:
|
|
363
|
+
print(detector.generate_recommendation(best_match, confidence))
|
|
364
|
+
|
|
365
|
+
# Show alternatives if confidence is moderate
|
|
366
|
+
if confidence < 0.5 and len(matches) > 1:
|
|
367
|
+
print("\n" + "-"*60)
|
|
368
|
+
print("Alternative patterns to consider:")
|
|
369
|
+
print("-"*60)
|
|
370
|
+
for pattern_id, score in matches[1:3]:
|
|
371
|
+
if score > 0:
|
|
372
|
+
pattern = detector.PATTERNS[pattern_id]
|
|
373
|
+
print(f" - {pattern['name']} ({score:.0%} match)")
|
|
374
|
+
print(f" {pattern['description']}")
|
|
375
|
+
print()
|
|
376
|
+
|
|
377
|
+
sys.exit(0)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
if __name__ == '__main__':
|
|
381
|
+
main()
|