vgxness 1.5.1 → 1.6.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 (56) hide show
  1. package/README.md +23 -2
  2. package/dist/agents/agent-seed-service.js +10 -0
  3. package/dist/agents/canonical-agent-manifest.js +177 -0
  4. package/dist/agents/canonical-agent-projection.js +164 -0
  5. package/dist/agents/renderers/claude-renderer.js +30 -52
  6. package/dist/cli/bun-bin.js +6 -0
  7. package/dist/cli/cli-flags.js +1 -1
  8. package/dist/cli/cli-help.js +7 -4
  9. package/dist/cli/commands/agent-skill-dispatcher.js +6 -5
  10. package/dist/cli/commands/interactive-entrypoint-dispatcher.js +2 -2
  11. package/dist/cli/commands/mcp-dispatcher.js +75 -3
  12. package/dist/cli/commands/setup-dispatcher.js +9 -0
  13. package/dist/cli/index.js +1 -1
  14. package/dist/cli/tui/main-menu/main-menu-read-model.js +41 -44
  15. package/dist/cli/tui/main-menu/main-menu-render-shape.js +15 -15
  16. package/dist/cli/tui/opentui/main-menu/screen.js +39 -41
  17. package/dist/cli/tui/opentui/main-menu/smoke.js +1 -1
  18. package/dist/cli/tui/opentui/main-menu/view.js +1 -1
  19. package/dist/cli/tui/setup/setup-tui-read-model.js +15 -12
  20. package/dist/governance/governance-report-builder.js +45 -26
  21. package/dist/mcp/claude-code-agent-config.js +95 -0
  22. package/dist/mcp/claude-code-cli.js +71 -0
  23. package/dist/mcp/claude-code-config.js +84 -0
  24. package/dist/mcp/claude-code-project-memory.js +127 -0
  25. package/dist/mcp/claude-code-scope.js +18 -0
  26. package/dist/mcp/client-install-claude-code-contract.js +114 -0
  27. package/dist/mcp/client-install-claude-code.js +136 -0
  28. package/dist/mcp/index.js +8 -0
  29. package/dist/mcp/opencode-default-agent-config.js +7 -113
  30. package/dist/mcp/provider-canonical-agent-manifest.js +39 -0
  31. package/dist/mcp/provider-change-plan.js +109 -1
  32. package/dist/mcp/provider-doctor.js +105 -1
  33. package/dist/mcp/provider-health-types.js +4 -0
  34. package/dist/mcp/provider-status.js +159 -3
  35. package/dist/mcp/schema.js +6 -5
  36. package/dist/mcp/validation.js +1 -1
  37. package/dist/memory/memory-service.js +4 -0
  38. package/dist/sdd/sdd-workflow-service.js +129 -59
  39. package/dist/setup/providers/claude-setup-adapter.js +13 -8
  40. package/dist/setup/setup-plan.js +60 -1
  41. package/docs/architecture.md +55 -113
  42. package/docs/cli.md +90 -2
  43. package/docs/code-runtime.md +218 -0
  44. package/docs/contributing.md +120 -0
  45. package/docs/glossary.md +211 -0
  46. package/docs/mcp.md +144 -0
  47. package/docs/prd.md +23 -26
  48. package/docs/providers.md +150 -0
  49. package/docs/roadmap.md +88 -0
  50. package/docs/safety.md +147 -0
  51. package/docs/storage.md +93 -0
  52. package/package.json +1 -1
  53. package/docs/funcionamiento-del-sistema.md +0 -865
  54. package/docs/harness-gap-analysis.md +0 -243
  55. package/docs/vgxcode.md +0 -87
  56. package/docs/vgxness-code.md +0 -48
package/docs/cli.md CHANGED
@@ -232,7 +232,7 @@ bun run cli:bun -- sdd status --project vgxness --change my-change
232
232
  Provider support shown in the Installation surface is:
233
233
 
234
234
  - **OpenCode** — supported primary provider with preview/status/doctor and read-only install planning.
235
- - **Claude** — preview-only guidance; no install/apply action is exposed.
235
+ - **Claude** — supported secondary provider for Claude CLI MCP registration, project `.mcp.json` compatibility, project-root `CLAUDE.md` managed memory, and project/user agent planning. Scopes are `local|project|user`; `personal`/`global` map to `user`. Explicit guarded apply is outside the guided OpenCode flow and requires `mcp install claude --scope <scope> --yes --run-id <id>`. Read-only status/doctor/change-plan do not read private Claude config or execute Claude Code.
236
236
  - **Antigravity** — placeholder/coming-soon guidance only.
