@relipa/ai-flow-kit 0.1.2-beta.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +26 -0
  2. package/bin/aiflow.js +40 -1
  3. package/custom/harness/playwright/.env.example +10 -0
  4. package/custom/harness/playwright/playwright.config.ts +34 -0
  5. package/custom/harness/playwright/tests/e2e/auth.setup.ts +25 -0
  6. package/custom/harness/playwright/tests/e2e/fixtures/test.ts +6 -0
  7. package/custom/harness/playwright/tests/e2e/pages/BasePage.ts +9 -0
  8. package/custom/harness/playwright/tests/e2e/support/auth.ts +5 -0
  9. package/custom/mcp-presets/playwright.json +8 -0
  10. package/custom/rules/test-patterns.md +70 -0
  11. package/custom/skills/automation-testing/SKILL.md +239 -0
  12. package/custom/skills/automation-testing/templates/BasePage.ts +29 -0
  13. package/custom/skills/automation-testing/templates/PageObject.example.ts +29 -0
  14. package/custom/skills/automation-testing/templates/playwright.config.ts +39 -0
  15. package/custom/skills/automation-testing/templates/spec.example.ts +29 -0
  16. package/custom/skills/coverage-check/SKILL.md +202 -0
  17. package/custom/skills/evidence-aggregation/SKILL.md +246 -0
  18. package/custom/skills/execute-flow/SKILL.md +479 -0
  19. package/custom/skills/execute-flow/templates/playwright.config.ts +39 -0
  20. package/custom/skills/generate-test-report/SKILL.md +99 -0
  21. package/custom/skills/generate-test-report/templates/test-report.md +58 -0
  22. package/custom/skills/generate-testcase/SKILL.md +303 -0
  23. package/custom/skills/generate-testcase/templates/testcase.md +88 -0
  24. package/custom/skills/log-bug/SKILL.md +131 -0
  25. package/custom/skills/pr-impact-analysis/SKILL.md +180 -0
  26. package/custom/skills/retest-orchestration/SKILL.md +191 -0
  27. package/custom/skills/script-sync/SKILL.md +208 -0
  28. package/custom/skills/test-analysis/SKILL.md +262 -0
  29. package/custom/templates/shared/gate-workflow.md +306 -2
  30. package/docs/common/CHANGELOG.md +84 -0
  31. package/docs/common/QUICK_START.md +30 -0
  32. package/docs/common/cli-reference.md +48 -7
  33. package/package.json +1 -1
  34. package/scripts/create-score-excel.js +20 -7
  35. package/scripts/detect.js +10 -0
  36. package/scripts/guide.js +9 -0
  37. package/scripts/prompt.js +36 -0
  38. package/scripts/scaffold-playwright.js +106 -0
  39. package/scripts/task.js +21 -7
  40. package/scripts/update.js +124 -124
  41. package/scripts/use.js +30 -12
