Skip to content

fix(rules): give ZCode, DeepSeek Harness and JoyCode the instruction blocks in their user rules file - #1031

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
SaulMoro:fix/1029-user-instruction-files
Oct 12, 2026
Merged

jeff-r2026 merged 2 commits into
Tencent:mainfrom
SaulMoro:fix/1029-user-instruction-files

Conversation

@SaulMoro

@SaulMoro SaulMoro commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1029.

Summary

In user scope, ZCode, DeepSeek Harness and JoyCode had a team-rules file but no instruction target. As a result, a team claudemd that named that file counted as retired, and pull cleaned it on every run. Now each of the three reads the culture, shared-instructions and recall blocks from the same file as its team rules, as Codex, Pi and OpenClaw already do.

 USER_TARGETS (src/instruction-targets.ts)
-  zcode:   { file: () => undefined, teamRules: { label, file: () => '.zcode/AGENTS.md' } }
+  zcode:   { file: () => '.zcode/AGENTS.md', teamRules: { label } }
-  dsh:     { file: () => undefined, teamRules: { label, file: dshAgentsMd } }
+  dsh:     { file: dshAgentsMd, teamRules: { label } }
-  joycode: { file: () => undefined, teamRules: { label, file: () => '.joycode/rules.txt' } }
+  joycode: { file: () => '.joycode/rules.txt', teamRules: { label } }
 retiredInstructionFiles(tool)      // claudemd counts as retired when it is not the current target
-  zcode current = undefined   → claudemd '.zcode/AGENTS.md' retired → pull strips/deletes it
+  zcode current = .zcode/AGENTS.md → same file is the target; any other claudemd is still retired

No setter remains for teamRules.file, so the field is removed. The Windows ZCode hook-output problem raised in the issue is tracked separately in #1030. Docs (en + zh-CN) and CHANGELOG are updated.

Evidence

Unit: src/__tests__/instruction-targets.test.ts, a new (#1029) describe block:

for each tool that reads team rules from a file of its own (derived via readsTeamRulesFromFile):
  for claudemd in [default, the team-rules file]:
    expect the tool's only instruction target == its team-rules file
    expect stale ∌ team-rules file
for zcode, dsh, joycode: a claudemd naming another file → still the team-rules file as target, other file stale
  • Before: zcode, dsh and joycode fail with claudemd: undefined: expected [] to deeply equal [ Array(1) ]. Codex, Pi and OpenClaw pass.
  • After (original PR head): npx vitest run passes (8472 passed, 19 skipped). npx tsc --noEmit and npm run lint pass.

After merging origin/main (head dccdba92): npx tsc --noEmit, npm run lint, and npm run build pass. npx vitest run passes (401 test files passed, 1 skipped; 8622 tests passed, 19 skipped).

Real CLI after merge (isolated HOME, local team repo, user scope; ZCode, DeepSeek Harness and JoyCode enabled): teamai pull --force exited 0, synced one rule, and the rule marker was present in all three user rules files.

- [user] Pulling team repo...
✔ [user] Team repo: already up to date
✔ [user] Synced 1 rule(s)
exit: 0
verified: .zcode/AGENTS.md
verified: .dsh/AGENTS.md
verified: .joycode/rules.txt

Real CLI (macOS, user scope, isolated HOME, local bare team repo, --agent zcode). The team has claudemd/harness-rules.md and rules/small-diffs.md, and its toolPaths.zcode is the issue's table with claudemd: '.zcode/AGENTS.md'. Sequence: init → pull --force → doctor → pull.

  • Before (published 0.27.0):
    ℹ [user] Removed teamai instruction blocks from <sb>/home/.zcode/AGENTS.md: replacement instructions are ready
    ~/.zcode/AGENTS.md: (missing)                      # after init, pull --force and pull
      ✖ Team rules are inlined in ZCode AGENTS.md
        → <sb>/home/.zcode/AGENTS.md carries no team-rules block, so zcode reads none of the team rules.
    
    With the default toolPaths, 0.27.0 writes only [teamai:team-rules] to the file. The shared instructions never reach ZCode.
  • After (this branch, npm run build), with both the issue's toolPaths and the defaults:
    ✔ [user] Synced shared instructions (1 file(s))
    ~/.zcode/AGENTS.md: [teamai:team-rules:start] TEAM-RULE [teamai:claudemd:start] HARNESS-INSTRUCTION   # after every step
      ✔ Team rules are inlined in ZCode AGENTS.md
      ✔ Team instructions are current for zcode
      ✔ No team instruction blocks are left in files no tool loads them from
    ✔ All checks passed!
    

Not checked:

  • DeepSeek Harness and JoyCode were not run through the real CLI; the unit test covers them.
  • No ZCode, dsh or JoyCode session was run to confirm the tool loads the blocks. The docs mark these rows unverified.
  • JoyCode's rules.txt gets the same marker-delimited markdown its team-rules block already uses. I could not check whether JoyCode limits that file's size.
  • Windows, and providers other than git, are left to CI.

Merge Danger

Door: two-way

Reverting the commit restores the 0.27.0 targets. A later pull on the older build removes the instruction blocks, the same cleanup that #1029 reports.

Blast Radius: user-scope

  • The first pull after upgrading adds the culture, shared-instructions and recall blocks to ~/.zcode/AGENTS.md, $DSH_HOME/AGENTS.md and ~/.joycode/rules.txt for every member with those tools installed. Content outside the markers is kept.
  • If a team toolPaths points one of these tools' claudemd at another file, pull removes teamai's blocks from that file.
  • teamai uninstall now treats these three files the way it treats Hermes' and OpenClaw's fixed files: a file that holds only teamai blocks is deleted, even if git tracks it.
  • Project scope is unchanged.

…blocks in their user rules file (Tencent#1029)

Tencent#957 gave these tools a user-scope team-rules file but no instruction
target, so a configured claudemd naming that file counted as retired:
pull stripped or deleted the file each run and doctor flagged it.
They now read culture, shared instructions and recall from the same
file as their team rules, as Codex, Pi and OpenClaw do.
@jeff-r2026 jeff-r2026 self-assigned this Oct 11, 2026
@github-actions

Copy link
Copy Markdown

No findings.

The PR description includes sufficient testing: unit, type-check, lint, and a representative real-CLI ZCode verification for this runtime behavior change. I did not run any PR code, per instructions.

@github-actions

Copy link
Copy Markdown

No findings.

The PR description documents sufficient testing for this runtime behavior change, including unit, type-check, lint, build, and representative real-CLI verification. The untested DeepSeek Harness/JoyCode and additional provider/platform coverage are explicitly disclosed and do not warrant a finding.

I did not run or install PR code, per instructions.

@jeff-r2026
jeff-r2026 merged commit 0ee15d6 into Tencent:main Oct 12, 2026
14 checks passed
@SaulMoro
SaulMoro deleted the fix/1029-user-instruction-files branch October 12, 2026 06:22
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…blocks in their user rules file (Tencent#1029) (Tencent#1031)

Tencent#957 gave these tools a user-scope team-rules file but no instruction
target, so a configured claudemd naming that file counted as retired:
pull stripped or deleted the file each run and doctor flagged it.
They now read culture, shared instructions and recall from the same
file as their team rules, as Codex, Pi and OpenClaw do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] ZCode user-scope rules dropped: pull deletes ~/.zcode/AGENTS.md though ZCode loads it as its user instruction file

2 participants