@relipa/ai-flow-kit 0.1.1-beta.0 → 0.1.2-beta.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.
Files changed (247) hide show
  1. package/README.md +0 -0
  2. package/bin/aiflow.js +55 -2
  3. package/bin/ak.js +0 -0
  4. package/custom/mcp-presets/README.md +204 -204
  5. package/custom/mcp-presets/backlog.json +0 -0
  6. package/custom/mcp-presets/figma-desktop.json +0 -0
  7. package/custom/mcp-presets/figma.json +0 -0
  8. package/custom/mcp-presets/gitnexus.json +0 -0
  9. package/custom/mcp-presets/google-sheets.json +0 -0
  10. package/custom/mcp-presets/jira.json +0 -0
  11. package/custom/prompts/bug-fix.md +0 -0
  12. package/custom/prompts/feature.md +0 -0
  13. package/custom/prompts/investigation.md +0 -0
  14. package/custom/rules/code-style.md +0 -0
  15. package/custom/rules/java/code-style.md +0 -0
  16. package/custom/rules/java/naming.md +0 -0
  17. package/custom/rules/java/review-checklist.md +0 -0
  18. package/custom/rules/java/spring-boot-examples.md +0 -0
  19. package/custom/rules/javascript/code-style.md +0 -0
  20. package/custom/rules/javascript/naming.md +0 -0
  21. package/custom/rules/ml-conventions.md +88 -0
  22. package/custom/rules/ml-review-checklist.md +14 -0
  23. package/custom/rules/naming.md +0 -0
  24. package/custom/rules/php/code-style.md +0 -0
  25. package/custom/rules/php/naming.md +0 -0
  26. package/custom/rules/project-conventions.md +0 -0
  27. package/custom/rules/review-checklist.md +0 -0
  28. package/custom/skills/deploy-model/SKILL.md +90 -0
  29. package/custom/skills/design-experiment/SKILL.md +88 -0
  30. package/custom/skills/evaluate-model/SKILL.md +93 -0
  31. package/custom/skills/explore-data/SKILL.md +87 -0
  32. package/custom/skills/figma-to-component/SKILL.md +164 -59
  33. package/custom/skills/frame-ml-problem/SKILL.md +88 -0
  34. package/custom/skills/generate-spec/SKILL.md +0 -0
  35. package/custom/skills/impact-analysis/SKILL.md +0 -0
  36. package/custom/skills/improve-algorithm/SKILL.md +74 -0
  37. package/custom/skills/investigate-bug/SKILL.md +0 -0
  38. package/custom/skills/read-study-requirement/SKILL.md +0 -0
  39. package/custom/skills/report-customer/SKILL.md +0 -0
  40. package/custom/skills/review-plan/SKILL.md +0 -0
  41. package/custom/skills/train-model/SKILL.md +78 -0
  42. package/custom/templates/laravel.md +0 -0
  43. package/custom/templates/nestjs.md +0 -0
  44. package/custom/templates/nextjs.md +0 -0
  45. package/custom/templates/nodejs-express.md +0 -0
  46. package/custom/templates/php-plain.md +0 -0
  47. package/custom/templates/php.md +0 -0
  48. package/custom/templates/python-django.md +0 -0
  49. package/custom/templates/python-fastapi.md +0 -0
  50. package/custom/templates/python-ml.md +273 -0
  51. package/custom/templates/python.md +0 -0
  52. package/custom/templates/reactjs.md +0 -0
  53. package/custom/templates/shared/gate-workflow.md +0 -0
  54. package/custom/templates/shared/ml-gate-workflow.md +103 -0
  55. package/custom/templates/spring-boot.md +0 -0
  56. package/custom/templates/tools/claude.md +0 -0
  57. package/custom/templates/tools/copilot.md +0 -0
  58. package/custom/templates/tools/cursor.md +0 -0
  59. package/custom/templates/tools/gemini.md +0 -0
  60. package/custom/templates/tools/generic.md +0 -0
  61. package/custom/templates/vue-nuxt.md +0 -0
  62. package/docs/common/AIFLOW.md +512 -512
  63. package/docs/common/CHANGELOG.md +16 -0
  64. package/docs/common/QUICK_START.md +0 -0
  65. package/docs/common/ai-integration.md +0 -0
  66. package/docs/common/cli-reference.md +0 -0
  67. package/docs/common/configuration.md +0 -0
  68. package/docs/common/getting-started.md +0 -0
  69. package/docs/common/troubleshooting.md +0 -0
  70. package/docs/common/workflows/bug-fix.md +0 -0
  71. package/docs/common/workflows/feature.md +0 -0
  72. package/docs/common/workflows/figma.md +0 -0
  73. package/docs/common/workflows/impact-analysis.md +0 -0
  74. package/docs/common/workflows/investigation.md +0 -0
  75. package/docs/common/workflows/refactor.md +0 -0
  76. package/docs/project/ARCHITECTURE.md +0 -0
  77. package/index.js +0 -0
  78. package/package.json +2 -2
  79. package/scripts/checkpoint.js +0 -0
  80. package/scripts/config.js +0 -0
  81. package/scripts/context.js +0 -0
  82. package/scripts/create-score-excel.js +0 -0
  83. package/scripts/detect.js +239 -239
  84. package/scripts/doctor.js +192 -218
  85. package/scripts/gitnexus-worker.js +0 -0
  86. package/scripts/guide.js +0 -0
  87. package/scripts/hooks/block-git-write.js +0 -0
  88. package/scripts/hooks/session-start.js +0 -0
  89. package/scripts/hooks/session-stop.js +0 -0
  90. package/scripts/init.js +1112 -1009
  91. package/scripts/link-resolver.js +0 -0
  92. package/scripts/memory.js +0 -0
  93. package/scripts/prompt.js +538 -538
  94. package/scripts/remove.js +0 -0
  95. package/scripts/task.js +546 -546
  96. package/scripts/telemetry/cli.js +0 -0
  97. package/scripts/telemetry/config.js +0 -0
  98. package/scripts/telemetry/crypto.js +0 -0
  99. package/scripts/telemetry/flush.js +0 -0
  100. package/scripts/telemetry/record.js +0 -0
  101. package/scripts/update.js +10 -7
  102. package/scripts/use.js +33 -12
  103. package/scripts/validate.js +0 -0
  104. package/upstream/.claude-plugin/marketplace.json +0 -0
  105. package/upstream/.claude-plugin/plugin.json +0 -0
  106. package/upstream/.codex/INSTALL.md +0 -0
  107. package/upstream/.cursor-plugin/plugin.json +0 -0
  108. package/upstream/.gitattributes +0 -0
  109. package/upstream/.github/FUNDING.yml +0 -0
  110. package/upstream/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  111. package/upstream/.github/ISSUE_TEMPLATE/config.yml +0 -0
  112. package/upstream/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  113. package/upstream/.github/ISSUE_TEMPLATE/platform_support.md +0 -0
  114. package/upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  115. package/upstream/.opencode/INSTALL.md +0 -0
  116. package/upstream/.opencode/plugins/superpowers.js +0 -0
  117. package/upstream/.version-bump.json +0 -0
  118. package/upstream/AGENTS.md +0 -0
  119. package/upstream/CHANGELOG.md +0 -0
  120. package/upstream/CLAUDE.md +0 -0
  121. package/upstream/CODE_OF_CONDUCT.md +0 -0
  122. package/upstream/GEMINI.md +0 -0
  123. package/upstream/LICENSE +0 -0
  124. package/upstream/README.md +0 -0
  125. package/upstream/RELEASE-NOTES.md +0 -0
  126. package/upstream/agents/code-reviewer.md +0 -0
  127. package/upstream/commands/brainstorm.md +0 -0
  128. package/upstream/commands/execute-plan.md +0 -0
  129. package/upstream/commands/write-plan.md +0 -0
  130. package/upstream/docs/README.codex.md +0 -0
  131. package/upstream/docs/README.opencode.md +0 -0
  132. package/upstream/docs/plans/2025-11-22-opencode-support-design.md +0 -0
  133. package/upstream/docs/plans/2025-11-22-opencode-support-implementation.md +0 -0
  134. package/upstream/docs/plans/2025-11-28-skills-improvements-from-user-feedback.md +0 -0
  135. package/upstream/docs/plans/2026-01-17-visual-brainstorming.md +0 -0
  136. package/upstream/docs/superpowers/plans/2026-01-22-document-review-system.md +0 -0
  137. package/upstream/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +0 -0
  138. package/upstream/docs/superpowers/plans/2026-03-11-zero-dep-brainstorm-server.md +0 -0
  139. package/upstream/docs/superpowers/plans/2026-03-23-codex-app-compatibility.md +0 -0
  140. package/upstream/docs/superpowers/specs/2026-01-22-document-review-system-design.md +0 -0
  141. package/upstream/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +0 -0
  142. package/upstream/docs/superpowers/specs/2026-03-11-zero-dep-brainstorm-server-design.md +0 -0
  143. package/upstream/docs/superpowers/specs/2026-03-23-codex-app-compatibility-design.md +0 -0
  144. package/upstream/docs/testing.md +0 -0
  145. package/upstream/docs/windows/polyglot-hooks.md +0 -0
  146. package/upstream/gemini-extension.json +0 -0
  147. package/upstream/hooks/hooks-cursor.json +0 -0
  148. package/upstream/hooks/hooks.json +0 -0
  149. package/upstream/hooks/run-hook.cmd +0 -0
  150. package/upstream/hooks/session-start +0 -0
  151. package/upstream/package.json +0 -0
  152. package/upstream/scripts/bump-version.sh +0 -0
  153. package/upstream/skills/brainstorming/SKILL.md +0 -0
  154. package/upstream/skills/brainstorming/scripts/frame-template.html +0 -0
  155. package/upstream/skills/brainstorming/scripts/helper.js +0 -0
  156. package/upstream/skills/brainstorming/scripts/server.cjs +0 -0
  157. package/upstream/skills/brainstorming/scripts/start-server.sh +0 -0
  158. package/upstream/skills/brainstorming/scripts/stop-server.sh +0 -0
  159. package/upstream/skills/brainstorming/spec-document-reviewer-prompt.md +0 -0
  160. package/upstream/skills/brainstorming/visual-companion.md +0 -0
  161. package/upstream/skills/dispatching-parallel-agents/SKILL.md +0 -0
  162. package/upstream/skills/executing-plans/SKILL.md +0 -0
  163. package/upstream/skills/finishing-a-development-branch/SKILL.md +0 -0
  164. package/upstream/skills/receiving-code-review/SKILL.md +0 -0
  165. package/upstream/skills/requesting-code-review/SKILL.md +0 -0
  166. package/upstream/skills/requesting-code-review/code-reviewer.md +0 -0
  167. package/upstream/skills/subagent-driven-development/SKILL.md +0 -0
  168. package/upstream/skills/subagent-driven-development/code-quality-reviewer-prompt.md +0 -0
  169. package/upstream/skills/subagent-driven-development/implementer-prompt.md +0 -0
  170. package/upstream/skills/subagent-driven-development/spec-reviewer-prompt.md +0 -0
  171. package/upstream/skills/systematic-debugging/CREATION-LOG.md +0 -0
  172. package/upstream/skills/systematic-debugging/SKILL.md +0 -0
  173. package/upstream/skills/systematic-debugging/condition-based-waiting-example.ts +0 -0
  174. package/upstream/skills/systematic-debugging/condition-based-waiting.md +0 -0
  175. package/upstream/skills/systematic-debugging/defense-in-depth.md +0 -0
  176. package/upstream/skills/systematic-debugging/find-polluter.sh +0 -0
  177. package/upstream/skills/systematic-debugging/root-cause-tracing.md +0 -0
  178. package/upstream/skills/systematic-debugging/test-academic.md +0 -0
  179. package/upstream/skills/systematic-debugging/test-pressure-1.md +0 -0
  180. package/upstream/skills/systematic-debugging/test-pressure-2.md +0 -0
  181. package/upstream/skills/systematic-debugging/test-pressure-3.md +0 -0
  182. package/upstream/skills/tdd-lean/SKILL.md +0 -0
  183. package/upstream/skills/test-driven-development/SKILL.md +0 -0
  184. package/upstream/skills/test-driven-development/testing-anti-patterns.md +0 -0
  185. package/upstream/skills/using-git-worktrees/SKILL.md +0 -0
  186. package/upstream/skills/using-superpowers/SKILL.md +0 -0
  187. package/upstream/skills/using-superpowers/references/codex-tools.md +0 -0
  188. package/upstream/skills/using-superpowers/references/copilot-tools.md +0 -0
  189. package/upstream/skills/using-superpowers/references/gemini-tools.md +0 -0
  190. package/upstream/skills/verification-before-completion/SKILL.md +0 -0
  191. package/upstream/skills/writing-plans/SKILL.md +0 -0
  192. package/upstream/skills/writing-plans/plan-document-reviewer-prompt.md +0 -0
  193. package/upstream/skills/writing-skills/SKILL.md +0 -0
  194. package/upstream/skills/writing-skills/anthropic-best-practices.md +0 -0
  195. package/upstream/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -0
  196. package/upstream/skills/writing-skills/graphviz-conventions.dot +0 -0
  197. package/upstream/skills/writing-skills/persuasion-principles.md +0 -0
  198. package/upstream/skills/writing-skills/render-graphs.js +0 -0
  199. package/upstream/skills/writing-skills/testing-skills-with-subagents.md +0 -0
  200. package/upstream/tests/brainstorm-server/package-lock.json +0 -0
  201. package/upstream/tests/brainstorm-server/package.json +0 -0
  202. package/upstream/tests/brainstorm-server/server.test.js +0 -0
  203. package/upstream/tests/brainstorm-server/windows-lifecycle.test.sh +0 -0
  204. package/upstream/tests/brainstorm-server/ws-protocol.test.js +0 -0
  205. package/upstream/tests/claude-code/README.md +0 -0
  206. package/upstream/tests/claude-code/analyze-token-usage.py +0 -0
  207. package/upstream/tests/claude-code/run-skill-tests.sh +0 -0
  208. package/upstream/tests/claude-code/test-document-review-system.sh +0 -0
  209. package/upstream/tests/claude-code/test-helpers.sh +0 -0
  210. package/upstream/tests/claude-code/test-subagent-driven-development-integration.sh +0 -0
  211. package/upstream/tests/claude-code/test-subagent-driven-development.sh +0 -0
  212. package/upstream/tests/explicit-skill-requests/prompts/action-oriented.txt +0 -0
  213. package/upstream/tests/explicit-skill-requests/prompts/after-planning-flow.txt +0 -0
  214. package/upstream/tests/explicit-skill-requests/prompts/claude-suggested-it.txt +0 -0
  215. package/upstream/tests/explicit-skill-requests/prompts/i-know-what-sdd-means.txt +0 -0
  216. package/upstream/tests/explicit-skill-requests/prompts/mid-conversation-execute-plan.txt +0 -0
  217. package/upstream/tests/explicit-skill-requests/prompts/please-use-brainstorming.txt +0 -0
  218. package/upstream/tests/explicit-skill-requests/prompts/skip-formalities.txt +0 -0
  219. package/upstream/tests/explicit-skill-requests/prompts/subagent-driven-development-please.txt +0 -0
  220. package/upstream/tests/explicit-skill-requests/prompts/use-systematic-debugging.txt +0 -0
  221. package/upstream/tests/explicit-skill-requests/run-all.sh +0 -0
  222. package/upstream/tests/explicit-skill-requests/run-claude-describes-sdd.sh +0 -0
  223. package/upstream/tests/explicit-skill-requests/run-extended-multiturn-test.sh +0 -0
  224. package/upstream/tests/explicit-skill-requests/run-haiku-test.sh +0 -0
  225. package/upstream/tests/explicit-skill-requests/run-multiturn-test.sh +0 -0
  226. package/upstream/tests/explicit-skill-requests/run-test.sh +0 -0
  227. package/upstream/tests/opencode/run-tests.sh +0 -0
  228. package/upstream/tests/opencode/setup.sh +0 -0
  229. package/upstream/tests/opencode/test-plugin-loading.sh +0 -0
  230. package/upstream/tests/opencode/test-priority.sh +0 -0
  231. package/upstream/tests/opencode/test-tools.sh +0 -0
  232. package/upstream/tests/skill-triggering/prompts/dispatching-parallel-agents.txt +0 -0
  233. package/upstream/tests/skill-triggering/prompts/executing-plans.txt +0 -0
  234. package/upstream/tests/skill-triggering/prompts/requesting-code-review.txt +0 -0
  235. package/upstream/tests/skill-triggering/prompts/systematic-debugging.txt +0 -0
  236. package/upstream/tests/skill-triggering/prompts/test-driven-development.txt +0 -0
  237. package/upstream/tests/skill-triggering/prompts/writing-plans.txt +0 -0
  238. package/upstream/tests/skill-triggering/run-all.sh +0 -0
  239. package/upstream/tests/skill-triggering/run-test.sh +0 -0
  240. package/upstream/tests/subagent-driven-dev/go-fractals/design.md +0 -0
  241. package/upstream/tests/subagent-driven-dev/go-fractals/plan.md +0 -0
  242. package/upstream/tests/subagent-driven-dev/go-fractals/scaffold.sh +0 -0
  243. package/upstream/tests/subagent-driven-dev/run-test.sh +0 -0
  244. package/upstream/tests/subagent-driven-dev/svelte-todo/design.md +0 -0
  245. package/upstream/tests/subagent-driven-dev/svelte-todo/plan.md +0 -0
  246. package/upstream/tests/subagent-driven-dev/svelte-todo/scaffold.sh +0 -0
  247. package/scripts/score_members.js +0 -320
