pumuki-ast-hooks 5.5.37 → 5.5.38
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pumuki-ast-hooks",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.38",
|
|
4
4
|
"description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -95,6 +95,68 @@ function summarizeRulesContent(content) {
|
|
|
95
95
|
return firstLine.length > 0 ? firstLine : `loaded (${content.length} chars)`;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
function buildAutoContextFrontmatter(detectedPlatforms) {
|
|
99
|
+
const platforms = Array.isArray(detectedPlatforms) ? detectedPlatforms.filter(Boolean) : [];
|
|
100
|
+
const generated = formatLocalTimestamp();
|
|
101
|
+
const platformStr = platforms.length > 0 ? platforms.join(', ') : 'none';
|
|
102
|
+
return `---\nalwaysApply: true\ndescription: Auto-generated context for detected platforms\nplatforms: ${platformStr}\ngenerated: ${generated}\n---\n\n`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function buildAutoContextContent(platformsEvidence) {
|
|
106
|
+
const loader = new DynamicRulesLoader();
|
|
107
|
+
const detectedPlatforms = ['backend', 'frontend', 'ios', 'android']
|
|
108
|
+
.filter(p => platformsEvidence && platformsEvidence[p] && platformsEvidence[p].detected);
|
|
109
|
+
|
|
110
|
+
const files = ['rulesgold.mdc', ...detectedPlatforms.map(p => loader.rulesMap[p]).filter(Boolean)];
|
|
111
|
+
const uniqueFiles = Array.from(new Set(files));
|
|
112
|
+
|
|
113
|
+
let content = buildAutoContextFrontmatter(detectedPlatforms);
|
|
114
|
+
|
|
115
|
+
for (const file of uniqueFiles) {
|
|
116
|
+
let ruleContent = null;
|
|
117
|
+
try {
|
|
118
|
+
ruleContent = await loader.loadRule(file);
|
|
119
|
+
} catch {
|
|
120
|
+
ruleContent = null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
content += `## Source: ${file}\n\n`;
|
|
124
|
+
content += ruleContent ? `${ruleContent}\n\n` : `not found\n\n`;
|
|
125
|
+
content += `---\n\n`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return content;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function writeAutoContextFiles(platformsEvidence) {
|
|
132
|
+
try {
|
|
133
|
+
const pkgPath = path.join(process.cwd(), 'package.json');
|
|
134
|
+
if (fs.existsSync(pkgPath)) {
|
|
135
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
136
|
+
if (pkg && pkg.name === 'pumuki-ast-hooks') {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} catch (error) {
|
|
141
|
+
process.stderr.write(`[Intelligent Audit] ⚠️ Failed to inspect package.json for auto-context skip logic (${toErrorMessage(error)})\n`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const content = await buildAutoContextContent(platformsEvidence);
|
|
145
|
+
const targets = [
|
|
146
|
+
path.join(process.cwd(), '.cursor', 'rules', 'auto-context.mdc'),
|
|
147
|
+
path.join(process.cwd(), '.windsurf', 'rules', 'auto-context.mdc')
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
for (const target of targets) {
|
|
151
|
+
try {
|
|
152
|
+
await fs.promises.mkdir(path.dirname(target), { recursive: true });
|
|
153
|
+
await fs.promises.writeFile(target, content, 'utf-8');
|
|
154
|
+
} catch (error) {
|
|
155
|
+
process.stderr.write(`[Intelligent Audit] ⚠️ Failed to write auto-context: ${target} (${toErrorMessage(error)})\n`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
98
160
|
async function buildRulesReadEvidence(platformsEvidence) {
|
|
99
161
|
const loader = new DynamicRulesLoader();
|
|
100
162
|
const entries = [];
|
|
@@ -440,6 +502,8 @@ async function updateAIEvidence(violations, gateResult, tokenUsage) {
|
|
|
440
502
|
const platformsEvidence = buildPlatformsEvidence(stagedFiles, violations);
|
|
441
503
|
const rulesRead = await buildRulesReadEvidence(platformsEvidence);
|
|
442
504
|
|
|
505
|
+
await writeAutoContextFiles(platformsEvidence);
|
|
506
|
+
|
|
443
507
|
evidence.rules_read = rulesRead.entries;
|
|
444
508
|
evidence.rules_read_flags = rulesRead.legacyFlags;
|
|
445
509
|
|