sentinelayer-cli 0.4.5 → 0.8.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.
Files changed (72) hide show
  1. package/README.md +16 -18
  2. package/package.json +7 -6
  3. package/src/agents/jules/config/definition.js +13 -62
  4. package/src/agents/jules/config/system-prompt.js +8 -1
  5. package/src/agents/jules/fix-cycle.js +12 -372
  6. package/src/agents/jules/loop.js +116 -26
  7. package/src/agents/jules/pulse.js +10 -327
  8. package/src/agents/jules/stream.js +13 -12
  9. package/src/agents/jules/swarm/orchestrator.js +3 -3
  10. package/src/agents/jules/swarm/sub-agent.js +6 -3
  11. package/src/agents/jules/tools/aidenid-email.js +189 -0
  12. package/src/agents/jules/tools/auth-audit.js +1187 -45
  13. package/src/agents/jules/tools/dispatch.js +25 -12
  14. package/src/agents/jules/tools/file-edit.js +2 -180
  15. package/src/agents/jules/tools/file-read.js +2 -100
  16. package/src/agents/jules/tools/glob.js +2 -168
  17. package/src/agents/jules/tools/grep.js +2 -228
  18. package/src/agents/jules/tools/path-guards.js +2 -161
  19. package/src/agents/jules/tools/runtime-audit.js +6 -2
  20. package/src/agents/jules/tools/shell.js +2 -383
  21. package/src/agents/persona-visuals.js +64 -0
  22. package/src/agents/shared-tools/dispatch-core.js +320 -0
  23. package/src/agents/shared-tools/file-edit.js +180 -0
  24. package/src/agents/shared-tools/file-read.js +100 -0
  25. package/src/agents/shared-tools/glob.js +168 -0
  26. package/src/agents/shared-tools/grep.js +228 -0
  27. package/src/agents/shared-tools/index.js +46 -0
  28. package/src/agents/shared-tools/path-guards.js +161 -0
  29. package/src/agents/shared-tools/shell.js +383 -0
  30. package/src/ai/aidenid.js +56 -7
  31. package/src/ai/client.js +45 -0
  32. package/src/ai/proxy.js +137 -0
  33. package/src/auth/gate.js +290 -16
  34. package/src/auth/http.js +450 -39
  35. package/src/auth/service.js +262 -47
  36. package/src/auth/session-store.js +475 -21
  37. package/src/cli.js +5 -0
  38. package/src/commands/audit.js +13 -8
  39. package/src/commands/auth.js +53 -9
  40. package/src/commands/omargate.js +10 -2
  41. package/src/commands/scan.js +10 -4
  42. package/src/commands/session.js +590 -0
  43. package/src/commands/spec.js +62 -0
  44. package/src/commands/watch.js +3 -2
  45. package/src/daemon/assignment-ledger.js +196 -0
  46. package/src/daemon/error-worker.js +599 -16
  47. package/src/daemon/fix-cycle.js +384 -0
  48. package/src/daemon/ingest-refresh.js +10 -9
  49. package/src/daemon/jira-lifecycle.js +135 -0
  50. package/src/daemon/pulse.js +327 -0
  51. package/src/daemon/scope-engine.js +1068 -0
  52. package/src/events/schema.js +190 -0
  53. package/src/interactive/index.js +18 -16
  54. package/src/legacy-cli.js +606 -37
  55. package/src/prompt/generator.js +19 -1
  56. package/src/review/ai-review.js +11 -1
  57. package/src/review/local-review.js +75 -19
  58. package/src/review/omargate-interactive.js +68 -0
  59. package/src/review/omargate-orchestrator.js +404 -0
  60. package/src/review/persona-prompts.js +296 -0
  61. package/src/review/scan-modes.js +48 -0
  62. package/src/scan/generator.js +1 -1
  63. package/src/session/agent-registry.js +352 -0
  64. package/src/session/daemon.js +801 -0
  65. package/src/session/paths.js +33 -0
  66. package/src/session/runtime-bridge.js +739 -0
  67. package/src/session/store.js +388 -0
  68. package/src/session/stream.js +325 -0
  69. package/src/spec/generator.js +100 -0
  70. package/src/telemetry/session-tracker.js +148 -32
  71. package/src/telemetry/sync.js +6 -2
  72. package/src/ui/command-hints.js +13 -0
package/README.md CHANGED
@@ -44,6 +44,8 @@ sl review --diff
44
44
  sl watch run-events --run-id <run-id>