@@ -7,6 +7,22 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ---
9
9
 
10
+ ## [0.1.1] - 2026-06-08
11
+
12
+ ### Added
13
+
14
+ - **Ubuntu / Linux clipboard support in `ak prompt`** — `ak prompt` now copies to the clipboard on native Linux. It auto-detects the display server (Wayland → `wl-copy`, X11 → `xclip` → `xsel`) and the package manager (`apt-get` / `dnf` / `pacman` / `zypper`). When no clipboard tool is installed it prints a clear warning (`⚠ Clipboard tool not found (need: xclip)`), shows the exact install command, and offers to install it via `sudo` then retries the copy. If the user declines or no package manager is found, it falls back to printing the full prompt for manual copy. Previously the command silently failed on Ubuntu when neither `xclip` nor `xsel` was present.
15
+ - **`figma-to-component`: image detection & export** — The skill now scans the Figma node tree for image nodes (`fills[].type === "IMAGE"`, `VECTOR`/`BOOLEAN_OPERATION`, complex non-CSS groups), exports them via `download_figma_images` into `public/assets/figma/`, and records an `imageMap`. Generated components render those nodes with `<Image>` (Next.js) / `<img>` (React/Vue) instead of CSS `background-image`.
16
+ - **`figma-to-component`: MCP availability pre-check (Step 0)** — The skill now verifies `mcp__figma__get_figma_data` / `mcp__figma__download_figma_images` are connected before running, and stops with setup instructions (`aiflow init -a figma` / `-a figma-desktop`) instead of guessing design values from the URL.
17
+ - **`figma-to-component`: CSS tooling detection + design tokens** — Detection now branches on the project's styling approach (Tailwind / CSS Modules / styled-components / vanilla CSS) instead of hardcoding Tailwind, and prefers mapping Figma Styles/Variables to existing project tokens (Tailwind theme keys or CSS custom properties), falling back to arbitrary values only when no token matches.
18
+ - **`figma-to-component`: troubleshooting table** — Added a troubleshooting section covering MCP-not-connected, `403`/token rejected, request timeout (lower `depth`), `404` node-id, empty fills, and unsupported `download_figma_images`.
19
+
20
+ ### Fixed
21
+
22
+ - **Critical: `figma-to-component` source/installed divergence** — The source skill (`custom/skills/figma-to-component/SKILL.md`) still referenced the non-existent tool names `figma_get_file_nodes` / `figma_get_file_styles` / `figma_get_image` and only had 2-tier framework detection, while the installed `.claude/` copy had been fixed in 0.0.9. The next `aiflow init` / `sync-skills` would have overwritten the working copy with the broken source — re-introducing the 0.0.9 bug. Both copies are now synced to a single canonical version: correct tool names (`get_figma_data` / `download_figma_images`), 4-tier framework detection (App Router / React / Vue / Angular), and the image-export step.
23
+
24
+ ---
25
+
10
26
  ## [0.1.0] - 2026-05-28
