karajan-code 1.32.0 → 1.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/orchestrator.js
CHANGED
|
@@ -36,6 +36,7 @@ import { runTesterStage, runSecurityStage, runImpeccableStage, runFinalAuditStag
|
|
|
36
36
|
import { waitForCooldown, MAX_STANDBY_RETRIES } from "./orchestrator/standby.js";
|
|
37
37
|
import { detectTestFramework } from "./utils/project-detect.js";
|
|
38
38
|
import { runPreflightChecks } from "./orchestrator/preflight-checks.js";
|
|
39
|
+
import { detectRtk } from "./utils/rtk-detect.js";
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
// --- Extracted helper functions (pure refactoring, zero behavior change) ---
|
|
@@ -70,8 +71,8 @@ async function handleDryRun({ task, config, flags, emitter, pipelineFlags }) {
|
|
|
70
71
|
const projectDir = config.projectDir || process.cwd();
|
|
71
72
|
const { rules: reviewRules } = await resolveReviewProfile({ mode: config.review_mode, projectDir });
|
|
72
73
|
const coderRules = await loadFirstExisting(resolveRoleMdPath("coder", projectDir));
|
|
73
|
-
const coderPrompt = buildCoderPrompt({ task, coderRules, methodology: config.development?.methodology, serenaEnabled: Boolean(config.serena?.enabled) });
|
|
74
|
-
const reviewerPrompt = buildReviewerPrompt({ task, diff: "(dry-run: no diff)", reviewRules, mode: config.review_mode, serenaEnabled: Boolean(config.serena?.enabled) });
|
|
74
|
+
const coderPrompt = buildCoderPrompt({ task, coderRules, methodology: config.development?.methodology, serenaEnabled: Boolean(config.serena?.enabled), rtkAvailable: Boolean(config.rtk?.available) });
|
|
75
|
+
const reviewerPrompt = buildReviewerPrompt({ task, diff: "(dry-run: no diff)", reviewRules, mode: config.review_mode, serenaEnabled: Boolean(config.serena?.enabled), rtkAvailable: Boolean(config.rtk?.available) });
|
|
75
76
|
|
|
76
77
|
const summary = {
|
|
77
78
|
dry_run: true,
|
|
@@ -1087,6 +1088,17 @@ async function initFlowContext({ task, config, logger, emitter, askQuestion, pgT
|
|
|
1087
1088
|
ctx.budgetSummary = budgetSummary;
|
|
1088
1089
|
ctx.trackBudget = trackBudget;
|
|
1089
1090
|
|
|
1091
|
+
// --- RTK detection ---
|
|
1092
|
+
const rtkResult = await detectRtk();
|
|
1093
|
+
if (rtkResult.available) {
|
|
1094
|
+
config = { ...config, rtk: { available: true, version: rtkResult.version } };
|
|
1095
|
+
logger.info(`RTK detected (${rtkResult.version}) — instructing agents to prefix Bash commands with rtk`);
|
|
1096
|
+
emitProgress(emitter, makeEvent("rtk:detected", ctx.eventBase, {
|
|
1097
|
+
message: "RTK detected — agent commands will use token optimization",
|
|
1098
|
+
detail: { version: rtkResult.version }
|
|
1099
|
+
}));
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1090
1102
|
ctx.session = await initializeSession({ task, config, flags, pgTaskId, pgProject });
|
|
1091
1103
|
ctx.eventBase.sessionId = ctx.session.id;
|
|
1092
1104
|
|
package/src/prompts/coder.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RTK_INSTRUCTIONS } from "./rtk-snippet.js";
|
|
2
|
+
|
|
1
3
|
const SUBAGENT_PREAMBLE = [
|
|
2
4
|
"IMPORTANT: You are running as a Karajan sub-agent.",
|
|
3
5
|
"Do NOT ask about using Karajan, do NOT mention Karajan, do NOT suggest orchestration.",
|
|
@@ -29,7 +31,7 @@ const SERENA_INSTRUCTIONS = [
|
|
|
29
31
|
"Fall back to reading files only when Serena tools are not sufficient."
|
|
30
32
|
].join("\n");
|
|
31
33
|
|
|
32
|
-
export function buildCoderPrompt({ task, reviewerFeedback = null, sonarSummary = null, coderRules = null, methodology = "tdd", serenaEnabled = false, deferredContext = null }) {
|
|
34
|
+
export function buildCoderPrompt({ task, reviewerFeedback = null, sonarSummary = null, coderRules = null, methodology = "tdd", serenaEnabled = false, rtkAvailable = false, deferredContext = null }) {
|
|
33
35
|
const sections = [
|
|
34
36
|
serenaEnabled ? SUBAGENT_PREAMBLE_SERENA : SUBAGENT_PREAMBLE,
|
|
35
37
|
`Task:\n${task}`,
|
|
@@ -42,6 +44,10 @@ export function buildCoderPrompt({ task, reviewerFeedback = null, sonarSummary =
|
|
|
42
44
|
sections.push(SERENA_INSTRUCTIONS);
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
if (rtkAvailable) {
|
|
48
|
+
sections.push(RTK_INSTRUCTIONS);
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
if (coderRules) {
|
|
46
52
|
sections.push(`Coder rules (MUST follow):\n${coderRules}`);
|
|
47
53
|
}
|
package/src/prompts/reviewer.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RTK_INSTRUCTIONS } from "./rtk-snippet.js";
|
|
2
|
+
|
|
1
3
|
const SUBAGENT_PREAMBLE = [
|
|
2
4
|
"IMPORTANT: You are running as a Karajan sub-agent.",
|
|
3
5
|
"Do NOT ask about using Karajan, do NOT mention Karajan, do NOT suggest orchestration.",
|
|
@@ -20,7 +22,7 @@ const SERENA_INSTRUCTIONS = [
|
|
|
20
22
|
"Fall back to reading files only when Serena tools are not sufficient."
|
|
21
23
|
].join("\n");
|
|
22
24
|
|
|
23
|
-
export function buildReviewerPrompt({ task, diff, reviewRules, mode, serenaEnabled = false }) {
|
|
25
|
+
export function buildReviewerPrompt({ task, diff, reviewRules, mode, serenaEnabled = false, rtkAvailable = false }) {
|
|
24
26
|
const truncatedDiff = diff.length > 12000 ? `${diff.slice(0, 12000)}\n\n[TRUNCATED]` : diff;
|
|
25
27
|
|
|
26
28
|
const sections = [
|
|
@@ -37,6 +39,10 @@ export function buildReviewerPrompt({ task, diff, reviewRules, mode, serenaEnabl
|
|
|
37
39
|
sections.push(SERENA_INSTRUCTIONS);
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
if (rtkAvailable) {
|
|
43
|
+
sections.push(RTK_INSTRUCTIONS);
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
sections.push(
|
|
41
47
|
`Task context:\n${task}`,
|
|
42
48
|
`Review rules:\n${reviewRules}`,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RTK (Rust Token Killer) prompt instruction snippet.
|
|
3
|
+
* Injected into coder/reviewer prompts when RTK is detected.
|
|
4
|
+
*/
|
|
5
|
+
export const RTK_INSTRUCTIONS = [
|
|
6
|
+
"## Token Optimization (RTK detected)",
|
|
7
|
+
"RTK is installed. Prefix ALL Bash tool calls with `rtk` to reduce token usage:",
|
|
8
|
+
"- Use `rtk git status` instead of `git status`",
|
|
9
|
+
"- Use `rtk git diff` instead of `git diff`",
|
|
10
|
+
"- Use `rtk ls` instead of `ls`",
|
|
11
|
+
"- Use `rtk find` instead of `find`",
|
|
12
|
+
"- Use `rtk grep` instead of `grep`",
|
|
13
|
+
"- Use `rtk cat` instead of `cat`",
|
|
14
|
+
"This does NOT apply to non-Bash tools (Read, Write, Edit, Glob, Grep)."
|
|
15
|
+
].join("\n");
|
package/src/roles/coder-role.js
CHANGED
|
@@ -41,7 +41,8 @@ export class CoderRole extends BaseRole {
|
|
|
41
41
|
deferredContext: deferredContext || null,
|
|
42
42
|
coderRules: this.instructions,
|
|
43
43
|
methodology: this.config?.development?.methodology || "tdd",
|
|
44
|
-
serenaEnabled: Boolean(this.config?.serena?.enabled)
|
|
44
|
+
serenaEnabled: Boolean(this.config?.serena?.enabled),
|
|
45
|
+
rtkAvailable: Boolean(this.config?.rtk?.available)
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
const coderArgs = { prompt, role: "coder" };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseRole } from "./base-role.js";
|
|
2
2
|
import { createAgent as defaultCreateAgent } from "../agents/index.js";
|
|
3
|
+
import { RTK_INSTRUCTIONS } from "../prompts/rtk-snippet.js";
|
|
3
4
|
|
|
4
5
|
const MAX_DIFF_LENGTH = 12000;
|
|
5
6
|
|
|
@@ -24,7 +25,7 @@ function truncateDiff(diff) {
|
|
|
24
25
|
: diff;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function buildPrompt({ task, diff, reviewRules, reviewMode, instructions }) {
|
|
28
|
+
function buildPrompt({ task, diff, reviewRules, reviewMode, instructions, rtkAvailable = false }) {
|
|
28
29
|
const sections = [];
|
|
29
30
|
|
|
30
31
|
sections.push(SUBAGENT_PREAMBLE);
|
|
@@ -41,6 +42,10 @@ function buildPrompt({ task, diff, reviewRules, reviewMode, instructions }) {
|
|
|
41
42
|
`Task context:\n${task}`
|
|
42
43
|
);
|
|
43
44
|
|
|
45
|
+
if (rtkAvailable) {
|
|
46
|
+
sections.push(RTK_INSTRUCTIONS);
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
if (reviewRules) {
|
|
45
50
|
sections.push(`Review rules:\n${reviewRules}`);
|
|
46
51
|
}
|
|
@@ -78,7 +83,8 @@ export class ReviewerRole extends BaseRole {
|
|
|
78
83
|
diff: diff || "",
|
|
79
84
|
reviewRules: reviewRules || null,
|
|
80
85
|
reviewMode: this.config?.review_mode || "standard",
|
|
81
|
-
instructions: this.instructions
|
|
86
|
+
instructions: this.instructions,
|
|
87
|
+
rtkAvailable: Boolean(this.config?.rtk?.available)
|
|
82
88
|
});
|
|
83
89
|
|
|
84
90
|
const reviewArgs = { prompt, role: "reviewer" };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { runCommand } from "./process.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Detect whether RTK (Rust Token Killer) is installed and available.
|
|
5
|
+
* @returns {Promise<{ available: boolean, version: string|null }>}
|
|
6
|
+
*/
|
|
7
|
+
export async function detectRtk() {
|
|
8
|
+
try {
|
|
9
|
+
const result = await runCommand("rtk", ["--version"]);
|
|
10
|
+
if (result.exitCode === 0) {
|
|
11
|
+
const version = (result.stdout || "").trim() || null;
|
|
12
|
+
return { available: true, version };
|
|
13
|
+
}
|
|
14
|
+
return { available: false, version: null };
|
|
15
|
+
} catch {
|
|
16
|
+
return { available: false, version: null };
|
|
17
|
+
}
|
|
18
|
+
}
|