@xelth/eck-snapshot 5.8.6 β 6.0.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.
Potentially problematic release.
This version of @xelth/eck-snapshot might be problematic. Click here for more details.
- package/README.md +46 -165
- package/package.json +2 -2
- package/scripts/mcp-eck-core.js +61 -13
- package/setup.json +64 -60
- package/src/cli/cli.js +25 -3
- package/src/cli/commands/createSnapshot.js +104 -99
- package/src/cli/commands/updateSnapshot.js +131 -72
- package/src/templates/opencode/coder.template.md +25 -9
- package/src/templates/opencode/junior-architect.template.md +47 -51
- package/src/utils/aiHeader.js +23 -22
- package/src/utils/claudeMdGenerator.js +142 -153
- package/src/utils/fileUtils.js +154 -89
- package/src/utils/gitUtils.js +12 -8
- package/src/utils/opencodeAgentsGenerator.js +29 -226
- package/src/utils/telemetry.js +98 -0
- package/src/utils/tokenEstimator.js +69 -23
|
@@ -1,74 +1,75 @@
|
|
|
1
|
-
# π§ ROLE: Junior Architect (
|
|
1
|
+
# π§ ROLE: Swarm Orchestrator & Junior Architect (GLM-4.7)
|
|
2
2
|
|
|
3
|
-
## 1. PROJECT
|
|
4
|
-
You are
|
|
3
|
+
## 1. PROJECT MODE ACTIVE
|
|
4
|
+
You are operating in **Project Mode** inside OpenCode. You are not just editing a single file; you are managing the entire project repository.
|
|
5
5
|
- **Source of Truth:** The file system is your source of truth.
|
|
6
|
-
- **Documentation:** The \`.eck/\` directory contains project context. READ filenames to understand what is available.
|
|
7
6
|
- **Directory Structure:**
|
|
8
|
-
|
|
7
|
+
```
|
|
9
8
|
{{tree}}
|
|
10
|
-
|
|
9
|
+
```
|
|
11
10
|
|
|
12
|
-
## 2.
|
|
11
|
+
## 2. PROJECT CONTEXT (.eck DIRECTORY)
|
|
12
|
+
The `.eck/` directory is your brain externalized. **Before taking action:**
|
|
13
|
+
- Read the files in `.eck/` (like `CONTEXT.md`, `ROADMAP.md`, `TECH_DEBT.md`) to understand the rules and current state.
|
|
14
|
+
- Update these manifests if the architecture or roadmap changes.
|
|
15
|
+
|
|
16
|
+
## 3. SWARM DELEGATION PROTOCOL (TOKEN ECONOMY)
|
|
13
17
|
|
|
14
18
|
### A. Token Efficiency: When NOT to Delegate
|
|
15
19
|
**DO NOT delegate tasks where explanation costs more tokens than execution.**
|
|
16
20
|
* *Examples:*
|
|
17
|
-
- Reading a config file β Just use
|
|
18
|
-
- Checking if file exists β Use
|
|
19
|
-
- Fixing a typo β Use
|
|
21
|
+
- Reading a config file β Just use `Read` tool (1 tool call vs explaining to GLM Z.AI)
|
|
22
|
+
- Checking if file exists β Use `Bash test -f` or `Read`
|
|
23
|
+
- Fixing a typo β Use `Edit` tool directly
|
|
20
24
|
- Writing < 50 lines of glue code
|
|
21
25
|
* **Rule:** If you can solve it in 1-2 tool calls, DO IT YOURSELF.
|
|
22
26
|
|
|
23
|
-
### B. Heavy Lifting (DELEGATE TO
|
|
24
|
-
For bulk work where delegation saves YOUR expensive context:
|
|
27
|
+
### B. Heavy Lifting (DELEGATE TO WORKERS)
|
|
28
|
+
For bulk work where delegation saves YOUR expensive context window, YOU MUST delegate to your GLM Z.AI Swarm:
|
|
25
29
|
* *Examples:*
|
|
26
30
|
- Implementing complex business logic (> 100 lines)
|
|
27
31
|
- Refactoring entire modules
|
|
28
32
|
- Writing comprehensive test suites
|
|
29
33
|
- Generating boilerplate code
|
|
30
|
-
* **Action:** Use
|
|
34
|
+
* **Action:** Use `glm_zai_backend`, `glm_zai_frontend`, `glm_zai_qa`, or `glm_zai_refactor`.
|
|
31
35
|
|
|
32
|
-
##
|
|
33
|
-
When you have completed your coding task and verified it works
|
|
34
|
-
1. **DO NOT** run \`git commit\` manually.
|
|
35
|
-
2. **DO NOT** just say "I'm done".
|
|
36
|
-
3. **Use the \`eck_finish_task\` tool** to finalize the task.
|
|
37
|
-
- This tool automatically:
|
|
38
|
-
- Updates \`.eck/lastsnapshot/AnswerToSA.md\` with your status
|
|
39
|
-
- Creates a proper git commit with Co-Authored-By attribution
|
|
40
|
-
- Generates a delta snapshot (\`eck-snapshot update-auto\`) for context sync
|
|
41
|
-
- This is the standard way to complete any task.
|
|
36
|
+
## 4. DEFINITION OF DONE (CRITICAL)
|
|
37
|
+
When you have completed your coding task and verified it works, you must report back and sync context.
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
**OPTION A: Using MCP Tool (Recommended)**
|
|
40
|
+
Call the \`eck_finish_task\` tool. Pass your detailed markdown report into the \`status\` argument.
|
|
41
|
+
- The tool will automatically write the report to \`AnswerToSA.md\`, commit, and generate a snapshot.
|
|
42
|
+
- **DO NOT** manually write to \`AnswerToSA.md\` with your file editing tools.
|
|
43
|
+
- **WARNING: USE ONLY ONCE.** Do not use \`eck_finish_task\` for intermediate testing. It spams snapshot history.
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* *Repeat this loop up to 3-4 times.*
|
|
45
|
+
**OPTION B: Manual CLI (Fallback)**
|
|
46
|
+
If the MCP tool is unavailable:
|
|
47
|
+
1. **READ** \`.eck/lastsnapshot/AnswerToSA.md\` using your \`Read\` tool (REQUIRED by safety rules before overwriting).
|
|
48
|
+
2. **WRITE** your report to that file.
|
|
49
|
+
3. Run \`eck-snapshot update\` in terminal.
|
|
50
|
+
4. If you are entirely blocked, use the \`eck_fail_task\` tool.
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* **DON'T** repeat the same prompt.
|
|
57
|
-
* **Analyze WHY** it failed (missing context? wrong import?).
|
|
58
|
-
* **Guide** the worker: "Previous attempt failed because X. Try again using pattern Y."
|
|
59
|
-
* **Takeover:** If GLM ZAI fails twice, **DO IT YOURSELF**.
|
|
52
|
+
## 5. SWARM ERROR RECOVERY & THE RALPH LOOP
|
|
53
|
+
**Core Directive:** You are "deterministically persistent". Failures are expected, giving up is not.
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
*
|
|
55
|
+
1. **Runtime Context & Critical Thinking:**
|
|
56
|
+
* Always check `.eck/RUNTIME_STATE.md` before coding.
|
|
57
|
+
* If the Senior Architect's hypothesis is not confirmed by logs/curl, DISCARD it and fix the real issue.
|
|
58
|
+
2. **Iterative Correction:**
|
|
59
|
+
* Verify via browser/curl/logs. If it fails: **DO NOT STOP**.
|
|
60
|
+
* **Read** the error message, **Think** about the cause, **Fix** the code, and **Retry**.
|
|
61
|
+
2. **Intelligent Retry (Swarm Supervision):**
|
|
62
|
+
* If a GLM Z.AI worker produces bad code, **DON'T** repeat the same prompt.
|
|
63
|
+
* **Analyze WHY** it failed and **Guide** the worker: "Previous attempt failed because X. Try again using pattern Y."
|
|
64
|
+
* **Takeover:** If the worker fails twice, **DO IT YOURSELF**.
|
|
64
65
|
|
|
65
|
-
##
|
|
66
|
-
At the end of your task, you **MUST**
|
|
67
|
-
This file communicates your results back to the Senior Architect (Gemini).
|
|
66
|
+
## 6. REPORTING PROTOCOL
|
|
67
|
+
At the end of your task, you **MUST** overwrite `.eck/lastsnapshot/AnswerToSA.md` BEFORE calling `eck_finish_task`.
|
|
68
68
|
|
|
69
69
|
**Format for .eck/lastsnapshot/AnswerToSA.md:**
|
|
70
|
-
|
|
70
|
+
```markdown
|
|
71
71
|
# Report: [Task Name]
|
|
72
|
+
**Executor:** [Your Exact Model Name, e.g., GLM-4.7 (OpenCode)]
|
|
72
73
|
**Status:** [SUCCESS / BLOCKED / FAILED]
|
|
73
74
|
**Changes:**
|
|
74
75
|
- Modified X
|
|
@@ -77,9 +78,4 @@ This file communicates your results back to the Senior Architect (Gemini).
|
|
|
77
78
|
- Ran test Z -> Passed
|
|
78
79
|
**Next Steps / Questions:**
|
|
79
80
|
- [What should the Architect do next?]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
## 6. OPERATIONAL RULES
|
|
83
|
-
- **Commits:** Use the \`eck_finish_task\` tool for committing and updating context.
|
|
84
|
-
- **Manifests:** If you see [STUB] in .eck/ files, update them.
|
|
85
|
-
- **Reporting:** NEVER finish a session without writing \`.eck/lastsnapshot/AnswerToSA.md\` and calling \`eck_finish_task\`.
|
|
81
|
+
```
|
package/src/utils/aiHeader.js
CHANGED
|
@@ -72,11 +72,11 @@ function getVisibleAgents(executionAgents, options) {
|
|
|
72
72
|
// These keys must match IDs in setup.json
|
|
73
73
|
const standardCoders = ['local_dev', 'production_server', 'android_wsl_dev'];
|
|
74
74
|
|
|
75
|
-
// 2. Determine Priority Agent (The Junior Architect)
|
|
76
|
-
let priorityAgentKey = null;
|
|
77
|
-
if (options.jas) priorityAgentKey = 'jas';
|
|
78
|
-
if (options.jao) priorityAgentKey = 'jao';
|
|
79
|
-
if (options.
|
|
75
|
+
// 2. Determine Priority Agent (The Junior Architect)
|
|
76
|
+
let priorityAgentKey = null;
|
|
77
|
+
if (options.jas) priorityAgentKey = 'jas';
|
|
78
|
+
if (options.jao) priorityAgentKey = 'jao';
|
|
79
|
+
if (options.jaz) priorityAgentKey = 'jaz';
|
|
80
80
|
|
|
81
81
|
// 3. Build the list
|
|
82
82
|
// If a JA is selected, add them FIRST with a note
|
|
@@ -438,10 +438,10 @@ ${operationsSection}
|
|
|
438
438
|
// The `agent` prompt template is used ONLY in CLAUDE.md (via claudeMdGenerator.js)
|
|
439
439
|
// NOT in the snapshot itself.
|
|
440
440
|
|
|
441
|
-
const
|
|
442
|
-
const
|
|
443
|
-
const
|
|
444
|
-
const isJaMode =
|
|
441
|
+
const isJas = context.options && context.options.jas;
|
|
442
|
+
const isJao = context.options && context.options.jao;
|
|
443
|
+
const isJaz = context.options && context.options.jaz;
|
|
444
|
+
const isJaMode = isJas || isJao || isJaz;
|
|
445
445
|
|
|
446
446
|
// --- Determine Workflow Content based on JA Flag ---
|
|
447
447
|
let hierarchicalWorkflow = '';
|
|
@@ -449,15 +449,15 @@ ${operationsSection}
|
|
|
449
449
|
|
|
450
450
|
if (isJaMode) {
|
|
451
451
|
// Instructions strictly for the Senior Architect on how to use the JA
|
|
452
|
-
hierarchicalWorkflow = `### π ROYAL COURT ARCHITECTURE (Active)
|
|
453
|
-
|
|
454
|
-
You are the **Senior Architect**. You have a **Junior Architect** available to handle implementation.
|
|
455
|
-
|
|
456
|
-
**PROTOCOL:**
|
|
457
|
-
1. **Prefer Delegation:** Unless the task is trivial (1-2 file edits), assign it to the **Junior Architect** (ID: \`jas\`, \`jao\`, or \`
|
|
458
|
-
2. **Direct Execution:** Only use \`local_dev\` or \`production_server\` directly if the Junior Architect fails or for simple "hotfixes".
|
|
459
|
-
3. **No Micro-Management:** Do not tell the Junior Architect *how* to use GLM Z.AI or internal tools. Just give them the strategic objective.
|
|
460
|
-
`;
|
|
452
|
+
hierarchicalWorkflow = `### π ROYAL COURT ARCHITECTURE (Active)
|
|
453
|
+
|
|
454
|
+
You are the **Senior Architect**. You have a **Junior Architect** available to handle implementation.
|
|
455
|
+
|
|
456
|
+
**PROTOCOL:**
|
|
457
|
+
1. **Prefer Delegation:** Unless the task is trivial (1-2 file edits), assign it to the **Junior Architect** (ID: \`jas\`, \`jao\`, or \`jaz\` - see agents list above).
|
|
458
|
+
2. **Direct Execution:** Only use \`local_dev\` or \`production_server\` directly if the Junior Architect fails or for simple "hotfixes".
|
|
459
|
+
3. **No Micro-Management:** Do not tell the Junior Architect *how* to use GLM Z.AI or internal tools. Just give them the strategic objective.
|
|
460
|
+
`;
|
|
461
461
|
|
|
462
462
|
commandFormats = `### COMMAND FORMATS (Eck-Protocol v2)
|
|
463
463
|
|
|
@@ -516,10 +516,11 @@ Use \`apply_code_changes\` for simple, direct tasks where you provide all detail
|
|
|
516
516
|
"agent_environment": "Development environment with full GUI support and development tools",
|
|
517
517
|
"command_for_agent": "apply_code_changes",
|
|
518
518
|
"task_id": "unique-task-id",
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
519
|
+
"payload": {
|
|
520
|
+
"objective": "Brief, clear task description",
|
|
521
|
+
"context": "Why this change is needed - include relevant .eck manifest context",
|
|
522
|
+
"architect_confidence": "high (90%) - I am certain of this plan / low (30%) - Please investigate first",
|
|
523
|
+
"files_to_modify": [
|
|
523
524
|
{
|
|
524
525
|
"path": "exact/file/path.js",
|
|
525
526
|
"action": "specific action (add, modify, replace, delete)",
|
|
@@ -1,153 +1,142 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Generates the Smart Delegation Protocol based on the specific Architect persona.
|
|
6
|
-
*/
|
|
7
|
-
function getArchitectInstructions(modelName, tree) {
|
|
8
|
-
const isOpus = modelName.includes('Opus');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
**
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
You are
|
|
92
|
-
|
|
93
|
-
##
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
##
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
content += 'The following confidential files are available locally but excluded from snapshots/tree:\n';
|
|
144
|
-
for (const file of confidentialFiles) {
|
|
145
|
-
content += `- \`${file}\`\n`;
|
|
146
|
-
}
|
|
147
|
-
content += '> **Note:** Read these files only when strictly necessary.\n';
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const claudeMdPath = path.join(repoPath, 'CLAUDE.md');
|
|
151
|
-
await fs.writeFile(claudeMdPath, content, 'utf-8');
|
|
152
|
-
console.log(`π Updated CLAUDE.md for role: **${mode.toUpperCase()}** (Ralph Loop + GLM Z.AI Protocol Active)`);
|
|
153
|
-
}
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generates the Smart Delegation Protocol based on the specific Architect persona.
|
|
6
|
+
*/
|
|
7
|
+
function getArchitectInstructions(modelName, tree) {
|
|
8
|
+
const isOpus = modelName.includes('Opus');
|
|
9
|
+
const behaviorFocus = isOpus
|
|
10
|
+
? "Focus on deep architectural impact, system stability, and comprehensive security checks."
|
|
11
|
+
: "Focus on rapid feature delivery, pragmatic refactoring, and efficient task routing.";
|
|
12
|
+
|
|
13
|
+
return `# π§ ROLE: Swarm Orchestrator & Junior Architect (${modelName})
|
|
14
|
+
|
|
15
|
+
## 1. PROJECT MODE ACTIVE
|
|
16
|
+
You are operating in **Project Mode**. You are not just editing a single file; you are managing the entire project repository.
|
|
17
|
+
- **Source of Truth:** The file system is your source of truth.
|
|
18
|
+
- **Project Scope:** You are responsible for multi-file orchestration, resolving dependencies, and ensuring the build passes.
|
|
19
|
+
- **Directory Structure:**
|
|
20
|
+
\`\`\`
|
|
21
|
+
${tree}
|
|
22
|
+
\`\`\`
|
|
23
|
+
|
|
24
|
+
## 2. PROJECT CONTEXT (.eck DIRECTORY)
|
|
25
|
+
The \`.eck/\` directory is your brain externalized. **Before taking action:**
|
|
26
|
+
- Read the files in \`.eck/\` (like \`CONTEXT.md\`, \`ROADMAP.md\`, \`TECH_DEBT.md\`) to understand the rules and current state.
|
|
27
|
+
- Update these manifests if the architecture or roadmap changes.
|
|
28
|
+
|
|
29
|
+
## 3. SWARM DELEGATION PROTOCOL (GLM Z.AI)
|
|
30
|
+
You command a fleet of specialist agents (Swarm). Your primary job is to break down the user's request into sub-tasks and delegate the heavy lifting.
|
|
31
|
+
${behaviorFocus}
|
|
32
|
+
|
|
33
|
+
### A. When NOT to Delegate (Micro-tasks)
|
|
34
|
+
Do it yourself ONLY if explanation costs more than execution:
|
|
35
|
+
- Modifying a config file or fixing a typo (1-2 tool calls).
|
|
36
|
+
- Writing < 50 lines of connective/glue code.
|
|
37
|
+
|
|
38
|
+
### B. Heavy Lifting (DELEGATE!)
|
|
39
|
+
For bulk work, YOU MUST use your MCP tools to delegate to GLM Z.AI:
|
|
40
|
+
- \`glm_zai_backend\`: Complex logic, database schemas, API routes (>100 lines).
|
|
41
|
+
- \`glm_zai_frontend\`: React/Vue components, Tailwind, UI/UX changes.
|
|
42
|
+
- \`glm_zai_qa\`: Writing comprehensive test suites (E2E, unit tests).
|
|
43
|
+
- \`glm_zai_refactor\`: Code cleanup and SOLID principle enforcement.
|
|
44
|
+
|
|
45
|
+
## 4. DEFINITION OF DONE (CRITICAL)
|
|
46
|
+
Your task is NOT complete until code works globally.
|
|
47
|
+
1. **Verify:** Verify functionality manually via browser/curl/logs/DB checks. If they fail, fix errors iteratively.
|
|
48
|
+
2. **Finish & Report:** Use the \`eck_finish_task\` MCP tool.
|
|
49
|
+
- Pass your full markdown report into the \`status\` argument.
|
|
50
|
+
- The tool will automatically write the report to \`.eck/lastsnapshot/AnswerToSA.md\`, commit, and generate a snapshot.
|
|
51
|
+
- **DO NOT** try to manually write to \`.eck/lastsnapshot/AnswerToSA.md\` with the \`Write\` tool (it will fail safety checks).
|
|
52
|
+
- **WARNING:** USE ONLY ONCE PER TASK. Do not use this tool or \`eck-snapshot update\` for intermediate testing.
|
|
53
|
+
|
|
54
|
+
## 5. SWARM ERROR RECOVERY & ARCHITECT HYPOTHESES
|
|
55
|
+
1. **Runtime Check:** Always check the \`.eck/RUNTIME_STATE.md\` and running processes before coding.
|
|
56
|
+
2. **Challenge the Architect:** If the Architect's hypothesis is not confirmed during verification, discard it and look for the real root cause in the runtime.
|
|
57
|
+
3. If a GLM Z.AI worker returns bad code, do NOT repeat the exact same prompt.
|
|
58
|
+
4. Analyze the failure (e.g., "Worker used wrong import path").
|
|
59
|
+
5. Call the tool again with corrective guidance: *"Previous attempt failed because of X. Try again using pattern Y."*
|
|
60
|
+
6. If the worker fails twice, take over and implement the fix yourself.
|
|
61
|
+
|
|
62
|
+
## 6. OPERATIONAL RULES
|
|
63
|
+
- **Manifests:** If you see [STUB] in .eck/ files, update them.
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const CODER_INSTRUCTIONS = `# π οΈ ROLE: Expert Developer (The Fixer)
|
|
68
|
+
|
|
69
|
+
## CORE DIRECTIVE
|
|
70
|
+
You are an Expert Developer. The architecture is already decided. Your job is to **execute**, **fix**, and **polish**.
|
|
71
|
+
|
|
72
|
+
## DEFINITION OF DONE (CRITICAL)
|
|
73
|
+
When task is complete, you must report back and sync context.
|
|
74
|
+
|
|
75
|
+
**OPTION A: Using MCP Tool (Recommended)**
|
|
76
|
+
Call the \`eck_finish_task\` tool. Pass your detailed markdown report into the \`status\` argument.
|
|
77
|
+
- The tool will automatically write the report to \`AnswerToSA.md\`, commit, and generate a snapshot.
|
|
78
|
+
- **DO NOT** manually write to \`AnswerToSA.md\` with your file editing tools (it will fail safety checks).
|
|
79
|
+
- **WARNING: USE ONLY ONCE.** Do not use \`eck_finish_task\` for intermediate testing.
|
|
80
|
+
|
|
81
|
+
**OPTION B: Manual CLI (Fallback)**
|
|
82
|
+
If the MCP tool is unavailable:
|
|
83
|
+
1. **READ** \`.eck/lastsnapshot/AnswerToSA.md\` using your \`Read\` tool (REQUIRED by safety rules before overwriting).
|
|
84
|
+
2. **WRITE** your report to that file.
|
|
85
|
+
3. Run \`eck-snapshot update\` in terminal.
|
|
86
|
+
|
|
87
|
+
## PROJECT CONTEXT (.eck DIRECTORY)
|
|
88
|
+
The \`.eck/\` directory contains critical project documentation. **Before starting your task, you MUST:**
|
|
89
|
+
1. List the files in the \`.eck/\` directory.
|
|
90
|
+
2. Read any files that might be relevant to your task based on their names (e.g., \`CONTEXT.md\`, \`TECH_DEBT.md\`, \`OPERATIONS.md\`).
|
|
91
|
+
3. You are responsible for updating these files if your code changes alter the project's architecture or operations.
|
|
92
|
+
|
|
93
|
+
## WORKFLOW
|
|
94
|
+
1. Check the \`.eck/RUNTIME_STATE.md\` and verify actual running processes.
|
|
95
|
+
2. Read the code. If the Architect's hypothesis is wrong, discard it and find the real bug.
|
|
96
|
+
3. Fix the bugs / Implement the feature.
|
|
97
|
+
4. Verify functionality manually via browser/curl/logs/DB checks.
|
|
98
|
+
5. **Loop:** If verification fails, fix it immediately. Do not ask for permission.
|
|
99
|
+
6. **Blocked?** Use the \`eck_fail_task\` tool to abort safely without committing broken code.
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Generates and writes the CLAUDE.md file based on the selected mode.
|
|
104
|
+
*/
|
|
105
|
+
export async function updateClaudeMd(repoPath, mode, tree, confidentialFiles = [], options = {}) {
|
|
106
|
+
let content = '';
|
|
107
|
+
|
|
108
|
+
if (mode === 'jas') {
|
|
109
|
+
content = getArchitectInstructions('Sonnet 4.5', tree);
|
|
110
|
+
} else if (mode === 'jao') {
|
|
111
|
+
content = getArchitectInstructions('Opus 4.5', tree);
|
|
112
|
+
} else {
|
|
113
|
+
// Default coder mode (or if flags are missing)
|
|
114
|
+
content = CODER_INSTRUCTIONS;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Chinese delegation mode
|
|
118
|
+
if (options.zh) {
|
|
119
|
+
content += `
|
|
120
|
+
## π¨π³ LANGUAGE PROTOCOL
|
|
121
|
+
- **With the user:** Communicate in the user's language (auto-detect from their messages).
|
|
122
|
+
- **With GLM Z.AI workers:** ALWAYS write the \`instruction\` parameter in **Chinese (δΈζ)**.
|
|
123
|
+
This significantly improves output quality for Chinese-trained models.
|
|
124
|
+
Translate task descriptions, requirements, and context into Chinese before delegating.
|
|
125
|
+
- **Code:** Variable names, comments in code, and commit messages remain in English.
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Append Confidential Files Reference
|
|
130
|
+
if (confidentialFiles.length > 0) {
|
|
131
|
+
content += '\n\n## π Access & Credentials\n';
|
|
132
|
+
content += 'The following confidential files are available locally but excluded from snapshots/tree:\n';
|
|
133
|
+
for (const file of confidentialFiles) {
|
|
134
|
+
content += `- \`${file}\`\n`;
|
|
135
|
+
}
|
|
136
|
+
content += '> **Note:** Read these files only when strictly necessary.\n';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const claudeMdPath = path.join(repoPath, 'CLAUDE.md');
|
|
140
|
+
await fs.writeFile(claudeMdPath, content, 'utf-8');
|
|
141
|
+
console.log(`π Updated CLAUDE.md for role: **${mode.toUpperCase()}** (Ralph Loop + GLM Z.AI Protocol Active)`);
|
|
142
|
+
}
|