237
237
  - **Custom/future** — extension point with safe manual/default unsupported behavior.
238
238
 
@@ -254,6 +254,45 @@ The command prints a deterministic JSON envelope with `flow`, `confidence`, `rea
254
254
 
255
255
  Safety boundary: this is a preview only. It does **not** call providers, edit files, write provider config, create runs, run installers, install global memory, or create `openspec/`. Preview actions are labels/manual commands for review, not executed steps.
256
256
 
257
+ ## Code runtime CLI (`vgxness code`)
258
+
259
+ `vgxness code` is the native workspace runtime for bounded agentic work. It is not a wrapper around OpenCode or any provider; provider adapters translate VGXNESS-native requests only. See [Code runtime](./code-runtime.md) for the full contract; this section lists the CLI surface.
260
+
261
+ Modes (read-only by default unless `--approval-channel` and `--approval-policy` are passed):
262
+
263
+ | Mode | Purpose | Mutations |
264
+ |---|---|---|
265
+ | `inspect` | Read-only investigation of the workspace. | None. |
266
+ | `plan` | Read-only implementation planning. | None. |
267
+ | `craft-preview` | Show the diff that would be applied. | None. |
268
+ | `craft` | Approval-gated, bounded edit-capable work. | Edits, shell, network, git, SDD persistence all routed through explicit policy decisions. |
269
+
270
+ Common flags across modes:
271
+
272
+ ```bash
273
+ vgxness code inspect "<question>" \
274
+ --provider openai-compatible \ # or "fake" for offline testing
275
+ --model <model-id> \
276
+ --stream \ # emit JSONL runtime events as they happen
277
+ --json \ # final response as JSON
278
+ --max-source-bytes <bytes> \ # bound on sources loaded into prompt
279
+ --approval-policy ask|allow|deny \
280
+ --approval-channel stdio|auto \
281
+ --verification none|suggest|run|repair \
282
+ --transcript off|summary|full \
283
+ --memory off|ask|auto
284
+ ```
285
+
286
+ SDD-aware mode is exposed through `vgxness code sdd <change> <phase>`; pass `--save-artifact` only when persistence is intended, and pass `--change-id`/`--phase` to scope work. Read-only phases stay artifact-oriented; `apply-progress` may expose edit and shell tools; `verify` may expose verification shell tools.
287
+
288
+ Useful events-only output for piping into the OpenTUI shell or your own tooling:
289
+
290
+ ```bash
291
+ vgxness code inspect "Summarize the current architecture" --events-jsonl
292
+ ```
293
+
294
+ Safety boundary: `inspect`, `plan`, and `craft-preview` never mutate. `craft` may only mutate through the permission-aware executors and the explicit approval channel; it never writes outside the workspace, never pushes to remote, and never edits `openspec/`. Secret-like values are redacted from prompts, transcripts, checkpoints, and memory saves. See [Safety model](./safety.md).
295
+
257
296
  ## Workflow CLI
258
297
 
259
298
  Use workflow commands when you want an explicit operator-controlled path from intent classification to a recorded run and, optionally, a guarded execution request. Supported workflows are `explore`, `quickfix`, `plan`, `build`, `debug`, and `sdd`:
@@ -406,7 +445,7 @@ bun run cli:bun -- mcp setup --preview --provider claude --db <path>
406
445
  bun run cli:bun -- mcp doctor --db <path> --project vgxness --change manual-smoke
407
446
  ```
408
447
 
409
- The setup preview JSON includes `installable:false`, `readOnly:true`, `writesProviderConfig:false`, plus a copyable MCP server command. Without `--db`, preview snippets omit `--db` and rely on the global default database; with `--db <path>` or `VGXNESS_DB_PATH`, snippets keep the explicit database argument. If needed, copy the `server.command` and `server.args` from the preview into your client manually; the preview itself never writes that config. For OpenCode config automation, inspect `mcp install opencode --plan` before applying with `--yes`; the default target is `$HOME/.config/opencode/opencode.json`.
448
+ The setup preview JSON includes `installable:false`, `readOnly:true`, `writesProviderConfig:false`, plus a copyable MCP server command. Without `--db`, preview snippets omit `--db` and rely on the global default database; with `--db <path>` or `VGXNESS_DB_PATH`, snippets keep the explicit database argument. If needed, copy the `server.command` and `server.args` from the preview into your client manually; the preview itself never writes that config. For OpenCode config automation, inspect `mcp install opencode --plan` before applying with `--yes`; the default target is `$HOME/.config/opencode/opencode.json`. For Claude config, inspect `mcp install claude --plan --scope local|project|user`; confirmed writes or CLI execution require `mcp install claude --scope <scope> --yes --run-id <id>` so VGXNESS run preflight can authorize each target.
410
449
 
