@skathio/somi 4.1.1 → 5.0.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/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +8 -3
- package/.claude-plugin/plugin.json +9 -10
- package/.copilot-extension/extension.json +32 -40
- package/.copilot-extension/marketplace.json +8 -3
- package/README.md +83 -228
- package/VERSION +1 -1
- package/agents/somi-reviewer.md +21 -40
- package/agents/somi-security-reviewer.md +16 -90
- package/agents/somi-worker-high.md +11 -0
- package/agents/somi-worker-low.md +11 -0
- package/agents/somi-worker-medium.md +11 -0
- package/agents/somi.md +8 -75
- package/commands/somi-config.md +5 -14
- package/commands/somi-deliver.md +11 -0
- package/commands/somi-quality.md +10 -0
- package/commands/somi-review.md +10 -0
- package/commands/somi-status.md +11 -0
- package/commands/somi.md +10 -0
- package/hooks/hooks.json +28 -23
- package/hooks/lib/common.mjs +45 -34
- package/hooks/pre-tool/apply-tier.mjs +31 -0
- package/hooks/pre-tool/block-dangerous-bash.mjs +15 -0
- package/hooks/pre-tool/gate-dep-install.mjs +2 -2
- package/hooks/pre-tool/guard-protected-paths.mjs +9 -16
- package/hooks/pre-tool/guard-tier-config.mjs +17 -0
- package/hooks/pre-tool/reviewers-read-only.mjs +11 -0
- package/hooks/session-start/inject-digest.mjs +51 -0
- package/hooks/stop/review-due.mjs +40 -0
- package/hooks/user-prompt/capture-prompt.mjs +17 -0
- package/library/lenses/architecture.md +1 -0
- package/library/lenses/test-strategy.md +1 -0
- package/library/roles/accessibility.md +1 -0
- package/library/roles/answer.md +1 -0
- package/library/roles/atlas.md +1 -0
- package/library/roles/build.md +1 -0
- package/library/roles/debug.md +6 -0
- package/library/roles/design.md +1 -0
- package/library/roles/discover.md +1 -0
- package/library/roles/incident.md +1 -0
- package/library/roles/migrate.md +1 -0
- package/library/roles/perf.md +1 -0
- package/library/roles/plan.md +1 -0
- package/library/roles/refactor.md +1 -0
- package/library/roles/review.md +1 -0
- package/library/roles/security-review.md +1 -0
- package/library/roles/upgrade.md +1 -0
- package/library/skills/accessibility.md +16 -0
- package/library/skills/ci-infra-gotchas.md +12 -0
- package/library/skills/perf-method.md +10 -0
- package/library/skills/secure-coding.md +18 -0
- package/library/skills/testing-checklist.md +16 -0
- package/library/skills/threat-modeling.md +10 -0
- package/package.json +12 -17
- package/profiles/claude.json +21 -0
- package/profiles/copilot.json +5 -0
- package/rules/digest.md +40 -0
- package/scripts/check-links.mjs +65 -76
- package/scripts/lib/advisor.mjs +207 -0
- package/scripts/lib/check.mjs +165 -0
- package/scripts/lib/copilot-workflow.mjs +41 -0
- package/scripts/lib/doctor.mjs +91 -0
- package/scripts/lib/gates.mjs +69 -0
- package/scripts/lib/git-tree.mjs +201 -0
- package/scripts/lib/init.mjs +23 -0
- package/scripts/lib/ledger.mjs +38 -0
- package/scripts/lib/mcp-project-root.mjs +63 -67
- package/scripts/lib/migrate.mjs +73 -0
- package/scripts/lib/path-facts.mjs +2 -2
- package/scripts/lib/path-safety.mjs +6 -134
- package/scripts/lib/plan.mjs +69 -0
- package/scripts/lib/policy.mjs +103 -0
- package/scripts/lib/pr.mjs +28 -0
- package/scripts/lib/prompt.mjs +72 -0
- package/scripts/lib/quality/clones.mjs +76 -0
- package/scripts/lib/quality/css.mjs +43 -0
- package/scripts/lib/quality/gate.mjs +230 -0
- package/scripts/lib/quality/limits.mjs +73 -0
- package/scripts/lib/quality/metrics.mjs +159 -0
- package/scripts/lib/quality/parse.mjs +73 -0
- package/scripts/lib/quality/repo.mjs +69 -0
- package/scripts/lib/quality/run.mjs +38 -0
- package/scripts/lib/reviews.mjs +132 -0
- package/scripts/lib/routes.mjs +108 -0
- package/scripts/lib/setup.mjs +34 -0
- package/scripts/lib/shards.mjs +166 -0
- package/scripts/lib/signals.mjs +110 -0
- package/scripts/lib/state.mjs +42 -0
- package/scripts/lib/tiers.mjs +42 -0
- package/scripts/lib/update-notice.mjs +48 -0
- package/scripts/lib/views.mjs +62 -0
- package/scripts/lib/workflows.mjs +56 -0
- package/scripts/somi-mcp.mjs +181 -323
- package/scripts/somi.mjs +208 -0
- package/scripts/vendor/tree-sitter/LICENSE.vscode-tree-sitter-wasm +21 -0
- package/scripts/vendor/tree-sitter/LICENSE.web-tree-sitter +21 -0
- package/scripts/vendor/tree-sitter/cgmanifest.vscode-tree-sitter-wasm.json +16 -0
- package/scripts/vendor/tree-sitter/manifest.json +59 -0
- package/scripts/vendor/tree-sitter/package.json +3 -0
- package/scripts/vendor/tree-sitter/tree-sitter-css.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-javascript.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-tsx.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-typescript.wasm +0 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.js +4081 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.wasm +0 -0
- package/skills/somi-expertise/SKILL.md +6 -0
- package/workflows/deliver-stages.js +81 -0
- package/.claude/settings.json +0 -131
- package/agents/somi-architecture-reviewer.md +0 -101
- package/agents/somi-atlas.md +0 -100
- package/agents/somi-coder.md +0 -60
- package/agents/somi-designer.md +0 -36
- package/agents/somi-discovery-analyst.md +0 -57
- package/agents/somi-flow.md +0 -47
- package/agents/somi-general.md +0 -36
- package/agents/somi-impact.md +0 -95
- package/agents/somi-incident.md +0 -94
- package/agents/somi-plan-reviewer.md +0 -68
- package/agents/somi-planner.md +0 -57
- package/agents/somi-pr.md +0 -99
- package/agents/somi-refactor-designer.md +0 -81
- package/agents/somi-refactorer.md +0 -99
- package/agents/somi-sdlc-reviewer.md +0 -67
- package/agents/somi-test-strategist.md +0 -87
- package/commands/adopt.md +0 -14
- package/commands/architecture-review.md +0 -19
- package/commands/atlas.md +0 -19
- package/commands/code-loop.md +0 -19
- package/commands/code-parallel.md +0 -19
- package/commands/code.md +0 -19
- package/commands/debug.md +0 -19
- package/commands/design.md +0 -19
- package/commands/discover.md +0 -19
- package/commands/impact.md +0 -19
- package/commands/incident.md +0 -19
- package/commands/plan-loop.md +0 -19
- package/commands/plan.md +0 -19
- package/commands/pr.md +0 -19
- package/commands/refactor-design.md +0 -19
- package/commands/refactor.md +0 -19
- package/commands/release-readiness.md +0 -19
- package/commands/review-panel.md +0 -19
- package/commands/review.md +0 -19
- package/commands/security-review.md +0 -19
- package/commands/ship-loop.md +0 -19
- package/commands/ship.md +0 -19
- package/commands/test-strategy.md +0 -19
- package/commands/upgrade.md +0 -19
- package/examples/README.md +0 -19
- package/examples/code-review-example.md +0 -88
- package/examples/discovery-example.md +0 -200
- package/examples/feature-plan-example.md +0 -377
- package/examples/full-pipeline-example.md +0 -188
- package/examples/sample-consumer/.claude/settings.json +0 -29
- package/examples/sample-consumer/CLAUDE.md +0 -78
- package/examples/sample-consumer/README.md +0 -102
- package/hooks/post-tool/lint-changed-files.mjs +0 -209
- package/hooks/pre-tool/guard-cost-lowering.mjs +0 -192
- package/hooks/session-start/detect-repo-instructions.mjs +0 -287
- package/hooks/session-start/ensure-default-config.mjs +0 -113
- package/hooks/user-prompt-submit/inject-workflow-context.mjs +0 -580
- package/rules/00-priorities.md +0 -48
- package/rules/10-solid.md +0 -87
- package/rules/20-clean-code.md +0 -62
- package/rules/30-security-owasp.md +0 -83
- package/rules/40-engineering-practices.md +0 -65
- package/rules/50-collaboration.md +0 -114
- package/rules/99-overrides.md +0 -52
- package/rules/CLAUDE.md +0 -200
- package/scripts/check-session-artefacts.mjs +0 -149
- package/scripts/check-size-budget.mjs +0 -137
- package/scripts/generate-digest.mjs +0 -176
- package/scripts/lib/agent-info.mjs +0 -85
- package/scripts/lib/agent-registry.mjs +0 -92
- package/scripts/lib/cost-ceiling.mjs +0 -328
- package/scripts/lib/cost-config-edit.mjs +0 -102
- package/scripts/lib/cost-config.mjs +0 -64
- package/scripts/lib/cost-defaults.mjs +0 -53
- package/scripts/lib/cost-lowering.mjs +0 -89
- package/scripts/lib/cost-model.mjs +0 -110
- package/scripts/lib/dispatch-resolver.mjs +0 -243
- package/scripts/lib/escalation-facts.mjs +0 -146
- package/scripts/lib/escalation.mjs +0 -129
- package/scripts/lib/findings-ledger.mjs +0 -241
- package/scripts/lib/install-text.mjs +0 -97
- package/scripts/lib/loop-caps.mjs +0 -140
- package/scripts/lib/loop-diff.mjs +0 -38
- package/scripts/lib/loop-dispatch.mjs +0 -19
- package/scripts/lib/loop-engine.mjs +0 -227
- package/scripts/lib/loop-escalate.mjs +0 -49
- package/scripts/lib/loop-exit.mjs +0 -47
- package/scripts/lib/loop-notes-compact.mjs +0 -72
- package/scripts/lib/loop-notes.mjs +0 -282
- package/scripts/lib/loop-review.mjs +0 -395
- package/scripts/lib/loop-state.mjs +0 -44
- package/scripts/lib/loop-step-close.mjs +0 -75
- package/scripts/lib/loop-step-kit.mjs +0 -179
- package/scripts/lib/loop-step-review.mjs +0 -140
- package/scripts/lib/loop-step-tool.mjs +0 -89
- package/scripts/lib/loop-step.mjs +0 -303
- package/scripts/lib/run-budget.mjs +0 -28
- package/scripts/lib/run-card.mjs +0 -73
- package/scripts/lib/size-tier.mjs +0 -184
- package/scripts/lib/tier-record.mjs +0 -82
- package/scripts/size-budget-overrides.json +0 -58
- package/scripts/somi-card.mjs +0 -39
- package/scripts/somi-check.mjs +0 -237
- package/scripts/somi-config.mjs +0 -421
- package/scripts/somi-dispatch.mjs +0 -141
- package/scripts/somi-findings.mjs +0 -100
- package/scripts/somi-loop.mjs +0 -139
- package/scripts/somi-tier.mjs +0 -393
- package/scripts/validate.sh +0 -653
- package/skills/api-design/SKILL.md +0 -147
- package/skills/clean-code/SKILL.md +0 -142
- package/skills/flow-adopt/SKILL.md +0 -92
- package/skills/flow-architecture-review/SKILL.md +0 -94
- package/skills/flow-atlas/SKILL.md +0 -34
- package/skills/flow-code/SKILL.md +0 -167
- package/skills/flow-code-loop/SKILL.md +0 -263
- package/skills/flow-code-parallel/SKILL.md +0 -160
- package/skills/flow-debug/SKILL.md +0 -141
- package/skills/flow-design/SKILL.md +0 -170
- package/skills/flow-discover/SKILL.md +0 -204
- package/skills/flow-impact/SKILL.md +0 -35
- package/skills/flow-incident/SKILL.md +0 -49
- package/skills/flow-plan/SKILL.md +0 -254
- package/skills/flow-plan-loop/SKILL.md +0 -254
- package/skills/flow-pr/SKILL.md +0 -34
- package/skills/flow-refactor/SKILL.md +0 -58
- package/skills/flow-refactor-design/SKILL.md +0 -97
- package/skills/flow-release-readiness/SKILL.md +0 -82
- package/skills/flow-review/SKILL.md +0 -193
- package/skills/flow-review-panel/SKILL.md +0 -154
- package/skills/flow-security-review/SKILL.md +0 -83
- package/skills/flow-ship/SKILL.md +0 -125
- package/skills/flow-ship-loop/SKILL.md +0 -274
- package/skills/flow-somi-config/SKILL.md +0 -142
- package/skills/flow-status/SKILL.md +0 -43
- package/skills/flow-test-strategy/SKILL.md +0 -83
- package/skills/flow-upgrade/SKILL.md +0 -82
- package/skills/market-research/SKILL.md +0 -125
- package/skills/observability/SKILL.md +0 -133
- package/skills/owasp-defense/SKILL.md +0 -141
- package/skills/plan-review/SKILL.md +0 -83
- package/skills/reasoning-craft/SKILL.md +0 -213
- package/skills/requirements-engineering/SKILL.md +0 -137
- package/skills/role-coder/SKILL.md +0 -247
- package/skills/role-designer/SKILL.md +0 -172
- package/skills/role-discovery-analyst/SKILL.md +0 -288
- package/skills/role-planner/SKILL.md +0 -353
- package/skills/role-reviewer/SKILL.md +0 -218
- package/skills/rules/SKILL.md +0 -47
- package/skills/sdlc-process/SKILL.md +0 -74
- package/skills/solid-principles/SKILL.md +0 -143
- package/skills/somi-checkpoint/SKILL.md +0 -95
- package/skills/somi-dispatch/SKILL.md +0 -259
- package/skills/somi-routing/SKILL.md +0 -158
- package/skills/testing-playbook/SKILL.md +0 -133
- package/skills/threat-modeling/SKILL.md +0 -117
- package/templates/ADR.md.tmpl +0 -73
- package/templates/ATLAS.md.tmpl +0 -75
- package/templates/BRD.md.tmpl +0 -68
- package/templates/BRIEF.md.tmpl +0 -119
- package/templates/CONTEXT.md.tmpl +0 -74
- package/templates/DECISIONS.md.tmpl +0 -105
- package/templates/DESIGN.md.tmpl +0 -83
- package/templates/DIARY.md.tmpl +0 -70
- package/templates/DOD.md.tmpl +0 -90
- package/templates/FRD.md.tmpl +0 -64
- package/templates/PHASE.md.tmpl +0 -80
- package/templates/PROGRESS.md.tmpl +0 -63
- package/templates/RCA.md.tmpl +0 -53
- package/templates/RD-README.md.tmpl +0 -70
- package/templates/RESEARCH.md.tmpl +0 -96
- package/templates/REVIEW.md.tmpl +0 -82
- package/templates/SDD.md.tmpl +0 -82
- package/templates/SOMI-README.md.tmpl +0 -83
- package/templates/SPEC.md.tmpl +0 -123
- package/templates/SRS.md.tmpl +0 -85
- package/templates/TDD.md.tmpl +0 -77
- package/tests/hooks/cases/audit-log.json +0 -21
- package/tests/hooks/cases/block-dangerous-bash.json +0 -166
- package/tests/hooks/cases/block-secret-writes.json +0 -140
- package/tests/hooks/cases/detect-repo-instructions.json +0 -105
- package/tests/hooks/cases/gate-dep-install.json +0 -42
- package/tests/hooks/cases/guard-protected-paths.json +0 -222
- package/tests/hooks/cases/inject-workflow-context.json +0 -239
- package/tests/hooks/cases/lint-changed-files.json +0 -120
- package/tests/hooks/run.sh +0 -392
- package/tests/scripts/agent-model-frontmatter.sh +0 -38
- package/tests/scripts/agent-names.sh +0 -77
- package/tests/scripts/check-frontmatter.sh +0 -37
- package/tests/scripts/check-links.sh +0 -105
- package/tests/scripts/check-session-artefacts.sh +0 -60
- package/tests/scripts/check-size-budget.sh +0 -71
- package/tests/scripts/checkpoint-gate.sh +0 -131
- package/tests/scripts/convergence-runner.sh +0 -1514
- package/tests/scripts/cost-ceiling.sh +0 -255
- package/tests/scripts/cost-defaults.sh +0 -130
- package/tests/scripts/cost-hardcap.sh +0 -338
- package/tests/scripts/cost-lowering.sh +0 -261
- package/tests/scripts/cost-model.sh +0 -196
- package/tests/scripts/dispatch-guard.sh +0 -108
- package/tests/scripts/dispatch-line-gate.sh +0 -61
- package/tests/scripts/dispatch-reference-gate.sh +0 -173
- package/tests/scripts/ensure-default-config.sh +0 -162
- package/tests/scripts/escalation.sh +0 -409
- package/tests/scripts/eval-runner.sh +0 -3692
- package/tests/scripts/evals-packaging.sh +0 -224
- package/tests/scripts/fact-sheet.sh +0 -296
- package/tests/scripts/fixtures/legacy-shard-no-schema.json +0 -50
- package/tests/scripts/fixtures/mock-stdin-read-throw.cjs +0 -18
- package/tests/scripts/fixtures/size-tier-cases.json +0 -87
- package/tests/scripts/generate-digest.sh +0 -180
- package/tests/scripts/global-config.sh +0 -167
- package/tests/scripts/goldens/loop-state-breach.json +0 -1
- package/tests/scripts/goldens/loop-state-done.json +0 -1
- package/tests/scripts/goldens/somi-findings.json +0 -336
- package/tests/scripts/goldens/somi-loop.json +0 -168
- package/tests/scripts/lib/adr-shape.mjs +0 -41
- package/tests/scripts/lib/agent-registry-tests.mjs +0 -95
- package/tests/scripts/lib/brief-only-guard.mjs +0 -27
- package/tests/scripts/lib/checkpoint-gate.mjs +0 -91
- package/tests/scripts/lib/digest-marker-coupling.mjs +0 -52
- package/tests/scripts/lib/dispatch-reference-gate.mjs +0 -121
- package/tests/scripts/lib/escalation-facts-tests.mjs +0 -140
- package/tests/scripts/lib/escalation-tests.mjs +0 -154
- package/tests/scripts/lib/findings-ledger-tests.mjs +0 -118
- package/tests/scripts/lib/loop-engine-tests.mjs +0 -287
- package/tests/scripts/lib/loop-escalate-tests.mjs +0 -356
- package/tests/scripts/lib/loop-flow-gate.mjs +0 -173
- package/tests/scripts/lib/loop-notes-tests.mjs +0 -384
- package/tests/scripts/lib/loop-step-cli-tests.mjs +0 -156
- package/tests/scripts/lib/loop-step-close-tests.mjs +0 -351
- package/tests/scripts/lib/loop-step-lenient-tests.mjs +0 -114
- package/tests/scripts/lib/loop-step-state-tests.mjs +0 -127
- package/tests/scripts/lib/loop-step-tests.mjs +0 -499
- package/tests/scripts/lib/loop-step-unwritten-tests.mjs +0 -55
- package/tests/scripts/lib/multipass-dependence.mjs +0 -192
- package/tests/scripts/lib/multipass-source-identity.mjs +0 -243
- package/tests/scripts/lib/path-facts-tests.mjs +0 -198
- package/tests/scripts/lib/path-safety-tests.mjs +0 -201
- package/tests/scripts/lib/reference-pair.mjs +0 -61
- package/tests/scripts/lib/retirement-gate.mjs +0 -172
- package/tests/scripts/lib/run-suites.mjs +0 -139
- package/tests/scripts/lib/shell-embedded-js.mjs +0 -47
- package/tests/scripts/lib/ship-loop-sizing-guard.mjs +0 -52
- package/tests/scripts/lib/site-roadmap-gate.mjs +0 -64
- package/tests/scripts/lib/size-tier-drift.mjs +0 -74
- package/tests/scripts/lib/sizing-score-tests.mjs +0 -210
- package/tests/scripts/lib/sizing-set-tests.mjs +0 -131
- package/tests/scripts/lib/somi-mcp-client.mjs +0 -102
- package/tests/scripts/lib/somi-mcp-config-tests.mjs +0 -92
- package/tests/scripts/lib/somi-mcp-loop-tests.mjs +0 -226
- package/tests/scripts/lib/somi-mcp-tests.mjs +0 -491
- package/tests/scripts/lib/somi-mcp-tier-tests.mjs +0 -64
- package/tests/scripts/lib/somi-mcp-tool-schema.mjs +0 -38
- package/tests/scripts/loop-engine.sh +0 -22
- package/tests/scripts/loop-flow-gate.sh +0 -11
- package/tests/scripts/retirement-gate.sh +0 -306
- package/tests/scripts/review-panel-seats.sh +0 -32
- package/tests/scripts/run-card.sh +0 -57
- package/tests/scripts/run-suites.sh +0 -74
- package/tests/scripts/run.sh +0 -689
- package/tests/scripts/site-roadmap-gate.sh +0 -76
- package/tests/scripts/size-tier.sh +0 -562
- package/tests/scripts/somi-agent-dispatch-contract.sh +0 -224
- package/tests/scripts/somi-config.sh +0 -286
- package/tests/scripts/somi-dispatch.sh +0 -465
- package/tests/scripts/somi-mcp.sh +0 -15
- package/tests/scripts/suite-plan.json +0 -20
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// signals.mjs: whether a change needs a reviewer, computed only from the real diff. Raise-only and deterministic: same diff,
|
|
2
|
+
// same answer. No forecast of how big the work might be, and no config can switch a built-in signal off (config only adds paths).
|
|
3
|
+
// The patterns route review attention. They are not a security boundary: the OS sandbox is the boundary.
|
|
4
|
+
|
|
5
|
+
import { classifyPaths } from './path-facts.mjs';
|
|
6
|
+
import { denyListed, foldName, trimDots } from './path-safety.mjs';
|
|
7
|
+
|
|
8
|
+
export const LARGE_DIFF_LINES = 300;
|
|
9
|
+
export const REVIEW_SIGNALS = Object.freeze(['multi-module', 'public-api', 'schema', 'tests-weakened', 'dependency', 'goldens-moved', 'large-diff', 'unreadable-diff']);
|
|
10
|
+
// Recorded, but they do not start a review on their own: review on these cost 68% more per task and showed no gain on hidden tests.
|
|
11
|
+
export const RECORDED_ONLY = Object.freeze(['multi-module', 'public-api', 'large-diff']);
|
|
12
|
+
export const SECURITY_SIGNALS = Object.freeze(['sink', 'secrets', 'network', 'repo-content', 'policy-file', 'sensitive-path', 'access-control', 'unreadable-diff']);
|
|
13
|
+
|
|
14
|
+
const DOC = /\.(md|mdx|txt|rst|adoc)$/i;
|
|
15
|
+
export const TEST_FILE = /(^|\/)(tests?|__tests__|spec|specs|e2e|testdata|__mocks__)\/|\.(test|spec)\.[^/]+$|[_-](test|spec)\.[^/]+$|(^|\/)test_[^/]+$/i;
|
|
16
|
+
const GOLDEN = /(^|\/)(goldens?|__snapshots__|snapshots)\/|\.(snap|golden)$/i;
|
|
17
|
+
const MAX_SCANNED_LINE = 2000;
|
|
18
|
+
|
|
19
|
+
const SINK = [
|
|
20
|
+
/\b(exec|execSync|execFile|execFileSync|spawn|spawnSync|fork|popen|system|subprocess\.\w+|child_process|ProcessBuilder)\b|shell\s*=\s*True/,
|
|
21
|
+
/\beval\s*\(|\bnew\s+Function\s*\(/,
|
|
22
|
+
/\b(SELECT\s+.+\s+FROM|INSERT\s+INTO|UPDATE\s+\w+\s+SET|DELETE\s+FROM)\b|\.(query|raw|execute)\s*\(/i,
|
|
23
|
+
/\b(readFile|readFileSync|writeFile|writeFileSync|createReadStream|createWriteStream|unlink|unlinkSync|rmSync|sendFile)\s*\(|\bos\.path\.join\b|\bopen\s*\(/,
|
|
24
|
+
/\b(pickle\.loads?|yaml\.load|unserialize|Marshal\.load|ObjectInputStream|deserialize\w*)\b/,
|
|
25
|
+
/\bnew\s+RegExp\s*\(|\bre\.compile\s*\(/,
|
|
26
|
+
];
|
|
27
|
+
// A regex's own exec runs nothing: a regex literal, or a name that says it is one. Any other receiver still counts, so cp.exec(cmd) fires,
|
|
28
|
+
// and so does exec(cmd) on its own.
|
|
29
|
+
const REGEX_EXEC = /(\/(?:\\.|[^/\\\n])+\/[dgimsuyv]*|\b(?:re|regexp?|pattern|[\w$]*(?:_RE|_REGEXP?|_PATTERN|Re|Regexp?|RegExp|Pattern)|RE|REGEXP?|PATTERN))\.exec\s*\(/g;
|
|
30
|
+
// A whole-line comment runs nothing either, so a sink, a call out or an access check named in one does not count. Secrets are still read
|
|
31
|
+
// there, because a key pasted into a comment is still out.
|
|
32
|
+
const COMMENT_LINE = /^\s*(\/\/|\/\*|\*(\s|\/|$)|#(\s|$)|--\s)/;
|
|
33
|
+
// No word boundaries: hashPassword and resetToken are the same thing as password and token, and a false alarm here costs one review.
|
|
34
|
+
const SECRETS = /password|passwd|secret|credential|private[_-]?key|api[_-]?key|(auth|access|bearer|refresh|reset|session|id)[_-]?token/i;
|
|
35
|
+
const NETWORK = /\b(fetch|axios|XMLHttpRequest|WebSocket|urllib\w*|requests\.(get|post|put|delete)|https?\.(request|get)|net\.(connect|createConnection))\b/;
|
|
36
|
+
// Who may do what: roles, permissions, owners and tenants. A permissions refactor fired no signal and leaked across organisations, so a
|
|
37
|
+
// changed line here, added or removed, calls in the security lens. Removing a check is as much a change to access as adding one.
|
|
38
|
+
const ACCESS = /\b(authori[sz]\w*|permissions?|is_?allowed|has_?(role|permission|access)|check_?access|can_?access|require_?role|access[_-]?control|acl|rbac|forbidden|unauthori[sz]ed|is_?admin|tenant[_-]?id|org(anisation|anization)?[_-]?id|owner[_-]?id)\b|\broles?\s*\.\s*(includes|has|indexOf|some)\s*\(/i;
|
|
39
|
+
const REPO_CONTENT = /\.gitmodules|\.git\/|core\.hooksPath|\bgit\s+(config|submodule|clone)\b|\.mcp\.json/;
|
|
40
|
+
const WEAKENS_TEST = /\.(skip|only|todo)\s*\(|\bx(it|describe|test)\s*\(|@(Ignore|Disabled)\b|pytest\.mark\.skip/;
|
|
41
|
+
const ASSERTION = /\b(assert\w*|expect|should)\b|\b(it|test)\s*\(/;
|
|
42
|
+
const EXPORT_LINE = /^\s*(export\s+(default\s+|async\s+)?(function|class|const|let|var|type|interface|enum|\{)|module\.exports\b|exports\.\w+\s*=|pub\s+(fn|struct|enum|trait)\b|public\s+[\w<>[\]]+\s+\w+\s*\()/;
|
|
43
|
+
const EXPORTED_VALUE = /^\s*export\s+(?:const|let|var)\s+(\w+)/;
|
|
44
|
+
|
|
45
|
+
// Files an agent's own behaviour hangs on. Frozen as a signal: it routes the security lens and is not hardened further.
|
|
46
|
+
function isPolicyFile(file) {
|
|
47
|
+
const segs = file.split(/[\\/]+/).map((s) => trimDots(foldName(s)));
|
|
48
|
+
return ['.claude', 'claude.md', 'claude.local.md', 'agents.md', '.mcp.json', '.gitmodules', '.gitattributes'].some((n) => segs.includes(n))
|
|
49
|
+
|| segs.some((s, i) => s === '.vscode' && segs[i + 1] === 'mcp.json')
|
|
50
|
+
|| (segs[0] === '.github' && (segs[1] === 'hooks' || segs[1] === 'copilot-instructions.md'))
|
|
51
|
+
|| (segs[0] === '.somi' && (segs[1] === 'config.json' || segs[1] === 'rules'));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const clip = (text) => (text.length > MAX_SCANNED_LINE ? text.slice(0, MAX_SCANNED_LINE) : text);
|
|
55
|
+
// A changed export value keeps the interface, so a constant compares by name. Anything else compares by its whole line, because a
|
|
56
|
+
// changed function signature is exactly what the signal is for.
|
|
57
|
+
const exportKey = (l) => `${l.file}\n${EXPORTED_VALUE.exec(l.text)?.[1] ?? l.text.trim()}`;
|
|
58
|
+
function removesExport(lines) {
|
|
59
|
+
const exports = lines.filter((l) => isCode(l.file) && EXPORT_LINE.test(clip(l.text)));
|
|
60
|
+
const kept = new Set(exports.filter((l) => l.sign === '+').map(exportKey));
|
|
61
|
+
return exports.some((l) => l.sign === '-' && !kept.has(exportKey(l)));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const hits = (lines, test) => lines.some((l) => test(clip(l.text)));
|
|
65
|
+
const isCode = (file) => !DOC.test(file) && !TEST_FILE.test(file);
|
|
66
|
+
const sorted = (set) => [...set].sort();
|
|
67
|
+
|
|
68
|
+
function testsWeakened(rows, lines) {
|
|
69
|
+
const testLines = lines.filter((l) => TEST_FILE.test(l.file));
|
|
70
|
+
const assertions = (sign) => testLines.filter((l) => l.sign === sign && ASSERTION.test(clip(l.text))).length;
|
|
71
|
+
const deletedTest = rows.some((r) => TEST_FILE.test(r.file) && r.status.startsWith('D'));
|
|
72
|
+
return deletedTest || assertions('-') > assertions('+') || hits(testLines.filter((l) => l.sign === '+'), (t) => WEAKENS_TEST.test(t));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function reviewSignals({ rows, lines, files, all, production, changed }) {
|
|
76
|
+
const review = new Set();
|
|
77
|
+
if (changed > LARGE_DIFF_LINES) review.add('large-diff');
|
|
78
|
+
if (production.modules > 1) review.add('multi-module');
|
|
79
|
+
if (all.contract.includes('schema')) review.add('schema');
|
|
80
|
+
if (all.contract.includes('lockfile') || all.contract.includes('manifest')) review.add('dependency');
|
|
81
|
+
if (files.some((f) => GOLDEN.test(f))) review.add('goldens-moved');
|
|
82
|
+
if (removesExport(lines)) review.add('public-api');
|
|
83
|
+
if (testsWeakened(rows, lines)) review.add('tests-weakened');
|
|
84
|
+
return review;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Patterns read on added code. Access checks are read on any changed code, because removing one is as much a change to access.
|
|
88
|
+
const isSink = (t) => { const code = t.replace(REGEX_EXEC, ''); return SINK.some((p) => p.test(code)); };
|
|
89
|
+
const ADDED_CODE_SIGNALS = [['sink', isSink, true], ['secrets', (t) => SECRETS.test(t), false], ['network', (t) => NETWORK.test(t), true], ['repo-content', (t) => REPO_CONTENT.test(t), false]];
|
|
90
|
+
const runs = (l) => !COMMENT_LINE.test(l.text);
|
|
91
|
+
|
|
92
|
+
function securitySignals({ lines, files, production }) {
|
|
93
|
+
const security = new Set();
|
|
94
|
+
if (production.sensitive.length + production.boundary.length > 0 || files.some(denyListed)) security.add('sensitive-path');
|
|
95
|
+
if (files.some(isPolicyFile)) security.add('policy-file');
|
|
96
|
+
const addedCode = lines.filter((l) => l.sign === '+' && isCode(l.file));
|
|
97
|
+
for (const [name, test, codeOnly] of ADDED_CODE_SIGNALS) if (hits(codeOnly ? addedCode.filter(runs) : addedCode, test)) security.add(name);
|
|
98
|
+
if (hits(lines.filter((l) => isCode(l.file) && runs(l)), (t) => ACCESS.test(t))) security.add('access-control');
|
|
99
|
+
return security;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function computeSignals({ rows, lines, unreadable = false }, configLayers = []) {
|
|
103
|
+
if (unreadable) return { review: ['unreadable-diff'], security: ['unreadable-diff'], facts: { files: 0, changed_lines: 0, modules: 0 } };
|
|
104
|
+
const files = rows.map((r) => r.file);
|
|
105
|
+
const changed = rows.reduce((n, r) => n + r.added + r.deleted, 0);
|
|
106
|
+
const all = classifyPaths(files, configLayers);
|
|
107
|
+
const production = classifyPaths(files.filter(isCode), configLayers);
|
|
108
|
+
const facts = { rows, lines, files, all, production, changed };
|
|
109
|
+
return { review: sorted(reviewSignals(facts)), security: sorted(securitySignals(facts)), facts: { files: files.length, changed_lines: changed, modules: production.modules } };
|
|
110
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// state.mjs: the few files SoMi keeps in its state folder. Nothing here steers the work. These files only remember what happened, so a new
|
|
2
|
+
// session, a compacted one and `somi pr` can read it. A committed link must not redirect a write, so each folder on the way is checked.
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
export class StateError extends Error {}
|
|
8
|
+
|
|
9
|
+
export function statePaths(root, env = process.env) {
|
|
10
|
+
const dir = env.SOMI_STATE_DIR ? path.resolve(env.SOMI_STATE_DIR) : path.join(root, '.somi', 'state');
|
|
11
|
+
return { dir, reviews: path.join(dir, 'reviews.jsonl'), check: path.join(dir, 'check.json') };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function refuseLink(p) {
|
|
15
|
+
let st;
|
|
16
|
+
try { st = fs.lstatSync(p); } catch (e) { if (e.code === 'ENOENT') return false; throw e; }
|
|
17
|
+
if (st.isSymbolicLink()) throw new StateError(`refusing to write through a link at ${p}; set SOMI_STATE_DIR to keep state elsewhere`);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function ensureSomiDir(root) {
|
|
22
|
+
const somi = path.join(root, '.somi');
|
|
23
|
+
if (!refuseLink(somi)) fs.mkdirSync(somi);
|
|
24
|
+
return somi;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function ensureStateDir(root, env = process.env) {
|
|
28
|
+
const { dir } = statePaths(root, env);
|
|
29
|
+
if (env.SOMI_STATE_DIR) { fs.mkdirSync(dir, { recursive: true }); return dir; }
|
|
30
|
+
ensureSomiDir(root);
|
|
31
|
+
if (!refuseLink(dir)) fs.mkdirSync(dir);
|
|
32
|
+
return dir;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function writeState(root, file, text, { env, flag }) {
|
|
36
|
+
ensureStateDir(root, env);
|
|
37
|
+
refuseLink(file);
|
|
38
|
+
fs.writeFileSync(file, text, { flag });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const writeStateFile = (root, file, text, env = process.env) => writeState(root, file, text, { env, flag: 'w' });
|
|
42
|
+
export const appendStateFile = (root, file, text, env = process.env) => writeState(root, file, text, { env, flag: 'a' });
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// tiers.mjs: low, medium and high, set per environment in config. Pure: it names a model. No shared file carries a model name, because names differ per host and go stale, so this table is the one place Claude
|
|
2
|
+
// Code's aliases appear. Copilot ships no map: its models vary by plan, so the user sets them in config. A tier with no model is not
|
|
3
|
+
// enforced, the worker inherits the session's model, and the response says so.
|
|
4
|
+
|
|
5
|
+
export const TIERS = Object.freeze(['low', 'medium', 'high']);
|
|
6
|
+
const DEFAULTS = Object.freeze({
|
|
7
|
+
claude: Object.freeze({ low: 'haiku', medium: 'sonnet', high: 'opus' }),
|
|
8
|
+
copilot: Object.freeze({}),
|
|
9
|
+
});
|
|
10
|
+
const MODEL_NAME = /^[A-Za-z0-9][A-Za-z0-9._:[\]-]{0,63}$/;
|
|
11
|
+
const plain = (o) => o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
12
|
+
|
|
13
|
+
export function detectHost(env = process.env) {
|
|
14
|
+
if (env.SOMI_HOST === 'claude' || env.SOMI_HOST === 'copilot') return env.SOMI_HOST;
|
|
15
|
+
return env.COPILOT_CLI || env.COPILOT_HOME || env.COPILOT_PLUGIN_ROOT || env.COPILOT_PLUGIN_DATA ? 'copilot' : 'claude';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// A ceiling caps every tier for a session or a project. It can only lower one.
|
|
19
|
+
function capped(config, tier) {
|
|
20
|
+
const ceiling = plain(config?.tiers) ? config.tiers.ceiling : undefined;
|
|
21
|
+
if (!TIERS.includes(ceiling)) return tier;
|
|
22
|
+
return TIERS[Math.min(TIERS.indexOf(tier), TIERS.indexOf(ceiling))];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function resolveTier(config, host, tier) {
|
|
26
|
+
const fromConfig = plain(config?.tiers) && plain(config.tiers[host]) ? config.tiers[host][tier] : undefined;
|
|
27
|
+
if (typeof fromConfig === 'string' && MODEL_NAME.test(fromConfig)) return fromConfig;
|
|
28
|
+
return (Object.hasOwn(DEFAULTS, host) ? DEFAULTS[host][tier] : null) ?? null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function resolveSpawn(config, host, wanted) {
|
|
32
|
+
const tier = capped(config, wanted);
|
|
33
|
+
const model = resolveTier(config, host, tier);
|
|
34
|
+
return { tier, model, enforced: model !== null };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The tier the conversation itself runs on: medium, as a bare agent would run, unless the user chose otherwise. Work cheaper than that
|
|
38
|
+
// goes down to a worker and work that needs more goes up. A ceiling can lower it.
|
|
39
|
+
export function mainTier(config) {
|
|
40
|
+
const chosen = plain(config?.tiers) ? config.tiers.main : undefined;
|
|
41
|
+
return capped(config, TIERS.includes(chosen) ? chosen : 'medium');
|
|
42
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// update-notice.mjs: SoMi says when it is out of date and never updates itself. The check runs at most once a day in a detached child,
|
|
2
|
+
// so a slow or blocked network never delays a session, and a sandbox that refuses it just means no notice. SOMI_NO_UPDATE_CHECK turns it off.
|
|
3
|
+
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const DAY_MS = 86400000;
|
|
11
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const cacheFile = (env) => path.join(env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache'), 'somi', 'latest-version.json');
|
|
13
|
+
const installed = () => JSON.parse(fs.readFileSync(path.join(HERE, '..', '..', 'package.json'), 'utf8')).version;
|
|
14
|
+
|
|
15
|
+
export function isNewer(latest, current) {
|
|
16
|
+
const parts = (v) => String(v).split('-')[0].split('.').map(Number);
|
|
17
|
+
const [a, b] = [parts(latest), parts(current)];
|
|
18
|
+
for (let i = 0; i < 3; i++) if ((a[i] ?? 0) !== (b[i] ?? 0)) return (a[i] ?? 0) > (b[i] ?? 0);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function updateNotice(env = process.env, now = Date.now()) {
|
|
23
|
+
if (env.SOMI_NO_UPDATE_CHECK) return null;
|
|
24
|
+
let cached = null;
|
|
25
|
+
try { cached = JSON.parse(fs.readFileSync(cacheFile(env), 'utf8')); } catch { /* no reading yet */ }
|
|
26
|
+
if (!cached || now - (cached.checked_at ?? 0) > DAY_MS) {
|
|
27
|
+
try {
|
|
28
|
+
const child = spawn(process.execPath, [fileURLToPath(import.meta.url), '--refresh'], { detached: true, stdio: 'ignore', env });
|
|
29
|
+
child.unref();
|
|
30
|
+
} catch { /* the notice is a courtesy */ }
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const current = installed();
|
|
34
|
+
if (cached?.latest && isNewer(cached.latest, current)) return `SoMi ${cached.latest} is available; you have ${current}. Tell the user once. SoMi never updates itself.`;
|
|
35
|
+
} catch { /* the notice is a courtesy */ }
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function refresh(env = process.env) {
|
|
40
|
+
const res = await fetch('https://registry.npmjs.org/@skathio/somi/latest', { signal: AbortSignal.timeout(5000) });
|
|
41
|
+
if (!res.ok) return;
|
|
42
|
+
const { version } = await res.json();
|
|
43
|
+
const file = cacheFile(env);
|
|
44
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
45
|
+
fs.writeFileSync(file, JSON.stringify({ latest: version, checked_at: Date.now() }));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (process.argv[1] === fileURLToPath(import.meta.url) && process.argv[2] === '--refresh') refresh().catch(() => {});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// views.mjs: what a person reads about the work, rendered from the plan, ledger and review record on demand. Recorded text came from
|
|
2
|
+
// models and reviewers, so control characters are stripped before it reaches a terminal or a PR body. Pure, so its output can be pinned.
|
|
3
|
+
|
|
4
|
+
import { isBlocking } from './policy.mjs';
|
|
5
|
+
|
|
6
|
+
const plain = (s) => String(s ?? '').replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+/gu, ' ').trim();
|
|
7
|
+
const place = (f) => (f.line ? `${plain(f.file)}:${f.line}` : plain(f.file));
|
|
8
|
+
const finding = (f) => `- ${plain(f.severity)} ${place(f)}: ${plain(f.claim)}`;
|
|
9
|
+
|
|
10
|
+
function loggedFindings(reviews, migrated = []) {
|
|
11
|
+
const seen = new Set();
|
|
12
|
+
const logged = reviews.flatMap((r) => r.findings ?? []).filter((f) => !isBlocking(f)).filter((f) => {
|
|
13
|
+
if (seen.has(f.fingerprint)) return false;
|
|
14
|
+
seen.add(f.fingerprint);
|
|
15
|
+
return true;
|
|
16
|
+
});
|
|
17
|
+
return [...logged, ...migrated];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function renderStatus({ plan, ledger, reviews = [], check, migrated }) {
|
|
21
|
+
const lines = [];
|
|
22
|
+
if (plan) {
|
|
23
|
+
lines.push(`Plan: ${plan.done} of ${plan.total} milestones done`);
|
|
24
|
+
if (plan.next) lines.push(`Next: ${plain(plan.next)}`);
|
|
25
|
+
} else lines.push('No plan open.');
|
|
26
|
+
const last = reviews.at(-1);
|
|
27
|
+
if (last) lines.push('', `Last review: ${(last.verdicts ?? []).map((v) => `${plain(v.agent)}: ${plain(v.verdict)}`).join(', ')}`);
|
|
28
|
+
const blocking = (last?.findings ?? []).filter(isBlocking);
|
|
29
|
+
if (blocking.length > 0) lines.push('', 'Blocking findings:', ...blocking.map(finding));
|
|
30
|
+
const logged = loggedFindings(reviews, migrated);
|
|
31
|
+
if (logged.length > 0) lines.push('', 'Logged findings:', ...logged.map(finding));
|
|
32
|
+
if (ledger) lines.push('', 'Decisions and limits:', ...ledger.split('\n').map(plain).filter(Boolean));
|
|
33
|
+
if (check) lines.push('', `Last check: ${check.ok ? 'passed' : 'failed'}${check.full ? ' (full suite)' : ''}`);
|
|
34
|
+
return `${lines.join('\n')}\n`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const NOT_REVIEWED = (gate) => (gate.reason === 'open-blocking'
|
|
38
|
+
? '> **Not cleared by review.** Blocking findings are still open on this change. See below.'
|
|
39
|
+
: `> **Not reviewed.** SoMi's signals asked for a review of this change, and none covers it: ${gate.signals?.map(plain).join(', ') || 'see the diff'}.`);
|
|
40
|
+
|
|
41
|
+
// Only what a PR reader can use. The commits and the review speak for the work, and local ids stay out, because they do not resolve for
|
|
42
|
+
// anyone who clones the repository.
|
|
43
|
+
export function renderPr({ subjects = [], gate, ledger, reviews = [], check, tree, migrated }) {
|
|
44
|
+
const lines = [];
|
|
45
|
+
if (!gate.ok) lines.push(NOT_REVIEWED(gate), '');
|
|
46
|
+
lines.push('## Summary', '');
|
|
47
|
+
if (subjects.length === 0) lines.push('- No commits yet.');
|
|
48
|
+
for (const s of subjects) lines.push(`- ${plain(s)}`);
|
|
49
|
+
lines.push('', '## Review', '');
|
|
50
|
+
if (gate.review) lines.push((gate.review.verdicts ?? []).map((v) => `- ${plain(v.agent)}: ${plain(v.verdict)}`).join('\n'));
|
|
51
|
+
else if (gate.ok) lines.push('No review was needed: no signal fired on the diff.');
|
|
52
|
+
else lines.push('None.');
|
|
53
|
+
const blocking = gate.blocking ?? [];
|
|
54
|
+
if (blocking.length > 0) lines.push('', '## Blocking findings', '', ...blocking.map(finding));
|
|
55
|
+
const logged = loggedFindings(reviews, migrated);
|
|
56
|
+
if (logged.length > 0) lines.push('', '## Open findings', '', ...logged.map(finding));
|
|
57
|
+
const said = (ledger ?? '').split('\n').map(plain).filter((l) => l.startsWith('- decision:')).map((l) => `- ${l.slice('- decision:'.length).trim()}`);
|
|
58
|
+
if (said.length > 0) lines.push('', '## Decisions', '', ...said);
|
|
59
|
+
const full = check?.full && check.tree === tree;
|
|
60
|
+
lines.push('', '## Checks', '', full ? `Full suite: ${check.ok ? 'passed' : 'failed'}.` : 'Full suite: not recorded for this code.');
|
|
61
|
+
return `${lines.join('\n')}\n`;
|
|
62
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// workflows.mjs: what each route is, at which tier, and the role text it gets. The library behind it can grow without adding anything to
|
|
2
|
+
// what a host lists.
|
|
3
|
+
// kind code work that changes code, which ends in a look at the diff to see whether a review is due.
|
|
4
|
+
// kind plan a plan the user approves, then milestones with fresh context.
|
|
5
|
+
// kind report a worker or reviewer produces an answer, and no code changes.
|
|
6
|
+
// kind command one SoMi command, and its output relayed.
|
|
7
|
+
// kind direct answered from what is on disk, with no agent.
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
|
|
13
|
+
// Writing code is medium work at the least. On the low tier, builds broke rules they were given, wrote tests that passed only their own
|
|
14
|
+
// code, and shipped functions far over the quality limits, and the fixes cost more than the low tier saved. The low tier is kept for
|
|
15
|
+
// gathering information and running commands.
|
|
16
|
+
export const WORKFLOWS = Object.freeze({
|
|
17
|
+
build: { kind: 'code', role: 'build', tier: 'medium', skills: ['testing-checklist'] },
|
|
18
|
+
debug: { kind: 'code', role: 'debug', tier: 'medium', skills: ['testing-checklist'] },
|
|
19
|
+
refactor: { kind: 'code', role: 'refactor', tier: 'medium', skills: ['testing-checklist'] },
|
|
20
|
+
upgrade: { kind: 'code', role: 'upgrade', tier: 'medium', skills: ['ci-infra-gotchas'] },
|
|
21
|
+
migrate: { kind: 'code', role: 'migrate', tier: 'medium', skills: ['ci-infra-gotchas'], alwaysReview: true },
|
|
22
|
+
perf: { kind: 'code', role: 'perf', tier: 'medium', skills: ['perf-method'] },
|
|
23
|
+
incident: { kind: 'code', role: 'incident', tier: 'medium', skills: [] },
|
|
24
|
+
accessibility: { kind: 'code', role: 'accessibility', tier: 'medium', skills: ['accessibility'] },
|
|
25
|
+
plan: { kind: 'plan', role: 'plan', tier: 'medium', skills: [] },
|
|
26
|
+
design: { kind: 'report', role: 'design', tier: 'high', skills: ['threat-modeling'] },
|
|
27
|
+
discover: { kind: 'report', role: 'discover', tier: 'medium', skills: [] },
|
|
28
|
+
atlas: { kind: 'report', role: 'atlas', tier: 'medium', skills: [] },
|
|
29
|
+
answer: { kind: 'report', role: 'answer', tier: 'low', skills: [] },
|
|
30
|
+
review: { kind: 'report', role: 'review', agent: 'somi:somi-reviewer', tier: 'medium', skills: ['testing-checklist'] },
|
|
31
|
+
'security-review': { kind: 'report', role: 'security-review', agent: 'somi:somi-security-reviewer', tier: 'high', skills: ['secure-coding', 'threat-modeling'] },
|
|
32
|
+
ship: { kind: 'command', tier: 'low' },
|
|
33
|
+
status: { kind: 'direct' },
|
|
34
|
+
config: { kind: 'direct' },
|
|
35
|
+
resume: { kind: 'direct' },
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const workerAgent = (tier) => `somi:somi-worker-${tier}`;
|
|
39
|
+
const WORKERS = Object.freeze({ 'somi-worker-low': 'low', 'somi-worker-medium': 'medium', 'somi-worker-high': 'high' });
|
|
40
|
+
// Judging a diff is judgement work, so the code reviewer is never on the low tier.
|
|
41
|
+
const REVIEWERS = Object.freeze({ 'somi-reviewer': 'medium', 'somi-security-reviewer': 'high' });
|
|
42
|
+
const plainName = (name) => String(name ?? '').split(':').pop();
|
|
43
|
+
export const tierForWorker = (name) => (Object.hasOwn(WORKERS, plainName(name)) ? WORKERS[plainName(name)] : null);
|
|
44
|
+
export const tierForReviewer = (name) => (Object.hasOwn(REVIEWERS, plainName(name)) ? REVIEWERS[plainName(name)] : null);
|
|
45
|
+
|
|
46
|
+
const LIBRARY = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'library');
|
|
47
|
+
export const libraryPath = (kind, name) => path.join(LIBRARY, kind, `${name}.md`);
|
|
48
|
+
export const roleBrief = (role) => fs.readFileSync(libraryPath('roles', role), 'utf8').trim();
|
|
49
|
+
|
|
50
|
+
export function expertiseIndex() {
|
|
51
|
+
const dir = path.join(LIBRARY, 'skills');
|
|
52
|
+
return fs.readdirSync(dir).filter((f) => f.endsWith('.md')).sort().map((f) => {
|
|
53
|
+
const first = fs.readFileSync(path.join(dir, f), 'utf8').split('\n').find((l) => l.startsWith('Use when')) ?? '';
|
|
54
|
+
return { name: f.replace(/\.md$/, ''), when: first, path: path.join(dir, f) };
|
|
55
|
+
});
|
|
56
|
+
}
|