@evomap/evolver-cli 2.0.0-beta.0 → 2.0.0-beta.10

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 (87) hide show
  1. package/dist/antiGeneBenchmark.js +12 -0
  2. package/dist/antiGeneEvidence.d.ts +15 -0
  3. package/dist/antiGeneEvidence.js +49 -0
  4. package/dist/antiGeneRollout.d.ts +3 -1
  5. package/dist/antiGeneRollout.js +16 -2
  6. package/dist/assetHealth.d.ts +6 -0
  7. package/dist/assetHealth.js +105 -0
  8. package/dist/assetSidecarRecovery.d.ts +14 -0
  9. package/dist/assetSidecarRecovery.js +171 -0
  10. package/dist/assetTrust.d.ts +24 -0
  11. package/dist/assetTrust.js +218 -0
  12. package/dist/atp.js +4 -2
  13. package/dist/autoDistillLlm.d.ts +6 -0
  14. package/dist/autoDistillLlm.js +44 -7
  15. package/dist/autoexec.d.ts +14 -12
  16. package/dist/autoexec.js +84 -34
  17. package/dist/autoexecConfig.d.ts +10 -0
  18. package/dist/autoexecConfig.js +68 -0
  19. package/dist/cli.js +12 -5
  20. package/dist/cliContracts.js +30 -3
  21. package/dist/cliLifecycle.d.ts +7 -0
  22. package/dist/cliLifecycle.js +9 -0
  23. package/dist/cycleConsumer.d.ts +61 -1
  24. package/dist/cycleConsumer.js +551 -16
  25. package/dist/dashboard.d.ts +33 -0
  26. package/dist/dashboard.js +352 -0
  27. package/dist/dispatch.d.ts +10 -1
  28. package/dist/dispatch.js +40 -2
  29. package/dist/distillAdmission.d.ts +13 -0
  30. package/dist/distillAdmission.js +35 -0
  31. package/dist/distillObserver.js +6 -8
  32. package/dist/distillPrimitives.d.ts +9 -7
  33. package/dist/distillPrimitives.js +65 -12
  34. package/dist/doctor.d.ts +2 -0
  35. package/dist/doctor.js +49 -3
  36. package/dist/index.d.ts +8 -2
  37. package/dist/index.js +350 -42
  38. package/dist/issueReport.d.ts +7 -0
  39. package/dist/issueReport.js +291 -0
  40. package/dist/lifecycle.d.ts +19 -1
  41. package/dist/lifecycle.js +226 -29
  42. package/dist/localMemoryGraph.d.ts +97 -0
  43. package/dist/localMemoryGraph.js +889 -0
  44. package/dist/login.d.ts +20 -4
  45. package/dist/login.js +58 -8
  46. package/dist/materialPackage.d.ts +52 -0
  47. package/dist/materialPackage.js +401 -0
  48. package/dist/materialSnapshot.d.ts +54 -0
  49. package/dist/materialSnapshot.js +370 -0
  50. package/dist/memoryEventMirror.d.ts +23 -0
  51. package/dist/memoryEventMirror.js +140 -0
  52. package/dist/migrate/fieldMap.js +25 -0
  53. package/dist/migrate/v1Import.d.ts +7 -1
  54. package/dist/migrate/v1Import.js +132 -11
  55. package/dist/nonGitWorkspaceNotice.d.ts +24 -0
  56. package/dist/nonGitWorkspaceNotice.js +122 -0
  57. package/dist/proxyToken.d.ts +10 -0
  58. package/dist/proxyToken.js +80 -0
  59. package/dist/recipe.d.ts +12 -2
  60. package/dist/recipe.js +381 -8
  61. package/dist/reuse.d.ts +5 -3
  62. package/dist/reuse.js +74 -6
  63. package/dist/reuseReport.js +16 -16
  64. package/dist/runtimeCapabilities.d.ts +18 -0
  65. package/dist/runtimeCapabilities.js +81 -0
  66. package/dist/runtimeSessionSource.d.ts +10 -0
  67. package/dist/runtimeSessionSource.js +32 -5
  68. package/dist/setupHooks.d.ts +11 -1
  69. package/dist/setupHooks.js +235 -16
  70. package/dist/skill2gep.d.ts +38 -9
  71. package/dist/skill2gep.js +147 -14
  72. package/dist/skillDistill.d.ts +1 -0
  73. package/dist/skillDistill.js +4 -4
  74. package/dist/skillFetch.d.ts +18 -0
  75. package/dist/skillFetch.js +391 -0
  76. package/dist/solo/mode.js +5 -0
  77. package/dist/sync.d.ts +38 -0
  78. package/dist/sync.js +1981 -0
  79. package/dist/trajectoryExport.js +23 -12
  80. package/dist/v1Compat.d.ts +24 -0
  81. package/dist/v1Compat.js +249 -0
  82. package/dist/version.js +2 -0
  83. package/dist/workflow.d.ts +39 -0
  84. package/dist/workflow.js +386 -0
  85. package/dist/workflowRuntime.d.ts +66 -0
  86. package/dist/workflowRuntime.js +631 -0
  87. package/package.json +12 -6
