tribunal-kit 4.3.0 → 4.3.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/.agent/scripts/case_law_manager.js +684 -684
- package/.agent/scripts/graph_builder.js +199 -0
- package/.agent/scripts/graph_zoom.js +154 -0
- package/.agent/skills/agent-organizer/SKILL.md +9 -1
- package/.agent/skills/agentic-patterns/SKILL.md +9 -1
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +9 -1
- package/.agent/skills/api-patterns/SKILL.md +206 -198
- package/.agent/skills/api-security-auditor/SKILL.md +9 -1
- package/.agent/skills/app-builder/SKILL.md +9 -1
- package/.agent/skills/app-builder/templates/SKILL.md +77 -69
- package/.agent/skills/appflow-wireframe/SKILL.md +9 -1
- package/.agent/skills/architecture/SKILL.md +9 -1
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -1
- package/.agent/skills/bash-linux/SKILL.md +9 -1
- package/.agent/skills/behavioral-modes/SKILL.md +9 -1
- package/.agent/skills/brainstorming/SKILL.md +9 -1
- package/.agent/skills/building-native-ui/SKILL.md +9 -1
- package/.agent/skills/clean-code/SKILL.md +9 -1
- package/.agent/skills/code-review-checklist/SKILL.md +9 -1
- package/.agent/skills/config-validator/SKILL.md +9 -1
- package/.agent/skills/csharp-developer/SKILL.md +9 -1
- package/.agent/skills/data-validation-schemas/SKILL.md +287 -279
- package/.agent/skills/database-design/SKILL.md +199 -191
- package/.agent/skills/deployment-procedures/SKILL.md +9 -1
- package/.agent/skills/devops-engineer/SKILL.md +9 -1
- package/.agent/skills/devops-incident-responder/SKILL.md +9 -1
- package/.agent/skills/documentation-templates/SKILL.md +9 -1
- package/.agent/skills/edge-computing/SKILL.md +9 -1
- package/.agent/skills/error-resilience/SKILL.md +387 -379
- package/.agent/skills/extract-design-system/SKILL.md +9 -1
- package/.agent/skills/framer-motion-expert/SKILL.md +203 -195
- package/.agent/skills/frontend-design/SKILL.md +160 -152
- package/.agent/skills/game-design-expert/SKILL.md +9 -1
- package/.agent/skills/game-engineering-expert/SKILL.md +9 -1
- package/.agent/skills/geo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/github-operations/SKILL.md +9 -1
- package/.agent/skills/gsap-core/SKILL.md +54 -46
- package/.agent/skills/gsap-frameworks/SKILL.md +54 -46
- package/.agent/skills/gsap-performance/SKILL.md +54 -46
- package/.agent/skills/gsap-plugins/SKILL.md +54 -46
- package/.agent/skills/gsap-react/SKILL.md +54 -46
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -46
- package/.agent/skills/gsap-timeline/SKILL.md +54 -46
- package/.agent/skills/gsap-utils/SKILL.md +54 -46
- package/.agent/skills/i18n-localization/SKILL.md +9 -1
- package/.agent/skills/intelligent-routing/SKILL.md +38 -30
- package/.agent/skills/knowledge-graph/SKILL.md +36 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -1
- package/.agent/skills/llm-engineering/SKILL.md +9 -1
- package/.agent/skills/local-first/SKILL.md +9 -1
- package/.agent/skills/mcp-builder/SKILL.md +9 -1
- package/.agent/skills/mobile-design/SKILL.md +222 -214
- package/.agent/skills/monorepo-management/SKILL.md +293 -285
- package/.agent/skills/motion-engineering/SKILL.md +193 -185
- package/.agent/skills/nextjs-react-expert/SKILL.md +193 -185
- package/.agent/skills/nodejs-best-practices/SKILL.md +9 -1
- package/.agent/skills/observability/SKILL.md +9 -1
- package/.agent/skills/parallel-agents/SKILL.md +9 -1
- package/.agent/skills/performance-profiling/SKILL.md +9 -1
- package/.agent/skills/plan-writing/SKILL.md +9 -1
- package/.agent/skills/platform-engineer/SKILL.md +9 -1
- package/.agent/skills/playwright-best-practices/SKILL.md +9 -1
- package/.agent/skills/powershell-windows/SKILL.md +9 -1
- package/.agent/skills/project-idioms/SKILL.md +9 -1
- package/.agent/skills/python-patterns/SKILL.md +9 -1
- package/.agent/skills/python-pro/SKILL.md +282 -274
- package/.agent/skills/react-specialist/SKILL.md +236 -228
- package/.agent/skills/readme-builder/SKILL.md +9 -1
- package/.agent/skills/realtime-patterns/SKILL.md +9 -1
- package/.agent/skills/red-team-tactics/SKILL.md +9 -1
- package/.agent/skills/rust-pro/SKILL.md +9 -1
- package/.agent/skills/seo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/server-management/SKILL.md +9 -1
- package/.agent/skills/shadcn-ui-expert/SKILL.md +9 -1
- package/.agent/skills/skill-creator/SKILL.md +9 -1
- package/.agent/skills/sql-pro/SKILL.md +9 -1
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +9 -1
- package/.agent/skills/swiftui-expert/SKILL.md +9 -1
- package/.agent/skills/systematic-debugging/SKILL.md +9 -1
- package/.agent/skills/tailwind-patterns/SKILL.md +9 -1
- package/.agent/skills/tdd-workflow/SKILL.md +9 -1
- package/.agent/skills/test-result-analyzer/SKILL.md +9 -1
- package/.agent/skills/testing-patterns/SKILL.md +9 -1
- package/.agent/skills/trend-researcher/SKILL.md +9 -1
- package/.agent/skills/typescript-advanced/SKILL.md +294 -286
- package/.agent/skills/ui-ux-pro-max/SKILL.md +9 -1
- package/.agent/skills/ui-ux-researcher/SKILL.md +9 -1
- package/.agent/skills/vue-expert/SKILL.md +234 -226
- package/.agent/skills/vulnerability-scanner/SKILL.md +9 -1
- package/.agent/skills/web-accessibility-auditor/SKILL.md +9 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +9 -1
- package/.agent/skills/webapp-testing/SKILL.md +9 -1
- package/.agent/skills/whimsy-injector/SKILL.md +9 -1
- package/.agent/skills/workflow-optimizer/SKILL.md +9 -1
- package/README.md +242 -242
- package/bin/tribunal-kit.js +30 -22
- package/package.json +81 -80
- package/scripts/validate-payload.js +73 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* graph_builder.js — Tribunal Kit Macro Graph Mapper
|
|
4
|
+
* Parses project structure for imports, exports, and dependencies
|
|
5
|
+
* using incremental caching and zero external dependencies.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
const AGENT_DIR = path.join(process.cwd(), '.agent');
|
|
14
|
+
const HISTORY_DIR = path.join(AGENT_DIR, 'history');
|
|
15
|
+
const CACHE_FILE = path.join(HISTORY_DIR, 'graph-cache.json');
|
|
16
|
+
const GRAPH_FILE = path.join(HISTORY_DIR, 'architecture-graph.yaml');
|
|
17
|
+
|
|
18
|
+
// ── Exclusions & Safety ───────────────────────────────────────────────────────
|
|
19
|
+
const DEFAULT_EXCLUSIONS = new Set([
|
|
20
|
+
'node_modules', '.git', '.next', 'dist', 'build', 'coverage', '.agent', 'artifacts'
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
function loadGitIgnore() {
|
|
24
|
+
const gitignorePath = path.join(process.cwd(), '.gitignore');
|
|
25
|
+
if (!fs.existsSync(gitignorePath)) return [];
|
|
26
|
+
|
|
27
|
+
return fs.readFileSync(gitignorePath, 'utf8')
|
|
28
|
+
.split('\n')
|
|
29
|
+
.map(line => line.trim())
|
|
30
|
+
.filter(line => line && !line.startsWith('#'))
|
|
31
|
+
// simplistic conversion from gitignore line to path check
|
|
32
|
+
.map(line => line.replace(/\/$/, '').replace(/^\//, ''));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const customExclusions = loadGitIgnore();
|
|
36
|
+
|
|
37
|
+
function isExcluded(filePath) {
|
|
38
|
+
const parts = filePath.split(path.sep);
|
|
39
|
+
|
|
40
|
+
// 1. Check against critical defaults (OOM prevention)
|
|
41
|
+
if (parts.some(p => DEFAULT_EXCLUSIONS.has(p))) return true;
|
|
42
|
+
|
|
43
|
+
// 2. Check against .gitignore rules
|
|
44
|
+
const relativePath = path.relative(process.cwd(), filePath).replace(/\\/g, '/');
|
|
45
|
+
for (const pattern of customExclusions) {
|
|
46
|
+
if (relativePath.includes(pattern)) return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ── Traversal ─────────────────────────────────────────────────────────────────
|
|
52
|
+
function walkDir(dir, fileList = []) {
|
|
53
|
+
if (!fs.existsSync(dir) || isExcluded(dir)) return fileList;
|
|
54
|
+
|
|
55
|
+
let files;
|
|
56
|
+
try {
|
|
57
|
+
files = fs.readdirSync(dir);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
return fileList; // Permission denied or similar
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
const filePath = path.join(dir, file);
|
|
64
|
+
if (isExcluded(filePath)) continue;
|
|
65
|
+
|
|
66
|
+
if (fs.statSync(filePath).isDirectory()) {
|
|
67
|
+
walkDir(filePath, fileList);
|
|
68
|
+
} else {
|
|
69
|
+
// Target standard JS/TS ecosystem files
|
|
70
|
+
if (/\.(js|jsx|ts|tsx|mjs|cjs)$/.test(file)) {
|
|
71
|
+
fileList.push(filePath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return fileList;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ── Regex AST Extraction ──────────────────────────────────────────────────────
|
|
79
|
+
function parseFile(content) {
|
|
80
|
+
const imports = new Set();
|
|
81
|
+
const exports = new Set();
|
|
82
|
+
|
|
83
|
+
// Strip comments to prevent false positives in regex
|
|
84
|
+
const cleanContent = content.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
85
|
+
|
|
86
|
+
// Import extractors
|
|
87
|
+
const importRegex = /import(?:(?:[\w*\s{},]*)\sfrom\s+)?['"]([^'"]+)['"]/g;
|
|
88
|
+
const requireRegex = /require\(['"]([^'"]+)['"]\)/g;
|
|
89
|
+
const dynamicImportRegex = /import\(['"]([^'"]+)['"]\)/g;
|
|
90
|
+
|
|
91
|
+
// Export extractors
|
|
92
|
+
const exportRegex = /export\s+(?:const|let|var|function|class)\s+([a-zA-Z0-9_]+)/g;
|
|
93
|
+
const moduleExportRegex = /module\.exports\s*=\s*\{([^}]+)\}/g;
|
|
94
|
+
const defaultExportRegex = /export\s+default\s+([a-zA-Z0-9_]+)/g;
|
|
95
|
+
|
|
96
|
+
let match;
|
|
97
|
+
while ((match = importRegex.exec(cleanContent)) !== null) imports.add(match[1]);
|
|
98
|
+
while ((match = requireRegex.exec(cleanContent)) !== null) imports.add(match[1]);
|
|
99
|
+
while ((match = dynamicImportRegex.exec(cleanContent)) !== null) imports.add(match[1]);
|
|
100
|
+
|
|
101
|
+
while ((match = exportRegex.exec(cleanContent)) !== null) exports.add(match[1]);
|
|
102
|
+
while ((match = defaultExportRegex.exec(cleanContent)) !== null) exports.add(match[1]);
|
|
103
|
+
|
|
104
|
+
// Extractor for module.exports = { a, b, c }
|
|
105
|
+
while ((match = moduleExportRegex.exec(cleanContent)) !== null) {
|
|
106
|
+
const tokens = match[1].split(',').map(s => s.trim().split(':')[0].trim());
|
|
107
|
+
tokens.forEach(t => t && exports.add(t));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
imports: Array.from(imports),
|
|
112
|
+
exports: Array.from(exports)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ── YAML Generation ───────────────────────────────────────────────────────────
|
|
117
|
+
function generateYAML(data) {
|
|
118
|
+
let yaml = '# Auto-generated Architecture Graph by Tribunal Kit\n';
|
|
119
|
+
yaml += '# DO NOT EDIT MANUALLY - Auto-updates via incremental cache\n\n';
|
|
120
|
+
|
|
121
|
+
for (const [file, info] of Object.entries(data)) {
|
|
122
|
+
// Only include files that actually export or import things to reduce noise
|
|
123
|
+
if (info.imports.length === 0 && info.exports.length === 0) continue;
|
|
124
|
+
|
|
125
|
+
yaml += `"${file}":\n`;
|
|
126
|
+
if (info.imports && info.imports.length > 0) {
|
|
127
|
+
yaml += ` imports:\n`;
|
|
128
|
+
info.imports.forEach(i => yaml += ` - "${i}"\n`);
|
|
129
|
+
}
|
|
130
|
+
if (info.exports && info.exports.length > 0) {
|
|
131
|
+
yaml += ` exports:\n`;
|
|
132
|
+
info.exports.forEach(e => yaml += ` - "${e}"\n`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return yaml;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ── Main Execution ────────────────────────────────────────────────────────────
|
|
139
|
+
function main() {
|
|
140
|
+
if (!fs.existsSync(AGENT_DIR)) {
|
|
141
|
+
console.error('\x1b[31m✖ Error: .agent directory not found. Please run tribunal-kit init first.\x1b[0m');
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!fs.existsSync(HISTORY_DIR)) {
|
|
146
|
+
fs.mkdirSync(HISTORY_DIR, { recursive: true });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 1. Load incremental cache
|
|
150
|
+
let cache = {};
|
|
151
|
+
if (fs.existsSync(CACHE_FILE)) {
|
|
152
|
+
try { cache = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8')); } catch(e) {}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
console.log('\x1b[96m✦ Building Architecture Graph...\x1b[0m');
|
|
156
|
+
const files = walkDir(process.cwd());
|
|
157
|
+
const graphData = {};
|
|
158
|
+
|
|
159
|
+
let parsedCount = 0;
|
|
160
|
+
let cachedCount = 0;
|
|
161
|
+
|
|
162
|
+
// 2. Parse or hit cache
|
|
163
|
+
for (const file of files) {
|
|
164
|
+
const stat = fs.statSync(file);
|
|
165
|
+
const relativePath = path.relative(process.cwd(), file).replace(/\\/g, '/');
|
|
166
|
+
|
|
167
|
+
if (cache[relativePath] && cache[relativePath].mtimeMs === stat.mtimeMs) {
|
|
168
|
+
graphData[relativePath] = { imports: cache[relativePath].imports, exports: cache[relativePath].exports };
|
|
169
|
+
cachedCount++;
|
|
170
|
+
} else {
|
|
171
|
+
try {
|
|
172
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
173
|
+
const parsed = parseFile(content);
|
|
174
|
+
graphData[relativePath] = parsed;
|
|
175
|
+
|
|
176
|
+
cache[relativePath] = {
|
|
177
|
+
mtimeMs: stat.mtimeMs,
|
|
178
|
+
imports: parsed.imports,
|
|
179
|
+
exports: parsed.exports
|
|
180
|
+
};
|
|
181
|
+
parsedCount++;
|
|
182
|
+
} catch (err) {
|
|
183
|
+
// Graceful fallback on unreadable files
|
|
184
|
+
console.warn(`\x1b[33m ⚠ Skipping unreadable file: ${relativePath}\x1b[0m`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// 3. Save states
|
|
190
|
+
fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2));
|
|
191
|
+
const yamlOutput = generateYAML(graphData);
|
|
192
|
+
fs.writeFileSync(GRAPH_FILE, yamlOutput);
|
|
193
|
+
|
|
194
|
+
console.log(`\n\x1b[32m✔ Graph successfully built.\x1b[0m`);
|
|
195
|
+
console.log(` \x1b[2mParsed: ${parsedCount} files | Cached: ${cachedCount} files\x1b[0m`);
|
|
196
|
+
console.log(` \x1b[2mSaved to: ${GRAPH_FILE}\x1b[0m`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
main();
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* graph_zoom.js — Tribunal Kit Micro Zoomer
|
|
4
|
+
* Provides an "X-Ray" structural view of a specific file for AI agents,
|
|
5
|
+
* stripping out internal logic to save tokens and prevent context bloat.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
function getFlag(name) {
|
|
14
|
+
const idx = process.argv.indexOf(name);
|
|
15
|
+
return (idx !== -1 && process.argv[idx + 1]) ? process.argv[idx + 1] : null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const targetFile = getFlag('--focus');
|
|
19
|
+
|
|
20
|
+
if (!targetFile) {
|
|
21
|
+
console.error('\x1b[31m✖ Error: Provide a file to zoom into. Usage: node graph_zoom.js --focus <filepath>\x1b[0m');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const absolutePath = path.resolve(process.cwd(), targetFile);
|
|
26
|
+
|
|
27
|
+
if (!fs.existsSync(absolutePath)) {
|
|
28
|
+
console.error(`\x1b[31m✖ Error: File not found at ${absolutePath}\x1b[0m`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function extractSkeleton(content) {
|
|
33
|
+
const lines = content.split('\n');
|
|
34
|
+
const skeleton = [];
|
|
35
|
+
|
|
36
|
+
// State machine flags
|
|
37
|
+
let inClass = false;
|
|
38
|
+
let braceDepth = 0;
|
|
39
|
+
|
|
40
|
+
// ── Regex Matchers ──
|
|
41
|
+
const importRegex = /^import\s+.*$/;
|
|
42
|
+
const requireRegex = /^(?:const|let|var)\s+.*require\(.*$/;
|
|
43
|
+
const classRegex = /^(?:export\s+)?(?:default\s+)?class\s+(\w+)(?:\s+extends\s+[\w.]+)?/;
|
|
44
|
+
const functionRegex = /^(?:export\s+)?(?:default\s+)?(?:async\s+)?function\s+(\w*)\s*\(([^)]*)\)/;
|
|
45
|
+
const arrowFuncRegex = /^(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\(([^)]*)\)\s*=>/;
|
|
46
|
+
// Heuristic for React Components (starts with Capital letter)
|
|
47
|
+
const reactComponentRegex = /^(?:export\s+)?(?:const|let|var)\s+([A-Z]\w+)\s*=\s*(?:[^=;]+)?=>/;
|
|
48
|
+
const typeInterfaceRegex = /^(?:export\s+)?(?:type|interface)\s+(\w+)/;
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < lines.length; i++) {
|
|
51
|
+
const line = lines[i];
|
|
52
|
+
const trimmed = line.trim();
|
|
53
|
+
|
|
54
|
+
if (!trimmed) continue;
|
|
55
|
+
|
|
56
|
+
// Keep imports
|
|
57
|
+
if (importRegex.test(trimmed) || requireRegex.test(trimmed)) {
|
|
58
|
+
skeleton.push(line);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Keep types and interfaces
|
|
63
|
+
if (typeInterfaceRegex.test(trimmed)) {
|
|
64
|
+
skeleton.push(line + (trimmed.endsWith('{') ? ' /* ... */ }' : ''));
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Keep classes
|
|
69
|
+
const classMatch = classRegex.exec(trimmed);
|
|
70
|
+
if (classMatch) {
|
|
71
|
+
skeleton.push('\n' + line + (trimmed.endsWith('{') ? '' : ' {'));
|
|
72
|
+
inClass = true;
|
|
73
|
+
braceDepth = (trimmed.match(/\{/g) || []).length - (trimmed.match(/\}/g) || []).length;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Keep function signatures
|
|
78
|
+
const funcMatch = functionRegex.exec(trimmed);
|
|
79
|
+
if (funcMatch) {
|
|
80
|
+
skeleton.push('\n' + line + (trimmed.endsWith('{') ? ' /* logic stripped */ }' : ' { /* logic stripped */ }'));
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Keep arrow functions
|
|
85
|
+
const arrowMatch = arrowFuncRegex.exec(trimmed);
|
|
86
|
+
if (arrowMatch) {
|
|
87
|
+
skeleton.push('\n' + line + (trimmed.endsWith('{') ? ' /* logic stripped */ }' : ' { /* logic stripped */ }'));
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Keep React Components / Standard constants
|
|
92
|
+
const reactMatch = reactComponentRegex.exec(trimmed);
|
|
93
|
+
if (reactMatch && !arrowMatch) {
|
|
94
|
+
skeleton.push('\n' + line + (trimmed.endsWith('{') ? ' /* logic stripped */ }' : ' { /* logic stripped */ }'));
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Very basic tracking of class methods (indentation heuristic)
|
|
99
|
+
if (inClass && (line.startsWith(' ') || line.startsWith('\t')) && trimmed.includes('(') && trimmed.includes(')') && !trimmed.startsWith('//')) {
|
|
100
|
+
// Avoid pushing if it's just a deeply nested logic block
|
|
101
|
+
if (!trimmed.startsWith('if') && !trimmed.startsWith('for') && !trimmed.startsWith('switch')) {
|
|
102
|
+
skeleton.push(' ' + trimmed + ' { /* ... */ }');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Manage class brace depth to properly close the skeleton
|
|
107
|
+
if (inClass) {
|
|
108
|
+
braceDepth += (line.match(/\{/g) || []).length;
|
|
109
|
+
braceDepth -= (line.match(/\}/g) || []).length;
|
|
110
|
+
if (braceDepth <= 0) {
|
|
111
|
+
skeleton.push('}\n');
|
|
112
|
+
inClass = false;
|
|
113
|
+
braceDepth = 0;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return skeleton.join('\n');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function main() {
|
|
122
|
+
console.log(`\x1b[96m✦ Zooming into: ${targetFile}\x1b[0m`);
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
const content = fs.readFileSync(absolutePath, 'utf8');
|
|
126
|
+
|
|
127
|
+
// Strip comments to make regex parsing easier
|
|
128
|
+
const noComments = content.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
129
|
+
|
|
130
|
+
let skeleton = extractSkeleton(noComments);
|
|
131
|
+
|
|
132
|
+
// Fallback Logic: If the file produced practically no useful skeleton (e.g. pure data object or failed parsing)
|
|
133
|
+
if (skeleton.trim().length < 20) {
|
|
134
|
+
const lines = content.split('\n');
|
|
135
|
+
skeleton = `// [WARNING: Parser yielded little structure. Falling back to truncated raw file]\n` +
|
|
136
|
+
lines.slice(0, 100).join('\n') +
|
|
137
|
+
(lines.length > 100 ? '\n\n... (truncated)' : '');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
console.log('\n--- SKELETON START ---');
|
|
141
|
+
console.log(skeleton);
|
|
142
|
+
console.log('--- SKELETON END ---\n');
|
|
143
|
+
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.error(`\x1b[31m✖ Error parsing file: ${e.message}\x1b[0m`);
|
|
146
|
+
// Fallback Logic: Return truncated raw on hard failure
|
|
147
|
+
const rawContent = fs.readFileSync(absolutePath, 'utf8').split('\n').slice(0, 100).join('\n');
|
|
148
|
+
console.log('\n--- RAW FILE FALLBACK (100 lines) ---');
|
|
149
|
+
console.log(rawContent);
|
|
150
|
+
console.log('-------------------------------------\n');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
main();
|
|
@@ -139,4 +139,12 @@ Review these questions before confirming output:
|
|
|
139
139
|
|
|
140
140
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
141
141
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
142
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
142
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## Pre-Flight Checklist
|
|
146
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
147
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
148
|
+
|
|
149
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
150
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -304,4 +304,12 @@ Review these questions before confirming output:
|
|
|
304
304
|
|
|
305
305
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
306
306
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
307
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
307
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
## Pre-Flight Checklist
|
|
311
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
312
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
313
|
+
|
|
314
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
315
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -173,4 +173,12 @@ Review these questions before confirming output:
|
|
|
173
173
|
|
|
174
174
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
175
175
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
176
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
176
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
## Pre-Flight Checklist
|
|
180
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
181
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
182
|
+
|
|
183
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
184
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|