14 Commits
Author SHA1 Message Date
sorcnr b92d558579 fix(sec-fix-attrib): null-prototype maps + TASK_ID allowlist (SEC-1), output sanitising (SEC-3), docs honesty (SEC-2/4/5) 2026-10-18 17:22:05 +03:00
sorcnr 2a118f7d5a Merge task attrib-docs (teamwork/20261018-135620-8b41-attrib-docs) 2026-10-18 17:03:51 +03:00
teamwork-worker d6c5088078 feat(engine): record actual actor in events.jsonl; attribute spend to taskId; bucket byTaskTokens
- teamwork_task_update accepts optional agent; recorded agent resolves explicit ->
  calling session agent (ctx.session.get, then snapshots bySession) -> plan agent.
  Derivation is fail-open with a 2s bound; every value passes clean(value, 64).
- teamwork_cost: non-root spend buckets to input.taskId when given; without it the
  agent-name bucketing is unchanged.
- costs.json gains additive byTaskTokens (per-bucket token deltas) in the same
  locked section and the tree / single-session paths; manual addUsd adds no tokens.
- byTaskTokens initialised on new costs.json and tolerated when absent.
2026-10-18 13:59:42 +03:00
sorcnr 1f1280c5f8 docs: per-task attribution workflow and events.jsonl/byTaskTokens schema
- sentinel + /teamwork template: teamwork_cost({ taskId }) at each worker
  return and verifier report; agent team/worker | team/verifier on task_update
- ARTIFACTS.md: document events.jsonl (11 fields, 3 kinds, JSONL, fail-open),
  costs.json byTaskTokens, non-root bucketing rule, timeline per-task tokens
2026-10-18 13:58:23 +03:00
sorcnr d8708521d7 fix(security): SEC-1 validate task ids as single path segment; assert containment before mkdir/rmSync/worktree add
- isSafeTaskId: ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$, rejects . and ..
- validated at worktree entry point (all actions) before any path/branch is built
- containmentError: relative(runWorktreesDir, targetDir) must be non-empty, non-absolute, not '..'
- containment asserted before mkdirSync/rmSync/worktree add for sentinel and worker/verifier setup;
  rmSync re-proves containment immediately before deletion
2026-10-18 13:17:04 +03:00
sorcnr 34d166551b feat(engine): append-only events.jsonl lifecycle log (R1)
Add appendEvent() helper: appendFileSync to <run>/events.jsonl inside
withFileLock(eventsFile), after resolveRun, with refuseSymlink first.
All string fields pass clean(); wrapped in try/catch (fail-open).

Write sites:
- teamwork_plan -> run_created (to: pending, phase: DAG_BUILD)
- teamwork_task_update -> task_transition (from = prior status, to =
  resolved status after pass/fail/running normalisation and maxRounds
  coercion; agent/branch/worktree/phase included)
- teamwork_security_audit -> security_audit (to = PASS/FAIL)

No tool signature, return value, or state.json/costs.json change.
2026-10-18 03:50:55 +03:00
sorcnr 6787cd734f feat: release v0.5.2 - session tree cost tracking, DAG engine, pre-merge security gate, dynamic pitfalls, conflict healing & CLI tools 2026-10-18 02:14:00 +03:00
sorcnr 8cf1b6ca6e feat(cost): native per-session cost + credit-derived budget
- teamwork_cost reads real, OpenCode-computed cost via ctx.session.get and
  reports per-session deltas; fixes 4x over-reporting from agent self-reports
- serialize cost writes per run; atomic writes; byTask always sums to total
- budgetUsd:0 respected; negative addUsd rejected; re-plan keeps spend
- teamwork_budget preflight: opencode/ models + opencode_console connected ->
  derive budget from credits, asking the user full or partial; plan records
  budgetSource and warns when credits apply but weren't used
- sentinel: budget preflight step + post-completion verifier step
2026-10-12 12:30:28 +03:00
sorcnr a444b27835 fix(security): close traversal/symlink, injection and unsafe-install gaps
Audited by clean-context subagents across three rounds; every finding fixed and
re-verified.