package/scripts/update.js CHANGED
@@ -1,124 +1,124 @@
1
- const fs = require('fs-extra');
2
- const path = require('path');
3
- const chalk = require('chalk');
4
- const { confirm, select } = require('@inquirer/prompts');
5
-
6
- const PKG_DIR = path.join(__dirname, '..');
7
- const PKG_VERSION = require('../package.json').version;
8
-
9
- // Same language map as init.js
10
- const FRAMEWORK_LANGUAGE = {
11
- 'laravel': 'php',
12
- 'spring-boot': 'java',
13
- 'reactjs': 'javascript',
14
- 'nextjs': 'javascript',
15
- 'vue-nuxt': 'javascript',
16
- };
17
-
18
- module.exports = async function update(options = {}) {
19
- const projectDir = process.cwd();
20
- const aiflowDir = path.join(projectDir, '.aiflow');
21
- const stateFile = path.join(aiflowDir, 'state.json');
22
-
23
- if (!(await fs.pathExists(stateFile))) {
24
- console.log(chalk.red('Project is not initialized. Please run `aiflow init` first.'));
25
- return;
26
- }
27
-
28
- const state = await fs.readJson(stateFile);
29
- const currentVersion = state.current_version;
30
-
31
- if (currentVersion === PKG_VERSION && !options.force) {
32
- console.log(chalk.cyan(`You are already on v${PKG_VERSION}. Syncing latest assets and instruction files...`));
33
- } else {
34
- console.log(chalk.blue(`Updating from v${currentVersion} to v${PKG_VERSION}...`));
35
- }
36
-
37
- const newVersionDir = path.join(aiflowDir, 'versions', PKG_VERSION);
38
- await fs.ensureDir(newVersionDir);
39
-
40
- // Merge skills
41
- const upstreamSkills = path.join(PKG_DIR, 'upstream', 'skills');
42
- const customSkills = path.join(PKG_DIR, 'custom', 'skills');
43
-
44
- await fs.ensureDir(path.join(newVersionDir, 'skills'));
45
- if (await fs.pathExists(upstreamSkills)) {
46
- await fs.copy(upstreamSkills, path.join(newVersionDir, 'skills'), { overwrite: true });
47
- }
48
- if (await fs.pathExists(customSkills)) {
49
- await fs.copy(customSkills, path.join(newVersionDir, 'skills'), { overwrite: true });
50
- }
51
-
52
- // Copy rules: common first, then language-specific overlay (mirrors init.js logic)
53
- const rulesTarget = path.join(newVersionDir, 'rules');
54
- const commonRules = path.join(PKG_DIR, 'custom', 'rules', 'common');
55
- const allRules = path.join(PKG_DIR, 'custom', 'rules');
56
- const primaryFramework = (state.frameworks || (state.framework ? [state.framework] : []))[0] || null;
57
-
58
- await fs.ensureDir(rulesTarget);
59
- if (await fs.pathExists(commonRules)) {
60
- await fs.copy(commonRules, rulesTarget, { overwrite: true });
61
- } else if (await fs.pathExists(allRules)) {
62
- const entries = await fs.readdir(allRules, { withFileTypes: true });
63
- for (const entry of entries) {
64
- if (entry.isFile() && entry.name.endsWith('.md')) {
65
- await fs.copy(path.join(allRules, entry.name), path.join(rulesTarget, entry.name), { overwrite: true });
66
- }
67
- }
68
- }
69
-
70
- if (primaryFramework) {
71
- const lang = FRAMEWORK_LANGUAGE[primaryFramework];
72
- if (lang) {
73
- const langRules = path.join(PKG_DIR, 'custom', 'rules', lang);
74
- if (await fs.pathExists(langRules)) {
75
- await fs.copy(langRules, rulesTarget, { overwrite: true });
76
- console.log(chalk.gray(` ✓ Applied ${lang} rules`));
77
- }
78
- }
79
- }
80
-
81
- console.log(chalk.green(`✓ Downloaded assets for v${PKG_VERSION} into the project.`));
82
-
83
- // Only offer to delete old version when it's a different version.
84
- // When --force re-copies the same version, old === new === newVersionDir,
85
- // so deleting "old" would immediately break the copy step below.
86
- const isSameVersion = currentVersion === PKG_VERSION;
87
- if (!isSameVersion) {
88
- const deleteOld = await confirm({ message: `Do you want to delete the old version (v${currentVersion})?` });
89
- if (deleteOld) {
90
- await fs.remove(path.join(aiflowDir, 'versions', currentVersion));
91
- console.log(chalk.gray(`Deleted v${currentVersion}.`));
92
- } else {
93
- console.log(chalk.gray(`Kept v${currentVersion}. You can switch back using 'aiflow use ${currentVersion}'.`));
94
- }
95
- }
96
-
97
- // Switch to new version — copy skills without wiping the whole .claude dir
98
- // (wiping would destroy settings.json which holds the hooks configuration)
99
- const claudeDir = path.join(projectDir, '.claude');
100
- const claudeSkillsDir = path.join(claudeDir, 'skills');
101
- await fs.emptyDir(claudeSkillsDir);
102
- await fs.copy(path.join(newVersionDir, 'skills'), claudeSkillsDir, { overwrite: true });
103
-
104
- const rulesDir = path.join(projectDir, '.rules');
105
- await fs.emptyDir(rulesDir);
106
- await fs.copy(path.join(newVersionDir, 'rules'), rulesDir, { overwrite: true });
107
-
108
- state.current_version = PKG_VERSION;
109
- await fs.writeJson(stateFile, state);
110
-
111
- // Sync instruction files with the updated skills.
112
- // Support both old 'framework' (singular string) and new 'frameworks' (array).
113
- const { setupFramework, AI_TOOL_FILES, ensureAiflowGitignored } = require('./init');
114
- const frameworks = state.frameworks || (state.framework ? [state.framework] : []);
115
- const selectedTools = state.aiTools || Object.keys(AI_TOOL_FILES);
116
- for (const fw of frameworks) {
117
- await setupFramework(projectDir, fw, frameworks.length > 1, selectedTools, { force: true });
118
- }
119
-
120
- // Ensure all aiflow files are gitignored (especially for projects upgrading from older versions)
121
- await ensureAiflowGitignored(projectDir);
122
-
123
- console.log(chalk.green(`\n✨ Update completed! Your project is now on v${PKG_VERSION}.`));
124
- };
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+ const chalk = require('chalk');
4
+ const { confirm, select } = require('@inquirer/prompts');
5
+
6
+ const PKG_DIR = path.join(__dirname, '..');
7
+ const PKG_VERSION = require('../package.json').version;
8
+
9
+ // Same language map as init.js
10
+ const FRAMEWORK_LANGUAGE = {
11
+ 'laravel': 'php',
12
+ 'spring-boot': 'java',
13
+ 'reactjs': 'javascript',
14
+ 'nextjs': 'javascript',
15
+ 'vue-nuxt': 'javascript',
16
+ };
17
+
18
+ module.exports = async function update(options = {}) {
19
+ const projectDir = process.cwd();
20
+ const aiflowDir = path.join(projectDir, '.aiflow');
21
+ const stateFile = path.join(aiflowDir, 'state.json');
22
+
23
+ if (!(await fs.pathExists(stateFile))) {
24
+ console.log(chalk.red('Project is not initialized. Please run `aiflow init` first.'));
25
+ return;
26
+ }
27
+
28
+ const state = await fs.readJson(stateFile);
29
+ const currentVersion = state.current_version;
30
+
31
+ if (currentVersion === PKG_VERSION && !options.force) {
32
+ console.log(chalk.cyan(`You are already on v${PKG_VERSION}. Syncing latest assets and instruction files...`));
33
+ } else {
34
+ console.log(chalk.blue(`Updating from v${currentVersion} to v${PKG_VERSION}...`));
35
+ }
36
+
37
+ const newVersionDir = path.join(aiflowDir, 'versions', PKG_VERSION);
38
+ await fs.ensureDir(newVersionDir);
39
+
40
+ // Merge skills
41
+ const upstreamSkills = path.join(PKG_DIR, 'upstream', 'skills');
42
+ const customSkills = path.join(PKG_DIR, 'custom', 'skills');
43
+
44
+ await fs.ensureDir(path.join(newVersionDir, 'skills'));
45
+ if (await fs.pathExists(upstreamSkills)) {
46
+ await fs.copy(upstreamSkills, path.join(newVersionDir, 'skills'), { overwrite: true });
47
+ }
48
+ if (await fs.pathExists(customSkills)) {
49
+ await fs.copy(customSkills, path.join(newVersionDir, 'skills'), { overwrite: true });
50
+ }
51
+
52
+ // Copy rules: common first, then language-specific overlay (mirrors init.js logic)
53
+ const rulesTarget = path.join(newVersionDir, 'rules');
54
+ const commonRules = path.join(PKG_DIR, 'custom', 'rules', 'common');
55
+ const allRules = path.join(PKG_DIR, 'custom', 'rules');
56
+ const primaryFramework = (state.frameworks || (state.framework ? [state.framework] : []))[0] || null;
57
+
58
+ await fs.ensureDir(rulesTarget);
59
+ if (await fs.pathExists(commonRules)) {
60
+ await fs.copy(commonRules, rulesTarget, { overwrite: true });
61
+ } else if (await fs.pathExists(allRules)) {
62
+ const entries = await fs.readdir(allRules, { withFileTypes: true });
63
+ for (const entry of entries) {
64
+ if (entry.isFile() && entry.name.endsWith('.md')) {
65
+ await fs.copy(path.join(allRules, entry.name), path.join(rulesTarget, entry.name), { overwrite: true });
66
+ }
67
+ }
68
+ }
69
+
70
+ if (primaryFramework) {
71
+ const lang = FRAMEWORK_LANGUAGE[primaryFramework];
72
+ if (lang) {
73
+ const langRules = path.join(PKG_DIR, 'custom', 'rules', lang);
74
+ if (await fs.pathExists(langRules)) {
75
+ await fs.copy(langRules, rulesTarget, { overwrite: true });
76
+ console.log(chalk.gray(` ✓ Applied ${lang} rules`));
77
+ }
78
+ }
79
+ }
80
+
81
+ console.log(chalk.green(`✓ Downloaded assets for v${PKG_VERSION} into the project.`));
82
+
83
+ // Only offer to delete old version when it's a different version.
84
+ // When --force re-copies the same version, old === new === newVersionDir,
85
+ // so deleting "old" would immediately break the copy step below.
86
+ const isSameVersion = currentVersion === PKG_VERSION;
87
+ if (!isSameVersion) {
88
+ const deleteOld = await confirm({ message: `Do you want to delete the old version (v${currentVersion})?` });
89
+ if (deleteOld) {
90
+ await fs.remove(path.join(aiflowDir, 'versions', currentVersion));
91
+ console.log(chalk.gray(`Deleted v${currentVersion}.`));
92
+ } else {
93
+ console.log(chalk.gray(`Kept v${currentVersion}. You can switch back using 'aiflow use ${currentVersion}'.`));
94
+ }
95
+ }
96
+
97
+ // Switch to new version — copy skills without wiping the whole .claude dir
98
+ // (wiping would destroy settings.json which holds the hooks configuration)
99
+ const claudeDir = path.join(projectDir, '.claude');
100
+ const claudeSkillsDir = path.join(claudeDir, 'skills');
101
+ await fs.emptyDir(claudeSkillsDir);
102
+ await fs.copy(path.join(newVersionDir, 'skills'), claudeSkillsDir, { overwrite: true });
103
+
104
+ const rulesDir = path.join(projectDir, '.rules');
105
+ await fs.emptyDir(rulesDir);
106
+ await fs.copy(path.join(newVersionDir, 'rules'), rulesDir, { overwrite: true });
107
+
108
+ state.current_version = PKG_VERSION;
109
+ await fs.writeJson(stateFile, state);
110
+
111
+ // Sync instruction files with the updated skills.
112
+ // Support both old 'framework' (singular string) and new 'frameworks' (array).
113
+ const { setupFramework, AI_TOOL_FILES, ensureAiflowGitignored } = require('./init');
114
+ const frameworks = state.frameworks || (state.framework ? [state.framework] : []);
115
+ const selectedTools = state.aiTools || Object.keys(AI_TOOL_FILES);
116
+ for (const fw of frameworks) {
117
+ await setupFramework(projectDir, fw, frameworks.length > 1, selectedTools, { force: true });
118
+ }
119
+
120
+ // Ensure all aiflow files are gitignored (especially for projects upgrading from older versions)
121
+ await ensureAiflowGitignored(projectDir);
122
+
123
+ console.log(chalk.green(`\n✨ Update completed! Your project is now on v${PKG_VERSION}.`));
124
+ };
package/scripts/use.js CHANGED
@@ -5,6 +5,18 @@ const chalk = require("chalk");
5
5
  const https = require("https");
