@khoavu882/doflow 2.0.0-beta.4 → 2.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/README.md +12 -11
- package/bin/doflow.js +21 -11
- package/core/.antigravity-plugin/plugin.json +1 -3
- package/core/.claude-plugin/plugin.json +1 -1
- package/core/.codex-plugin/plugin.json +1 -1
- package/core/.plugin/plugin.json +1 -1
- package/core/harnesses/claude/hooks/lib.sh +43 -24
- package/core/harnesses/claude/hooks/mcp-tool-guard.sh +7 -17
- package/core/harnesses/claude/hooks/permission-audit.sh +3 -0
- package/core/harnesses/claude/hooks/post-compact.sh +35 -32
- package/core/harnesses/claude/hooks/post-edit-lint.sh +2 -0
- package/core/harnesses/claude/hooks/post-shell-observe.sh +48 -0
- package/core/harnesses/claude/hooks/post-tool-failure.sh +3 -0
- package/core/harnesses/claude/hooks/pre-bash-guard.sh +7 -17
- package/core/harnesses/claude/hooks/pre-compact.sh +23 -27
- package/core/harnesses/claude/hooks/pre-implement-gate.sh +7 -18
- package/core/harnesses/claude/hooks/session-end.sh +23 -10
- package/core/harnesses/claude/hooks/session-start.sh +5 -3
- package/core/harnesses/claude/hooks/skill-config-audit.sh +3 -0
- package/core/harnesses/claude/hooks/stop-check.sh +5 -3
- package/core/harnesses/claude/hooks/subagent-audit.sh +5 -5
- package/core/harnesses/claude/hooks/user-prompt-submit.sh +5 -3
- package/core/harnesses/claude/settings/settings.json +18 -0
- package/core/harnesses/claude/statusline/doflow-statusline.sh +1 -0
- package/core/harnesses/codex/agents/core-implementer.toml +1 -0
- package/core/harnesses/codex/agents/delivery-lead.toml +10 -0
- package/core/harnesses/codex/agents/quality-guardian.toml +1 -1
- package/core/harnesses/codex/agents/research-writer.toml +1 -1
- package/core/harnesses/codex/agents/reviewer.toml +10 -0
- package/core/harnesses/codex/agents/spec-analyst.toml +1 -1
- package/core/harnesses/codex/agents/system-architect.toml +1 -1
- package/core/harnesses/codex/hooks/lib.sh +44 -25
- package/core/harnesses/codex/hooks/mcp-tool-guard.sh +7 -15
- package/core/harnesses/codex/hooks/post-edit-lint.impl.sh +3 -1
- package/core/harnesses/codex/hooks/pre-bash-guard.sh +7 -15
- package/core/harnesses/codex/hooks/pre-compact.impl.sh +29 -26
- package/core/harnesses/codex/hooks/pre-implement-gate.sh +7 -16
- package/core/harnesses/codex/hooks/session-end.impl.sh +23 -10
- package/core/harnesses/codex/hooks/session-start.sh +5 -3
- package/core/harnesses/codex/hooks/stop-check.sh +6 -5
- package/core/harnesses/codex/hooks/subagent-audit.sh +18 -6
- package/core/harnesses/codex/hooks/user-prompt-submit.sh +5 -4
- package/core/harnesses/copilot/hooks/doflow-lib.sh +93 -0
- package/core/harnesses/copilot/hooks/doflow-mcp-tool-guard.sh +9 -0
- package/core/harnesses/copilot/hooks/doflow-pre-bash-guard.sh +9 -0
- package/core/harnesses/copilot/hooks/doflow-pre-implement-gate.sh +9 -0
- package/core/harnesses/copilot/hooks/doflow-session-start.sh +9 -0
- package/core/harnesses/copilot/hooks/doflow-stop-check.sh +9 -0
- package/core/harnesses/copilot/hooks/doflow-subagent-start.sh +9 -0
- package/core/harnesses/copilot/hooks/doflow-subagent-stop.sh +9 -0
- package/core/harnesses/copilot/hooks/doflow.json +57 -0
- package/core/harnesses/kiro/agents/doflow.json +1 -1
- package/core/harnesses/kiro/hooks/lib.sh +26 -6
- package/core/harnesses/kiro/hooks/mcp-tool-guard.sh +21 -5
- package/core/harnesses/kiro/hooks/pre-bash-guard.sh +21 -5
- package/core/harnesses/kiro/hooks/pre-implement-gate.sh +21 -5
- package/core/harnesses/kiro/hooks/session-start.sh +12 -5
- package/core/harnesses/kiro/hooks/stop-check.sh +22 -30
- package/core/harnesses/pi/extensions/doflow-guard.js +167 -0
- package/core/harnesses/shared/hooks/ENVELOPE_MIGRATION.md +27 -12
- package/core/harnesses/shared/hooks/adapters/antigravity.js +14 -57
- package/core/harnesses/shared/hooks/bridge/bridge.sh +277 -0
- package/core/harnesses/shared/hooks/bridge/envelope.jq +129 -0
- package/core/harnesses/shared/hooks/bridge/observe-model.sh +75 -0
- package/core/harnesses/shared/hooks/bridge/respond.sh +70 -0
- package/core/harnesses/shared/hooks/policies/blocked-patterns.conf +28 -14
- package/core/harnesses/shared/hooks/policies/capture-failure.sh +51 -16
- package/core/harnesses/shared/hooks/policies/compact-text.sh +46 -0
- package/core/harnesses/shared/hooks/policies/contract.sh +78 -0
- package/core/harnesses/shared/hooks/policies/deny-json.sh +35 -9
- package/core/harnesses/shared/hooks/policies/emission-rules.sh +37 -0
- package/core/harnesses/shared/hooks/policies/emission.jq +209 -0
- package/core/harnesses/shared/hooks/policies/emission.sh +383 -0
- package/core/harnesses/shared/hooks/policies/identity.sh +177 -0
- package/core/harnesses/shared/hooks/policies/lib.sh +65 -40
- package/core/harnesses/shared/hooks/policies/mcp-tool-guard.sh +48 -35
- package/core/harnesses/shared/hooks/policies/pre-bash-guard.sh +284 -33
- package/core/harnesses/shared/hooks/policies/pre-implementation-gate.sh +180 -110
- package/core/harnesses/shared/hooks/policies/session-context.sh +66 -7
- package/core/harnesses/shared/hooks/policies/stop-check.sh +61 -23
- package/core/harnesses/shared/hooks/policies/subagent-audit.sh +39 -6
- package/core/harnesses/shared/hooks/policies/summary-store.sh +347 -0
- package/core/harnesses/shared/hooks/policies/user-prompt-submit.sh +97 -159
- package/core/harnesses/shared/hooks/stream-hook-runner.js +114 -187
- package/core/harnesses/shared/locator/doflow-run +2 -3
- package/core/registry/advice.json +3 -3
- package/core/registry/assets.json +72 -80
- package/core/registry/capabilities.json +12 -0
- package/core/registry/contracts.json +60 -33
- package/core/registry/contribution-points.json +32 -0
- package/core/registry/gates.json +32 -0
- package/core/registry/guidance-caps.json +40 -0
- package/core/registry/harnesses.json +1542 -277
- package/core/registry/lifecycle.json +2837 -37
- package/core/registry/mcp.json +5 -1
- package/core/registry/models.json +7 -1
- package/core/registry/package-templates/README.md +19 -0
- package/core/registry/package-templates/agent/files/agent.md +9 -0
- package/core/registry/package-templates/agent/template.json +4 -0
- package/core/registry/package-templates/capability-provider/files/provider.json +9 -0
- package/core/registry/package-templates/capability-provider/template.json +11 -0
- package/core/registry/package-templates/debate-preset/files/preset.json +26 -0
- package/core/registry/package-templates/debate-preset/template.json +4 -0
- package/core/registry/package-templates/review-preset/files/preset.json +30 -0
- package/core/registry/package-templates/review-preset/template.json +4 -0
- package/core/registry/package-templates/skill/files/SKILL.md +8 -0
- package/core/registry/package-templates/skill/template.json +4 -0
- package/core/registry/package-templates/worker/files/worker.json +92 -0
- package/core/registry/package-templates/worker/template.json +11 -0
- package/core/registry/packages/doflow/doflow-package.json +15 -0
- package/core/registry/packages/doflow/presets/debate-3.json +26 -0
- package/core/registry/protocols.json +61 -0
- package/core/registry/routes.json +17 -0
- package/core/registry/rules.json +431 -0
- package/core/registry/settings.json +276 -0
- package/core/registry/storage.json +701 -30
- package/core/registry/telemetry.json +236 -0
- package/core/registry/transcripts.json +142 -0
- package/core/registry/verification.json +76 -1
- package/core/registry/workflows.json +55 -0
- package/core/shared/agent-specs/core-implementer.md +3 -0
- package/core/shared/agent-specs/delivery-lead.md +68 -0
- package/core/shared/agent-specs/quality-guardian.md +5 -1
- package/core/shared/agent-specs/research-writer.md +10 -3
- package/core/shared/agent-specs/reviewer.md +53 -0
- package/core/shared/agent-specs/spec-analyst.md +5 -6
- package/core/shared/agent-specs/system-architect.md +5 -1
- package/core/shared/guidance/DOFLOW_CORE.md +1 -5
- package/core/shared/guidance/modes/MODE_DeepResearch.md +1 -1
- package/core/shared/guidance/modes/MODE_Orchestration.md +4 -3
- package/core/shared/guidance/modes/MODE_Task_Management.md +14 -14
- package/core/shared/guidance/pointers/codex.md +1 -4
- package/core/shared/guidance/references/ARTIFACT_FORMAT.md +30 -16
- package/core/shared/guidance/references/ARTIFACT_VOICE.md +3 -2
- package/core/shared/guidance/references/CONSTITUTION_BASE.md +17 -15
- package/core/shared/guidance/references/DIAGRAM_GUIDE.md +1 -1
- package/core/shared/guidance/references/DOFLOW_CHAIN.md +17 -19
- package/core/shared/guidance/references/EVIDENCE_LEDGER.md +7 -8
- package/core/shared/guidance/references/MODEL_SELECTION.md +5 -3
- package/core/shared/guidance/references/ORCHESTRATION.md +1 -2
- package/core/shared/guidance/rules/RULES.md +45 -0
- package/core/shared/scripts/doflow/bash/do-args.sh +37 -0
- package/core/shared/scripts/doflow/bash/do-exec-paths.sh +4 -0
- package/core/shared/scripts/doflow/bash/do-git-state.sh +15 -4
- package/core/shared/scripts/doflow/bash/do-parallel-check.sh +4 -0
- package/core/shared/scripts/doflow/bash/do-paths.sh +40 -2
- package/core/shared/scripts/doflow/bash/do-prereqs.sh +2 -1
- package/core/shared/scripts/doflow/bash/do-review-package.sh +4 -0
- package/core/shared/scripts/doflow/bash/do-task-brief.sh +58 -16
- package/core/shared/scripts/doflow/bash/render-audit.sh +26 -2
- package/core/shared/scripts/doflow/bash/render-diagrams.sh +1 -0
- package/core/shared/scripts/doflow/bash/render-puml.sh +2 -1
- package/core/shared/scripts/doflow/bash/validate-artifacts.sh +48 -4
- package/core/shared/scripts/doflow/bin/doflow-run +154 -35
- package/core/shared/skills/do/SKILL.md +12 -10
- package/core/shared/skills/do/references/advice_calls.md +26 -0
- package/core/shared/skills/do/references/pm_routing.md +1 -2
- package/core/shared/skills/do/references/program_mode.md +31 -0
- package/core/shared/skills/do-brainstorm/SKILL.md +20 -74
- package/core/shared/skills/do-brainstorm/references/handoff_branches.md +35 -0
- package/core/shared/skills/do-brainstorm/references/intent_seed.md +21 -0
- package/core/shared/skills/do-brainstorm/references/round_log.md +17 -0
- package/core/shared/skills/do-code-review/SKILL.md +41 -144
- package/core/shared/skills/do-code-review/content-types/markdown.md +24 -2
- package/core/shared/skills/do-code-review/references/tools.md +90 -0
- package/core/shared/skills/do-code-review/scripts/doc_quality_checker.py +549 -7
- package/core/shared/skills/do-design/SKILL.md +24 -23
- package/core/shared/skills/do-diagnose/SKILL.md +14 -4
- package/core/shared/skills/do-document/SKILL.md +11 -1
- package/core/shared/skills/do-document/references/deep_research.md +1 -2
- package/core/shared/skills/do-document/references/embedded-research.md +18 -6
- package/core/shared/skills/do-document/references/implementation-flow.md +5 -6
- package/core/shared/skills/do-execute-plan/SKILL.md +17 -59
- package/core/shared/skills/do-execute-plan/references/handoff_record.md +7 -2
- package/core/shared/skills/do-execute-plan/references/parallel_dispatch.md +13 -0
- package/core/shared/skills/do-execute-plan/references/readiness_gate.md +28 -1
- package/core/shared/skills/do-execute-plan/references/run_position.md +13 -1
- package/core/shared/skills/do-execute-plan/references/scaffold.md +17 -9
- package/core/shared/skills/do-execute-plan/references/state_checkpoint.md +11 -0
- package/core/shared/skills/do-execute-plan/references/task_attempts.md +78 -24
- package/core/shared/skills/do-flow/SKILL.md +8 -9
- package/core/shared/skills/do-flow/references/task_classes.md +2 -2
- package/core/shared/skills/do-git/SKILL.md +4 -0
- package/core/shared/skills/do-implement/SKILL.md +7 -9
- package/core/shared/skills/do-plan/SKILL.md +29 -19
- package/core/shared/skills/do-test/SKILL.md +7 -4
- package/core/shared/templates/doflow/constitution-template.md +9 -3
- package/core/shared/templates/doflow/data-model-template.md +1 -1
- package/core/shared/templates/doflow/design-template.md +113 -16
- package/core/shared/templates/doflow/plan-template.md +11 -10
- package/core/shared/templates/doflow/question-log-template.md +14 -2
- package/core/shared/templates/doflow/requirement-template.md +1 -1
- package/core/worker-evidence/antigravity/checks.json +14 -0
- package/core/worker-evidence/codex/2026-10-18-cli-check.json +107 -0
- package/core/worker-evidence/codex/2026-10-18-live-run-edit.json +73 -0
- package/core/worker-evidence/codex/2026-10-18-live-run-read-only.json +62 -0
- package/core/worker-evidence/codex/2026-10-24-cli-check.json +126 -0
- package/core/worker-evidence/codex/checks.json +38 -0
- package/package.json +10 -6
- package/src/adapters/antigravity/index.js +226 -113
- package/src/adapters/claude/index.js +39 -5
- package/src/adapters/codex/agents.js +25 -15
- package/src/adapters/codex/hooks.js +40 -5
- package/src/adapters/codex/index.js +100 -22
- package/src/adapters/codex/native-projection.js +6 -2
- package/src/adapters/copilot/index.js +58 -23
- package/src/adapters/copy-tree.js +294 -48
- package/src/adapters/guidance-manifest.js +71 -0
- package/src/adapters/guidance-pointer.js +19 -0
- package/src/adapters/hook-commands.js +6 -10
- package/src/adapters/index.js +1 -0
- package/src/adapters/kiro/index.js +38 -13
- package/src/adapters/opencode/index.js +8 -8
- package/src/adapters/pi/hooks.js +120 -0
- package/src/adapters/pi/index.js +48 -16
- package/src/adapters/resolve-source.js +26 -2
- package/src/cli/commands/install.js +3 -2
- package/src/cli/commands/reconcile.js +53 -9
- package/src/cli/commands/remove.js +2 -2
- package/src/cli/commands/rollback.js +6 -3
- package/src/cli/commands/self-update.js +18 -9
- package/src/cli/commands/status.js +21 -2
- package/src/cli/commands/ui.js +99 -0
- package/src/cli/commands/update.js +3 -2
- package/src/cli/index.js +338 -33
- package/src/cli/runtime-commands.js +243 -52
- package/src/cli/shared.js +0 -2
- package/src/helper/git.js +1 -1
- package/src/helper/guardrails.js +1 -1
- package/src/helper/marker-merge.js +31 -13
- package/src/helper/package-ids.js +37 -0
- package/src/helper/semver.js +94 -0
- package/src/install/backup.js +105 -15
- package/src/install/context.js +1 -1
- package/src/install/targets.js +31 -16
- package/src/lifecycle/coverage.js +74 -0
- package/src/lifecycle/hook-step.js +61 -0
- package/src/lifecycle/hook-tier.js +160 -0
- package/src/lifecycle/index.js +434 -86
- package/src/lifecycle/retired-harnesses.js +318 -0
- package/src/lifecycle/view.js +35 -15
- package/src/registry/index.js +686 -32
- package/src/registry/worker-ids.js +45 -0
- package/src/release/build-package.js +0 -3
- package/src/release/docs-blocks.js +492 -0
- package/src/release/preflight.js +425 -0
- package/src/release/rehearse.js +401 -0
- package/src/release/release-workflow.js +733 -0
- package/src/release/sync-plugin-versions.js +43 -7
- package/src/runtime/advice/bench-gate.js +25 -0
- package/src/runtime/advice/cli.js +59 -16
- package/src/runtime/advice/client.js +32 -9
- package/src/runtime/advice/config.js +98 -133
- package/src/runtime/advice/doctor.js +1 -1
- package/src/runtime/advice/elevation.js +97 -0
- package/src/runtime/advice/endpoint-guard.js +9 -3
- package/src/runtime/advice/mode.js +37 -0
- package/src/runtime/advice/record.js +18 -5
- package/src/runtime/advice/registry.js +4 -1
- package/src/runtime/advice/shadow-config.js +229 -0
- package/src/runtime/advice/shadow-dispatcher.js +276 -0
- package/src/runtime/brief-rules.js +81 -0
- package/src/runtime/brief-tools.js +111 -34
- package/src/runtime/candidate.js +514 -0
- package/src/runtime/capabilities/executor.js +450 -0
- package/src/runtime/capabilities/loopback.js +41 -0
- package/src/runtime/capabilities/sanitizer.js +88 -0
- package/src/runtime/capability-router.js +135 -3
- package/src/runtime/checkouts.js +73 -11
- package/src/runtime/claims.js +27 -12
- package/src/runtime/cli-result.js +11 -4
- package/src/runtime/cli.js +221 -277
- package/src/runtime/config-home.js +42 -0
- package/src/runtime/context/arbitrate.js +767 -0
- package/src/runtime/context/budget.js +203 -0
- package/src/runtime/context/compose.js +1367 -0
- package/src/runtime/context/delivery-store.js +100 -0
- package/src/runtime/context/emission-rules.js +118 -0
- package/src/runtime/context/identity.js +227 -0
- package/src/runtime/context/mandatory.js +594 -0
- package/src/runtime/context/pointer.js +142 -0
- package/src/runtime/context/primary-command.js +117 -0
- package/src/runtime/context/primary.js +344 -0
- package/src/runtime/context/summary-store.js +655 -0
- package/src/runtime/context-pack.js +1106 -245
- package/src/runtime/decision-register.js +13 -4
- package/src/runtime/dispatch/admission.js +392 -0
- package/src/runtime/dispatch/attempt-end.js +274 -0
- package/src/runtime/dispatch/command.js +628 -0
- package/src/runtime/dispatch/controls.js +904 -0
- package/src/runtime/dispatch/envelope.js +276 -0
- package/src/runtime/dispatch/grants.js +310 -0
- package/src/runtime/dispatch/integrate.js +617 -0
- package/src/runtime/dispatch/loop.js +1835 -0
- package/src/runtime/dispatch/store.js +352 -0
- package/src/runtime/dispatch/verify-run.js +201 -0
- package/src/runtime/evidence-fields.js +39 -0
- package/src/runtime/evidence-ledger.js +41 -7
- package/src/runtime/failure/capture.js +3 -1
- package/src/runtime/failure/cli.js +25 -9
- package/src/runtime/failure/home.js +57 -30
- package/src/runtime/failure/store.js +7 -2
- package/src/runtime/feature-pointer.js +174 -0
- package/src/runtime/feature-resolve.js +13 -2
- package/src/runtime/fleet/command.js +77 -0
- package/src/runtime/fleet/projects.js +178 -0
- package/src/runtime/fleet/tree.js +383 -0
- package/src/runtime/freshness.js +77 -10
- package/src/runtime/git-memo.js +46 -0
- package/src/runtime/guidance/ablation.js +427 -0
- package/src/runtime/health.js +565 -17
- package/src/runtime/history-compactor.js +13 -3
- package/src/runtime/implementation-gate.js +277 -22
- package/src/runtime/inventory/coverage.js +1 -1
- package/src/runtime/inventory/index.js +1 -1
- package/src/runtime/inventory/precedence.js +2 -2
- package/src/runtime/inventory/siblings.js +6 -4
- package/src/runtime/knowledge/code-corpus.js +277 -0
- package/src/runtime/knowledge/code-lexical.js +130 -0
- package/src/runtime/knowledge/code-retrieval.js +307 -0
- package/src/runtime/knowledge/code-validation.js +106 -0
- package/src/runtime/knowledge/gp3-gate.js +74 -0
- package/src/runtime/knowledge/graph-adapter.js +288 -0
- package/src/runtime/knowledge/graph-fallback.js +394 -0
- package/src/runtime/knowledge/hybrid.js +136 -8
- package/src/runtime/knowledge/retrieval.js +34 -1
- package/src/runtime/knowledge/rtk-compress.js +77 -0
- package/src/runtime/knowledge/semble-bridge.py +106 -0
- package/src/runtime/knowledge/semble-lifecycle.js +114 -0
- package/src/runtime/knowledge/semble-provider.js +365 -0
- package/src/runtime/lifecycle/cli.js +16 -6
- package/src/runtime/lifecycle/event-store.js +8 -6
- package/src/runtime/lifecycle/followup.js +6 -1
- package/src/runtime/lifecycle/overview.js +24 -1
- package/src/runtime/lifecycle/report-store.js +8 -10
- package/src/runtime/lifecycle/retention.js +95 -31
- package/src/runtime/lifecycle/root.js +9 -1
- package/src/runtime/lifecycle/status.js +34 -17
- package/src/runtime/lifecycle/store-upkeep.js +56 -7
- package/src/runtime/mask.js +134 -7
- package/src/runtime/mcp-consultations.js +40 -6
- package/src/runtime/model-router.js +79 -7
- package/src/runtime/models/catalogue.js +191 -0
- package/src/runtime/models/command.js +153 -0
- package/src/runtime/off-words.js +12 -0
- package/src/runtime/outcome.js +3 -3
- package/src/runtime/packages/command.js +1009 -0
- package/src/runtime/packages/contributions.js +116 -0
- package/src/runtime/packages/digest.js +132 -0
- package/src/runtime/packages/fetch.js +182 -0
- package/src/runtime/packages/grants.js +192 -0
- package/src/runtime/packages/index-file.js +134 -0
- package/src/runtime/packages/instruction.js +90 -0
- package/src/runtime/packages/manifest.js +331 -0
- package/src/runtime/packages/points.js +477 -0
- package/src/runtime/packages/programs.js +216 -0
- package/src/runtime/packages/scaffold.js +277 -0
- package/src/runtime/packages/source.js +90 -0
- package/src/runtime/packages/state.js +164 -0
- package/src/runtime/packages/store.js +449 -0
- package/src/runtime/packages/tar.js +106 -0
- package/src/runtime/packages/view.js +406 -0
- package/src/runtime/plan-check.js +59 -0
- package/src/runtime/plan-content.js +324 -0
- package/src/runtime/policy-init.js +118 -0
- package/src/runtime/profiles/doctor.js +96 -0
- package/src/runtime/profiles/resolve.js +244 -0
- package/src/runtime/profiles/rollback.js +254 -0
- package/src/runtime/profiles/sampler.js +41 -0
- package/src/runtime/readiness-record.js +16 -11
- package/src/runtime/readiness.js +127 -16
- package/src/runtime/research-request.js +50 -25
- package/src/runtime/retrieval-plan.js +402 -73
- package/src/runtime/retrieval-record.js +293 -0
- package/src/runtime/review/command.js +246 -0
- package/src/runtime/review/dominance.js +68 -0
- package/src/runtime/review/findings.js +434 -0
- package/src/runtime/review/identity.js +255 -0
- package/src/runtime/review/protocol-command.js +109 -0
- package/src/runtime/review/protocols.js +405 -0
- package/src/runtime/review/resolve-protocol.js +302 -0
- package/src/runtime/review/start.js +530 -0
- package/src/runtime/roadmap/facts.js +479 -0
- package/src/runtime/roadmap/gates.js +270 -0
- package/src/runtime/roadmap/loop.js +1636 -0
- package/src/runtime/roadmap/merge.js +381 -0
- package/src/runtime/roadmap/rows.js +1113 -0
- package/src/runtime/roadmap/seed.js +951 -0
- package/src/runtime/rules-report.js +336 -0
- package/src/runtime/scaffold/artifacts.js +63 -9
- package/src/runtime/scaffold/generate.js +21 -9
- package/src/runtime/settings/autopilot.js +106 -0
- package/src/runtime/settings/cli.js +280 -0
- package/src/runtime/settings/config-write.js +314 -0
- package/src/runtime/settings/files.js +271 -0
- package/src/runtime/settings/legacy.js +154 -0
- package/src/runtime/settings/lexical.js +56 -0
- package/src/runtime/settings/prepared-run.js +269 -0
- package/src/runtime/settings/project-layers.js +118 -0
- package/src/runtime/settings/refs.js +288 -0
- package/src/runtime/settings/registry.js +553 -0
- package/src/runtime/settings/resolve.js +713 -0
- package/src/runtime/settings/shared.js +37 -0
- package/src/runtime/settings/worker-billing.js +107 -0
- package/src/runtime/settings/write.js +269 -0
- package/src/runtime/slot-command.js +78 -0
- package/src/runtime/slots.js +671 -0
- package/src/runtime/source-version.js +290 -0
- package/src/runtime/state-root.js +217 -0
- package/src/runtime/storage/cli.js +12 -5
- package/src/runtime/storage/engine.js +9 -2
- package/src/runtime/storage/registry.js +14 -1
- package/src/runtime/storage/roots.js +66 -16
- package/src/runtime/storage/rules.js +82 -10
- package/src/runtime/storage/upkeep.js +10 -2
- package/src/runtime/storage/work-status.js +245 -26
- package/src/runtime/task-attempts.js +589 -69
- package/src/runtime/task-classifier.js +47 -11
- package/src/runtime/task-graph.js +373 -0
- package/src/runtime/task-run.js +778 -0
- package/src/runtime/task-scope.js +202 -56
- package/src/runtime/task-sources.js +147 -0
- package/src/runtime/task-state.js +440 -65
- package/src/runtime/team/admission.js +301 -0
- package/src/runtime/team/envelope.js +324 -0
- package/src/runtime/team/review-guard.js +156 -0
- package/src/runtime/trace/analyze.js +427 -0
- package/src/runtime/trace/baseline.js +770 -0
- package/src/runtime/trace/ledger.js +63 -140
- package/src/runtime/trace/otlp-export.js +568 -0
- package/src/runtime/trace/otlp-map.js +481 -0
- package/src/runtime/trace/spans.js +745 -0
- package/src/runtime/trace/telemetry.js +225 -0
- package/src/runtime/trace/views.js +1 -0
- package/src/runtime/transcripts/command.js +98 -0
- package/src/runtime/transcripts/cursor.js +326 -0
- package/src/runtime/transcripts/read.js +126 -0
- package/src/runtime/transcripts/readers/claude-jsonl.js +74 -0
- package/src/runtime/transcripts/readers/codex-rollout.js +70 -0
- package/src/runtime/transcripts/readers/copilot-events.js +90 -0
- package/src/runtime/transcripts/readers/kiro-jsonl.js +77 -0
- package/src/runtime/transcripts/readers/pi-jsonl.js +59 -0
- package/src/runtime/transcripts/registry.js +161 -0
- package/src/runtime/transcripts/stats.js +161 -0
- package/src/runtime/verification/check-key.js +628 -0
- package/src/runtime/verification/contract-runner.js +546 -11
- package/src/runtime/verification/engine.js +499 -9
- package/src/runtime/verification/impact.js +617 -0
- package/src/runtime/verification/inflight.js +205 -0
- package/src/runtime/verification/registry.js +176 -0
- package/src/runtime/verification/reuse.js +184 -0
- package/src/runtime/verification/telemetry-emit.js +254 -0
- package/src/runtime/verification/test-selection.js +67 -7
- package/src/runtime/worker/active.js +90 -0
- package/src/runtime/worker/cancel.js +222 -0
- package/src/runtime/worker/catalogue.js +122 -0
- package/src/runtime/worker/command.js +677 -0
- package/src/runtime/worker/evidence.js +288 -0
- package/src/runtime/worker/launch.js +288 -0
- package/src/runtime/worker/models.js +137 -0
- package/src/runtime/worker/parsers.js +218 -0
- package/src/runtime/worker/probes/index.js +706 -0
- package/src/runtime/worker/process-tree.js +415 -0
- package/src/runtime/worker/quota.js +43 -0
- package/src/runtime/worker/readiness.js +713 -0
- package/src/runtime/worker/run-store.js +166 -0
- package/src/runtime/worker/supervisor.js +541 -0
- package/src/runtime/worker/worktree-check.js +252 -0
- package/src/runtime/workflow-engine.js +5 -1
- package/src/runtime/workflow-orchestrator.js +578 -63
- package/src/runtime/worktree.js +149 -22
- package/src/state/index.js +1 -1
- package/src/state/lockfile.js +64 -10
- package/src/state/run-lock.js +1 -1
- package/types/node-commonjs.d.ts +106 -7
- package/core/.antigravity-plugin/hooks.json +0 -39
- package/core/harnesses/gemini/hooks/hooks.json +0 -77
- package/core/harnesses/gemini/hooks/lib.sh +0 -302
- package/core/harnesses/gemini/hooks/mcp-tool-guard.sh +0 -21
- package/core/harnesses/gemini/hooks/post-edit-lint.sh +0 -39
- package/core/harnesses/gemini/hooks/pre-bash-guard.sh +0 -21
- package/core/harnesses/gemini/hooks/pre-compact.sh +0 -38
- package/core/harnesses/gemini/hooks/pre-implement-gate.sh +0 -22
- package/core/harnesses/gemini/hooks/session-end.impl.sh +0 -89
- package/core/harnesses/gemini/hooks/session-end.sh +0 -5
- package/core/harnesses/gemini/hooks/session-start.sh +0 -5
- package/core/harnesses/gemini/settings/adapter-defaults.json +0 -4
- package/core/harnesses/shared/hooks/adapters/arg-fields.js +0 -19
- package/core/harnesses/shared/hooks/adapters/gemini.js +0 -114
- package/core/harnesses/shared/hooks/hooks.json +0 -47
- package/core/shared/guidance/FLAGS.md +0 -25
- package/core/shared/guidance/rules/RULE_01_SAFETY.md +0 -25
- package/core/shared/guidance/rules/RULE_02_WORKFLOW.md +0 -23
- package/core/shared/guidance/rules/RULE_03_QUALITY.md +0 -14
- package/core/shared/guidance/rules/RULE_04_QUESTIONS.md +0 -46
- package/src/adapters/gemini/hooks.js +0 -210
- package/src/adapters/gemini/index.js +0 -390
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `transcript --action read` (093 IC-022): one agent's recent events. The agent is resolved inside core from
|
|
5
|
+
* `buildTree`'s node set for the current project (a key outside it is `agent-not-in-project`); its transcript
|
|
6
|
+
* file is the one the tree joined by session id, and its header `cwd` must lie in one of the project's
|
|
7
|
+
* checkouts (`session-not-in-project`, R24). Text mode, so reply text and tool arguments come back masked and
|
|
8
|
+
* capped by the reader. Every agent also gets `record` events, DoFlow's own records of it (worker run start and
|
|
9
|
+
* end, attempt claim and end, hook records): they carry no text and make a panel non-blank whatever the reader
|
|
10
|
+
* status. A read with a cursor returns only the record events newer than the cursor's `recordAtMs`; without
|
|
11
|
+
* one (or after a reset) the 64 newest. Nothing is written; no path, pid or raw session id is printed.
|
|
12
|
+
*
|
|
13
|
+
* The cursor stays the reader's four parts. `recordSeq` also counts the record events returned, so `seq` is
|
|
14
|
+
* one running sequence. `recordAtMs` is raised to the newest record event returned, so one is not returned
|
|
15
|
+
* twice, except for Kiro, whose reader uses that field as its turn clock (raising it could skip a turn): a
|
|
16
|
+
* Kiro record event newer than the newest turn can come back again on the next read.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const fs = require('node:fs');
|
|
20
|
+
const path = require('node:path');
|
|
21
|
+
const { buildTree, READERS } = require('../fleet/tree.js');
|
|
22
|
+
const { listCheckouts } = require('../checkouts.js');
|
|
23
|
+
const { loadTranscriptRegistry } = require('./registry.js');
|
|
24
|
+
const { parseCursor, toMs, toIso } = require('./cursor.js');
|
|
25
|
+
|
|
26
|
+
const RECORD_EVENTS = 64;
|
|
27
|
+
const AGENT_KEY = /^[0-9a-f]{16}$/;
|
|
28
|
+
|
|
29
|
+
/** True when `cwd` is a checkout or lies under one. An absent cwd cannot be checked and passes (the join was by session id). */
|
|
30
|
+
function inCheckouts(cwd , checkouts , fsImpl = fs) {
|
|
31
|
+
if (cwd === null || cwd === undefined) return true;
|
|
32
|
+
if (typeof cwd !== 'string' || !path.isAbsolute(cwd)) return false;
|
|
33
|
+
let real = path.resolve(cwd);
|
|
34
|
+
try { real = fsImpl.realpathSync(real); } catch { /* a cwd that is gone is compared as written */ }
|
|
35
|
+
return checkouts.some((root) => {
|
|
36
|
+
let r = root;
|
|
37
|
+
try { r = fsImpl.realpathSync(root); } catch { /* as written */ }
|
|
38
|
+
return real === r || real.startsWith(r.endsWith(path.sep) ? r : r + path.sep);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The project's non-sandbox checkouts. */
|
|
43
|
+
function checkoutRoots({ cwd, exec, fsImpl } ) {
|
|
44
|
+
const listed = listCheckouts({ cwd, ...(exec ? { exec } : {}), ...(fsImpl ? { fsImpl } : {}) });
|
|
45
|
+
return listed.ok ? listed.entries.filter((e ) => !e.sandbox).map((e ) => e.path) : [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** What the registry says about a node's harness: the reader id and status the body prints. */
|
|
49
|
+
function readerFor(registry , node ) {
|
|
50
|
+
const entry = node.harness ? registry[node.harness] : null;
|
|
51
|
+
if (!entry) return { id: null, status: 'events-only' };
|
|
52
|
+
if (node.transcript.reason === 'no-reader' || node.transcript.reason === 'not-linked') return { id: null, status: 'events-only' };
|
|
53
|
+
return { id: entry.reader, status: entry.status };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function registryById() {
|
|
57
|
+
const loaded = loadTranscriptRegistry();
|
|
58
|
+
const out = {};
|
|
59
|
+
for (const entry of loaded.ok ? loaded.registry.entries : []) out[entry.harness] = entry;
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The record events of `records` newer than `sinceMs` (all when null), at most 64 newest, oldest first. */
|
|
64
|
+
function recordEvents(records , node , sinceMs , firstSeq ) {
|
|
65
|
+
const timed = records.map((r) => ({ r, ms: toMs(r.at) })).filter((x) => Number.isFinite(x.ms) && (sinceMs === null || x.ms > sinceMs));
|
|
66
|
+
timed.sort((a, b) => a.ms - b.ms || (a.r.type < b.r.type ? -1 : 1));
|
|
67
|
+
return timed.slice(-RECORD_EVENTS).map(({ r }, i) => ({
|
|
68
|
+
seq: firstSeq + i, at: toIso(r.at), kind: 'record', agentKey: node.agentKey, model: null, tool: null, text: null, args: null, cut: false, tokens: null,
|
|
69
|
+
record: { type: r.type, task: r.task ?? null, result: r.result ?? null },
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function readAgent({
|
|
74
|
+
env = process.env, cwd = process.cwd(), agent, cursor, limit, exec, alive, fsImpl = fs, platform, home, now,
|
|
75
|
+
} = {}) {
|
|
76
|
+
const built = buildTree({ env, cwd, ...(exec ? { exec } : {}), ...(alive ? { alive } : {}), ...(fsImpl !== fs ? { fsImpl } : {}), ...(platform ? { platform } : {}), ...(home ? { home } : {}), ...(now ? { now } : {}) });
|
|
77
|
+
if (!built.ok) return { ok: false, error: built.error };
|
|
78
|
+
const node = AGENT_KEY.test(agent ?? '') ? built.body.nodes.find((n ) => n.agentKey === agent) : undefined;
|
|
79
|
+
if (!node) return { ok: false, error: 'agent-not-in-project' };
|
|
80
|
+
const internal = built.internal.get(node.agentKey) ?? {};
|
|
81
|
+
const registry = registryById();
|
|
82
|
+
const reader = readerFor(registry, node);
|
|
83
|
+
let transcript = { linked: node.transcript.linked, reason: node.transcript.reason };
|
|
84
|
+
let result = null;
|
|
85
|
+
|
|
86
|
+
if (node.transcript.linked && internal.file) {
|
|
87
|
+
const mod = READERS[registry[node.harness].reader]();
|
|
88
|
+
const header = mod.header({ file: internal.file, companion: internal.companion });
|
|
89
|
+
if (!inCheckouts(header.cwd, checkoutRoots({ cwd, exec, fsImpl }), fsImpl)) return { ok: false, error: 'session-not-in-project' };
|
|
90
|
+
try {
|
|
91
|
+
result = mod.read({ file: internal.file, companion: internal.companion, mode: 'text', cursor, limit, agentKey: node.agentKey });
|
|
92
|
+
} catch (error ) {
|
|
93
|
+
if (!error || (error.code !== 'ENOENT' && error.code !== 'ENOTDIR' && error.code !== 'EACCES')) throw error;
|
|
94
|
+
transcript = { linked: false, reason: 'not-found' }; // the file went away between the tree and the read
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const parsed = parseCursor(cursor);
|
|
99
|
+
const fresh = parsed === null || (result !== null && result.reset);
|
|
100
|
+
const readerEvents = result ? result.events : [];
|
|
101
|
+
const firstSeq = result ? parseCursor(result.cursor).seq : parsed ? parsed.seq : 0;
|
|
102
|
+
const recs = recordEvents(internal.records ?? [], node, fresh ? null : parsed.atMs, firstSeq);
|
|
103
|
+
const newest = recs.length ? Math.max(...recs.map((e ) => toMs(e.at))) : null;
|
|
104
|
+
|
|
105
|
+
let nextCursor ;
|
|
106
|
+
if (result) {
|
|
107
|
+
const c = parseCursor(result.cursor);
|
|
108
|
+
const raise = registry[node.harness].reader !== 'kiro-jsonl' && newest !== null ? Math.max(c.atMs, newest) : c.atMs;
|
|
109
|
+
nextCursor = `${c.ino}:${c.offset}:${c.seq + recs.length}:${raise}`;
|
|
110
|
+
} else {
|
|
111
|
+
const prior = parsed ? parsed.atMs : 0;
|
|
112
|
+
nextCursor = `0:0:${firstSeq + recs.length}:${Math.max(prior, newest ?? 0)}`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
ok: true,
|
|
117
|
+
body: {
|
|
118
|
+
v: 1, agentKey: node.agentKey, harness: node.harness, reader, transcript,
|
|
119
|
+
events: [...readerEvents, ...recs], cursor: nextCursor, reset: result ? result.reset : false, eof: result ? result.eof : true,
|
|
120
|
+
otherRecords: result ? result.otherRecords : 0, unparsable: result ? result.unparsable : 0, masked: result ? result.masked : 0,
|
|
121
|
+
warnings: result ? result.warnings : [],
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { readAgent, inCheckouts, checkoutRoots, registryById, AGENT_KEY };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 093 V.4 (IC-022): Claude Code reader. `~/.claude/projects/<cwd>/<sessionId>.jsonl`, and a sub-agent's
|
|
5
|
+
* `<sessionId>/subagents/agent-<id>.jsonl` with its `.meta.json` (R§3). Whitelist: `assistant` records
|
|
6
|
+
* (`message.content[]` `text` and `tool_use`, `message.usage`), `user` records' `tool_result` blocks.
|
|
7
|
+
* Thinking, user prompts, attachments, system and every other type are counted, never read. Usage is
|
|
8
|
+
* deduplicated by `message.id` (the same usage repeats on every line of one message).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { readTranscript, headRecords, readJsonFile, label, sizeOf, tokens } = require('../cursor.js');
|
|
12
|
+
|
|
13
|
+
const REQUIRED_KEYS = ['type', 'timestamp', 'sessionId'];
|
|
14
|
+
|
|
15
|
+
function blocksOf(content ) {
|
|
16
|
+
if (typeof content === 'string') return [{ type: 'text', text: content }];
|
|
17
|
+
return Array.isArray(content) ? content : [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const SPEC = {
|
|
21
|
+
id: 'claude-jsonl',
|
|
22
|
+
requiredKeys: REQUIRED_KEYS,
|
|
23
|
+
init: () => ({ seen: new Set () }),
|
|
24
|
+
parse(rec , ctx ) {
|
|
25
|
+
const events = [];
|
|
26
|
+
let other = 0;
|
|
27
|
+
const msg = rec.message && typeof rec.message === 'object' ? rec.message : null;
|
|
28
|
+
if (rec.type === 'assistant' && msg) {
|
|
29
|
+
for (const b of blocksOf(msg.content)) {
|
|
30
|
+
if (b && b.type === 'text' && typeof b.text === 'string') events.push(ctx.event('reply', rec.timestamp, { model: msg.model, text: b.text }));
|
|
31
|
+
else if (b && b.type === 'tool_use') {
|
|
32
|
+
ctx.noteCall(b.id, rec.timestamp, b.name);
|
|
33
|
+
events.push(ctx.event('tool-call', rec.timestamp, { model: msg.model, tool: ctx.tool(b.name, b.id), args: b.input }));
|
|
34
|
+
} else other += 1; // thinking and anything else
|
|
35
|
+
}
|
|
36
|
+
const first = typeof msg.id !== 'string' || !ctx.state.seen.has(msg.id);
|
|
37
|
+
if (msg.usage && typeof msg.usage === 'object' && first) {
|
|
38
|
+
if (typeof msg.id === 'string') ctx.state.seen.add(msg.id);
|
|
39
|
+
const t = tokens({
|
|
40
|
+
input: msg.usage.input_tokens, output: msg.usage.output_tokens,
|
|
41
|
+
cacheRead: msg.usage.cache_read_input_tokens, cacheWrite: msg.usage.cache_creation_input_tokens,
|
|
42
|
+
});
|
|
43
|
+
if (t) events.push(ctx.event('usage', rec.timestamp, { model: msg.model, tokens: t }));
|
|
44
|
+
}
|
|
45
|
+
} else if (rec.type === 'user' && msg) {
|
|
46
|
+
for (const b of blocksOf(msg.content)) {
|
|
47
|
+
if (b && b.type === 'tool_result') {
|
|
48
|
+
const call = ctx.callOf(b.tool_use_id);
|
|
49
|
+
events.push(ctx.event('tool-result', rec.timestamp, {
|
|
50
|
+
tool: ctx.tool(call && call.name, b.tool_use_id, {
|
|
51
|
+
status: b.is_error === true ? 'error' : b.is_error === false ? 'ok' : null,
|
|
52
|
+
bytes: sizeOf(b.content), durationMs: ctx.durationOf(b.tool_use_id, rec.timestamp),
|
|
53
|
+
}),
|
|
54
|
+
}));
|
|
55
|
+
} else other += 1; // the user's own text
|
|
56
|
+
}
|
|
57
|
+
} else other = 1;
|
|
58
|
+
return { events, other };
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** Header facts of a main or sub-agent file; `sessionId` and `cwd` are for core only, never printed. */
|
|
63
|
+
function header({ file, metaFile } ) {
|
|
64
|
+
const first = headRecords(file).find((r ) => typeof r.sessionId === 'string') || {};
|
|
65
|
+
const meta = readJsonFile(metaFile ?? file.replace(/\.jsonl$/, '.meta.json')) || {};
|
|
66
|
+
return {
|
|
67
|
+
sessionId: first.sessionId ?? null, agentId: typeof first.agentId === 'string' ? first.agentId : null,
|
|
68
|
+
cwd: typeof first.cwd === 'string' ? first.cwd : null, parentSessionId: null,
|
|
69
|
+
label: label(meta.agentType), depth: Number.isInteger(meta.spawnDepth) ? meta.spawnDepth : null, model: label(meta.model),
|
|
70
|
+
children: [],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = { id: 'claude-jsonl', REQUIRED_KEYS, read: (opts ) => readTranscript(SPEC, opts), header };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 093 V.4 (IC-022): Codex reader. `$CODEX_HOME/sessions/YYYY/MM/DD/rollout-<ts>-<uuid>.jsonl`, lines
|
|
5
|
+
* `{timestamp, type, payload}` (R§3). Whitelist: `turn_context` (model), `response_item` assistant
|
|
6
|
+
* `message`, `function_call`, `custom_tool_call` and their outputs, `event_msg` `token_count` (per-call
|
|
7
|
+
* `last_token_usage`) and `agent_message`. Reasoning, user and developer messages, `session_meta` and every
|
|
8
|
+
* other type are counted, never read. Codex writes a reply as both a message item and an `agent_message`;
|
|
9
|
+
* an identical reply straight after another is skipped.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { readTranscript, headRecords, label, sizeOf, tokens } = require('../cursor.js');
|
|
13
|
+
|
|
14
|
+
const REQUIRED_KEYS = ['timestamp', 'type', 'payload'];
|
|
15
|
+
|
|
16
|
+
const SPEC = {
|
|
17
|
+
id: 'codex-rollout',
|
|
18
|
+
requiredKeys: REQUIRED_KEYS,
|
|
19
|
+
init: () => ({ model: null, lastReply: null }),
|
|
20
|
+
parse(rec , ctx ) {
|
|
21
|
+
const events = [];
|
|
22
|
+
let other = 0;
|
|
23
|
+
const p = rec.payload && typeof rec.payload === 'object' ? rec.payload : {};
|
|
24
|
+
const reply = (text ) => {
|
|
25
|
+
if (typeof text !== 'string' || text === ctx.state.lastReply) { other += 1; return; }
|
|
26
|
+
ctx.state.lastReply = text;
|
|
27
|
+
events.push(ctx.event('reply', rec.timestamp, { text }));
|
|
28
|
+
};
|
|
29
|
+
if (rec.type === 'turn_context' && typeof p.model === 'string') {
|
|
30
|
+
ctx.state.model = p.model;
|
|
31
|
+
events.push(ctx.event('model-change', rec.timestamp, { model: p.model }));
|
|
32
|
+
} else if (rec.type === 'response_item' && p.type === 'message' && p.role === 'assistant') {
|
|
33
|
+
for (const c of Array.isArray(p.content) ? p.content : []) {
|
|
34
|
+
if (c && c.type === 'output_text') reply(c.text);
|
|
35
|
+
else other += 1;
|
|
36
|
+
}
|
|
37
|
+
} else if (rec.type === 'response_item' && (p.type === 'function_call' || p.type === 'custom_tool_call')) {
|
|
38
|
+
ctx.noteCall(p.call_id, rec.timestamp, p.name);
|
|
39
|
+
events.push(ctx.event('tool-call', rec.timestamp, { tool: ctx.tool(p.name, p.call_id), args: p.type === 'function_call' ? p.arguments : p.input }));
|
|
40
|
+
} else if (rec.type === 'response_item' && (p.type === 'function_call_output' || p.type === 'custom_tool_call_output')) {
|
|
41
|
+
const call = ctx.callOf(p.call_id);
|
|
42
|
+
events.push(ctx.event('tool-result', rec.timestamp, {
|
|
43
|
+
tool: ctx.tool(call && call.name, p.call_id, { bytes: sizeOf(p.output), durationMs: ctx.durationOf(p.call_id, rec.timestamp) }),
|
|
44
|
+
}));
|
|
45
|
+
} else if (rec.type === 'event_msg' && p.type === 'token_count' && p.info && p.info.last_token_usage) {
|
|
46
|
+
const u = p.info.last_token_usage;
|
|
47
|
+
const t = tokens({ input: u.input_tokens, output: u.output_tokens, cacheRead: u.cached_input_tokens, cacheWrite: u.cache_write_input_tokens, reasoning: u.reasoning_output_tokens });
|
|
48
|
+
if (t) events.push(ctx.event('usage', rec.timestamp, { tokens: t }));
|
|
49
|
+
else other = 1;
|
|
50
|
+
} else if (rec.type === 'event_msg' && p.type === 'agent_message') reply(p.message);
|
|
51
|
+
else other = 1;
|
|
52
|
+
if (events.length === 0 && other === 0) other = 1;
|
|
53
|
+
return { events, other };
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Header facts from `session_meta`; `sessionId` and `cwd` are for core only. A sub-agent's `source` names its parent thread. */
|
|
58
|
+
function header({ file } ) {
|
|
59
|
+
const meta = headRecords(file).find((r ) => r.type === 'session_meta');
|
|
60
|
+
const p = (meta && meta.payload) || {};
|
|
61
|
+
const spawn = (p.source && p.source.SubAgent && p.source.SubAgent.ThreadSpawn) || null;
|
|
62
|
+
return {
|
|
63
|
+
sessionId: typeof p.id === 'string' ? p.id : null, agentId: null, cwd: typeof p.cwd === 'string' ? p.cwd : null,
|
|
64
|
+
parentSessionId: spawn && typeof spawn.parent_thread_id === 'string' ? spawn.parent_thread_id : null,
|
|
65
|
+
label: spawn ? label(spawn.agent_role) : null, depth: spawn && Number.isInteger(spawn.depth) ? spawn.depth : null, model: null,
|
|
66
|
+
children: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = { id: 'codex-rollout', REQUIRED_KEYS, read: (opts ) => readTranscript(SPEC, opts), header };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 093 V.4 (IC-022): GitHub Copilot CLI reader. `~/.copilot/session-state/<sessionId>/events.jsonl`, envelope
|
|
5
|
+
* `{id, parentId, timestamp, type, agentId, data}` (R§3). Whitelist: `assistant.message`,
|
|
6
|
+
* `tool.execution_start`, `tool.execution_complete`, `subagent.started` and the usage records. Usage is
|
|
7
|
+
* cumulative per model, so each record is differenced against the previous one; the first record of a window
|
|
8
|
+
* is differenced against the last usage record before the window (a negative step means the counter restarted
|
|
9
|
+
* and the value itself is the step). Reasoning, encrypted content, user messages and every other type are
|
|
10
|
+
* counted, never read.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { readTranscript, headRecords, label, sizeOf, tokens } = require('../cursor.js');
|
|
14
|
+
|
|
15
|
+
const REQUIRED_KEYS = ['id', 'timestamp', 'type', 'data'];
|
|
16
|
+
const USAGE_TYPES = new Set(['session.usage_record', 'session.usage_checkpoint', 'session.shutdown']);
|
|
17
|
+
const FIELDS = [
|
|
18
|
+
['input', 'inputTokens'], ['output', 'outputTokens'], ['cacheRead', 'cacheReadTokens'], ['cacheWrite', 'cacheWriteTokens'], ['reasoning', 'reasoningTokens'],
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/** model -> cumulative `usage` object of one usage record. */
|
|
22
|
+
function metricsOf(rec ) {
|
|
23
|
+
const mm = rec && rec.data && rec.data.modelMetrics;
|
|
24
|
+
if (!mm || typeof mm !== 'object') return [];
|
|
25
|
+
return Object.entries(mm).filter(([, v] ) => v && typeof v.usage === 'object' && v.usage !== null).map(([k, v] ) => [k, v.usage]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const SPEC = {
|
|
29
|
+
id: 'copilot-events',
|
|
30
|
+
requiredKeys: REQUIRED_KEYS,
|
|
31
|
+
init: (win ) => {
|
|
32
|
+
const base = new Map ();
|
|
33
|
+
for (const text of win.prior()) {
|
|
34
|
+
try {
|
|
35
|
+
const rec = JSON.parse(text);
|
|
36
|
+
if (rec && USAGE_TYPES.has(rec.type)) for (const [model, usage] of metricsOf(rec)) base.set(model, usage);
|
|
37
|
+
} catch { /* torn line */ }
|
|
38
|
+
}
|
|
39
|
+
return { base, model: null };
|
|
40
|
+
},
|
|
41
|
+
parse(rec , ctx ) {
|
|
42
|
+
const events = [];
|
|
43
|
+
const d = rec.data && typeof rec.data === 'object' ? rec.data : {};
|
|
44
|
+
let other = 0;
|
|
45
|
+
if (rec.type === 'assistant.message' && typeof d.content === 'string') {
|
|
46
|
+
events.push(ctx.event('reply', rec.timestamp, { model: d.model, text: d.content }));
|
|
47
|
+
} else if (rec.type === 'tool.execution_start') {
|
|
48
|
+
ctx.noteCall(d.toolCallId, rec.timestamp, d.toolName);
|
|
49
|
+
events.push(ctx.event('tool-call', rec.timestamp, { model: d.model, tool: ctx.tool(d.toolName, d.toolCallId), args: d.arguments }));
|
|
50
|
+
} else if (rec.type === 'tool.execution_complete') {
|
|
51
|
+
const call = ctx.callOf(d.toolCallId);
|
|
52
|
+
events.push(ctx.event('tool-result', rec.timestamp, {
|
|
53
|
+
model: d.model,
|
|
54
|
+
tool: ctx.tool(call && call.name, d.toolCallId, {
|
|
55
|
+
status: d.success === true ? 'ok' : d.success === false ? 'error' : null, bytes: sizeOf(d.result && d.result.content),
|
|
56
|
+
durationMs: ctx.durationOf(d.toolCallId, rec.timestamp),
|
|
57
|
+
}),
|
|
58
|
+
}));
|
|
59
|
+
} else if (rec.type === 'subagent.started') {
|
|
60
|
+
events.push(ctx.event('subagent-start', rec.timestamp, { model: d.model }));
|
|
61
|
+
} else if (USAGE_TYPES.has(rec.type)) {
|
|
62
|
+
for (const [model, cur] of metricsOf(rec)) {
|
|
63
|
+
const prev = ctx.state.base.get(model) || {};
|
|
64
|
+
const step = (key ) => (Number.isFinite(cur[key]) ? cur[key] - (Number.isFinite(prev[key]) ? prev[key] : 0) : null);
|
|
65
|
+
const restarted = FIELDS.some(([, key]) => (step(key) ?? 0) < 0);
|
|
66
|
+
const t = tokens(Object.fromEntries(FIELDS.map(([name, key]) => [name, restarted ? cur[key] : step(key)])));
|
|
67
|
+
ctx.state.base.set(model, cur);
|
|
68
|
+
if (t && Object.values(t).some((v) => v)) events.push(ctx.event('usage', rec.timestamp, { model, tokens: t }));
|
|
69
|
+
}
|
|
70
|
+
return { events, other: 0 };
|
|
71
|
+
} else other = 1;
|
|
72
|
+
if (events.length === 0 && other === 0) other = 1;
|
|
73
|
+
return { events, other };
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Header facts: `session.start` ids and the sub-agents this session started (`agentId` and its `agentName`). */
|
|
78
|
+
function header({ file } ) {
|
|
79
|
+
const records = headRecords(file, 2000, 256 * 1024);
|
|
80
|
+
const start = records.find((r ) => r.type === 'session.start');
|
|
81
|
+
const d = (start && start.data) || {};
|
|
82
|
+
return {
|
|
83
|
+
sessionId: typeof d.sessionId === 'string' ? d.sessionId : null, agentId: null,
|
|
84
|
+
cwd: d.context && typeof d.context.cwd === 'string' ? d.context.cwd : null, parentSessionId: null, label: null, depth: null, model: null,
|
|
85
|
+
children: records.filter((r ) => r.type === 'subagent.started' && typeof r.agentId === 'string')
|
|
86
|
+
.map((r ) => ({ agentId: r.agentId, label: label(r.data && r.data.agentName), depth: null })),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = { id: 'copilot-events', REQUIRED_KEYS, read: (opts ) => readTranscript(SPEC, opts), header };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 093 V.4 (IC-022): Kiro reader. `~/.kiro/sessions/cli/<uuid>.jsonl` (`{version, kind, data}`) with its
|
|
5
|
+
* companion `<uuid>.json` (R§3). Whitelist: `AssistantMessage` (`text`, `toolUse`) and `ToolResults`.
|
|
6
|
+
* Thinking, prompts, context, `Clear` and every other kind are counted, never read. The JSONL has no
|
|
7
|
+
* timestamp per record, so every event has `at: null`; per-turn tokens come from the companion's
|
|
8
|
+
* `user_turn_metadatas[]` as `usage` events (the cursor's `recordAtMs` is the newest turn `end_timestamp`
|
|
9
|
+
* already returned, so a turn is returned once).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { readTranscript, readJsonFile, label, toMs, sizeOf, tokens } = require('../cursor.js');
|
|
13
|
+
|
|
14
|
+
const REQUIRED_KEYS = ['version', 'kind', 'data'];
|
|
15
|
+
const TAIL_TURNS = 64;
|
|
16
|
+
|
|
17
|
+
function blocks(data ) {
|
|
18
|
+
return Array.isArray(data && data.content) ? data.content.filter((b ) => b && typeof b === 'object' && b.data && typeof b.data === 'object') : [];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SPEC = {
|
|
22
|
+
id: 'kiro-jsonl',
|
|
23
|
+
requiredKeys: REQUIRED_KEYS,
|
|
24
|
+
at: () => NaN, // no per-record time
|
|
25
|
+
init: () => ({ model: null }),
|
|
26
|
+
parse(rec , ctx ) {
|
|
27
|
+
const events = [];
|
|
28
|
+
let other = 0;
|
|
29
|
+
if (rec.kind === 'AssistantMessage') {
|
|
30
|
+
for (const b of blocks(rec.data)) {
|
|
31
|
+
if (typeof b.data.modelId === 'string' && b.kind !== 'thinking') ctx.state.model = b.data.modelId;
|
|
32
|
+
if (b.kind === 'text' && typeof b.data.text === 'string') events.push(ctx.event('reply', null, { text: b.data.text }));
|
|
33
|
+
else if (b.kind === 'toolUse') {
|
|
34
|
+
ctx.noteCall(b.data.toolUseId, null, b.data.name);
|
|
35
|
+
events.push(ctx.event('tool-call', null, { tool: ctx.tool(b.data.name, b.data.toolUseId), args: b.data.input }));
|
|
36
|
+
} else other += 1; // thinking
|
|
37
|
+
}
|
|
38
|
+
} else if (rec.kind === 'ToolResults') {
|
|
39
|
+
for (const b of blocks(rec.data)) {
|
|
40
|
+
if (b.kind !== 'toolResult') { other += 1; continue; }
|
|
41
|
+
const call = ctx.callOf(b.data.toolUseId);
|
|
42
|
+
const status = b.data.status === 'success' ? 'ok' : typeof b.data.status === 'string' ? 'error' : null;
|
|
43
|
+
events.push(ctx.event('tool-result', null, { tool: ctx.tool(call && call.name, b.data.toolUseId, { status, bytes: sizeOf(b.data.content) }) }));
|
|
44
|
+
}
|
|
45
|
+
} else other = 1;
|
|
46
|
+
if (events.length === 0 && other === 0) other = 1;
|
|
47
|
+
return { events, other };
|
|
48
|
+
},
|
|
49
|
+
/** Per-turn usage from the companion `.json`, after the JSONL events. */
|
|
50
|
+
extra(ctx , win , opts , room ) {
|
|
51
|
+
const j = readJsonFile(opts.companion ?? opts.file.replace(/\.jsonl$/, '.json'));
|
|
52
|
+
const turns = ((j && Array.isArray(j.user_turn_metadatas)) ? j.user_turn_metadatas : [])
|
|
53
|
+
.filter((t ) => t && typeof t === 'object')
|
|
54
|
+
.map((t ) => ({ t, ms: toMs(t.end_timestamp) }));
|
|
55
|
+
const fresh = win.tail ? turns.slice(-TAIL_TURNS) : turns.filter((x ) => !(x.ms <= win.cursor.atMs));
|
|
56
|
+
const take = fresh.slice(0, Math.max(0, room));
|
|
57
|
+
const events = take.map(({ t } ) => ctx.event('usage', null, {
|
|
58
|
+
model: t.model ?? (j.rts_model_state && j.rts_model_state.model_info && j.rts_model_state.model_info.model_id),
|
|
59
|
+
tokens: tokens({ input: t.input_token_count, output: t.output_token_count, cacheRead: t.cache_read_token_count, cacheWrite: t.cache_write_token_count }),
|
|
60
|
+
})).filter((e ) => e.tokens !== null);
|
|
61
|
+
const newest = take.map((x ) => x.ms).filter(Number.isFinite);
|
|
62
|
+
return { events, atMs: newest.length ? Math.max(...newest) : NaN, more: take.length < fresh.length };
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Header facts from the companion `.json`; `sessionId`, `cwd` and `parentSessionId` are for core only. */
|
|
67
|
+
function header({ file, companion } ) {
|
|
68
|
+
const j = readJsonFile(companion ?? file.replace(/\.jsonl$/, '.json')) || {};
|
|
69
|
+
const model = j.rts_model_state && j.rts_model_state.model_info && j.rts_model_state.model_info.model_id;
|
|
70
|
+
return {
|
|
71
|
+
sessionId: typeof j.session_id === 'string' ? j.session_id : null, agentId: null, cwd: typeof j.cwd === 'string' ? j.cwd : null,
|
|
72
|
+
parentSessionId: typeof j.parent_session_id === 'string' ? j.parent_session_id : null,
|
|
73
|
+
label: null, depth: null, model: label(model), children: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { id: 'kiro-jsonl', REQUIRED_KEYS, read: (opts ) => readTranscript(SPEC, opts), header };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 093 V.4 (IC-022): Pi reader. `~/.pi/agent/sessions/--<cwd>--/<ts>_<uuid>.jsonl`, session format v3 (R§3).
|
|
5
|
+
* Whitelist: `model_change`, `message` with role `assistant` (`text`, `toolCall`, `usage`) and `toolResult`.
|
|
6
|
+
* Thinking, user messages, the session header, custom messages and every other type are counted, never read.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { readTranscript, headRecords, label, sizeOf, tokens } = require('../cursor.js');
|
|
10
|
+
|
|
11
|
+
const REQUIRED_KEYS = ['type', 'timestamp'];
|
|
12
|
+
|
|
13
|
+
const SPEC = {
|
|
14
|
+
id: 'pi-jsonl',
|
|
15
|
+
requiredKeys: REQUIRED_KEYS,
|
|
16
|
+
init: () => ({ model: null }),
|
|
17
|
+
parse(rec , ctx ) {
|
|
18
|
+
const events = [];
|
|
19
|
+
let other = 0;
|
|
20
|
+
const m = rec.message && typeof rec.message === 'object' ? rec.message : null;
|
|
21
|
+
if (rec.type === 'model_change' && typeof rec.modelId === 'string') {
|
|
22
|
+
ctx.state.model = rec.modelId;
|
|
23
|
+
events.push(ctx.event('model-change', rec.timestamp, { model: rec.modelId }));
|
|
24
|
+
} else if (rec.type === 'message' && m && m.role === 'assistant') {
|
|
25
|
+
for (const b of Array.isArray(m.content) ? m.content : []) {
|
|
26
|
+
if (b && b.type === 'text' && typeof b.text === 'string') events.push(ctx.event('reply', rec.timestamp, { model: m.model, text: b.text }));
|
|
27
|
+
else if (b && b.type === 'toolCall') {
|
|
28
|
+
ctx.noteCall(b.id, rec.timestamp, b.name);
|
|
29
|
+
events.push(ctx.event('tool-call', rec.timestamp, { model: m.model, tool: ctx.tool(b.name, b.id), args: b.arguments }));
|
|
30
|
+
} else other += 1; // thinking
|
|
31
|
+
}
|
|
32
|
+
const u = m.usage && typeof m.usage === 'object' ? m.usage : null;
|
|
33
|
+
const t = u && tokens({ input: u.input, output: u.output, cacheRead: u.cacheRead, cacheWrite: u.cacheWrite, reasoning: u.reasoning });
|
|
34
|
+
if (t) events.push(ctx.event('usage', rec.timestamp, { model: m.model, tokens: t }));
|
|
35
|
+
} else if (rec.type === 'message' && m && m.role === 'toolResult') {
|
|
36
|
+
events.push(ctx.event('tool-result', rec.timestamp, {
|
|
37
|
+
tool: ctx.tool(m.toolName, m.toolCallId, {
|
|
38
|
+
status: m.isError === true ? 'error' : m.isError === false ? 'ok' : null, bytes: sizeOf(m.content),
|
|
39
|
+
durationMs: Number.isFinite(m.durationMs) ? m.durationMs : null,
|
|
40
|
+
}),
|
|
41
|
+
}));
|
|
42
|
+
} else other = 1;
|
|
43
|
+
if (events.length === 0 && other === 0) other = 1;
|
|
44
|
+
return { events, other };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Header facts from the `session` record; `sessionId`, `cwd` and the parent id are for core only. */
|
|
49
|
+
function header({ file } ) {
|
|
50
|
+
const h = headRecords(file, 1)[0] || {};
|
|
51
|
+
const parent = typeof h.parentSession === 'string' ? /_([0-9a-f-]{36})\.jsonl$/.exec(h.parentSession) : null;
|
|
52
|
+
return {
|
|
53
|
+
sessionId: h.type === 'session' && typeof h.id === 'string' ? h.id : null, agentId: null,
|
|
54
|
+
cwd: typeof h.cwd === 'string' ? h.cwd : null, parentSessionId: parent ? parent[1] : null,
|
|
55
|
+
label: label(null), depth: null, model: null, children: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = { id: 'pi-jsonl', REQUIRED_KEYS, read: (opts ) => readTranscript(SPEC, opts), header };
|