hyntx 2.3.0 → 2.4.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.
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +226 -25
- package/dist/cli.js +181 -25
- package/dist/index.js +226 -25
- package/package.json +2 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -414,7 +414,8 @@ declare function getAllProviders(config: EnvConfig): readonly AnalysisProvider[]
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* Checks if this is the first run of Hyntx.
|
|
417
|
-
* First run is detected when HYNTX_SERVICES is not set.
|
|
417
|
+
* First run is detected when HYNTX_SERVICES is not set in process.env
|
|
418
|
+
* AND no configuration exists in the shell config file.
|
|
418
419
|
*
|
|
419
420
|
* @returns true if this is the first run
|
|
420
421
|
*/
|
package/dist/api/index.js
CHANGED
|
@@ -389,63 +389,178 @@ var ISSUE_TAXONOMY = {
|
|
|
389
389
|
vague: {
|
|
390
390
|
name: "Vague Request",
|
|
391
391
|
severity: "high",
|
|
392
|
-
suggestion: "Be more specific about what you need",
|
|
392
|
+
suggestion: "Be more specific about what you need - include function names, file paths, error messages, or specific behaviors",
|
|
393
393
|
exampleBefore: "Help me with my code",
|
|
394
|
-
exampleAfter: "Help me debug
|
|
394
|
+
exampleAfter: "Help me debug the calculateTotal() function in utils.ts that returns undefined when called with an empty array"
|
|
395
395
|
},
|
|
396
396
|
"no-context": {
|
|
397
397
|
name: "Missing Context",
|
|
398
398
|
severity: "high",
|
|
399
|
-
suggestion: "Provide relevant background information",
|
|
399
|
+
suggestion: "Provide relevant background information - include file paths, function names, error messages, or code snippets",
|
|
400
400
|
exampleBefore: "Fix the bug",
|
|
401
|
-
exampleAfter: "Fix the bug in
|
|
401
|
+
exampleAfter: "Fix the bug in src/auth/login.ts where users are logged out after 5 minutes due to token expiration logic"
|
|
402
402
|
},
|
|
403
403
|
"too-broad": {
|
|
404
404
|
name: "Too Broad",
|
|
405
405
|
severity: "medium",
|
|
406
|
-
suggestion: "Break down into smaller, focused requests",
|
|
407
|
-
exampleBefore: "Build me an app",
|
|
408
|
-
exampleAfter: "Create a React component
|
|
406
|
+
suggestion: "Break down into smaller, focused requests - focus on one task or clearly order multiple related tasks",
|
|
407
|
+
exampleBefore: "Build me an app with authentication, database, and API",
|
|
408
|
+
exampleAfter: "Create a React login component with email/password authentication using JWT tokens"
|
|
409
409
|
},
|
|
410
410
|
"no-goal": {
|
|
411
411
|
name: "No Clear Goal",
|
|
412
412
|
severity: "high",
|
|
413
|
-
suggestion: "State what outcome you want to achieve",
|
|
413
|
+
suggestion: "State what outcome you want to achieve - specify success criteria and desired behavior",
|
|
414
414
|
exampleBefore: "Look at this file",
|
|
415
|
-
exampleAfter: "Review
|
|
415
|
+
exampleAfter: "Review src/auth/login.ts for security vulnerabilities, focusing on input validation and SQL injection risks"
|
|
416
416
|
},
|
|
417
417
|
imperative: {
|
|
418
418
|
name: "Command Without Context",
|
|
419
419
|
severity: "low",
|
|
420
|
-
suggestion: "Explain why you need this",
|
|
420
|
+
suggestion: "Explain why you need this - provide context about the use case and requirements",
|
|
421
421
|
exampleBefore: "Add a button",
|
|
422
|
-
exampleAfter: 'Add a "Submit" button to
|
|
422
|
+
exampleAfter: 'Add a "Submit" button to the login form that triggers validation and calls the authentication API'
|
|
423
|
+
},
|
|
424
|
+
"missing-technical-details": {
|
|
425
|
+
name: "Missing Technical Details",
|
|
426
|
+
severity: "medium",
|
|
427
|
+
suggestion: "Include technical details - file paths, function signatures, error messages, stack traces, or code snippets",
|
|
428
|
+
exampleBefore: "The function crashes sometimes",
|
|
429
|
+
exampleAfter: `The validateUser() function in src/utils/auth.ts crashes with "Cannot read property 'email' of null" when called with undefined`
|
|
430
|
+
},
|
|
431
|
+
"unclear-priorities": {
|
|
432
|
+
name: "Unclear Priorities",
|
|
433
|
+
severity: "low",
|
|
434
|
+
suggestion: "Order multiple requests by priority or split into separate prompts for clarity",
|
|
435
|
+
exampleBefore: "Add error handling and logging and also optimize performance and add tests",
|
|
436
|
+
exampleAfter: "First, add comprehensive error handling with try-catch blocks. Then, add logging for debugging. Finally, optimize database queries."
|
|
437
|
+
},
|
|
438
|
+
"insufficient-constraints": {
|
|
439
|
+
name: "Insufficient Constraints",
|
|
440
|
+
severity: "low",
|
|
441
|
+
suggestion: "Specify requirements and constraints - edge cases, performance needs, compatibility requirements",
|
|
442
|
+
exampleBefore: "Make it faster",
|
|
443
|
+
exampleAfter: "Optimize the database query to reduce response time to under 100ms, maintaining backward compatibility with existing API clients"
|
|
423
444
|
}
|
|
424
445
|
};
|
|
425
446
|
var SYSTEM_PROMPT_MINIMAL = `You analyze prompts for quality issues.
|
|
426
447
|
Respond with JSON only: {"issues": ["issue-id", ...], "score": 0-100}
|
|
427
448
|
|
|
428
|
-
Valid issue IDs: vague, no-context, too-broad, no-goal, imperative
|
|
449
|
+
Valid issue IDs: vague, no-context, too-broad, no-goal, imperative, missing-technical-details, unclear-priorities, insufficient-constraints
|
|
450
|
+
|
|
451
|
+
Issue definitions:
|
|
452
|
+
- vague: Generic requests without specifics ("help", "fix", "improve")
|
|
453
|
+
- no-context: Missing background info (uses "this", "it", "the bug" without context)
|
|
454
|
+
- too-broad: Requests covering multiple unrelated topics
|
|
455
|
+
- no-goal: Ambiguous success criteria or desired outcome
|
|
456
|
+
- imperative: Commands without explanation or reasoning
|
|
457
|
+
- missing-technical-details: No file paths, function names, or error messages
|
|
458
|
+
- unclear-priorities: Multiple requests without ordering
|
|
459
|
+
- insufficient-constraints: No requirements or edge cases mentioned
|
|
460
|
+
|
|
461
|
+
Scoring: 0-100 (100=perfect, 90+=excellent, 70-89=good, 50-69=fair, <50=poor)
|
|
429
462
|
|
|
430
463
|
Examples:
|
|
431
464
|
Input: "Help me with code"
|
|
432
|
-
Output: {"issues": ["vague", "no-context"], "score":
|
|
465
|
+
Output: {"issues": ["vague", "no-context"], "score": 35}
|
|
433
466
|
|
|
434
467
|
Input: "Debug this TypeScript function that returns undefined"
|
|
435
|
-
Output: {"issues": [], "score":
|
|
436
|
-
|
|
468
|
+
Output: {"issues": ["missing-technical-details"], "score": 70}
|
|
469
|
+
|
|
470
|
+
Input: "Debug calculateTotal() in utils.ts that returns undefined when called with empty array"
|
|
471
|
+
Output: {"issues": [], "score": 90}`;
|
|
472
|
+
var SYSTEM_PROMPT_FULL = `You are an expert prompt quality analyst specializing in code-related prompts for AI assistants like Claude. Your task is to analyze prompts and identify patterns that reduce their effectiveness, providing actionable improvements.
|
|
473
|
+
|
|
474
|
+
CRITICAL: Return ONLY valid JSON following the exact schema below. No markdown, no explanations, no code fences - just pure JSON.
|
|
437
475
|
|
|
438
476
|
Schema:
|
|
439
|
-
{
|
|
477
|
+
{
|
|
478
|
+
"patterns": [
|
|
479
|
+
{
|
|
480
|
+
"id": "kebab-case-id",
|
|
481
|
+
"name": "Human-Readable Issue Name",
|
|
482
|
+
"frequency": 3,
|
|
483
|
+
"severity": "high|medium|low",
|
|
484
|
+
"examples": ["example prompt 1", "example prompt 2"],
|
|
485
|
+
"suggestion": "Actionable advice to fix this pattern",
|
|
486
|
+
"beforeAfter": {
|
|
487
|
+
"before": "Original problematic prompt",
|
|
488
|
+
"after": "Improved version addressing the issue"
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
],
|
|
492
|
+
"stats": {
|
|
493
|
+
"totalPrompts": 10,
|
|
494
|
+
"promptsWithIssues": 7,
|
|
495
|
+
"overallScore": 65
|
|
496
|
+
},
|
|
497
|
+
"topSuggestion": "Single most impactful recommendation"
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
QUALITY DIMENSIONS TO EVALUATE:
|
|
501
|
+
|
|
502
|
+
1. SPECIFICITY (High Priority)
|
|
503
|
+
- Vague: "help me", "fix this", "improve code" without specifics
|
|
504
|
+
- Good: Includes function names, file paths, error messages, specific behaviors
|
|
505
|
+
- Look for: Generic verbs without objects, pronouns without referents
|
|
440
506
|
|
|
441
|
-
|
|
442
|
-
-
|
|
443
|
-
-
|
|
444
|
-
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
-
|
|
448
|
-
|
|
507
|
+
2. CONTEXT PROVISION (High Priority)
|
|
508
|
+
- Missing: References to "this code", "the bug", "it" without background
|
|
509
|
+
- Good: Provides file paths, function signatures, relevant code snippets, error stack traces
|
|
510
|
+
- Look for: Unclear referents, assumptions of shared knowledge
|
|
511
|
+
|
|
512
|
+
3. GOAL CLARITY (High Priority)
|
|
513
|
+
- Unclear: "Look at this", "Review my code", "What's wrong?"
|
|
514
|
+
- Good: Explicitly states desired outcome: "Find security vulnerabilities", "Optimize for performance", "Fix the null pointer exception"
|
|
515
|
+
- Look for: Ambiguous success criteria, open-ended questions
|
|
516
|
+
|
|
517
|
+
4. SCOPE APPROPRIATENESS (Medium Priority)
|
|
518
|
+
- Too broad: "Build me an app", "Refactor everything", multiple unrelated tasks
|
|
519
|
+
- Too narrow: Overly specific constraints that limit solution space unnecessarily
|
|
520
|
+
- Good: Focused single task or clearly ordered multiple tasks
|
|
521
|
+
- Look for: Multiple "and" clauses, unrelated requests, scope creep
|
|
522
|
+
|
|
523
|
+
5. ACTIONABILITY (Medium Priority)
|
|
524
|
+
- Low: "What do you think?", "Is this good?", purely exploratory
|
|
525
|
+
- Good: Clear action requested: "Fix", "Implement", "Refactor", "Add"
|
|
526
|
+
- Look for: Vague intentions, exploration without purpose
|
|
527
|
+
|
|
528
|
+
6. TECHNICAL RICHNESS (Medium Priority)
|
|
529
|
+
- Missing: No code examples, file paths, function names, error messages
|
|
530
|
+
- Good: Includes relevant code, stack traces, configuration, environment details
|
|
531
|
+
- Look for: Purely conceptual descriptions without technical details
|
|
532
|
+
|
|
533
|
+
7. CONSTRAINT DEFINITION (Low Priority)
|
|
534
|
+
- Missing: No requirements, edge cases, or constraints mentioned
|
|
535
|
+
- Good: Specifies requirements, edge cases, performance needs, compatibility needs
|
|
536
|
+
- Look for: Requests that could have many valid interpretations
|
|
537
|
+
|
|
538
|
+
SEVERITY GUIDELINES:
|
|
539
|
+
- high: Significantly impairs prompt effectiveness (vague, missing context, no goal)
|
|
540
|
+
- medium: Moderate impact on effectiveness (too broad, lacks technical details)
|
|
541
|
+
- low: Minor improvement opportunity (missing constraints, could be more specific)
|
|
542
|
+
|
|
543
|
+
SCORING GUIDELINES (0-100):
|
|
544
|
+
- 90-100: Excellent prompts - specific, contextual, actionable, well-scoped
|
|
545
|
+
- 75-89: Good prompts - minor improvements possible
|
|
546
|
+
- 60-74: Fair prompts - needs more context, clarity, or specificity
|
|
547
|
+
- 40-59: Poor prompts - multiple significant issues, partially actionable
|
|
548
|
+
- 20-39: Very poor - barely actionable, missing critical information
|
|
549
|
+
- 0-19: Extremely poor - cannot be meaningfully acted upon
|
|
550
|
+
|
|
551
|
+
PATTERN IDENTIFICATION:
|
|
552
|
+
- Group similar issues together (same root cause)
|
|
553
|
+
- Count frequency: how many prompts exhibit this pattern
|
|
554
|
+
- Provide 1-3 real examples from the actual prompts analyzed
|
|
555
|
+
- Create meaningful before/after pairs that clearly show improvement
|
|
556
|
+
- Ensure beforeAfter.before matches one of the examples
|
|
557
|
+
|
|
558
|
+
IMPROVEMENT PRIORITIES:
|
|
559
|
+
1. High severity patterns (vague, missing context, no goal) should appear first
|
|
560
|
+
2. More frequent patterns should rank higher
|
|
561
|
+
3. topSuggestion should address the most common high-severity issue
|
|
562
|
+
|
|
563
|
+
Remember: The goal is actionable feedback. Focus on patterns that, when fixed, would meaningfully improve prompt effectiveness for AI code assistants.`;
|
|
449
564
|
var VALID_PATTERN_IDS = Object.keys(ISSUE_TAXONOMY);
|
|
450
565
|
function applyRulesConfig(rules, baseTaxonomy = ISSUE_TAXONOMY) {
|
|
451
566
|
if (!rules || Object.keys(rules).length === 0) {
|
|
@@ -1822,6 +1937,32 @@ function extractRealExamples(issueId, prompts, limit = 3) {
|
|
|
1822
1937
|
case "imperative":
|
|
1823
1938
|
isMatch = trimmed.length < 20 && wordCount <= 3 && /^(add|delete|remove|update|change|modify)\b/.exec(lowerPrompt) !== null && !lowerPrompt.includes("?");
|
|
1824
1939
|
break;
|
|
1940
|
+
case "missing-technical-details": {
|
|
1941
|
+
const hasFileRef = /\w+\.(ts|js|tsx|jsx|py|go|java|rb|php|json|yaml|yml)\b/.exec(
|
|
1942
|
+
lowerPrompt
|
|
1943
|
+
) !== null;
|
|
1944
|
+
const hasFunctionRef = /function|def |class |const |let |var |(\.\w+\()/.exec(
|
|
1945
|
+
lowerPrompt
|
|
1946
|
+
) !== null;
|
|
1947
|
+
const hasErrorRef = /error|exception|failed|crash|undefined|null/.exec(lowerPrompt) !== null;
|
|
1948
|
+
isMatch = !hasFileRef && !hasFunctionRef && !hasErrorRef && wordCount >= 3;
|
|
1949
|
+
break;
|
|
1950
|
+
}
|
|
1951
|
+
case "unclear-priorities": {
|
|
1952
|
+
const andMatches = lowerPrompt.match(/\band\b/g);
|
|
1953
|
+
const orMatches = lowerPrompt.match(/\bor\b/g);
|
|
1954
|
+
const alsoMatches = lowerPrompt.match(/\balso\b/g);
|
|
1955
|
+
const conjunctionCount = (andMatches?.length ?? 0) + (orMatches?.length ?? 0) + (alsoMatches?.length ?? 0);
|
|
1956
|
+
isMatch = conjunctionCount >= 2 && !/\b(first|second|third|then|next|finally|after|before)\b/.exec(
|
|
1957
|
+
lowerPrompt
|
|
1958
|
+
) && wordCount >= 10;
|
|
1959
|
+
break;
|
|
1960
|
+
}
|
|
1961
|
+
case "insufficient-constraints":
|
|
1962
|
+
isMatch = !/\b(constraint|requirement|must|should|edge case|boundary|limit|performance|compatib)\b/.exec(
|
|
1963
|
+
lowerPrompt
|
|
1964
|
+
) && !/\b(<|>|<=|>=|\d+ms|\d+mb|\d+kb)\b/.exec(lowerPrompt) && (lowerPrompt.includes("optimize") || lowerPrompt.includes("improve") || lowerPrompt.includes("make") || lowerPrompt.includes("add")) && wordCount >= 4;
|
|
1965
|
+
break;
|
|
1825
1966
|
default:
|
|
1826
1967
|
isMatch = false;
|
|
1827
1968
|
}
|
|
@@ -2730,6 +2871,52 @@ function getAllProviders(config) {
|
|
|
2730
2871
|
}
|
|
2731
2872
|
return config.services.map((type) => createProvider(type, config));
|
|
2732
2873
|
}
|
|
2874
|
+
var START_MARKER = "# >>> hyntx config >>>";
|
|
2875
|
+
var END_MARKER = "# <<< hyntx config <<<";
|
|
2876
|
+
function findMarkerPositions(content) {
|
|
2877
|
+
const startIndex = content.indexOf(START_MARKER);
|
|
2878
|
+
const endIndex = content.indexOf(END_MARKER);
|
|
2879
|
+
if (startIndex === -1 && endIndex === -1) {
|
|
2880
|
+
return { startIndex: -1, endIndex: -1, isValid: true };
|
|
2881
|
+
}
|
|
2882
|
+
if (startIndex !== -1 && endIndex === -1) {
|
|
2883
|
+
return { startIndex, endIndex: -1, isValid: false, issue: "missing_end" };
|
|
2884
|
+
}
|
|
2885
|
+
if (startIndex === -1 && endIndex !== -1) {
|
|
2886
|
+
return { startIndex: -1, endIndex, isValid: false, issue: "missing_start" };
|
|
2887
|
+
}
|
|
2888
|
+
if (startIndex > endIndex) {
|
|
2889
|
+
return { startIndex, endIndex, isValid: false, issue: "wrong_order" };
|
|
2890
|
+
}
|
|
2891
|
+
return { startIndex, endIndex, isValid: true };
|
|
2892
|
+
}
|
|
2893
|
+
function detectShellConfigFile() {
|
|
2894
|
+
const home = homedir();
|
|
2895
|
+
const shell = process.env["SHELL"] ?? "";
|
|
2896
|
+
if (shell.includes("zsh")) {
|
|
2897
|
+
return {
|
|
2898
|
+
shellType: "zsh",
|
|
2899
|
+
configFile: join(home, ".zshrc")
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2902
|
+
if (shell.includes("bash")) {
|
|
2903
|
+
return {
|
|
2904
|
+
shellType: "bash",
|
|
2905
|
+
configFile: join(home, ".bashrc")
|
|
2906
|
+
};
|
|
2907
|
+
}
|
|
2908
|
+
if (shell.includes("fish")) {
|
|
2909
|
+
return {
|
|
2910
|
+
shellType: "fish",
|
|
2911
|
+
configFile: join(home, ".config", "fish", "config.fish")
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
const defaultShell = process.platform === "darwin" ? "zsh" : "bash";
|
|
2915
|
+
return {
|
|
2916
|
+
shellType: defaultShell,
|
|
2917
|
+
configFile: join(home, `.${defaultShell}rc`)
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
2733
2920
|
|
|
2734
2921
|
// src/utils/env.ts
|
|
2735
2922
|
var VALID_PROVIDERS = [
|
|
@@ -2738,7 +2925,21 @@ var VALID_PROVIDERS = [
|
|
|
2738
2925
|
"google"
|
|
2739
2926
|
];
|
|
2740
2927
|
function isFirstRun() {
|
|
2741
|
-
|
|
2928
|
+
if (process.env["HYNTX_SERVICES"]) {
|
|
2929
|
+
return false;
|
|
2930
|
+
}
|
|
2931
|
+
try {
|
|
2932
|
+
const { configFile } = detectShellConfigFile();
|
|
2933
|
+
if (existsSync(configFile)) {
|
|
2934
|
+
const content = readFileSync(configFile, "utf-8");
|
|
2935
|
+
const positions = findMarkerPositions(content);
|
|
2936
|
+
if (positions.startIndex !== -1 && positions.endIndex !== -1 && positions.isValid) {
|
|
2937
|
+
return false;
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
} catch {
|
|
2941
|
+
}
|
|
2942
|
+
return true;
|
|
2742
2943
|
}
|
|
2743
2944
|
function parseServices(services) {
|
|
2744
2945
|
if (!services || services.trim() === "") {
|
package/dist/cli.js
CHANGED
|
@@ -489,13 +489,28 @@ var CACHE_DEFAULTS = {
|
|
|
489
489
|
};
|
|
490
490
|
|
|
491
491
|
// src/utils/env.ts
|
|
492
|
+
init_shell_config();
|
|
492
493
|
var VALID_PROVIDERS = [
|
|
493
494
|
"ollama",
|
|
494
495
|
"anthropic",
|
|
495
496
|
"google"
|
|
496
497
|
];
|
|
497
498
|
function isFirstRun() {
|
|
498
|
-
|
|
499
|
+
if (process.env["HYNTX_SERVICES"]) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
try {
|
|
503
|
+
const { configFile } = detectShellConfigFile();
|
|
504
|
+
if (existsSync(configFile)) {
|
|
505
|
+
const content = readFileSync(configFile, "utf-8");
|
|
506
|
+
const positions = findMarkerPositions(content);
|
|
507
|
+
if (positions.startIndex !== -1 && positions.endIndex !== -1 && positions.isValid) {
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
} catch {
|
|
512
|
+
}
|
|
513
|
+
return true;
|
|
499
514
|
}
|
|
500
515
|
function parseServices(services) {
|
|
501
516
|
if (!services || services.trim() === "") {
|
|
@@ -1435,63 +1450,178 @@ var ISSUE_TAXONOMY = {
|
|
|
1435
1450
|
vague: {
|
|
1436
1451
|
name: "Vague Request",
|
|
1437
1452
|
severity: "high",
|
|
1438
|
-
suggestion: "Be more specific about what you need",
|
|
1453
|
+
suggestion: "Be more specific about what you need - include function names, file paths, error messages, or specific behaviors",
|
|
1439
1454
|
exampleBefore: "Help me with my code",
|
|
1440
|
-
exampleAfter: "Help me debug
|
|
1455
|
+
exampleAfter: "Help me debug the calculateTotal() function in utils.ts that returns undefined when called with an empty array"
|
|
1441
1456
|
},
|
|
1442
1457
|
"no-context": {
|
|
1443
1458
|
name: "Missing Context",
|
|
1444
1459
|
severity: "high",
|
|
1445
|
-
suggestion: "Provide relevant background information",
|
|
1460
|
+
suggestion: "Provide relevant background information - include file paths, function names, error messages, or code snippets",
|
|
1446
1461
|
exampleBefore: "Fix the bug",
|
|
1447
|
-
exampleAfter: "Fix the bug in
|
|
1462
|
+
exampleAfter: "Fix the bug in src/auth/login.ts where users are logged out after 5 minutes due to token expiration logic"
|
|
1448
1463
|
},
|
|
1449
1464
|
"too-broad": {
|
|
1450
1465
|
name: "Too Broad",
|
|
1451
1466
|
severity: "medium",
|
|
1452
|
-
suggestion: "Break down into smaller, focused requests",
|
|
1453
|
-
exampleBefore: "Build me an app",
|
|
1454
|
-
exampleAfter: "Create a React component
|
|
1467
|
+
suggestion: "Break down into smaller, focused requests - focus on one task or clearly order multiple related tasks",
|
|
1468
|
+
exampleBefore: "Build me an app with authentication, database, and API",
|
|
1469
|
+
exampleAfter: "Create a React login component with email/password authentication using JWT tokens"
|
|
1455
1470
|
},
|
|
1456
1471
|
"no-goal": {
|
|
1457
1472
|
name: "No Clear Goal",
|
|
1458
1473
|
severity: "high",
|
|
1459
|
-
suggestion: "State what outcome you want to achieve",
|
|
1474
|
+
suggestion: "State what outcome you want to achieve - specify success criteria and desired behavior",
|
|
1460
1475
|
exampleBefore: "Look at this file",
|
|
1461
|
-
exampleAfter: "Review
|
|
1476
|
+
exampleAfter: "Review src/auth/login.ts for security vulnerabilities, focusing on input validation and SQL injection risks"
|
|
1462
1477
|
},
|
|
1463
1478
|
imperative: {
|
|
1464
1479
|
name: "Command Without Context",
|
|
1465
1480
|
severity: "low",
|
|
1466
|
-
suggestion: "Explain why you need this",
|
|
1481
|
+
suggestion: "Explain why you need this - provide context about the use case and requirements",
|
|
1467
1482
|
exampleBefore: "Add a button",
|
|
1468
|
-
exampleAfter: 'Add a "Submit" button to
|
|
1483
|
+
exampleAfter: 'Add a "Submit" button to the login form that triggers validation and calls the authentication API'
|
|
1484
|
+
},
|
|
1485
|
+
"missing-technical-details": {
|
|
1486
|
+
name: "Missing Technical Details",
|
|
1487
|
+
severity: "medium",
|
|
1488
|
+
suggestion: "Include technical details - file paths, function signatures, error messages, stack traces, or code snippets",
|
|
1489
|
+
exampleBefore: "The function crashes sometimes",
|
|
1490
|
+
exampleAfter: `The validateUser() function in src/utils/auth.ts crashes with "Cannot read property 'email' of null" when called with undefined`
|
|
1491
|
+
},
|
|
1492
|
+
"unclear-priorities": {
|
|
1493
|
+
name: "Unclear Priorities",
|
|
1494
|
+
severity: "low",
|
|
1495
|
+
suggestion: "Order multiple requests by priority or split into separate prompts for clarity",
|
|
1496
|
+
exampleBefore: "Add error handling and logging and also optimize performance and add tests",
|
|
1497
|
+
exampleAfter: "First, add comprehensive error handling with try-catch blocks. Then, add logging for debugging. Finally, optimize database queries."
|
|
1498
|
+
},
|
|
1499
|
+
"insufficient-constraints": {
|
|
1500
|
+
name: "Insufficient Constraints",
|
|
1501
|
+
severity: "low",
|
|
1502
|
+
suggestion: "Specify requirements and constraints - edge cases, performance needs, compatibility requirements",
|
|
1503
|
+
exampleBefore: "Make it faster",
|
|
1504
|
+
exampleAfter: "Optimize the database query to reduce response time to under 100ms, maintaining backward compatibility with existing API clients"
|
|
1469
1505
|
}
|
|
1470
1506
|
};
|
|
1471
1507
|
var SYSTEM_PROMPT_MINIMAL = `You analyze prompts for quality issues.
|
|
1472
1508
|
Respond with JSON only: {"issues": ["issue-id", ...], "score": 0-100}
|
|
1473
1509
|
|
|
1474
|
-
Valid issue IDs: vague, no-context, too-broad, no-goal, imperative
|
|
1510
|
+
Valid issue IDs: vague, no-context, too-broad, no-goal, imperative, missing-technical-details, unclear-priorities, insufficient-constraints
|
|
1511
|
+
|
|
1512
|
+
Issue definitions:
|
|
1513
|
+
- vague: Generic requests without specifics ("help", "fix", "improve")
|
|
1514
|
+
- no-context: Missing background info (uses "this", "it", "the bug" without context)
|
|
1515
|
+
- too-broad: Requests covering multiple unrelated topics
|
|
1516
|
+
- no-goal: Ambiguous success criteria or desired outcome
|
|
1517
|
+
- imperative: Commands without explanation or reasoning
|
|
1518
|
+
- missing-technical-details: No file paths, function names, or error messages
|
|
1519
|
+
- unclear-priorities: Multiple requests without ordering
|
|
1520
|
+
- insufficient-constraints: No requirements or edge cases mentioned
|
|
1521
|
+
|
|
1522
|
+
Scoring: 0-100 (100=perfect, 90+=excellent, 70-89=good, 50-69=fair, <50=poor)
|
|
1475
1523
|
|
|
1476
1524
|
Examples:
|
|
1477
1525
|
Input: "Help me with code"
|
|
1478
|
-
Output: {"issues": ["vague", "no-context"], "score":
|
|
1526
|
+
Output: {"issues": ["vague", "no-context"], "score": 35}
|
|
1479
1527
|
|
|
1480
1528
|
Input: "Debug this TypeScript function that returns undefined"
|
|
1481
|
-
Output: {"issues": [], "score":
|
|
1482
|
-
|
|
1529
|
+
Output: {"issues": ["missing-technical-details"], "score": 70}
|
|
1530
|
+
|
|
1531
|
+
Input: "Debug calculateTotal() in utils.ts that returns undefined when called with empty array"
|
|
1532
|
+
Output: {"issues": [], "score": 90}`;
|
|
1533
|
+
var SYSTEM_PROMPT_FULL = `You are an expert prompt quality analyst specializing in code-related prompts for AI assistants like Claude. Your task is to analyze prompts and identify patterns that reduce their effectiveness, providing actionable improvements.
|
|
1534
|
+
|
|
1535
|
+
CRITICAL: Return ONLY valid JSON following the exact schema below. No markdown, no explanations, no code fences - just pure JSON.
|
|
1483
1536
|
|
|
1484
1537
|
Schema:
|
|
1485
|
-
{
|
|
1538
|
+
{
|
|
1539
|
+
"patterns": [
|
|
1540
|
+
{
|
|
1541
|
+
"id": "kebab-case-id",
|
|
1542
|
+
"name": "Human-Readable Issue Name",
|
|
1543
|
+
"frequency": 3,
|
|
1544
|
+
"severity": "high|medium|low",
|
|
1545
|
+
"examples": ["example prompt 1", "example prompt 2"],
|
|
1546
|
+
"suggestion": "Actionable advice to fix this pattern",
|
|
1547
|
+
"beforeAfter": {
|
|
1548
|
+
"before": "Original problematic prompt",
|
|
1549
|
+
"after": "Improved version addressing the issue"
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
],
|
|
1553
|
+
"stats": {
|
|
1554
|
+
"totalPrompts": 10,
|
|
1555
|
+
"promptsWithIssues": 7,
|
|
1556
|
+
"overallScore": 65
|
|
1557
|
+
},
|
|
1558
|
+
"topSuggestion": "Single most impactful recommendation"
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
QUALITY DIMENSIONS TO EVALUATE:
|
|
1562
|
+
|
|
1563
|
+
1. SPECIFICITY (High Priority)
|
|
1564
|
+
- Vague: "help me", "fix this", "improve code" without specifics
|
|
1565
|
+
- Good: Includes function names, file paths, error messages, specific behaviors
|
|
1566
|
+
- Look for: Generic verbs without objects, pronouns without referents
|
|
1567
|
+
|
|
1568
|
+
2. CONTEXT PROVISION (High Priority)
|
|
1569
|
+
- Missing: References to "this code", "the bug", "it" without background
|
|
1570
|
+
- Good: Provides file paths, function signatures, relevant code snippets, error stack traces
|
|
1571
|
+
- Look for: Unclear referents, assumptions of shared knowledge
|
|
1572
|
+
|
|
1573
|
+
3. GOAL CLARITY (High Priority)
|
|
1574
|
+
- Unclear: "Look at this", "Review my code", "What's wrong?"
|
|
1575
|
+
- Good: Explicitly states desired outcome: "Find security vulnerabilities", "Optimize for performance", "Fix the null pointer exception"
|
|
1576
|
+
- Look for: Ambiguous success criteria, open-ended questions
|
|
1577
|
+
|
|
1578
|
+
4. SCOPE APPROPRIATENESS (Medium Priority)
|
|
1579
|
+
- Too broad: "Build me an app", "Refactor everything", multiple unrelated tasks
|
|
1580
|
+
- Too narrow: Overly specific constraints that limit solution space unnecessarily
|
|
1581
|
+
- Good: Focused single task or clearly ordered multiple tasks
|
|
1582
|
+
- Look for: Multiple "and" clauses, unrelated requests, scope creep
|
|
1583
|
+
|
|
1584
|
+
5. ACTIONABILITY (Medium Priority)
|
|
1585
|
+
- Low: "What do you think?", "Is this good?", purely exploratory
|
|
1586
|
+
- Good: Clear action requested: "Fix", "Implement", "Refactor", "Add"
|
|
1587
|
+
- Look for: Vague intentions, exploration without purpose
|
|
1588
|
+
|
|
1589
|
+
6. TECHNICAL RICHNESS (Medium Priority)
|
|
1590
|
+
- Missing: No code examples, file paths, function names, error messages
|
|
1591
|
+
- Good: Includes relevant code, stack traces, configuration, environment details
|
|
1592
|
+
- Look for: Purely conceptual descriptions without technical details
|
|
1593
|
+
|
|
1594
|
+
7. CONSTRAINT DEFINITION (Low Priority)
|
|
1595
|
+
- Missing: No requirements, edge cases, or constraints mentioned
|
|
1596
|
+
- Good: Specifies requirements, edge cases, performance needs, compatibility needs
|
|
1597
|
+
- Look for: Requests that could have many valid interpretations
|
|
1598
|
+
|
|
1599
|
+
SEVERITY GUIDELINES:
|
|
1600
|
+
- high: Significantly impairs prompt effectiveness (vague, missing context, no goal)
|
|
1601
|
+
- medium: Moderate impact on effectiveness (too broad, lacks technical details)
|
|
1602
|
+
- low: Minor improvement opportunity (missing constraints, could be more specific)
|
|
1603
|
+
|
|
1604
|
+
SCORING GUIDELINES (0-100):
|
|
1605
|
+
- 90-100: Excellent prompts - specific, contextual, actionable, well-scoped
|
|
1606
|
+
- 75-89: Good prompts - minor improvements possible
|
|
1607
|
+
- 60-74: Fair prompts - needs more context, clarity, or specificity
|
|
1608
|
+
- 40-59: Poor prompts - multiple significant issues, partially actionable
|
|
1609
|
+
- 20-39: Very poor - barely actionable, missing critical information
|
|
1610
|
+
- 0-19: Extremely poor - cannot be meaningfully acted upon
|
|
1611
|
+
|
|
1612
|
+
PATTERN IDENTIFICATION:
|
|
1613
|
+
- Group similar issues together (same root cause)
|
|
1614
|
+
- Count frequency: how many prompts exhibit this pattern
|
|
1615
|
+
- Provide 1-3 real examples from the actual prompts analyzed
|
|
1616
|
+
- Create meaningful before/after pairs that clearly show improvement
|
|
1617
|
+
- Ensure beforeAfter.before matches one of the examples
|
|
1486
1618
|
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
- fix: improved version of that prompt`;
|
|
1494
|
-
var SYSTEM_PROMPT_FULL = SYSTEM_PROMPT_SIMPLE;
|
|
1619
|
+
IMPROVEMENT PRIORITIES:
|
|
1620
|
+
1. High severity patterns (vague, missing context, no goal) should appear first
|
|
1621
|
+
2. More frequent patterns should rank higher
|
|
1622
|
+
3. topSuggestion should address the most common high-severity issue
|
|
1623
|
+
|
|
1624
|
+
Remember: The goal is actionable feedback. Focus on patterns that, when fixed, would meaningfully improve prompt effectiveness for AI code assistants.`;
|
|
1495
1625
|
var VALID_PATTERN_IDS = Object.keys(ISSUE_TAXONOMY);
|
|
1496
1626
|
function applyRulesConfig(rules, baseTaxonomy = ISSUE_TAXONOMY) {
|
|
1497
1627
|
if (!rules || Object.keys(rules).length === 0) {
|
|
@@ -2721,6 +2851,32 @@ function extractRealExamples(issueId, prompts3, limit = 3) {
|
|
|
2721
2851
|
case "imperative":
|
|
2722
2852
|
isMatch = trimmed.length < 20 && wordCount <= 3 && /^(add|delete|remove|update|change|modify)\b/.exec(lowerPrompt) !== null && !lowerPrompt.includes("?");
|
|
2723
2853
|
break;
|
|
2854
|
+
case "missing-technical-details": {
|
|
2855
|
+
const hasFileRef = /\w+\.(ts|js|tsx|jsx|py|go|java|rb|php|json|yaml|yml)\b/.exec(
|
|
2856
|
+
lowerPrompt
|
|
2857
|
+
) !== null;
|
|
2858
|
+
const hasFunctionRef = /function|def |class |const |let |var |(\.\w+\()/.exec(
|
|
2859
|
+
lowerPrompt
|
|
2860
|
+
) !== null;
|
|
2861
|
+
const hasErrorRef = /error|exception|failed|crash|undefined|null/.exec(lowerPrompt) !== null;
|
|
2862
|
+
isMatch = !hasFileRef && !hasFunctionRef && !hasErrorRef && wordCount >= 3;
|
|
2863
|
+
break;
|
|
2864
|
+
}
|
|
2865
|
+
case "unclear-priorities": {
|
|
2866
|
+
const andMatches = lowerPrompt.match(/\band\b/g);
|
|
2867
|
+
const orMatches = lowerPrompt.match(/\bor\b/g);
|
|
2868
|
+
const alsoMatches = lowerPrompt.match(/\balso\b/g);
|
|
2869
|
+
const conjunctionCount = (andMatches?.length ?? 0) + (orMatches?.length ?? 0) + (alsoMatches?.length ?? 0);
|
|
2870
|
+
isMatch = conjunctionCount >= 2 && !/\b(first|second|third|then|next|finally|after|before)\b/.exec(
|
|
2871
|
+
lowerPrompt
|
|
2872
|
+
) && wordCount >= 10;
|
|
2873
|
+
break;
|
|
2874
|
+
}
|
|
2875
|
+
case "insufficient-constraints":
|
|
2876
|
+
isMatch = !/\b(constraint|requirement|must|should|edge case|boundary|limit|performance|compatib)\b/.exec(
|
|
2877
|
+
lowerPrompt
|
|
2878
|
+
) && !/\b(<|>|<=|>=|\d+ms|\d+mb|\d+kb)\b/.exec(lowerPrompt) && (lowerPrompt.includes("optimize") || lowerPrompt.includes("improve") || lowerPrompt.includes("make") || lowerPrompt.includes("add")) && wordCount >= 4;
|
|
2879
|
+
break;
|
|
2724
2880
|
default:
|
|
2725
2881
|
isMatch = false;
|
|
2726
2882
|
}
|
package/dist/index.js
CHANGED
|
@@ -389,63 +389,178 @@ var ISSUE_TAXONOMY = {
|
|
|
389
389
|
vague: {
|
|
390
390
|
name: "Vague Request",
|
|
391
391
|
severity: "high",
|
|
392
|
-
suggestion: "Be more specific about what you need",
|
|
392
|
+
suggestion: "Be more specific about what you need - include function names, file paths, error messages, or specific behaviors",
|
|
393
393
|
exampleBefore: "Help me with my code",
|
|
394
|
-
exampleAfter: "Help me debug
|
|
394
|
+
exampleAfter: "Help me debug the calculateTotal() function in utils.ts that returns undefined when called with an empty array"
|
|
395
395
|
},
|
|
396
396
|
"no-context": {
|
|
397
397
|
name: "Missing Context",
|
|
398
398
|
severity: "high",
|
|
399
|
-
suggestion: "Provide relevant background information",
|
|
399
|
+
suggestion: "Provide relevant background information - include file paths, function names, error messages, or code snippets",
|
|
400
400
|
exampleBefore: "Fix the bug",
|
|
401
|
-
exampleAfter: "Fix the bug in
|
|
401
|
+
exampleAfter: "Fix the bug in src/auth/login.ts where users are logged out after 5 minutes due to token expiration logic"
|
|
402
402
|
},
|
|
403
403
|
"too-broad": {
|
|
404
404
|
name: "Too Broad",
|
|
405
405
|
severity: "medium",
|
|
406
|
-
suggestion: "Break down into smaller, focused requests",
|
|
407
|
-
exampleBefore: "Build me an app",
|
|
408
|
-
exampleAfter: "Create a React component
|
|
406
|
+
suggestion: "Break down into smaller, focused requests - focus on one task or clearly order multiple related tasks",
|
|
407
|
+
exampleBefore: "Build me an app with authentication, database, and API",
|
|
408
|
+
exampleAfter: "Create a React login component with email/password authentication using JWT tokens"
|
|
409
409
|
},
|
|
410
410
|
"no-goal": {
|
|
411
411
|
name: "No Clear Goal",
|
|
412
412
|
severity: "high",
|
|
413
|
-
suggestion: "State what outcome you want to achieve",
|
|
413
|
+
suggestion: "State what outcome you want to achieve - specify success criteria and desired behavior",
|
|
414
414
|
exampleBefore: "Look at this file",
|
|
415
|
-
exampleAfter: "Review
|
|
415
|
+
exampleAfter: "Review src/auth/login.ts for security vulnerabilities, focusing on input validation and SQL injection risks"
|
|
416
416
|
},
|
|
417
417
|
imperative: {
|
|
418
418
|
name: "Command Without Context",
|
|
419
419
|
severity: "low",
|
|
420
|
-
suggestion: "Explain why you need this",
|
|
420
|
+
suggestion: "Explain why you need this - provide context about the use case and requirements",
|
|
421
421
|
exampleBefore: "Add a button",
|
|
422
|
-
exampleAfter: 'Add a "Submit" button to
|
|
422
|
+
exampleAfter: 'Add a "Submit" button to the login form that triggers validation and calls the authentication API'
|
|
423
|
+
},
|
|
424
|
+
"missing-technical-details": {
|
|
425
|
+
name: "Missing Technical Details",
|
|
426
|
+
severity: "medium",
|
|
427
|
+
suggestion: "Include technical details - file paths, function signatures, error messages, stack traces, or code snippets",
|
|
428
|
+
exampleBefore: "The function crashes sometimes",
|
|
429
|
+
exampleAfter: `The validateUser() function in src/utils/auth.ts crashes with "Cannot read property 'email' of null" when called with undefined`
|
|
430
|
+
},
|
|
431
|
+
"unclear-priorities": {
|
|
432
|
+
name: "Unclear Priorities",
|
|
433
|
+
severity: "low",
|
|
434
|
+
suggestion: "Order multiple requests by priority or split into separate prompts for clarity",
|
|
435
|
+
exampleBefore: "Add error handling and logging and also optimize performance and add tests",
|
|
436
|
+
exampleAfter: "First, add comprehensive error handling with try-catch blocks. Then, add logging for debugging. Finally, optimize database queries."
|
|
437
|
+
},
|
|
438
|
+
"insufficient-constraints": {
|
|
439
|
+
name: "Insufficient Constraints",
|
|
440
|
+
severity: "low",
|
|
441
|
+
suggestion: "Specify requirements and constraints - edge cases, performance needs, compatibility requirements",
|
|
442
|
+
exampleBefore: "Make it faster",
|
|
443
|
+
exampleAfter: "Optimize the database query to reduce response time to under 100ms, maintaining backward compatibility with existing API clients"
|
|
423
444
|
}
|
|
424
445
|
};
|
|
425
446
|
var SYSTEM_PROMPT_MINIMAL = `You analyze prompts for quality issues.
|
|
426
447
|
Respond with JSON only: {"issues": ["issue-id", ...], "score": 0-100}
|
|
427
448
|
|
|
428
|
-
Valid issue IDs: vague, no-context, too-broad, no-goal, imperative
|
|
449
|
+
Valid issue IDs: vague, no-context, too-broad, no-goal, imperative, missing-technical-details, unclear-priorities, insufficient-constraints
|
|
450
|
+
|
|
451
|
+
Issue definitions:
|
|
452
|
+
- vague: Generic requests without specifics ("help", "fix", "improve")
|
|
453
|
+
- no-context: Missing background info (uses "this", "it", "the bug" without context)
|
|
454
|
+
- too-broad: Requests covering multiple unrelated topics
|
|
455
|
+
- no-goal: Ambiguous success criteria or desired outcome
|
|
456
|
+
- imperative: Commands without explanation or reasoning
|
|
457
|
+
- missing-technical-details: No file paths, function names, or error messages
|
|
458
|
+
- unclear-priorities: Multiple requests without ordering
|
|
459
|
+
- insufficient-constraints: No requirements or edge cases mentioned
|
|
460
|
+
|
|
461
|
+
Scoring: 0-100 (100=perfect, 90+=excellent, 70-89=good, 50-69=fair, <50=poor)
|
|
429
462
|
|
|
430
463
|
Examples:
|
|
431
464
|
Input: "Help me with code"
|
|
432
|
-
Output: {"issues": ["vague", "no-context"], "score":
|
|
465
|
+
Output: {"issues": ["vague", "no-context"], "score": 35}
|
|
433
466
|
|
|
434
467
|
Input: "Debug this TypeScript function that returns undefined"
|
|
435
|
-
Output: {"issues": [], "score":
|
|
436
|
-
|
|
468
|
+
Output: {"issues": ["missing-technical-details"], "score": 70}
|
|
469
|
+
|
|
470
|
+
Input: "Debug calculateTotal() in utils.ts that returns undefined when called with empty array"
|
|
471
|
+
Output: {"issues": [], "score": 90}`;
|
|
472
|
+
var SYSTEM_PROMPT_FULL = `You are an expert prompt quality analyst specializing in code-related prompts for AI assistants like Claude. Your task is to analyze prompts and identify patterns that reduce their effectiveness, providing actionable improvements.
|
|
473
|
+
|
|
474
|
+
CRITICAL: Return ONLY valid JSON following the exact schema below. No markdown, no explanations, no code fences - just pure JSON.
|
|
437
475
|
|
|
438
476
|
Schema:
|
|
439
|
-
{
|
|
477
|
+
{
|
|
478
|
+
"patterns": [
|
|
479
|
+
{
|
|
480
|
+
"id": "kebab-case-id",
|
|
481
|
+
"name": "Human-Readable Issue Name",
|
|
482
|
+
"frequency": 3,
|
|
483
|
+
"severity": "high|medium|low",
|
|
484
|
+
"examples": ["example prompt 1", "example prompt 2"],
|
|
485
|
+
"suggestion": "Actionable advice to fix this pattern",
|
|
486
|
+
"beforeAfter": {
|
|
487
|
+
"before": "Original problematic prompt",
|
|
488
|
+
"after": "Improved version addressing the issue"
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
],
|
|
492
|
+
"stats": {
|
|
493
|
+
"totalPrompts": 10,
|
|
494
|
+
"promptsWithIssues": 7,
|
|
495
|
+
"overallScore": 65
|
|
496
|
+
},
|
|
497
|
+
"topSuggestion": "Single most impactful recommendation"
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
QUALITY DIMENSIONS TO EVALUATE:
|
|
501
|
+
|
|
502
|
+
1. SPECIFICITY (High Priority)
|
|
503
|
+
- Vague: "help me", "fix this", "improve code" without specifics
|
|
504
|
+
- Good: Includes function names, file paths, error messages, specific behaviors
|
|
505
|
+
- Look for: Generic verbs without objects, pronouns without referents
|
|
440
506
|
|
|
441
|
-
|
|
442
|
-
-
|
|
443
|
-
-
|
|
444
|
-
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
-
|
|
448
|
-
|
|
507
|
+
2. CONTEXT PROVISION (High Priority)
|
|
508
|
+
- Missing: References to "this code", "the bug", "it" without background
|
|
509
|
+
- Good: Provides file paths, function signatures, relevant code snippets, error stack traces
|
|
510
|
+
- Look for: Unclear referents, assumptions of shared knowledge
|
|
511
|
+
|
|
512
|
+
3. GOAL CLARITY (High Priority)
|
|
513
|
+
- Unclear: "Look at this", "Review my code", "What's wrong?"
|
|
514
|
+
- Good: Explicitly states desired outcome: "Find security vulnerabilities", "Optimize for performance", "Fix the null pointer exception"
|
|
515
|
+
- Look for: Ambiguous success criteria, open-ended questions
|
|
516
|
+
|
|
517
|
+
4. SCOPE APPROPRIATENESS (Medium Priority)
|
|
518
|
+
- Too broad: "Build me an app", "Refactor everything", multiple unrelated tasks
|
|
519
|
+
- Too narrow: Overly specific constraints that limit solution space unnecessarily
|
|
520
|
+
- Good: Focused single task or clearly ordered multiple tasks
|
|
521
|
+
- Look for: Multiple "and" clauses, unrelated requests, scope creep
|
|
522
|
+
|
|
523
|
+
5. ACTIONABILITY (Medium Priority)
|
|
524
|
+
- Low: "What do you think?", "Is this good?", purely exploratory
|
|
525
|
+
- Good: Clear action requested: "Fix", "Implement", "Refactor", "Add"
|
|
526
|
+
- Look for: Vague intentions, exploration without purpose
|
|
527
|
+
|
|
528
|
+
6. TECHNICAL RICHNESS (Medium Priority)
|
|
529
|
+
- Missing: No code examples, file paths, function names, error messages
|
|
530
|
+
- Good: Includes relevant code, stack traces, configuration, environment details
|
|
531
|
+
- Look for: Purely conceptual descriptions without technical details
|
|
532
|
+
|
|
533
|
+
7. CONSTRAINT DEFINITION (Low Priority)
|
|
534
|
+
- Missing: No requirements, edge cases, or constraints mentioned
|
|
535
|
+
- Good: Specifies requirements, edge cases, performance needs, compatibility needs
|
|
536
|
+
- Look for: Requests that could have many valid interpretations
|
|
537
|
+
|
|
538
|
+
SEVERITY GUIDELINES:
|
|
539
|
+
- high: Significantly impairs prompt effectiveness (vague, missing context, no goal)
|
|
540
|
+
- medium: Moderate impact on effectiveness (too broad, lacks technical details)
|
|
541
|
+
- low: Minor improvement opportunity (missing constraints, could be more specific)
|
|
542
|
+
|
|
543
|
+
SCORING GUIDELINES (0-100):
|
|
544
|
+
- 90-100: Excellent prompts - specific, contextual, actionable, well-scoped
|
|
545
|
+
- 75-89: Good prompts - minor improvements possible
|
|
546
|
+
- 60-74: Fair prompts - needs more context, clarity, or specificity
|
|
547
|
+
- 40-59: Poor prompts - multiple significant issues, partially actionable
|
|
548
|
+
- 20-39: Very poor - barely actionable, missing critical information
|
|
549
|
+
- 0-19: Extremely poor - cannot be meaningfully acted upon
|
|
550
|
+
|
|
551
|
+
PATTERN IDENTIFICATION:
|
|
552
|
+
- Group similar issues together (same root cause)
|
|
553
|
+
- Count frequency: how many prompts exhibit this pattern
|
|
554
|
+
- Provide 1-3 real examples from the actual prompts analyzed
|
|
555
|
+
- Create meaningful before/after pairs that clearly show improvement
|
|
556
|
+
- Ensure beforeAfter.before matches one of the examples
|
|
557
|
+
|
|
558
|
+
IMPROVEMENT PRIORITIES:
|
|
559
|
+
1. High severity patterns (vague, missing context, no goal) should appear first
|
|
560
|
+
2. More frequent patterns should rank higher
|
|
561
|
+
3. topSuggestion should address the most common high-severity issue
|
|
562
|
+
|
|
563
|
+
Remember: The goal is actionable feedback. Focus on patterns that, when fixed, would meaningfully improve prompt effectiveness for AI code assistants.`;
|
|
449
564
|
var VALID_PATTERN_IDS = Object.keys(ISSUE_TAXONOMY);
|
|
450
565
|
function applyRulesConfig(rules, baseTaxonomy = ISSUE_TAXONOMY) {
|
|
451
566
|
if (!rules || Object.keys(rules).length === 0) {
|
|
@@ -1822,6 +1937,32 @@ function extractRealExamples(issueId, prompts, limit = 3) {
|
|
|
1822
1937
|
case "imperative":
|
|
1823
1938
|
isMatch = trimmed.length < 20 && wordCount <= 3 && /^(add|delete|remove|update|change|modify)\b/.exec(lowerPrompt) !== null && !lowerPrompt.includes("?");
|
|
1824
1939
|
break;
|
|
1940
|
+
case "missing-technical-details": {
|
|
1941
|
+
const hasFileRef = /\w+\.(ts|js|tsx|jsx|py|go|java|rb|php|json|yaml|yml)\b/.exec(
|
|
1942
|
+
lowerPrompt
|
|
1943
|
+
) !== null;
|
|
1944
|
+
const hasFunctionRef = /function|def |class |const |let |var |(\.\w+\()/.exec(
|
|
1945
|
+
lowerPrompt
|
|
1946
|
+
) !== null;
|
|
1947
|
+
const hasErrorRef = /error|exception|failed|crash|undefined|null/.exec(lowerPrompt) !== null;
|
|
1948
|
+
isMatch = !hasFileRef && !hasFunctionRef && !hasErrorRef && wordCount >= 3;
|
|
1949
|
+
break;
|
|
1950
|
+
}
|
|
1951
|
+
case "unclear-priorities": {
|
|
1952
|
+
const andMatches = lowerPrompt.match(/\band\b/g);
|
|
1953
|
+
const orMatches = lowerPrompt.match(/\bor\b/g);
|
|
1954
|
+
const alsoMatches = lowerPrompt.match(/\balso\b/g);
|
|
1955
|
+
const conjunctionCount = (andMatches?.length ?? 0) + (orMatches?.length ?? 0) + (alsoMatches?.length ?? 0);
|
|
1956
|
+
isMatch = conjunctionCount >= 2 && !/\b(first|second|third|then|next|finally|after|before)\b/.exec(
|
|
1957
|
+
lowerPrompt
|
|
1958
|
+
) && wordCount >= 10;
|
|
1959
|
+
break;
|
|
1960
|
+
}
|
|
1961
|
+
case "insufficient-constraints":
|
|
1962
|
+
isMatch = !/\b(constraint|requirement|must|should|edge case|boundary|limit|performance|compatib)\b/.exec(
|
|
1963
|
+
lowerPrompt
|
|
1964
|
+
) && !/\b(<|>|<=|>=|\d+ms|\d+mb|\d+kb)\b/.exec(lowerPrompt) && (lowerPrompt.includes("optimize") || lowerPrompt.includes("improve") || lowerPrompt.includes("make") || lowerPrompt.includes("add")) && wordCount >= 4;
|
|
1965
|
+
break;
|
|
1825
1966
|
default:
|
|
1826
1967
|
isMatch = false;
|
|
1827
1968
|
}
|
|
@@ -2730,6 +2871,52 @@ function getAllProviders(config) {
|
|
|
2730
2871
|
}
|
|
2731
2872
|
return config.services.map((type) => createProvider(type, config));
|
|
2732
2873
|
}
|
|
2874
|
+
var START_MARKER = "# >>> hyntx config >>>";
|
|
2875
|
+
var END_MARKER = "# <<< hyntx config <<<";
|
|
2876
|
+
function findMarkerPositions(content) {
|
|
2877
|
+
const startIndex = content.indexOf(START_MARKER);
|
|
2878
|
+
const endIndex = content.indexOf(END_MARKER);
|
|
2879
|
+
if (startIndex === -1 && endIndex === -1) {
|
|
2880
|
+
return { startIndex: -1, endIndex: -1, isValid: true };
|
|
2881
|
+
}
|
|
2882
|
+
if (startIndex !== -1 && endIndex === -1) {
|
|
2883
|
+
return { startIndex, endIndex: -1, isValid: false, issue: "missing_end" };
|
|
2884
|
+
}
|
|
2885
|
+
if (startIndex === -1 && endIndex !== -1) {
|
|
2886
|
+
return { startIndex: -1, endIndex, isValid: false, issue: "missing_start" };
|
|
2887
|
+
}
|
|
2888
|
+
if (startIndex > endIndex) {
|
|
2889
|
+
return { startIndex, endIndex, isValid: false, issue: "wrong_order" };
|
|
2890
|
+
}
|
|
2891
|
+
return { startIndex, endIndex, isValid: true };
|
|
2892
|
+
}
|
|
2893
|
+
function detectShellConfigFile() {
|
|
2894
|
+
const home = homedir();
|
|
2895
|
+
const shell = process.env["SHELL"] ?? "";
|
|
2896
|
+
if (shell.includes("zsh")) {
|
|
2897
|
+
return {
|
|
2898
|
+
shellType: "zsh",
|
|
2899
|
+
configFile: join(home, ".zshrc")
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2902
|
+
if (shell.includes("bash")) {
|
|
2903
|
+
return {
|
|
2904
|
+
shellType: "bash",
|
|
2905
|
+
configFile: join(home, ".bashrc")
|
|
2906
|
+
};
|
|
2907
|
+
}
|
|
2908
|
+
if (shell.includes("fish")) {
|
|
2909
|
+
return {
|
|
2910
|
+
shellType: "fish",
|
|
2911
|
+
configFile: join(home, ".config", "fish", "config.fish")
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
const defaultShell = process.platform === "darwin" ? "zsh" : "bash";
|
|
2915
|
+
return {
|
|
2916
|
+
shellType: defaultShell,
|
|
2917
|
+
configFile: join(home, `.${defaultShell}rc`)
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
2733
2920
|
|
|
2734
2921
|
// src/utils/env.ts
|
|
2735
2922
|
var VALID_PROVIDERS = [
|
|
@@ -2738,7 +2925,21 @@ var VALID_PROVIDERS = [
|
|
|
2738
2925
|
"google"
|
|
2739
2926
|
];
|
|
2740
2927
|
function isFirstRun() {
|
|
2741
|
-
|
|
2928
|
+
if (process.env["HYNTX_SERVICES"]) {
|
|
2929
|
+
return false;
|
|
2930
|
+
}
|
|
2931
|
+
try {
|
|
2932
|
+
const { configFile } = detectShellConfigFile();
|
|
2933
|
+
if (existsSync(configFile)) {
|
|
2934
|
+
const content = readFileSync(configFile, "utf-8");
|
|
2935
|
+
const positions = findMarkerPositions(content);
|
|
2936
|
+
if (positions.startIndex !== -1 && positions.endIndex !== -1 && positions.isValid) {
|
|
2937
|
+
return false;
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
} catch {
|
|
2941
|
+
}
|
|
2942
|
+
return true;
|
|
2742
2943
|
}
|
|
2743
2944
|
function parseServices(services) {
|
|
2744
2945
|
if (!services || services.trim() === "") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyntx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "CLI that analyzes Claude Code prompts and generates improvement suggestions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@jmlweb/tsconfig-base": "^1.0.0",
|
|
24
24
|
"@jmlweb/vitest-config": "^1.0.0",
|
|
25
25
|
"@semantic-release/changelog": "^6.0.3",
|
|
26
|
+
"@semantic-release/exec": "^6.0.3",
|
|
26
27
|
"@semantic-release/git": "^10.0.1",
|
|
27
28
|
"@types/figlet": "^1.7.0",
|
|
28
29
|
"@types/node": "^25.0.3",
|