archgraph-argo-beta 0.27.0-beta.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/LICENSE +201 -0
- package/README.md +107 -0
- package/argo/.env.example +170 -0
- package/argo/defaults/EA-model-template.qea +0 -0
- package/argo/defaults/design/KG/SystemArchitecture.json +128 -0
- package/argo/mcp-bridges/graph-mcp-stdio.js +98 -0
- package/argo/package.json +8 -0
- package/argo/plugins/argo-cost-collector.js +35 -0
- package/argo/plugins/argo-wakeup.js +29 -0
- package/argo/rules/archgraph.instructions.md +189 -0
- package/argo/schema/ImplementationToCodingHandoff.schema.json +252 -0
- package/argo/schema/ImplementationToIntentTraceProposal.schema.json +180 -0
- package/argo/schema/IntentToImplementationHandoff.schema.json +75 -0
- package/argo/schema/SystemArchitecture.schema.json +378 -0
- package/argo/schema/archimate3.2.md +7153 -0
- package/argo/schema/argob-rules.json +12229 -0
- package/argo/schema/argob.config.json +20 -0
- package/argo/scripts/ARCHITECTURE.md +58 -0
- package/argo/scripts/agentSearchDiagnose.js +407 -0
- package/argo/scripts/archimate32-rules.js +12301 -0
- package/argo/scripts/argo-mcp-server.js +952 -0
- package/argo/scripts/argo-paths.js +168 -0
- package/argo/scripts/argob-schema.js +574 -0
- package/argo/scripts/ea-qea-sync-lib.js +1014 -0
- package/argo/scripts/ea-qea-sync.js +110 -0
- package/argo/scripts/ensureArgoHarnessEnvironment.js +451 -0
- package/argo/scripts/external-graph-query.js +162 -0
- package/argo/scripts/generateArchitectureDiffPlantuml.js +466 -0
- package/argo/scripts/graph-rag/ARCHITECTURE.md +192 -0
- package/argo/scripts/graph-rag/agentCostLog.js +179 -0
- package/argo/scripts/graph-rag/canonicalProjectionAuthority.js +45 -0
- package/argo/scripts/graph-rag/defaultSemanticRetrieval.js +1244 -0
- package/argo/scripts/graph-rag/embeddingProviderProfile.js +89 -0
- package/argo/scripts/graph-rag/embeddingQualificationGate.js +59 -0
- package/argo/scripts/graph-rag/externalProductionConfig.js +74 -0
- package/argo/scripts/graph-rag/hybridRetrieval.js +114 -0
- package/argo/scripts/graph-rag/liveEmbeddingIndexGate.js +128 -0
- package/argo/scripts/graph-rag/liveEmbeddingNeo4jBoundary.js +137 -0
- package/argo/scripts/graph-rag/liveEmbeddingProviderClient.js +49 -0
- package/argo/scripts/graph-rag/liveEmbeddingProviderConfig.js +571 -0
- package/argo/scripts/graph-rag/mcpCrashDiagnostics.js +137 -0
- package/argo/scripts/graph-rag/mutationEmbeddingVectorLifecycle.js +1266 -0
- package/argo/scripts/graph-rag/neo4jNativeRetrieval.js +37 -0
- package/argo/scripts/graph-rag/productionGraphRagRuntime.js +1633 -0
- package/argo/scripts/graph-rag/rerankRetrieval.js +201 -0
- package/argo/scripts/graph-rag/semantic-persistence/ARCHITECTURE.md +51 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticBackfill.js +342 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticCheckpointStore.js +99 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticNeo4jAdapter.js +186 -0
- package/argo/scripts/graph-rag/semantic-persistence/productionSemanticProjectionStore.js +171 -0
- package/argo/scripts/graph-rag/semanticAlignmentLock.js +76 -0
- package/argo/scripts/graph-rag/semanticAlignmentRunner.js +131 -0
- package/argo/scripts/graph-rag/semanticInitConfiguration.js +24 -0
- package/argo/scripts/graph-rag/semanticOperatorError.js +38 -0
- package/argo/scripts/graph-rag/semanticOperatorJourney.js +459 -0
- package/argo/scripts/graph-rag/semanticReadinessAttestationStore.js +398 -0
- package/argo/scripts/graph-rag/semanticRecordText.js +75 -0
- package/argo/scripts/graph-rag/systemMetadataCommandAdapter.js +269 -0
- package/argo/scripts/graph-semantics.js +266 -0
- package/argo/scripts/lossless-write-gate.js +500 -0
- package/argo/scripts/neo4j-system-architecture-store.js +1066 -0
- package/argo/scripts/repair-subdiagram-views.js +288 -0
- package/argo/scripts/repositoryArgoEnvironment.js +101 -0
- package/argo/scripts/runArchitectureTests.js +591 -0
- package/argo/scripts/semanticOperatorJourneyCli.js +91 -0
- package/argo/scripts/syncSystemArchitectureToNeo4j.js +67 -0
- package/argo/scripts/systemarchitecture-mcp-server.js +4508 -0
- package/argo/scripts/test-executors/_template.js +58 -0
- package/argo/scripts/test-executors/default.js +199 -0
- package/argo/scripts/validateStageHandoff.js +459 -0
- package/argo/scripts/validateSystemArchitecture.js +261 -0
- package/argo/scripts/validateTraceProposal.js +181 -0
- package/argo/scripts/validator-mcp-server.js +347 -0
- package/argo/skills/agent-search-diagnosis/SKILL.md +60 -0
- package/argo/skills/argo-init/SKILL.md +86 -0
- package/argo/skills/ea-human-reconcile/SKILL.md +40 -0
- package/bin/argo-deploy.js +12 -0
- package/cordis.patch.yml +6 -0
- package/dsh-argo-wakeup/index.js +17 -0
- package/dsh-argo-wakeup/package.json +1 -0
- package/dsh-argo-workspace/index.js +142 -0
- package/dsh-argo-workspace/package.json +1 -0
- package/install-argo.ps1 +1162 -0
- package/package.json +56 -0
- package/vendor/neo4j-driver-6.2.0.tgz +0 -0
package/install-argo.ps1
ADDED
|
@@ -0,0 +1,1162 @@
|
|
|
1
|
+
#Requires -Version 5.1
|
|
2
|
+
param(
|
|
3
|
+
[string]$ArgoRoot = "$env:USERPROFILE\.argo",
|
|
4
|
+
[string]$SkillsRoot = "$env:USERPROFILE\.copilot\skills",
|
|
5
|
+
[string]$PromptsRoot = "$env:APPDATA\Code\User\prompts",
|
|
6
|
+
[string]$CursorSkillsRoot = "$env:USERPROFILE\.cursor\skills",
|
|
7
|
+
[string]$CursorMcpPath = "$env:USERPROFILE\.cursor\mcp.json",
|
|
8
|
+
[string]$CursorMcpBridgesRoot = "$env:USERPROFILE\.cursor\mcp-bridges",
|
|
9
|
+
[string]$OpenCodeSkillsRoot = "$env:USERPROFILE\.config\opencode\skills",
|
|
10
|
+
[string]$OpenCodeAgentsPath = "$env:USERPROFILE\.config\opencode\AGENTS.md",
|
|
11
|
+
[string]$OpenCodeConfigPath = "$env:USERPROFILE\.config\opencode\opencode.json",
|
|
12
|
+
[string]$CopilotAgentsRoot = "$env:USERPROFILE\.copilot\agents",
|
|
13
|
+
[string]$CursorAgentsRoot = "$env:USERPROFILE\.cursor\agents",
|
|
14
|
+
[string]$CursorRulesRoot = "$env:USERPROFILE\.cursor\rules",
|
|
15
|
+
[string]$OpenCodeAgentsRoot = "$env:USERPROFILE\.config\opencode\agents",
|
|
16
|
+
[string]$PluginsRoot = "$env:USERPROFILE\.argo\plugins",
|
|
17
|
+
[switch]$SkipEnv,
|
|
18
|
+
[switch]$SkipDeps,
|
|
19
|
+
[switch]$SkipMcp,
|
|
20
|
+
[switch]$SkipDsh,
|
|
21
|
+
[string]$DshHome = "$env:USERPROFILE\.dsh",
|
|
22
|
+
[string]$DshCwd = '',
|
|
23
|
+
[string]$DshWorkspaces = '',
|
|
24
|
+
[string]$OpenClawHome = "$env:USERPROFILE\.openclaw",
|
|
25
|
+
[string]$OpenClawWorkspace = "$env:USERPROFILE\.openclaw\workspace",
|
|
26
|
+
[string]$OpenClawRepoRoot = '',
|
|
27
|
+
[switch]$SkipOpenClaw,
|
|
28
|
+
[string]$DoubaoHome = "$env:USERPROFILE\Doubao",
|
|
29
|
+
[string]$DoubaoWorkspace = "$env:LOCALAPPDATA\Doubao\User Data\Default\.doubao\agent_mode\workspace",
|
|
30
|
+
[switch]$SkipDoubao,
|
|
31
|
+
[string]$McpPath,
|
|
32
|
+
[string]$GraphMcpUrl = 'https://argo.derekworkspacev5.com/mcp'
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
$ErrorActionPreference = 'Stop'
|
|
36
|
+
$repoRoot = $PSScriptRoot
|
|
37
|
+
$argoDir = Join-Path $repoRoot 'argo'
|
|
38
|
+
|
|
39
|
+
# OpenCode-only model-id remap. argo/agents/*.agent.md is a single source shared
|
|
40
|
+
# verbatim across Copilot / Cursor / OpenCode (and DSH presets), so the original
|
|
41
|
+
# model binding must stay untouched there. OpenCode has no Qwen provider
|
|
42
|
+
# configured, so 'alibaba-cn/qwen3.7-plus' cannot resolve; only the OpenCode
|
|
43
|
+
|
|
44
|
+
function Copy-Tree {
|
|
45
|
+
param([string]$Source, [string]$Destination)
|
|
46
|
+
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
|
|
47
|
+
Copy-Item -Recurse -Force -Path (Join-Path $Source '*') -Destination $Destination
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function Copy-Agents {
|
|
51
|
+
param(
|
|
52
|
+
[string]$Source,
|
|
53
|
+
[string]$Destination,
|
|
54
|
+
[string]$Target
|
|
55
|
+
)
|
|
56
|
+
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
|
|
57
|
+
$files = @(Get-ChildItem -Path (Join-Path $Source '*.agent.md') -ErrorAction SilentlyContinue)
|
|
58
|
+
foreach ($file in $files) {
|
|
59
|
+
if (-not $Target) {
|
|
60
|
+
# Copilot: VS Code format, keep the .agent.md extension verbatim.
|
|
61
|
+
Copy-Item -Force -Path $file.FullName -Destination (Join-Path $Destination $file.Name)
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
$targetName = ($file.BaseName -replace '\.agent$', '') + '.md'
|
|
65
|
+
Convert-AgentFile -SourceFile $file.FullName -DestinationFile (Join-Path $Destination $targetName) -Target $Target
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Convert-AgentFile {
|
|
70
|
+
param(
|
|
71
|
+
[string]$SourceFile,
|
|
72
|
+
[string]$DestinationFile,
|
|
73
|
+
[string]$Target
|
|
74
|
+
)
|
|
75
|
+
$content = Get-Content $SourceFile -Raw -Encoding UTF8
|
|
76
|
+
$m = [regex]::Match($content, '(?s)^---\s*\r?\n(.*?)\r?\n---\s*\r?\n(.*)$')
|
|
77
|
+
if (-not $m.Success) {
|
|
78
|
+
Copy-Item -Force -Path $SourceFile -Destination $DestinationFile
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
$front = $m.Groups[1].Value
|
|
82
|
+
$body = $m.Groups[2].Value
|
|
83
|
+
|
|
84
|
+
$name = ''
|
|
85
|
+
$desc = ''
|
|
86
|
+
$model = ''
|
|
87
|
+
$nm = [regex]::Match($front, '(?m)^name:\s*(.*)$')
|
|
88
|
+
if ($nm.Success) { $name = $nm.Groups[1].Value.Trim().Trim('"').Trim("'") }
|
|
89
|
+
$dm = [regex]::Match($front, '(?m)^description:\s*(.*)$')
|
|
90
|
+
if ($dm.Success) { $desc = $dm.Groups[1].Value.Trim().Trim('"').Trim("'") }
|
|
91
|
+
$mm = [regex]::Match($front, '(?m)^model:\s*(.*)$')
|
|
92
|
+
if ($mm.Success) { $model = $mm.Groups[1].Value.Trim().Trim('"').Trim("'") }
|
|
93
|
+
|
|
94
|
+
if ($Target -eq 'opencode') {
|
|
95
|
+
# OpenCode markdown agent: description is required; mode: all keeps it
|
|
96
|
+
# usable as primary and subagent. Keep model so each agent pins its
|
|
97
|
+
# required model; drop VS Code-only fields (tools array, user-invocable,
|
|
98
|
+
# argument-hint) which OpenCode rejects.
|
|
99
|
+
$newFront = "---`r`n"
|
|
100
|
+
if ($desc) { $newFront += "description: `"$($desc -replace '"','\"')`"`r`n" }
|
|
101
|
+
if ($model) {
|
|
102
|
+
$newFront += "model: `"$model`"`r`n"
|
|
103
|
+
}
|
|
104
|
+
$newFront += "mode: all`r`n---`r`n"
|
|
105
|
+
} else {
|
|
106
|
+
# Cursor markdown agent: name + description + model; drop VS Code-only fields.
|
|
107
|
+
$newFront = "---`r`n"
|
|
108
|
+
if ($name) { $newFront += "name: `"$name`"`r`n" }
|
|
109
|
+
if ($desc) { $newFront += "description: `"$($desc -replace '"','\"')`"`r`n" }
|
|
110
|
+
if ($model) { $newFront += "model: `"$model`"`r`n" }
|
|
111
|
+
$newFront += "---`r`n"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
$result = $newFront + "`r`n" + $body
|
|
115
|
+
[System.IO.File]::WriteAllText($DestinationFile, $result, (New-Object System.Text.UTF8Encoding $false))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function Convert-RuleFile {
|
|
119
|
+
param(
|
|
120
|
+
[string]$SourceFile,
|
|
121
|
+
[string]$DestinationFile
|
|
122
|
+
)
|
|
123
|
+
$content = Get-Content $SourceFile -Raw -Encoding UTF8
|
|
124
|
+
$m = [regex]::Match($content, '(?s)^---\s*\r?\n(.*?)\r?\n---\s*\r?\n(.*)$')
|
|
125
|
+
if (-not $m.Success) {
|
|
126
|
+
Copy-Item -Force -Path $SourceFile -Destination $DestinationFile
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
$front = $m.Groups[1].Value
|
|
130
|
+
$body = $m.Groups[2].Value
|
|
131
|
+
|
|
132
|
+
$desc = ''
|
|
133
|
+
$dm = [regex]::Match($front, '(?m)^description:\s*(.*)$')
|
|
134
|
+
if ($dm.Success) { $desc = $dm.Groups[1].Value.Trim().Trim('"').Trim("'") }
|
|
135
|
+
|
|
136
|
+
# Cursor .mdc rule: description + alwaysApply so it is injected into every
|
|
137
|
+
# request. The rule body (WakeupGuideline + CoreRules + ...) is kept verbatim.
|
|
138
|
+
$newFront = "---`r`n"
|
|
139
|
+
if ($desc) { $newFront += "description: `"$($desc -replace '"','\"')`"`r`n" }
|
|
140
|
+
$newFront += "alwaysApply: true`r`n---`r`n"
|
|
141
|
+
|
|
142
|
+
$result = $newFront + "`r`n" + $body
|
|
143
|
+
[System.IO.File]::WriteAllText($DestinationFile, $result, (New-Object System.Text.UTF8Encoding $false))
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function Write-McpConfig {
|
|
147
|
+
param(
|
|
148
|
+
[string]$Path,
|
|
149
|
+
[string]$ServersKey,
|
|
150
|
+
$ServerConfig,
|
|
151
|
+
[System.Collections.IDictionary]$ExtraServers = $null
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
$root = [ordered]@{}
|
|
155
|
+
if (Test-Path $Path) {
|
|
156
|
+
try {
|
|
157
|
+
$existing = Get-Content $Path -Raw | ConvertFrom-Json
|
|
158
|
+
foreach ($p in $existing.PSObject.Properties) {
|
|
159
|
+
$root[$p.Name] = $p.Value
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
# Ignore an unparseable existing file and start fresh.
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
$servers = [ordered]@{}
|
|
167
|
+
if ($root.Contains($ServersKey)) {
|
|
168
|
+
$serversValue = $root[$ServersKey]
|
|
169
|
+
if ($null -ne $serversValue) {
|
|
170
|
+
foreach ($p in $serversValue.PSObject.Properties) {
|
|
171
|
+
$servers[$p.Name] = $p.Value
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
$servers['argo'] = $ServerConfig
|
|
176
|
+
if ($null -ne $ExtraServers) {
|
|
177
|
+
foreach ($name in $ExtraServers.Keys) {
|
|
178
|
+
$servers[$name] = $ExtraServers[$name]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
$root[$ServersKey] = $servers
|
|
182
|
+
|
|
183
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $Path) | Out-Null
|
|
184
|
+
$json = $root | ConvertTo-Json -Depth 10
|
|
185
|
+
[System.IO.File]::WriteAllText($Path, $json, (New-Object System.Text.UTF8Encoding $false))
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function Register-OpenCodePlugin {
|
|
189
|
+
param(
|
|
190
|
+
[string]$ConfigPath,
|
|
191
|
+
[string]$PluginFilePath
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
$root = [ordered]@{}
|
|
195
|
+
if (Test-Path $ConfigPath) {
|
|
196
|
+
try {
|
|
197
|
+
$existing = Get-Content $ConfigPath -Raw | ConvertFrom-Json
|
|
198
|
+
foreach ($p in $existing.PSObject.Properties) {
|
|
199
|
+
$root[$p.Name] = $p.Value
|
|
200
|
+
}
|
|
201
|
+
} catch {
|
|
202
|
+
# Ignore an unparseable existing file and start fresh.
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
$url = 'file:///' + (($PluginFilePath -replace '\\', '/').TrimStart('/'))
|
|
207
|
+
$plugins = @()
|
|
208
|
+
if ($root.Contains('plugin') -and $null -ne $root['plugin']) {
|
|
209
|
+
$plugins = @($root['plugin'])
|
|
210
|
+
}
|
|
211
|
+
if ($plugins -notcontains $url) {
|
|
212
|
+
$plugins += $url
|
|
213
|
+
}
|
|
214
|
+
$root['plugin'] = $plugins
|
|
215
|
+
|
|
216
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $ConfigPath) | Out-Null
|
|
217
|
+
$json = $root | ConvertTo-Json -Depth 10
|
|
218
|
+
[System.IO.File]::WriteAllText($ConfigPath, $json, (New-Object System.Text.UTF8Encoding $false))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function Get-ArchGraphRuleBlockEndIndex {
|
|
222
|
+
# Locate the end of a previously merged ArchGraph rule block. The rule's
|
|
223
|
+
# final section tag changed over versions: earlier rules ended with
|
|
224
|
+
# </ToolsGuideline>, the current layout ends with </Attention> and places
|
|
225
|
+
# <ToolsGuideline> earlier. Pick whichever final tag occurs LAST at/after
|
|
226
|
+
# the block marker, so the merge stays correct across rule reorderings and
|
|
227
|
+
# also repairs a previously duplicated tail.
|
|
228
|
+
param([string]$Text, [int]$From)
|
|
229
|
+
$idx = -1
|
|
230
|
+
foreach ($tag in @('</ToolsGuideline>', '</Attention>')) {
|
|
231
|
+
$i = $Text.LastIndexOf($tag)
|
|
232
|
+
if ($i -ge $From -and $i -gt $idx) { $idx = $i }
|
|
233
|
+
}
|
|
234
|
+
return $idx
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function Get-ArchGraphRuleBlockEndTagLength {
|
|
238
|
+
param([string]$Text, [int]$Index)
|
|
239
|
+
if ($Index -lt 0) { return 0 }
|
|
240
|
+
if ($Text.Substring($Index).StartsWith('</ToolsGuideline>')) { return '</ToolsGuideline>'.Length }
|
|
241
|
+
if ($Text.Substring($Index).StartsWith('</Attention>')) { return '</Attention>'.Length }
|
|
242
|
+
return 0
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function Add-AgentsRule {
|
|
246
|
+
param(
|
|
247
|
+
[string]$AgentsPath,
|
|
248
|
+
[string]$RulePath
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $AgentsPath) | Out-Null
|
|
252
|
+
$ruleContent = Get-Content $RulePath -Raw -Encoding UTF8
|
|
253
|
+
$marker = 'ArchGraph ARGO Workflow Rules'
|
|
254
|
+
|
|
255
|
+
if (Test-Path $AgentsPath) {
|
|
256
|
+
$existing = Get-Content $AgentsPath -Raw -Encoding UTF8
|
|
257
|
+
if ($existing -like "*$marker*") {
|
|
258
|
+
# An existing ArchGraph rules block is present. Replace it with the
|
|
259
|
+
# current rule content while preserving any unrelated content that
|
|
260
|
+
# surrounds it (e.g. user-authored OpenCode instructions).
|
|
261
|
+
$markerIdx = $existing.IndexOf($marker)
|
|
262
|
+
if ($markerIdx -lt 0) { $markerIdx = 0 }
|
|
263
|
+
$startIdx = $existing.LastIndexOf('---', $markerIdx)
|
|
264
|
+
if ($startIdx -lt 0) { $startIdx = 0 }
|
|
265
|
+
$endIdx = Get-ArchGraphRuleBlockEndIndex -Text $existing -From $markerIdx
|
|
266
|
+
|
|
267
|
+
$before = $existing.Substring(0, $startIdx).TrimEnd()
|
|
268
|
+
if ($endIdx -lt 0) {
|
|
269
|
+
$combined = $ruleContent
|
|
270
|
+
} else {
|
|
271
|
+
$endLen = Get-ArchGraphRuleBlockEndTagLength -Text $existing -Index $endIdx
|
|
272
|
+
$after = $existing.Substring($endIdx + $endLen)
|
|
273
|
+
$combined = $before
|
|
274
|
+
if ($combined.Length -gt 0) { $combined += "`n`n" }
|
|
275
|
+
$combined += $ruleContent
|
|
276
|
+
if ($after.Length -gt 0) { $combined += $after }
|
|
277
|
+
}
|
|
278
|
+
[System.IO.File]::WriteAllText($AgentsPath, $combined, (New-Object System.Text.UTF8Encoding $false))
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
$combined = $existing.TrimEnd() + "`n`n" + $ruleContent
|
|
282
|
+
[System.IO.File]::WriteAllText($AgentsPath, $combined, (New-Object System.Text.UTF8Encoding $false))
|
|
283
|
+
} else {
|
|
284
|
+
[System.IO.File]::WriteAllText($AgentsPath, $ruleContent, (New-Object System.Text.UTF8Encoding $false))
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
# ---- DeepSeek Harness (dsh) conversion helpers ----
|
|
289
|
+
# The ArchGraph repository keeps ONE source file per artifact (rule / skill /
|
|
290
|
+
# mcp / plugin / agent). The targets below convert that single source into the
|
|
291
|
+
# DeepSeek Harness shape at deploy time, exactly like Convert-AgentFile and
|
|
292
|
+
# Convert-RuleFile do for Cursor / OpenCode.
|
|
293
|
+
|
|
294
|
+
function Get-MarkdownBody {
|
|
295
|
+
# Strip a leading YAML frontmatter block (--- ... ---) from markdown text.
|
|
296
|
+
# DeepSeek Harness injects AGENTS.md-style instruction files verbatim, so
|
|
297
|
+
# the frontmatter must not reach the model prompt.
|
|
298
|
+
param([string]$Content)
|
|
299
|
+
$m = [regex]::Match($Content, '(?s)^---\s*\r?\n(.*?)\r?\n---\s*\r?\n(.*)$')
|
|
300
|
+
if (-not $m.Success) { return $Content }
|
|
301
|
+
return $m.Groups[2].Value
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function Write-ArchGraphRuleBlock {
|
|
305
|
+
# Merge the frontmatter-stripped ArchGraph rule into a target AGENTS.md
|
|
306
|
+
# file (DSH home or OpenClaw workspace), replacing the previous ArchGraph
|
|
307
|
+
# block while preserving surrounding user content. The rule body is
|
|
308
|
+
# injected verbatim - no adapter prose - so the working prompt stays
|
|
309
|
+
# identical to the Copilot / Cursor / OpenCode rules.
|
|
310
|
+
param(
|
|
311
|
+
[string]$DestPath,
|
|
312
|
+
[string]$RuleText,
|
|
313
|
+
[string]$Label
|
|
314
|
+
)
|
|
315
|
+
$ruleContent = Get-MarkdownBody -Content $RuleText
|
|
316
|
+
$marker = '<WakeupGuideline>'
|
|
317
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $DestPath) | Out-Null
|
|
318
|
+
if (Test-Path $DestPath) {
|
|
319
|
+
$existing = Get-Content $DestPath -Raw -Encoding UTF8
|
|
320
|
+
if ($existing -like "*$marker*") {
|
|
321
|
+
$startIdx = $existing.IndexOf($marker)
|
|
322
|
+
if ($startIdx -lt 0) { $startIdx = 0 }
|
|
323
|
+
$endIdx = Get-ArchGraphRuleBlockEndIndex -Text $existing -From $startIdx
|
|
324
|
+
$before = $existing.Substring(0, $startIdx).TrimEnd()
|
|
325
|
+
$after = ''
|
|
326
|
+
if ($endIdx -ge 0) {
|
|
327
|
+
$endLen = Get-ArchGraphRuleBlockEndTagLength -Text $existing -Index $endIdx
|
|
328
|
+
$after = $existing.Substring($endIdx + $endLen).TrimStart()
|
|
329
|
+
}
|
|
330
|
+
$combined = $before
|
|
331
|
+
if ($combined.Length -gt 0) { $combined += "`n`n" }
|
|
332
|
+
$combined += $ruleContent
|
|
333
|
+
if ($after.Length -gt 0) { $combined += "`n`n" + $after }
|
|
334
|
+
[System.IO.File]::WriteAllText($DestPath, $combined, (New-Object System.Text.UTF8Encoding $false))
|
|
335
|
+
} else {
|
|
336
|
+
$combined = $existing.TrimEnd() + "`n`n" + $ruleContent
|
|
337
|
+
[System.IO.File]::WriteAllText($DestPath, $combined, (New-Object System.Text.UTF8Encoding $false))
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
[System.IO.File]::WriteAllText($DestPath, $ruleContent, (New-Object System.Text.UTF8Encoding $false))
|
|
341
|
+
}
|
|
342
|
+
Write-Host " $Label installed -> $DestPath"
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function Write-DshAgentRule {
|
|
346
|
+
# Merge the frontmatter-stripped ArchGraph rule into ~/.dsh/AGENTS.md
|
|
347
|
+
# (DeepSeek Harness user-global rule), replacing the previous ArchGraph
|
|
348
|
+
# block while preserving surrounding user content.
|
|
349
|
+
param(
|
|
350
|
+
[string]$DshHome,
|
|
351
|
+
[string]$RuleText
|
|
352
|
+
)
|
|
353
|
+
Write-ArchGraphRuleBlock -DestPath (Join-Path $DshHome 'AGENTS.md') -RuleText $RuleText -Label 'DSH rule'
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function Write-OpenClawAgentRule {
|
|
357
|
+
# Deploy the ArchGraph rules into the OpenClaw agent workspace AGENTS.md.
|
|
358
|
+
# OpenClaw injects AGENTS.md into Project Context on every session (the
|
|
359
|
+
# same mechanism as the DSH / OpenCode AGENTS.md rules), so the
|
|
360
|
+
# UNCONDITIONAL STARTUP GATE is always active for OpenClaw agents.
|
|
361
|
+
param(
|
|
362
|
+
[string]$OpenClawWorkspace,
|
|
363
|
+
[string]$RuleText
|
|
364
|
+
)
|
|
365
|
+
Write-ArchGraphRuleBlock -DestPath (Join-Path $OpenClawWorkspace 'AGENTS.md') -RuleText $RuleText -Label 'OpenClaw rule'
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function Convert-SkillFile {
|
|
369
|
+
# Normalize an ArchGraph SKILL.md for the Doubao (desktop agent mode) skill
|
|
370
|
+
# system. Doubao follows the Anthropic Agent Skills spec: the YAML
|
|
371
|
+
# frontmatter may contain ONLY `name` and `description` (see the built-in
|
|
372
|
+
# skill-creator-for-work skill); any other field is rejected. The ArchGraph
|
|
373
|
+
# skills additionally carry VS Code / OpenCode-only fields (argument-hint,
|
|
374
|
+
# disable-model-invocation), so strip the frontmatter down to name +
|
|
375
|
+
# description while keeping the body verbatim and the values byte-intact.
|
|
376
|
+
param(
|
|
377
|
+
[string]$SourceFile,
|
|
378
|
+
[string]$DestinationFile
|
|
379
|
+
)
|
|
380
|
+
$content = Get-Content $SourceFile -Raw -Encoding UTF8
|
|
381
|
+
$m = [regex]::Match($content, '(?s)^---\s*\r?\n(.*?)\r?\n---\s*\r?\n(.*)$')
|
|
382
|
+
if (-not $m.Success) {
|
|
383
|
+
Copy-Item -Force -Path $SourceFile -Destination $DestinationFile
|
|
384
|
+
return
|
|
385
|
+
}
|
|
386
|
+
$front = $m.Groups[1].Value
|
|
387
|
+
$body = $m.Groups[2].Value
|
|
388
|
+
|
|
389
|
+
$name = ''
|
|
390
|
+
$desc = ''
|
|
391
|
+
$nm = [regex]::Match($front, '(?m)^name:\s*(.*)$')
|
|
392
|
+
if ($nm.Success) { $name = $nm.Groups[1].Value.Trim().Trim('"').Trim("'") }
|
|
393
|
+
# Keep the description value verbatim (including any surrounding quotes) so
|
|
394
|
+
# non-ASCII and internal punctuation survive the round-trip byte-for-byte.
|
|
395
|
+
$dm = [regex]::Match($front, '(?m)^description:\s*(.*)$')
|
|
396
|
+
if ($dm.Success) { $desc = $dm.Groups[1].Value.Trim() }
|
|
397
|
+
|
|
398
|
+
$newFront = "---`r`n"
|
|
399
|
+
if ($name) { $newFront += "name: $name`r`n" }
|
|
400
|
+
if ($desc) { $newFront += "description: $desc`r`n" }
|
|
401
|
+
$newFront += "---`r`n"
|
|
402
|
+
|
|
403
|
+
$result = $newFront + "`r`n" + $body
|
|
404
|
+
[System.IO.File]::WriteAllText($DestinationFile, $result, (New-Object System.Text.UTF8Encoding $false))
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function Copy-DoubaoSkills {
|
|
408
|
+
# Deploy the ArchGraph skills into a Doubao skill root. Doubao adopts the
|
|
409
|
+
# Anthropic Agent Skills layout: one folder per skill containing SKILL.md
|
|
410
|
+
# (plus optional scripts/references/assets). The metadata (name +
|
|
411
|
+
# description) is always in context; the body loads only when the skill
|
|
412
|
+
# triggers. SKILL.md is normalized via Convert-SkillFile; any bundled
|
|
413
|
+
# resources are copied verbatim so the skill folder is self-contained.
|
|
414
|
+
param(
|
|
415
|
+
[string]$Root,
|
|
416
|
+
[string]$SourceSkillsRoot,
|
|
417
|
+
[string[]]$SkillNames,
|
|
418
|
+
[string]$Label
|
|
419
|
+
)
|
|
420
|
+
foreach ($skill in $SkillNames) {
|
|
421
|
+
$src = Join-Path $SourceSkillsRoot $skill
|
|
422
|
+
if (-not (Test-Path (Join-Path $src 'SKILL.md'))) { continue }
|
|
423
|
+
$destDir = Join-Path $Root $skill
|
|
424
|
+
New-Item -ItemType Directory -Force -Path $destDir | Out-Null
|
|
425
|
+
Copy-Item -Recurse -Force -Path (Join-Path $src '*') -Destination $destDir
|
|
426
|
+
Convert-SkillFile -SourceFile (Join-Path $src 'SKILL.md') -DestinationFile (Join-Path $destDir 'SKILL.md')
|
|
427
|
+
}
|
|
428
|
+
Write-Host " argo skills -> $Root ($Label)"
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function Convert-RuleToSkill {
|
|
432
|
+
# Package the single-source ARGO rule file (argo/rules/archgraph.instructions.md)
|
|
433
|
+
# as a Doubao entry skill. Doubao keeps ONLY a skill's name + description in
|
|
434
|
+
# context permanently (the body loads when the skill triggers) and it
|
|
435
|
+
# forbids angle brackets in the description. So the frontmatter carries a
|
|
436
|
+
# mandatory trigger description (the STEP 0 gate + the "load before any
|
|
437
|
+
# intent-graph read/write" mandate) and the body is the rule text verbatim
|
|
438
|
+
# (frontmatter stripped). This is the closest Doubao allows to an always-on
|
|
439
|
+
# rule: Doubao has no system-prompt / AGENTS.md hook.
|
|
440
|
+
param(
|
|
441
|
+
[string]$RuleFile,
|
|
442
|
+
[string]$DestinationFile
|
|
443
|
+
)
|
|
444
|
+
$rule = Get-Content $RuleFile -Raw -Encoding UTF8
|
|
445
|
+
$body = Get-MarkdownBody -Content $rule
|
|
446
|
+
$description = 'MANDATORY entry skill for the ARGO / ArchGraph intent graph. Whenever the workspace is an ArchGraph workspace (contains design/KG/SystemArchitecture.json) or the argo MCP tools (mcp__argo__*) are available, you MUST load this skill BEFORE reading, querying or writing the architecture graph. STEP 0 gate: identify your Business Actor through the argo MCP and restore your working memory first, then follow this skill for KG-first retrieval, the ARGO red lines, acceptance-test-first work, deduplicated and lossless graph writes, and commit tracing.'
|
|
447
|
+
$front = "---`r`nname: archgraph-argo`r`ndescription: `"$description`"`r`n---`r`n"
|
|
448
|
+
[System.IO.File]::WriteAllText($DestinationFile, ($front + "`r`n" + $body), (New-Object System.Text.UTF8Encoding $false))
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function Write-DoubaoMcpRecipe {
|
|
452
|
+
# Doubao's desktop agent mode registers MCP servers through its in-app UI
|
|
453
|
+
# (自定义连接器: 传输类型 STDIO / 命令 / 参数 / 环境变量), NOT through a config
|
|
454
|
+
# file, so the installer cannot auto-register. This writes the exact
|
|
455
|
+
# connector values to a reference file and prints a copy-paste recipe.
|
|
456
|
+
#
|
|
457
|
+
# The argo server is a local stdio child with NO fixed workspace: Doubao's
|
|
458
|
+
# MCP client (rmcp) supports the MCP `roots` handshake and passes a
|
|
459
|
+
# `workingDirectory` when spawning a stdio connector, so argo follows the
|
|
460
|
+
# workspace the user selected in Doubao - exactly like the OpenCode (roots)
|
|
461
|
+
# and DeepSeek Harness (injected workspaceRoot) hosts. ARGO_REPO_ROOT is
|
|
462
|
+
# therefore NOT pinned; it remains available as an optional override.
|
|
463
|
+
# graph-mcp (remote Streamable HTTP) is exposed through the same stdio
|
|
464
|
+
# bridge the Cursor deployment uses.
|
|
465
|
+
param(
|
|
466
|
+
[string]$RecipePath,
|
|
467
|
+
[string]$ArgoServer,
|
|
468
|
+
[string]$BridgePath,
|
|
469
|
+
[string]$GraphMcpUrl
|
|
470
|
+
)
|
|
471
|
+
$argoServerSlash = ($ArgoServer -replace '\\', '/')
|
|
472
|
+
$connectors = @(
|
|
473
|
+
[ordered]@{
|
|
474
|
+
serverName = 'argo'
|
|
475
|
+
transport = 'STDIO'
|
|
476
|
+
command = 'node'
|
|
477
|
+
args = @($argoServerSlash)
|
|
478
|
+
}
|
|
479
|
+
)
|
|
480
|
+
if ($BridgePath) {
|
|
481
|
+
$connectors += [ordered]@{
|
|
482
|
+
serverName = 'graph-mcp'
|
|
483
|
+
transport = 'STDIO'
|
|
484
|
+
command = 'node'
|
|
485
|
+
args = @(($BridgePath -replace '\\', '/'))
|
|
486
|
+
env = [ordered]@{ GRAPH_MCP_URL = $GraphMcpUrl }
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
$recipe = [ordered]@{
|
|
490
|
+
host = 'Doubao desktop (agent mode) - custom connector (自定义连接器), manual in-app registration'
|
|
491
|
+
note = 'Open Doubao agent mode -> MCP/connector settings -> add a custom connector -> enter the values below (transport 传输类型 = STDIO). Requires Node.js on PATH. Doubao custom connectors run only on the local machine.'
|
|
492
|
+
workspace = 'The argo connector has no fixed workspace: it follows the workspace selected in Doubao (MCP roots / connector workingDirectory), the same way OpenCode (roots) and DeepSeek Harness (injected workspaceRoot) do. To pin a fixed workspace instead, add env ARGO_REPO_ROOT=<absolute project path>.'
|
|
493
|
+
connectors = $connectors
|
|
494
|
+
}
|
|
495
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $RecipePath) | Out-Null
|
|
496
|
+
[System.IO.File]::WriteAllText($RecipePath, ($recipe | ConvertTo-Json -Depth 8), (New-Object System.Text.UTF8Encoding $false))
|
|
497
|
+
Write-Host " Doubao MCP connector recipe -> $RecipePath"
|
|
498
|
+
Write-Host ' Register once in the Doubao app (自定义连接器, 传输类型 STDIO):'
|
|
499
|
+
Write-Host ' 服务器名称: argo'
|
|
500
|
+
Write-Host ' 命令: node'
|
|
501
|
+
Write-Host " 参数: $argoServerSlash"
|
|
502
|
+
Write-Host ' (workspace: follows the workspace selected in Doubao)'
|
|
503
|
+
if ($BridgePath) {
|
|
504
|
+
Write-Host ' 服务器名称: graph-mcp'
|
|
505
|
+
Write-Host ' 命令: node'
|
|
506
|
+
Write-Host " 参数: $($BridgePath -replace '\\', '/')"
|
|
507
|
+
Write-Host " 环境变量: GRAPH_MCP_URL=$GraphMcpUrl"
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function Write-OpenClawMcpConfig {
|
|
512
|
+
# Register the argo MCP server under mcp.servers.argo in
|
|
513
|
+
# ~/.openclaw/openclaw.json. OpenClaw is a fixed-workspace host: its
|
|
514
|
+
# embedded MCP client does not advertise MCP roots, so the workspace is
|
|
515
|
+
# pinned explicitly via env.ARGO_REPO_ROOT to the repository root this
|
|
516
|
+
# installer runs from. Only a real ArchGraph workspace (one that contains
|
|
517
|
+
# design/KG/SystemArchitecture.json) is pinned; when the installer runs
|
|
518
|
+
# from a non-workspace location (e.g. the npm-global archgraph-argo package
|
|
519
|
+
# dir via `argo-deploy`), an existing ARGO_REPO_ROOT is preserved instead
|
|
520
|
+
# of being clobbered, and a missing one is left unpinned with a hint.
|
|
521
|
+
# Existing config keys are preserved; a JSON5 (non strict JSON) config is
|
|
522
|
+
# left untouched with a manual-registration hint.
|
|
523
|
+
param(
|
|
524
|
+
[string]$OpenClawHome,
|
|
525
|
+
[string]$RepoRoot,
|
|
526
|
+
[string]$ArgoServer,
|
|
527
|
+
$GraphMcpServer
|
|
528
|
+
)
|
|
529
|
+
$configPath = Join-Path $OpenClawHome 'openclaw.json'
|
|
530
|
+
$root = [ordered]@{}
|
|
531
|
+
$existingArgoRoot = ''
|
|
532
|
+
if (Test-Path $configPath) {
|
|
533
|
+
try {
|
|
534
|
+
$existing = Get-Content $configPath -Raw | ConvertFrom-Json
|
|
535
|
+
foreach ($p in $existing.PSObject.Properties) {
|
|
536
|
+
$root[$p.Name] = $p.Value
|
|
537
|
+
}
|
|
538
|
+
# Capture any previously pinned ARGO_REPO_ROOT so a non-workspace
|
|
539
|
+
# refresh (e.g. npm-global argo-deploy) cannot clobber a correct pin.
|
|
540
|
+
if ($null -ne $existing.mcp -and $null -ne $existing.mcp.servers `
|
|
541
|
+
-and $null -ne $existing.mcp.servers.argo -and $null -ne $existing.mcp.servers.argo.env `
|
|
542
|
+
-and $null -ne $existing.mcp.servers.argo.env.ARGO_REPO_ROOT) {
|
|
543
|
+
$existingArgoRoot = [string]$existing.mcp.servers.argo.env.ARGO_REPO_ROOT
|
|
544
|
+
}
|
|
545
|
+
} catch {
|
|
546
|
+
Write-Warning " $configPath is not strict JSON (JSON5 with comments?); skipping argo MCP registration."
|
|
547
|
+
Write-Warning " Register manually: openclaw mcp add argo --command node --arg `"$ArgoServer`" --env ARGO_REPO_ROOT=$RepoRoot"
|
|
548
|
+
return
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
$repoIsWorkspace = Test-Path (Join-Path $RepoRoot 'design\KG\SystemArchitecture.json')
|
|
552
|
+
# Only preserve an existing ARGO_REPO_ROOT that is itself a real ArchGraph
|
|
553
|
+
# workspace. A stale value from a previous non-workspace install (e.g. the
|
|
554
|
+
# npm-global archgraph-argo package dir) must NOT be preserved, otherwise
|
|
555
|
+
# OpenClaw keeps resolving the wrong Neo4j database (basename-derived).
|
|
556
|
+
$existingIsWorkspace = $false
|
|
557
|
+
if ($existingArgoRoot) {
|
|
558
|
+
$existingIsWorkspace = Test-Path (Join-Path $existingArgoRoot 'design\KG\SystemArchitecture.json')
|
|
559
|
+
}
|
|
560
|
+
$envBlock = [ordered]@{}
|
|
561
|
+
if ($repoIsWorkspace) {
|
|
562
|
+
$envBlock.ARGO_REPO_ROOT = $RepoRoot
|
|
563
|
+
} elseif ($existingIsWorkspace) {
|
|
564
|
+
$envBlock.ARGO_REPO_ROOT = $existingArgoRoot
|
|
565
|
+
Write-Host " $RepoRoot is not an ArchGraph workspace; preserving existing ARGO_REPO_ROOT=$existingArgoRoot"
|
|
566
|
+
} else {
|
|
567
|
+
if ($existingArgoRoot) {
|
|
568
|
+
Write-Warning " Cleared stale non-workspace ARGO_REPO_ROOT=$existingArgoRoot from the OpenClaw MCP config."
|
|
569
|
+
}
|
|
570
|
+
Write-Warning " $RepoRoot is not an ArchGraph workspace; not pinning ARGO_REPO_ROOT for OpenClaw."
|
|
571
|
+
Write-Warning " Run install-argo.ps1 from the repository you want OpenClaw to serve, or set mcp.servers.argo.env.ARGO_REPO_ROOT manually (e.g. -OpenClawRepoRoot <repo>)."
|
|
572
|
+
}
|
|
573
|
+
$mcp = [ordered]@{}
|
|
574
|
+
if ($root.Contains('mcp') -and $null -ne $root['mcp']) {
|
|
575
|
+
foreach ($p in $root['mcp'].PSObject.Properties) { $mcp[$p.Name] = $p.Value }
|
|
576
|
+
}
|
|
577
|
+
$servers = [ordered]@{}
|
|
578
|
+
if ($mcp.Contains('servers') -and $null -ne $mcp['servers']) {
|
|
579
|
+
foreach ($p in $mcp['servers'].PSObject.Properties) { $servers[$p.Name] = $p.Value }
|
|
580
|
+
}
|
|
581
|
+
$argoServerObj = [ordered]@{
|
|
582
|
+
command = 'node'
|
|
583
|
+
args = @($ArgoServer)
|
|
584
|
+
}
|
|
585
|
+
if ($envBlock.Count -gt 0) {
|
|
586
|
+
$argoServerObj.env = $envBlock
|
|
587
|
+
}
|
|
588
|
+
$servers['argo'] = $argoServerObj
|
|
589
|
+
if ($null -ne $GraphMcpServer) {
|
|
590
|
+
$servers['graph-mcp'] = $GraphMcpServer
|
|
591
|
+
}
|
|
592
|
+
$mcp['servers'] = $servers
|
|
593
|
+
$root['mcp'] = $mcp
|
|
594
|
+
New-Item -ItemType Directory -Force -Path $OpenClawHome | Out-Null
|
|
595
|
+
$json = $root | ConvertTo-Json -Depth 12
|
|
596
|
+
[System.IO.File]::WriteAllText($configPath, $json, (New-Object System.Text.UTF8Encoding $false))
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function Write-DshManagedBlock {
|
|
600
|
+
# Text-level upsert of a marker-delimited block into a file (used for the
|
|
601
|
+
# managed rows in ~/.dsh/cordis.patch.yml): replaces the previous managed
|
|
602
|
+
# block and preserves surrounding content. No YAML dependency needed.
|
|
603
|
+
param(
|
|
604
|
+
[string]$Path,
|
|
605
|
+
[string]$Block,
|
|
606
|
+
[string]$MarkerStart,
|
|
607
|
+
[string]$MarkerEnd
|
|
608
|
+
)
|
|
609
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $Path) | Out-Null
|
|
610
|
+
$existing = if (Test-Path $Path) { Get-Content $Path -Raw -Encoding UTF8 } else { '' }
|
|
611
|
+
$startIdx = $existing.IndexOf($MarkerStart)
|
|
612
|
+
$endIdx = if ($startIdx -ge 0) { $existing.IndexOf($MarkerEnd, $startIdx) } else { -1 }
|
|
613
|
+
if ($startIdx -ge 0 -and $endIdx -ge 0) {
|
|
614
|
+
$endIdx += $MarkerEnd.Length
|
|
615
|
+
$combined = $existing.Substring(0, $startIdx).TrimEnd()
|
|
616
|
+
if ($combined.Length -gt 0) { $combined += "`n`n" }
|
|
617
|
+
$combined += $Block
|
|
618
|
+
$after = $existing.Substring($endIdx).TrimStart()
|
|
619
|
+
if ($after.Length -gt 0) { $combined += "`n`n" + $after }
|
|
620
|
+
[System.IO.File]::WriteAllText($Path, $combined, (New-Object System.Text.UTF8Encoding $false))
|
|
621
|
+
} else {
|
|
622
|
+
$combined = $existing.TrimEnd()
|
|
623
|
+
if ($combined.Length -gt 0) { $combined += "`n`n" }
|
|
624
|
+
$combined += $Block + "`n"
|
|
625
|
+
[System.IO.File]::WriteAllText($Path, $combined, (New-Object System.Text.UTF8Encoding $false))
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function New-DshWakeupPlugin {
|
|
630
|
+
# Deploy the DSH wakeup-gate Cordis plugin under ~/.dsh/plugins by copying
|
|
631
|
+
# the single-source bundle artifact dsh-argo-wakeup/index.js (generated from
|
|
632
|
+
# the <WakeupGuideline> block of argo/rules/archgraph.instructions.md by
|
|
633
|
+
# scripts/gen-dsh-plugins.js). Copying - not regenerating a template here -
|
|
634
|
+
# keeps the deployed plugin and the shipped bundle byte-identical, so the
|
|
635
|
+
# gate text has exactly one source and cannot fork.
|
|
636
|
+
param(
|
|
637
|
+
[string]$DshHome
|
|
638
|
+
)
|
|
639
|
+
$source = Join-Path (Join-Path $repoRoot 'dsh-argo-wakeup') 'index.js'
|
|
640
|
+
if (-not (Test-Path $source)) {
|
|
641
|
+
Write-Warning " $source not found; DSH wakeup plugin skipped."
|
|
642
|
+
return $null
|
|
643
|
+
}
|
|
644
|
+
$dir = Join-Path (Join-Path $DshHome 'plugins') 'dsh-argo-wakeup'
|
|
645
|
+
New-Item -ItemType Directory -Force -Path $dir | Out-Null
|
|
646
|
+
$indexPath = Join-Path $dir 'index.js'
|
|
647
|
+
Copy-Item -Force -Path $source -Destination $indexPath
|
|
648
|
+
Write-Host " DSH wakeup plugin <- $source (single source)"
|
|
649
|
+
return $indexPath
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function New-DshWorkspaceBridge {
|
|
653
|
+
# Deploy the DSH workspace bridge plugin under ~/.dsh/plugins by copying the
|
|
654
|
+
# single-source bundle artifact dsh-argo-workspace/index.js. It connects
|
|
655
|
+
# directly to the argo MCP server (no dsh-mcp-client row needed) with a
|
|
656
|
+
# zero-dependency minimal MCP stdio client, registers every tool as
|
|
657
|
+
# mcp__argo__* and injects the current session's workspace directory
|
|
658
|
+
# (SessionHeader.cwd) as the per-call `workspaceRoot`, so ONE dsh instance
|
|
659
|
+
# follows whichever workspace the user switched to - no model-visible
|
|
660
|
+
# parameters, no internal tool names, no restart. Copying (not embedding a
|
|
661
|
+
# template) keeps the deployed plugin and the shipped bundle identical.
|
|
662
|
+
param(
|
|
663
|
+
[string]$DshHome
|
|
664
|
+
)
|
|
665
|
+
$source = Join-Path (Join-Path $repoRoot 'dsh-argo-workspace') 'index.js'
|
|
666
|
+
if (-not (Test-Path $source)) {
|
|
667
|
+
Write-Warning " $source not found; DSH workspace bridge skipped."
|
|
668
|
+
return $null
|
|
669
|
+
}
|
|
670
|
+
$dir = Join-Path (Join-Path $DshHome 'plugins') 'dsh-argo-workspace'
|
|
671
|
+
New-Item -ItemType Directory -Force -Path $dir | Out-Null
|
|
672
|
+
$indexPath = Join-Path $dir 'index.js'
|
|
673
|
+
Copy-Item -Force -Path $source -Destination $indexPath
|
|
674
|
+
Write-Host " DSH workspace bridge <- $source (single source)"
|
|
675
|
+
return $indexPath
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
function New-DshAgentPresets {
|
|
679
|
+
# Generate DSH agent presets under ~/.dsh/.agent-presets/<id>/ from
|
|
680
|
+
# argo/agents/*.agent.md (the same single source the Copilot / Cursor /
|
|
681
|
+
# OpenCode agent files are converted from). persona.md is a
|
|
682
|
+
# frontmatter-stripped copy of the agent body; persona.js is a fixed
|
|
683
|
+
# self-contained row that mounts it as the session persona
|
|
684
|
+
# (deployment:persona section, order 0).
|
|
685
|
+
param(
|
|
686
|
+
[string]$DshHome,
|
|
687
|
+
[string]$AgentsSrc
|
|
688
|
+
)
|
|
689
|
+
$files = @(Get-ChildItem -Path (Join-Path $AgentsSrc '*.agent.md') -ErrorAction SilentlyContinue)
|
|
690
|
+
if ($files.Count -eq 0) {
|
|
691
|
+
Write-Warning ' no *.agent.md files found; DSH agent presets skipped.'
|
|
692
|
+
return
|
|
693
|
+
}
|
|
694
|
+
foreach ($file in $files) {
|
|
695
|
+
$content = Get-Content $file.FullName -Raw -Encoding UTF8
|
|
696
|
+
$m = [regex]::Match($content, '(?s)^---\s*\r?\n(.*?)\r?\n---\s*\r?\n(.*)$')
|
|
697
|
+
$name = ''
|
|
698
|
+
$desc = ''
|
|
699
|
+
$body = $content
|
|
700
|
+
if ($m.Success) {
|
|
701
|
+
$front = $m.Groups[1].Value
|
|
702
|
+
$body = $m.Groups[2].Value.TrimStart("`r", "`n")
|
|
703
|
+
$nm = [regex]::Match($front, '(?m)^name:\s*(.*)$')
|
|
704
|
+
if ($nm.Success) { $name = $nm.Groups[1].Value.Trim().Trim('"').Trim("'") }
|
|
705
|
+
$dm = [regex]::Match($front, '(?m)^description:\s*(.*)$')
|
|
706
|
+
if ($dm.Success) { $desc = $dm.Groups[1].Value.Trim().Trim('"').Trim("'") }
|
|
707
|
+
}
|
|
708
|
+
$id = $file.BaseName -replace '\.agent$', ''
|
|
709
|
+
if (-not $name) { $name = $id }
|
|
710
|
+
$dir = Join-Path (Join-Path $DshHome '.agent-presets') $id
|
|
711
|
+
New-Item -ItemType Directory -Force -Path $dir | Out-Null
|
|
712
|
+
|
|
713
|
+
# preset.yml: display metadata (name + description).
|
|
714
|
+
$presetYml = "name: $name`n"
|
|
715
|
+
if ($desc) { $presetYml += "description: `"$($desc -replace '"', '\"')`"`n" }
|
|
716
|
+
[System.IO.File]::WriteAllText((Join-Path $dir 'preset.yml'), $presetYml, (New-Object System.Text.UTF8Encoding $false))
|
|
717
|
+
|
|
718
|
+
# persona.md: the agent body verbatim (single source: the .agent.md file).
|
|
719
|
+
[System.IO.File]::WriteAllText((Join-Path $dir 'persona.md'), $body, (New-Object System.Text.UTF8Encoding $false))
|
|
720
|
+
|
|
721
|
+
# agent.cordis.yml: mount the local persona row.
|
|
722
|
+
$cordisYml = @"
|
|
723
|
+
# ArchGraph agent preset "$name" - generated by install-argo.ps1 from
|
|
724
|
+
# argo/agents/$($file.Name) (single source of truth; this file is a deployment
|
|
725
|
+
# artifact, do not edit by hand). The persona is the frontmatter-stripped agent
|
|
726
|
+
# body (persona.md), mounted as the session's deployment:persona section.
|
|
727
|
+
- id: persona
|
|
728
|
+
name: './persona.js'
|
|
729
|
+
"@
|
|
730
|
+
[System.IO.File]::WriteAllText((Join-Path $dir 'agent.cordis.yml'), $cordisYml, (New-Object System.Text.UTF8Encoding $false))
|
|
731
|
+
|
|
732
|
+
# persona.js: fixed row implementation.
|
|
733
|
+
$personaJs = @'
|
|
734
|
+
// persona row for an ArchGraph agent preset (generated by install-argo.ps1).
|
|
735
|
+
// Loads persona.md next to this file and registers it as the
|
|
736
|
+
// deployment:persona system-prompt section (order 0), shadowing the
|
|
737
|
+
// deployment persona for the session that mounts this preset.
|
|
738
|
+
import { readFileSync } from 'node:fs'
|
|
739
|
+
import { fileURLToPath } from 'node:url'
|
|
740
|
+
export const name = 'persona'
|
|
741
|
+
export const inject = ['systemPrompt']
|
|
742
|
+
export function apply(ctx) {
|
|
743
|
+
const text = readFileSync(fileURLToPath(new URL('./persona.md', import.meta.url)), 'utf8')
|
|
744
|
+
ctx.effect(() => ctx.systemPrompt.section({
|
|
745
|
+
name: 'deployment:persona',
|
|
746
|
+
order: 0,
|
|
747
|
+
text,
|
|
748
|
+
}), 'persona.section()')
|
|
749
|
+
}
|
|
750
|
+
'@
|
|
751
|
+
[System.IO.File]::WriteAllText((Join-Path $dir 'persona.js'), $personaJs, (New-Object System.Text.UTF8Encoding $false))
|
|
752
|
+
Write-Host " DSH agent preset generated -> $dir"
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
Write-Host '==> Deploying Argo toolchain'
|
|
757
|
+
|
|
758
|
+
$schemaSrc = Join-Path $argoDir 'schema'
|
|
759
|
+
$schemaDest = Join-Path $ArgoRoot 'schema'
|
|
760
|
+
Write-Host "[1/22] argo\schema -> $schemaDest"
|
|
761
|
+
Copy-Tree -Source $schemaSrc -Destination $schemaDest
|
|
762
|
+
|
|
763
|
+
$scriptsSrc = Join-Path $argoDir 'scripts'
|
|
764
|
+
$scriptsDest = Join-Path $ArgoRoot 'scripts'
|
|
765
|
+
Write-Host "[2/22] argo\scripts -> $scriptsDest"
|
|
766
|
+
Copy-Tree -Source $scriptsSrc -Destination $scriptsDest
|
|
767
|
+
|
|
768
|
+
$defaultsSrc = Join-Path $argoDir 'defaults'
|
|
769
|
+
$defaultsDest = Join-Path $ArgoRoot 'defaults'
|
|
770
|
+
Write-Host "[3/22] argo\defaults -> $defaultsDest"
|
|
771
|
+
Copy-Tree -Source $defaultsSrc -Destination $defaultsDest
|
|
772
|
+
|
|
773
|
+
$skillSrc = Join-Path (Join-Path $argoDir 'skills') 'argo-init'
|
|
774
|
+
$skillDest = Join-Path $SkillsRoot 'argo-init'
|
|
775
|
+
Write-Host "[4/22] argo\skills\argo-init -> $skillDest"
|
|
776
|
+
Copy-Tree -Source $skillSrc -Destination $skillDest
|
|
777
|
+
$reconcileSkillSrc = Join-Path (Join-Path $argoDir 'skills') 'ea-human-reconcile'
|
|
778
|
+
$diagSkillSrc = Join-Path (Join-Path $argoDir 'skills') 'agent-search-diagnosis'
|
|
779
|
+
Write-Host ' argo\skills\ea-human-reconcile -> $SkillsRoot\ea-human-reconcile (EA human draft reconcile skill)'
|
|
780
|
+
Copy-Tree -Source $reconcileSkillSrc -Destination (Join-Path $SkillsRoot 'ea-human-reconcile')
|
|
781
|
+
Write-Host ' argo\skills\agent-search-diagnosis -> $SkillsRoot\agent-search-diagnosis (agent search diagnosis skill)'
|
|
782
|
+
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path $SkillsRoot 'agent-search-diagnosis')
|
|
783
|
+
|
|
784
|
+
$ruleSrc = Join-Path (Join-Path $argoDir 'rules') 'archgraph.instructions.md'
|
|
785
|
+
$ruleDest = Join-Path $PromptsRoot 'archgraph.instructions.md'
|
|
786
|
+
Write-Host "[5/22] argo\rules\archgraph.instructions.md -> $ruleDest"
|
|
787
|
+
New-Item -ItemType Directory -Force -Path $PromptsRoot | Out-Null
|
|
788
|
+
Copy-Item -Force -Path $ruleSrc -Destination $ruleDest
|
|
789
|
+
|
|
790
|
+
$depsSrc = Join-Path $argoDir 'package.json'
|
|
791
|
+
$depsDest = Join-Path $ArgoRoot 'package.json'
|
|
792
|
+
Write-Host "[6/22] argo\package.json -> $depsDest"
|
|
793
|
+
Copy-Item -Force -Path $depsSrc -Destination $depsDest
|
|
794
|
+
|
|
795
|
+
$cursorSkillDest = Join-Path $CursorSkillsRoot 'argo-init'
|
|
796
|
+
Write-Host "[7/22] argo\skills\argo-init -> $cursorSkillDest (Cursor)"
|
|
797
|
+
Copy-Tree -Source $skillSrc -Destination $cursorSkillDest
|
|
798
|
+
Write-Host ' argo\skills\ea-human-reconcile -> $CursorSkillsRoot\ea-human-reconcile (Cursor)'
|
|
799
|
+
Copy-Tree -Source $reconcileSkillSrc -Destination (Join-Path $CursorSkillsRoot 'ea-human-reconcile')
|
|
800
|
+
Write-Host ' argo\skills\agent-search-diagnosis -> $CursorSkillsRoot\agent-search-diagnosis (Cursor)'
|
|
801
|
+
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path $CursorSkillsRoot 'agent-search-diagnosis')
|
|
802
|
+
|
|
803
|
+
$mcpBridgeSrc = Join-Path $argoDir 'mcp-bridges'
|
|
804
|
+
$mcpBridgeDest = Join-Path $CursorMcpBridgesRoot ''
|
|
805
|
+
Write-Host " argo\mcp-bridges -> $mcpBridgeDest (Cursor graph-mcp stdio bridge)"
|
|
806
|
+
Copy-Tree -Source $mcpBridgeSrc -Destination $mcpBridgeDest
|
|
807
|
+
|
|
808
|
+
$openCodeSkillDest = Join-Path $OpenCodeSkillsRoot 'argo-init'
|
|
809
|
+
Write-Host "[8/22] argo\skills\argo-init -> $openCodeSkillDest (OpenCode)"
|
|
810
|
+
Copy-Tree -Source $skillSrc -Destination $openCodeSkillDest
|
|
811
|
+
Write-Host ' argo\skills\ea-human-reconcile -> $OpenCodeSkillsRoot\ea-human-reconcile (OpenCode)'
|
|
812
|
+
Copy-Tree -Source $reconcileSkillSrc -Destination (Join-Path $OpenCodeSkillsRoot 'ea-human-reconcile')
|
|
813
|
+
Write-Host ' argo\skills\agent-search-diagnosis -> $OpenCodeSkillsRoot\agent-search-diagnosis (OpenCode)'
|
|
814
|
+
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path $OpenCodeSkillsRoot 'agent-search-diagnosis')
|
|
815
|
+
|
|
816
|
+
Write-Host "[9/22] argo\rules\archgraph.instructions.md -> $OpenCodeAgentsPath (OpenCode global AGENTS.md)"
|
|
817
|
+
Add-AgentsRule -AgentsPath $OpenCodeAgentsPath -RulePath $ruleSrc
|
|
818
|
+
|
|
819
|
+
$agentsSrc = Join-Path $argoDir 'agents'
|
|
820
|
+
Write-Host "[10/22] argo\agents -> $CopilotAgentsRoot (Copilot user-level)"
|
|
821
|
+
Copy-Agents -Source $agentsSrc -Destination $CopilotAgentsRoot
|
|
822
|
+
|
|
823
|
+
Write-Host "[11/22] argo\agents -> $CursorAgentsRoot (Cursor user-level, converted to .md)"
|
|
824
|
+
Copy-Agents -Source $agentsSrc -Destination $CursorAgentsRoot -Target cursor
|
|
825
|
+
|
|
826
|
+
Write-Host "[12/22] argo\agents -> $OpenCodeAgentsRoot (OpenCode user-level, converted to .md)"
|
|
827
|
+
Copy-Agents -Source $agentsSrc -Destination $OpenCodeAgentsRoot -Target opencode
|
|
828
|
+
|
|
829
|
+
$pluginsSrc = Join-Path $argoDir 'plugins'
|
|
830
|
+
Write-Host "[13/22] argo\plugins -> $PluginsRoot (Argo opencode plugins)"
|
|
831
|
+
Copy-Tree -Source $pluginsSrc -Destination $PluginsRoot
|
|
832
|
+
|
|
833
|
+
$cursorRuleSrc = Join-Path (Join-Path $argoDir 'rules') 'archgraph.instructions.md'
|
|
834
|
+
$cursorRuleDest = Join-Path $CursorRulesRoot 'archgraph.mdc'
|
|
835
|
+
Write-Host "[14/22] argo\rules\archgraph.instructions.md -> $cursorRuleDest (Cursor global rule, alwaysApply)"
|
|
836
|
+
New-Item -ItemType Directory -Force -Path $CursorRulesRoot | Out-Null
|
|
837
|
+
Convert-RuleFile -SourceFile $cursorRuleSrc -DestinationFile $cursorRuleDest
|
|
838
|
+
|
|
839
|
+
if ($SkipDsh) {
|
|
840
|
+
Write-Host 'Skipped DeepSeek Harness integration (-SkipDsh).'
|
|
841
|
+
} else {
|
|
842
|
+
$ruleSrcContent = Get-Content $ruleSrc -Raw -Encoding UTF8
|
|
843
|
+
$dshSkillDest = Join-Path (Join-Path $DshHome 'skills') 'argo-init'
|
|
844
|
+
$patchPath = Join-Path $DshHome 'cordis.patch.yml'
|
|
845
|
+
$argoServer = (Join-Path $ArgoRoot 'scripts\argo-mcp-server.js').Replace('\', '/')
|
|
846
|
+
|
|
847
|
+
Write-Host "[15/22] argo\rules\archgraph.instructions.md -> $DshHome\AGENTS.md (DeepSeek Harness user-global rule, frontmatter stripped)"
|
|
848
|
+
Write-DshAgentRule -DshHome $DshHome -RuleText $ruleSrcContent
|
|
849
|
+
|
|
850
|
+
Write-Host "[16/22] argo\skills\argo-init -> $dshSkillDest (DeepSeek Harness skill)"
|
|
851
|
+
Copy-Tree -Source (Join-Path $argoDir 'skills\argo-init') -Destination $dshSkillDest
|
|
852
|
+
Write-Host ' argo\skills\ea-human-reconcile -> $DshHome\skills\ea-human-reconcile (DeepSeek Harness skill)'
|
|
853
|
+
Copy-Tree -Source (Join-Path $argoDir 'skills\ea-human-reconcile') -Destination (Join-Path (Join-Path $DshHome 'skills') 'ea-human-reconcile')
|
|
854
|
+
Write-Host ' argo\skills\agent-search-diagnosis -> $DshHome\skills\agent-search-diagnosis (DeepSeek Harness skill)'
|
|
855
|
+
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path (Join-Path $DshHome 'skills') 'agent-search-diagnosis')
|
|
856
|
+
|
|
857
|
+
Write-Host "[17/22] dsh-argo-wakeup\index.js (single source; gate from argo\rules\archgraph.instructions.md <WakeupGuideline>) -> $DshHome\plugins\dsh-argo-wakeup\index.js (DeepSeek Harness wakeup plugin)"
|
|
858
|
+
$wakeupDshPath = New-DshWakeupPlugin -DshHome $DshHome
|
|
859
|
+
|
|
860
|
+
Write-Host "[18/22] argo-workspace + argo-wakeup rows -> $patchPath (DeepSeek Harness MCP bridge + wakeup plugin)"
|
|
861
|
+
# The generated dsh-argo-workspace bridge connects directly to the argo
|
|
862
|
+
# server (no dsh-mcp-client row), registers every tool as mcp__argo__* and
|
|
863
|
+
# injects the current session's workspace (SessionHeader.cwd) as the
|
|
864
|
+
# per-call workspaceRoot, so one dsh instance follows the workspace the
|
|
865
|
+
# user switched to. The server honors the injected workspaceRoot
|
|
866
|
+
# unconditionally.
|
|
867
|
+
$bridgeDshPath = New-DshWorkspaceBridge -DshHome $DshHome
|
|
868
|
+
if ($bridgeDshPath) {
|
|
869
|
+
$bridgeUrl = 'file:///' + (($bridgeDshPath -replace '\\', '/').TrimStart('/'))
|
|
870
|
+
$bridgeConfig = " config:`n serverPath: '$argoServer'`n"
|
|
871
|
+
if ($DshWorkspaces) {
|
|
872
|
+
$wsList = @($DshWorkspaces.Replace('\', '/').Split(';') | ForEach-Object { " - $_" }) -join "`n"
|
|
873
|
+
$bridgeConfig += " workspaces:`n" + $wsList + "`n"
|
|
874
|
+
}
|
|
875
|
+
if ($DshCwd) {
|
|
876
|
+
$bridgeConfig += " cwd: $($DshCwd.Replace('\', '/'))`n"
|
|
877
|
+
}
|
|
878
|
+
$rows = " - id: argo-workspace`n name: '$bridgeUrl'`n" + $bridgeConfig
|
|
879
|
+
} else {
|
|
880
|
+
$rows = ''
|
|
881
|
+
}
|
|
882
|
+
if ($wakeupDshPath) {
|
|
883
|
+
$pluginUrl = 'file:///' + (($wakeupDshPath -replace '\\', '/').TrimStart('/'))
|
|
884
|
+
$rows += " - id: argo-wakeup`n name: '$pluginUrl'`n"
|
|
885
|
+
}
|
|
886
|
+
if ($rows) {
|
|
887
|
+
$block = "# BEGIN ArchGraph ARGO deployment (managed by install-argo.ps1)`n- insert:`n" + $rows + "# END ArchGraph ARGO deployment"
|
|
888
|
+
Write-DshManagedBlock -Path $patchPath -Block $block -MarkerStart '# BEGIN ArchGraph ARGO deployment' -MarkerEnd '# END ArchGraph ARGO deployment'
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
Write-Host "[19/22] argo\agents -> $DshHome\.agent-presets\<id> (DeepSeek Harness agent presets)"
|
|
892
|
+
New-DshAgentPresets -DshHome $DshHome -AgentsSrc (Join-Path $argoDir 'agents')
|
|
893
|
+
|
|
894
|
+
Write-Host " note: graph-mcp remote ($GraphMcpUrl) is NOT registered for DeepSeek Harness -"
|
|
895
|
+
Write-Host " ~/.dsh/cordis.patch.yml only carries plugin rows (the dsh-argo-workspace bridge spawns"
|
|
896
|
+
Write-Host " the local argo server); an HTTP remote MCP server has no equivalent cordis row here."
|
|
897
|
+
Write-Host " Restart `dsh web` to activate the MCP bridge and the wakeup plugin;"
|
|
898
|
+
Write-Host ' new sessions pick up the global rule and the argo-init skill automatically.'
|
|
899
|
+
Write-Host ' The argo tools (mcp__argo__*) auto-follow the workspace the user switched to'
|
|
900
|
+
Write-Host ' in one dsh instance - no restart needed between workspaces (the server honors'
|
|
901
|
+
Write-Host ' the injected workspaceRoot unconditionally).'
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
if ($SkipOpenClaw) {
|
|
905
|
+
Write-Host 'Skipped OpenClaw integration (-SkipOpenClaw).'
|
|
906
|
+
} else {
|
|
907
|
+
$ruleSrcContent = Get-Content $ruleSrc -Raw -Encoding UTF8
|
|
908
|
+
$openClawSkillDest = Join-Path $OpenClawHome 'skills\argo-init'
|
|
909
|
+
$openClawAgentsDest = Join-Path $OpenClawWorkspace 'AGENTS.md'
|
|
910
|
+
|
|
911
|
+
Write-Host '==> Deploying OpenClaw integration'
|
|
912
|
+
Write-Host "[20/22] argo\rules\archgraph.instructions.md -> $openClawAgentsDest (OpenClaw workspace AGENTS.md, frontmatter stripped)"
|
|
913
|
+
Write-OpenClawAgentRule -OpenClawWorkspace $OpenClawWorkspace -RuleText $ruleSrcContent
|
|
914
|
+
|
|
915
|
+
Write-Host "[21/22] argo\skills\argo-init -> $openClawSkillDest (OpenClaw managed skill, all agents)"
|
|
916
|
+
Copy-Tree -Source (Join-Path $argoDir 'skills\argo-init') -Destination $openClawSkillDest
|
|
917
|
+
Write-Host ' argo\skills\ea-human-reconcile -> $OpenClawHome\skills\ea-human-reconcile (OpenClaw managed skill, all agents)'
|
|
918
|
+
Copy-Tree -Source (Join-Path $argoDir 'skills\ea-human-reconcile') -Destination (Join-Path (Join-Path $OpenClawHome 'skills') 'ea-human-reconcile')
|
|
919
|
+
Write-Host ' argo\skills\agent-search-diagnosis -> $OpenClawHome\skills\agent-search-diagnosis (OpenClaw managed skill, all agents)'
|
|
920
|
+
Copy-Tree -Source $diagSkillSrc -Destination (Join-Path (Join-Path $OpenClawHome 'skills') 'agent-search-diagnosis')
|
|
921
|
+
|
|
922
|
+
Write-Host ' OpenClaw injects AGENTS.md into Project Context on every session, so the wakeup'
|
|
923
|
+
Write-Host ' gate (UNCONDITIONAL STARTUP GATE) is active on the next OpenClaw session; restart'
|
|
924
|
+
Write-Host ' the OpenClaw gateway (openclaw gateway restart) if it is already running.'
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
if ($SkipDoubao) {
|
|
928
|
+
Write-Host 'Skipped Doubao integration (-SkipDoubao).'
|
|
929
|
+
} else {
|
|
930
|
+
# Doubao (desktop agent mode) skill discovery. Doubao adopts the Anthropic
|
|
931
|
+
# Agent Skills spec and loads user skills from
|
|
932
|
+
# <workspace>/.user_skills/<name>/SKILL.md (per-session workspace root)
|
|
933
|
+
# plus a global user root
|
|
934
|
+
# ~/Doubao/skills/<name>/SKILL.md
|
|
935
|
+
# Doubao exposes no AGENTS.md-equivalent always-on instruction file, so the
|
|
936
|
+
# WakeupGuideline / unconditional startup gate has no hook (skills are the
|
|
937
|
+
# fully ported surface). MCP servers are registered through Doubao's in-app
|
|
938
|
+
# custom connector UI (STDIO), not a config file, so the installer emits a
|
|
939
|
+
# copy-paste connector recipe instead of writing a config.
|
|
940
|
+
$doubaoSkills = @('argo-init', 'ea-human-reconcile', 'agent-search-diagnosis')
|
|
941
|
+
$doubaoSkillsSrc = Join-Path $argoDir 'skills'
|
|
942
|
+
Write-Host '==> Deploying Doubao (desktop agent mode) integration'
|
|
943
|
+
Copy-DoubaoSkills -Root (Join-Path $DoubaoWorkspace '.user_skills') -SourceSkillsRoot $doubaoSkillsSrc -SkillNames $doubaoSkills -Label 'workspace .user_skills'
|
|
944
|
+
Copy-DoubaoSkills -Root (Join-Path $DoubaoHome 'skills') -SourceSkillsRoot $doubaoSkillsSrc -SkillNames $doubaoSkills -Label 'global ~/Doubao/skills'
|
|
945
|
+
# Entry skill: the single-source ARGO rules packaged as a Doubao skill whose
|
|
946
|
+
# always-in-context description states the STEP 0 gate and the mandate to
|
|
947
|
+
# load it before any intent-graph read/write. This is the closest Doubao
|
|
948
|
+
# allows to an always-on rule (skills have no system-prompt hook).
|
|
949
|
+
$doubaoRule = Join-Path $argoDir 'rules\archgraph.instructions.md'
|
|
950
|
+
foreach ($doubaoRoot in @((Join-Path $DoubaoWorkspace '.user_skills'), (Join-Path $DoubaoHome 'skills'))) {
|
|
951
|
+
$entryDir = Join-Path $doubaoRoot 'archgraph-argo'
|
|
952
|
+
New-Item -ItemType Directory -Force -Path $entryDir | Out-Null
|
|
953
|
+
Convert-RuleToSkill -RuleFile $doubaoRule -DestinationFile (Join-Path $entryDir 'SKILL.md')
|
|
954
|
+
Write-Host " entry skill (ARGO rules) -> $(Join-Path $entryDir 'SKILL.md')"
|
|
955
|
+
}
|
|
956
|
+
Write-Host ' Doubao injects each skill''s name + description into context and loads the'
|
|
957
|
+
Write-Host ' body on trigger; new skills are picked up on the next agent session.'
|
|
958
|
+
$doubaoBridgeDir = Join-Path $ArgoRoot 'mcp-bridges'
|
|
959
|
+
Copy-Tree -Source (Join-Path $argoDir 'mcp-bridges') -Destination $doubaoBridgeDir
|
|
960
|
+
$doubaoBridgePath = Join-Path $doubaoBridgeDir 'graph-mcp-stdio.js'
|
|
961
|
+
if (-not (Test-Path $doubaoBridgePath)) { $doubaoBridgePath = '' }
|
|
962
|
+
Write-DoubaoMcpRecipe -RecipePath (Join-Path $ArgoRoot 'doubao-mcp.json') -ArgoServer (Join-Path $ArgoRoot 'scripts\argo-mcp-server.js') -BridgePath $doubaoBridgePath -GraphMcpUrl $GraphMcpUrl
|
|
963
|
+
Write-Host ' the argo connector has no fixed workspace: it follows the workspace you'
|
|
964
|
+
Write-Host ' select in Doubao (MCP roots / connector workingDirectory), like OpenCode/DSH.'
|
|
965
|
+
Write-Host ' note: Doubao has no AGENTS.md-equivalent always-on rule file, so the ARGO'
|
|
966
|
+
Write-Host ' WakeupGuideline / unconditional startup gate is not deployed (no hook).'
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
if ($SkipDeps) {
|
|
970
|
+
Write-Host 'Skipped dependency install (-SkipDeps).'
|
|
971
|
+
} elseif (Get-Command npm -ErrorAction SilentlyContinue) {
|
|
972
|
+
Write-Host "==> Installing Node dependencies in $ArgoRoot"
|
|
973
|
+
$vendorDir = Join-Path $PSScriptRoot 'vendor'
|
|
974
|
+
Push-Location $ArgoRoot
|
|
975
|
+
try {
|
|
976
|
+
$vendorTgzs = @(Get-ChildItem -Path $vendorDir -Filter '*.tgz' -ErrorAction SilentlyContinue)
|
|
977
|
+
if ($vendorTgzs.Count -gt 0) {
|
|
978
|
+
foreach ($tgz in $vendorTgzs) {
|
|
979
|
+
Write-Host " installing bundled $($tgz.Name)"
|
|
980
|
+
npm install --no-save --omit=dev --no-audit --no-fund $tgz.FullName
|
|
981
|
+
if ($LASTEXITCODE -ne 0) {
|
|
982
|
+
throw "npm install $($tgz.Name) failed with exit code $LASTEXITCODE"
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
} else {
|
|
986
|
+
npm install --omit=dev --no-audit --no-fund
|
|
987
|
+
if ($LASTEXITCODE -ne 0) {
|
|
988
|
+
throw "npm install failed with exit code $LASTEXITCODE"
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
} finally {
|
|
992
|
+
Pop-Location
|
|
993
|
+
}
|
|
994
|
+
} else {
|
|
995
|
+
Write-Warning 'npm was not found on PATH; skipped dependency install.'
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
if ($SkipEnv) {
|
|
999
|
+
Write-Host 'Skipped .env generation (-SkipEnv).'
|
|
1000
|
+
} else {
|
|
1001
|
+
$envPath = Join-Path $ArgoRoot '.env'
|
|
1002
|
+
|
|
1003
|
+
# Load existing values so we can skip prompting for variables that already
|
|
1004
|
+
# hold a non-empty value. Missing or empty variables still get prompted.
|
|
1005
|
+
$existing = @{}
|
|
1006
|
+
if (Test-Path $envPath) {
|
|
1007
|
+
foreach ($line in Get-Content $envPath) {
|
|
1008
|
+
$line = $line.Trim()
|
|
1009
|
+
if (-not $line -or $line.StartsWith('#')) { continue }
|
|
1010
|
+
$sep = $line.IndexOf('=')
|
|
1011
|
+
if ($sep -le 0) { continue }
|
|
1012
|
+
$key = $line.Substring(0, $sep).Trim()
|
|
1013
|
+
if ($key) {
|
|
1014
|
+
$existing[$key] = $line.Substring($sep + 1).Trim()
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
Write-Host ''
|
|
1020
|
+
Write-Host '==> Configure .env (existing non-empty values are kept; press Enter to leave a value empty)'
|
|
1021
|
+
$envKeys = @(
|
|
1022
|
+
'ARGO_EMBEDDING_BASE_URL',
|
|
1023
|
+
'ARGO_EMBEDDING_MODEL',
|
|
1024
|
+
'ARGO_EMBEDDING_PROVIDER',
|
|
1025
|
+
'ARGO_EMBEDDING_MODEL_VERSION',
|
|
1026
|
+
'ARGO_EMBEDDING_DIMENSIONS',
|
|
1027
|
+
'ARGO_NEO4J_DATABASE_URL',
|
|
1028
|
+
'ARGO_NEO4J_DATABASE_USERNAME',
|
|
1029
|
+
'ARGO_NEO4J_DATABASE_PASSWORD',
|
|
1030
|
+
'QWEN_KEY',
|
|
1031
|
+
'ARGO_LIVE_PROVIDER_E2E',
|
|
1032
|
+
'ARGO_W31_LIVE_MUTATION_VECTOR_E2E'
|
|
1033
|
+
)
|
|
1034
|
+
|
|
1035
|
+
$lines = @('# Argo live-provider and Neo4j configuration.')
|
|
1036
|
+
foreach ($key in $envKeys) {
|
|
1037
|
+
$existingValue = $null
|
|
1038
|
+
if ($existing.ContainsKey($key)) {
|
|
1039
|
+
$existingValue = $existing[$key]
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
if ($null -ne $existingValue -and -not [string]::IsNullOrWhiteSpace([string]$existingValue)) {
|
|
1043
|
+
$value = $existingValue
|
|
1044
|
+
} else {
|
|
1045
|
+
$value = Read-Host $key
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
$lines += "$key=$value"
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
# Preserve any extra keys already present in .env but not part of the
|
|
1052
|
+
# interactive prompt list (e.g. semantic retrieval tuning: hybrid/rerank/
|
|
1053
|
+
# thresholds). Without this a re-deploy would silently drop them. They are
|
|
1054
|
+
# documented in argo/.env.example.
|
|
1055
|
+
foreach ($key in ($existing.Keys | Sort-Object)) {
|
|
1056
|
+
if ($envKeys -notcontains $key) {
|
|
1057
|
+
$lines += "$key=$($existing[$key])"
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
[System.IO.File]::WriteAllLines(
|
|
1062
|
+
$envPath,
|
|
1063
|
+
$lines,
|
|
1064
|
+
(New-Object System.Text.UTF8Encoding $false)
|
|
1065
|
+
)
|
|
1066
|
+
Write-Host "Wrote $envPath"
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
if ($SkipMcp) {
|
|
1070
|
+
Write-Host 'Skipped MCP configuration (-SkipMcp).'
|
|
1071
|
+
} else {
|
|
1072
|
+
$argoServer = (Join-Path $ArgoRoot 'scripts\argo-mcp-server.js').Replace('\', '/')
|
|
1073
|
+
# graph-mcp is a Streamable HTTP remote MCP endpoint. Its config shape is
|
|
1074
|
+
# HOST-SPECIFIC (each host's mcp.json schema is different):
|
|
1075
|
+
# - OpenCode (opencode.json mcp.<name>): {type: remote, url, enabled}
|
|
1076
|
+
# - Cursor (mcp.json mcpServers.<name>): stdio bridge — Cursor dials
|
|
1077
|
+
# remote url servers over SSE GET /mcp, which the Streamable HTTP
|
|
1078
|
+
# endpoint answers with 404, so graph-mcp is exposed as a local stdio
|
|
1079
|
+
# bridge (graph-mcp-stdio.js) that forwards to the remote over POST.
|
|
1080
|
+
# - VS Code (mcp.json servers.<name>): {type: http, url}
|
|
1081
|
+
# - OpenClaw (openclaw.json mcp.servers.<name>): {url, transport:
|
|
1082
|
+
# streamable-http} — keyed by transport, not by a type alias.
|
|
1083
|
+
# Reusing one uniform {type: remote} entry across hosts is INVALID for
|
|
1084
|
+
# Cursor / VS Code / OpenClaw and makes the server fail to load.
|
|
1085
|
+
$graphMcpOpenCode = [ordered]@{
|
|
1086
|
+
type = 'remote'
|
|
1087
|
+
url = $GraphMcpUrl
|
|
1088
|
+
enabled = $true
|
|
1089
|
+
}
|
|
1090
|
+
$graphMcpBridgePath = (Join-Path $CursorMcpBridgesRoot 'graph-mcp-stdio.js').Replace('\', '/')
|
|
1091
|
+
$graphMcpCursor = [ordered]@{
|
|
1092
|
+
type = 'stdio'
|
|
1093
|
+
command = 'node'
|
|
1094
|
+
args = @($graphMcpBridgePath)
|
|
1095
|
+
env = [ordered]@{
|
|
1096
|
+
GRAPH_MCP_URL = $GraphMcpUrl
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
$graphMcpVSCode = [ordered]@{
|
|
1100
|
+
type = 'http'
|
|
1101
|
+
url = $GraphMcpUrl
|
|
1102
|
+
}
|
|
1103
|
+
$openClawGraphMcpServer = [ordered]@{
|
|
1104
|
+
url = $GraphMcpUrl
|
|
1105
|
+
transport = 'streamable-http'
|
|
1106
|
+
enabled = $true
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
Write-Host '==> Registering argo MCP server in VS Code (GitHub Copilot)'
|
|
1110
|
+
$mcpPath = if ($McpPath) { $McpPath } else { Join-Path $env:APPDATA 'Code\User\mcp.json' }
|
|
1111
|
+
Write-McpConfig -Path $mcpPath -ServersKey 'servers' -ServerConfig ([ordered]@{
|
|
1112
|
+
type = 'stdio'
|
|
1113
|
+
command = 'node'
|
|
1114
|
+
args = @($argoServer)
|
|
1115
|
+
}) -ExtraServers ([ordered]@{ 'graph-mcp' = $graphMcpVSCode })
|
|
1116
|
+
Write-Host "argo MCP config written -> $mcpPath"
|
|
1117
|
+
|
|
1118
|
+
Write-Host '==> Registering argo MCP server in Cursor'
|
|
1119
|
+
Write-McpConfig -Path $CursorMcpPath -ServersKey 'mcpServers' -ServerConfig ([ordered]@{
|
|
1120
|
+
type = 'stdio'
|
|
1121
|
+
command = 'node'
|
|
1122
|
+
args = @($argoServer)
|
|
1123
|
+
}) -ExtraServers ([ordered]@{ 'graph-mcp' = $graphMcpCursor })
|
|
1124
|
+
Write-Host "argo MCP config written -> $CursorMcpPath"
|
|
1125
|
+
Write-Host " graph-mcp registered as stdio bridge -> $graphMcpBridgePath"
|
|
1126
|
+
|
|
1127
|
+
Write-Host '==> Registering argo MCP server in OpenCode'
|
|
1128
|
+
Write-McpConfig -Path $OpenCodeConfigPath -ServersKey 'mcp' -ServerConfig ([ordered]@{
|
|
1129
|
+
type = 'local'
|
|
1130
|
+
command = @('node', $argoServer)
|
|
1131
|
+
enabled = $true
|
|
1132
|
+
}) -ExtraServers ([ordered]@{ 'graph-mcp' = $graphMcpOpenCode })
|
|
1133
|
+
Write-Host "argo MCP config written -> $OpenCodeConfigPath"
|
|
1134
|
+
|
|
1135
|
+
if (-not $SkipOpenClaw) {
|
|
1136
|
+
# The repo root to pin for OpenClaw defaults to the installer's own
|
|
1137
|
+
# location; -OpenClawRepoRoot overrides it (e.g. for tests or when the
|
|
1138
|
+
# installer runs from a non-workspace npm-global package dir).
|
|
1139
|
+
$openClawRepoRoot = if ($OpenClawRepoRoot) { $OpenClawRepoRoot } else { $repoRoot }
|
|
1140
|
+
Write-Host "[22/22] argo MCP server -> $(Join-Path $OpenClawHome 'openclaw.json') (OpenClaw mcp.servers.argo, env.ARGO_REPO_ROOT pinned)"
|
|
1141
|
+
Write-OpenClawMcpConfig -OpenClawHome $OpenClawHome -RepoRoot $openClawRepoRoot -ArgoServer $argoServer -GraphMcpServer $openClawGraphMcpServer
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
$wakeupPluginPath = Join-Path $PluginsRoot 'argo-wakeup.js'
|
|
1146
|
+
if (Test-Path $wakeupPluginPath) {
|
|
1147
|
+
Write-Host '==> Registering argo-wakeup plugin in OpenCode'
|
|
1148
|
+
Register-OpenCodePlugin -ConfigPath $OpenCodeConfigPath -PluginFilePath $wakeupPluginPath
|
|
1149
|
+
Write-Host "argo-wakeup plugin registered -> $OpenCodeConfigPath"
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
# Agent-cost collector: the complete host-side writer of the single consolidated
|
|
1153
|
+
# agent-cost log (<workspace>/.argo/temp/agent-cost-log.ndjson).
|
|
1154
|
+
$costCollectorPath = Join-Path $PluginsRoot 'argo-cost-collector.js'
|
|
1155
|
+
if (Test-Path $costCollectorPath) {
|
|
1156
|
+
Write-Host '==> Registering argo-cost-collector plugin in OpenCode'
|
|
1157
|
+
Register-OpenCodePlugin -ConfigPath $OpenCodeConfigPath -PluginFilePath $costCollectorPath
|
|
1158
|
+
Write-Host "argo-cost-collector plugin registered -> $OpenCodeConfigPath"
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
Write-Host ''
|
|
1162
|
+
Write-Host 'Argo deployment complete.'
|