karajan-code 4.70.4 → 5.0.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/README.md +2 -2
- package/package.json +6 -14
- package/packages/hu-board/package.json +1 -1
- package/packages/hu-board/public/app.js +4 -18
- package/packages/hu-board/public/index.html +5 -2
- package/packages/hu-board/public/styles.css +26 -0
- package/packages/hu-board/public/utils/api.js +0 -74
- package/packages/hu-board/public/utils/board-tour.js +62 -0
- package/packages/hu-board/public/utils/board-view.js +49 -144
- package/packages/hu-board/public/utils/command-launcher.js +8 -70
- package/packages/hu-board/public/utils/formatters.js +10 -0
- package/packages/hu-board/public/utils/governance-view.js +13 -1
- package/packages/hu-board/public/utils/hu-actions.js +17 -68
- package/packages/hu-board/public/utils/init-listeners.js +7 -8
- package/packages/hu-board/public/utils/log-panel.js +3 -16
- package/packages/hu-board/public/utils/maggle-mode.js +2 -12
- package/packages/hu-board/public/utils/modals.js +7 -0
- package/packages/hu-board/public/utils/project-picker-view.js +1 -1
- package/packages/hu-board/public/utils/server-push.js +3 -22
- package/packages/hu-board/public/utils/shared-board-notice.js +33 -0
- package/packages/hu-board/public/utils/story-detail-view.js +5 -19
- package/packages/hu-board/src/cleanup-zombies.js +0 -1
- package/packages/hu-board/src/command-runner.js +36 -25
- package/packages/hu-board/src/db-connection.js +282 -0
- package/packages/hu-board/src/db-paths.js +113 -0
- package/packages/hu-board/src/db-queries.js +188 -0
- package/packages/hu-board/src/db-tombstones.js +51 -0
- package/packages/hu-board/src/db.js +28 -619
- package/packages/hu-board/src/ephemeral-cleaner.js +2 -3
- package/packages/hu-board/src/hu-zombie-reaper.js +5 -1
- package/packages/hu-board/src/plan-mutations.js +3 -153
- package/packages/hu-board/src/plans-service.js +55 -0
- package/packages/hu-board/src/routes/api/commands.js +122 -0
- package/packages/hu-board/src/routes/api/plans.js +55 -0
- package/packages/hu-board/src/routes/api/projects.js +267 -0
- package/packages/hu-board/src/routes/api/prompts.js +135 -0
- package/packages/hu-board/src/routes/api/sessions.js +95 -0
- package/packages/hu-board/src/routes/api/stories.js +183 -0
- package/packages/hu-board/src/routes/api/system.js +241 -0
- package/packages/hu-board/src/routes/api/tombstones.js +38 -0
- package/packages/hu-board/src/routes/api.js +24 -1371
- package/packages/hu-board/src/routes/governance.js +23 -1
- package/packages/hu-board/src/routes/lanes.js +40 -0
- package/packages/hu-board/src/routes/rag.js +4 -3
- package/packages/hu-board/src/server.js +20 -34
- package/packages/hu-board/src/sync-files.js +318 -0
- package/packages/hu-board/src/sync-project.js +99 -0
- package/packages/hu-board/src/sync.js +22 -566
- package/packages/hu-board/src/zombie-reaper.js +1 -1
- package/scripts/dual-publish.mjs +19 -3
- package/scripts/postinstall.js +15 -2
- package/scripts/verify-pack-mcp.mjs +11 -7
- package/scripts/verify-pack.mjs +4 -4
- package/src/audit/audit-history.js +3 -2
- package/src/audit/dead-exports.js +68 -59
- package/src/audit/deterministic-summary.js +33 -13
- package/src/audit/npm-signatures.js +41 -0
- package/src/audit/sbom.js +35 -0
- package/src/checks/agent-token.js +112 -0
- package/src/checks/dir-setup.js +34 -1
- package/src/checks/native-build.js +21 -39
- package/src/checks/runner.js +128 -142
- package/src/cli/advanced-commands.js +6 -6
- package/src/cli/register-meta.js +42 -82
- package/src/cli/register-pipeline.js +8 -143
- package/src/cli/register-plan.js +9 -100
- package/src/cli/register-roles-skills.js +1 -1
- package/src/cli/retired-commands.js +49 -0
- package/src/cli.js +18 -5
- package/src/commands/agent-run.js +40 -26
- package/src/commands/audit.js +127 -124
- package/src/commands/board.js +5 -9
- package/src/commands/check.js +29 -16
- package/src/commands/doctor.js +2 -0
- package/src/commands/env.js +176 -150
- package/src/commands/go.js +71 -53
- package/src/commands/harden.js +90 -81
- package/src/commands/hu-start.js +52 -0
- package/src/commands/hu.js +288 -221
- package/src/commands/identity.js +111 -78
- package/src/commands/init-atril.js +47 -0
- package/src/commands/init.js +11 -40
- package/src/commands/install-tools.js +70 -85
- package/src/commands/main-guard.js +78 -0
- package/src/commands/policy.js +226 -184
- package/src/commands/qmd.js +27 -21
- package/src/commands/rag.js +121 -55
- package/src/commands/review-gate.js +421 -341
- package/src/commands/skills.js +4 -1
- package/src/commands/start.js +4 -5
- package/src/commands/steward.js +96 -47
- package/src/commands/tournament.js +46 -37
- package/src/commands/worktree.js +107 -26
- package/src/config/defaults.js +1 -0
- package/src/config/loader.js +34 -17
- package/src/config/role-resolver.js +1 -0
- package/src/config/schema.js +1 -0
- package/src/config/secrets.js +36 -0
- package/src/config.js +1 -0
- package/src/environment/adr.js +16 -2
- package/src/git/karajan-label.js +20 -8
- package/src/guards/main-guard.js +54 -0
- package/src/harden/hook-templates.js +16 -1
- package/src/harden/sentinel/posttooluse.mjs +18 -6
- package/src/harden/sentinel/pretooluse-sentinel.mjs +64 -36
- package/src/harden/sentinel/sentinel-lib.mjs +129 -26
- package/src/harden/sentinel/sentinel-shell.mjs +5 -16
- package/src/harden/sentinel/sessionstart.mjs +3 -2
- package/src/harden/sentinel/stop.mjs +5 -4
- package/src/harden/workflow-templates.js +1 -1
- package/src/hu/board-lookup.js +29 -0
- package/src/hu/gh-identity.js +23 -0
- package/src/hu/github-board.js +4 -2
- package/src/hu/lane-prune.js +83 -13
- package/src/hu/lane-setup.js +65 -0
- package/src/hu/lanes.js +66 -0
- package/src/hu/team-board-mirror.js +3 -2
- package/src/infrastructure/command-runner.js +1 -1
- package/src/infrastructure/file-system-service.js +1 -1
- package/src/mcp/handlers/direct-handlers.js +2 -292
- package/src/mcp/handlers/hu-handlers.js +1 -35
- package/src/mcp/handlers/management-handlers.js +2 -42
- package/src/mcp/handlers/rag-handler.js +9 -1
- package/src/mcp/server-handlers.js +16 -22
- package/src/mcp/tools.js +1 -196
- package/src/plan/lane-plans.js +54 -0
- package/src/plan/plan-store.js +7 -4
- package/src/policy/add.js +26 -12
- package/src/policy/adr-number-check.js +31 -0
- package/src/prompts/audit.js +299 -339
- package/src/prompts/card-context.js +10 -5
- package/src/prompts/reviewer.js +5 -2
- package/src/rag/auto-update.js +71 -44
- package/src/rag/bootstrap-index.js +46 -54
- package/src/rag/indexer.js +9 -4
- package/src/rag/migrate.js +1 -1
- package/src/rag/onnx-fallback.js +2 -2
- package/src/rag/pid-lease.js +181 -0
- package/src/rag/project-store.js +2 -12
- package/src/review/card-first.js +57 -46
- package/src/review/gate-gitignore.js +23 -4
- package/src/review/gate-hook.js +12 -4
- package/src/review/one-shot-review.js +45 -35
- package/src/review/publish-pr.js +14 -2
- package/src/review/repo-docs.js +73 -0
- package/src/review/repo-stack.js +59 -0
- package/src/review/reviewer-fallback.js +19 -4
- package/src/review/seal-commit.js +29 -0
- package/src/review/sonar-pregate.js +59 -44
- package/src/review/third-party-review.js +90 -16
- package/src/review/third-party-size.js +43 -0
- package/src/review/third-party-skills.js +54 -0
- package/src/review/verify-pr.js +1 -24
- package/src/roles/audit-role.js +106 -125
- package/src/skills/atril-cli.js +19 -1
- package/src/skills/atril-skills.js +5 -4
- package/src/skills/skills-search.js +72 -0
- package/src/skills/translate.js +62 -0
- package/src/sonar/scanner.js +116 -101
- package/src/steward/invariants.js +5 -4
- package/src/steward/phantom-sweep.js +66 -0
- package/src/tournament/judge.js +60 -53
- package/src/utils/gh-account.js +37 -0
- package/src/utils/git.js +0 -13
- package/src/utils/home-migration.js +7 -1
- package/src/utils/main-checkout.js +53 -0
- package/src/utils/qmd-collection.js +3 -1
- package/src/utils/welcome.js +3 -3
- package/templates/{skills → atril/commands}/kj-architect.md +5 -0
- package/templates/{skills → atril/commands}/kj-audit.md +5 -0
- package/templates/{skills → atril/commands}/kj-board.md +5 -0
- package/templates/{skills → atril/commands}/kj-code.md +5 -0
- package/templates/{skills → atril/commands}/kj-csv-transform.md +5 -0
- package/templates/{skills → atril/commands}/kj-data-report.md +5 -0
- package/templates/{skills → atril/commands}/kj-discover.md +5 -0
- package/templates/{skills → atril/commands}/kj-rag-query.md +5 -0
- package/templates/{skills → atril/commands}/kj-review.md +5 -0
- package/templates/{skills → atril/commands}/kj-security.md +5 -0
- package/templates/{skills → atril/commands}/kj-sonar.md +5 -0
- package/templates/{skills → atril/commands}/kj-sql-analysis.md +5 -0
- package/templates/{skills → atril/commands}/kj-test.md +5 -0
- package/packages/hu-board/public/utils/run-launcher.js +0 -169
- package/packages/hu-board/src/run-tracker.js +0 -121
- package/src/activity-log.js +0 -59
- package/src/agents/host-agent.js +0 -38
- package/src/agents/model-registry.js +0 -142
- package/src/audit/plan-adherence.js +0 -224
- package/src/autonomy/arbiter-role.js +0 -71
- package/src/autonomy/arbiter.js +0 -22
- package/src/autonomy/decider.js +0 -18
- package/src/autonomy/decision-resolver.js +0 -58
- package/src/autonomy/outcome-report.js +0 -55
- package/src/autonomy/stage-ask.js +0 -30
- package/src/brain/decision-tracker.js +0 -125
- package/src/brain/decisor.js +0 -243
- package/src/brain/solomon-consult.js +0 -171
- package/src/brain/standby-scheduler.js +0 -8
- package/src/budget/comparison.js +0 -96
- package/src/canvas/parse-md.js +0 -238
- package/src/canvas/schema.js +0 -101
- package/src/canvas/to-flat.js +0 -85
- package/src/canvas/validate.js +0 -163
- package/src/ci/dispatch.js +0 -99
- package/src/ci/index.js +0 -3
- package/src/ci/pr-diff.js +0 -26
- package/src/cli/register-standby.js +0 -26
- package/src/commands/architect.js +0 -111
- package/src/commands/autorun.js +0 -49
- package/src/commands/researcher.js +0 -54
- package/src/commands/resume.js +0 -72
- package/src/commands/review.js +0 -89
- package/src/commands/run.js +0 -185
- package/src/commands/standby.js +0 -117
- package/src/commands/status.js +0 -36
- package/src/commands/triage.js +0 -78
- package/src/commands/undo.js +0 -62
- package/src/domains/domain-loader.js +0 -245
- package/src/domains/domain-registry.js +0 -140
- package/src/domains/domain-synthesizer.js +0 -129
- package/src/git/automation.js +0 -433
- package/src/git/coder-commit-guard.js +0 -40
- package/src/git/hu-automation.js +0 -243
- package/src/git/hu-snapshot.js +0 -10
- package/src/git/symlink-targets.js +0 -57
- package/src/golden/asserter.js +0 -92
- package/src/golden/loader.js +0 -52
- package/src/golden/runner.js +0 -92
- package/src/golden/schema.js +0 -41
- package/src/guards/duplicate-members.js +0 -86
- package/src/guards/intent-guard.js +0 -161
- package/src/guards/perf-guard.js +0 -126
- package/src/guards/policy-guard.js +0 -90
- package/src/guards/policy-resolver.js +0 -85
- package/src/guards/secret-redactor.js +0 -71
- package/src/hu/acceptance-runner.js +0 -138
- package/src/hu/lazy-planner.js +0 -109
- package/src/hu/parallel-executor.js +0 -94
- package/src/hu/routing-metrics.js +0 -17
- package/src/hu/split-validator.js +0 -143
- package/src/hu/splitting-detector.js +0 -158
- package/src/hu/splitting-generator.js +0 -175
- package/src/hu/store.js +0 -394
- package/src/infrastructure/mocks.js +0 -182
- package/src/mcp/handlers/run-handler.js +0 -318
- package/src/mcp/sovereignty-guard.js +0 -113
- package/src/mcp/tool-arg-normalizers.js +0 -16
- package/src/mutate/reviewer-signal.js +0 -76
- package/src/orchestrator/agent-fallback.js +0 -81
- package/src/orchestrator/brain-coordinator.js +0 -186
- package/src/orchestrator/ci-integration.js +0 -139
- package/src/orchestrator/config-init.js +0 -426
- package/src/orchestrator/direct-actions.js +0 -217
- package/src/orchestrator/drivers/error-recovery.js +0 -287
- package/src/orchestrator/drivers/init-context.js +0 -238
- package/src/orchestrator/drivers/iteration-loop.js +0 -382
- package/src/orchestrator/drivers/iteration-phases/coder-and-refactorer.js +0 -69
- package/src/orchestrator/drivers/iteration-phases/guards.js +0 -91
- package/src/orchestrator/drivers/iteration-phases/handle-approved.js +0 -29
- package/src/orchestrator/drivers/iteration-phases/quality-gates.js +0 -125
- package/src/orchestrator/drivers/iteration-phases/reviewer-gate.js +0 -62
- package/src/orchestrator/drivers/post-loop.js +0 -404
- package/src/orchestrator/drivers/pre-loop-phases/auto-hu-batch.js +0 -137
- package/src/orchestrator/drivers/pre-loop-phases/config-deprecations.js +0 -47
- package/src/orchestrator/drivers/pre-loop-phases/ensure-addyosmani-skills.js +0 -84
- package/src/orchestrator/drivers/pre-loop-phases/inject-loaded-plan.js +0 -393
- package/src/orchestrator/drivers/pre-loop.js +0 -524
- package/src/orchestrator/drivers/run-hu-batch.js +0 -468
- package/src/orchestrator/feedback-enrichment.js +0 -140
- package/src/orchestrator/feedback-queue.js +0 -151
- package/src/orchestrator/flow-control.js +0 -170
- package/src/orchestrator/flow-runner.js +0 -365
- package/src/orchestrator/fs-leak-detector.js +0 -228
- package/src/orchestrator/hu-scheduler.js +0 -114
- package/src/orchestrator/hu-sub-pipeline.js +0 -642
- package/src/orchestrator/iteration-gate.js +0 -73
- package/src/orchestrator/iteration-stages.js +0 -9
- package/src/orchestrator/parallel-limiter.js +0 -74
- package/src/orchestrator/pipeline-context.js +0 -72
- package/src/orchestrator/post-loop-stages.js +0 -468
- package/src/orchestrator/pre-loop-stages.js +0 -11
- package/src/orchestrator/preflight-checks.js +0 -487
- package/src/orchestrator/repair/repair-detector.js +0 -117
- package/src/orchestrator/repair/repair-runner.js +0 -142
- package/src/orchestrator/reviewer-fallback.js +0 -45
- package/src/orchestrator/role-output-compressor.js +0 -189
- package/src/orchestrator/session-journal.js +0 -308
- package/src/orchestrator/solomon-escalation.js +0 -331
- package/src/orchestrator/solomon-rules.js +0 -212
- package/src/orchestrator/stages/acceptance-coverage-stage.js +0 -47
- package/src/orchestrator/stages/architect-stage.js +0 -172
- package/src/orchestrator/stages/coder-stage.js +0 -506
- package/src/orchestrator/stages/domain-curator-stage.js +0 -82
- package/src/orchestrator/stages/format-stage.js +0 -61
- package/src/orchestrator/stages/hu-reviewer-phases/detect-and-apply-splits.js +0 -127
- package/src/orchestrator/stages/hu-reviewer-stage.js +0 -419
- package/src/orchestrator/stages/perf-stage.js +0 -140
- package/src/orchestrator/stages/planner-stage.js +0 -85
- package/src/orchestrator/stages/rag-context-stage.js +0 -80
- package/src/orchestrator/stages/rag-preload-decisor.js +0 -58
- package/src/orchestrator/stages/research-stage.js +0 -69
- package/src/orchestrator/stages/reviewer-stage.js +0 -431
- package/src/orchestrator/stages/sonar-stage.js +0 -439
- package/src/orchestrator/stages/stage-classes.js +0 -84
- package/src/orchestrator/stages/stage-executor.js +0 -155
- package/src/orchestrator/stages/suite-green-stage.js +0 -62
- package/src/orchestrator/stages/tdd-discipline-stage.js +0 -56
- package/src/orchestrator/stages/tool-judge-stage.js +0 -53
- package/src/orchestrator/stages/triage-stage.js +0 -172
- package/src/orchestrator/standby.js +0 -71
- package/src/orchestrator/verification-gate.js +0 -183
- package/src/orchestrator.js +0 -22
- package/src/plan/adr-generator.js +0 -170
- package/src/plan/adr-loader.js +0 -60
- package/src/plan/plan-executor.js +0 -100
- package/src/plan/plan-validation.js +0 -4
- package/src/prompts/acceptance-coverage.js +0 -32
- package/src/prompts/arbiter.js +0 -38
- package/src/prompts/architect.js +0 -103
- package/src/prompts/hu-reviewer.js +0 -244
- package/src/prompts/tool-correctness-judge.js +0 -31
- package/src/prompts/triage.js +0 -57
- package/src/rag/embedder.js +0 -2
- package/src/rag/embedders/_cloud-base.js +0 -2
- package/src/rag/embedders/cohere.js +0 -2
- package/src/rag/embedders/mistral.js +0 -2
- package/src/rag/embedders/onnx.js +0 -2
- package/src/rag/embedders/openai.js +0 -2
- package/src/rag/embedders/voyage.js +0 -2
- package/src/rag/rerank.js +0 -4
- package/src/rag/where-parser.js +0 -4
- package/src/repeat-detector.js +0 -88
- package/src/review/diff-generator.js +0 -112
- package/src/review/git-stash-helper.js +0 -104
- package/src/review/schema.js +0 -31
- package/src/review/scope-filter.js +0 -152
- package/src/review/snapshot-diff.js +0 -122
- package/src/review/tdd-discipline.js +0 -90
- package/src/review/tdd-policy.js +0 -69
- package/src/roles/acceptance-coverage-role.js +0 -78
- package/src/roles/architect-role.js +0 -77
- package/src/roles/coder-role.js +0 -113
- package/src/roles/commiter-role.js +0 -113
- package/src/roles/domain-curator-role.js +0 -134
- package/src/roles/hu-reviewer-role.js +0 -64
- package/src/roles/impeccable-role.js +0 -85
- package/src/roles/index.js +0 -18
- package/src/roles/karajan-brain-role.js +0 -134
- package/src/roles/perf-role.js +0 -122
- package/src/roles/planner-role.js +0 -151
- package/src/roles/refactorer-role.js +0 -30
- package/src/roles/repairer-role.js +0 -181
- package/src/roles/researcher-role.js +0 -70
- package/src/roles/reviewer-role.js +0 -115
- package/src/roles/security-role.js +0 -73
- package/src/roles/solomon-role.js +0 -271
- package/src/roles/sonar-role.js +0 -72
- package/src/roles/tester-role.js +0 -235
- package/src/roles/tool-correctness-judge-role.js +0 -78
- package/src/roles/triage-role.js +0 -99
- package/src/session/journal/decisions-writer.js +0 -200
- package/src/session/journal/iteration-logger.js +0 -194
- package/src/session/journal/summary-writer.js +0 -320
- package/src/session/journal/tree-writer.js +0 -164
- package/src/session/journal/write-all.js +0 -89
- package/src/session-cleanup.js +0 -116
- package/src/skills/semantic-detector.js +0 -167
- package/src/skills/skill-detector.js +0 -385
- package/src/sonar/cloud-scanner.js +0 -78
- package/src/tracker-bootstrap.js +0 -44
- package/src/types/index.js +0 -38
- package/src/types/policy.js +0 -43
- package/src/types/solomon.js +0 -87
- package/src/utils/async-lock.js +0 -31
- package/src/utils/budget.js +0 -229
- package/src/utils/cwd-confirm.js +0 -39
- package/src/utils/display/event-handlers.js +0 -403
- package/src/utils/display/formatters.js +0 -132
- package/src/utils/display/header.js +0 -47
- package/src/utils/display/session-summary.js +0 -118
- package/src/utils/display/solomon.js +0 -42
- package/src/utils/pricing.js +0 -29
- package/src/utils/quota-simulator.js +0 -56
- package/src/utils/role-assigner.js +0 -137
- package/src/utils/rtk-wrapper.js +0 -87
- package/src/utils/run-registry.js +0 -9
- package/src/utils/status-dashboard.js +0 -254
- package/src/utils/tool-call-extractor.js +0 -56
- package/src/webperf/devtools-detect.js +0 -112
- package/src/webperf/webperf-role-integration.js +0 -66
- package/templates/skills/kj-run.md +0 -73
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detects needed skills from task description and project files,
|
|
3
|
-
* then auto-installs them via OpenSkills if available.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import fs from "node:fs/promises";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import { loadAvailableSkills } from "./skill-loader.js";
|
|
9
|
-
import { isOpenSkillsAvailable, installSkill, removeSkill } from "./openskills-client.js";
|
|
10
|
-
import { isFresh as isCacheFresh, recordInstall as recordSkillInstall } from "./skills-cache.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Known frameworks detectable from package.json dependencies.
|
|
14
|
-
* Maps dependency name to the skill name to search for.
|
|
15
|
-
*/
|
|
16
|
-
const PKG_JSON_FRAMEWORKS = {
|
|
17
|
-
astro: "astro",
|
|
18
|
-
next: "nextjs",
|
|
19
|
-
react: "react",
|
|
20
|
-
"react-dom": "react",
|
|
21
|
-
vue: "vue",
|
|
22
|
-
svelte: "svelte",
|
|
23
|
-
"@angular/core": "angular",
|
|
24
|
-
express: "express",
|
|
25
|
-
fastify: "fastify",
|
|
26
|
-
"@nestjs/core": "nestjs",
|
|
27
|
-
// DB / ORM
|
|
28
|
-
prisma: "prisma",
|
|
29
|
-
"@prisma/client": "prisma",
|
|
30
|
-
knex: "sql-analysis",
|
|
31
|
-
sequelize: "sql-analysis",
|
|
32
|
-
typeorm: "sql-analysis",
|
|
33
|
-
mongoose: "mongodb",
|
|
34
|
-
"better-sqlite3": "sql-analysis",
|
|
35
|
-
// Testing
|
|
36
|
-
vitest: "vitest-patterns",
|
|
37
|
-
jest: "jest-patterns",
|
|
38
|
-
"@playwright/test": "playwright-patterns",
|
|
39
|
-
cypress: "cypress-patterns",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Python dependency names (from requirements.txt or pyproject.toml) mapping
|
|
44
|
-
* to their canonical skill.
|
|
45
|
-
*/
|
|
46
|
-
const PYTHON_DEPS = {
|
|
47
|
-
pandas: "python-data",
|
|
48
|
-
numpy: "python-data",
|
|
49
|
-
scipy: "python-data",
|
|
50
|
-
"scikit-learn": "python-ml",
|
|
51
|
-
sklearn: "python-ml",
|
|
52
|
-
tensorflow: "python-ml",
|
|
53
|
-
torch: "python-ml",
|
|
54
|
-
pytorch: "python-ml",
|
|
55
|
-
pytest: "pytest-patterns",
|
|
56
|
-
django: "python-django",
|
|
57
|
-
flask: "python-flask",
|
|
58
|
-
fastapi: "python-fastapi",
|
|
59
|
-
sqlalchemy: "sql-analysis",
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Language markers: file presence maps to a skill name.
|
|
64
|
-
* Reuses the same concept as src/utils/project-detect.js LANGUAGE_MARKERS.
|
|
65
|
-
*/
|
|
66
|
-
const LANGUAGE_FILE_MARKERS = [
|
|
67
|
-
{ file: "pom.xml", skill: "java" },
|
|
68
|
-
{ file: "build.gradle", skill: "java" },
|
|
69
|
-
{ file: "build.gradle.kts", skill: "kotlin" },
|
|
70
|
-
{ file: "go.mod", skill: "go" },
|
|
71
|
-
{ file: "Cargo.toml", skill: "rust" },
|
|
72
|
-
{ file: "pyproject.toml", skill: "python" },
|
|
73
|
-
{ file: "requirements.txt", skill: "python" },
|
|
74
|
-
{ file: "setup.py", skill: "python" },
|
|
75
|
-
{ file: "Gemfile", skill: "ruby" },
|
|
76
|
-
{ file: "pubspec.yaml", skill: "flutter" },
|
|
77
|
-
{ file: "Package.swift", skill: "swift" },
|
|
78
|
-
{ file: "phpunit.xml", skill: "php" },
|
|
79
|
-
{ file: "composer.json", skill: "php" },
|
|
80
|
-
{ file: "mix.exs", skill: "elixir" },
|
|
81
|
-
{ file: "rebar.config", skill: "erlang" },
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* File EXTENSIONS whose presence anywhere under projectDir adds a skill.
|
|
86
|
-
* Uses a shallow-recursive glob with a cutoff to avoid walking node_modules.
|
|
87
|
-
*/
|
|
88
|
-
const EXTENSION_MARKERS = [
|
|
89
|
-
{ ext: ".csproj", skill: "dotnet" },
|
|
90
|
-
{ ext: ".sln", skill: "dotnet" },
|
|
91
|
-
{ ext: ".ipynb", skill: "python-data" },
|
|
92
|
-
{ ext: ".prisma", skill: "prisma" },
|
|
93
|
-
];
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Files detected as "SQL / database schema" when they exist at repo root.
|
|
97
|
-
* Used in addition to EXTENSION_MARKERS for *.sql anywhere in the repo.
|
|
98
|
-
*/
|
|
99
|
-
const SQL_MARKER_FILES = [
|
|
100
|
-
"schema.sql",
|
|
101
|
-
"schema.prisma",
|
|
102
|
-
"migrations",
|
|
103
|
-
"db/migrate",
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
const DIRECTORIES_TO_SKIP = new Set([
|
|
107
|
-
"node_modules", ".git", ".kj", ".karajan", "dist", "build", ".next", "out",
|
|
108
|
-
"target", ".venv", "venv", "__pycache__", ".vitest-cache", "coverage",
|
|
109
|
-
]);
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Patterns to detect framework/skill mentions in the task text.
|
|
113
|
-
* Each entry: regex pattern (case-insensitive) -> skill name.
|
|
114
|
-
*/
|
|
115
|
-
const TASK_TEXT_PATTERNS = [
|
|
116
|
-
{ pattern: /\bastro\b/i, skill: "astro" },
|
|
117
|
-
{ pattern: /\bnext\.?js\b/i, skill: "nextjs" },
|
|
118
|
-
{ pattern: /\breact\b/i, skill: "react" },
|
|
119
|
-
{ pattern: /\bvue\b/i, skill: "vue" },
|
|
120
|
-
{ pattern: /\bsvelte\b/i, skill: "svelte" },
|
|
121
|
-
{ pattern: /\bangular\b/i, skill: "angular" },
|
|
122
|
-
{ pattern: /\bexpress\b/i, skill: "express" },
|
|
123
|
-
{ pattern: /\bfastify\b/i, skill: "fastify" },
|
|
124
|
-
{ pattern: /\bnest\.?js\b/i, skill: "nestjs" },
|
|
125
|
-
{ pattern: /\bjava\b/i, skill: "java" },
|
|
126
|
-
{ pattern: /\bkotlin\b/i, skill: "kotlin" },
|
|
127
|
-
{ pattern: /\bgo(?:lang)?\b/i, skill: "go" },
|
|
128
|
-
{ pattern: /\brust\b/i, skill: "rust" },
|
|
129
|
-
{ pattern: /\bpython\b/i, skill: "python" },
|
|
130
|
-
{ pattern: /\bdjango\b/i, skill: "python" },
|
|
131
|
-
{ pattern: /\bflask\b/i, skill: "python" },
|
|
132
|
-
{ pattern: /\bruby\b/i, skill: "ruby" },
|
|
133
|
-
{ pattern: /\bflutter\b/i, skill: "flutter" },
|
|
134
|
-
{ pattern: /\bswift\b/i, skill: "swift" },
|
|
135
|
-
{ pattern: /\bphp\b/i, skill: "php" },
|
|
136
|
-
{ pattern: /\bSQL\b/i, skill: "sql-analysis" },
|
|
137
|
-
{ pattern: /\bquer(?:y|ies)\b/i, skill: "sql-analysis" },
|
|
138
|
-
{ pattern: /\bdatabase\b/i, skill: "sql-analysis" },
|
|
139
|
-
{ pattern: /\bCSV\b/i, skill: "csv-transform" },
|
|
140
|
-
{ pattern: /\btransform\b/i, skill: "csv-transform" },
|
|
141
|
-
{ pattern: /\bparse\b/i, skill: "csv-transform" },
|
|
142
|
-
{ pattern: /\breport\b/i, skill: "data-report" },
|
|
143
|
-
{ pattern: /\banalysis\b/i, skill: "data-report" },
|
|
144
|
-
{ pattern: /\bfindings\b/i, skill: "data-report" },
|
|
145
|
-
// Frontend/backend broad categories
|
|
146
|
-
{ pattern: /\bfrontend\b/i, skill: "frontend-design" },
|
|
147
|
-
{ pattern: /\bCSS\b/i, skill: "frontend-design" },
|
|
148
|
-
{ pattern: /\bHTML\b/i, skill: "frontend-design" },
|
|
149
|
-
{ pattern: /\bbackend\b/i, skill: "express" },
|
|
150
|
-
{ pattern: /\bnode\.?js\b/i, skill: "express" },
|
|
151
|
-
{ pattern: /\bAPI\b/, skill: "express" },
|
|
152
|
-
{ pattern: /\bwebsocket\b/i, skill: "express" },
|
|
153
|
-
{ pattern: /\breal[- ]time\b/i, skill: "express" },
|
|
154
|
-
];
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Analyze the task and project to determine what skills might be needed.
|
|
158
|
-
*
|
|
159
|
-
* @param {string} task - The task description text.
|
|
160
|
-
* @param {string} projectDir - Absolute path to project root.
|
|
161
|
-
* @param {{ includeExtensions?: boolean, maxDepth?: number }} [options]
|
|
162
|
-
* - includeExtensions: scan for file extensions (.csproj, .ipynb, .sql...)
|
|
163
|
-
* that signal a stack. Default true. Disable to avoid the shallow walk
|
|
164
|
-
* in very large repos or in tests.
|
|
165
|
-
* - maxDepth: bound the walk (default 3 directories deep).
|
|
166
|
-
* @returns {Promise<string[]>} Array of unique skill names to search for.
|
|
167
|
-
*/
|
|
168
|
-
export async function detectNeededSkills(task, projectDir, options = {}) {
|
|
169
|
-
const { includeExtensions = true, maxDepth = 3 } = options;
|
|
170
|
-
const needed = new Set();
|
|
171
|
-
|
|
172
|
-
// 1. Scan package.json for known frameworks and JS-ecosystem deps
|
|
173
|
-
if (projectDir) {
|
|
174
|
-
try {
|
|
175
|
-
const pkgRaw = await fs.readFile(path.join(projectDir, "package.json"), "utf8");
|
|
176
|
-
const pkg = JSON.parse(pkgRaw);
|
|
177
|
-
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
178
|
-
for (const [dep, skill] of Object.entries(PKG_JSON_FRAMEWORKS)) {
|
|
179
|
-
if (allDeps[dep]) {
|
|
180
|
-
needed.add(skill);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
} catch { /* no package.json or parse error — skip */ }
|
|
184
|
-
|
|
185
|
-
// 2. Language marker files at repo root
|
|
186
|
-
for (const marker of LANGUAGE_FILE_MARKERS) {
|
|
187
|
-
try {
|
|
188
|
-
await fs.access(path.join(projectDir, marker.file));
|
|
189
|
-
needed.add(marker.skill);
|
|
190
|
-
} catch { /* file not found — skip */ }
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// 3. Python deps from requirements.txt / pyproject.toml
|
|
194
|
-
await collectPythonDeps(projectDir, needed);
|
|
195
|
-
|
|
196
|
-
// 4. File extension markers (.csproj, .ipynb, .prisma, *.sql)
|
|
197
|
-
if (includeExtensions) {
|
|
198
|
-
await collectExtensionMarkers(projectDir, maxDepth, needed);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// 5. SQL / DB schema markers at well-known paths
|
|
202
|
-
for (const candidate of SQL_MARKER_FILES) {
|
|
203
|
-
try {
|
|
204
|
-
await fs.access(path.join(projectDir, candidate));
|
|
205
|
-
needed.add("sql-analysis");
|
|
206
|
-
} catch { /* skip */ }
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// 6. Task text patterns
|
|
211
|
-
if (task) {
|
|
212
|
-
for (const { pattern, skill } of TASK_TEXT_PATTERNS) {
|
|
213
|
-
if (pattern.test(task)) {
|
|
214
|
-
needed.add(skill);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return Array.from(needed);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
async function collectPythonDeps(projectDir, needed) {
|
|
223
|
-
// requirements.txt — each non-comment line is "name==ver" or "name>=ver"
|
|
224
|
-
try {
|
|
225
|
-
const raw = await fs.readFile(path.join(projectDir, "requirements.txt"), "utf8");
|
|
226
|
-
for (const line of raw.split("\n")) {
|
|
227
|
-
const trimmed = line.trim().split("#")[0].trim();
|
|
228
|
-
if (!trimmed) continue;
|
|
229
|
-
const name = trimmed.split(/[<>=!~[\s]/)[0].toLowerCase();
|
|
230
|
-
const skill = PYTHON_DEPS[name];
|
|
231
|
-
if (skill) needed.add(skill);
|
|
232
|
-
}
|
|
233
|
-
} catch { /* no requirements.txt */ }
|
|
234
|
-
|
|
235
|
-
// pyproject.toml — simple heuristic scan for dependency names. A full TOML
|
|
236
|
-
// parse would need a dep; we just look for quoted names, which is fine.
|
|
237
|
-
try {
|
|
238
|
-
const raw = await fs.readFile(path.join(projectDir, "pyproject.toml"), "utf8");
|
|
239
|
-
const lower = raw.toLowerCase();
|
|
240
|
-
for (const [name, skill] of Object.entries(PYTHON_DEPS)) {
|
|
241
|
-
if (lower.includes(`"${name}"`) || lower.includes(`'${name}'`)) {
|
|
242
|
-
needed.add(skill);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
} catch { /* no pyproject.toml */ }
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function collectExtensionMarkers(projectDir, maxDepth, needed) {
|
|
249
|
-
// Build a lookup by extension for fast decisions.
|
|
250
|
-
const byExt = new Map(EXTENSION_MARKERS.map((m) => [m.ext, m.skill]));
|
|
251
|
-
const extensions = new Set(byExt.keys());
|
|
252
|
-
extensions.add(".sql");
|
|
253
|
-
let sqlFound = false;
|
|
254
|
-
|
|
255
|
-
async function walk(dir, depth) {
|
|
256
|
-
if (depth > maxDepth) return;
|
|
257
|
-
let entries;
|
|
258
|
-
try {
|
|
259
|
-
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
260
|
-
} catch {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
for (const entry of entries) {
|
|
264
|
-
if (entry.isDirectory()) {
|
|
265
|
-
if (DIRECTORIES_TO_SKIP.has(entry.name)) continue;
|
|
266
|
-
if (entry.name.startsWith(".")) continue;
|
|
267
|
-
await walk(path.join(dir, entry.name), depth + 1);
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
if (!entry.isFile()) continue;
|
|
271
|
-
const ext = path.extname(entry.name).toLowerCase();
|
|
272
|
-
if (!extensions.has(ext)) continue;
|
|
273
|
-
if (ext === ".sql") {
|
|
274
|
-
sqlFound = true;
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
const skill = byExt.get(ext);
|
|
278
|
-
if (skill) needed.add(skill);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
await walk(projectDir, 0);
|
|
283
|
-
if (sqlFound) needed.add("sql-analysis");
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Auto-install needed skills that are not yet installed.
|
|
288
|
-
*
|
|
289
|
-
* When the `openskills` CLI is not available, this function degrades
|
|
290
|
-
* gracefully: it returns `osAvailable: false` and `wouldHaveUsed` with the
|
|
291
|
-
* list of skills that would have been installed if the CLI had been present.
|
|
292
|
-
* Callers (e.g. the orchestrator) can surface this info in the session
|
|
293
|
-
* report without blocking execution.
|
|
294
|
-
*
|
|
295
|
-
* @param {string[]} neededSkills - Skill names to ensure are installed.
|
|
296
|
-
* @param {string} projectDir - Absolute path to project root.
|
|
297
|
-
* @returns {Promise<{
|
|
298
|
-
* installed: string[],
|
|
299
|
-
* failed: string[],
|
|
300
|
-
* alreadyInstalled: string[],
|
|
301
|
-
* wouldHaveUsed: string[],
|
|
302
|
-
* osAvailable: boolean
|
|
303
|
-
* }>}
|
|
304
|
-
*/
|
|
305
|
-
export async function autoInstallSkills(neededSkills, projectDir) {
|
|
306
|
-
const result = { installed: [], failed: [], alreadyInstalled: [], wouldHaveUsed: [], osAvailable: true };
|
|
307
|
-
|
|
308
|
-
if (!neededSkills || neededSkills.length === 0) {
|
|
309
|
-
return result;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Check which skills are already installed locally
|
|
313
|
-
const existingSkills = await loadAvailableSkills(projectDir);
|
|
314
|
-
const existingNames = new Set(existingSkills.map(s => s.name.toLowerCase()));
|
|
315
|
-
|
|
316
|
-
// Check if OpenSkills is available
|
|
317
|
-
const osAvailable = await isOpenSkillsAvailable();
|
|
318
|
-
if (!osAvailable) {
|
|
319
|
-
result.osAvailable = false;
|
|
320
|
-
// Report what we would have installed so the session report can surface
|
|
321
|
-
// the recommendation — "install openskills globally to enable: X, Y, Z".
|
|
322
|
-
result.wouldHaveUsed = neededSkills.filter((s) => !existingNames.has(s.toLowerCase()));
|
|
323
|
-
return result;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
for (const skillName of neededSkills) {
|
|
327
|
-
if (existingNames.has(skillName.toLowerCase())) {
|
|
328
|
-
result.alreadyInstalled.push(skillName);
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// Cache short-circuit: if we installed this skill in the last 7 days,
|
|
333
|
-
// assume it's still good and skip the `npx openskills install` call
|
|
334
|
-
// (which can take 10-30s). Running sessions can opt out by clearing
|
|
335
|
-
// the cache with `kj skills clear-cache`.
|
|
336
|
-
if (await isCacheFresh(skillName)) {
|
|
337
|
-
result.alreadyInstalled.push(skillName);
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
try {
|
|
342
|
-
const installResult = await installSkill(skillName, { projectDir });
|
|
343
|
-
if (installResult.ok) {
|
|
344
|
-
const installedName = installResult.name || skillName;
|
|
345
|
-
result.installed.push(installedName);
|
|
346
|
-
await recordSkillInstall(installedName, { source: skillName }).catch(() => {});
|
|
347
|
-
} else {
|
|
348
|
-
result.failed.push(skillName);
|
|
349
|
-
}
|
|
350
|
-
} catch { /* skill install threw */
|
|
351
|
-
result.failed.push(skillName);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return result;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Remove skills that were auto-installed during this session.
|
|
360
|
-
* @param {string[]} skillNames - Skill names to remove.
|
|
361
|
-
* @param {string} projectDir - Absolute path to project root.
|
|
362
|
-
* @returns {Promise<{removed: string[], failed: string[]}>}
|
|
363
|
-
*/
|
|
364
|
-
export async function cleanupAutoInstalledSkills(skillNames, projectDir) {
|
|
365
|
-
const result = { removed: [], failed: [] };
|
|
366
|
-
|
|
367
|
-
if (!skillNames || skillNames.length === 0) {
|
|
368
|
-
return result;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
for (const name of skillNames) {
|
|
372
|
-
try {
|
|
373
|
-
const removeResult = await removeSkill(name, { projectDir });
|
|
374
|
-
if (removeResult.ok) {
|
|
375
|
-
result.removed.push(name);
|
|
376
|
-
} else {
|
|
377
|
-
result.failed.push(name);
|
|
378
|
-
}
|
|
379
|
-
} catch { /* skill removal threw */
|
|
380
|
-
result.failed.push(name);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return result;
|
|
385
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { runCommand } from "../utils/process.js";
|
|
2
|
-
import { resolveSonarProjectKey } from "./project-key.js";
|
|
3
|
-
|
|
4
|
-
function buildCloudScannerArgs(projectKey, config) {
|
|
5
|
-
const sc = config.sonarcloud || {};
|
|
6
|
-
const scanner = sc.scanner || {};
|
|
7
|
-
const host = sc.host || "https://sonarcloud.io";
|
|
8
|
-
const organization = process.env.KJ_SONARCLOUD_ORG || sc.organization;
|
|
9
|
-
|
|
10
|
-
const args = [
|
|
11
|
-
`-Dsonar.host.url=${host}`,
|
|
12
|
-
`-Dsonar.projectKey=${projectKey}`
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
// Token passed via SONAR_TOKEN env var, not CLI args (invisible in `ps aux`)
|
|
16
|
-
if (organization) args.push(`-Dsonar.organization=${organization}`);
|
|
17
|
-
if (scanner.sources) args.push(`-Dsonar.sources=${scanner.sources}`);
|
|
18
|
-
if (scanner.exclusions) args.push(`-Dsonar.exclusions=${scanner.exclusions}`);
|
|
19
|
-
if (scanner.test_inclusions) args.push(`-Dsonar.test.inclusions=${scanner.test_inclusions}`);
|
|
20
|
-
|
|
21
|
-
return args;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function runSonarCloudScan(config, projectKey = null) {
|
|
25
|
-
const sc = config.sonarcloud || {};
|
|
26
|
-
const token = process.env.KJ_SONARCLOUD_TOKEN || sc.token;
|
|
27
|
-
const organization = sc.organization || process.env.KJ_SONARCLOUD_ORG;
|
|
28
|
-
|
|
29
|
-
if (!token) {
|
|
30
|
-
return {
|
|
31
|
-
ok: false,
|
|
32
|
-
projectKey: null,
|
|
33
|
-
stdout: "",
|
|
34
|
-
stderr: "SonarCloud token not configured. Set sonarcloud.token in kj.config.yml or KJ_SONARCLOUD_TOKEN env var.",
|
|
35
|
-
exitCode: 1
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!organization) {
|
|
40
|
-
return {
|
|
41
|
-
ok: false,
|
|
42
|
-
projectKey: null,
|
|
43
|
-
stdout: "",
|
|
44
|
-
stderr: "SonarCloud organization not configured. Set sonarcloud.organization in kj.config.yml or KJ_SONARCLOUD_ORG env var.",
|
|
45
|
-
exitCode: 1
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let effectiveProjectKey;
|
|
50
|
-
try {
|
|
51
|
-
effectiveProjectKey = projectKey || sc.project_key || await resolveSonarProjectKey(config, { projectKey });
|
|
52
|
-
} catch (error) {
|
|
53
|
-
return {
|
|
54
|
-
ok: false,
|
|
55
|
-
projectKey: null,
|
|
56
|
-
stdout: "",
|
|
57
|
-
stderr: error?.message || String(error),
|
|
58
|
-
exitCode: 1
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const scannerTimeout = 15 * 60 * 1000;
|
|
63
|
-
const args = buildCloudScannerArgs(effectiveProjectKey, config);
|
|
64
|
-
|
|
65
|
-
// Pass token via process env, not CLI args — invisible in `ps aux`
|
|
66
|
-
const env = { ...process.env };
|
|
67
|
-
if (token) env.SONAR_TOKEN = token;
|
|
68
|
-
|
|
69
|
-
const result = await runCommand("npx", ["@sonar/scan", ...args], { timeout: scannerTimeout, env });
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
ok: result.exitCode === 0,
|
|
73
|
-
projectKey: effectiveProjectKey,
|
|
74
|
-
stdout: result.stdout,
|
|
75
|
-
stderr: result.stderr,
|
|
76
|
-
exitCode: result.exitCode
|
|
77
|
-
};
|
|
78
|
-
}
|
package/src/tracker-bootstrap.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tracker bootstrap — registers the configured task-tracker adapter into
|
|
3
|
-
* the orchestrator's integrations registry at runtime.
|
|
4
|
-
*
|
|
5
|
-
* This module exists so that `src/orchestrator/` never imports
|
|
6
|
-
* `src/planning-game/` (or any other tracker) directly — the architecture
|
|
7
|
-
* invariant `tests/architecture/tracker-coupling.test.js` enforces that.
|
|
8
|
-
* `runFlow` calls `ensureTrackerRegistered(config)` from here; this
|
|
9
|
-
* module owns the conditional import of each adapter.
|
|
10
|
-
*
|
|
11
|
-
* Adding a new tracker:
|
|
12
|
-
* 1. Write `src/adapters/<name>/adapter.js` with the hook surface
|
|
13
|
-
* documented in `src/orchestrator/integrations.js`.
|
|
14
|
-
* 2. Add a branch below that imports and registers it when the relevant
|
|
15
|
-
* config flag is true.
|
|
16
|
-
*
|
|
17
|
-
* The function is idempotent: once registered, subsequent calls are
|
|
18
|
-
* no-ops (the registry already has an entry for the slot).
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import { getIntegration, registerIntegration } from "./orchestrator/integrations.js";
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Ensure the tracker adapter configured by `config` is registered under
|
|
25
|
-
* the `"tracker"` slot. Safe to call on every `runFlow` invocation.
|
|
26
|
-
*
|
|
27
|
-
* @param {object|null} config
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
*/
|
|
30
|
-
export async function ensureTrackerRegistered(config) {
|
|
31
|
-
if (getIntegration("tracker")) return; // Already registered.
|
|
32
|
-
|
|
33
|
-
if (config?.planning_game?.enabled) {
|
|
34
|
-
try {
|
|
35
|
-
const { planningGameAdapter } = await import("./planning-game/pipeline-adapter.js");
|
|
36
|
-
registerIntegration("tracker", planningGameAdapter);
|
|
37
|
-
} catch { /* registration failed — non-blocking, adapter stays absent */ }
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// No tracker enabled — the orchestrator's `getIntegration("tracker")`
|
|
42
|
-
// calls will return undefined and every hook becomes an optional-chain
|
|
43
|
-
// no-op. That's the intended behavior for "tracker disabled" runs.
|
|
44
|
-
}
|
package/src/types/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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 {};
|
package/src/types/policy.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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 {};
|
package/src/types/solomon.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
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 {};
|