archgraph-argo 0.17.0 → 0.17.1

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 (2) hide show
  1. package/install-argo.ps1 +32 -6
  2. package/package.json +1 -1
package/install-argo.ps1 CHANGED
@@ -215,6 +215,30 @@ function Register-OpenCodePlugin {
215
215
  [System.IO.File]::WriteAllText($ConfigPath, $json, (New-Object System.Text.UTF8Encoding $false))
216
216
  }
217
217
 
218
+ function Get-ArchGraphRuleBlockEndIndex {
219
+ # Locate the end of a previously merged ArchGraph rule block. The rule's
220
+ # final section tag changed over versions: earlier rules ended with
221
+ # </ToolsGuideline>, the current layout ends with </Attention> and places
222
+ # <ToolsGuideline> earlier. Pick whichever final tag occurs LAST at/after
223
+ # the block marker, so the merge stays correct across rule reorderings and
224
+ # also repairs a previously duplicated tail.
225
+ param([string]$Text, [int]$From)
226
+ $idx = -1
227
+ foreach ($tag in @('</ToolsGuideline>', '</Attention>')) {
228
+ $i = $Text.LastIndexOf($tag)
229
+ if ($i -ge $From -and $i -gt $idx) { $idx = $i }
230
+ }
231
+ return $idx
232
+ }
233
+
234
+ function Get-ArchGraphRuleBlockEndTagLength {
235
+ param([string]$Text, [int]$Index)
236
+ if ($Index -lt 0) { return 0 }
237
+ if ($Text.Substring($Index).StartsWith('</ToolsGuideline>')) { return '</ToolsGuideline>'.Length }
238
+ if ($Text.Substring($Index).StartsWith('</Attention>')) { return '</Attention>'.Length }
239
+ return 0
240
+ }
241
+
218
242
  function Add-AgentsRule {
219
243
  param(
220
244
  [string]$AgentsPath,
@@ -231,18 +255,18 @@ function Add-AgentsRule {
231
255
  # An existing ArchGraph rules block is present. Replace it with the
232
256
  # current rule content while preserving any unrelated content that
233
257
  # surrounds it (e.g. user-authored OpenCode instructions).
234
- $endTag = '</ToolsGuideline>'
235
258
  $markerIdx = $existing.IndexOf($marker)
236
259
  if ($markerIdx -lt 0) { $markerIdx = 0 }
237
260
  $startIdx = $existing.LastIndexOf('---', $markerIdx)
238
261
  if ($startIdx -lt 0) { $startIdx = 0 }
239
- $endIdx = $existing.IndexOf($endTag, $markerIdx)
262
+ $endIdx = Get-ArchGraphRuleBlockEndIndex -Text $existing -From $markerIdx
240
263
 
241
264
  $before = $existing.Substring(0, $startIdx).TrimEnd()
242
265
  if ($endIdx -lt 0) {
243
266
  $combined = $ruleContent
244
267
  } else {
245
- $after = $existing.Substring($endIdx + $endTag.Length)
268
+ $endLen = Get-ArchGraphRuleBlockEndTagLength -Text $existing -Index $endIdx
269
+ $after = $existing.Substring($endIdx + $endLen)
246
270
  $combined = $before
247
271
  if ($combined.Length -gt 0) { $combined += "`n`n" }
248
272
  $combined += $ruleContent
@@ -301,13 +325,15 @@ function Write-ArchGraphRuleBlock {
301
325
  if (Test-Path $DestPath) {
302
326
  $existing = Get-Content $DestPath -Raw -Encoding UTF8
303
327
  if ($existing -like "*$marker*") {
304
- $endTag = '</ToolsGuideline>'
305
328
  $startIdx = $existing.IndexOf($marker)
306
329
  if ($startIdx -lt 0) { $startIdx = 0 }
307
- $endIdx = $existing.IndexOf($endTag, $startIdx)
330
+ $endIdx = Get-ArchGraphRuleBlockEndIndex -Text $existing -From $startIdx
308
331
  $before = $existing.Substring(0, $startIdx).TrimEnd()
309
332
  $after = ''
310
- if ($endIdx -ge 0) { $after = $existing.Substring($endIdx + $endTag.Length).TrimStart() }
333
+ if ($endIdx -ge 0) {
334
+ $endLen = Get-ArchGraphRuleBlockEndTagLength -Text $existing -Index $endIdx
335
+ $after = $existing.Substring($endIdx + $endLen).TrimStart()
336
+ }
311
337
  $combined = $before
312
338
  if ($combined.Length -gt 0) { $combined += "`n`n" }
313
339
  $combined += $ruleContent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archgraph-argo",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
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": {