6
6
  const { select, input } = require("@inquirer/prompts");
7
7
 
8
+ const stringWidth = require("string-width");
9
+ const CATEGORY_COLOR = {
10
+ Coding: chalk.cyan,
11
+ Testing: chalk.green,
12
+ Analysis: chalk.yellow,
13
+ Document: chalk.magenta,
14
+ };
15
+ const td = (label, cat, desc) => {
16
+ const pad = " ".repeat(Math.max(0, 20 - stringWidth(label)));
17
+ return label + pad + CATEGORY_COLOR[cat](cat.padEnd(10)) + chalk.dim(desc);
18
+ };
19
+
8
20
  const PROJECT_DIR = process.cwd();
9
21
  const AIFLOW_DIR = path.join(PROJECT_DIR, ".aiflow");
10
22
  const STATE_FILE = path.join(AIFLOW_DIR, "state.json");
@@ -613,12 +625,14 @@ async function promptForTaskType(detectedDefault) {
613
625
  return await select({
614
626
  message: "Task type:",
615
627
  choices: [
616
- { name: "🐛 Bug Fix", value: "bug-fix" },
617
- { name: "✨ Feature", value: "feature" },
618
- { name: "🔍 Investigation", value: "investigation" },
619
- { name: "♻️ Refactor", value: "refactor" },
620
- { name: "📊 Impact Analysis", value: "impact-analysis" },
621
- { name: "📖 Documentation", value: "documentation" },
628
+ { name: td("🐛 Bug Fix", "Coding", "Fix bugs, crashes, regressions"), value: "bug-fix" },
629
+ { name: td("✨ Feature", "Coding", "Build new features, user stories"), value: "feature" },
630
+ { name: td("🔄 Refactor", "Coding", "Improve code without behavior change"), value: "refactor" },
631
+ { name: td("🔬 Testing", "Testing", "Write tests, QA, coverage"), value: "testing" },
632
+ { name: td("▶️ Execute Test", "Testing", "Run existing TC scripts (4-gate flow)"), value: "execute" },
633
+ { name: td("🔍 Investigation", "Analysis", "Investigate, analyze root cause"), value: "investigation" },
634
+ { name: td("📊 Impact Analysis", "Analysis", "Assess scope and risk of changes"), value: "impact-analysis" },
635
+ { name: td("📖 Documentation", "Document", "Write docs, README, API reference"), value: "documentation" },
622
636
  ],
623
637
  default: detectedDefault || "feature",
624
638
  });
@@ -683,12 +697,14 @@ async function manualContext(prefillId = "") {
683
697
  const taskType = await select({
684
698
  message: "Task type:",
685
699
  choices: [
686
- { name: "🐛 Bug Fix", value: "bug-fix" },
687
- { name: "✨ Feature", value: "feature" },
688
- { name: "🔍 Investigation", value: "investigation" },
689
- { name: "♻️ Refactor", value: "refactor" },
690
- { name: "📊 Impact Analysis", value: "impact-analysis" },
691
- { name: "📖 Documentation", value: "documentation" },
700
+ { name: td("🐛 Bug Fix", "Coding", "Fix bugs, crashes, regressions"), value: "bug-fix" },
701
+ { name: td("✨ Feature", "Coding", "Build new features, user stories"), value: "feature" },
702
+ { name: td("🔄 Refactor", "Coding", "Improve code without behavior change"), value: "refactor" },
703
+ { name: td("🔬 Testing", "Testing", "Write tests, QA, coverage"), value: "testing" },
704
+ { name: td("▶️ Execute Test", "Testing", "Run existing TC scripts (4-gate flow)"), value: "execute" },
705
+ { name: td("🔍 Investigation", "Analysis", "Investigate, analyze root cause"), value: "investigation" },
706
+ { name: td("📊 Impact Analysis", "Analysis", "Assess scope and risk of changes"), value: "impact-analysis" },
707
+ { name: td("📖 Documentation", "Document", "Write docs, README, API reference"), value: "documentation" },
692
708
  ],
693
709
  default: existing.taskType || undefined,
694
710
  });
@@ -939,6 +955,8 @@ function detectTaskTypeFromString(text) {
939
955
  return "feature";
940
956
  if (["research", "investigation", "調査"].some((k) => lower.includes(k)))
941
957
  return "investigation";
958
+ if (["test", "testing", "qa", "quality", "coverage", "テスト"].some((k) => lower.includes(k)))
959
+ return "testing";
942
960
  return "bug-fix"; // default for unknown
943
961
  }
944
962