@xelth/eck-snapshot 5.9.0 → 6.4.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.
Potentially problematic release.
This version of @xelth/eck-snapshot might be problematic. Click here for more details.
- package/README.md +267 -190
- package/package.json +15 -2
- package/scripts/mcp-eck-core.js +61 -13
- package/setup.json +119 -81
- package/src/cli/cli.js +235 -385
- package/src/cli/commands/createSnapshot.js +336 -122
- package/src/cli/commands/recon.js +244 -0
- package/src/cli/commands/setupMcp.js +278 -19
- package/src/cli/commands/trainTokens.js +42 -32
- package/src/cli/commands/updateSnapshot.js +128 -76
- package/src/core/depthConfig.js +54 -0
- package/src/core/skeletonizer.js +71 -18
- package/src/templates/architect-prompt.template.md +34 -0
- package/src/templates/multiAgent.md +43 -10
- package/src/templates/opencode/coder.template.md +44 -17
- package/src/templates/opencode/junior-architect.template.md +45 -15
- package/src/templates/skeleton-instruction.md +1 -1
- package/src/utils/aiHeader.js +57 -27
- package/src/utils/claudeMdGenerator.js +136 -78
- package/src/utils/fileUtils.js +1023 -1016
- package/src/utils/gitUtils.js +12 -8
- package/src/utils/opencodeAgentsGenerator.js +8 -2
- package/src/utils/projectDetector.js +66 -21
- package/src/utils/tokenEstimator.js +11 -7
- package/src/cli/commands/consilium.js +0 -86
- package/src/cli/commands/detectProfiles.js +0 -98
- package/src/cli/commands/envSync.js +0 -319
- package/src/cli/commands/generateProfileGuide.js +0 -144
- package/src/cli/commands/pruneSnapshot.js +0 -106
- package/src/cli/commands/restoreSnapshot.js +0 -173
- package/src/cli/commands/setupGemini.js +0 -149
- package/src/cli/commands/setupGemini.test.js +0 -115
- package/src/cli/commands/showFile.js +0 -39
- package/src/services/claudeCliService.js +0 -626
- package/src/services/claudeCliService.test.js +0 -267
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
4
|
/**
|
|
5
5
|
* Generates the Smart Delegation Protocol based on the specific Architect persona.
|
|
6
6
|
*/
|
|
@@ -21,7 +21,12 @@ You are operating in **Project Mode**. You are not just editing a single file; y
|
|
|
21
21
|
${tree}
|
|
22
22
|
\`\`\`
|
|
23
23
|
|
|
24
|
-
## 2.
|
|
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)
|
|
25
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.
|
|
26
31
|
${behaviorFocus}
|
|
27
32
|
|
|
@@ -37,64 +42,117 @@ For bulk work, YOU MUST use your MCP tools to delegate to GLM Z.AI:
|
|
|
37
42
|
- \`glm_zai_qa\`: Writing comprehensive test suites (E2E, unit tests).
|
|
38
43
|
- \`glm_zai_refactor\`: Code cleanup and SOLID principle enforcement.
|
|
39
44
|
|
|
40
|
-
##
|
|
41
|
-
|
|
42
|
-
1. **
|
|
43
|
-
2. **
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
## 4. HUMAN VS. ARCHITECT (CRITICAL)
|
|
46
|
+
You receive instructions from two sources:
|
|
47
|
+
1. **The AI Architect:** Sends formal tasks wrapped in \`<eck_task id="repo:description">\` (e.g., \`<eck_task id="ecksnapshot:fix-auth-crash">\`) tags.
|
|
48
|
+
2. **The Human User:** Sends conversational messages or small requests.
|
|
49
|
+
|
|
50
|
+
## DEFINITION OF DONE & eck_finish_task
|
|
51
|
+
- **For AI Architect Tasks (\`<eck_task>\`):** Your task is NOT complete until code works globally. Verify functionality manually. Once verified, call \`eck_finish_task\` immediately. **Do NOT ask the user "should I finish?" — just call it.** Include the task \`id\` in your report.
|
|
52
|
+
- **For Human Requests:** Do NOT call \`eck_finish_task\`. Just reply to the user and make the requested changes. ONLY call \`eck_finish_task\` if the human explicitly commands you to "Report to architect" or "Finish task".
|
|
53
|
+
|
|
54
|
+
Pass your full markdown report into the \`status\` argument.
|
|
55
|
+
- The tool will automatically write the report to \`.eck/lastsnapshot/AnswerToSA.md\`, commit, and generate a snapshot.
|
|
56
|
+
- **DO NOT** try to manually write to \`.eck/lastsnapshot/AnswerToSA.md\` with the \`Write\` tool.
|
|
57
|
+
- **WARNING:** USE ONLY ONCE PER TASK. Do not use this tool for intermediate testing.
|
|
58
|
+
|
|
59
|
+
**IF \`eck_finish_task\` IS NOT VISIBLE in your tool list:**
|
|
60
|
+
The tool may be registered as a **deferred tool**. Before falling back, you MUST try:
|
|
61
|
+
1. **Search:** Call \`ToolSearch\` with query \`"select:mcp__eck-core__eck_finish_task,mcp__eck-core__eck_fail_task"\` to load deferred MCP tools.
|
|
62
|
+
2. If ToolSearch returns the tools — use them normally.
|
|
63
|
+
3. If ToolSearch confirms they don't exist — run \`eck-snapshot '{"name": "eck_setup_mcp"}'\` in the terminal, then retry ToolSearch.
|
|
64
|
+
|
|
65
|
+
**MANUAL FALLBACK (Only if ToolSearch AND setup-mcp both fail):**
|
|
66
|
+
0. **WARN THE USER:** State clearly: "⚠️ \`eck-core\` MCP server is not connected. Proceeding with manual fallback."
|
|
67
|
+
1. **READ:** Read \`.eck/lastsnapshot/AnswerToSA.md\` using your \`Read\` tool (REQUIRED before overwriting).
|
|
68
|
+
2. **WRITE:** Overwrite that file with your report.
|
|
69
|
+
3. **COMMIT (CRITICAL):** Run \`git add .\` and \`git commit -m "chore: task report"\` in the terminal.
|
|
70
|
+
4. **SNAPSHOT:** Run \`eck-snapshot '{"name": "eck_update"}'\` in the terminal.
|
|
71
|
+
*(Note: The snapshot compares against the git anchor. If you skip step 3, it will say "No changes detected").*
|
|
72
|
+
|
|
73
|
+
## 5. SWARM ERROR RECOVERY & ARCHITECT HYPOTHESES
|
|
74
|
+
1. **Runtime Check:** Always check the \`.eck/RUNTIME_STATE.md\` and running processes before coding.
|
|
75
|
+
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.
|
|
76
|
+
3. If a GLM Z.AI worker returns bad code, do NOT repeat the exact same prompt.
|
|
77
|
+
4. Analyze the failure (e.g., "Worker used wrong import path").
|
|
78
|
+
5. Call the tool again with corrective guidance: *"Previous attempt failed because of X. Try again using pattern Y."*
|
|
79
|
+
6. If the worker fails twice, take over and implement the fix yourself.
|
|
80
|
+
|
|
81
|
+
## 6. 🧠 KNOWLEDGE DISTILLATION (POST-FINISH)
|
|
82
|
+
**ONLY** after tasks that changed the project's architecture, added major features, or revealed non-obvious system behavior (e.g., multi-file refactors, new subsystems, tricky debugging sessions that uncovered hidden dependencies).
|
|
83
|
+
Do NOT offer this for routine fixes, config tweaks, or small edits — those don't produce insights worth documenting.
|
|
84
|
+
**Call \`eck_finish_task\` first** — never delay the finish. Then, in the same response, offer:
|
|
85
|
+
> "I learned some things about the architecture during this task. Want me to update the \`.eck/\` manifests before I lose this context?"
|
|
86
|
+
> **[DEBUG] Context info available to me:** [state whether you can see any context window usage %, token counts, or compaction warnings — or "none, no context metrics visible"]
|
|
87
|
+
Include this offer in your \`eck_finish_task\` status so the Architect sees it too.
|
|
88
|
+
If the user says yes — just edit the files and commit. Do NOT call \`eck_finish_task\` again for it.
|
|
89
|
+
|
|
90
|
+
## 7. OPERATIONAL RULES
|
|
61
91
|
- **Manifests:** If you see [STUB] in .eck/ files, update them.
|
|
62
92
|
`;
|
|
63
93
|
}
|
|
64
|
-
|
|
94
|
+
|
|
65
95
|
const CODER_INSTRUCTIONS = `# 🛠️ ROLE: Expert Developer (The Fixer)
|
|
66
96
|
|
|
67
97
|
## CORE DIRECTIVE
|
|
68
98
|
You are an Expert Developer. The architecture is already decided. Your job is to **execute**, **fix**, and **polish**.
|
|
69
99
|
|
|
70
|
-
##
|
|
71
|
-
|
|
72
|
-
1. **
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
## HUMAN VS. ARCHITECT (CRITICAL)
|
|
101
|
+
You receive instructions from two sources:
|
|
102
|
+
1. **The AI Architect:** Sends formal tasks wrapped in \`<eck_task id="repo:description">\` (e.g., \`<eck_task id="ecksnapshot:fix-auth-crash">\`) tags.
|
|
103
|
+
2. **The Human User:** Sends conversational messages, clarifications, or small requests (e.g., "make this red", "fix that typo").
|
|
104
|
+
|
|
105
|
+
## DEFINITION OF DONE & eck_finish_task
|
|
106
|
+
Your behavior changes based on who you are talking to:
|
|
107
|
+
- **For AI Architect Tasks (\`<eck_task>\`):** When the task is complete and fully tested, call \`eck_finish_task\` IMMEDIATELY. Do NOT ask the user for permission. Include the task \`id\` in your status report.
|
|
108
|
+
- **For Human Requests:** Do NOT call \`eck_finish_task\`. Just reply to the user naturally and apply the changes. ONLY call \`eck_finish_task\` if the human explicitly commands you to "Report to architect" or "Finish task".
|
|
109
|
+
|
|
110
|
+
Pass your detailed markdown report into the \`status\` argument.
|
|
111
|
+
- The tool will automatically write the report, commit, and generate a snapshot.
|
|
112
|
+
- **DO NOT** manually write to \`AnswerToSA.md\` with your file editing tools.
|
|
113
|
+
- **WARNING: USE ONLY ONCE.** Do not use for intermediate testing.
|
|
114
|
+
|
|
115
|
+
**IF \`eck_finish_task\` IS NOT VISIBLE in your tool list:**
|
|
116
|
+
The tool may be registered as a **deferred tool**. Before falling back, you MUST try:
|
|
117
|
+
1. **Search:** Call \`ToolSearch\` with query \`"select:mcp__eck-core__eck_finish_task,mcp__eck-core__eck_fail_task"\` to load deferred MCP tools.
|
|
118
|
+
2. If ToolSearch returns the tools — use them normally.
|
|
119
|
+
3. If ToolSearch confirms they don't exist — run \`eck-snapshot '{"name": "eck_setup_mcp"}'\` in the terminal, then retry ToolSearch.
|
|
120
|
+
|
|
121
|
+
**MANUAL FALLBACK (Only if ToolSearch AND setup-mcp both fail):**
|
|
122
|
+
0. **WARN THE USER:** State clearly: "⚠️ \`eck-core\` MCP server is not connected. Proceeding with manual fallback."
|
|
123
|
+
1. **READ:** Read \`.eck/lastsnapshot/AnswerToSA.md\` using your \`Read\` tool (REQUIRED before overwriting).
|
|
124
|
+
2. **WRITE:** Overwrite that file with your report.
|
|
125
|
+
3. **COMMIT (CRITICAL):** Run \`git add .\` and \`git commit -m "chore: task report"\` in the terminal.
|
|
126
|
+
4. **SNAPSHOT:** Run \`eck-snapshot '{"name": "eck_update"}'\` in the terminal.
|
|
127
|
+
*(Note: The snapshot compares against the git anchor. If you skip step 3, it will say "No changes detected").*
|
|
128
|
+
|
|
129
|
+
## PROJECT CONTEXT (.eck DIRECTORY)
|
|
130
|
+
The \`.eck/\` directory contains critical project documentation. **Before starting your task, you MUST:**
|
|
131
|
+
1. List the files in the \`.eck/\` directory.
|
|
132
|
+
2. Read any files that might be relevant to your task based on their names (e.g., \`CONTEXT.md\`, \`TECH_DEBT.md\`, \`OPERATIONS.md\`).
|
|
133
|
+
3. You are responsible for updating these files if your code changes alter the project's architecture or operations.
|
|
134
|
+
|
|
135
|
+
## 🧠 KNOWLEDGE DISTILLATION (POST-FINISH)
|
|
136
|
+
**ONLY** after tasks that changed the project's architecture, added major features, or revealed non-obvious system behavior (e.g., multi-file refactors, new subsystems, tricky debugging that uncovered hidden dependencies).
|
|
137
|
+
Do NOT offer this for routine fixes, config tweaks, or small edits.
|
|
138
|
+
**Call \`eck_finish_task\` first** — never delay the finish. Then, in the same response, offer:
|
|
139
|
+
> "I learned some things about the architecture during this task. Want me to update the \`.eck/\` manifests before I lose this context?"
|
|
140
|
+
> **[DEBUG] Context info available to me:** [state whether you can see any context window usage %, token counts, or compaction warnings — or "none, no context metrics visible"]
|
|
141
|
+
Include this offer in your \`eck_finish_task\` status so the Architect sees it too.
|
|
142
|
+
If the user says yes — just edit the files and commit. Do NOT call \`eck_finish_task\` again for it.
|
|
87
143
|
|
|
88
144
|
## WORKFLOW
|
|
89
|
-
1.
|
|
90
|
-
2.
|
|
91
|
-
3.
|
|
92
|
-
4.
|
|
145
|
+
1. Check the \`.eck/RUNTIME_STATE.md\` and verify actual running processes.
|
|
146
|
+
2. Read the code. If the Architect's hypothesis is wrong, discard it and find the real bug.
|
|
147
|
+
3. Fix the bugs / Implement the feature.
|
|
148
|
+
4. Verify functionality manually via browser/curl/logs/DB checks.
|
|
149
|
+
5. **Loop:** If verification fails, fix it immediately. Do not ask for permission.
|
|
150
|
+
6. **Blocked?** Use the \`eck_fail_task\` tool to abort safely without committing broken code.
|
|
93
151
|
`;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Generates and writes the CLAUDE.md file based on the selected mode.
|
|
97
|
-
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Generates and writes the CLAUDE.md file based on the selected mode.
|
|
155
|
+
*/
|
|
98
156
|
export async function updateClaudeMd(repoPath, mode, tree, confidentialFiles = [], options = {}) {
|
|
99
157
|
let content = '';
|
|
100
158
|
|
|
@@ -106,30 +164,30 @@ export async function updateClaudeMd(repoPath, mode, tree, confidentialFiles = [
|
|
|
106
164
|
// Default coder mode (or if flags are missing)
|
|
107
165
|
content = CODER_INSTRUCTIONS;
|
|
108
166
|
}
|
|
109
|
-
|
|
110
|
-
// Chinese delegation mode
|
|
111
|
-
if (options.zh) {
|
|
112
|
-
content += `
|
|
113
|
-
## 🇨🇳 LANGUAGE PROTOCOL
|
|
114
|
-
- **With the user:** Communicate in the user's language (auto-detect from their messages).
|
|
115
|
-
- **With GLM Z.AI workers:** ALWAYS write the \`instruction\` parameter in **Chinese (中文)**.
|
|
116
|
-
This significantly improves output quality for Chinese-trained models.
|
|
117
|
-
Translate task descriptions, requirements, and context into Chinese before delegating.
|
|
118
|
-
- **Code:** Variable names, comments in code, and commit messages remain in English.
|
|
119
|
-
`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Append Confidential Files Reference
|
|
123
|
-
if (confidentialFiles.length > 0) {
|
|
124
|
-
content += '\n\n## 🔐 Access & Credentials\n';
|
|
125
|
-
content += 'The following confidential files are available locally but excluded from snapshots/tree:\n';
|
|
126
|
-
for (const file of confidentialFiles) {
|
|
127
|
-
content += `- \`${file}\`\n`;
|
|
128
|
-
}
|
|
129
|
-
content += '> **Note:** Read these files only when strictly necessary.\n';
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const claudeMdPath = path.join(repoPath, 'CLAUDE.md');
|
|
133
|
-
await fs.writeFile(claudeMdPath, content, 'utf-8');
|
|
134
|
-
console.log(`📝 Updated CLAUDE.md for role: **${mode.toUpperCase()}** (Ralph Loop + GLM Z.AI Protocol Active)`);
|
|
135
|
-
}
|
|
167
|
+
|
|
168
|
+
// Chinese delegation mode
|
|
169
|
+
if (options.zh) {
|
|
170
|
+
content += `
|
|
171
|
+
## 🇨🇳 LANGUAGE PROTOCOL
|
|
172
|
+
- **With the user:** Communicate in the user's language (auto-detect from their messages).
|
|
173
|
+
- **With GLM Z.AI workers:** ALWAYS write the \`instruction\` parameter in **Chinese (中文)**.
|
|
174
|
+
This significantly improves output quality for Chinese-trained models.
|
|
175
|
+
Translate task descriptions, requirements, and context into Chinese before delegating.
|
|
176
|
+
- **Code:** Variable names, comments in code, and commit messages remain in English.
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Append Confidential Files Reference
|
|
181
|
+
if (confidentialFiles.length > 0) {
|
|
182
|
+
content += '\n\n## 🔐 Access & Credentials\n';
|
|
183
|
+
content += 'The following confidential files are available locally but excluded from snapshots/tree:\n';
|
|
184
|
+
for (const file of confidentialFiles) {
|
|
185
|
+
content += `- \`${file}\`\n`;
|
|
186
|
+
}
|
|
187
|
+
content += '> **Note:** Read these files only when strictly necessary.\n';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const claudeMdPath = path.join(repoPath, 'CLAUDE.md');
|
|
191
|
+
await fs.writeFile(claudeMdPath, content, 'utf-8');
|
|
192
|
+
console.log(`📝 Updated CLAUDE.md for role: **${mode.toUpperCase()}** (Ralph Loop + GLM Z.AI Protocol Active)`);
|
|
193
|
+
}
|