11
27
 
12
28
  ### Added
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relipa/ai-flow-kit",
3
- "version": "0.1.1-beta.0",
3
+ "version": "0.1.2-beta.0",
4
4
  "description": "All-in-one AI Flow Kit for team development with Claude AI - skills, templates, and MCP adapters",
5
5
  "author": "Example Team",
6
6
  "publishConfig": {
@@ -65,4 +65,4 @@
65
65
  "<rootDir>/tests/**/*.test.js"
66
66
  ]
67
67
  }
68
- }
68
+ }
File without changes
package/scripts/config.js CHANGED
File without changes
File without changes
File without changes
package/scripts/detect.js CHANGED
@@ -1,239 +1,239 @@
1
- const chalk = require('chalk');
2
-
3
- class TaskDetector {
4
- constructor() {
5
- this.taskTypes = {
6
- 'bug-fix': {
7
- keywords: [
8
- 'bug', 'error', 'broken', 'crash', 'fail', 'failed', 'failure',
9
- 'issue', 'problem', 'wrong', 'not working', 'doesn\'t work',
10
- 'can\'t', 'cannot', 'regression', 'fixing', 'fix',
11
- 'exception', 'bug report'
12
- ],
13
- antiKeywords: ['add', 'create', 'new feature', 'build'],
14
- icon: '🐛',
15
- description: 'Fixing production issues'
16
- },
17
- 'feature': {
18
- keywords: [
19
- 'add', 'create', 'build', 'new', 'implement', 'feature',
20
- 'new feature', 'feature request', 'capability', 'support for',
21
- 'enable', 'make it possible', 'allow', 'user story'
22
- ],
23
- antiKeywords: ['fix', 'bug', 'broken', 'error'],
24
- icon: '✨',
25
- description: 'Building new features'
26
- },
27
- 'refactor': {
28
- keywords: [
29
- 'refactor', 'improve', 'optimize', 'clean up', 'cleanup',
30
- 'simplify', 'reorganize', 'reorganise', 'redesign', 'restructure',
31
- 'modernize', 'upgrade', 'update', 'rework', 'rewrite',
32
- 'performance', 'efficient', 'better', 'enhancement'
33
- ],
34
- antiKeywords: ['bug', 'broken', 'feature'],
35
- icon: '♻️',
36
- description: 'Improving existing code'
37
- },
38
- 'investigation': {
39
- keywords: [
40
- 'investigate', 'analyze', 'analysis', 'understand', 'how does',
41
- 'why', 'trace', 'explore', 'research', 'find out', 'examine',
42
- 'check', 'review', 'audit', 'assessment'
43
- ],
44
- antiKeywords: ['fix', 'build', 'create'],
45
- icon: '🔍',
46
- description: 'Analyzing code and systems'
47
- },
48
- 'impact-analysis': {
49
- keywords: [
50
- 'impact', 'affect', 'affected', 'breaking', 'breaking change',
51
- 'scope', 'scope of change', 'side effect', 'consequence',
52
- 'dependent', 'dependency', 'risk', 'assess'
53
- ],
54
- antiKeywords: [],
55
- icon: '📊',
56
- description: 'Assessing change impact'
57
- },
58
- 'documentation': {
59
- keywords: [
60
- 'document', 'readme', 'guide', 'tutorial',
61
- 'documentation', 'write doc', 'comment', 'docstring',
62
- 'explain', 'api doc', 'reference'
63
- ],
64
- antiKeywords: ['code'],
65
- icon: '📖',
66
- description: 'Writing documentation'
67
- }
68
- };
69
- }
70
-
71
- /**
72
- * Detect task type from description
73
- * Returns: { type, confidence, keywords, suggestions }
74
- */
75
- detect(description, confidenceThreshold = 0.8) {
76
- if (!description || typeof description !== 'string') {
77
- return this.getDefaultResult();
78
- }
79
-
80
- const lowerDesc = description.toLowerCase();
81
- const scores = {};
82
-
83
- // Score each task type
84
- for (const [type, config] of Object.entries(this.taskTypes)) {
85
- scores[type] = this.scoreType(lowerDesc, config);
86
- }
87
-
88
- // Find best match
89
- const sorted = Object.entries(scores)
90
- .sort(([, scoreA], [, scoreB]) => scoreB - scoreA);
91
-
92
- if (!sorted.length || sorted[0][1] === 0) {
93
- return this.getDefaultResult();
94
- }
95
-
96
- const [bestType, score] = sorted[0];
97
- const confidence = Math.min(score, 1.0);
98
-
99
- return {
100
- type: bestType,
101
- confidence: Math.round(confidence * 100) / 100,
102
- confidence_percent: Math.round(confidence * 100),
103
- icon: this.taskTypes[bestType].icon,
104
- description: this.taskTypes[bestType].description,
105
- keywords: this.findMatchingKeywords(lowerDesc, this.taskTypes[bestType]),
106
- suggestions: sorted.slice(1, 3).map(([t, s]) => ({
107
- type: t,
108
- confidence: Math.round(s * 100) / 100
109
- })),
110
- isConfident: confidence >= confidenceThreshold,
111
- detectedKeywords: this.findAllMatchedKeywords(lowerDesc)
112
- };
113
- }
114
-
115
- /**
116
- * Score a task type based on description
117
- */
118
- scoreType(description, config) {
119
- let score = 0;
120
-
121
- // Count matching keywords
122
- for (const keyword of config.keywords) {
123
- if (description.includes(keyword)) {
124
- score += 0.5;
125
- }
126
- }
127
-
128
- // Penalize anti-keywords
129
- for (const antiKeyword of config.antiKeywords) {
130
- if (description.includes(antiKeyword)) {
131
- score -= 0.3;
132
- }
133
- }
134
-
135
- // Normalize score
136
- return Math.max(0, Math.min(1, score / Math.max(1, config.keywords.length / 3)));
137
- }
138
-
139
- /**
140
- * Find which keywords matched in description
141
- */
142
- findMatchingKeywords(description, config) {
143
- const matches = [];
144
- for (const keyword of config.keywords) {
145
- if (description.includes(keyword)) {
146
- matches.push(keyword);
147
- }
148
- }
149
- return matches.slice(0, 5); // Top 5 matches
150
- }
151
-
152
- /**
153
- * Find all matched keywords across all types
154
- */
155
- findAllMatchedKeywords(description) {
156
- const allKeywords = {};
157
- for (const [type, config] of Object.entries(this.taskTypes)) {
158
- const matched = this.findMatchingKeywords(description, config);
159
- if (matched.length > 0) {
160
- allKeywords[type] = matched;
161
- }
162
- }
163
- return allKeywords;
164
- }
165
-
166
- /**
167
- * Default result when detection fails
168
- */
169
- getDefaultResult() {
170
- return {
171
- type: 'unknown',
172
- confidence: 0,
173
- confidence_percent: 0,
174
- icon: '❓',
175
- description: 'Unknown task type',
176
- keywords: [],
177
- suggestions: [],
178
- isConfident: false,
179
- detectedKeywords: {}
180
- };
181
- }
182
-
183
- /**
184
- * Get formatted output for CLI
185
- */
186
- formatOutput(result, verbose = false) {
187
- if (result.type === 'unknown') {
188
- return `${result.icon} Could not detect task type\n\nPlease provide more details or specify task type explicitly:\n aiflow prompt bug-fix\n aiflow prompt feature\n aiflow prompt investigation`;
189
- }
190
-
191
- let output = `${result.icon} ${result.type.toUpperCase()} (${result.confidence_percent}% confidence)\n\n`;
192
-
193
- if (verbose) {
194
- output += `Description: ${result.description}\n`;
195
- output += `Detected keywords:\n`;
196
- for (const keyword of result.keywords.slice(0, 5)) {
197
- output += ` - ${keyword}\n`;
198
- }
199
-
200
- if (result.suggestions.length > 0) {
201
- output += `\nOther possibilities:\n`;
202
- for (const sugg of result.suggestions) {
203
- output += ` - ${sugg.type} (${Math.round(sugg.confidence * 100)}%)\n`;
204
- }
205
- }
206
- }
207
-
208
- output += `\nSuggested skill: ${result.type}\n`;
209
- output += `\nNext: aiflow prompt ${result.type}`;
210
-
211
- return output;
212
- }
213
-
214
- /**
215
- * Export all task types for reference
216
- */
217
- getTaskTypes() {
218
- return this.taskTypes;
219
- }
220
-
221
- /**
222
- * Get task type by name
223
- */
224
- getTaskType(name) {
225
- return this.taskTypes[name] || null;
226
- }
227
-
228
- /**
229
- * Get available task types
230
- */
231
- getAvailableTypes() {
232
- return Object.keys(this.taskTypes).map(type => ({
233
- name: type,
234
- ...this.taskTypes[type]
235
- }));
236
- }
237
- }
238
-
239
- module.exports = TaskDetector;
1
+ const chalk = require('chalk');
2
+
3
+ class TaskDetector {
4
+ constructor() {
5
+ this.taskTypes = {
6
+ 'bug-fix': {
7
+ keywords: [
8
+ 'bug', 'error', 'broken', 'crash', 'fail', 'failed', 'failure',
9
+ 'issue', 'problem', 'wrong', 'not working', 'doesn\'t work',
10
+ 'can\'t', 'cannot', 'regression', 'fixing', 'fix',
11
+ 'exception', 'bug report'
12
+ ],
13
+ antiKeywords: ['add', 'create', 'new feature', 'build'],
14
+ icon: '🐛',
15
+ description: 'Fixing production issues'
16
+ },
17
+ 'feature': {
18
+ keywords: [
19
+ 'add', 'create', 'build', 'new', 'implement', 'feature',
20
+ 'new feature', 'feature request', 'capability', 'support for',
21
+ 'enable', 'make it possible', 'allow', 'user story'
22
+ ],
23
+ antiKeywords: ['fix', 'bug', 'broken', 'error'],
24
+ icon: '✨',
25
+ description: 'Building new features'
26
+ },
27
+ 'refactor': {
28
+ keywords: [
29
+ 'refactor', 'improve', 'optimize', 'clean up', 'cleanup',
30
+ 'simplify', 'reorganize', 'reorganise', 'redesign', 'restructure',
31
+ 'modernize', 'upgrade', 'update', 'rework', 'rewrite',
32
+ 'performance', 'efficient', 'better', 'enhancement'
33
+ ],
34
+ antiKeywords: ['bug', 'broken', 'feature'],
35
+ icon: '♻️',
36
+ description: 'Improving existing code'
37
+ },
38
+ 'investigation': {
39
+ keywords: [
40
+ 'investigate', 'analyze', 'analysis', 'understand', 'how does',
41
+ 'why', 'trace', 'explore', 'research', 'find out', 'examine',
42
+ 'check', 'review', 'audit', 'assessment'
43
+ ],
44
+ antiKeywords: ['fix', 'build', 'create'],
45
+ icon: '🔍',
46
+ description: 'Analyzing code and systems'
47
+ },
48
+ 'impact-analysis': {
49
+ keywords: [
50
+ 'impact', 'affect', 'affected', 'breaking', 'breaking change',
51
+ 'scope', 'scope of change', 'side effect', 'consequence',
52
+ 'dependent', 'dependency', 'risk', 'assess'
53
+ ],
54
+ antiKeywords: [],
55
+ icon: '📊',
56
+ description: 'Assessing change impact'
57
+ },
58
+ 'documentation': {
59
+ keywords: [
60
+ 'document', 'readme', 'guide', 'tutorial',
61
+ 'documentation', 'write doc', 'comment', 'docstring',
62
+ 'explain', 'api doc', 'reference'
63
+ ],
64
+ antiKeywords: ['code'],
65
+ icon: '📖',
66
+ description: 'Writing documentation'
67
+ }
68
+ };
69
+ }
70
+
71
+ /**
72
+ * Detect task type from description
73
+ * Returns: { type, confidence, keywords, suggestions }
74
+ */
75
+ detect(description, confidenceThreshold = 0.8) {
76
+ if (!description || typeof description !== 'string') {
77
+ return this.getDefaultResult();
78
+ }
79
+
80
+ const lowerDesc = description.toLowerCase();
81
+ const scores = {};
82
+
83
+ // Score each task type
84
+ for (const [type, config] of Object.entries(this.taskTypes)) {
85
+ scores[type] = this.scoreType(lowerDesc, config);
86
+ }
87
+
88
+ // Find best match
89
+ const sorted = Object.entries(scores)
90
+ .sort(([, scoreA], [, scoreB]) => scoreB - scoreA);
91
+
92
+ if (!sorted.length || sorted[0][1] === 0) {
93
+ return this.getDefaultResult();
94
+ }
95
+
96
+ const [bestType, score] = sorted[0];
97
+ const confidence = Math.min(score, 1.0);
98
+
99
+ return {
100
+ type: bestType,
101
+ confidence: Math.round(confidence * 100) / 100,
102
+ confidence_percent: Math.round(confidence * 100),
103
+ icon: this.taskTypes[bestType].icon,
104
+ description: this.taskTypes[bestType].description,
105
+ keywords: this.findMatchingKeywords(lowerDesc, this.taskTypes[bestType]),
106
+ suggestions: sorted.slice(1, 3).map(([t, s]) => ({
107
+ type: t,
108
+ confidence: Math.round(s * 100) / 100
109
+ })),
110
+ isConfident: confidence >= confidenceThreshold,
111
+ detectedKeywords: this.findAllMatchedKeywords(lowerDesc)
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Score a task type based on description
117
+ */
118
+ scoreType(description, config) {
119
+ let score = 0;
120
+
121
+ // Count matching keywords
122
+ for (const keyword of config.keywords) {
123
+ if (description.includes(keyword)) {
124
+ score += 0.5;
125
+ }
126
+ }
127
+
128
+ // Penalize anti-keywords
129
+ for (const antiKeyword of config.antiKeywords) {
130
+ if (description.includes(antiKeyword)) {
131
+ score -= 0.3;
132
+ }
133
+ }
134
+
135
+ // Normalize score
136
+ return Math.max(0, Math.min(1, score / Math.max(1, config.keywords.length / 3)));
137
+ }
138
+
139
+ /**
140
+ * Find which keywords matched in description
141
+ */
142
+ findMatchingKeywords(description, config) {
143
+ const matches = [];
144
+ for (const keyword of config.keywords) {
145
+ if (description.includes(keyword)) {
146
+ matches.push(keyword);
147
+ }
148
+ }
149
+ return matches.slice(0, 5); // Top 5 matches
150
+ }
151
+
152
+ /**
153
+ * Find all matched keywords across all types
154
+ */
155
+ findAllMatchedKeywords(description) {
156
+ const allKeywords = {};
157
+ for (const [type, config] of Object.entries(this.taskTypes)) {
158
+ const matched = this.findMatchingKeywords(description, config);
159
+ if (matched.length > 0) {
160
+ allKeywords[type] = matched;
161
+ }
162
+ }
163
+ return allKeywords;
164
+ }
165
+
166
+ /**
167
+ * Default result when detection fails
168
+ */
169
+ getDefaultResult() {
170
+ return {
171
+ type: 'unknown',
172
+ confidence: 0,
173
+ confidence_percent: 0,
174
+ icon: '❓',
175
+ description: 'Unknown task type',
176
+ keywords: [],
177
+ suggestions: [],
178
+ isConfident: false,
179
+ detectedKeywords: {}
180
+ };
181
+ }
182
+
183
+ /**
184
+ * Get formatted output for CLI
185
+ */
186
+ formatOutput(result, verbose = false) {
187
+ if (result.type === 'unknown') {
188
+ return `${result.icon} Could not detect task type\n\nPlease provide more details or specify task type explicitly:\n aiflow prompt bug-fix\n aiflow prompt feature\n aiflow prompt investigation`;
189
+ }
190
+
191
+ let output = `${result.icon} ${result.type.toUpperCase()} (${result.confidence_percent}% confidence)\n\n`;
192
+
193
+ if (verbose) {
194
+ output += `Description: ${result.description}\n`;
195
+ output += `Detected keywords:\n`;
196
+ for (const keyword of result.keywords.slice(0, 5)) {
197
+ output += ` - ${keyword}\n`;
198
+ }
199
+
200
+ if (result.suggestions.length > 0) {
201
+ output += `\nOther possibilities:\n`;
202
+ for (const sugg of result.suggestions) {
203
+ output += ` - ${sugg.type} (${Math.round(sugg.confidence * 100)}%)\n`;
204
+ }
205
+ }
206
+ }
207
+
208
+ output += `\nSuggested skill: ${result.type}\n`;
209
+ output += `\nNext: aiflow prompt ${result.type}`;
210
+
211
+ return output;
212
+ }
213
+
214
+ /**
215
+ * Export all task types for reference
216
+ */
217
+ getTaskTypes() {
218
+ return this.taskTypes;
219
+ }
220
+
221
+ /**
222
+ * Get task type by name
223
+ */
224
+ getTaskType(name) {
225
+ return this.taskTypes[name] || null;
226
+ }
227
+
228
+ /**
229
+ * Get available task types
230
+ */
231
+ getAvailableTypes() {
232
+ return Object.keys(this.taskTypes).map(type => ({
233
+ name: type,
234
+ ...this.taskTypes[type]
235
+ }));
236
+ }
237
+ }
238
+
239
+ module.exports = TaskDetector;