karajan-code 1.42.0 → 1.44.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/README.md CHANGED
@@ -52,6 +52,14 @@ If Claude Code is a smart pair programmer, Karajan is the CI/CD pipeline for AI-
52
52
 
53
53
  ## Install
54
54
 
55
+ **One-liner** (detects your OS, installs via npm):
56
+
57
+ ```bash
58
+ curl -fsSL https://raw.githubusercontent.com/manufosela/karajan-code/main/scripts/install-kj.sh | sh
59
+ ```
60
+
61
+ **Or directly with npm:**
62
+
55
63
  ```bash
56
64
  npm install -g karajan-code
57
65
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karajan-code",
3
- "version": "1.42.0",
3
+ "version": "1.44.0",
4
4
  "description": "Local multi-agent coding orchestrator with TDD, SonarQube, and code review pipeline",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0",
@@ -0,0 +1,193 @@
1
+ #!/bin/sh
2
+ # Karajan Code - Universal Installer
3
+ # Usage: curl -fsSL https://raw.githubusercontent.com/manufosela/karajan-code/main/scripts/install-kj.sh | sh
4
+ #
5
+ # Installs karajan-code globally via npm if Node.js >= 18 is available.
6
+ # If Node.js is not installed, prints platform-specific instructions.
7
+
8
+ # --- Color support ---
9
+ setup_colors() {
10
+ if [ -t 1 ] && command -v tput >/dev/null 2>&1 && [ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]; then
11
+ BOLD="$(tput bold)"
12
+ GREEN="$(tput setaf 2)"
13
+ YELLOW="$(tput setaf 3)"
14
+ RED="$(tput setaf 1)"
15
+ CYAN="$(tput setaf 6)"
16
+ RESET="$(tput sgr0)"
17
+ else
18
+ BOLD="" GREEN="" YELLOW="" RED="" CYAN="" RESET=""
19
+ fi
20
+ }
21
+
22
+ info() { printf '%s[info]%s %s\n' "$CYAN" "$RESET" "$1"; }
23
+ success() { printf '%s[ok]%s %s\n' "$GREEN" "$RESET" "$1"; }
24
+ warn() { printf '%s[warn]%s %s\n' "$YELLOW" "$RESET" "$1"; }
25
+ error() { printf '%s[error]%s %s\n' "$RED" "$RESET" "$1"; }
26
+
27
+ # --- Platform detection ---
28
+ detect_platform() {
29
+ OS="$(uname -s)"
30
+ ARCH="$(uname -m)"
31
+
32
+ case "$OS" in
33
+ Linux*) PLATFORM="linux" ;;
34
+ Darwin*) PLATFORM="macos" ;;
35
+ MINGW*|MSYS*|CYGWIN*) PLATFORM="windows" ;;
36
+ *) PLATFORM="unknown" ;;
37
+ esac
38
+
39
+ case "$ARCH" in
40
+ x86_64|amd64) ARCH="x64" ;;
41
+ aarch64|arm64) ARCH="arm64" ;;
42
+ *) ARCH="$ARCH" ;;
43
+ esac
44
+ }
45
+
46
+ # --- Check Node.js ---
47
+ check_node() {
48
+ if ! command -v node >/dev/null 2>&1; then
49
+ return 1
50
+ fi
51
+
52
+ NODE_VERSION="$(node --version 2>/dev/null | sed 's/^v//')"
53
+ NODE_MAJOR="$(echo "$NODE_VERSION" | cut -d. -f1)"
54
+
55
+ if [ "$NODE_MAJOR" -lt 18 ] 2>/dev/null; then
56
+ warn "Node.js v${NODE_VERSION} found, but v18+ is required."
57
+ return 1
58
+ fi
59
+
60
+ return 0
61
+ }
62
+
63
+ # --- Print Node.js install instructions ---
64
+ print_node_instructions() {
65
+ echo ""
66
+ error "Node.js >= 18 is required but not found."
67
+ echo ""
68
+ printf '%sInstall Node.js for your platform:%s\n' "$BOLD" "$RESET"
69
+ echo ""
70
+
71
+ case "$PLATFORM" in
72
+ linux)
73
+ echo " Option 1 - nvm (recommended):"
74
+ echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash"
75
+ echo " nvm install 22"
76
+ echo ""
77
+ echo " Option 2 - NodeSource:"
78
+ echo " curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -"
79
+ echo " sudo apt-get install -y nodejs"
80
+ ;;
81
+ macos)
82
+ echo " Option 1 - nvm (recommended):"
83
+ echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash"
84
+ echo " nvm install 22"
85
+ echo ""
86
+ echo " Option 2 - Homebrew:"
87
+ echo " brew install node@22"
88
+ ;;
89
+ windows)
90
+ echo " Option 1 - nvm-windows:"
91
+ echo " https://github.com/coreybutler/nvm-windows/releases"
92
+ echo ""
93
+ echo " Option 2 - Download installer:"
94
+ echo " https://nodejs.org/en/download/"
95
+ ;;
96
+ *)
97
+ echo " Download from: https://nodejs.org/en/download/"
98
+ ;;
99
+ esac
100
+
101
+ echo ""
102
+ echo " After installing Node.js, re-run this script:"
103
+ echo " curl -fsSL https://raw.githubusercontent.com/manufosela/karajan-code/main/scripts/install-kj.sh | sh"
104
+ echo ""
105
+ }
106
+
107
+ # --- Install via npm ---
108
+ install_karajan() {
109
+ info "Installing karajan-code via npm..."
110
+ echo ""
111
+
112
+ if npm install -g karajan-code; then
113
+ success "karajan-code installed successfully."
114
+ else
115
+ echo ""
116
+ error "npm install failed."
117
+ echo ""
118
+ echo " Common fixes:"
119
+ echo " - Permission error? Use: sudo npm install -g karajan-code"
120
+ echo " - Or configure npm prefix: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally"
121
+ echo ""
122
+ exit 1
123
+ fi
124
+ }
125
+
126
+ # --- Verify installation ---
127
+ verify_install() {
128
+ echo ""
129
+ if command -v kj >/dev/null 2>&1; then
130
+ KJ_VERSION="$(kj --version 2>/dev/null || echo "unknown")"
131
+ success "kj ${KJ_VERSION} is ready."
132
+ else
133
+ warn "kj command not found in PATH. You may need to restart your shell."
134
+ return 1
135
+ fi
136
+ }
137
+
138
+ # --- Run kj init ---
139
+ run_init() {
140
+ if command -v kj >/dev/null 2>&1; then
141
+ info "Running kj init to detect installed agents..."
142
+ echo ""
143
+ kj init --no-interactive 2>/dev/null || true
144
+ echo ""
145
+ fi
146
+ }
147
+
148
+ # --- Print next steps ---
149
+ print_next_steps() {
150
+ echo ""
151
+ printf '%s%s--- Karajan Code installed ---%s\n' "$BOLD" "$GREEN" "$RESET"
152
+ echo ""
153
+ echo " Next steps:"
154
+ echo ""
155
+ echo " 1. Go to a project directory:"
156
+ echo " cd your-project/"
157
+ echo ""
158
+ echo " 2. Run from CLI:"
159
+ echo " kj run \"Add input validation with tests\""
160
+ echo ""
161
+ echo " 3. Or use as MCP server inside Claude Code / Codex:"
162
+ echo " The MCP server auto-registers during install."
163
+ echo " Open kj-tail in a separate terminal to see pipeline output."
164
+ echo ""
165
+ echo " Docs: https://karajancode.com"
166
+ echo ""
167
+ }
168
+
169
+ # --- Main ---
170
+ main() {
171
+ setup_colors
172
+
173
+ echo ""
174
+ printf '%s%sKarajan Code Installer%s\n' "$BOLD" "$CYAN" "$RESET"
175
+ echo ""
176
+
177
+ detect_platform
178
+ info "Detected: ${PLATFORM} (${ARCH})"
179
+
180
+ if ! check_node; then
181
+ print_node_instructions
182
+ exit 1
183
+ fi
184
+
185
+ success "Node.js v${NODE_VERSION} detected."
186
+
187
+ install_karajan
188
+ verify_install
189
+ run_init
190
+ print_next_steps
191
+ }
192
+
193
+ main
@@ -9,6 +9,7 @@ import { detectAvailableAgents } from "../utils/agent-detect.js";
9
9
  import { createWizard, isTTY } from "../utils/wizard.js";
10
10
  import { runCommand } from "../utils/process.js";
11
11
  import { getInstallCommand } from "../utils/os-detect.js";
12
+ import { detectOsLocale, SUPPORTED_LANGUAGES } from "../utils/locale.js";
12
13
 
13
14
  async function runWizard(config, logger) {
14
15
  const agents = await detectAvailableAgents();
@@ -88,6 +89,31 @@ async function runWizard(config, logger) {
88
89
  config.development.require_test_changes = methodology === "tdd";
89
90
  logger.info(` -> Methodology: ${methodology}`);
90
91
 
92
+ const detectedLocale = detectOsLocale();
93
+ const allLangEntries = Object.entries(SUPPORTED_LANGUAGES).map(([code, name]) => ({
94
+ label: `${name} (${code})`,
95
+ value: code,
96
+ available: true
97
+ }));
98
+ // Put detected locale first so it becomes the default selection
99
+ const languageOptions = [
100
+ ...allLangEntries.filter((o) => o.value === detectedLocale),
101
+ ...allLangEntries.filter((o) => o.value !== detectedLocale)
102
+ ];
103
+
104
+ const pipelineLang = await wizard.select("Pipeline language:", languageOptions);
105
+ config.language = pipelineLang;
106
+ logger.info(` -> Pipeline language: ${pipelineLang}`);
107
+
108
+ // Reorder for HU language with pipeline language as default
109
+ const huLangOptions = [
110
+ ...allLangEntries.filter((o) => o.value === pipelineLang),
111
+ ...allLangEntries.filter((o) => o.value !== pipelineLang)
112
+ ];
113
+ const huLang = await wizard.select("HU language (for user stories):", huLangOptions);
114
+ config.hu_language = huLang;
115
+ logger.info(` -> HU language: ${huLang}`);
116
+
91
117
  logger.info("");
92
118
  } finally {
93
119
  wizard.close();
@@ -290,6 +316,13 @@ export async function initCommand({ logger, flags = {} }) {
290
316
  const { config, exists: configExists } = await loadConfig();
291
317
  const interactive = flags.noInteractive !== true && isTTY();
292
318
 
319
+ // Auto-detect language from OS locale for non-interactive mode
320
+ if (!interactive && !configExists) {
321
+ const detectedLocale = detectOsLocale();
322
+ config.language = detectedLocale;
323
+ config.hu_language = detectedLocale;
324
+ }
325
+
293
326
  await handleConfigSetup({ config, configExists, interactive, configPath, logger });
294
327
  await ensureReviewRules(reviewRulesPath, logger);
295
328
  await ensureCoderRules(coderRulesPath, logger);
package/src/config.js CHANGED
@@ -123,6 +123,8 @@ const DEFAULTS = {
123
123
  port: 4000,
124
124
  auto_start: false
125
125
  },
126
+ language: "en",
127
+ hu_language: "en",
126
128
  policies: {},
127
129
  serena: { enabled: false },
128
130
  planning_game: { enabled: false, project_id: null, codeveloper: null },
@@ -1,4 +1,5 @@
1
1
  import { loadAvailableSkills, buildSkillSection } from "../skills/skill-loader.js";
2
+ import { getLanguageInstruction } from "../utils/locale.js";
2
3
 
3
4
  const SUBAGENT_PREAMBLE = [
4
5
  "IMPORTANT: You are running as a Karajan sub-agent.",
@@ -8,8 +9,9 @@ const SUBAGENT_PREAMBLE = [
8
9
 
9
10
  export const VALID_VERDICTS = new Set(["ready", "needs_clarification"]);
10
11
 
11
- export async function buildArchitectPrompt({ task, instructions, researchContext = null, productContext = null, projectDir = null }) {
12
- const sections = [SUBAGENT_PREAMBLE];
12
+ export async function buildArchitectPrompt({ task, instructions, researchContext = null, productContext = null, projectDir = null, language = "en" }) {
13
+ const langInstruction = getLanguageInstruction(language);
14
+ const sections = [SUBAGENT_PREAMBLE, ...(langInstruction ? [langInstruction] : [])];
13
15
 
14
16
  if (instructions) {
15
17
  sections.push(instructions);
@@ -1,5 +1,6 @@
1
1
  import { RTK_INSTRUCTIONS } from "./rtk-snippet.js";
2
2
  import { loadAvailableSkills, buildSkillSection } from "../skills/skill-loader.js";
3
+ import { getLanguageInstruction } from "../utils/locale.js";
3
4
 
4
5
  const SUBAGENT_PREAMBLE = [
5
6
  "IMPORTANT: You are running as a Karajan sub-agent.",
@@ -32,9 +33,11 @@ const SERENA_INSTRUCTIONS = [
32
33
  "Fall back to reading files only when Serena tools are not sufficient."
33
34
  ].join("\n");
34
35
 
35
- export async function buildCoderPrompt({ task, reviewerFeedback = null, sonarSummary = null, coderRules = null, methodology = "tdd", serenaEnabled = false, rtkAvailable = false, deferredContext = null, productContext = null, plan = null, projectDir = null }) {
36
+ export async function buildCoderPrompt({ task, reviewerFeedback = null, sonarSummary = null, coderRules = null, methodology = "tdd", serenaEnabled = false, rtkAvailable = false, deferredContext = null, productContext = null, plan = null, projectDir = null, language = "en" }) {
37
+ const langInstruction = getLanguageInstruction(language);
36
38
  const sections = [
37
39
  serenaEnabled ? SUBAGENT_PREAMBLE_SERENA : SUBAGENT_PREAMBLE,
40
+ ...(langInstruction ? [langInstruction] : []),
38
41
  `Task:\n${task}`,
39
42
  "Implement directly in the repository.",
40
43
  "Keep changes minimal and production-ready.",
@@ -1,4 +1,5 @@
1
1
  import { extractFirstJson } from "../utils/json-extract.js";
2
+ import { getLanguageInstruction } from "../utils/locale.js";
2
3
 
3
4
  const SUBAGENT_PREAMBLE = [
4
5
  "IMPORTANT: You are running as a Karajan sub-agent.",
@@ -21,8 +22,9 @@ const DIMENSION_KEYS = [
21
22
  * @param {{stories: Array<{id: string, text: string}>, instructions: string|null, context?: string|null}} params
22
23
  * @returns {string} The assembled prompt.
23
24
  */
24
- export function buildHuReviewerPrompt({ stories, instructions, context = null, productContext = null }) {
25
- const sections = [SUBAGENT_PREAMBLE];
25
+ export function buildHuReviewerPrompt({ stories, instructions, context = null, productContext = null, hu_language = "en" }) {
26
+ const langInstruction = getLanguageInstruction(hu_language);
27
+ const sections = [SUBAGENT_PREAMBLE, ...(langInstruction ? [langInstruction] : [])];
26
28
 
27
29
  if (instructions) {
28
30
  sections.push(instructions);
@@ -1,5 +1,6 @@
1
1
  import { RTK_INSTRUCTIONS } from "./rtk-snippet.js";
2
2
  import { loadAvailableSkills, buildSkillSection } from "../skills/skill-loader.js";
3
+ import { getLanguageInstruction } from "../utils/locale.js";
3
4
 
4
5
  const SUBAGENT_PREAMBLE = [
5
6
  "IMPORTANT: You are running as a Karajan sub-agent.",
@@ -23,11 +24,13 @@ const SERENA_INSTRUCTIONS = [
23
24
  "Fall back to reading files only when Serena tools are not sufficient."
24
25
  ].join("\n");
25
26
 
26
- export async function buildReviewerPrompt({ task, diff, reviewRules, mode, serenaEnabled = false, rtkAvailable = false, productContext = null, projectDir = null }) {
27
+ export async function buildReviewerPrompt({ task, diff, reviewRules, mode, serenaEnabled = false, rtkAvailable = false, productContext = null, projectDir = null, language = "en" }) {
27
28
  const truncatedDiff = diff.length > 12000 ? `${diff.slice(0, 12000)}\n\n[TRUNCATED]` : diff;
28
29
 
30
+ const langInstruction = getLanguageInstruction(language);
29
31
  const sections = [
30
32
  serenaEnabled ? SUBAGENT_PREAMBLE_SERENA : SUBAGENT_PREAMBLE,
33
+ ...(langInstruction ? [langInstruction] : []),
31
34
  `You are a code reviewer in ${mode} mode.`,
32
35
  "CRITICAL SCOPE RULE: Only review changes that are part of the diff below. Do NOT flag issues in unchanged code, missing features planned for future tasks, or improvements outside the scope of this task. If the diff is correct for what the task asks, approve it — even if the broader codebase has other issues.",
33
36
  "Only block approval for issues IN THE DIFF that are bugs, security vulnerabilities, or clear violations of the review rules.",
@@ -2,6 +2,7 @@ import path from "node:path";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
 
5
+ // TODO: i18n display messages
5
6
  const DISPLAY_PKG_PATH = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../package.json");
6
7
  const DISPLAY_VERSION = JSON.parse(readFileSync(DISPLAY_PKG_PATH, "utf8")).version;
7
8
 
@@ -0,0 +1,59 @@
1
+ /**
2
+ * OS locale detection and language instruction generation for i18n support.
3
+ */
4
+
5
+ export const SUPPORTED_LANGUAGES = {
6
+ en: "English",
7
+ es: "Español"
8
+ };
9
+
10
+ const LANG_ENV_VARS = ["LANG", "LANGUAGE", "LC_ALL", "LC_MESSAGES"];
11
+
12
+ /**
13
+ * Detect the 2-letter language code from OS environment variables.
14
+ * Checks LANG, LANGUAGE, LC_ALL, LC_MESSAGES in order.
15
+ * @returns {string} 2-letter language code (e.g. "en", "es")
16
+ */
17
+ export function detectOsLocale() {
18
+ for (const envVar of LANG_ENV_VARS) {
19
+ const value = process.env[envVar];
20
+ if (value) {
21
+ const code = extractLangCode(value);
22
+ if (code) return code;
23
+ }
24
+ }
25
+ return "en";
26
+ }
27
+
28
+ /**
29
+ * Extract a 2-letter language code from a locale string.
30
+ * Handles formats like "es_ES.UTF-8", "en_US", "es", "C.UTF-8".
31
+ * @param {string} locale
32
+ * @returns {string|null}
33
+ */
34
+ function extractLangCode(locale) {
35
+ const trimmed = locale.trim();
36
+ if (!trimmed || trimmed === "C" || trimmed === "POSIX") return null;
37
+ // Match first 2 lowercase letters before _, ., or end
38
+ const match = /^([a-z]{2})(?:[_.\-]|$)/i.exec(trimmed);
39
+ if (match) return match[1].toLowerCase();
40
+ return null;
41
+ }
42
+
43
+ /**
44
+ * Get a prompt instruction string for the given language.
45
+ * Returns empty string for English (agents default to English).
46
+ * @param {string} lang - 2-letter language code
47
+ * @returns {string}
48
+ */
49
+ export function getLanguageInstruction(lang) {
50
+ if (!lang || lang === "en") return "";
51
+ const languageName = SUPPORTED_LANGUAGES[lang];
52
+ if (lang === "es") {
53
+ return "IMPORTANT: Respond in Spanish. All output, explanations, and feedback must be in Spanish.";
54
+ }
55
+ if (languageName) {
56
+ return `IMPORTANT: Respond in ${languageName}. All output must be in ${languageName}.`;
57
+ }
58
+ return `IMPORTANT: Respond in ${lang}. All output must be in ${lang}.`;
59
+ }