- F1 path traversal: sessionId allowlist + lexical & realpath containment;
  refuse a symlinked run root, symlinked run dir, and any symlinked run file
  (lstat-based, dangling-safe)
- F2 command injection: no shell interpolation of session ids — server-derived
  $SESSION_ID, quoted; lint scans agent files AND command templates (incl.
  backslash line-continuations)
- F3 read-only guardrail: per-agent deny list (real permission actions),
  fail-closed when the permission API is unavailable
- F4 stored prompt injection: sanitised run-state injection (phase allowlist,
  validated dir name, no raw newlines/paths)
- F5 installer is non-destructive by default (refresh opt-in via --refresh)
- F6 refuse symlinked/JSONC configs; string-aware comment/trailing-comma strip
- F8 create-only reference copy on plugin load
- add team/security-auditor agent + docs/GUARDRAILS.md + guardrail lint rules
2026-10-12 02:53:25 +03:00
sorcnr fef9b9025b feat(engine): real Teamwork tools + hooks (V2 API)
- plugins/opencode-teamwork/tools.ts registers teamwork_plan/status/resume/
  cost/pitfall tools that own the run dir, plan.dag.json, state.json,
  costs.json and the pitfall registry
- permission.hook('evaluate') enforces the read-only guarantee for verifier/
  falsifier/scout in code, not just in the prompt
- session.hook('context') injects the active run's state + pitfalls into every
  team agent's system prompt
- sentinel/orchestrator now call the tools instead of hand-writing files
2026-10-12 02:12:30 +03:00
sorcnr 6774b059b6 refactor: canonical topologies, artifact schemas, safer defaults
- add docs/ARTIFACTS.md as the single schema reference (spec/plan/state/report)
- unify the topology enum across sentinel/crafter/orchestrator/commands
  (small-focused, iterative-coding, distributed-coding, proof, massive-proof,
  document-review); accept legacy aliases
- create worktrees OUTSIDE the repo (nested worktrees are a footgun)
- branch-based worker→verifier handoff instead of loose patch.diff
- proposer/synthesizer/worker shell+edit no longer 'ask' (unblocks parallel runs)
- installer copies ARTIFACTS.md to <config>/teamwork/ and ships docs/
2026-10-12 02:10:44 +03:00
sorcnr cb40d6704d refactor(agents): unify artifact root, drop duplicated prompt blocks, remove stale references
- single canonical artifact root .opencode/teamwork/<session-id>/ everywhere
  (was split between .teamwork-runs/<run-id>/ and .opencode/teamwork/)
- remove per-file 'run-time reminder' duplicates and the self-referential
  'read your agent file' instructions
- fix stale refs: src/agents/defaults.ts, agent.team/* keys, 'four patterns',
  Antigravity attributions, unverifiable Deep Think comparison
- restore interrupted.md handling in the orchestrator
2026-10-12 02:08:44 +03:00
sorcnr b97234dae7 feat: package for npm/GitHub with interactive model assignment
- root npm manifest (opencode-teamwork-v2), exports the V2 plugin, bin + postinstall
- lib/: dependency-free installer (config dir, teamwork.json model map, agent
  files, opencode.json(c) registration) and interactive model picker via 'opencode models'
- bin/opencode-teamwork.mjs: init / models / install / status + flags
- postinstall.mjs: asks models on npm install (CI-safe)
- plugin self-heals missing team/*.md on load without touching existing files
- README: npm + GitHub install, model assignment, publishing notes
2026-10-12 01:09:43 +03:00
sorcnr 1d6ffee130 feat: OpenCode V2 port of opencode-teamwork
Port the V1 opencode-teamwork plugin to the OpenCode V2 plugin API.

- plugin now default-exports { id, setup } and registers the 7 /team* commands
  via ctx.command.transform (V1 config-hook injection no longer exists)
- agents moved to markdown files under agents/team/ (V2 plugins cannot add agents)
- command templates converted from {{ }} handlebars to $ARGUMENTS
- agent permissions converted to the V2 permissions array (edit/shell/webfetch/subagent)
- no runtime dependency on @opencode/plugin

Verified against OpenCode v2.0.26.
2026-10-11 17:24:21 +03:00