ai-scaffold-pro 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+
3
+ import chalk from 'chalk';
4
+ import { execSync } from 'child_process';
5
+ import { detectProject } from '../src/detect.js';
6
+ import { promptConfig } from '../src/prompts.js';
7
+ import { renderTemplates } from '../src/render.js';
8
+ import path from 'path';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+ const TEMPLATE_ROOT = path.resolve(__dirname, '../templates');
13
+
14
+ async function main() {
15
+ console.log(chalk.cyan.bold('\n AI Coding Skeleton — ai-scaffold\n'));
16
+
17
+ const targetDir = process.argv[2] || process.cwd();
18
+ console.log(chalk.gray(` Target directory: ${targetDir}\n`));
19
+
20
+ // Phase 0: Language + AI tool selection
21
+ // Phase 1: Project detection
22
+ console.log(chalk.yellow(' Detecting project...'));
23
+ const detection = await detectProject(targetDir);
24
+ console.log(chalk.green(` Platform: ${detection.platform} / ${detection.buildSystem}`));
25
+ if (detection.hasNdk) {
26
+ console.log(chalk.green(' NDK/C++: detected'));
27
+ }
28
+ console.log();
29
+
30
+ // Phase 0 + Phase 2: Interactive configuration
31
+ const config = await promptConfig(detection);
32
+
33
+ // Phase 3: Generate files
34
+ console.log(chalk.yellow('\n Generating files...\n'));
35
+ await renderTemplates(TEMPLATE_ROOT, targetDir, config, detection);
36
+
37
+ // Summary
38
+ const dir = config.dir;
39
+ const entry = config.entry;
40
+ const isZh = config.lang === 'zh';
41
+ const langLabel = config.lang === 'en' ? 'English' : '中文';
42
+ console.log(chalk.cyan.bold(`\n ${config.target.toUpperCase()} system initialized\n`));
43
+ console.log(chalk.white(` Language: ${langLabel}`));
44
+ console.log(chalk.white(` Entry file: ${entry}`));
45
+ console.log(chalk.white(` Config dir: ${dir}/`));
46
+
47
+ console.log('');
48
+ console.log(chalk.cyan(isZh ? '📋 下一步操作:' : '📋 Next Steps:'));
49
+ console.log('');
50
+ if (config.hasCodeGraph) {
51
+ console.log(chalk.white(isZh
52
+ ? ` 1. [必做] 运行 python ${dir}/scripts/gen_references.py --lightweight 生成轻量参考文档`
53
+ : ` 1. [Required] Run python ${dir}/scripts/gen_references.py --lightweight to generate lightweight references`));
54
+ } else {
55
+ console.log(chalk.white(isZh
56
+ ? ` 1. [必做] 运行 python ${dir}/scripts/gen_references.py 生成项目参考文档`
57
+ : ` 1. [Required] Run python ${dir}/scripts/gen_references.py to generate project references`));
58
+ }
59
+ console.log(chalk.white(isZh
60
+ ? ` 2. [必做] 检查 ${dir}/rules/project_rule.md 中的架构约束是否符合项目实际`
61
+ : ` 2. [Required] Review ${dir}/rules/project_rule.md to verify architecture constraints match your project`));
62
+ console.log(chalk.white(isZh
63
+ ? ` 3. [可选] 调整 ${dir}/agents/ 中各 Agent 的检查规则`
64
+ : ` 3. [Optional] Adjust check rules in ${dir}/agents/`));
65
+ console.log(chalk.white(isZh
66
+ ? ` 4. [可选] 修改 ${dir}/skills/ 中的审查标准`
67
+ : ` 4. [Optional] Modify review standards in ${dir}/skills/`));
68
+ console.log('');
69
+ console.log(chalk.gray(isZh
70
+ ? ' 预计补充时间:5-10 分钟'
71
+ : ' Estimated setup time: 5-10 minutes'));
72
+ console.log(chalk.gray(isZh
73
+ ? ' 验证方式:让 AI 阅读生成的规则文件并确认无冲突'
74
+ : ' Verification: Ask the AI to read the generated rules and confirm no conflicts'));
75
+ console.log('');
76
+ }
77
+
78
+ main().catch(err => {
79
+ console.error(chalk.red('Error:'), err.message);
80
+ process.exit(1);
81
+ });
82
+
83
+ main().catch(err => {
84
+ console.error(chalk.red('Error:'), err.message);
85
+ process.exit(1);
86
+ });
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ # Stop hook: checks if code_review is needed after code modifications
3
+ # Template file from ai_scaffold_skill — replace {{DIR}} and {{REVIEW_FILE_THRESHOLD}} for target project
4
+
5
+ stdin=$(cat)
6
+ session_id=$(echo "$stdin" | grep -o '"session_id":"[^"]*"' | head -1 | sed 's/"session_id":"//;s/"//')
7
+
8
+ # session_id 有效性检查
9
+ if [[ -z "$session_id" ]]; then
10
+ exit 0
11
+ fi
12
+
13
+ track_file="/tmp/{{DIR}}edits_${session_id}.txt"
14
+
15
+ if [ -f "$track_file" ]; then
16
+ file_count=$(sort -u "$track_file" | wc -l | tr -d ' ')
17
+ rm -f "$track_file"
18
+ # 确保 file_count 是有效数字
19
+ if ! [[ "$file_count" =~ ^[0-9]+$ ]]; then
20
+ exit 0
21
+ fi
22
+ if [ "$file_count" -ge {{REVIEW_FILE_THRESHOLD}} ]; then
23
+ echo "[强制规则] 检测到 ${file_count} 个源码文件被修改,请确认是否已触发 code_review 技能。如已审查则忽略此提醒。" >&2
24
+ exit 2
25
+ fi
26
+ fi
27
+
28
+ exit 0
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+ # PostToolUse hook: tracks edited code files for review reminder
3
+ # Template file from ai_scaffold_skill — replace {{DIR}} and {{SOURCE_EXTENSIONS}} for target project
4
+ # Default extensions: Java/Kotlin/XML/Gradle + C/C++/NDK (cpp|h|c|mk|cmake)
5
+ # For non-NDK projects, remove the C/C++/NDK extensions when replacing {{SOURCE_EXTENSIONS}}
6
+
7
+ stdin=$(cat)
8
+ file_path=$(echo "$stdin" | grep -o '"file_path":"[^"]*"' | head -1 | sed 's/"file_path":"//;s/"//')
9
+ session_id=$(echo "$stdin" | grep -o '"session_id":"[^"]*"' | head -1 | sed 's/"session_id":"//;s/"//')
10
+
11
+ # session_id 有效性检查
12
+ if [[ -z "$session_id" ]]; then
13
+ exit 0
14
+ fi
15
+
16
+ if [[ "$file_path" =~ \.(kt|java|xml|gradle|cpp|h|c|mk|cmake)$ ]]; then
17
+ track_file="/tmp/{{DIR}}edits_${session_id}.txt"
18
+ echo "$file_path" >> "$track_file"
19
+ fi
20
+
21
+ exit 0