karajan-code 2.5.0 → 2.6.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.
Files changed (111) hide show
  1. package/README.md +39 -4
  2. package/package.json +5 -2
  3. package/src/agents/aider-agent.js +1 -2
  4. package/src/agents/base-agent.js +63 -1
  5. package/src/agents/claude-agent.js +3 -4
  6. package/src/agents/codex-agent.js +1 -2
  7. package/src/agents/gemini-agent.js +1 -2
  8. package/src/agents/index.js +11 -2
  9. package/src/agents/opencode-agent.js +1 -2
  10. package/src/brain/decision-tracker.js +123 -0
  11. package/src/brain/decisor.js +243 -0
  12. package/src/brain/solomon-consult.js +171 -0
  13. package/src/budget/comparison.js +96 -0
  14. package/src/checks/binaries.js +123 -0
  15. package/src/checks/ci.js +105 -0
  16. package/src/checks/config-files.js +217 -0
  17. package/src/checks/dir-setup.js +63 -0
  18. package/src/checks/mcp-health.js +157 -0
  19. package/src/checks/node.js +61 -0
  20. package/src/checks/ports.js +110 -0
  21. package/src/checks/rtk.js +36 -0
  22. package/src/checks/runner.js +267 -0
  23. package/src/checks/skills.js +49 -0
  24. package/src/checks/sonar.js +67 -0
  25. package/src/checks/system.js +53 -0
  26. package/src/checks/tokens.js +96 -0
  27. package/src/checks/types.js +105 -0
  28. package/src/cli.js +29 -3
  29. package/src/commands/board.js +23 -0
  30. package/src/commands/doctor.js +130 -362
  31. package/src/commands/resume.js +1 -1
  32. package/src/commands/run.js +2 -1
  33. package/src/commands/skills.js +49 -0
  34. package/src/config/schema.js +222 -0
  35. package/src/config.js +32 -3
  36. package/src/guards/policy-resolver.js +8 -0
  37. package/src/hu/store.js +9 -0
  38. package/src/infrastructure/command-runner.js +44 -0
  39. package/src/infrastructure/environment.js +38 -0
  40. package/src/infrastructure/file-system-service.js +63 -0
  41. package/src/infrastructure/mocks.js +182 -0
  42. package/src/mcp/handlers/management-handlers.js +7 -2
  43. package/src/mcp/tools.js +10 -3
  44. package/src/orchestrator/config-init.js +16 -1
  45. package/src/orchestrator/flow-runner.js +2085 -0
  46. package/src/orchestrator/pipeline-context.js +17 -0
  47. package/src/orchestrator/preflight-checks.js +78 -4
  48. package/src/orchestrator/solomon-escalation.js +55 -0
  49. package/src/orchestrator/stages/stage-executor.js +155 -0
  50. package/src/orchestrator.js +19 -1923
  51. package/src/prompts/architect.js +2 -2
  52. package/src/prompts/coder.js +2 -2
  53. package/src/prompts/prompt-resolver.js +127 -0
  54. package/src/prompts/reviewer.js +2 -2
  55. package/src/roles/agent-role.js +9 -0
  56. package/src/roles/architect-role.js +3 -1
  57. package/src/roles/base-role.js +40 -2
  58. package/src/roles/coder-role.js +3 -1
  59. package/src/roles/security-role.js +12 -0
  60. package/src/roles/tester-role.js +11 -0
  61. package/src/session/journal/decisions-writer.js +200 -0
  62. package/src/session/journal/iteration-logger.js +194 -0
  63. package/src/session/journal/summary-writer.js +176 -0
  64. package/src/session/journal/tree-writer.js +164 -0
  65. package/src/skills/semantic-detector.js +147 -0
  66. package/src/skills/skill-detector.js +186 -8
  67. package/src/skills/skill-loader.js +131 -1
  68. package/src/skills/skills-cache.js +128 -0
  69. package/src/types/agent.js +55 -0
  70. package/src/types/config.js +114 -0
  71. package/src/types/hu.js +47 -0
  72. package/src/types/index.js +38 -0
  73. package/src/types/policy.js +43 -0
  74. package/src/types/session.js +74 -0
  75. package/src/types/solomon.js +87 -0
  76. package/src/types/stage.js +68 -0
  77. package/src/utils/display/event-handlers.js +389 -0
  78. package/src/utils/display/formatters.js +132 -0
  79. package/src/utils/display/header.js +48 -0
  80. package/src/utils/display/session-summary.js +108 -0
  81. package/src/utils/display/solomon.js +42 -0
  82. package/src/utils/port-check.js +45 -0
  83. package/src/utils/port-occupant.js +95 -0
  84. package/src/utils/provider-env.js +116 -0
  85. package/src/utils/with-timeout.js +42 -0
  86. package/templates/roles/architect/anthropic.md +65 -0
  87. package/templates/roles/architect/default.md +63 -0
  88. package/templates/roles/architect/google.md +52 -0
  89. package/templates/roles/architect/openai.md +51 -0
  90. package/templates/roles/architect/opencode.md +50 -0
  91. package/templates/roles/coder/anthropic.md +72 -0
  92. package/templates/roles/coder/default.md +69 -0
  93. package/templates/roles/coder/google.md +78 -0
  94. package/templates/roles/coder/openai.md +59 -0
  95. package/templates/roles/coder/opencode.md +49 -0
  96. package/templates/roles/planner/anthropic.md +50 -0
  97. package/templates/roles/planner/default.md +48 -0
  98. package/templates/roles/planner/google.md +66 -0
  99. package/templates/roles/planner/openai.md +46 -0
  100. package/templates/roles/planner/opencode.md +53 -0
  101. package/templates/roles/reviewer/anthropic.md +61 -0
  102. package/templates/roles/reviewer/default.md +62 -0
  103. package/templates/roles/reviewer/google.md +63 -0
  104. package/templates/roles/reviewer/openai.md +57 -0
  105. package/templates/roles/reviewer/opencode.md +42 -0
  106. package/templates/roles/solomon/anthropic.md +71 -0
  107. package/templates/roles/solomon/default.md +83 -0
  108. package/templates/roles/solomon/google.md +61 -0
  109. package/templates/roles/solomon/openai.md +53 -0
  110. package/templates/roles/solomon/opencode.md +55 -0
  111. package/src/utils/display.js +0 -669
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Karajan configuration typedefs. Mirrors the shape produced by loadConfig()
3
+ * and consumed throughout the orchestrator. Optional fields are intentional
4
+ * — users may set them in kj.config.yml without every field being required.
5
+ */
6
+
7
+ /**
8
+ * @typedef {Object} RoleConfig
9
+ * @property {string} [provider] - claude | codex | gemini | opencode | aider | anthropic | openai | google
10
+ * @property {string} [model] - provider-specific model identifier
11
+ */
12
+
13
+ /**
14
+ * @typedef {Object} PipelineToggle
15
+ * @property {boolean} [enabled]
16
+ */
17
+
18
+ /**
19
+ * @typedef {Object} PipelineFlags
20
+ * @property {boolean} [coderEnabled]
21
+ * @property {boolean} [reviewerEnabled]
22
+ * @property {boolean} [plannerEnabled]
23
+ * @property {boolean} [researcherEnabled]
24
+ * @property {boolean} [architectEnabled]
25
+ * @property {boolean} [refactorerEnabled]
26
+ * @property {boolean} [testerEnabled]
27
+ * @property {boolean} [securityEnabled]
28
+ * @property {boolean} [impeccableEnabled]
29
+ * @property {boolean} [triageEnabled]
30
+ * @property {boolean} [discoverEnabled]
31
+ * @property {boolean} [huReviewerEnabled]
32
+ * @property {boolean} [coderRequired]
33
+ */
34
+
35
+ /**
36
+ * @typedef {Object} GitConfig
37
+ * @property {boolean} [auto_commit]
38
+ * @property {boolean} [auto_push]
39
+ * @property {boolean} [auto_pr]
40
+ * @property {boolean} [auto_rebase]
41
+ * @property {string} [branch_prefix]
42
+ */
43
+
44
+ /**
45
+ * @typedef {Object} SonarConfig
46
+ * @property {boolean} [enabled]
47
+ * @property {string} [host]
48
+ * @property {string} [token]
49
+ * @property {boolean} [external]
50
+ * @property {string} [enforcement_profile]
51
+ */
52
+
53
+ /**
54
+ * @typedef {Object} BudgetConfig
55
+ * @property {Object} [pricing]
56
+ * @property {number} [warn_threshold_pct]
57
+ */
58
+
59
+ /**
60
+ * @typedef {Object} BrainDecisorConfig
61
+ * @property {boolean} [enabled]
62
+ * @property {number} [maxDecisions]
63
+ */
64
+
65
+ /**
66
+ * @typedef {Object} BrainConfig
67
+ * @property {boolean} [enabled]
68
+ * @property {string} [provider]
69
+ * @property {boolean} [bypass_solomon_on_correctness]
70
+ * @property {number} [max_consecutive_verification_failures]
71
+ * @property {BrainDecisorConfig} [decisor]
72
+ */
73
+
74
+ /**
75
+ * @typedef {Object} SkillsConfig
76
+ * @property {boolean} [enabled]
77
+ * @property {"auto"|"regex"|"semantic"|"none"} [mode]
78
+ */
79
+
80
+ /**
81
+ * @typedef {Object} PreflightConfig
82
+ * @property {boolean} [extended]
83
+ */
84
+
85
+ /**
86
+ * Full Karajan configuration shape as resolved by loadConfig() +
87
+ * applyRunOverrides(). Not every field is always present; consumers should
88
+ * defensively read via `config.x?.y`.
89
+ *
90
+ * @typedef {Object} KarajanConfig
91
+ * @property {string} [coder] - legacy agent name (claude, codex, ...)
92
+ * @property {string} [reviewer] - legacy agent name
93
+ * @property {Object.<string, RoleConfig>} [roles]
94
+ * @property {Object.<string, PipelineToggle>} [pipeline]
95
+ * @property {string} [review_mode] - standard | strict | paranoid | relaxed
96
+ * @property {string} [review_rules] - path to review rules .md
97
+ * @property {number} [max_iterations]
98
+ * @property {number} [max_budget_usd]
99
+ * @property {BudgetConfig} [budget]
100
+ * @property {SonarConfig} [sonarqube]
101
+ * @property {GitConfig} [git]
102
+ * @property {string} [base_branch]
103
+ * @property {Object} [session] - timeouts etc
104
+ * @property {Object} [output] - log level, report dir
105
+ * @property {Object} [development] - methodology, require_test_changes
106
+ * @property {BrainConfig} [brain]
107
+ * @property {SkillsConfig} [skills]
108
+ * @property {PreflightConfig} [preflight]
109
+ * @property {string} [projectDir] - absolute path, set at runtime
110
+ * @property {string} [productContext] - runtime-loaded
111
+ * @property {string} [domainContext] - runtime-loaded
112
+ */
113
+
114
+ export {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * HU (Historia de Usuario) typedefs. An HU is a user story that the
3
+ * pipeline can decompose into, certify via hu-reviewer, then run as a
4
+ * sub-pipeline.
5
+ */
6
+
7
+ /**
8
+ * @typedef {"pending"|"planned"|"in_progress"|"done"|"rejected"|"blocked"|"failed"} HUStatus
9
+ */
10
+
11
+ /**
12
+ * @typedef {Object} HUAcceptanceCriterion
13
+ * @property {string} [given]
14
+ * @property {string} [when]
15
+ * @property {string} [then]
16
+ * @property {string} [raw] - plain-text AC if not Gherkin
17
+ */
18
+
19
+ /**
20
+ * @typedef {Object} HUStory
21
+ * @property {string} id - stable slug per batch
22
+ * @property {string} title
23
+ * @property {string} [role] - "Como ..."
24
+ * @property {string} [goal] - "Quiero ..."
25
+ * @property {string} [benefit] - "Para ..."
26
+ * @property {HUAcceptanceCriterion[]} [acceptanceCriteria]
27
+ * @property {HUStatus} [status]
28
+ * @property {string} [assignee]
29
+ * @property {string[]} [dependencies] - ids of HUs that must be done first
30
+ * @property {Object} [certification] - hu-reviewer verdict
31
+ * @property {Object} [session] - sub-pipeline session metadata when it runs
32
+ */
33
+
34
+ /**
35
+ * A batch is the ordered collection of HUs produced by the auto-generator
36
+ * or loaded from a YAML file.
37
+ *
38
+ * @typedef {Object} HUBatch
39
+ * @property {string} id - typically the parent sessionId
40
+ * @property {string} [task] - original task text
41
+ * @property {HUStory[]} stories
42
+ * @property {string} [created_at]
43
+ * @property {string} [updated_at]
44
+ * @property {Object} [board] - HU Board metadata (port, URL)
45
+ */
46
+
47
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Central JSDoc typedef registry. Import typedefs via:
3
+ *
4
+ * /** @typedef {import("../types/index.js").KarajanConfig} KarajanConfig *\/
5
+ *
6
+ * This module re-exports every type so consumers have a single import path.
7
+ * The actual typedef bodies live in the focused files under src/types/.
8
+ *
9
+ * Intentionally a runtime-empty module: it only carries JSDoc annotations,
10
+ * nothing to execute.
11
+ */
12
+
13
+ /**
14
+ * @typedef {import("./config.js").KarajanConfig} KarajanConfig
15
+ * @typedef {import("./config.js").RoleConfig} RoleConfig
16
+ * @typedef {import("./config.js").PipelineFlags} PipelineFlags
17
+ *
18
+ * @typedef {import("./session.js").Session} Session
19
+ * @typedef {import("./session.js").Checkpoint} Checkpoint
20
+ *
21
+ * @typedef {import("./stage.js").StageContext} StageContext
22
+ * @typedef {import("./stage.js").StageResult} StageResult
23
+ *
24
+ * @typedef {import("./agent.js").AgentResult} AgentResult
25
+ * @typedef {import("./agent.js").AgentResponse} AgentResponse
26
+ *
27
+ * @typedef {import("./hu.js").HUStory} HUStory
28
+ * @typedef {import("./hu.js").HUBatch} HUBatch
29
+ *
30
+ * @typedef {import("./policy.js").ResolvedPolicies} ResolvedPolicies
31
+ * @typedef {import("./policy.js").QualityGateResult} QualityGateResult
32
+ *
33
+ * @typedef {import("./solomon.js").Conflict} SolomonConflict
34
+ * @typedef {import("./solomon.js").ConflictHistoryEntry} SolomonConflictHistoryEntry
35
+ * @typedef {import("./solomon.js").SolomonResult} SolomonResult
36
+ */
37
+
38
+ export {};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Policy + quality-gate typedefs. Policies are resolved once per session
3
+ * from config + task type; quality gates are the outputs of each gate
4
+ * (sonar, perf, tests, review).
5
+ */
6
+
7
+ /**
8
+ * @typedef {Object} ResolvedPolicies
9
+ * @property {boolean} [tdd] - whether TDD is enforced
10
+ * @property {boolean} [sonar] - Sonar gate enabled
11
+ * @property {boolean} [tests] - tester gate enabled
12
+ * @property {boolean} [security] - security audit enabled
13
+ * @property {boolean} [reviewer] - reviewer gate enabled
14
+ * @property {boolean} [planner] - planner enabled
15
+ * @property {boolean} [researcher] - researcher enabled
16
+ * @property {boolean} [architect] - architect enabled
17
+ * @property {boolean} [refactorer] - refactorer enabled
18
+ * @property {boolean} [impeccable] - impeccable audit enabled
19
+ * @property {boolean} [triage] - triage enabled
20
+ * @property {boolean} [discover] - discover phase enabled
21
+ * @property {boolean} [hu_reviewer] - HU certification enabled
22
+ * @property {number} [reviewer_retries]
23
+ * @property {number} [tester_retries]
24
+ * @property {string} [reason] - why these policies (task type + config chain)
25
+ */
26
+
27
+ /**
28
+ * Result of a quality gate evaluation — Sonar, perf, tester, reviewer, etc.
29
+ *
30
+ * @typedef {Object} QualityGateResult
31
+ * @property {boolean} ok - did the gate pass
32
+ * @property {"OK"|"FAIL"|"WARN"|"ERROR"} gateStatus
33
+ * @property {string} [summary]
34
+ * @property {Object[]} [blocking_issues] - for reviewer/security gates
35
+ * @property {number} [openIssues] - sonar
36
+ * @property {number} [issuesInitial]
37
+ * @property {number} [issuesFinal]
38
+ * @property {number} [issuesResolved]
39
+ * @property {string} [provider] - which agent produced the verdict (when relevant)
40
+ * @property {Object} [details] - gate-specific payload
41
+ */
42
+
43
+ export {};
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Session state typedefs. The session is a mutable object that accumulates
3
+ * state throughout a kj run and is persisted to ~/.karajan/sessions/<id>/.
4
+ */
5
+
6
+ /**
7
+ * @typedef {Object} Checkpoint
8
+ * @property {string} [at] - ISO timestamp
9
+ * @property {string} [stage]
10
+ * @property {number} [iteration]
11
+ * @property {string} [conflictStage]
12
+ * @property {string} [ruling]
13
+ * @property {string} [alternativeAgent]
14
+ * @property {string} [waitUntil]
15
+ * @property {string[]} [conditions]
16
+ * @property {boolean} [escalate]
17
+ * @property {string} [error]
18
+ * @property {string|null} [subtask]
19
+ */
20
+
21
+ /**
22
+ * @typedef {Object} SolomonRulingRecord
23
+ * @property {string} at - ISO timestamp
24
+ * @property {string} stage
25
+ * @property {string} trigger
26
+ * @property {Object} conflict
27
+ * @property {string} ruling - approve | approve_with_conditions | escalate_human | create_subtask | ...
28
+ * @property {string} [reasoning]
29
+ * @property {string[]} [conditions]
30
+ * @property {string|null} [alternativeAgent]
31
+ * @property {string} [result]
32
+ */
33
+
34
+ /**
35
+ * @typedef {Object} BrainDecisionRecord
36
+ * @property {number} seq
37
+ * @property {string} at
38
+ * @property {string} intent - "<taskType>:<level>"
39
+ * @property {string[]} rolesOn
40
+ * @property {string} confidence - low | medium | high
41
+ * @property {string} rationale
42
+ * @property {string[]} appliedOverrides
43
+ */
44
+
45
+ /**
46
+ * @typedef {Object} RtkSavings
47
+ * @property {number} [callCount]
48
+ * @property {number} [estimatedTokensSaved]
49
+ * @property {number} [savedPct]
50
+ * @property {number} [originalBytes]
51
+ * @property {number} [rtkBytes]
52
+ */
53
+
54
+ /**
55
+ * @typedef {Object} Session
56
+ * @property {string} id - session id
57
+ * @property {string} task - user's task text
58
+ * @property {"running"|"paused"|"approved"|"rejected"|"failed"} status
59
+ * @property {string} created_at - ISO timestamp
60
+ * @property {string} updated_at
61
+ * @property {Checkpoint[]} [checkpoints]
62
+ * @property {SolomonRulingRecord[]} [solomonRulings] - KJC-TSK-0287
63
+ * @property {BrainDecisionRecord[]} [brainDecisions] - KJC-TSK-0322
64
+ * @property {string[]} [skillsRecommended] - wouldHaveUsed when openskills missing
65
+ * @property {string[]} [autoInstalledSkills]
66
+ * @property {RtkSavings} [rtk_savings]
67
+ * @property {string} [session_start_sha]
68
+ * @property {string} [_journalDir] - runtime journal path
69
+ * @property {string[]} [_journalIterations] - rendered iteration markdown
70
+ * @property {string[]} [_journalFiles]
71
+ * @property {Object} [budget] - final budget summary snapshot
72
+ */
73
+
74
+ export {};
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Typedefs for Solomon — the AI judge consulted by Brain on genuine dilemmas.
3
+ *
4
+ * Architectural invariant (enforced by convention, see docs/ARCHITECTURE.md):
5
+ * Solomon is **NEVER** invoked directly from stages, rules or roles.
6
+ * The only legitimate entry points are:
7
+ * - `src/brain/solomon-consult.js#consultSolomonForRouting`
8
+ * - `src/orchestrator/solomon-escalation.js#invokeSolomon`
9
+ * Both are called by Brain (or by the orchestrator on Brain's behalf).
10
+ * The v2.3.0 audit fixed 21 violations where stages bypassed Brain and
11
+ * called Solomon directly. Don't reintroduce that pattern.
12
+ *
13
+ * This module is runtime-empty — it only carries JSDoc annotations.
14
+ *
15
+ * @module types/solomon
16
+ */
17
+
18
+ /**
19
+ * A single turn of feedback attributed to a pipeline agent. Used to build
20
+ * `Conflict.history` when Brain escalates a decision to Solomon.
21
+ *
22
+ * @typedef {Object} ConflictHistoryEntry
23
+ * @property {string} agent - slug of the agent that produced the feedback
24
+ * (e.g. "reviewer", "sonar", "tester",
25
+ * "coder_rate_limit").
26
+ * @property {string} feedback - raw textual feedback to be weighted by Solomon.
27
+ */
28
+
29
+ /**
30
+ * The bundle of context Brain hands to Solomon when it cannot decide on its
31
+ * own. Solomon reads only this object + the stage + task; it never sees
32
+ * session internals beyond what is packed here.
33
+ *
34
+ * Historical shape: this matches the argument already used by
35
+ * `invokeSolomon({ ..., conflict })` — the typedef formalizes the contract
36
+ * so future drift is caught by `npm run typecheck`.
37
+ *
38
+ * @typedef {Object} Conflict
39
+ * @property {string} stage
40
+ * Pipeline stage that triggered escalation (e.g. "reviewer",
41
+ * "sonar", "tester", "init_error", "coder_rate_limit").
42
+ * @property {string} task
43
+ * Original user task (denormalized so Solomon sees what the user
44
+ * actually asked for, not just the stage context).
45
+ * @property {number} iterationCount
46
+ * Current iteration number inside the escalating sub-loop.
47
+ * @property {number} maxIterations
48
+ * Configured cap for that sub-loop (reviewer retries, tester
49
+ * retries, full pipeline iterations, etc.). Hitting this cap is
50
+ * the canonical trigger for Solomon consultation.
51
+ * @property {string|null} [cooldownUntil]
52
+ * ISO timestamp for rate-limit / standby escalations. Null when
53
+ * the conflict is not a rate-limit.
54
+ * @property {number|null} [cooldownMs]
55
+ * Remaining cooldown in milliseconds. Null outside rate-limit
56
+ * escalations.
57
+ * @property {ConflictHistoryEntry[]} history
58
+ * Ordered list of agent feedback Solomon should weigh. Most
59
+ * recent last. Must be non-empty — Solomon should always see at
60
+ * least one piece of evidence.
61
+ */
62
+
63
+ /**
64
+ * Solomon's ruling on a `Conflict`. Returned by `invokeSolomon()` and
65
+ * consumed by the orchestrator to decide what happens next.
66
+ *
67
+ * @typedef {Object} SolomonResult
68
+ * @property {"continue"|"pause"|"subtask"} action
69
+ * - `continue`: retry the sub-loop with optional `humanGuidance`
70
+ * appended to the next feedback round.
71
+ * - `pause`: stop the pipeline and surface a question to the
72
+ * human operator (`SolomonResult.question`).
73
+ * - `subtask`: bifurcate into a named sub-task defined in
74
+ * `SolomonResult.subtask`.
75
+ * @property {string} [rationale] - human-readable reasoning for the
76
+ * chosen action. Logged to the
77
+ * decisions journal.
78
+ * @property {string} [humanGuidance] - text to merge into the next
79
+ * coder/reviewer prompt when
80
+ * action === "continue".
81
+ * @property {string} [question] - prompt shown to the human when
82
+ * action === "pause".
83
+ * @property {Object} [subtask] - sub-task descriptor when
84
+ * action === "subtask".
85
+ */
86
+
87
+ export {};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Stage context + stage result typedefs. A StageContext is the bundle of
3
+ * orchestration state every stage function receives; a StageResult is what
4
+ * they return for downstream stages to consume.
5
+ */
6
+
7
+ /**
8
+ * @typedef {Object} Logger
9
+ * @property {(msg: string, ...rest: any[]) => void} info
10
+ * @property {(msg: string, ...rest: any[]) => void} warn
11
+ * @property {(msg: string, ...rest: any[]) => void} error
12
+ * @property {(msg: string, ...rest: any[]) => void} [debug]
13
+ */
14
+
15
+ /**
16
+ * @typedef {Object} Emitter
17
+ * @property {(event: string, data?: any) => void} emit
18
+ */
19
+
20
+ /**
21
+ * Shape of `eventBase` propagated to every emitted event for correlation.
22
+ *
23
+ * @typedef {Object} EventBase
24
+ * @property {string} sessionId
25
+ * @property {number} iteration
26
+ * @property {string|null} stage
27
+ * @property {number} startedAt - epoch ms
28
+ */
29
+
30
+ /**
31
+ * The context every pipeline stage consumes. Most stages pick a subset with
32
+ * destructuring. Listed here so consumers can import a single type instead
33
+ * of re-declaring ad-hoc objects.
34
+ *
35
+ * @typedef {Object} StageContext
36
+ * @property {import("./config.js").KarajanConfig} config
37
+ * @property {import("./session.js").Session} session
38
+ * @property {Logger} logger
39
+ * @property {Emitter|null} emitter
40
+ * @property {EventBase} eventBase
41
+ * @property {Function} [trackBudget]
42
+ * @property {Function} [budgetSummary]
43
+ * @property {import("./config.js").PipelineFlags} [pipelineFlags]
44
+ * @property {Object} [coderRole] - CoderRole instance
45
+ * @property {Object} [reviewerRole]
46
+ * @property {Object} [brainCtx]
47
+ * @property {Function} [askQuestion]
48
+ * @property {Object} [stageResults] - accumulated results from prior stages
49
+ * @property {string} [task]
50
+ * @property {string|null} [pgTaskId]
51
+ * @property {string|null} [pgProject]
52
+ * @property {Object} [flags] - CLI/call-time flags
53
+ */
54
+
55
+ /**
56
+ * The structured return of most stage helpers. Stages are allowed to return
57
+ * shape-specific additions on top of these common fields.
58
+ *
59
+ * @typedef {Object} StageResult
60
+ * @property {boolean} ok
61
+ * @property {string} [summary]
62
+ * @property {Object} [result] - stage-specific payload
63
+ * @property {string} [action] - "return" | "retry" | "continue" | "skip" | ...
64
+ * @property {Object} [stageResult] - alternate nested result shape used by some stages
65
+ * @property {string} [provider]
66
+ */
67
+
68
+ export {};