411
450
  The top-level `vgxness doctor` command prints human-readable readiness checks by default and accepts `--json` for scriptable output. Lower-level `mcp doctor` remains useful for MCP-specific checks and manual diagnostics; use `--json` where parseable output is needed. `ready:true` means required checks passed. `ready:false` means at least one required check failed; read the failed check `id`, `detail`, and optional `remediation` to fix the local setup, then run doctor again.
412
451
 
@@ -467,6 +506,41 @@ Manual OpenCode verification checklist:
467
506
  5. In OpenCode, confirm the `vgxness` MCP tools are available.
468
507
  6. Call `vgxness_sdd_status` against a known project/change, then run doctor again if anything fails.
469
508
 
509
+ ## Claude Code MCP install
510
+
511
+ Claude Code is supported as a secondary, non-default provider for VGXNESS MCP/subagent configuration. Planning/status/doctor/change-plan are read-only and do not require Claude Code, network, or credentials. Scopes are `local`, `project`, and `user`; compatibility aliases `personal` and legacy `global` map to Claude `user` with warnings. MCP registration is represented as Claude CLI argv (`claude mcp add --scope <scope> vgxness -- vgxness mcp start`), never shell strings or manual `~/.claude.json` mutation.
512
+
513
+ ```bash
514
+ bun run cli:bun -- mcp install claude --plan --scope project --db <path>
515
+ bun run cli:bun -- mcp install claude --plan --scope user --db <path>
516
+ bun run cli:bun -- mcp install claude --yes --scope project --run-id <id> --db <path>
517
+ ```
518
+
519
+ Allowed project-scope writes after explicit confirmation and run preflight:
520
+
521
+ - `.mcp.json`
522
+ - `.claude/agents/*.md`
523
+ - project-root `CLAUDE.md`, only the VGXNESS managed block; user-authored content outside the block is preserved and existing files are backed up before append/update
524
+
525
+ User agent files target `~/.claude/agents/*.md` only when a future apply path explicitly preflights that external directory. Read-only plans/status/doctor/change-plan never write it.
526
+
527
+ Forbidden writes:
528
+
529
+ - `~/.claude.json`
530
+ - `.claude/CLAUDE.md`
531
+
532
+ Malformed or conflicting VGXNESS markers in project-root `CLAUDE.md` refuse the full Claude project install before any Claude target is mutated.
533
+
534
+ Manual/opt-in runtime validation checklist (not normal CI):
535
+
536
+ 1. Apply Claude project-local config through the guarded VGXNESS flow.
537
+ 2. Open Claude Code in the project manually.
538
+ 3. Approve the project MCP server if prompted.
539
+ 4. Run `/mcp` and verify `vgxness` is connected.
540
+ 5. Run `/agents` and verify expected project subagents are visible.
541
+ 6. Ask Claude to call a safe read-only VGXNESS MCP tool.
542
+ 7. Confirm forbidden files were not written by VGXNESS.
543
+
470
544
  ## SDD workflow examples
471
545
 
472
546
  Use `sdd` commands to inspect local SDD artifact state and save, read, or list phase artifacts. These commands read and write only the selected `vgxness` local SQLite memory store: `--db <path>` when passed, `VGXNESS_DB_PATH` when set, or the global default database when neither override is present.
@@ -872,3 +946,17 @@ Existing project-local stores remain compatible; opt in explicitly when needed:
872
946
  ```bash
873
947
  bun run cli:bun -- memory search --project vgxness --db .vgx/memory.sqlite
874
948
  ```