@@ -0,0 +1,291 @@
1
+ import { join } from 'node:path';
2
+ import { events, issueReporter } from '@evomap/evolver-core';
3
+ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
4
+ import { runDoctorChecks } from './doctor.js';
5
+ import { getCliVersion } from './version.js';
6
+ const GITHUB_FETCH_TIMEOUT_MS = 15_000;
7
+ function parseFlags(argv) {
8
+ const flags = {
9
+ json: false,
10
+ cycleIds: [],
11
+ eventIds: [],
12
+ traceIds: [],
13
+ steps: [],
14
+ diagnosticCodes: [],
15
+ approved: false,
16
+ notCreated: false,
17
+ abandon: false,
18
+ };
19
+ for (let index = 0; index < argv.length; index++) {
20
+ const arg = argv[index];
21
+ const next = () => argv[++index];
22
+ if (arg === '--root')
23
+ flags.root = next() ?? flags.root;
24
+ else if (arg === '--json')
25
+ flags.json = true;
26
+ else if (arg === '--source')
27
+ flags.source = next();
28
+ else if (arg === '--error-class')
29
+ flags.errorClass = next();
30
+ else if (arg === '--failure-class')
31
+ flags.failureClass = next();
32
+ else if (arg === '--cycle') {
33
+ const value = next();
34
+ if (value)
35
+ flags.cycleIds.push(value);
36
+ }
37
+ else if (arg === '--event') {
38
+ const value = next();
39
+ if (value)
40
+ flags.eventIds.push(value);
41
+ }
42
+ else if (arg === '--trace') {
43
+ const value = next();
44
+ if (value)
45
+ flags.traceIds.push(value);
46
+ }
47
+ else if (arg === '--step') {
48
+ const value = next();
49
+ if (value)
50
+ flags.steps.push(value);
51
+ }
52
+ else if (arg === '--diagnostic') {
53
+ const value = next();
54
+ if (value)
55
+ flags.diagnosticCodes.push(value);
56
+ }
57
+ else if (arg === '--repo')
58
+ flags.repo = next();
59
+ else if (arg === '--approve')
60
+ flags.approved = true;
61
+ else if (arg === '--not-created')
62
+ flags.notCreated = true;
63
+ else if (arg === '--abandon')
64
+ flags.abandon = true;
65
+ else if (arg === '--issue-number') {
66
+ const value = Number(next());
67
+ if (Number.isInteger(value) && value > 0)
68
+ flags.issueNumber = value;
69
+ }
70
+ else if (arg === '--issue-url')
71
+ flags.issueUrl = next();
72
+ }
73
+ return flags;
74
+ }
75
+ function reporterOptions(flags, env, deps) {
76
+ const envRoot = env['EVOLVER_ISSUE_REPORT_ROOT']?.trim();
77
+ return {
78
+ rootDir: flags.root ?? (envRoot || join(events.evomapHome(env), 'evolution', 'issue-reporter')),
79
+ workspaceScope: process.cwd(),
80
+ env,
81
+ now: deps.now,
82
+ logger: (entry) => process.stderr.write(`[issue-report] fingerprint=${entry.fingerprint} status=${entry.status}${entry.errorClass ? ` error_class=${entry.errorClass}` : ''}\n`),
83
+ };
84
+ }
85
+ function writeResult(value, json) {
86
+ process.stdout.write(json ? `${JSON.stringify(value)}\n` : `${String(value)}\n`);
87
+ }
88
+ function publicDraftState(draft) {
89
+ return { fingerprint: draft.fingerprint, status: draft.status };
90
+ }
91
+ function publicSubmitResult(result) {
92
+ return {
93
+ status: result.status,
94
+ ...('errorClass' in result ? { errorClass: result.errorClass } : {}),
95
+ draft: publicDraftState(result.draft),
96
+ };
97
+ }
98
+ function githubTransport(token, fetchFn) {
99
+ return {
100
+ async listOpenIssues(input) {
101
+ const controller = new AbortController();
102
+ const timer = setTimeout(() => controller.abort(), GITHUB_FETCH_TIMEOUT_MS);
103
+ timer.unref?.();
104
+ try {
105
+ const response = await fetchFn(`https://api.github.com/repos/${input.repo}/issues?state=open&per_page=${input.perPage}&page=${input.page}`, {
106
+ method: 'GET',
107
+ signal: controller.signal,
108
+ headers: {
109
+ accept: 'application/vnd.github+json',
110
+ authorization: `Bearer ${token}`,
111
+ 'user-agent': 'evolver-v2-safe-issue-reporter',
112
+ 'x-github-api-version': '2022-11-28',
113
+ },
114
+ });
115
+ if (!response.ok)
116
+ throw new issueReporter.GithubIssueTransportError('not_created');
117
+ const payload = await response.json();
118
+ if (!Array.isArray(payload))
119
+ throw new issueReporter.GithubIssueTransportError('not_created');
120
+ return {
121
+ issues: payload.map((item) => {
122
+ const record = item;
123
+ return {
124
+ number: Number(record['number']),
125
+ url: String(record['html_url'] ?? ''),
126
+ body: typeof record['body'] === 'string' ? record['body'] : '',
127
+ isPullRequest: record['pull_request'] !== undefined,
128
+ };
129
+ }),
130
+ hasNextPage: /<[^>]+>;\s*rel="next"/.test(response.headers.get('link') ?? ''),
131
+ };
132
+ }
133
+ finally {
134
+ clearTimeout(timer);
135
+ }
136
+ },
137
+ async createIssue(input) {
138
+ const controller = new AbortController();
139
+ const timer = setTimeout(() => controller.abort(), GITHUB_FETCH_TIMEOUT_MS);
140
+ timer.unref?.();
141
+ try {
142
+ const response = await fetchFn(`https://api.github.com/repos/${input.repo}/issues`, {
143
+ method: 'POST',
144
+ signal: controller.signal,
145
+ headers: {
146
+ accept: 'application/vnd.github+json',
147
+ authorization: `Bearer ${token}`,
148
+ 'content-type': 'application/json',
149
+ 'user-agent': 'evolver-v2-safe-issue-reporter',
150
+ 'x-github-api-version': '2022-11-28',
151
+ },
152
+ body: JSON.stringify({ title: input.title, body: input.body }),
153
+ });
154
+ if (!response.ok) {
155
+ throw new issueReporter.GithubIssueTransportError(response.status >= 400 && response.status < 500 ? 'not_created' : 'ambiguous');
156
+ }
157
+ const payload = await response.json();
158
+ return { number: Number(payload.number), url: String(payload.html_url ?? '') };
159
+ }
160
+ finally {
161
+ clearTimeout(timer);
162
+ }
163
+ },
164
+ };
165
+ }
166
+ export async function runIssueReportCommand(argv, deps = {}) {
167
+ const action = argv[0];
168
+ const fingerprint = argv[1];
169
+ const flags = parseFlags(argv.slice(action === 'submit' || action === 'reject' || action === 'resolve' ? 2 : 1));
170
+ const env = { ...(deps.env ?? process.env) };
171
+ if (action === 'submit' || action === 'resolve') {
172
+ const envLoad = loadEnvFileFromEnv(env);
173
+ if (envLoad.error) {
174
+ process.stderr.write('issue_report_env_file_error\n');
175
+ return 1;
176
+ }
177
+ }
178
+ const options = reporterOptions(flags, env, { ...deps, env });
179
+ if (action === 'draft') {
180
+ let input = null;
181
+ if (flags.cycleIds[0]) {
182
+ input = issueReporter.issueReportInputFromCycle(events.readEvents(), flags.cycleIds[0]);
183
+ }
184
+ else if (flags.source === 'doctor') {
185
+ input = issueReporter.issueReportInputFromDoctor(runDoctorChecks().map(({ name, status }) => ({ name, status })));
186
+ }
187
+ else if (issueReporter.isIssueReportSource(flags.source) && flags.errorClass) {
188
+ input = {
189
+ source: flags.source,
190
+ errorClass: flags.errorClass,
191
+ failureClass: flags.failureClass,
192
+ cycleIds: flags.cycleIds,
193
+ eventIds: flags.eventIds,
194
+ traceIds: flags.traceIds,
195
+ reproductionSteps: flags.steps,
196
+ diagnosticCodes: flags.diagnosticCodes,
197
+ version: getCliVersion(),
198
+ };
199
+ }
200
+ if (!input) {
201
+ process.stderr.write('用法: evolver issue-report draft (--cycle <id> | --source <doctor|review|event|cycle_failure> --error-class <class>) [--json]\n');
202
+ return 1;
203
+ }
204
+ if (flags.traceIds.length > 0) {
205
+ input.traceIds = [...(input.traceIds ?? []), ...flags.traceIds];
206
+ }
207
+ input.version ??= getCliVersion();
208
+ const result = issueReporter.createIssueDraft(input, options);
209
+ writeResult(flags.json ? result : `${result.status}: ${result.draft.fingerprint}`, flags.json);
210
+ return 0;
211
+ }
212
+ if ((action === 'submit' || action === 'reject' || action === 'resolve') && fingerprint) {
213
+ const lookup = issueReporter.lookupIssueDraft(options.rootDir, fingerprint);
214
+ if (lookup.status !== 'found') {
215
+ if (flags.json && /^[a-f0-9]{20}$/.test(fingerprint)) {
216
+ writeResult({
217
+ status: 'failed',
218
+ errorClass: lookup.status === 'missing' ? 'draft_not_found' : 'unsafe_draft',
219
+ draft: { fingerprint, status: 'draft' },
220
+ }, true);
221
+ }
222
+ else {
223
+ process.stderr.write('issue draft not found\n');
224
+ }
225
+ return 1;
226
+ }
227
+ const { draft } = lookup;
228
+ if (action === 'resolve') {
229
+ const repo = flags.repo ?? env['EVOLVER_ISSUE_REPO'];
230
+ const resolution = flags.notCreated
231
+ ? { outcome: 'not_created' }
232
+ : flags.abandon
233
+ ? { outcome: 'abandoned' }
234
+ : flags.issueNumber && flags.issueUrl && repo
235
+ ? { outcome: 'submitted', issueNumber: flags.issueNumber, url: flags.issueUrl, repo }
236
+ : null;
237
+ if (!resolution) {
238
+ process.stderr.write('resolve requires --not-created, --abandon, or --issue-number/--issue-url/--repo\n');
239
+ return 1;
240
+ }
241
+ try {
242
+ const resolved = issueReporter.resolveIssueSubmission(fingerprint, resolution, options);
243
+ writeResult(flags.json ? publicDraftState(resolved) : `${resolved.status}: ${resolved.fingerprint}`, flags.json);
244
+ return 0;
245
+ }
246
+ catch (error) {
247
+ const errorClass = error instanceof issueReporter.IssueDraftConflictError
248
+ ? error.errorClass
249
+ : 'invalid_resolution';
250
+ writeResult(flags.json ? { status: 'failed', errorClass, draft: publicDraftState(draft) } : `failed: ${draft.fingerprint}`, flags.json);
251
+ return 1;
252
+ }
253
+ }
254
+ if (action === 'reject') {
255
+ let rejected;
256
+ try {
257
+ rejected = issueReporter.rejectIssueDraft(draft, options);
258
+ }
259
+ catch (error) {
260
+ if (!(error instanceof issueReporter.IssueDraftConflictError))
261
+ throw error;
262
+ const result = {
263
+ status: 'rate_limited',
264
+ errorClass: error.errorClass,
265
+ draft: publicDraftState(draft),
266
+ };
267
+ writeResult(flags.json ? result : `${result.status}: ${draft.fingerprint}`, flags.json);
268
+ return 1;
269
+ }
270
+ writeResult(flags.json ? publicDraftState(rejected) : `${rejected.status}: ${rejected.fingerprint}`, flags.json);
271
+ return rejected.status === 'submitted' ? 1 : 0;
272
+ }
273
+ const repo = flags.repo ?? env['EVOLVER_ISSUE_REPO'];
274
+ const token = env['GITHUB_TOKEN'] ?? env['GH_TOKEN'];
275
+ const operatorPolicy = env['EVOLVER_ISSUE_SUBMIT_POLICY']?.trim().toLowerCase() === 'allow';
276
+ if (!repo || !token) {
277
+ process.stderr.write('submit requires --repo and GITHUB_TOKEN/GH_TOKEN\n');
278
+ return 1;
279
+ }
280
+ const result = await issueReporter.submitIssueDraft(draft, {
281
+ repo,
282
+ approved: flags.approved || operatorPolicy,
283
+ approvalSource: operatorPolicy ? 'operator_policy' : flags.approved ? 'human' : undefined,
284
+ transport: githubTransport(token, deps.fetch ?? fetch),
285
+ }, options);
286
+ writeResult(flags.json ? publicSubmitResult(result) : `${result.status}: ${result.draft.fingerprint}`, flags.json);
287
+ return result.status === 'submitted' || result.status === 'already_submitted' ? 0 : 1;
288
+ }
289
+ process.stderr.write('用法: evolver issue-report <draft|submit|reject|resolve> ...\n');
290
+ return 1;
291
+ }
@@ -1,4 +1,9 @@
1
1
  import { spawn } from 'node:child_process';
