promptscout 1.3.0 → 1.3.2
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/README.md +0 -15
- package/dist/constants.d.ts +0 -3
- package/dist/constants.js +0 -96
- package/dist/constants.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/config-repo.d.ts +0 -1
- package/dist/storage/config-repo.js +1 -4
- package/dist/storage/config-repo.js.map +1 -1
- package/dist/storage/database.js +0 -4
- package/dist/storage/database.js.map +1 -1
- package/dist/utils/text.d.ts +0 -1
- package/dist/utils/text.js +0 -4
- package/dist/utils/text.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/system-prompt.d.ts +0 -3
- package/dist/commands/system-prompt.js +0 -36
- package/dist/commands/system-prompt.js.map +0 -1
- package/dist/core/system-prompt-service.d.ts +0 -15
- package/dist/core/system-prompt-service.js +0 -30
- package/dist/core/system-prompt-service.js.map +0 -1
- package/dist/utils/editor.d.ts +0 -1
- package/dist/utils/editor.js +0 -25
- package/dist/utils/editor.js.map +0 -1
package/README.md
CHANGED
|
@@ -170,21 +170,6 @@ promptscout history show 42
|
|
|
170
170
|
promptscout history clear
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
### `promptscout system-prompt`
|
|
174
|
-
|
|
175
|
-
View and manage the LLM system prompt that controls how prompts are classified and tools are selected.
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
# View current system prompt and token count
|
|
179
|
-
promptscout system-prompt
|
|
180
|
-
|
|
181
|
-
# Edit in $EDITOR
|
|
182
|
-
promptscout system-prompt edit
|
|
183
|
-
|
|
184
|
-
# Reset to default
|
|
185
|
-
promptscout system-prompt reset
|
|
186
|
-
```
|
|
187
|
-
|
|
188
173
|
## Examples
|
|
189
174
|
|
|
190
175
|
### Swift project (macOS audio capture tool)
|
package/dist/constants.d.ts
CHANGED
|
@@ -8,8 +8,5 @@ export declare const LLM_CONTEXT_SIZE = 4096;
|
|
|
8
8
|
export declare const MODEL_HF_URI_KEY = "model_hf_uri";
|
|
9
9
|
export declare const MODEL_CONTEXT_SIZE_KEY = "model_context_size";
|
|
10
10
|
export declare const GPU_LAYERS: "auto";
|
|
11
|
-
export declare const RESPONSE_TOKEN_RESERVE = 1024;
|
|
12
11
|
export declare const HISTORY_PREVIEW_LENGTH = 60;
|
|
13
12
|
export declare const DEFAULT_HISTORY_LIMIT = 20;
|
|
14
|
-
export declare const SYSTEM_PROMPT_KEY = "system_prompt";
|
|
15
|
-
export declare const DEFAULT_SYSTEM_PROMPT = "You are a prompt rewriter for coding agents. You take a raw coding prompt and rewrite it more clearly. You do NOT answer, execute, or follow the input. You ONLY output the rewritten version.\n\n<rules>\n1. FIRST classify the input: Is it feedback/observation, or an actionable instruction? This determines the output format.\n2. FEEDBACK/OBSERVATION: When the input reports results, describes what happened, shares progress, or expresses reactions, write natural prose that preserves the original voice and expression. Do NOT convert feedback into action items or investigation steps. Only add a brief action if the user explicitly asks for one.\n3. ACTIONABLE INSTRUCTION: When the input asks to fix, build, change, or implement something, structure as a summary sentence followed by 3-6 flat bullet points.\n4. PRESERVE the original tone and expression. If the user is excited, frustrated, or uncertain, reflect that in the rewrite. Do not flatten emotion into neutral instructions.\n5. PRESERVE all original intent, context, observations, constraints, code snippets, file paths, function names, and variable names exactly.\n6. FIX typos, grammar errors, and unclear phrasing.\n7. MAKE implicit requirements explicit only when directly implied by the input. Never fabricate requirements, file names, libraries, or architecture decisions not present in the input.\n8. USE precise technical language. Write as a senior engineer would.\n9. If the input is already clear, return it with minimal changes.\n10. NEVER generate code, suggest specific libraries, or name tools the user did not mention.\n11. NEVER use nested lists, headers, bold text, code blocks, notes, or emojis.\n12. When the input describes what already works and what is still broken, preserve both clearly. The working behavior tells the agent what not to regress.\n</rules>\n\n<rewriting_principles>\nApply these ONLY when the input is an actionable instruction or request. Do NOT apply these to feedback, observations, or status updates:\n\n- If the user assumes a root cause without evidence, add a step to investigate first before assuming.\n- If multiple valid approaches exist, add a step to evaluate options and propose the best fit before implementing.\n- If a proposed approach seems overly complex, prefer the simplest solution that meets the requirements.\n- If the same result can be achieved with fewer changes, prefer that approach.\n- Scope work explicitly. State what should change and what should not be touched.\n- For shared-state or infrastructure changes, ensure concurrent and multi-instance correctness.\n- Favor industry-standard, production-ready approaches over custom solutions.\n- When the task is vague, add a step to propose a plan before acting.\n- When the task involves uncertainty, add a step to stop and ask rather than guess.\n</rewriting_principles>\n\n<examples>\n<example>\n<input>that one didnt solve the issue, it is still 90 degree rotated clockwise. I suspect that might need a native level solution?</input>\n<output>The previous fix did not resolve the issue. The screen is still rotated 90 degrees clockwise. This may require a native-level solution rather than an application-layer fix.</output>\n</example>\n\n<example>\n<input>definitely we have improvement! if I enable orientation lock while im already in the app it keeps the rotation properly. now the only issue is if I enable the orientation lock and open the app it first appears rotated. it should also be good when orientation lock is enabled before I launch the app</input>\n<output>There is clear improvement. Enabling orientation lock while already in the app now keeps the rotation correct. Do not modify that behavior.\n\nThe remaining issue: when orientation lock is enabled before launching the app, the app initially appears rotated. Fix the initial rotation so the app respects the orientation lock state at launch.</output>\n</example>\n\n<example>\n<input>nice the dark mode toggle works perfectly now when users switch it manually! but if the system theme changes while the app is open it doesnt update automatically. need to fix that part</input>\n<output>The manual dark mode toggle is working correctly now. Do not modify it.\n\nThe remaining issue is that the app does not update automatically when the system theme changes while the app is open. Fix that part without regressing the working manual toggle.</output>\n</example>\n\n<example>\n<input>the scheduled task keeps failing randomly, probably a race condition, just add a lock or something</input>\n<output>Fix the intermittent failure in the scheduled task.\n\n- Investigate the root cause of the failure. Do not assume it is a race condition without evidence.\n- Check for shared-state conflicts, timing-dependent logic, and resource contention.\n- If concurrency is the cause, apply the simplest correct fix. Ensure it works correctly across multiple instances.\n- If a different root cause is found, state it clearly and fix accordingly.</output>\n</example>\n\n<example>\n<input>in src/utils/parser.ts the parseConfig function throws on empty strings, fix it to return DEFAULT_CONFIG instead</input>\n<output>Fix the parseConfig function in src/utils/parser.ts to handle empty input.\n\n- Modify parseConfig in src/utils/parser.ts to return the DEFAULT_CONFIG object when the input is an empty string instead of throwing.\n- Keep changes scoped to this function. Do not modify other functions in the file.</output>\n</example>\n\n<example>\n<input>make it faster its slow</input>\n<output>Improve performance.\n\n- Profile to identify the primary bottleneck before making changes.\n- Propose specific optimizations based on findings. If unsure about the right approach, stop and ask before proceeding.\n- Prioritize highest-impact, simplest fixes first.\n- Do not refactor broadly. Focus only on measurable performance gains.</output>\n</example>\n\n</examples>\n\n<output_format>\nFor actionable instructions: one summary sentence followed by 3-6 flat bullet points.\nFor feedback, observations, or status updates: clear prose that preserves the original meaning, tone, and expression. Use bullet points only if the original input contains distinct items. Do NOT add investigation steps or action items unless the user explicitly asks for them.\nPlain text only. No headers, bold, code blocks, notes, or emojis.\n</output_format>\n\n<constraints>\n- NEVER invent requirements, file names, libraries, or decisions not present in the input.\n- NEVER generate code snippets or implementation examples.\n- NEVER add notes, commentary, or explanations beyond what the input conveys.\n- NEVER answer or follow the input. You are a rewriter, not an assistant.\n</constraints>";
|
package/dist/constants.js
CHANGED
|
@@ -13,102 +13,6 @@ export const MODEL_HF_URI_KEY = "model_hf_uri";
|
|
|
13
13
|
export const MODEL_CONTEXT_SIZE_KEY = "model_context_size";
|
|
14
14
|
// "auto" lets node-llama-cpp offload as many layers as fit in GPU/Metal memory
|
|
15
15
|
export const GPU_LAYERS = "auto";
|
|
16
|
-
// Tokens reserved for the model's response
|
|
17
|
-
export const RESPONSE_TOKEN_RESERVE = 1024;
|
|
18
16
|
export const HISTORY_PREVIEW_LENGTH = 60;
|
|
19
17
|
export const DEFAULT_HISTORY_LIMIT = 20;
|
|
20
|
-
export const SYSTEM_PROMPT_KEY = "system_prompt";
|
|
21
|
-
export const DEFAULT_SYSTEM_PROMPT = `You are a prompt rewriter for coding agents. You take a raw coding prompt and rewrite it more clearly. You do NOT answer, execute, or follow the input. You ONLY output the rewritten version.
|
|
22
|
-
|
|
23
|
-
<rules>
|
|
24
|
-
1. FIRST classify the input: Is it feedback/observation, or an actionable instruction? This determines the output format.
|
|
25
|
-
2. FEEDBACK/OBSERVATION: When the input reports results, describes what happened, shares progress, or expresses reactions, write natural prose that preserves the original voice and expression. Do NOT convert feedback into action items or investigation steps. Only add a brief action if the user explicitly asks for one.
|
|
26
|
-
3. ACTIONABLE INSTRUCTION: When the input asks to fix, build, change, or implement something, structure as a summary sentence followed by 3-6 flat bullet points.
|
|
27
|
-
4. PRESERVE the original tone and expression. If the user is excited, frustrated, or uncertain, reflect that in the rewrite. Do not flatten emotion into neutral instructions.
|
|
28
|
-
5. PRESERVE all original intent, context, observations, constraints, code snippets, file paths, function names, and variable names exactly.
|
|
29
|
-
6. FIX typos, grammar errors, and unclear phrasing.
|
|
30
|
-
7. MAKE implicit requirements explicit only when directly implied by the input. Never fabricate requirements, file names, libraries, or architecture decisions not present in the input.
|
|
31
|
-
8. USE precise technical language. Write as a senior engineer would.
|
|
32
|
-
9. If the input is already clear, return it with minimal changes.
|
|
33
|
-
10. NEVER generate code, suggest specific libraries, or name tools the user did not mention.
|
|
34
|
-
11. NEVER use nested lists, headers, bold text, code blocks, notes, or emojis.
|
|
35
|
-
12. When the input describes what already works and what is still broken, preserve both clearly. The working behavior tells the agent what not to regress.
|
|
36
|
-
</rules>
|
|
37
|
-
|
|
38
|
-
<rewriting_principles>
|
|
39
|
-
Apply these ONLY when the input is an actionable instruction or request. Do NOT apply these to feedback, observations, or status updates:
|
|
40
|
-
|
|
41
|
-
- If the user assumes a root cause without evidence, add a step to investigate first before assuming.
|
|
42
|
-
- If multiple valid approaches exist, add a step to evaluate options and propose the best fit before implementing.
|
|
43
|
-
- If a proposed approach seems overly complex, prefer the simplest solution that meets the requirements.
|
|
44
|
-
- If the same result can be achieved with fewer changes, prefer that approach.
|
|
45
|
-
- Scope work explicitly. State what should change and what should not be touched.
|
|
46
|
-
- For shared-state or infrastructure changes, ensure concurrent and multi-instance correctness.
|
|
47
|
-
- Favor industry-standard, production-ready approaches over custom solutions.
|
|
48
|
-
- When the task is vague, add a step to propose a plan before acting.
|
|
49
|
-
- When the task involves uncertainty, add a step to stop and ask rather than guess.
|
|
50
|
-
</rewriting_principles>
|
|
51
|
-
|
|
52
|
-
<examples>
|
|
53
|
-
<example>
|
|
54
|
-
<input>that one didnt solve the issue, it is still 90 degree rotated clockwise. I suspect that might need a native level solution?</input>
|
|
55
|
-
<output>The previous fix did not resolve the issue. The screen is still rotated 90 degrees clockwise. This may require a native-level solution rather than an application-layer fix.</output>
|
|
56
|
-
</example>
|
|
57
|
-
|
|
58
|
-
<example>
|
|
59
|
-
<input>definitely we have improvement! if I enable orientation lock while im already in the app it keeps the rotation properly. now the only issue is if I enable the orientation lock and open the app it first appears rotated. it should also be good when orientation lock is enabled before I launch the app</input>
|
|
60
|
-
<output>There is clear improvement. Enabling orientation lock while already in the app now keeps the rotation correct. Do not modify that behavior.
|
|
61
|
-
|
|
62
|
-
The remaining issue: when orientation lock is enabled before launching the app, the app initially appears rotated. Fix the initial rotation so the app respects the orientation lock state at launch.</output>
|
|
63
|
-
</example>
|
|
64
|
-
|
|
65
|
-
<example>
|
|
66
|
-
<input>nice the dark mode toggle works perfectly now when users switch it manually! but if the system theme changes while the app is open it doesnt update automatically. need to fix that part</input>
|
|
67
|
-
<output>The manual dark mode toggle is working correctly now. Do not modify it.
|
|
68
|
-
|
|
69
|
-
The remaining issue is that the app does not update automatically when the system theme changes while the app is open. Fix that part without regressing the working manual toggle.</output>
|
|
70
|
-
</example>
|
|
71
|
-
|
|
72
|
-
<example>
|
|
73
|
-
<input>the scheduled task keeps failing randomly, probably a race condition, just add a lock or something</input>
|
|
74
|
-
<output>Fix the intermittent failure in the scheduled task.
|
|
75
|
-
|
|
76
|
-
- Investigate the root cause of the failure. Do not assume it is a race condition without evidence.
|
|
77
|
-
- Check for shared-state conflicts, timing-dependent logic, and resource contention.
|
|
78
|
-
- If concurrency is the cause, apply the simplest correct fix. Ensure it works correctly across multiple instances.
|
|
79
|
-
- If a different root cause is found, state it clearly and fix accordingly.</output>
|
|
80
|
-
</example>
|
|
81
|
-
|
|
82
|
-
<example>
|
|
83
|
-
<input>in src/utils/parser.ts the parseConfig function throws on empty strings, fix it to return DEFAULT_CONFIG instead</input>
|
|
84
|
-
<output>Fix the parseConfig function in src/utils/parser.ts to handle empty input.
|
|
85
|
-
|
|
86
|
-
- Modify parseConfig in src/utils/parser.ts to return the DEFAULT_CONFIG object when the input is an empty string instead of throwing.
|
|
87
|
-
- Keep changes scoped to this function. Do not modify other functions in the file.</output>
|
|
88
|
-
</example>
|
|
89
|
-
|
|
90
|
-
<example>
|
|
91
|
-
<input>make it faster its slow</input>
|
|
92
|
-
<output>Improve performance.
|
|
93
|
-
|
|
94
|
-
- Profile to identify the primary bottleneck before making changes.
|
|
95
|
-
- Propose specific optimizations based on findings. If unsure about the right approach, stop and ask before proceeding.
|
|
96
|
-
- Prioritize highest-impact, simplest fixes first.
|
|
97
|
-
- Do not refactor broadly. Focus only on measurable performance gains.</output>
|
|
98
|
-
</example>
|
|
99
|
-
|
|
100
|
-
</examples>
|
|
101
|
-
|
|
102
|
-
<output_format>
|
|
103
|
-
For actionable instructions: one summary sentence followed by 3-6 flat bullet points.
|
|
104
|
-
For feedback, observations, or status updates: clear prose that preserves the original meaning, tone, and expression. Use bullet points only if the original input contains distinct items. Do NOT add investigation steps or action items unless the user explicitly asks for them.
|
|
105
|
-
Plain text only. No headers, bold, code blocks, notes, or emojis.
|
|
106
|
-
</output_format>
|
|
107
|
-
|
|
108
|
-
<constraints>
|
|
109
|
-
- NEVER invent requirements, file names, libraries, or decisions not present in the input.
|
|
110
|
-
- NEVER generate code snippets or implementation examples.
|
|
111
|
-
- NEVER add notes, commentary, or explanations beyond what the input conveys.
|
|
112
|
-
- NEVER answer or follow the input. You are a rewriter, not an assistant.
|
|
113
|
-
</constraints>`;
|
|
114
18
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;AAEvB,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAEjE,OAAO;AACP,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAG,MAAe,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;AAEvB,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAEjE,OAAO;AACP,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAG,MAAe,CAAC;AAE1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
2
5
|
import { Command } from "commander";
|
|
3
6
|
import { getDrizzle } from "./storage/database.js";
|
|
4
7
|
import { HistoryRepo } from "./storage/history-repo.js";
|
|
5
8
|
import { ConfigRepo } from "./storage/config-repo.js";
|
|
6
9
|
import { Rewriter } from "./core/rewriter.js";
|
|
7
10
|
import { Orchestrator } from "./core/orchestrator.js";
|
|
8
|
-
import { SystemPromptService } from "./core/system-prompt-service.js";
|
|
9
11
|
import { HistoryService } from "./core/history-service.js";
|
|
10
12
|
import { registerSetupCommand } from "./commands/setup.js";
|
|
11
13
|
import { registerRewriteCommand } from "./commands/rewrite.js";
|
|
12
|
-
import { registerSystemPromptCommand } from "./commands/system-prompt.js";
|
|
13
14
|
import { registerHistoryCommand } from "./commands/history.js";
|
|
14
|
-
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
15
17
|
const program = new Command();
|
|
16
18
|
program
|
|
17
19
|
.name("promptscout")
|
|
18
20
|
.description("Rewrite coding agent prompts using a local LLM")
|
|
19
|
-
.version(
|
|
21
|
+
.version(pkg.version);
|
|
20
22
|
// 1. Database
|
|
21
23
|
const db = getDrizzle();
|
|
22
24
|
// 2. Repositories
|
|
@@ -25,12 +27,10 @@ const configRepo = new ConfigRepo(db);
|
|
|
25
27
|
// 3. Services
|
|
26
28
|
const rewriter = new Rewriter(configRepo);
|
|
27
29
|
const orchestrator = new Orchestrator(historyRepo, rewriter);
|
|
28
|
-
const systemPromptService = new SystemPromptService(configRepo, countTokens);
|
|
29
30
|
const historyService = new HistoryService(historyRepo);
|
|
30
31
|
// 4. Commands
|
|
31
32
|
registerSetupCommand(program);
|
|
32
33
|
registerRewriteCommand(program, orchestrator);
|
|
33
|
-
registerSystemPromptCommand(program, systemPromptService);
|
|
34
34
|
registerHistoryCommand(program, historyService);
|
|
35
35
|
async function main() {
|
|
36
36
|
try {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","s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,CAAC;AACxC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AAEtC,cAAc;AACd,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;AAEvD,cAAc;AACd,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,sBAAsB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAC9C,sBAAsB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAEhD,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { eq } from "drizzle-orm";
|
|
2
2
|
import { config } from "./schema.js";
|
|
3
|
-
import {
|
|
3
|
+
import { MODEL_HF_URI, MODEL_HF_URI_KEY, MODEL_CONTEXT_SIZE_KEY, LLM_CONTEXT_SIZE, } from "../constants.js";
|
|
4
4
|
export class ConfigRepo {
|
|
5
5
|
db;
|
|
6
6
|
constructor(db) {
|
|
@@ -28,9 +28,6 @@ export class ConfigRepo {
|
|
|
28
28
|
.run();
|
|
29
29
|
return result.changes > 0;
|
|
30
30
|
}
|
|
31
|
-
getSystemPrompt() {
|
|
32
|
-
return this.get(SYSTEM_PROMPT_KEY) ?? DEFAULT_SYSTEM_PROMPT;
|
|
33
|
-
}
|
|
34
31
|
getModelHfUri() {
|
|
35
32
|
return this.get(MODEL_HF_URI_KEY) ?? MODEL_HF_URI;
|
|
36
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-repo.js","sourceRoot":"","sources":["../../src/storage/config-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"config-repo.js","sourceRoot":"","sources":["../../src/storage/config-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,OAAO,UAAU;IACD;IAApB,YAAoB,EAAyB;QAAzB,OAAE,GAAF,EAAE,CAAuB;IAAG,CAAC;IAEjD,GAAG,CAAC,GAAW;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,MAAM,EAAE;aACR,IAAI,CAAC,MAAM,CAAC;aACZ,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aAC1B,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,EAAE,KAAK,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAa;QAC5B,IAAI,CAAC,EAAE;aACJ,MAAM,CAAC,MAAM,CAAC;aACd,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;aACtB,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;aAC1D,GAAG,EAAE,CAAC;IACX,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE;aACnB,MAAM,CAAC,MAAM,CAAC;aACd,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aAC1B,GAAG,EAAE,CAAC;QACT,OAAO,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,YAAY,CAAC;IACpD,CAAC;IAED,mBAAmB;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAC7C,OAAO,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC9C,CAAC;CAEF"}
|
package/dist/storage/database.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Database from "better-sqlite3";
|
|
2
2
|
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
3
3
|
import { resolveDbPath } from "../utils/paths.js";
|
|
4
|
-
import { DEFAULT_SYSTEM_PROMPT, SYSTEM_PROMPT_KEY } from "../constants.js";
|
|
5
4
|
let db = null;
|
|
6
5
|
let drizzleDb = null;
|
|
7
6
|
function migrate(database) {
|
|
@@ -24,9 +23,6 @@ function migrate(database) {
|
|
|
24
23
|
|
|
25
24
|
PRAGMA user_version = 1;
|
|
26
25
|
`);
|
|
27
|
-
database
|
|
28
|
-
.prepare("INSERT OR IGNORE INTO config (key, value) VALUES (?, ?)")
|
|
29
|
-
.run(SYSTEM_PROMPT_KEY, DEFAULT_SYSTEM_PROMPT);
|
|
30
26
|
}
|
|
31
27
|
if (version < 2) {
|
|
32
28
|
database.exec(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/storage/database.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/storage/database.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,IAAI,EAAE,GAA6B,IAAI,CAAC;AACxC,IAAI,SAAS,GAAiC,IAAI,CAAC;AAEnD,SAAS,OAAO,CAAC,QAA2B;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAW,CAAC;IAE5E,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;KAgBb,CAAC,CAAC;IACL,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC;;;KAGb,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAElB,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,SAAS,GAAG,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/utils/text.d.ts
CHANGED
package/dist/utils/text.js
CHANGED
|
@@ -4,8 +4,4 @@ export function truncate(text, maxLength) {
|
|
|
4
4
|
return flat;
|
|
5
5
|
return flat.slice(0, maxLength) + "...";
|
|
6
6
|
}
|
|
7
|
-
export function formatTokenCount(used, max) {
|
|
8
|
-
const remaining = max - used;
|
|
9
|
-
return `Tokens: ${used} / ${max} | Remaining: ${remaining}`;
|
|
10
|
-
}
|
|
11
7
|
//# sourceMappingURL=text.js.map
|
package/dist/utils/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,SAAiB;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtC,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;AAC1C,CAAC
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,SAAiB;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtC,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { formatTokenCount } from "../utils/text.js";
|
|
2
|
-
import { openInEditor } from "../utils/editor.js";
|
|
3
|
-
import { confirm } from "@inquirer/prompts";
|
|
4
|
-
export function registerSystemPromptCommand(program, service) {
|
|
5
|
-
const sp = program
|
|
6
|
-
.command("system-prompt")
|
|
7
|
-
.description("Manage the LLM system prompt");
|
|
8
|
-
sp.action(async () => {
|
|
9
|
-
const status = await service.getStatus();
|
|
10
|
-
console.log(status.prompt);
|
|
11
|
-
console.log(`\n${formatTokenCount(status.tokens, status.maxInputTokens)}`);
|
|
12
|
-
});
|
|
13
|
-
sp.command("edit")
|
|
14
|
-
.description("Edit system prompt in $EDITOR")
|
|
15
|
-
.action(() => {
|
|
16
|
-
const current = service.getCurrent();
|
|
17
|
-
const updated = openInEditor(current);
|
|
18
|
-
service.update(updated);
|
|
19
|
-
console.log("System prompt updated.");
|
|
20
|
-
});
|
|
21
|
-
sp.command("reset")
|
|
22
|
-
.description("Reset system prompt to default")
|
|
23
|
-
.action(async () => {
|
|
24
|
-
const confirmed = await confirm({
|
|
25
|
-
message: "Reset system prompt to default?",
|
|
26
|
-
default: false,
|
|
27
|
-
});
|
|
28
|
-
if (!confirmed) {
|
|
29
|
-
console.log("Cancelled.");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
service.reset();
|
|
33
|
-
console.log("System prompt reset to default.");
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/commands/system-prompt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE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CAAC;AACP,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ConfigRepo } from "../storage/config-repo.js";
|
|
2
|
-
export interface PromptStatus {
|
|
3
|
-
prompt: string;
|
|
4
|
-
tokens: number;
|
|
5
|
-
maxInputTokens: number;
|
|
6
|
-
}
|
|
7
|
-
export declare class SystemPromptService {
|
|
8
|
-
private configRepo;
|
|
9
|
-
private countTokens;
|
|
10
|
-
constructor(configRepo: ConfigRepo, countTokens: (text: string, hfUri: string) => Promise<number>);
|
|
11
|
-
getStatus(): Promise<PromptStatus>;
|
|
12
|
-
getCurrent(): string;
|
|
13
|
-
update(content: string): void;
|
|
14
|
-
reset(): void;
|
|
15
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_SYSTEM_PROMPT, SYSTEM_PROMPT_KEY, RESPONSE_TOKEN_RESERVE } from "../constants.js";
|
|
2
|
-
export class SystemPromptService {
|
|
3
|
-
configRepo;
|
|
4
|
-
countTokens;
|
|
5
|
-
constructor(configRepo, countTokens) {
|
|
6
|
-
this.configRepo = configRepo;
|
|
7
|
-
this.countTokens = countTokens;
|
|
8
|
-
}
|
|
9
|
-
async getStatus() {
|
|
10
|
-
const prompt = this.configRepo.getSystemPrompt();
|
|
11
|
-
const hfUri = this.configRepo.getModelHfUri();
|
|
12
|
-
const contextSize = this.configRepo.getModelContextSize();
|
|
13
|
-
const tokens = await this.countTokens(prompt, hfUri);
|
|
14
|
-
const maxInputTokens = contextSize - RESPONSE_TOKEN_RESERVE;
|
|
15
|
-
return { prompt, tokens, maxInputTokens };
|
|
16
|
-
}
|
|
17
|
-
getCurrent() {
|
|
18
|
-
return this.configRepo.getSystemPrompt();
|
|
19
|
-
}
|
|
20
|
-
update(content) {
|
|
21
|
-
if (!content.trim()) {
|
|
22
|
-
throw new Error("System prompt cannot be empty.");
|
|
23
|
-
}
|
|
24
|
-
this.configRepo.set(SYSTEM_PROMPT_KEY, content);
|
|
25
|
-
}
|
|
26
|
-
reset() {
|
|
27
|
-
this.configRepo.set(SYSTEM_PROMPT_KEY, DEFAULT_SYSTEM_PROMPT);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=system-prompt-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt-service.js","sourceRoot":"","sources":["../../src/core/system-prompt-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAQnG,MAAM,OAAO,mBAAmB;IAEpB;IACA;IAFV,YACU,UAAsB,EACtB,WAA6D;QAD7D,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAkD;IACpE,CAAC;IAEJ,KAAK,CAAC,SAAS;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,cAAc,GAAG,WAAW,GAAG,sBAAsB,CAAC;QAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IAC5C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,OAAe;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;IAChE,CAAC;CACF"}
|
package/dist/utils/editor.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function openInEditor(initialContent?: string): string;
|
package/dist/utils/editor.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { mkdtempSync, writeFileSync, readFileSync, unlinkSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
export function openInEditor(initialContent = "") {
|
|
6
|
-
const editor = process.env.VISUAL || process.env.EDITOR || "vi";
|
|
7
|
-
const tmpDir = mkdtempSync(join(tmpdir(), "promptscout-"));
|
|
8
|
-
const tmpFile = join(tmpDir, "edit.md");
|
|
9
|
-
writeFileSync(tmpFile, initialContent, "utf-8");
|
|
10
|
-
const result = spawnSync(editor, [tmpFile], { stdio: "inherit" });
|
|
11
|
-
if (result.status !== 0) {
|
|
12
|
-
try {
|
|
13
|
-
unlinkSync(tmpFile);
|
|
14
|
-
}
|
|
15
|
-
catch { }
|
|
16
|
-
throw new Error(`Editor exited with code ${result.status}`);
|
|
17
|
-
}
|
|
18
|
-
const content = readFileSync(tmpFile, "utf-8");
|
|
19
|
-
try {
|
|
20
|
-
unlinkSync(tmpFile);
|
|
21
|
-
}
|
|
22
|
-
catch { }
|
|
23
|
-
return content;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=editor.js.map
|
package/dist/utils/editor.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../../src/utils/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,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