45
45
  ```
46
46
 
47
+ Windows PowerShell note: `sl` is a built-in alias for `Set-Location`. Use `sentinelayer-cli` (or short alias `slc`) instead.
48
+
47
49
  ## 60-second flow
48
50
 
49
51
  1. Trigger:
@@ -141,18 +143,24 @@ For long-running agent/operator workflows, the CLI now supports persistent auth
141
143
  - `sl auth sessions`
142
144
  - `sl auth revoke --token-id <token-id>`
143
145
 
146
+ On Windows PowerShell, run these as `sentinelayer-cli auth ...` or `slc auth ...`.
147
+
144
148
  Behavior:
145
149
 
146
150
  - login uses browser approval (`/api/v1/auth/cli/sessions/*`)
147
151
  - after approval, CLI mints a long-lived API token (`/api/v1/auth/api-tokens`)
148
152
  - session metadata is stored at `~/.sentinelayer/credentials.json`
149
- - token storage uses OS keyring when `keytar` is available; file fallback is used otherwise
153
+ - token storage uses OS keyring only when explicitly enabled (`SENTINELAYER_KEYRING_MODE=keyring`) and `keytar` is installed; file fallback is used otherwise
150
154
  - near-expiry token rotation is automatic on command use for stored sessions
151
155
  - env/config tokens still take precedence:
152
156
  - `SENTINELAYER_TOKEN`
153
157
  - `.sentinelayer.yml` `sentinelayerToken`
154
158
 
155
- Opt-out of keyring usage:
159
+ Opt-in to keyring usage:
160
+
161
+ - `SENTINELAYER_KEYRING_MODE=keyring` (requires `npm install keytar`)
162
+
163
+ Opt-out of keyring usage (overrides any opt-in):
156
164
 
157
165
  - `SENTINELAYER_DISABLE_KEYRING=1`
158
166
 
@@ -779,6 +787,7 @@ Generate and validate a spec-aligned security workflow:
779
787
  - `scan_mode` + `severity_gate` from spec risk profile
780
788
  - `playwright_mode` from spec signals + optional E2E wizard/flags
781
789
  - `sbom_mode` from supply-chain/dependency signals in spec
790
+ - Action bridge parity: generated `scan_mode` options align to `sentinelayer-v1-action` (`baseline`, `deep`, `audit`, `full-depth`) and use the pinned action ref.
782
791
 
783
792
  `scan validate` checks workflow drift against the current spec profile and exits non-zero when mismatched.
784
793
 
@@ -871,15 +880,10 @@ Ledger contract:
871
880
 
872
881
  This repo includes `.github/workflows/release.yml`.
873
882
  Automated version/tag PR flow is handled by `.github/workflows/release-please.yml`.
874
- AppSec SAST is enforced by `.github/workflows/codeql.yml` (`CodeQL Summary` check).
875
- Custom static policy checks are enforced by `.github/workflows/semgrep.yml` (`Semgrep Summary` check) using `.semgrep/rules/sentinelayer-cli.yml`.
876
- Secret scanning is enforced by `.github/workflows/gitleaks.yml` (`Gitleaks Summary` check).
877
- IaC misconfiguration scanning is enforced by `.github/workflows/iac-scan.yml` (`IaC Summary` check).
878
- Dependency vulnerability policy is enforced by `.github/workflows/sca-audit.yml` (`SCA Summary` check).
879
- Open-source license policy is enforced by `.github/workflows/license-gate.yml` (`License Summary` check) using `.github/policies/license-policy.json` (`allowed_licenses` with `fail_on_unknown` policy behavior).
880
- Dependabot auto-fix governance is enforced by `.github/workflows/dependabot-governance.yml` with policy controls in `.github/policies/dependabot-governance.json`.
881
- SBOM governance is enforced by `.github/workflows/sbom.yml` (`SBOM Summary`) with CycloneDX/SPDX JSON artifacts and hash-manifest output.
882
- Build provenance attestations are enforced by `.github/workflows/attestations.yml` (`Attestation Summary`) with verification against signer-workflow policy.
883
+ Primary gate enforcement is Omar-first:
884
+ - `.github/workflows/omar-gate.yml` (`Omar Gate`) for AppSec findings and merge thresholds
885
+ - `.github/workflows/quality-gates.yml` (`Quality Summary`) for deterministic build/test/package checks
886
+ - `.github/workflows/attestations.yml` (`Attestation Summary`) for provenance verification
883
887
 
884
888
  Prerequisites:
885
889
 
@@ -902,13 +906,6 @@ Release guardrails now require successful upstream checks on the target commit:
902
906
 
903
907
  - `Quality Summary`
904
908
  - `Omar Gate`
905
- - `CodeQL Summary`
906
- - `Semgrep Summary`
907
- - `Gitleaks Summary`
908
- - `IaC Summary`
909
- - `SCA Summary`
910
- - `License Summary`
911
- - `SBOM Summary`
912
909
  - `Attestation Summary`
913
910
 
914
911
  ## Local verification
@@ -937,6 +934,7 @@ The CLI now supports a command tree, while keeping slash-command compatibility:
937
934
 
938
935
  - `sentinelayer-cli init <project-name>` runs scaffold/auth generation (legacy top-level invocation still works)
939
936
  - `sentinelayer-cli omargate deep --path <repo>` runs a local credential/policy scan and writes `.sentinelayer/reports/omargate-deep-*.md` (non-zero exit if P1 findings exist)
937
+ - Local `/omargate` is a local preflight engine; GitHub PR gate execution runs through `sentinelayer-v1-action` -> Sentinelayer API (`/api/v1/github-app/trigger` + `/api/v1/github-app/runs/{id}/status`).
940
938
  - `sentinelayer-cli audit [--agents <ids>] [--max-parallel <n>]` runs orchestrated audit agents and writes `.sentinelayer/audits/<run-id>/AUDIT_REPORT.{md,json}`
941
939
  - `sentinelayer-cli audit registry` lists built-in/customized audit-agent registry records
942
940
  - `sentinelayer-cli audit security` runs the security specialist agent and writes a dedicated `SECURITY_AGENT_REPORT.md`
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "sentinelayer-cli",
3
- "version": "0.4.5",
3
+ "version": "0.8.0",
4
4
  "description": "Scaffold Sentinelayer spec/prompt/guide artifacts with secure browser auth and token bootstrap.",
5
5
  "type": "module",
6
6
  "scripts": {
7
- "check": "node --check bin/sentinelayer-cli.js && node --check bin/create-sentinelayer.js && node --check bin/sl.js && node --check src/cli.js && node --check src/legacy-cli.js && node --check src/commands/config.js && node --check src/commands/ingest.js && node --check src/commands/spec.js && node --check src/commands/prompt.js && node --check src/commands/scan.js && node --check src/commands/guide.js && node --check src/commands/cost.js && node --check src/commands/telemetry.js && node --check src/commands/auth.js && node --check src/commands/watch.js && node --check src/commands/mcp.js && node --check src/commands/plugin.js && node --check src/commands/ai.js && node --check src/commands/review.js && node --check src/commands/chat.js && node --check src/commands/policy.js && node --check src/commands/swarm.js && node --check src/commands/daemon.js && node --check src/commands/audit.js && node --check src/config/service.js && node --check src/ingest/engine.js && node --check src/spec/generator.js && node --check src/spec/regenerate.js && node --check src/spec/templates.js && node --check src/prompt/generator.js && node --check src/scan/generator.js && node --check src/guide/generator.js && node --check src/cost/tracker.js && node --check src/cost/history.js && node --check src/cost/budget.js && node --check src/ai/client.js && node --check src/ai/aidenid.js && node --check src/ai/identity-store.js && node --check src/ai/domain-target-store.js && node --check src/ai/site-store.js && node --check src/review/local-review.js && node --check src/review/ai-review.js && node --check src/review/report.js && node --check src/review/replay.js && node --check src/audit/registry.js && node --check src/audit/orchestrator.js && node --check src/audit/package.js && node --check src/audit/replay.js && node --check src/audit/agents/security.js && node --check src/audit/agents/architecture.js && node --check src/audit/agents/testing.js && node --check src/audit/agents/performance.js && node --check src/audit/agents/compliance.js && node --check src/audit/agents/documentation.js && node --check src/swarm/registry.js && node --check src/swarm/factory.js && node --check src/swarm/runtime.js && node --check src/swarm/scenario-dsl.js && node --check src/swarm/dashboard.js && node --check src/swarm/report.js && node --check src/swarm/pentest.js && node --check src/daemon/error-worker.js && node --check src/daemon/assignment-ledger.js && node --check src/daemon/jira-lifecycle.js && node --check src/daemon/budget-governor.js && node --check src/daemon/operator-control.js && node --check src/daemon/artifact-lineage.js && node --check src/daemon/ast-parser-layer.js && node --check src/daemon/callgraph-overlay.js && node --check src/daemon/hybrid-mapper.js && node --check src/daemon/reliability-lane.js && node --check src/daemon/watchdog.js && node --check src/telemetry/ledger.js && node --check src/auth/http.js && node --check src/auth/session-store.js && node --check src/auth/service.js && node --check src/mcp/registry.js && node --check src/memory/blackboard.js && node --check src/memory/retrieval.js && node --check src/plugin/manifest.js && node --check src/policy/packs.js && node --check src/ui/markdown.js && node --check src/ui/progress.js && node --check src/agents/jules/tools/file-read.js && node --check src/agents/jules/tools/grep.js && node --check src/agents/jules/tools/glob.js && node --check src/agents/jules/tools/shell.js && node --check src/agents/jules/tools/file-edit.js && node --check src/agents/jules/tools/dispatch.js && node --check src/agents/jules/tools/index.js && node --check src/agents/jules/tools/frontend-analyze.js && node --check src/agents/jules/swarm/sub-agent.js && node --check src/agents/jules/swarm/file-scanner.js && node --check src/agents/jules/swarm/pattern-hunter.js && node --check src/agents/jules/swarm/index.js && node --check src/agents/jules/swarm/orchestrator.js && node --check src/agents/jules/config/definition.js && node --check src/agents/jules/loop.js && node --check src/agents/jules/stream.js && node --check src/agents/jules/fix-cycle.js && node --check src/agents/jules/error-intake.js && node --check src/agents/jules/tools/runtime-audit.js && node --check src/agents/jules/config/system-prompt.js && node --check src/agents/jules/tools/auth-audit.js && node --check src/auth/gate.js && node --check src/telemetry/sync.js && node --check src/telemetry/session-tracker.js && node --check src/interactive/workspace.js && node --check src/interactive/auto-ingest.js && node --check src/interactive/action-menu.js && node --check src/interactive/index.js && node --check src/daemon/ingest-refresh.js",
7
+ "check": "node --check bin/sentinelayer-cli.js && node --check bin/create-sentinelayer.js && node --check bin/sl.js && node --check src/cli.js && node --check src/legacy-cli.js && node --check src/commands/config.js && node --check src/commands/ingest.js && node --check src/commands/spec.js && node --check src/commands/prompt.js && node --check src/commands/scan.js && node --check src/commands/guide.js && node --check src/commands/cost.js && node --check src/commands/telemetry.js && node --check src/commands/auth.js && node --check src/commands/watch.js && node --check src/commands/mcp.js && node --check src/commands/plugin.js && node --check src/commands/ai.js && node --check src/commands/review.js && node --check src/commands/chat.js && node --check src/commands/policy.js && node --check src/commands/swarm.js && node --check src/commands/daemon.js && node --check src/commands/session.js && node --check src/commands/audit.js && node --check src/config/service.js && node --check src/ingest/engine.js && node --check src/spec/generator.js && node --check src/spec/regenerate.js && node --check src/spec/templates.js && node --check src/prompt/generator.js && node --check src/scan/generator.js && node --check src/guide/generator.js && node --check src/cost/tracker.js && node --check src/cost/history.js && node --check src/cost/budget.js && node --check src/ai/client.js && node --check src/ai/aidenid.js && node --check src/ai/identity-store.js && node --check src/ai/domain-target-store.js && node --check src/ai/site-store.js && node --check src/review/local-review.js && node --check src/review/ai-review.js && node --check src/review/report.js && node --check src/review/replay.js && node --check src/audit/registry.js && node --check src/audit/orchestrator.js && node --check src/audit/package.js && node --check src/audit/replay.js && node --check src/audit/agents/security.js && node --check src/audit/agents/architecture.js && node --check src/audit/agents/testing.js && node --check src/audit/agents/performance.js && node --check src/audit/agents/compliance.js && node --check src/audit/agents/documentation.js && node --check src/swarm/registry.js && node --check src/swarm/factory.js && node --check src/swarm/runtime.js && node --check src/swarm/scenario-dsl.js && node --check src/swarm/dashboard.js && node --check src/swarm/report.js && node --check src/swarm/pentest.js && node --check src/daemon/error-worker.js && node --check src/daemon/assignment-ledger.js && node --check src/daemon/jira-lifecycle.js && node --check src/daemon/budget-governor.js && node --check src/daemon/operator-control.js && node --check src/daemon/artifact-lineage.js && node --check src/daemon/ast-parser-layer.js && node --check src/daemon/callgraph-overlay.js && node --check src/daemon/hybrid-mapper.js && node --check src/daemon/scope-engine.js && node --check src/daemon/reliability-lane.js && node --check src/daemon/watchdog.js && node --check src/telemetry/ledger.js && node --check src/auth/http.js && node --check src/auth/session-store.js && node --check src/auth/service.js && node --check src/mcp/registry.js && node --check src/memory/blackboard.js && node --check src/memory/retrieval.js && node --check src/plugin/manifest.js && node --check src/policy/packs.js && node --check src/ui/markdown.js && node --check src/ui/progress.js && node --check src/ui/command-hints.js && node --check src/agents/jules/tools/file-read.js && node --check src/agents/jules/tools/grep.js && node --check src/agents/jules/tools/glob.js && node --check src/agents/jules/tools/shell.js && node --check src/agents/jules/tools/file-edit.js && node --check src/agents/jules/tools/dispatch.js && node --check src/agents/jules/tools/index.js && node --check src/agents/jules/tools/frontend-analyze.js && node --check src/agents/jules/swarm/sub-agent.js && node --check src/agents/jules/swarm/file-scanner.js && node --check src/agents/jules/swarm/pattern-hunter.js && node --check src/agents/jules/swarm/index.js && node --check src/agents/jules/swarm/orchestrator.js && node --check src/agents/jules/config/definition.js && node --check src/agents/jules/loop.js && node --check src/agents/jules/stream.js && node --check src/agents/jules/fix-cycle.js && node --check src/agents/jules/error-intake.js && node --check src/agents/jules/tools/runtime-audit.js && node --check src/agents/jules/config/system-prompt.js && node --check src/agents/jules/tools/auth-audit.js && node --check src/auth/gate.js && node --check src/telemetry/sync.js && node --check src/telemetry/session-tracker.js && node --check src/session/paths.js && node --check src/session/store.js && node --check src/session/stream.js && node --check src/session/agent-registry.js && node --check src/session/daemon.js && node --check src/session/runtime-bridge.js && node --check src/interactive/workspace.js && node --check src/interactive/auto-ingest.js && node --check src/interactive/action-menu.js && node --check src/interactive/index.js && node --check src/daemon/ingest-refresh.js",
8
8
  "test": "npm run test:unit && npm run test:e2e",
9
9
  "test:unit": "node --test tests/unit*.test.mjs",
10
10
  "test:e2e": "node --test tests/e2e.test.mjs",
@@ -15,6 +15,8 @@
15
15
  "sentinelayer-cli": "bin/sentinelayer-cli.js",
16
16
  "create-sentinelayer": "bin/create-sentinelayer.js",
17
17
  "sentinel": "bin/create-sentinelayer.js",
18
+ "sl-cli": "bin/sentinelayer-cli.js",
19
+ "slc": "bin/sentinelayer-cli.js",
18
20
  "sl": "bin/sl.js"
19
21
  },
20
22
  "files": [
@@ -23,7 +25,7 @@
23
25
  "README.md"
24
26
  ],
25
27
  "engines": {
26
- "node": ">=20.0.0"
28
+ "node": "^20.0.0 || ^22.0.0"
27
29
  },
28
30
  "keywords": [
29
31
  "sentinelayer",
@@ -53,11 +55,10 @@
53
55
  "yaml": "2.8.3",
54
56
  "zod": "4.1.12"
55
57
  },
56
- "optionalDependencies": {
57
- "keytar": "7.9.0"
58
- },
58
+ "optionalDependencies": {},
59
59
  "devDependencies": {
60
60
  "c8": "10.1.3",
61
61
  "license-checker-rseidelsohn": "4.4.2"
62
62
  }
63
63
  }
64
+
@@ -60,11 +60,13 @@ export const JULES_DEFINITION = Object.freeze({
60
60
  ],
61
61
  },
62
62
 
63
- // Evidence requirements
63
+ // Evidence requirements (aligned with output contract in system-prompt.js)
64
64
  evidenceRequirements: [
65
- "file_path_and_line",
66
- "reproduction_steps",
67
- "user_impact_statement",
65
+ "file_and_line",
66
+ "evidence",
67
+ "user_impact",
68
+ "reproduction_p0_p1",
69
+ "confidence",
68
70
  ],
69
71
  confidenceFloor: 0.75,
70
72
 
@@ -149,61 +151,10 @@ export const JULES_DEFINITION = Object.freeze({
149
151
  },
150
152
  });
151
153
 
152
- /**
153
- * All 13 SentinelLayer personas — visual identity, domain specialty, and bias.
154
- * Jules Tanaka was the first onboarded, but every persona follows the same
155
- * tool-equipped, budget-governed, isolated-context architecture.
156
- */
157
- export const PERSONA_VISUALS = Object.freeze({
158
- frontend: { color: "cyan", avatar: "\u{1F3AF}", shortName: "Jules", fullName: "Jules Tanaka", domain: "frontend_runtime", specialty: "React/Next.js/Vue production specialist — hydration safety, render cost, accessibility, bundle weight, mobile responsiveness", bias: "user-perceived performance over vanity optimization" },
159
- security: { color: "red", avatar: "\u{1F6E1}\uFE0F", shortName: "Nina", fullName: "Nina Patel", domain: "security_overlay", specialty: "AuthZ breaks, secret exposure, injection paths, policy bypass, externally reachable abuse conditions", bias: "assume hostile inputs until proven safe" },
160
- backend: { color: "blue", avatar: "\u2699\uFE0F", shortName: "Maya", fullName: "Maya Volkov", domain: "backend_runtime", specialty: "Unsafe request handling, runtime crashes, unbounded work, validation gaps, server-side trust boundary failures", bias: "every request is potentially adversarial" },
161
- testing: { color: "green", avatar: "\u{1F9EA}", shortName: "Priya", fullName: "Priya Raman", domain: "testing_correctness", specialty: "Missing regression coverage, false confidence from shallow tests, broken invariants with no executable proof", bias: "tests that pass but miss real bugs are worse than no tests" },
162
- release: { color: "yellow", avatar: "\u{1F680}", shortName: "Omar", fullName: "Omar Singh", domain: "release_engineering", specialty: "CI/CD integrity, workflow trust, artifact provenance, bypassable gates, unsafe deployment automation", bias: "every deployment is a security boundary" },
163
- "code-quality": { color: "purple", avatar: "\u{1F48E}", shortName: "Ethan", fullName: "Ethan Park", domain: "code_quality", specialty: "Complexity hotspots, unsafe shortcuts, brittle structure, maintenance risks that hide future defects", bias: "simplicity is a security feature" },
164
- infrastructure: { color: "orange", avatar: "\u{1F3D7}\uFE0F", shortName: "Kat", fullName: "Kat Hughes", domain: "infrastructure", specialty: "IAM blast radius, public exposure, network posture, secrets placement, infrastructure policy drift", bias: "least privilege by default, explicit escalation required" },
165
- data: { color: "pink", avatar: "\u{1F5C4}\uFE0F", shortName: "Linh", fullName: "Linh Tran", domain: "data_layer", specialty: "Query safety, migration drift, integrity failures, tenancy leaks, schema/application mismatches", bias: "data integrity is non-negotiable" },
166
- observability: { color: "magenta", avatar: "\u{1F4CA}", shortName: "Sofia", fullName: "Sofia Alvarez", domain: "observability", specialty: "Missing telemetry, broken alerting, weak auditability, blind spots that hide failures or attacks", bias: "if you can't observe it, you can't secure it" },
167
- reliability: { color: "white", avatar: "\u{1F504}", shortName: "Noah", fullName: "Noah Ben-David", domain: "reliability_sre", specialty: "Timeout safety, retry storms, backlog growth, partial failure handling, operational blast radius", bias: "graceful degradation over silent failure" },
168
- documentation: { color: "gray", avatar: "\u{1F4DD}", shortName: "Samir", fullName: "Samir Okafor", domain: "docs_knowledge", specialty: "Operational drift between docs and code, missing runbook steps, misleading instructions that break operators", bias: "documentation is a contract, not decoration" },
169
- "supply-chain": { color: "brown", avatar: "\u{1F4E6}", shortName: "Nora", fullName: "Nora Kline", domain: "supply_chain", specialty: "Dependency risk, provenance gaps, pinning drift, artifact trust, compromised build inputs", bias: "every dependency is a trust decision" },
170
- "ai-governance": { color: "violet", avatar: "\u{1F916}", shortName: "Amina", fullName: "Amina Chen", domain: "ai_pipeline", specialty: "Prompt injection, tool abuse, eval regressions, unsafe model routing, guardrail bypass, policy drift in agentic flows", bias: "AI autonomy requires proportional governance" },
171
- });
172
-
173
- /**
174
- * Resolve persona visual identity by agent ID or persona name.
175
- */
176
- export function resolvePersonaVisual(idOrName) {
177
- if (!idOrName) return null;
178
- const lower = String(idOrName).toLowerCase();
179
-
180
- // Direct ID match
181
- if (PERSONA_VISUALS[lower]) return { id: lower, ...PERSONA_VISUALS[lower] };
182
-
183
- // Name match (first name or full name)
184
- for (const [id, visual] of Object.entries(PERSONA_VISUALS)) {
185
- if (visual.shortName.toLowerCase() === lower || visual.fullName.toLowerCase() === lower) {
186
- return { id, ...visual };
187
- }
188
- }
189
-
190
- return null;
191
- }
192
-
193
- /**
194
- * List all persona IDs for autocomplete.
195
- */
196
- export function listPersonaIds() {
197
- return Object.keys(PERSONA_VISUALS);
198
- }
199
-
200
- /**
201
- * List all persona names (short + full) for autocomplete.
202
- */
203
- export function listPersonaNames() {
204
- const names = [];
205
- for (const [id, visual] of Object.entries(PERSONA_VISUALS)) {
206
- names.push(id, visual.shortName.toLowerCase(), visual.fullName.toLowerCase());
207
- }
208
- return names;
209
- }
154
+ // Re-export from shared persona-visuals. These cover all 13 personas — not Jules-specific.
155
+ export {
156
+ PERSONA_VISUALS,
157
+ resolvePersonaVisual,
158
+ listPersonaIds,
159
+ listPersonaNames,
160
+ } from "../../persona-visuals.js";
@@ -164,9 +164,16 @@ Return findings as a JSON array in a \`\`\`json code block:
164
164
  "evidence": "dangerouslySetInnerHTML with user-controlled prop at line 42",
165
165
  "rootCause": "No DOMPurify sanitization before render",
166
166
  "recommendedFix": "Wrap input with DOMPurify.sanitize() before passing to dangerouslySetInnerHTML",
167
- "trafficLight": "red"
167
+ "trafficLight": "red",
168
+ "reproduction": { "type": "manual_step", "steps": ["Open RichText component with untrusted HTML input", "Observe raw HTML rendered without sanitization"] },
169
+ "user_impact": "Attacker-controlled HTML renders in the user's browser, enabling XSS",
170
+ "confidence": 0.92
168
171
  }]
169
172
 
173
+ reproduction: required for P0/P1, optional for P2+. Object with "type" (manual_step | shell | runtime_probe) and "steps" array.
174
+ user_impact: required. One sentence: what the user or system experiences if this is exploited or triggered.
175
+ confidence: required. Number 0.0-1.0. Your confidence this is a real issue with sufficient evidence. Below ${def.confidenceFloor} = flag as evidence_gap instead of confirmed.
176
+
170
177
  VOICE
171
178
  Sharp, skeptical, concrete, user-centric.
172
179
  Like someone who has debugged hydration crashes at 2 a.m. and knows "technically correct" UI can still feel broken.
@@ -1,377 +1,17 @@
1
- import { execFileSync } from "node:child_process";
2
- import path from "node:path";
3
- import fsp from "node:fs/promises";
1
+ // Re-export from platform daemon. Fix-cycle is not Jules-specific.
2
+ // Jules passes its own identity; any persona can use the same lifecycle.
3
+ import { runFixCycle as _runFixCycle } from "../../daemon/fix-cycle.js";
4
4
  import { JULES_DEFINITION } from "./config/definition.js";
5
- import { startJiraLifecycle, commentJiraIssue, transitionJiraIssue } from "../../daemon/jira-lifecycle.js";
6
- import { claimAssignment, heartbeatAssignment, releaseAssignment } from "../../daemon/assignment-ledger.js";
7
5
 
8
- /**
9
- * Jules Tanaka — Autonomous Fix Cycle
10
- *
11
- * Complete lifecycle:
12
- * claim → Jira open → worktree create → agentic fix → test →
13
- * Jira comment findings → PR create → Omar Gate watch →
14
- * fix P0-P2 from comments → merge → Jira close → artifact → release
15
- *
16
- * Failure path: BLOCKED status + Jira comment + release assignment
17
- * Worktree cleanup: always in finally block
18
- */
19
-
20
- const LEASE_TTL_SECONDS = 1800;
21
- const HEARTBEAT_INTERVAL_MS = 300000;
22
- // MAX_FIX_ATTEMPTS reserved for future agentic retry loop
23
- const OMAR_POLL_INTERVAL_MS = 15000;
24
- const OMAR_POLL_MAX_ATTEMPTS = 40; // 10 minutes max wait
25
-
26
- export async function runFixCycle({ workItemId, workItem, rootPath, scopeMap, findings, onEvent }) {
27
- const emit = (ev, pl) => {
28
- if (onEvent) onEvent({
29
- stream: "sl_event", event: ev,
30
- agent: { id: JULES_DEFINITION.id, persona: JULES_DEFINITION.persona, color: JULES_DEFINITION.color, avatar: JULES_DEFINITION.avatar },
31
- payload: { workItemId, ...pl },
32
- });
33
- };
34
-
35
- const artDir = path.join(rootPath, ".sentinelayer", "observability", "fixes", workItemId);
36
- await fsp.mkdir(artDir, { recursive: true });
37
-
38
- let jiraKey = null;
39
- let prNumber = null;
40
- let worktreePath = null;
41
- let branchName = null;
42
- let hbTimer = null;
43
-
44
- try {
45
- // ── [1] CLAIM ─────────────────────────────────────────────────
46
- emit("fix_claim", { status: "claiming" });
47
- await claimAssignment({
48
- targetPath: rootPath, workItemId,
49
- agentIdentity: "jules-tanaka@frontend",
50
- leaseTtlSeconds: LEASE_TTL_SECONDS, stage: "fix",
51
- });
52
-
53
- hbTimer = setInterval(async () => {
54
- try {
55
- await heartbeatAssignment({
56
- targetPath: rootPath, workItemId,
57
- agentIdentity: "jules-tanaka@frontend",
58
- leaseTtlSeconds: LEASE_TTL_SECONDS, stage: "fix",
59
- });
60
- } catch { /* heartbeat failure is non-blocking */ }
61
- }, HEARTBEAT_INTERVAL_MS);
62
-
63
- // ── [2] JIRA OPEN ─────────────────────────────────────────────
64
- emit("fix_jira", { status: "opening" });
65
- const sev = workItem?.severity || "P2";
66
- const endpoint = workItem?.endpoint || "unknown";
67
- const errorCode = workItem?.errorCode || "UNKNOWN";
68
-
69
- const jr = await startJiraLifecycle({
70
- targetPath: rootPath, workItemId, actor: JULES_DEFINITION.persona,
71
- summary: "[" + sev + "] Frontend: " + errorCode + " at " + endpoint,
72
- description: buildDescription(workItem, findings),
73
- labels: ["sentinelayer", "jules-tanaka", "frontend", "severity-" + sev.toLowerCase()],
74
- planMessage: buildPlan(workItem, scopeMap, findings),
75
- issueKeyPrefix: "SLD",
76
- });
77
- jiraKey = jr.issue?.issueKey;
78
- emit("fix_jira", { status: "opened", issueKey: jiraKey });
79
-
80
- // ── [3] WORKTREE CREATE ───────────────────────────────────────
81
- branchName = "fix/jules-" + workItemId.replace(/[^a-zA-Z0-9-]/g, "-");
82
- worktreePath = path.join(rootPath, ".jules-worktree-" + workItemId);
83
- emit("fix_worktree", { status: "creating", branch: branchName });
84
-
85
- safeExecFile("git", ["fetch", "origin"], rootPath);
86
- safeExecFile("git", ["worktree", "add", "-b", branchName, worktreePath, "origin/main"], rootPath);
87
- emit("fix_worktree", { status: "created", path: worktreePath });
88
-
89
- // ── [4] INVESTIGATE + FIX ─────────────────────────────────────
90
- emit("fix_investigate", { status: "analyzing" });
91
-
92
- // Comment Jira with findings before fix attempt
93
- if (jiraKey && findings && findings.length > 0) {
94
- await commentJiraIssue({
95
- targetPath: rootPath, workItemId, issueKey: jiraKey,
96
- actor: JULES_DEFINITION.persona, type: "finding",
97
- message: buildFindingsComment(findings),
98
- });
99
- }
100
-
101
- // Fix generation: the caller is responsible for writing changes to the
102
- // worktree before invoking runFixCycle, or for wiring julesAuditLoop
103
- // in fix mode with FileEdit tool access. runFixCycle handles the full
104
- // PR/Omar/merge/Jira lifecycle for whatever changes exist in the worktree.
105
-
106
- // ── [5] PUSH + PR ─────────────────────────────────────────────
107
- emit("fix_pr", { status: "pushing" });
108
-
109
- // Check if there are changes to commit in the worktree
110
- const diffOutput = safeExecFile("git", ["diff", "--stat"], worktreePath);
111
- const untrackedOutput = safeExecFile("git", ["ls-files", "--others", "--exclude-standard"], worktreePath);
112
- const hasChanges = diffOutput.trim().length > 0 || untrackedOutput.trim().length > 0;
113
-
114
- if (hasChanges) {
115
- safeExecFile("git", ["add", "-A"], worktreePath);
116
- safeExecFile("git", ["commit", "-m", "[Jules] Fix " + errorCode + " at " + endpoint], worktreePath);
117
- }
118
-
119
- safeExecFile("git", ["push", "-u", "origin", branchName], worktreePath);
120
-
121
- const prBody = buildPrBody(workItem, findings, jiraKey);
122
- const prUrl = safeExecFile("gh", [
123
- "pr", "create",
124
- "--title", "[Jules] Fix " + errorCode,
125
- "--body", prBody,
126
- "--head", branchName,
127
- ], worktreePath).trim();
128
-
129
- const prMatch = prUrl.match(/\/pull\/(\d+)/);
130
- prNumber = prMatch ? parseInt(prMatch[1]) : null;
131
- emit("fix_pr", { status: "created", prNumber, url: prUrl });
132
-
133
- // ── [6] OMAR GATE WATCH ───────────────────────────────────────
134
- if (prNumber) {
135
- emit("fix_omar", { status: "watching", prNumber });
136
- const omarPassed = await watchOmarGate(rootPath, branchName, emit);
137
-
138
- if (!omarPassed) {
139
- emit("fix_omar", { status: "failed" });
140
- // Comment Jira about Omar failure
141
- if (jiraKey) {
142
- await commentJiraIssue({
143
- targetPath: rootPath, workItemId, issueKey: jiraKey,
144
- actor: JULES_DEFINITION.persona, type: "operator_stop",
145
- message: "## Omar Gate Failed\nPR #" + prNumber + " did not pass Omar Gate.\nEscalating to human review.\n\n" + JULES_DEFINITION.signature,
146
- });
147
- await transitionJiraIssue({
148
- targetPath: rootPath, workItemId, issueKey: jiraKey,
149
- toStatus: "BLOCKED", actor: JULES_DEFINITION.persona,
150
- reason: "Omar Gate failed on PR #" + prNumber,
151
- });
152
- }
153
- await releaseAssignment({
154
- targetPath: rootPath, workItemId,
155
- agentIdentity: "jules-tanaka@frontend",
156
- status: "BLOCKED", reason: "Omar Gate failed on PR #" + prNumber,
157
- });
158
- return {
159
- workItemId, jiraIssueKey: jiraKey, prNumber,
160
- status: "blocked_omar", signature: JULES_DEFINITION.signature,
161
- };
162
- }
163
-
164
- emit("fix_omar", { status: "passed", prNumber });
165
-
166
- // ── [7] MERGE ───────────────────────────────────────────────
167
- emit("fix_merge", { status: "merging", prNumber });
168
- try {
169
- safeExecFile("gh", ["pr", "merge", String(prNumber), "--squash", "--delete-branch"], rootPath);
170
- emit("fix_merge", { status: "merged", prNumber });
171
- } catch (mergeErr) {
172
- emit("fix_merge", { status: "failed", error: mergeErr.message });
173
- // PR created but merge failed — still better than nothing
174
- }
175
- }
176
-
177
- // ── [8] JIRA CLOSE ────────────────────────────────────────────
178
- if (jiraKey) {
179
- await commentJiraIssue({
180
- targetPath: rootPath, workItemId, issueKey: jiraKey,
181
- actor: JULES_DEFINITION.persona, type: "fix",
182
- message: "## Resolution\nPR #" + (prNumber || "pending") + " merged.\nOmar Gate: passed.\nFindings addressed: " + (findings?.length || 0) + "\n\n" + JULES_DEFINITION.signature,
183
- });
184
- await transitionJiraIssue({
185
- targetPath: rootPath, workItemId, issueKey: jiraKey,
186
- toStatus: "DONE", actor: JULES_DEFINITION.persona,
187
- reason: "Fixed in PR #" + (prNumber || "pending"),
188
- });
189
- }
190
-
191
- // ── [9] ARTIFACT + S3 UPLOAD ────────────────────────────────────
192
- const result = {
193
- workItemId, jiraIssueKey: jiraKey, prNumber,
194
- status: "completed",
195
- findingsAddressed: findings?.length || 0,
6
+ export function runFixCycle(opts) {
7
+ return _runFixCycle({
8
+ ...opts,
9
+ agentIdentity: {
10
+ id: JULES_DEFINITION.id,
11
+ persona: JULES_DEFINITION.persona,
12
+ color: JULES_DEFINITION.color,
13
+ avatar: JULES_DEFINITION.avatar,
196
14
  signature: JULES_DEFINITION.signature,
197
- };
198
- await fsp.writeFile(
199
- path.join(artDir, "fix-result.json"),
200
- JSON.stringify(result, null, 2),
201
- );
202
-
203
- // Upload to S3 for compliance archive + agent training data
204
- emit("fix_s3", { status: "uploading" });
205
- const s3Result = await uploadFixArtifactsToS3(artDir, workItemId, rootPath);
206
- emit("fix_s3", { status: s3Result.uploaded ? "uploaded" : "skipped", reason: s3Result.reason });
207
-
208
- // ── [10] RELEASE ──────────────────────────────────────────────
209
- await releaseAssignment({
210
- targetPath: rootPath, workItemId,
211
- agentIdentity: "jules-tanaka@frontend",
212
- status: "DONE",
213
- reason: "PR #" + (prNumber || "pending") + " merged. " + JULES_DEFINITION.signature,
214
- });
215
-
216
- emit("fix_complete", { prNumber, jiraIssueKey: jiraKey, status: "completed" });
217
- return result;
218
-
219
- } catch (err) {
220
- emit("fix_error", { error: err.message });
221
- try {
222
- await releaseAssignment({
223
- targetPath: rootPath, workItemId,
224
- agentIdentity: "jules-tanaka@frontend",
225
- status: "BLOCKED", reason: "Fix cycle failed: " + err.message,
226
- });
227
- } catch { /* release failure non-blocking */ }
228
- if (jiraKey) {
229
- try {
230
- await commentJiraIssue({
231
- targetPath: rootPath, workItemId, issueKey: jiraKey,
232
- actor: JULES_DEFINITION.persona, type: "operator_stop",
233
- message: "## Fix Failed\n" + err.message + "\nEscalating to human.\n\n" + JULES_DEFINITION.signature,
234
- });
235
- await transitionJiraIssue({
236
- targetPath: rootPath, workItemId, issueKey: jiraKey,
237
- toStatus: "BLOCKED", actor: JULES_DEFINITION.persona,
238
- reason: "Fix cycle failed: " + err.message,
239
- });
240
- } catch { /* Jira failure non-blocking */ }
241
- }
242
- return { workItemId, jiraIssueKey: jiraKey, prNumber, status: "failed", error: err.message, signature: JULES_DEFINITION.signature };
243
- } finally {
244
- if (hbTimer) clearInterval(hbTimer);
245
- if (worktreePath) {
246
- try { safeExecFile("git", ["worktree", "remove", worktreePath, "--force"], rootPath); } catch { /* best effort */ }
247
- }
248
- }
249
- }
250
-
251
- // ── Omar Gate Watch ──────────────────────────────────────────────────
252
-
253
- async function watchOmarGate(rootPath, branchName, emit) {
254
- for (let attempt = 0; attempt < OMAR_POLL_MAX_ATTEMPTS; attempt++) {
255
- await sleep(OMAR_POLL_INTERVAL_MS);
256
- try {
257
- const runJson = safeExecFile("gh", [
258
- "run", "list", "--workflow", "Omar Gate", "--branch", branchName,
259
- "--limit", "1", "--json", "databaseId,status,conclusion",
260
- ], rootPath);
261
- const runs = JSON.parse(runJson || "[]");
262
- if (runs.length === 0) continue;
263
-
264
- const run = runs[0];
265
- if (run.status === "completed") {
266
- emit("fix_omar", { status: "completed", conclusion: run.conclusion, runId: run.databaseId });
267
- return run.conclusion === "success";
268
- }
269
- if (attempt % 4 === 0) {
270
- emit("fix_omar", { status: "waiting", attempt, runId: run.databaseId });
271
- }
272
- } catch { /* polling failure non-blocking, will retry */ }
273
- }
274
- // Timed out waiting for Omar
275
- emit("fix_omar", { status: "timeout" });
276
- return false;
277
- }
278
-
279
- // ── Helpers ──────────────────────────────────────────────────────────
280
-
281
- function safeExecFile(bin, args, cwd) {
282
- return execFileSync(bin, args, {
283
- cwd, encoding: "utf-8", timeout: 60000,
284
- stdio: ["pipe", "pipe", "pipe"],
15
+ },
285
16
  });
286
17
  }
287
-
288
- function sleep(ms) {
289
- return new Promise(resolve => setTimeout(resolve, ms));
290
- }
291
-
292
- function buildDescription(w, f) {
293
- const parts = [];
294
- parts.push("**Service:** " + (w?.service || "unknown"));
295
- parts.push("**Endpoint:** " + (w?.endpoint || "unknown"));
296
- parts.push("**Error:** " + (w?.errorCode || "UNKNOWN"));
297
- parts.push("**Severity:** " + (w?.severity || "P2"));
298
- if (w?.message) parts.push("**Message:** " + w.message.slice(0, 500));
299
- if (w?.stackFingerprint) parts.push("**Stack fingerprint:** " + w.stackFingerprint);
300
- if (f?.length) parts.push("\n**Related findings:** " + f.length);
301
- parts.push("\n" + JULES_DEFINITION.signature);
302
- return parts.join("\n");
303
- }
304
-
305
- function buildPlan(w, s, f) {
306
- const parts = [];
307
- parts.push("## Investigation Plan");
308
- parts.push("1. Scope reconstruction from error at " + (w?.endpoint || "unknown"));
309
- parts.push("2. Read " + ((s?.primary || []).length) + " primary scope files");
310
- parts.push("3. Identify root cause from stack trace + code analysis");
311
- parts.push("4. Apply fix in isolated worktree");
312
- parts.push("5. Run tests to verify fix");
313
- parts.push("6. Open PR and watch Omar Gate");
314
- if (f?.length) parts.push("\n**Pre-existing findings:** " + f.length);
315
- parts.push("\n" + JULES_DEFINITION.signature);
316
- return parts.join("\n");
317
- }
318
-
319
- function buildFindingsComment(f) {
320
- const parts = ["## Findings"];
321
- const items = f || [];
322
- for (const finding of items.slice(0, 10)) {
323
- parts.push("- **[" + (finding.severity || "P3") + "]** " + (finding.file || "") + ":" + (finding.line || "") + " " + (finding.title || finding.type || ""));
324
- if (finding.evidence) parts.push(" Evidence: " + String(finding.evidence).slice(0, 200));
325
- }
326
- if (items.length > 10) parts.push("... and " + (items.length - 10) + " more");
327
- parts.push("\n" + JULES_DEFINITION.signature);
328
- return parts.join("\n");
329
- }
330
-
331
- function buildPrBody(w, f, jiraKey) {
332
- const parts = [];
333
- if (jiraKey) parts.push("Fixes " + jiraKey);
334
- parts.push("Error: " + (w?.errorCode || "UNKNOWN") + " at " + (w?.endpoint || "unknown"));
335
- parts.push("Severity: " + (w?.severity || "P2"));
336
- if (f?.length) parts.push("Findings addressed: " + f.length);
337
- parts.push("");
338
- parts.push(JULES_DEFINITION.signature);
339
- return parts.join("\n");
340
- }
341
-
342
- // ── S3 Upload ────────────────────────────────────────────────────────
343
-
344
- /**
345
- * Upload fix artifacts to S3 for compliance archive and agent training.
346
- * Uses AWS CLI (must be configured in environment).
347
- * Fails silently — S3 upload must never block the fix cycle.
348
- *
349
- * Bucket: SENTINELAYER_AUDIT_S3_BUCKET env var (default: sentinelayer-audit-artifacts)
350
- * Key pattern: {repo}/{date}/jules-tanaka/{workItemId}/
351
- */
352
- async function uploadFixArtifactsToS3(artifactDir, workItemId, rootPath) {
353
- const bucket = process.env.SENTINELAYER_AUDIT_S3_BUCKET;
354
- if (!bucket) {
355
- return { uploaded: false, reason: "SENTINELAYER_AUDIT_S3_BUCKET not set" };
356
- }
357
-
358
- try {
359
- // Derive repo name from git remote or directory name
360
- let repoName = "unknown-repo";
361
- try {
362
- const remote = safeExecFile("git", ["remote", "get-url", "origin"], rootPath).trim();
363
- const match = remote.match(/\/([^/]+?)(?:\.git)?$/);
364
- if (match) repoName = match[1];
365
- } catch { /* use default */ }
366
-
367
- const date = new Date().toISOString().split("T")[0];
368
- const s3Key = repoName + "/" + date + "/jules-tanaka/" + workItemId + "/";
369
- const s3Url = "s3://" + bucket + "/" + s3Key;
370
-
371
- safeExecFile("aws", ["s3", "sync", artifactDir, s3Url, "--quiet", "--sse", "AES256"], rootPath);
372
-
373
- return { uploaded: true, bucket, key: s3Key };
374
- } catch (err) {
375
- return { uploaded: false, reason: "S3 upload failed: " + err.message };
376
- }
377
- }