archgraph-argo-beta 0.27.0-beta.14 → 0.27.0-beta.16

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 CHANGED
@@ -38,10 +38,18 @@ ArchGraph deploys the ARGO toolchain to all major coding-agent environments:
38
38
  | OpenCode | ✓ | ✓ | ✓ | ✓ | ✓ |
39
39
  | DeepSeek Harness | ✓ | ✓ | ✓ | ✓ | ✓ |
40
40
  | OpenClaw | ✓ | ✓ | ✓ | — | ✓ |
41
+ | Codex | ✓ | ✓ | ✓ | — | ✓ |
41
42
 
42
43
  A single `argo-deploy` registers the `argo` MCP server and installs all artifacts into each harness
43
44
  automatically.
44
45
 
46
+ For **Codex** (OpenAI Codex CLI / desktop), `argo-deploy` places the artifacts where Codex looks:
47
+ the rules go to `~/.codex/AGENTS.md` (Codex injects the global `AGENTS.md` into every session, so the
48
+ wakeup gate is always active), the `argo-init` and `ea-human-reconcile` skills go to
49
+ `~/.codex/skills/`, and the `argo` and `graph-mcp` MCP servers are registered in
50
+ `~/.codex/config.toml` (`[mcp_servers.*]`) — the `argo` server follows the workspace you open in
51
+ Codex.
52
+
45
53
  ## Install
46
54
 
47
55
  ```powershell
@@ -49,7 +57,7 @@ npm install -g archgraph-argo
49
57
  argo-deploy
50
58
  ```
51
59
 
52
- Done — the ARGO toolchain, skills, and rules are deployed, and the `argo` MCP server is registered automatically in **GitHub Copilot**, **Cursor**, **OpenCode**, **DeepSeek Harness** (dsh), and **OpenClaw**.
60
+ Done — the ARGO toolchain, skills, and rules are deployed, and the `argo` MCP server is registered automatically in **GitHub Copilot**, **Cursor**, **OpenCode**, **DeepSeek Harness** (dsh), **OpenClaw**, and **Codex**.
53
61
 
54
62
  ### Prerequisites and configuration
55
63
 
package/argo/.env.example CHANGED
@@ -168,3 +168,14 @@ ARGO_W31_LIVE_MUTATION_VECTOR_E2E=
168
168
  # ARGO_MCP_SEMANTIC_DEDUP_THRESHOLD=
169
169
  # Alias of ARGO_MCP_SEMANTIC_DEDUP_THRESHOLD (takes precedence when set).
170
170
  # ARGO_SEMANTIC_DEDUP_THRESHOLD=
171
+ # Cross-project WRITE guard. Default ON: a write tool may only target the
172
+ # server's own (home) workspace, so a foreign per-call workspaceRoot is
173
+ # rejected fail-closed while cross-project READS stay open. "0" disables it
174
+ # (all-or-nothing) for a trusted multi-workspace host that legitimately writes
175
+ # several workspaces through one server.
176
+ # ARGO_WORKSPACE_WRITE_GUARD=
177
+ # Set to "1" by a trusted host broker (e.g. the DSH workspace bridge) to assert
178
+ # it controls the per-call `sessionWorkspaceRoot` field; the argo server then
179
+ # allows WRITES to that host-designated session workspace as well as its home
180
+ # workspace. A model cannot set a process env var, so the trust is unforgeable.
181
+ # ARGO_WORKSPACE_ROOT_TRUSTED=
@@ -19,6 +19,11 @@ const {
19
19
  externalQueryRequested,
20
20
  queryExternalRead,
21
21
  } = require('./external-graph-query.js');