949
+
950
+ For more on schema, scopes, and lifecycle, see [Storage](./storage.md).
951
+
952
+ ## See also
953
+
954
+ - [Architecture](./architecture.md) — current-state architecture and core domain model.
955
+ - [Code runtime](./code-runtime.md) — `vgxness code` modes, tools, providers, and approval flow.
956
+ - [MCP tools](./mcp.md) — full reference for the 38 MCP tools exposed to agents.
957
+ - [Safety model](./safety.md) — permission categories, approval flow, redactors, and runtime gates.
958
+ - [Storage](./storage.md) — SQLite schema, scopes, and lifecycle.
959
+ - [Providers](./providers.md) — adapter contract and how to add a new provider.
960
+ - [Roadmap](./roadmap.md) — planned work not yet shipped.
961
+ - [Contributing](./contributing.md) — repository layout, verification, and style.
962
+ - [Glossary](./glossary.md) — terminology used across the docs and the codebase.
@@ -0,0 +1,218 @@
1
+ # VGXNESS Code runtime (`vgxness code`)
2
+
3
+ `vgxness code` is the native VGXNESS coding CLI/runtime. It is not a wrapper around OpenCode, a fork, a compatibility layer, a config format, a prompt copy, or a branded re-skin. Provider adapters translate VGXNESS-native requests only.
4
+
5
+ `vgxcode` is the experimental OpenTUI shell that renders `vgxness code` runtime events. It is currently root-owned during development; promoted surfaces will move to the standard `vgxness`/`vgx` bins.
6
+
7
+ ## Commands
8
+
9
+ ```bash
10
+ vgxness code inspect "<question>" # read-only repository investigation
11
+ vgxness code plan "<task>" # read-only implementation planning
12
+ vgxness code craft-preview "<task>" # show the diff you would make
13
+ vgxness code craft "<task>" # bounded edit-capable work with approval gates
14
+ vgxness code sdd <change> <phase> # SDD-backed phase work
15
+ ```
16
+
17
+ Common flags across modes:
18
+
19
+ | Flag | Effect |
20
+ |---|---|
21
+ | `--provider <id>` | `openai-compatible` (default in real use) or `fake` (deterministic for tests). |
22
+ | `--model <id>` | Provider model id. |
23
+ | `--stream` | Emit JSONL runtime events as they happen. |
24
+ | `--json` | Final response as JSON. |
25
+ | `--max-source-bytes <bytes>` | Bound on sources loaded into the prompt. |
26
+ | `--approval-policy ask\|allow\|deny` | Default `ask`. |
27
+ | `--approval-channel stdio\|auto` | `stdio` reads decisions from stdin; `auto` uses the configured broker. |
28
+ | `--verification none\|suggest\|run\|repair` | Verification posture. Default `suggest`. |
29
+ | `--transcript off\|summary\|full` | Final summary contents. Default `summary`. |
30
+ | `--memory off\|ask\|auto` | Memory save posture. Default `off`. |
31
+ | `--events-jsonl` | Output only the JSONL event stream (used for piping into the OpenTUI shell). |
32
+
33
+ `vgxness code sdd <change> <phase>` accepts:
34
+
35
+ | Flag | Effect |
36
+ |---|---|
37
+ | `--save-artifact` | Persist the phase artifact when explicit persistence is intended. |
38
+ | `--change-id <id>` | Override change id. |
39
+ | `--approval-policy`, `--approval-channel`, `--memory` | Same as the other modes. |
40
+
41
+ ## Modes
42
+
43
+ ### `inspect`
44
+
45
+ Read-only repository investigation. The runtime exposes only the `read` tool group: `list_files`, `read_file`, `search_content`, `inspect_project`, `git_status`, `git_diff`, `git_log`. No mutations, no shell, no network, no git writes.
46
+
47
+ ### `plan`
48
+
49
+ Read-only implementation planning. Same read tool group as `inspect`. The runtime can summarize architecture, propose safe approaches, and produce implementation outlines without touching the workspace.
50
+
51
+ ### `craft-preview`
52
+
53
+ Show the diff the runtime would apply. The runtime may call read tools and run planning-style reasoning, but does not write. Output is a unified diff that the user can review before approving the actual mutation.
54
+
55
+ ### `craft`
56
+
57
+ Approval-gated, bounded edit-capable work. Adds the workspace mutation group (`apply_patch`, `create_file`, `update_file`, `delete_file`), the shell/verification group (`run_shell_command`, `run_verification_command`, `network_request`, `git_mutation`), and SDD persistence tools if `--save-artifact` is set. Each mutation routes through `evaluatePermission(...)`; the `ApprovalBroker` either auto-resolves per `--approval-policy` or surfaces a prompt through the configured `approval-channel`.
58
+
59
+ ## Tool groups (19 tools)
60
+
61
+ The runtime's tool set is defined in `src/code/tools/tool-definitions.ts` and is composed per mode.
62
+
63
+ ### Read-only (7)
64
+
65
+ | Tool | Category | Notes |
66
+ |---|---|---|
67
+ | `list_files` | `read` | Repository files within the workspace. |
68
+ | `read_file` | `read` | Bounded text read. |
69
+ | `search_content` | `read` | Text content search. |
70
+ | `inspect_project` | `read` | Project metadata: package scripts, config files. |
71
+ | `git_status` | `git` | Inspection only. |
72
+ | `git_diff` | `git` | Inspection only. |
73
+ | `git_log` | `git` | Inspection only. |
74
+
75
+ ### Workspace mutations (4, all confirm-gated)
76
+
77
+ | Tool | Tier | Notes |
78
+ |---|---|---|
79
+ | `apply_patch` | `confirm`, audit | Bounded unified patch inside the workspace. |
80
+ | `create_file` | `confirm`, audit | New file inside the workspace. |
81
+ | `update_file` | `confirm`, audit | Existing file update. |
82
+ | `delete_file` | `restricted`, audit | Destructive; tighter gate. |
83
+
84
+ ### Shell, verification, network, git mutation (4, confirm-gated)
85
+
86
+ | Tool | Category | Notes |
87
+ |---|---|---|
88
+ | `run_shell_command` | `shell` | Non-destructive commands; permission-gated. |
89
+ | `run_verification_command` | `shell` | Routed through the permission-aware shell executor. |
90
+ | `network_request` | `network` | Bounded; explicit approval required. |
91
+ | `git_mutation` | `git` | Denied by default unless policy explicitly allows it. |
92
+
93
+ ### SDD reads (5)
94
+
95
+ | Tool | Notes |
96
+ |---|---|
97
+ | `sdd_status` | Read SDD change status for the active change. |
98
+ | `sdd_get_readiness` | Read readiness for the active phase; does not mutate artifacts. |
99
+ | `sdd_read_artifact` | Read one artifact for the active change. |
100
+ | `sdd_next_phase` | Recommended next phase. |
101
+ | `governance_report` | Redacted SDD governance report snapshot. |
102
+
103
+ ### SDD persistence (3, confirm-gated)
104
+
105
+ | Tool | Notes |
106
+ |---|---|
107
+ | `sdd_save_artifact` | Saves only when explicit persistence was requested. |
108
+ | `sdd_mark_ready` | Marks the phase ready; only when explicit persistence was requested. |
109
+ | `sdd_accept_artifact` | Records human-only acceptance; agents must not auto-accept. |
110
+
111
+ The SDD tool set is composed per phase: `apply-progress` exposes edit + shell + verification + persistence; `verify` exposes verification shell tools; other phases stay read/artifact oriented.
112
+
113
+ ## Providers
114
+
115
+ The runtime is provider-neutral. Adapters implement `CodeProviderAdapter` (`src/code/providers/provider-adapter.ts`):
116
+
117
+ | Adapter | Status | Notes |
118
+ |---|---|---|
119
+ | `openai-compatible` | Real | Speaks to any OpenAI-compatible endpoint; credentials come from environment references, never embedded. |
120
+ | `fake` | Tests | Deterministic, offline; for unit tests and CI. |
121
+
122
+ There is no native Anthropic provider in the runtime as of v1.5.1. OpenCode exposes an OpenAI-compatible bridge for Claude models; users who want Claude through `vgxness code` go through that bridge. Adding a native Anthropic provider is tracked in [Roadmap](./roadmap.md).
123
+
124
+ ## Approval flow
125
+
126
+ `PolicyApprovalBroker`, `StdioApprovalBroker`, and `ConservativePermissionGateway` (in `src/code/runtime/approval-coordinator.ts`) wire approval decisions to the runtime event stream.
127
+
128
+ ```text
129
+ tool call requested
130
+
131
+
132
+ PolicyApprovalBroker ──► ConservativePermissionGateway.evaluate(...)
133
+ │ │
134
+ │ ├── allow → execute, record event
135
+ │ ├── ask → ApprovalPrompt
136
+ │ │ ├── stdio channel: read line from stdin
137
+ │ │ └── auto channel: call injected broker
138
+ │ └── deny → record blocked event, return error
139
+
140
+ CodeRuntimeEventSink (stream JSONL to consumer)
141
+ ```
142
+
143
+ The `vgxcode` OpenTUI shell is one consumer of the event sink. When `craft` requests approval, the shell renders the prompt and writes the human decision back through the live process.
144
+
145
+ ## Configuration and reporting
146
+
147
+ Safe defaults are local and conservative:
148
+
149
+ - Provider: `fake` for offline/CI smoke; `openai-compatible` for real use.
150
+ - Posture: read-only by default unless the mode is `craft` or `craft-preview` was previewed.
151
+ - Approval policy: `ask`.
152
+ - Verification: `suggest`.
153
+ - Transcript: `summary` (checkpoint labels/timestamps only).
154
+ - Memory: `off` (never auto-save learnings).
155
+ - Bounded prompt/context size; no repair loop unless explicitly enabled.
156
+
157
+ Transcript modes:
158
+
159
+ - `off` — no transcript in the final summary.
160
+ - `summary` — checkpoint labels/timestamps only.
161
+ - `full` — sanitized checkpoints and tool summaries; command stdout/stderr are omitted by default.
162
+
163
+ Memory modes:
164
+
165
+ - `off` — never save learnings.
166
+ - `ask` — prepare a sanitized memory-save checkpoint but do not persist.
167
+ - `auto` — save sanitized learnings only through a configured memory gateway.
168
+
169
+ Prompts, reports, checkpoints, transcripts, and memory saves redact secret-like values through `omitSensitiveCommandOutput`, `redactJson`, and `redactSecrets` (`src/code/reporting/redaction.ts`).
170
+
171
+ ## SDD mode
172
+
173
+ `vgxness code sdd <change> <phase>` loads existing artifacts for the requested change/phase and exposes phase-appropriate tools. Non-implementation phases stay read/artifact oriented. `apply-progress` may expose edit and shell tools. `verify` may expose verification shell tools. Artifact saves require explicit `--save-artifact` (or the equivalent runtime flag); passing it is the only way persistence is triggered.
174
+
175
+ ## Project detection
176
+
177
+ `detectProject()` (in `src/code/runtime/project-detection.ts`) reports repository root, stack hints, config files, and verification presets such as `npm run typecheck` or `npm run test` when package scripts exist. The fake provider is deterministic for local tests.
178
+
179
+ ## OpenTUI shell (`vgxcode`)
180
+
181
+ The shell reads newline-delimited `CodeRuntimeEvent` JSON from stdin. If stdin has events or parse errors, `vgxcode` renders that stream and does not spawn the CLI. If stdin is a TTY, the OpenTUI entrypoint opens the interactive prompt and uses `inspect` by default.
182
+
183
+ ```bash
184
+ bun src/cli/tui/opentui/code/index.ts
185
+ ```
186
+
187
+ Interactive controls: `Tab` toggles between `inspect` and `plan`; prefix with `/inspect`, `/plan`, `/craft-preview`, or `/craft` to switch. Press `Enter` to submit; `Ctrl+C` to exit. The prompt input is cleared after submit and the submitted prompt remains visible as `Last submitted`. The UI shows explicit `idle`, `running`, `completed`, and `error` states.
188
+
189
+ Replay real read-only runtime events without spawning the root CLI:
190
+
191
+ ```bash
192
+ bun run cli:bun -- code inspect "What is this project?" --events-jsonl | bun src/cli/tui/opentui/code/index.ts
193
+ ```
194
+
195
+ `vgxcode` does not own mutation policy. `inspect`, `plan`, and `craft-preview` are read-only/preview paths. `/craft` is approval-capable and may mutate only through the runtime and its explicit approval channel; the OpenTUI shell only renders pending approvals and writes approve/deny decisions to the live runtime process.
196
+
197
+ ## Safety model
198
+
199
+ `vgxness code` routes edits, shell, network, git mutation, SDD persistence, and memory saves through explicit policy decisions:
200
+
201
+ - External workspace edits are denied.
202
+ - Destructive commands require approval.
203
+ - Git mutation is blocked by default unless explicitly approved.
204
+ - Network access requires approval.
205
+ - Secret-like values are redacted from prompts, reports, checkpoints, transcripts, and memory saves.
206
+ - Unrelated user work is preserved (no glob expansion outside the workspace, no `.` rewrites, no recursive deletes without explicit operator intent).
207
+
208
+ The full contract — categories, approval flow, redactors, retry policy — is in [Safety model](./safety.md).
209
+
210
+ ## Rollout checklist
211
+
212
+ For projects adopting `vgxness code`:
213
+
214
+ - **Config**: safe defaults documented; transcript/memory/provider controls exposed (`--transcript`, `--memory`, `--provider`).
215
+ - **Safety**: external edits, destructive shell, git mutation, network, secrets, and unrelated user work are covered by tests under `test/code/`.
216
+ - **Verification**: detected presets reported by `detectProject()`; verification results are honest `pass`/`fail`/`skipped` evidence.
217
+ - **Reporting**: transcripts are configurable and sanitized; sensitive command output is omitted by default.
218
+ - **Provider behavior**: core runtime remains provider-neutral and native VGXNESS Code, not a wrapper around any specific provider.
@@ -0,0 +1,120 @@
1
+ # Contributing
2
+
3
+ VGXNESS is an alpha local-first control plane. The repository follows a few rules that keep the product safe, predictable, and reviewable. This document is for humans and AI assistants who want to change the code, the docs, or both.
4
+
5
+ ## Repository layout
6
+
7
+ ```
8
+ src/
9
+ agents/ # agent + subagent registry, resolver, canonical manifest
10
+ cli/ # CLI dispatch, command modules, TUI, OpenTUI
11
+ code/ # native code runtime (vgxness code)
12
+ export/ # redaction and export helpers
13
+ governance/ # governance report builder, overlay fingerprint
14
+ harness/ # harness-side tool handlers
15
+ mcp/ # MCP server, schemas, control plane, doctor, OpenCode install
16
+ memory/ # memory service, SQLite database, migrations
17
+ orchestrator/ # natural-language planner (preview only)
18
+ payload/ # payload summary helpers
19
+ permissions/ # policy evaluator, schemas
20
+ providers/ # OpenCode provider adapter
21
+ runs/ # run lifecycle, execution planning, retry, snapshot export
22
+ sdd/ # SDD workflow service, schema, artifact portability
23
+ setup/ # setup defaults, plan, lifecycle, backup-rollback
24
+ skills/ # skill registry, resolver, payload, improvement proposals
25
+ verification/ # verification plan + report services
26
+ workflows/ # workflow registry, executor, allowlist adapter
27
+
28
+ test/ # node:test files mirroring src/ structure
29
+ seeds/ # shipped skill/agent seed assets
30
+ scripts/ # repo-level helper scripts
31
+ docs/ # human-facing documentation
32
+ ```
33
+
34
+ ## Runtime and toolchain
35
+
36
+ - Bun `>= 1.3.14` is the installed CLI/MCP runtime and the canonical CI verification path. It is also the only supported storage runtime (`bun:sqlite`).
37
+ - Node.js `>= 22` is development/build/test tooling for TypeScript, `node:test`, and selected helper scripts.
38
+ - TypeScript is ESM/NodeNext and strict, with `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes`. Prefer explicit `undefined` over loose optional properties.
39
+ - Tests use the built-in `node:test` runner with `node:assert/strict`, not Jest/Vitest.
40
+
41
+ Install dependencies with `bun install --frozen-lockfile` when reproducing CI. When `package.json` dependency specifiers change, refresh and review `bun.lock` intentionally. Use `bun run check:bun-lock` to detect drift without mutating `node_modules`.
42
+
43
+ ## Verification order
44
+
45
+ CI runs the verification chain in this order:
46
+
47
+ ```bash
48
+ bun install --frozen-lockfile
49
+ bun run check:bun-lock
50
+ bun run verify:typecheck
51
+ bun run verify:test
52
+ bun run verify:test:bun-storage
53
+ bun run verify:bun-sqlite
54
+ bun run verify:package # which is bun run package:bun:evidence
55
+ bun run package:bun:evidence -- --require-pass
56
+ ```
57
+
58
+ The full chain is wrapped in `bun run verify`. For release-readiness, the package evidence run must pass explicitly with `--require-pass`.
59
+
60
+ `bun run verify:bun-sqlite` is the SQLite runtime release gate. It copies the source migrations into a temporary directory, applies them against a temporary database, and checks foreign keys, busy timeout, FTS/search, transaction rollback, integrity, and cleanup.
61
+
62
+ ## Product boundaries
63
+
64
+ VGXNESS is a local-first CLI/MCP control plane. The same domain services should back CLI, TUI, and MCP. Avoid reimplementing workflow, setup, or storage rules in only one surface.
65
+
66
+ The configurator/setup plane (rendering/installing provider config) is separate from the runtime control plane (executing SDD phases, recording runs, gating approvals). They are wired by services, not by side effects.
67
+
68
+ ## Safety conventions
69
+
70
+ These rules are non-negotiable. The harness is loaded with capability; do not remove these guards.
71
+
72
+ - Read-only/preview commands must stay non-mutating. Setup plans, MCP setup previews, OpenCode previews, workflow previews, and status views must not write provider config or call providers.
73
+ - Provider config writes require explicit consent (`--yes` or equivalent confirmed flow) plus backup/rollback behavior.
74
+ - Do not create or write `openspec/`. SDD artifacts are stored through the local SQLite artifact service under canonical topic keys `sdd/{change}/{phase}`.
75
+ - Human acceptance is distinct from artifact presence. Do not infer acceptance from generated content or saved drafts. The runtime rejects `acceptedBy.type !== 'human'`.
76
+ - Workspace boundary denials cannot be relaxed by agent or subagent overrides. The policy evaluator uses `realpathSync` to defeat symlink escapes.
77
+ - Secrets and external directory access deny by default. Redaction helpers in `src/code/reporting/redaction.ts` and `src/export/redaction.ts` are the only place secret-shaped values should be stripped.
78
+
79
+ ## Style
80
+
81
+ - TypeScript strict, ESM/NodeNext, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`.
82
+ - Prefer explicit `undefined` over loose optional properties. Use the existing `MemoryResult<T>` / `MemoryResult<...>` style for fallible operations instead of throwing across module boundaries.
83
+ - Domain entities live in their module's `schema.ts`. Tool-facing payloads live in `src/mcp/schema.ts` (or a sibling) and are validated with `zod` before dispatch.
84
+ - Tests are colocated by module under `test/`. Use `node:test` and `node:assert/strict`. Each test file should set up its own `MemoryDatabase` (see existing files for the pattern).
85
+ - Public CLI/setup language is English unless existing docs explicitly say otherwise.
86
+
87
+ ## Doc-sync discipline
88
+
89
+ The docs are the user-facing contract. When the code drifts, the docs must catch up — not the other way around.
90
+
91
+ - When you add, rename, or remove an MCP tool, update `SUPPORTED_VGX_MCP_TOOL_NAMES` in `src/mcp/schema.ts` and the table in [MCP tools](./mcp.md). They must stay in sync.
92
+ - When you add a new CLI command, document it in [CLI reference](./cli.md).
93
+ - When you change a permission category, default, or phase mode, update [Safety model](./safety.md).
94
+ - When you add a migration, append it to the table in [Storage](./storage.md).
95
+ - When you add or change a provider, update [Providers](./providers.md) and the [Code runtime](./code-runtime.md) tool list.
96
+
97
+ ## Pull request process
98
+
99
+ VGXNESS is shipped as a proprietary package. The npm publication step is a separate, explicit, human-approved process. PRs that change published artifacts must:
100
+
101
+ 1. Run `bun run verify` locally and confirm all steps pass.
102
+ 2. Include or update tests for any behavioral change.
103
+ 3. Update docs that reference the changed surface.
104
+ 4. Not change the publication path. `npm publish`, `bun publish`, registry dry-runs, provenance upload, release creation, and dist-tag mutation are not part of normal PR flow.
105
+ 5. Not change `engines.bun` or remove the `bin`/`files` whitelist without a separate, documented decision.
106
+
107
+ PRs that touch safety gates, permission categories, default policies, the run lifecycle, or the SDD acceptance gate are reviewed by a maintainer who can answer "does this still match the safety model?" without consulting the diff. If you are unsure, open the PR as a draft and ask.
108
+
109
+ ## Commit conventions
110
+
111
+ - Conventional Commits (`feat:`, `fix:`, `chore:`, `docs:`, `refactor:`, `test:`, `build:`, `ci:`).
112
+ - No `Co-Authored-By` lines for AI assistants. Do not add AI attribution to commits.
113
+ - One logical change per commit. Squash fixups locally before pushing.
114
+
115
+ ## AI assistants in this repo
116
+
117
+ `AGENTS.md` at the repository root carries the working instructions for AI assistants. The two non-negotiables are:
118
+
119
+ - Do not write to `openspec/`.
120
+ - Do not infer SDD acceptance from generated content. The runtime will reject it, but the rejection costs a run.