2
+ export interface DaemonCommand {
3
+ command: string;
4
+ args: string[];
5
+ display: string;
6
+ }
2
7
  interface ProcessIdentity {
3
8
  executable?: string;
4
9
  parentPid?: number;
@@ -59,15 +64,28 @@ export declare function renderSystemdUnit(opts?: {
59
64
  envFile?: string;
60
65
  workingDirectory?: string;
61
66
  execStart?: string;
67
+ selfUpdateStateDir?: string;
68
+ selfUpdateTarget?: string;
62
69
  }): string;
63
70
  export declare function renderLaunchdPlist(opts?: {
64
71
  envFile?: string;
65
72
  workingDirectory?: string;
66
73
  nodePath?: string;
67
74
  proxyBin?: string;
75
+ programArguments?: readonly string[];
68
76
  logDir?: string;
77
+ selfUpdateStateDir?: string;
78
+ selfUpdateTarget?: string;
79
+ }): string;
80
+ export declare function renderWindowsInstaller(defaults?: {
81
+ evolverBin?: string;
82
+ nodePath?: string;
83
+ proxyBin?: string;
84
+ envFile?: string;
85
+ selfUpdateStateDir?: string;
69
86
  }): string;
70
- export declare function renderWindowsInstaller(): string;
87
+ export declare function resolveDaemonCommand(env: NodeJS.ProcessEnv, execPath?: string, argv1?: string | undefined): DaemonCommand;
88
+ export declare function resolveSelfUpdatingExecutable(execPath: string, argv1: string | undefined): DaemonCommand | undefined;
71
89
  export declare function resolveProxyBinPath(): string | undefined;
72
90
  export declare function resolveStableNodePath(): string;
73
91
  export declare function sessionStartHookVerboseEnabled(env?: NodeJS.ProcessEnv): boolean;