22
+ const {
23
+ authorizeWorkspaceWrite,
24
+ isWriteTool,
25
+ stripTrustedSessionField,
26
+ } = require('./workspace-write-guard.js');
22
27
  const {
23
28
  getWorkspaceRoot,
24
29
  hasStaticWorkspace,
@@ -411,6 +416,33 @@ function resolveWorkspaceRoot(args) {
411
416
  }
412
417
 
413
418
  async function callTool(name, args = {}, progressToken = null, dependencies = undefined) {
419
+ // Cross-project WRITE guard (single choke point for every tool): a write tool
420
+ // may only target this server's HOME workspace, or a host-designated trusted
421
+ // session workspace when the process was launched by a trusted broker
422
+ // (ARGO_WORKSPACE_ROOT_TRUSTED=1). A foreign `workspaceRoot` is rejected
423
+ // fail-closed before any side effect; READ tools stay ungated so cross-project
424
+ // reading still works. See workspace-write-guard.js.
425
+ if (isWriteTool(name, args)) {
426
+ const decision = authorizeWorkspaceWrite({ tool: name, args, homeRoot: getWorkspaceRoot() });
427
+ if (!decision.allowed) {
428
+ return toolResult({
429
+ status: 'failed',
430
+ error: {
431
+ category: decision.category,
432
+ message: decision.message,
433
+ tool: decision.tool,
434
+ homeWorkspaceRoot: decision.homeWorkspaceRoot,
435
+ requestedWorkspaceRoot: decision.requestedWorkspaceRoot,
436
+ ...(decision.trustedSessionWorkspaceRoot
437
+ ? { trustedSessionWorkspaceRoot: decision.trustedSessionWorkspaceRoot }
438
+ : {}),
439
+ },
440
+ });
441
+ }
442
+ }
443
+ // The broker-only field is not part of any tool's schema: honor it above, then
444
+ // drop it before dispatch so schema validation never sees it.
445
+ args = stripTrustedSessionField(args);
414
446
  loadRepositoryArgoEnvironment(resolveWorkspaceRoot(args));
415
447
  try {
416
448
  const crash = require('./graph-rag/mcpCrashDiagnostics.js');
@@ -99,6 +99,8 @@ const HOST_ONLY_ENV_KEYS = Object.freeze([
99
99
  'ARGO_MCP_SEMANTIC_DEDUP',
100
100
  'ARGO_MCP_SEMANTIC_DEDUP_THRESHOLD',
101
101
  'ARGO_SEMANTIC_DEDUP_THRESHOLD',
102
+ 'ARGO_WORKSPACE_WRITE_GUARD',
103
+ 'ARGO_WORKSPACE_ROOT_TRUSTED',
102
104
  'ARGO_COST_PROFILER',
103
105
  'ARGO_COST_TRACE_MAX_BYTES',
104
106
  'ARGO_CONTEXT_MAX_BYTES',
@@ -0,0 +1,144 @@
1
+ 'use strict';
2
+
3
+ // Cross-project workspace WRITE guard.
4
+ //
5
+ // The per-call `workspaceRoot` override is a wanted capability: it lets a caller
6
+ // READ another local project's intent graph. It must NOT let the caller WRITE an
7
+ // arbitrary other project's graph. This guard bounds writes to the server's HOME
8
+ // workspace PLUS a host-designated session workspace that only a trusted broker
9
+ // may name.
10
+ //
11
+ // Two channels, deliberately distinct:
12
+ // - `workspaceRoot` : the generic per-call override. A model may set it.
13
+ // Reads honor it; a WRITE to a foreign path is denied.
14
+ // - `sessionWorkspaceRoot`: the host broker's (e.g. the DSH workspace bridge)
15
+ // designation of the current session's workspace. It
16
+ // is trusted for writes ONLY when the process was
17
+ // launched with ARGO_WORKSPACE_ROOT_TRUSTED=1 (set by
18
+ // the broker at spawn, which the model cannot forge).
19
+ // A model-supplied sessionWorkspaceRoot on a plain
20
+ // (unflagged) server is ignored.
21
+ //
22
+ // So: cross-project reading keeps working everywhere; cross-project WRITING is
23
+ // blocked unless the trusted host broker explicitly designates that workspace.
24
+ // The whole guard is OFF (all-or-nothing) with ARGO_WORKSPACE_WRITE_GUARD=0.
25
+
26
+ const path = require('node:path');
27
+
28
+ // Host-designated trusted session workspace (broker channel, not advertised to
29
+ // the model).
30
+ const TRUSTED_SESSION_FIELD = 'sessionWorkspaceRoot';
31
+ // Spawn-time flag the broker sets to assert it controls TRUSTED_SESSION_FIELD.
32
+ const TRUSTED_ENV = 'ARGO_WORKSPACE_ROOT_TRUSTED';
33
+
34
+ // Tools whose invocation mutates the target workspace. `preview*` and the read
35
+ // tools are intentionally absent.
36
+ const WRITE_TOOLS = Object.freeze(new Set([
37
+ 'initializeWorkspace',
38
+ 'runArchitectureTests',
39
+ 'applySystemArchitectureMutation',
40
+ 'addArchitectureElement',
41
+ 'updateArchitectureElement',
42
+ 'removeArchitectureElement',
43
+ 'addArchitectureRelationship',
44
+ 'updateArchitectureRelationship',
45
+ 'removeArchitectureRelationship',
46
+ 'addArchitectureView',
47
+ 'updateArchitectureView',
48
+ 'removeArchitectureView',
49
+ ]));
50
+
51
+ function guardDisabled(env = process.env) {
52
+ const value = env && env.ARGO_WORKSPACE_WRITE_GUARD;
53
+ return value !== undefined && String(value).trim() === '0';
54
+ }
55
+
56
+ // A focused mutation with dryRun:true validates only and never writes, so it is
57
+ // not a write for this guard. initializeWorkspace has no dry-run.
58
+ function isWriteTool(name, args = {}) {
59
+ if (!WRITE_TOOLS.has(name)) {
60
+ return false;
61
+ }
62
+ if (name !== 'initializeWorkspace' && args && args.dryRun === true) {
63
+ return false;
64
+ }
65
+ return true;
66
+ }
67
+
68
+ function sameWorkspace(a, b) {
69
+ const na = path.resolve(String(a));
70
+ const nb = path.resolve(String(b));
71
+ return process.platform === 'win32' ? na.toLowerCase() === nb.toLowerCase() : na === nb;
72
+ }
73
+
74
+ // The host-broker-designated session workspace, honored only behind the
75
+ // spawn-time trust flag. Returns an absolute path or null.
76
+ function trustedSessionWorkspace(args, env = process.env) {
77
+ if (!env || String(env[TRUSTED_ENV]).trim() !== '1') {
78
+ return null;
79
+ }
80
+ const raw = args && typeof args[TRUSTED_SESSION_FIELD] === 'string'
81
+ ? args[TRUSTED_SESSION_FIELD].trim()
82
+ : '';
83
+ return raw !== '' ? path.resolve(raw) : null;
84
+ }
85
+
86
+ /**
87
+ * Authorize one write against the home workspace and the trusted session workspace.
88
+ *
89
+ * @param {object} options
90
+ * @param {string} options.tool
91
+ * @param {object} [options.args]
92
+ * @param {string} options.homeRoot - the server's own workspace root.
93
+ * @param {object} [options.env] - injectable environment (tests).
94
+ * @returns {{allowed:boolean, category?:string, message?:string, tool:string, homeWorkspaceRoot:string, requestedWorkspaceRoot:string, trustedSessionWorkspaceRoot:(string|null)}}
95
+ */
96
+ function authorizeWorkspaceWrite({ tool, args = {}, homeRoot, env = process.env }) {
97
+ const requestedRaw = args && typeof args.workspaceRoot === 'string' ? args.workspaceRoot.trim() : '';
98
+ const requested = requestedRaw !== '' ? path.resolve(requestedRaw) : path.resolve(homeRoot);
99
+ const trusted = trustedSessionWorkspace(args, env);
100
+ const base = {
101
+ tool,
102
+ homeWorkspaceRoot: path.resolve(homeRoot),
103
+ requestedWorkspaceRoot: requested,
104
+ trustedSessionWorkspaceRoot: trusted,
105
+ };
106
+ if (guardDisabled(env) || sameWorkspace(requested, homeRoot)) {
107
+ return { ...base, allowed: true };
108
+ }
109
+ if (trusted && sameWorkspace(requested, trusted)) {
110
+ return { ...base, allowed: true };
111
+ }
112
+ return {
113
+ ...base,
114
+ allowed: false,
115
+ category: 'WORKSPACE_WRITE_DENIED',
116
+ message:
117
+ `Write tool '${tool}' targets workspace '${requested}' but this server is only allowed to write its home workspace ` +
118
+ `'${base.homeWorkspaceRoot}' (plus a trusted host-designated session workspace). Cross-project access is read-only: ` +
119
+ 'pass workspaceRoot only to read tools (getSystemArchitecture, getIntentElementContext, getArchitectureViewContext, ' +
120
+ 'queryNeo4jGraph, memory_search).',
121
+ };
122
+ }
123
+
124
+ // Remove the broker-only field so it never reaches tool schema validation.
125
+ function stripTrustedSessionField(args) {
126
+ if (!args || !Object.prototype.hasOwnProperty.call(args, TRUSTED_SESSION_FIELD)) {
127
+ return args;
128
+ }
129
+ const next = { ...args };
130
+ delete next[TRUSTED_SESSION_FIELD];
131
+ return next;
132
+ }
133
+
134
+ module.exports = {
135
+ WRITE_TOOLS,
136
+ TRUSTED_SESSION_FIELD,
137
+ TRUSTED_ENV,
138
+ guardDisabled,
139
+ isWriteTool,
140
+ sameWorkspace,
141
+ trustedSessionWorkspace,
142
+ authorizeWorkspaceWrite,
143
+ stripTrustedSessionField,
144
+ };
@@ -50,6 +50,14 @@ function normalizeServerSpecs(config) {
50
50
  if (spec.injectWorkspaceRoot && topWorkspaces.length > 0) {
51
51
  env.ARGO_WORKSPACE_ROOTS = topWorkspaces.join(';')
52
52
  }
53
+ // Assert the broker-controlled workspace channel: the argo server will only
54
+ // trust the per-call sessionWorkspaceRoot (which this bridge sets from the
55
+ // durable SessionHeader.cwd, overwriting any model value) when this flag is
56
+ // present. The model cannot set a server process env var, so the trust is
57
+ // unforgeable.
58
+ if (spec.injectWorkspaceRoot) {
59
+ env.ARGO_WORKSPACE_ROOT_TRUSTED = '1'
60
+ }
53
61
  return { ...spec, env, cwd: spec.cwd ?? (spec.injectWorkspaceRoot ? config.cwd : undefined) }
54
62
  }
55
63
 
@@ -173,6 +181,13 @@ async function mountServer(ctx, spec, registered) {
173
181
  : undefined
174
182
  if (typeof sessionCwd === 'string' && sessionCwd !== '') {
175
183
  injected.workspaceRoot = sessionCwd
184
+ // Broker-only trusted channel: the server allows WRITES to this
185
+ // workspace (see workspace-write-guard.js). Set AFTER the spread so
186
+ // a model-supplied value can never win.
187
+ injected.sessionWorkspaceRoot = sessionCwd
188
+ } else {
189
+ // No session workspace: never forward a model-supplied trusted field.
190
+ delete injected.sessionWorkspaceRoot
176
191
  }
177
192
  }
178
193
  if (exec && exec.signal && exec.signal.aborted) {
package/install-argo.ps1 CHANGED
@@ -28,6 +28,9 @@ param(
28
28
  [string]$DoubaoHome = "$env:USERPROFILE\Doubao",
29
29
  [string]$DoubaoWorkspace = "$env:LOCALAPPDATA\Doubao\User Data\Default\.doubao\agent_mode\workspace",
30
30
  [switch]$SkipDoubao,
31
+ [string]$CodexHome = "$env:USERPROFILE\.codex",
32
+ [string]$CodexRepoRoot = '',
33
+ [switch]$SkipCodex,
31
34
  [string]$McpPath,
32
35
  [string]$GraphMcpUrl = 'https://argo.derekworkspacev5.com/mcp'
33
36
  )
@@ -596,6 +599,71 @@ function Write-OpenClawMcpConfig {
596
599
  [System.IO.File]::WriteAllText($configPath, $json, (New-Object System.Text.UTF8Encoding $false))
597
600
  }
598
601
 
602
+ function ConvertTo-TomlString {
603
+ # Encode a value as a TOML basic string (escape backslash + double quote).
604
+ param([string]$Value)
605
+ return '"' + ($Value -replace '\\', '\\\\' -replace '"', '\"') + '"'
606
+ }
607
+
608
+ function Write-CodexMcpConfig {
609
+ # Register the argo and graph-mcp MCP servers in the Codex config file
610
+ # (~/.codex/config.toml). Codex stores MCP servers as standard TOML tables
611
+ # [mcp_servers.<name>] (NOT the JSON/YAML shapes the other hosts use), so
612
+ # this is a text-level table upsert:
613
+ # - the previous managed tables ([mcp_servers.argo], [mcp_servers.argo.env],
614
+ # [mcp_servers.graph-mcp]) are removed first, so a re-deploy replaces
615
+ # rather than duplicates them (duplicate TOML tables are a parse error);
616
+ # - every unrelated config.toml key (the desktop app's own settings, other
617
+ # MCP servers, plugins, marketplaces) is preserved verbatim;
618
+ # - the file is written without a BOM.
619
+ #
620
+ # Workspace: Codex spawns every stdio MCP server with the SESSION workspace
621
+ # as its process cwd and without ARGO_* env (verified), and argo-paths.js
622
+ # falls back to process.cwd() when ARGO_REPO_ROOT is unset. So, like
623
+ # OpenCode / DeepSeek Harness, the single global argo server FOLLOWS whichever
624
+ # workspace the user opened in Codex and ARGO_REPO_ROOT is NOT pinned by
625
+ # default. Pass -RepoRoot to pin a fixed workspace instead (opt-in).
626
+ param(
627
+ [string]$ConfigPath,
628
+ [string]$ArgoServer,
629
+ [string]$GraphMcpUrl,
630
+ [string]$RepoRoot
631
+ )
632
+ $targetHeaders = @('[mcp_servers.argo]', '[mcp_servers.argo.env]', '[mcp_servers.graph-mcp]')
633
+ $existing = if (Test-Path $ConfigPath) { [System.IO.File]::ReadAllText($ConfigPath) } else { '' }
634
+ $lines = if ($existing -eq '') { @() } else { $existing -split "\r?\n" }
635
+
636
+ $kept = New-Object System.Collections.Generic.List[string]
637
+ $i = 0
638
+ while ($i -lt $lines.Count) {
639
+ $trim = $lines[$i].Trim()
640
+ if ($targetHeaders -contains $trim) {
641
+ # Skip the header and its body up to the next top-level table header.
642
+ $i++
643
+ while ($i -lt $lines.Count -and -not $lines[$i].TrimStart().StartsWith('[')) { $i++ }
644
+ continue
645
+ }
646
+ $kept.Add($lines[$i])
647
+ $i++
648
+ }
649
+ while ($kept.Count -gt 0 -and $kept[$kept.Count - 1].Trim() -eq '') { $kept.RemoveAt($kept.Count - 1) }
650
+
651
+ $blocks = New-Object System.Collections.Generic.List[string]
652
+ $blocks.Add((@('[mcp_servers.argo]', 'command = "node"', "args = [$(ConvertTo-TomlString $ArgoServer)]") -join "`n"))
653
+ if (-not [string]::IsNullOrWhiteSpace($RepoRoot)) {
654
+ $blocks.Add(("[mcp_servers.argo.env]`nARGO_REPO_ROOT = $(ConvertTo-TomlString $RepoRoot)"))
655
+ }
656
+ $blocks.Add(("[mcp_servers.graph-mcp]`nurl = $(ConvertTo-TomlString $GraphMcpUrl)"))
657
+
658
+ $result = ($kept -join "`n")
659
+ if ($result.Trim() -ne '') { $result = $result.TrimEnd() + "`n`n" }
660
+ $result += ($blocks -join "`n`n") + "`n"
661
+
662
+ New-Item -ItemType Directory -Force -Path (Split-Path $ConfigPath) | Out-Null
663
+ [System.IO.File]::WriteAllText($ConfigPath, $result, (New-Object System.Text.UTF8Encoding $false))
664
+ Write-Host " Codex MCP: argo (stdio) + graph-mcp (streamable http) -> $ConfigPath"
665
+ }
666
+
599
667
  function Write-DshManagedBlock {
600
668
  # Text-level upsert of a marker-delimited block into a file (used for the
601
669
  # managed rows in ~/.dsh/cordis.patch.yml): replaces the previous managed
@@ -1148,6 +1216,33 @@ if ($SkipMcp) {
1148
1216
  }
1149
1217
  }
1150
1218
 
1219
+ if ($SkipCodex) {
1220
+ Write-Host 'Skipped Codex integration (-SkipCodex).'
1221
+ } else {
1222
+ $ruleSrcContent = Get-Content $ruleSrc -Raw -Encoding UTF8
1223
+ $codexAgentsPath = Join-Path $CodexHome 'AGENTS.md'
1224
+ $codexSkillsRoot = Join-Path $CodexHome 'skills'
1225
+
1226
+ Write-Host '==> Deploying Codex integration'
1227
+ Write-Host "[Codex 1/3] argo\rules\archgraph.instructions.md -> $codexAgentsPath (Codex global AGENTS.md, frontmatter stripped)"
1228
+ Write-ArchGraphRuleBlock -DestPath $codexAgentsPath -RuleText $ruleSrcContent -Label 'Codex rule'
1229
+
1230
+ Write-Host "[Codex 2/3] argo\skills -> $codexSkillsRoot (Codex user skills: argo-init, ea-human-reconcile)"
1231
+ Copy-DoubaoSkills -Root $codexSkillsRoot -SourceSkillsRoot (Join-Path $argoDir 'skills') -SkillNames @('argo-init', 'ea-human-reconcile') -Label 'Codex user skills'
1232
+ # agent-search-diagnosis is OpenCode-only (it assumes `opencode` session export); not deployed to Codex.
1233
+
1234
+ if ($SkipMcp) {
1235
+ Write-Host ' Skipped Codex MCP registration (-SkipMcp).'
1236
+ } else {
1237
+ $codexConfigPath = Join-Path $CodexHome 'config.toml'
1238
+ Write-Host "[Codex 3/3] argo MCP (stdio) + graph-mcp -> $codexConfigPath (Codex config.toml)"
1239
+ Write-CodexMcpConfig -ConfigPath $codexConfigPath -ArgoServer $argoServer -GraphMcpUrl $GraphMcpUrl -RepoRoot $CodexRepoRoot
1240
+ }
1241
+ Write-Host ' Codex injects the global AGENTS.md into every session, so the wakeup gate is'
1242
+ Write-Host ' active on the next Codex session; skills load on trigger. Restart Codex so it'
1243
+ Write-Host ' picks up config.toml and the new skills.'
1244
+ }
1245
+
1151
1246
  $wakeupPluginPath = Join-Path $PluginsRoot 'argo-wakeup.js'
1152
1247
  if (Test-Path $wakeupPluginPath) {
1153
1248
  Write-Host '==> Registering argo-wakeup plugin in OpenCode'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archgraph-argo-beta",
3
- "version": "0.27.0-beta.14",
3
+ "version": "0.27.0-beta.16",
4
4
  "description": "Deploy the ArchGraph ARGO toolchain, skills, and rules (schema, scripts, argo-init skill, global rule) with one command.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -48,6 +48,7 @@
48
48
  "test": "node --test \"tests/*.test.js\"",
49
49
  "acceptance": "node scripts/mcp-acceptance.js",
50
50
  "gen:dsh-plugins": "node scripts/gen-dsh-plugins.js",
51
+ "gen:deck": "node scripts/gen-coding-deck.js --check && node scripts/rasterize-coding-deck.js && python scripts/build-coding-deck-pptx.py",
51
52
  "prepack": "node scripts/gen-dsh-plugins.js"
52
53
  },
53
54
  "engines": {