@claushaas/ergon-cli 0.1.2
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 +1 -0
- package/README.md +20 -0
- package/dist/commands/approve.d.ts +14 -0
- package/dist/commands/approve.d.ts.map +1 -0
- package/dist/commands/approve.js +60 -0
- package/dist/commands/approve.js.map +1 -0
- package/dist/commands/cancel.d.ts +7 -0
- package/dist/commands/cancel.d.ts.map +1 -0
- package/dist/commands/cancel.js +27 -0
- package/dist/commands/cancel.js.map +1 -0
- package/dist/commands/init.d.ts +10 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +16 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/library.d.ts +7 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +12 -0
- package/dist/commands/library.js.map +1 -0
- package/dist/commands/run.d.ts +18 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +82 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/template.d.ts +13 -0
- package/dist/commands/template.d.ts.map +1 -0
- package/dist/commands/template.js +42 -0
- package/dist/commands/template.js.map +1 -0
- package/dist/commands/worker.d.ts +15 -0
- package/dist/commands/worker.d.ts.map +1 -0
- package/dist/commands/worker.js +108 -0
- package/dist/commands/worker.js.map +1 -0
- package/dist/commands/workflow.d.ts +8 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +34 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +76 -0
- package/dist/config/index.js.map +1 -0
- package/dist/help.d.ts +3 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +45 -0
- package/dist/help.js.map +1 -0
- package/dist/library/agents/coder.yaml +27 -0
- package/dist/library/agents/pr-writer.yaml +28 -0
- package/dist/library/agents/repo-analyzer.yaml +31 -0
- package/dist/library/agents/repo-planner.yaml +35 -0
- package/dist/library/schemas/agent.analysis.v1.json +51 -0
- package/dist/library/schemas/agent.patch.v1.json +57 -0
- package/dist/library/schemas/agent.plan.v1.json +71 -0
- package/dist/library/schemas/agent.pr.v1.json +54 -0
- package/dist/library/workflows/code.bump_deps.yaml +268 -0
- package/dist/library/workflows/code.codegen.yaml +256 -0
- package/dist/library/workflows/code.docs_update.yaml +252 -0
- package/dist/library/workflows/code.hotfix.yaml +264 -0
- package/dist/library/workflows/code.refactor.yaml +256 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +86 -0
- package/dist/main.js.map +1 -0
- package/dist/output/format.d.ts +2 -0
- package/dist/output/format.d.ts.map +1 -0
- package/dist/output/format.js +4 -0
- package/dist/output/format.js.map +1 -0
- package/dist/project.d.ts +42 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +229 -0
- package/dist/project.js.map +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +39 -0
- package/dist/utils.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
workflow:
|
|
2
|
+
id: code.refactor
|
|
3
|
+
version: 1
|
|
4
|
+
description: "Refactor code with an AI-assisted plan → patch → tests → review → manual gate → notify."
|
|
5
|
+
author: "ergon-flow"
|
|
6
|
+
tags: ["code", "refactor", "pr"]
|
|
7
|
+
|
|
8
|
+
inputs:
|
|
9
|
+
repo_path:
|
|
10
|
+
type: string
|
|
11
|
+
description: "Local filesystem path to the git repository."
|
|
12
|
+
base_branch:
|
|
13
|
+
type: string
|
|
14
|
+
description: "Branch to start from (e.g., main)."
|
|
15
|
+
default: "main"
|
|
16
|
+
new_branch:
|
|
17
|
+
type: string
|
|
18
|
+
description: "Branch to create for the refactor (e.g., refactor/xyz)."
|
|
19
|
+
task:
|
|
20
|
+
type: string
|
|
21
|
+
description: "What to refactor and why."
|
|
22
|
+
constraints:
|
|
23
|
+
type: string
|
|
24
|
+
description: "Hard constraints (keep behavior, keep public API, performance limits, etc.)."
|
|
25
|
+
default: "No behavior changes unless explicitly stated. Keep public APIs stable."
|
|
26
|
+
focus_paths:
|
|
27
|
+
type: array
|
|
28
|
+
description: "Optional list of paths/globs to focus on."
|
|
29
|
+
default: []
|
|
30
|
+
test_command:
|
|
31
|
+
type: string
|
|
32
|
+
description: "Command to run tests (empty means skip tests step)."
|
|
33
|
+
default: ""
|
|
34
|
+
notify:
|
|
35
|
+
type: object
|
|
36
|
+
description: "Notification backend config."
|
|
37
|
+
default:
|
|
38
|
+
channel: "stdout" # stdout|webhook|openclaw
|
|
39
|
+
target: "" # e.g. Slack channel, webhook URL, openclaw target
|
|
40
|
+
message_prefix: "[ergon-flow]"
|
|
41
|
+
|
|
42
|
+
steps:
|
|
43
|
+
- id: repo.prepare
|
|
44
|
+
kind: exec
|
|
45
|
+
name: "Prepare repo branch"
|
|
46
|
+
description: "Fetch, checkout base branch, create new branch."
|
|
47
|
+
command: |
|
|
48
|
+
set -euo pipefail
|
|
49
|
+
cd "{{ inputs.repo_path }}"
|
|
50
|
+
git fetch --all --prune
|
|
51
|
+
git checkout "{{ inputs.base_branch }}"
|
|
52
|
+
git pull --ff-only
|
|
53
|
+
git checkout -B "{{ inputs.new_branch }}"
|
|
54
|
+
|
|
55
|
+
- id: analyze
|
|
56
|
+
kind: agent
|
|
57
|
+
name: "Analyze codebase"
|
|
58
|
+
description: "Analyze current structure, risks, and refactor approach. Produce an analysis artifact."
|
|
59
|
+
provider: openrouter
|
|
60
|
+
model: deepseek/deepseek-v3.2
|
|
61
|
+
output:
|
|
62
|
+
name: analysis
|
|
63
|
+
type: analysis
|
|
64
|
+
prompt: |
|
|
65
|
+
You are an expert software engineer.
|
|
66
|
+
|
|
67
|
+
Task:
|
|
68
|
+
{{ inputs.task }}
|
|
69
|
+
|
|
70
|
+
Constraints:
|
|
71
|
+
{{ inputs.constraints }}
|
|
72
|
+
|
|
73
|
+
Focus paths (may be empty):
|
|
74
|
+
{{ inputs.focus_paths }}
|
|
75
|
+
|
|
76
|
+
Produce:
|
|
77
|
+
1) A concise diagnosis of current structure/problems
|
|
78
|
+
2) Risks (behavior change, API break, perf, tests)
|
|
79
|
+
3) A refactor strategy suitable for a single PR
|
|
80
|
+
4) A list of files likely to change
|
|
81
|
+
|
|
82
|
+
Output MUST be structured JSON with keys:
|
|
83
|
+
- diagnosis
|
|
84
|
+
- risks
|
|
85
|
+
- strategy
|
|
86
|
+
- files
|
|
87
|
+
- notes
|
|
88
|
+
|
|
89
|
+
- id: plan
|
|
90
|
+
kind: agent
|
|
91
|
+
name: "Create step-by-step plan"
|
|
92
|
+
description: "Turn analysis into an ordered plan with checkpoints."
|
|
93
|
+
provider: openrouter
|
|
94
|
+
model: moonshotai/kimi-k2.5
|
|
95
|
+
output:
|
|
96
|
+
name: plan
|
|
97
|
+
type: plan
|
|
98
|
+
prompt: |
|
|
99
|
+
You are creating an implementation plan for a refactor.
|
|
100
|
+
|
|
101
|
+
Task:
|
|
102
|
+
{{ inputs.task }}
|
|
103
|
+
|
|
104
|
+
Constraints:
|
|
105
|
+
{{ inputs.constraints }}
|
|
106
|
+
|
|
107
|
+
Prior analysis (JSON):
|
|
108
|
+
{{ artifacts.analysis }}
|
|
109
|
+
|
|
110
|
+
Produce an ordered plan for a single PR.
|
|
111
|
+
|
|
112
|
+
Output MUST be structured JSON with keys:
|
|
113
|
+
- goal
|
|
114
|
+
- approach
|
|
115
|
+
- steps (array of {id, description, files, verification})
|
|
116
|
+
- rollback
|
|
117
|
+
- pr_description
|
|
118
|
+
|
|
119
|
+
- id: patch
|
|
120
|
+
kind: agent
|
|
121
|
+
name: "Generate patch"
|
|
122
|
+
description: "Generate a unified diff patch implementing the plan."
|
|
123
|
+
provider: codex
|
|
124
|
+
output:
|
|
125
|
+
name: patch
|
|
126
|
+
type: text
|
|
127
|
+
prompt: |
|
|
128
|
+
You are an AI coding agent. Generate a unified diff patch.
|
|
129
|
+
|
|
130
|
+
Repo path:
|
|
131
|
+
{{ inputs.repo_path }}
|
|
132
|
+
|
|
133
|
+
Task:
|
|
134
|
+
{{ inputs.task }}
|
|
135
|
+
|
|
136
|
+
Constraints:
|
|
137
|
+
{{ inputs.constraints }}
|
|
138
|
+
|
|
139
|
+
Plan (JSON):
|
|
140
|
+
{{ artifacts.plan }}
|
|
141
|
+
|
|
142
|
+
Requirements:
|
|
143
|
+
- Output ONLY a unified diff (git apply compatible)
|
|
144
|
+
- No prose outside the diff
|
|
145
|
+
- Keep changes minimal and coherent
|
|
146
|
+
|
|
147
|
+
- id: patch.apply
|
|
148
|
+
kind: exec
|
|
149
|
+
name: "Apply patch"
|
|
150
|
+
description: "Write patch to disk and apply it to the repo."
|
|
151
|
+
command: |
|
|
152
|
+
set -euo pipefail
|
|
153
|
+
cd "{{ inputs.repo_path }}"
|
|
154
|
+
mkdir -p .ergon
|
|
155
|
+
cat > .ergon/refactor.patch <<'PATCH'
|
|
156
|
+
{{ artifacts.patch }}
|
|
157
|
+
PATCH
|
|
158
|
+
git apply --index .ergon/refactor.patch
|
|
159
|
+
|
|
160
|
+
- id: tests.run
|
|
161
|
+
kind: condition
|
|
162
|
+
name: "Should run tests?"
|
|
163
|
+
description: "Skip test execution if test_command is empty."
|
|
164
|
+
expression: "{{ inputs.test_command }}"
|
|
165
|
+
|
|
166
|
+
- id: tests.exec
|
|
167
|
+
kind: exec
|
|
168
|
+
name: "Run tests"
|
|
169
|
+
description: "Run tests and capture results."
|
|
170
|
+
depends_on: [tests.run]
|
|
171
|
+
command: |
|
|
172
|
+
set -euo pipefail
|
|
173
|
+
cd "{{ inputs.repo_path }}"
|
|
174
|
+
{{ inputs.test_command }}
|
|
175
|
+
|
|
176
|
+
- id: review
|
|
177
|
+
kind: agent
|
|
178
|
+
name: "Review changes"
|
|
179
|
+
description: "Review the patch and test results. Provide final PR text and any follow-ups."
|
|
180
|
+
provider: claude-code
|
|
181
|
+
output:
|
|
182
|
+
name: review
|
|
183
|
+
type: json
|
|
184
|
+
prompt: |
|
|
185
|
+
You are a meticulous code reviewer.
|
|
186
|
+
|
|
187
|
+
Task:
|
|
188
|
+
{{ inputs.task }}
|
|
189
|
+
|
|
190
|
+
Constraints:
|
|
191
|
+
{{ inputs.constraints }}
|
|
192
|
+
|
|
193
|
+
Plan (JSON):
|
|
194
|
+
{{ artifacts.plan }}
|
|
195
|
+
|
|
196
|
+
Patch (diff):
|
|
197
|
+
{{ artifacts.patch }}
|
|
198
|
+
|
|
199
|
+
Test command:
|
|
200
|
+
{{ inputs.test_command }}
|
|
201
|
+
|
|
202
|
+
Test execution result (may be empty if skipped):
|
|
203
|
+
{{ artifacts.tests.exec.stdout }}
|
|
204
|
+
|
|
205
|
+
Produce structured JSON with keys:
|
|
206
|
+
- summary
|
|
207
|
+
- risk_assessment
|
|
208
|
+
- required_changes (array)
|
|
209
|
+
- optional_improvements (array)
|
|
210
|
+
- pr_title
|
|
211
|
+
- pr_body
|
|
212
|
+
|
|
213
|
+
- id: gate
|
|
214
|
+
kind: manual
|
|
215
|
+
name: "Manual gate"
|
|
216
|
+
description: "Human verifies PR, merges, and marks workflow complete."
|
|
217
|
+
message: |
|
|
218
|
+
PR is ready to review.
|
|
219
|
+
|
|
220
|
+
Suggested PR title:
|
|
221
|
+
{{ artifacts.review.pr_title }}
|
|
222
|
+
|
|
223
|
+
Suggested PR body:
|
|
224
|
+
{{ artifacts.review.pr_body }}
|
|
225
|
+
|
|
226
|
+
Repo:
|
|
227
|
+
{{ inputs.repo_path }}
|
|
228
|
+
|
|
229
|
+
Branch:
|
|
230
|
+
{{ inputs.new_branch }} (from {{ inputs.base_branch }})
|
|
231
|
+
|
|
232
|
+
Decision required: approve or reject.
|
|
233
|
+
|
|
234
|
+
- id: notify
|
|
235
|
+
kind: notify
|
|
236
|
+
name: "Notify user"
|
|
237
|
+
description: "Send final notification (stdout/webhook/openclaw)."
|
|
238
|
+
channel: "{{ inputs.notify.channel }}"
|
|
239
|
+
target: "{{ inputs.notify.target }}"
|
|
240
|
+
message: |
|
|
241
|
+
{{ inputs.notify.message_prefix }} Workflow completed: code.refactor
|
|
242
|
+
|
|
243
|
+
Repo: {{ inputs.repo_path }}
|
|
244
|
+
Branch: {{ inputs.new_branch }} (from {{ inputs.base_branch }})
|
|
245
|
+
|
|
246
|
+
Next action: review the branch / open PR / merge.
|
|
247
|
+
|
|
248
|
+
Summary:
|
|
249
|
+
{{ artifacts.review.summary }}
|
|
250
|
+
|
|
251
|
+
outputs:
|
|
252
|
+
patch: artifacts.patch
|
|
253
|
+
plan: artifacts.plan
|
|
254
|
+
review: artifacts.review
|
|
255
|
+
branch: inputs.new_branch
|
|
256
|
+
base_branch: inputs.base_branch
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseApproveCommandArgs, runApproveCommand, } from './commands/approve.js';
|
|
3
|
+
import { runCancelCommand } from './commands/cancel.js';
|
|
4
|
+
import { runInitCommand } from './commands/init.js';
|
|
5
|
+
import { runLibrarySyncCommand } from './commands/library.js';
|
|
6
|
+
import { runRunCommand, runRunStatusCommand } from './commands/run.js';
|
|
7
|
+
import { runTemplateListCommand } from './commands/template.js';
|
|
8
|
+
import { parseWorkerCommandArgs, runWorkerCommand } from './commands/worker.js';
|
|
9
|
+
import { runWorkflowListCommand } from './commands/workflow.js';
|
|
10
|
+
import { getCliHelpText, getCliVersionText } from './help.js';
|
|
11
|
+
function readFlagValue(argv, flagName) {
|
|
12
|
+
const flagIndex = argv.indexOf(flagName);
|
|
13
|
+
if (flagIndex < 0) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const value = argv[flagIndex + 1];
|
|
17
|
+
if (!value || value.startsWith('--')) {
|
|
18
|
+
throw new Error(`Missing value for ${flagName}`);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
async function main(argv) {
|
|
23
|
+
const [command, subcommand, ...rest] = argv;
|
|
24
|
+
if (!command || command === 'help' || command === '--help') {
|
|
25
|
+
console.log(getCliHelpText());
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (command === 'version' || command === '--version') {
|
|
29
|
+
console.log(getCliVersionText());
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (command === 'init') {
|
|
33
|
+
runInitCommand({
|
|
34
|
+
rootDir: readFlagValue(argv.slice(1), '--root'),
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (command === 'worker' && subcommand === 'start') {
|
|
39
|
+
await runWorkerCommand(parseWorkerCommandArgs(rest));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (command === 'library' && subcommand === 'sync') {
|
|
43
|
+
runLibrarySyncCommand({
|
|
44
|
+
force: rest.includes('--force'),
|
|
45
|
+
rootDir: readFlagValue(rest, '--root'),
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (command === 'template' && subcommand === 'list') {
|
|
50
|
+
runTemplateListCommand();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (command === 'workflow' && subcommand === 'list') {
|
|
54
|
+
runWorkflowListCommand();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (command === 'approve' && subcommand) {
|
|
58
|
+
const { decision, stepId } = parseApproveCommandArgs(rest);
|
|
59
|
+
runApproveCommand(subcommand, stepId, { decision });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (command === 'cancel' && subcommand) {
|
|
63
|
+
runCancelCommand(subcommand);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (command === 'run' && subcommand) {
|
|
67
|
+
const inputsIndex = rest.indexOf('--inputs');
|
|
68
|
+
runRunCommand(subcommand, {
|
|
69
|
+
inputs: inputsIndex >= 0 && inputsIndex < rest.length - 1
|
|
70
|
+
? rest[inputsIndex + 1]
|
|
71
|
+
: undefined,
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (command === 'run-status' && subcommand) {
|
|
76
|
+
runRunStatusCommand(subcommand);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`Unsupported command: ${[command, subcommand].filter(Boolean).join(' ') || '(empty)'}`);
|
|
80
|
+
}
|
|
81
|
+
main(process.argv.slice(2)).catch((error) => {
|
|
82
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
83
|
+
console.error(message);
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA,OAAO,EACN,uBAAuB,EACvB,iBAAiB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9D,SAAS,aAAa,CAAC,IAAc,EAAE,QAAgB;IACtD,MAAM,SAAS,GAAG,IAAI,C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AE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CACtF,CAAC;AACH,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/output/format.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/output/format.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,KAAc;IACvC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface ProjectLibraryMetadata {
|
|
2
|
+
cli_version: string;
|
|
3
|
+
format_version: number;
|
|
4
|
+
initialized_at: string;
|
|
5
|
+
library_files: Record<string, string>;
|
|
6
|
+
library_version: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ProjectPaths {
|
|
9
|
+
configPath: string;
|
|
10
|
+
dbPath: string;
|
|
11
|
+
embeddedLibraryDir: string;
|
|
12
|
+
embeddedWorkflowsDir: string;
|
|
13
|
+
ergonDir: string;
|
|
14
|
+
initialized: boolean;
|
|
15
|
+
libraryDir: string;
|
|
16
|
+
rootDir: string;
|
|
17
|
+
storageDir: string;
|
|
18
|
+
workflowsDir: string;
|
|
19
|
+
}
|
|
20
|
+
export interface InitializeProjectOptions {
|
|
21
|
+
rootDir: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SyncLibraryOptions {
|
|
24
|
+
force?: boolean;
|
|
25
|
+
rootDir: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SyncLibrarySummary {
|
|
28
|
+
added: string[];
|
|
29
|
+
conflicted: string[];
|
|
30
|
+
force: boolean;
|
|
31
|
+
rootDir: string;
|
|
32
|
+
skipped: string[];
|
|
33
|
+
updated: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function getCliVersion(): string;
|
|
36
|
+
export declare function getEmbeddedLibraryDir(): string;
|
|
37
|
+
export declare function resolveProjectPaths(cwd?: string, explicitRootDir?: string): ProjectPaths;
|
|
38
|
+
export declare function loadProjectLibraryMetadata(project: ProjectPaths): ProjectLibraryMetadata | null;
|
|
39
|
+
export declare function assertInitializedProject(project: ProjectPaths, commandName: string): ProjectPaths;
|
|
40
|
+
export declare function initializeProject(options: InitializeProjectOptions): ProjectLibraryMetadata;
|
|
41
|
+
export declare function syncProjectLibrary(options: SyncLibraryOptions): SyncLibrarySummary;
|
|
42
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,sBAAsB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,E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|
|
2
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
const ERGON_DIR_NAME = '.ergon';
|
|
6
|
+
const ERGON_CONFIG_FILE_NAME = 'config.json';
|
|
7
|
+
const ERGON_DB_RELATIVE_PATH = path.join('storage', 'ergon.db');
|
|
8
|
+
const CONFIG_FORMAT_VERSION = 1;
|
|
9
|
+
function hashContent(content) {
|
|
10
|
+
return createHash('sha256').update(content).digest('hex');
|
|
11
|
+
}
|
|
12
|
+
function hashFile(filePath) {
|
|
13
|
+
return hashContent(readFileSync(filePath));
|
|
14
|
+
}
|
|
15
|
+
function getPackageRootDir() {
|
|
16
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
return path.resolve(moduleDir, '..');
|
|
18
|
+
}
|
|
19
|
+
export function getCliVersion() {
|
|
20
|
+
const packageRootDir = getPackageRootDir();
|
|
21
|
+
const packageJsonPath = path.join(packageRootDir, 'package.json');
|
|
22
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
23
|
+
if (typeof packageJson.version !== 'string' ||
|
|
24
|
+
packageJson.version.length === 0) {
|
|
25
|
+
throw new Error(`CLI package version is missing in "${packageJsonPath}"`);
|
|
26
|
+
}
|
|
27
|
+
return packageJson.version;
|
|
28
|
+
}
|
|
29
|
+
export function getEmbeddedLibraryDir() {
|
|
30
|
+
const packageRootDir = getPackageRootDir();
|
|
31
|
+
const candidates = [
|
|
32
|
+
path.join(packageRootDir, 'dist', 'library'),
|
|
33
|
+
path.resolve(packageRootDir, '..', '..', 'library'),
|
|
34
|
+
];
|
|
35
|
+
for (const candidate of candidates) {
|
|
36
|
+
if (existsSync(candidate) && statSync(candidate).isDirectory()) {
|
|
37
|
+
return candidate;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`Embedded library is not available. Expected one of: ${candidates.join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
function resolveRootDir(cwd, explicitRootDir) {
|
|
43
|
+
if (explicitRootDir) {
|
|
44
|
+
return path.resolve(explicitRootDir);
|
|
45
|
+
}
|
|
46
|
+
const envRootDir = process.env.ERGON_ROOT_DIR?.trim();
|
|
47
|
+
if (envRootDir) {
|
|
48
|
+
return path.resolve(envRootDir);
|
|
49
|
+
}
|
|
50
|
+
let currentDir = path.resolve(cwd);
|
|
51
|
+
while (true) {
|
|
52
|
+
if (existsSync(path.join(currentDir, ERGON_DIR_NAME))) {
|
|
53
|
+
return currentDir;
|
|
54
|
+
}
|
|
55
|
+
const parentDir = path.dirname(currentDir);
|
|
56
|
+
if (parentDir === currentDir) {
|
|
57
|
+
return path.resolve(cwd);
|
|
58
|
+
}
|
|
59
|
+
currentDir = parentDir;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function toPortableRelativePath(relativePath) {
|
|
63
|
+
return relativePath.split(path.sep).join('/');
|
|
64
|
+
}
|
|
65
|
+
function listFilesRecursive(baseDir) {
|
|
66
|
+
const files = [];
|
|
67
|
+
const visit = (currentDir) => {
|
|
68
|
+
for (const entry of readdirSync(currentDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
69
|
+
const entryPath = path.join(currentDir, entry.name);
|
|
70
|
+
if (entry.isDirectory()) {
|
|
71
|
+
visit(entryPath);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (entry.isFile()) {
|
|
75
|
+
files.push(toPortableRelativePath(path.relative(baseDir, entryPath)));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
if (!existsSync(baseDir)) {
|
|
80
|
+
return files;
|
|
81
|
+
}
|
|
82
|
+
visit(baseDir);
|
|
83
|
+
return files;
|
|
84
|
+
}
|
|
85
|
+
function readProjectLibraryMetadata(configPath) {
|
|
86
|
+
if (!existsSync(configPath)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const parsed = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
90
|
+
if (typeof parsed !== 'object' ||
|
|
91
|
+
parsed === null ||
|
|
92
|
+
typeof parsed.format_version !== 'number' ||
|
|
93
|
+
typeof parsed.initialized_at !== 'string' ||
|
|
94
|
+
typeof parsed.cli_version !== 'string' ||
|
|
95
|
+
typeof parsed.library_version !== 'string' ||
|
|
96
|
+
typeof parsed.library_files !== 'object' ||
|
|
97
|
+
parsed.library_files === null ||
|
|
98
|
+
Array.isArray(parsed.library_files)) {
|
|
99
|
+
throw new Error(`Invalid Ergon project config at "${configPath}"`);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
cli_version: parsed.cli_version,
|
|
103
|
+
format_version: parsed.format_version,
|
|
104
|
+
initialized_at: parsed.initialized_at,
|
|
105
|
+
library_files: Object.fromEntries(Object.entries(parsed.library_files).filter(([relativePath, hash]) => typeof relativePath === 'string' && typeof hash === 'string')),
|
|
106
|
+
library_version: parsed.library_version,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function writeProjectLibraryMetadata(configPath, metadata) {
|
|
110
|
+
writeFileSync(`${configPath}`, `${JSON.stringify(metadata, null, 2)}\n`, 'utf8');
|
|
111
|
+
}
|
|
112
|
+
function buildLibraryMetadata(libraryDir) {
|
|
113
|
+
const cliVersion = getCliVersion();
|
|
114
|
+
return {
|
|
115
|
+
cli_version: cliVersion,
|
|
116
|
+
format_version: CONFIG_FORMAT_VERSION,
|
|
117
|
+
initialized_at: new Date().toISOString(),
|
|
118
|
+
library_files: Object.fromEntries(listFilesRecursive(libraryDir).map((relativePath) => [
|
|
119
|
+
relativePath,
|
|
120
|
+
hashFile(path.join(libraryDir, relativePath)),
|
|
121
|
+
])),
|
|
122
|
+
library_version: cliVersion,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export function resolveProjectPaths(cwd = process.cwd(), explicitRootDir) {
|
|
126
|
+
const rootDir = resolveRootDir(cwd, explicitRootDir);
|
|
127
|
+
const ergonDir = path.join(rootDir, ERGON_DIR_NAME);
|
|
128
|
+
const libraryDir = path.join(ergonDir, 'library');
|
|
129
|
+
return {
|
|
130
|
+
configPath: path.join(ergonDir, ERGON_CONFIG_FILE_NAME),
|
|
131
|
+
dbPath: path.join(ergonDir, ERGON_DB_RELATIVE_PATH),
|
|
132
|
+
embeddedLibraryDir: getEmbeddedLibraryDir(),
|
|
133
|
+
embeddedWorkflowsDir: path.join(getEmbeddedLibraryDir(), 'workflows'),
|
|
134
|
+
ergonDir,
|
|
135
|
+
initialized: existsSync(ergonDir),
|
|
136
|
+
libraryDir,
|
|
137
|
+
rootDir,
|
|
138
|
+
storageDir: path.join(ergonDir, 'storage'),
|
|
139
|
+
workflowsDir: path.join(libraryDir, 'workflows'),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function loadProjectLibraryMetadata(project) {
|
|
143
|
+
return readProjectLibraryMetadata(project.configPath);
|
|
144
|
+
}
|
|
145
|
+
export function assertInitializedProject(project, commandName) {
|
|
146
|
+
if (!project.initialized || !existsSync(project.configPath)) {
|
|
147
|
+
throw new Error(`The "${commandName}" command requires an initialized Ergon project at "${project.rootDir}". Run "ergon init" first.`);
|
|
148
|
+
}
|
|
149
|
+
return project;
|
|
150
|
+
}
|
|
151
|
+
export function initializeProject(options) {
|
|
152
|
+
const project = resolveProjectPaths(options.rootDir, options.rootDir);
|
|
153
|
+
if (project.initialized) {
|
|
154
|
+
throw new Error(`Ergon is already initialized at "${project.rootDir}". Use "ergon library sync" to update managed assets.`);
|
|
155
|
+
}
|
|
156
|
+
mkdirSync(project.storageDir, { recursive: true });
|
|
157
|
+
mkdirSync(project.libraryDir, { recursive: true });
|
|
158
|
+
for (const relativePath of listFilesRecursive(project.embeddedLibraryDir)) {
|
|
159
|
+
const sourcePath = path.join(project.embeddedLibraryDir, relativePath);
|
|
160
|
+
const targetPath = path.join(project.libraryDir, relativePath);
|
|
161
|
+
mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
162
|
+
copyFileSync(sourcePath, targetPath);
|
|
163
|
+
}
|
|
164
|
+
const metadata = buildLibraryMetadata(project.libraryDir);
|
|
165
|
+
writeProjectLibraryMetadata(project.configPath, metadata);
|
|
166
|
+
return metadata;
|
|
167
|
+
}
|
|
168
|
+
export function syncProjectLibrary(options) {
|
|
169
|
+
const project = assertInitializedProject(resolveProjectPaths(options.rootDir, options.rootDir), 'library sync');
|
|
170
|
+
const previousMetadata = loadProjectLibraryMetadata(project);
|
|
171
|
+
if (!previousMetadata) {
|
|
172
|
+
throw new Error(`Invalid Ergon project at "${project.rootDir}": missing "${project.configPath}"`);
|
|
173
|
+
}
|
|
174
|
+
const summary = {
|
|
175
|
+
added: [],
|
|
176
|
+
conflicted: [],
|
|
177
|
+
force: options.force === true,
|
|
178
|
+
rootDir: project.rootDir,
|
|
179
|
+
skipped: [],
|
|
180
|
+
updated: [],
|
|
181
|
+
};
|
|
182
|
+
const nextManagedFiles = { ...previousMetadata.library_files };
|
|
183
|
+
for (const relativePath of listFilesRecursive(project.embeddedLibraryDir)) {
|
|
184
|
+
const sourcePath = path.join(project.embeddedLibraryDir, relativePath);
|
|
185
|
+
const targetPath = path.join(project.libraryDir, relativePath);
|
|
186
|
+
const sourceHash = hashFile(sourcePath);
|
|
187
|
+
const existingManagedHash = previousMetadata.library_files[relativePath];
|
|
188
|
+
if (!existsSync(targetPath)) {
|
|
189
|
+
mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
190
|
+
copyFileSync(sourcePath, targetPath);
|
|
191
|
+
nextManagedFiles[relativePath] = sourceHash;
|
|
192
|
+
summary.added.push(relativePath);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const localHash = hashFile(targetPath);
|
|
196
|
+
if (options.force) {
|
|
197
|
+
if (localHash === sourceHash) {
|
|
198
|
+
nextManagedFiles[relativePath] = sourceHash;
|
|
199
|
+
summary.skipped.push(relativePath);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
copyFileSync(sourcePath, targetPath);
|
|
203
|
+
nextManagedFiles[relativePath] = sourceHash;
|
|
204
|
+
summary.updated.push(relativePath);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (localHash === sourceHash) {
|
|
208
|
+
nextManagedFiles[relativePath] = sourceHash;
|
|
209
|
+
summary.skipped.push(relativePath);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (existingManagedHash && existingManagedHash === localHash) {
|
|
213
|
+
copyFileSync(sourcePath, targetPath);
|
|
214
|
+
nextManagedFiles[relativePath] = sourceHash;
|
|
215
|
+
summary.updated.push(relativePath);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
summary.conflicted.push(relativePath);
|
|
219
|
+
}
|
|
220
|
+
writeProjectLibraryMetadata(project.configPath, {
|
|
221
|
+
cli_version: getCliVersion(),
|
|
222
|
+
format_version: previousMetadata.format_version,
|
|
223
|
+
initialized_at: previousMetadata.initialized_at,
|
|
224
|
+
library_files: nextManagedFiles,
|
|
225
|
+
library_version: getCliVersion(),
|
|
226
|
+
});
|
|
227
|
+
return summary;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAC7C,MAAM,sBAAsB,GAAG,IAAI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gBAAgB;QAC/B,eAAe,EAAE,aAAa,EAAE;KAChC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function hashFile(filePath: string): string;
|
|
2
|
+
export declare function resolveWorkflowTemplatesDir(rootDir: string): string;
|
|
3
|
+
export declare function resolveEmbeddedTemplateDisplayPath(templatePath: string): string;
|
|
4
|
+
export declare function assertValidWorkflowId(workflowId: string): string;
|
|
5
|
+
export declare function assertValidStepId(stepId: string): string;
|
|
6
|
+
export declare function resolvePathWithinBase(baseDir: string, unsafePath: string, label: string): string;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|