jude-prompt-engine 0.1.0__tar.gz

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 (27) hide show
  1. jude_prompt_engine-0.1.0/PKG-INFO +64 -0
  2. jude_prompt_engine-0.1.0/README.md +39 -0
  3. jude_prompt_engine-0.1.0/jude_prompt_engine.egg-info/PKG-INFO +64 -0
  4. jude_prompt_engine-0.1.0/jude_prompt_engine.egg-info/SOURCES.txt +25 -0
  5. jude_prompt_engine-0.1.0/jude_prompt_engine.egg-info/dependency_links.txt +1 -0
  6. jude_prompt_engine-0.1.0/jude_prompt_engine.egg-info/entry_points.txt +2 -0
  7. jude_prompt_engine-0.1.0/jude_prompt_engine.egg-info/requires.txt +5 -0
  8. jude_prompt_engine-0.1.0/jude_prompt_engine.egg-info/top_level.txt +1 -0
  9. jude_prompt_engine-0.1.0/prompt_engine/__init__.py +15 -0
  10. jude_prompt_engine-0.1.0/prompt_engine/budget.py +85 -0
  11. jude_prompt_engine-0.1.0/prompt_engine/cli.py +817 -0
  12. jude_prompt_engine-0.1.0/prompt_engine/compiler.py +248 -0
  13. jude_prompt_engine-0.1.0/prompt_engine/config.py +169 -0
  14. jude_prompt_engine-0.1.0/prompt_engine/contracts.py +199 -0
  15. jude_prompt_engine-0.1.0/prompt_engine/intent.py +572 -0
  16. jude_prompt_engine-0.1.0/prompt_engine/output_serializer.py +149 -0
  17. jude_prompt_engine-0.1.0/prompt_engine/policy.py +97 -0
  18. jude_prompt_engine-0.1.0/prompt_engine/presets.py +225 -0
  19. jude_prompt_engine-0.1.0/prompt_engine/retrieval.py +421 -0
  20. jude_prompt_engine-0.1.0/prompt_engine/schemas.py +130 -0
  21. jude_prompt_engine-0.1.0/prompt_engine/task.py +170 -0
  22. jude_prompt_engine-0.1.0/prompt_engine/taxonomy.py +181 -0
  23. jude_prompt_engine-0.1.0/prompt_engine/validator.py +167 -0
  24. jude_prompt_engine-0.1.0/pyproject.toml +45 -0
  25. jude_prompt_engine-0.1.0/setup.cfg +4 -0
  26. jude_prompt_engine-0.1.0/tests/test_retrieval.py +447 -0
  27. jude_prompt_engine-0.1.0/tests/test_schemas.py +322 -0
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: jude-prompt-engine
3
+ Version: 0.1.0
4
+ Summary: Deterministic prompt compiler and optimizer for AI-driven code analysis
5
+ Author-email: Aryan Walia <p0riya003@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/aryanwalia2003/jude
8
+ Project-URL: Repository, https://github.com/aryanwalia2003/jude
9
+ Project-URL: Issues, https://github.com/aryanwalia2003/jude/issues
10
+ Project-URL: Documentation, https://github.com/aryanwalia2003/jude/tree/main/prompt-engine
11
+ Keywords: prompt-engineering,ai-agents,code-analysis,deterministic
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: typer>=0.9
22
+ Requires-Dist: rich>=13
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7; extra == "dev"
25
+
26
+ # jude-prompt-engine
27
+
28
+ Deterministic prompt compiler and optimizer for AI-driven code analysis. Part of the Jude AI Infrastructure suite.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install jude-prompt-engine
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```bash
39
+ ai --help
40
+ ```
41
+
42
+ ## Features
43
+
44
+ - **Deterministic Compilation** — Reproducible prompt generation
45
+ - **Multi-mode Support** — strict, safe, deep modes for different use cases
46
+ - **Ranking & Context** — Deterministic symbol retrieval with audit trails
47
+ - **Output Validation** — Schema enforcement for structured outputs
48
+
49
+ ## Usage
50
+
51
+ ```bash
52
+ # Basic prompt
53
+ ai "debug why emit_sync is failing"
54
+
55
+ # With specific mode
56
+ ai --mode deep "analyze performance of scheduler"
57
+
58
+ # Custom preset
59
+ ai --preset code-review "check this function"
60
+ ```
61
+
62
+ ## Documentation
63
+
64
+ Full documentation is available in the [main repository](https://github.com/aryanwalia2003/jude).
@@ -0,0 +1,39 @@
1
+ # jude-prompt-engine
2
+
3
+ Deterministic prompt compiler and optimizer for AI-driven code analysis. Part of the Jude AI Infrastructure suite.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install jude-prompt-engine
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ ai --help
15
+ ```
16
+
17
+ ## Features
18
+
19
+ - **Deterministic Compilation** — Reproducible prompt generation
20
+ - **Multi-mode Support** — strict, safe, deep modes for different use cases
21
+ - **Ranking & Context** — Deterministic symbol retrieval with audit trails
22
+ - **Output Validation** — Schema enforcement for structured outputs
23
+
24
+ ## Usage
25
+
26
+ ```bash
27
+ # Basic prompt
28
+ ai "debug why emit_sync is failing"
29
+
30
+ # With specific mode
31
+ ai --mode deep "analyze performance of scheduler"
32
+
33
+ # Custom preset
34
+ ai --preset code-review "check this function"
35
+ ```
36
+
37
+ ## Documentation
38
+
39
+ Full documentation is available in the [main repository](https://github.com/aryanwalia2003/jude).
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: jude-prompt-engine
3
+ Version: 0.1.0
4
+ Summary: Deterministic prompt compiler and optimizer for AI-driven code analysis
5
+ Author-email: Aryan Walia <p0riya003@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/aryanwalia2003/jude
8
+ Project-URL: Repository, https://github.com/aryanwalia2003/jude
9
+ Project-URL: Issues, https://github.com/aryanwalia2003/jude/issues
10
+ Project-URL: Documentation, https://github.com/aryanwalia2003/jude/tree/main/prompt-engine
11
+ Keywords: prompt-engineering,ai-agents,code-analysis,deterministic
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: typer>=0.9
22
+ Requires-Dist: rich>=13
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7; extra == "dev"
25
+
26
+ # jude-prompt-engine
27
+
28
+ Deterministic prompt compiler and optimizer for AI-driven code analysis. Part of the Jude AI Infrastructure suite.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install jude-prompt-engine
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```bash
39
+ ai --help
40
+ ```
41
+
42
+ ## Features
43
+
44
+ - **Deterministic Compilation** — Reproducible prompt generation
45
+ - **Multi-mode Support** — strict, safe, deep modes for different use cases
46
+ - **Ranking & Context** — Deterministic symbol retrieval with audit trails
47
+ - **Output Validation** — Schema enforcement for structured outputs
48
+
49
+ ## Usage
50
+
51
+ ```bash
52
+ # Basic prompt
53
+ ai "debug why emit_sync is failing"
54
+
55
+ # With specific mode
56
+ ai --mode deep "analyze performance of scheduler"
57
+
58
+ # Custom preset
59
+ ai --preset code-review "check this function"
60
+ ```
61
+
62
+ ## Documentation
63
+
64
+ Full documentation is available in the [main repository](https://github.com/aryanwalia2003/jude).
@@ -0,0 +1,25 @@
1
+ README.md
2
+ pyproject.toml
3
+ jude_prompt_engine.egg-info/PKG-INFO
4
+ jude_prompt_engine.egg-info/SOURCES.txt
5
+ jude_prompt_engine.egg-info/dependency_links.txt
6
+ jude_prompt_engine.egg-info/entry_points.txt
7
+ jude_prompt_engine.egg-info/requires.txt
8
+ jude_prompt_engine.egg-info/top_level.txt
9
+ prompt_engine/__init__.py
10
+ prompt_engine/budget.py
11
+ prompt_engine/cli.py
12
+ prompt_engine/compiler.py
13
+ prompt_engine/config.py
14
+ prompt_engine/contracts.py
15
+ prompt_engine/intent.py
16
+ prompt_engine/output_serializer.py
17
+ prompt_engine/policy.py
18
+ prompt_engine/presets.py
19
+ prompt_engine/retrieval.py
20
+ prompt_engine/schemas.py
21
+ prompt_engine/task.py
22
+ prompt_engine/taxonomy.py
23
+ prompt_engine/validator.py
24
+ tests/test_retrieval.py
25
+ tests/test_schemas.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ai = prompt_engine.cli:app
@@ -0,0 +1,5 @@
1
+ typer>=0.9
2
+ rich>=13
3
+
4
+ [dev]
5
+ pytest>=7
@@ -0,0 +1,15 @@
1
+ """Deterministic prompt orchestration engine for AI-assisted coding."""
2
+
3
+ from .taxonomy import TaskType, SubType, Mode, Constraint, RiskLevel
4
+ from .task import Task, RetrievalPlan, PromptPlan, PromptBlock, VerificationPlan, ContextBudget
5
+ from .intent import classify, IntentResult
6
+ from .compiler import compile_task
7
+ from .config import load_config, EngineConfig
8
+
9
+ __all__ = [
10
+ "TaskType", "SubType", "Mode", "Constraint", "RiskLevel",
11
+ "Task", "RetrievalPlan", "PromptPlan", "PromptBlock", "VerificationPlan", "ContextBudget",
12
+ "classify", "IntentResult",
13
+ "compile_task",
14
+ "load_config", "EngineConfig",
15
+ ]
@@ -0,0 +1,85 @@
1
+ """Context budget management — token allocation and prioritization."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Optional
7
+
8
+ from .task import ContextBudget, PromptBlock, PromptPlan
9
+
10
+
11
+ _CHARS_PER_TOKEN = 4
12
+
13
+
14
+ def estimate_tokens(text: str) -> int:
15
+ return max(1, len(text) // _CHARS_PER_TOKEN)
16
+
17
+
18
+ @dataclass
19
+ class BudgetAllocation:
20
+ system_policy: int
21
+ task_block: int
22
+ constraints: int
23
+ context_placeholder: int
24
+ output_contract: int
25
+ verification: int
26
+
27
+ @property
28
+ def total(self) -> int:
29
+ return (
30
+ self.system_policy
31
+ + self.task_block
32
+ + self.constraints
33
+ + self.context_placeholder
34
+ + self.output_contract
35
+ + self.verification
36
+ )
37
+
38
+
39
+ def allocate(budget: ContextBudget) -> BudgetAllocation:
40
+ """Distribute token budget across prompt sections."""
41
+ total = budget.max_tokens
42
+ return BudgetAllocation(
43
+ system_policy=int(total * 0.08),
44
+ task_block=int(total * 0.05),
45
+ constraints=int(total * 0.10),
46
+ context_placeholder=int(total * 0.55), # largest — actual repo context
47
+ output_contract=int(total * 0.12),
48
+ verification=int(total * 0.10),
49
+ )
50
+
51
+
52
+ def enforce_budget(plan: PromptPlan) -> PromptPlan:
53
+ """Mark low-priority blocks as excluded if over budget."""
54
+ if not plan.budget:
55
+ return plan
56
+
57
+ max_tokens = plan.budget.max_tokens
58
+ included = sorted(
59
+ [b for b in plan.blocks if b.included],
60
+ key=lambda b: b.priority,
61
+ )
62
+ running = 0
63
+ for block in included:
64
+ if running + block.token_estimate > max_tokens:
65
+ block.included = False
66
+ block.omit_reason = f"budget exceeded ({running}/{max_tokens} used)"
67
+ else:
68
+ running += block.token_estimate
69
+
70
+ return plan
71
+
72
+
73
+ def compression_summary(plan: PromptPlan) -> list[str]:
74
+ """Describe what was included vs excluded and why."""
75
+ lines = []
76
+ for b in plan.blocks:
77
+ status = "✓" if b.included else "✗"
78
+ reason = f" [{b.omit_reason}]" if b.omit_reason else ""
79
+ lines.append(f" {status} {b.role:<22} ~{b.token_estimate:>4} tokens{reason}")
80
+ if plan.budget:
81
+ used = plan.total_tokens()
82
+ cap = plan.budget.max_tokens
83
+ pct = int(used / cap * 100)
84
+ lines.append(f"\n Total: {used}/{cap} tokens ({pct}%)")
85
+ return lines