@companion-ai/feynman 0.5.2 → 0.5.4
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/.feynman/SYSTEM.md +33 -67
- package/.feynman/agents/writer.md +1 -2
- package/.feynman/themes/feynman.json +1 -1
- package/README.md +19 -71
- package/RELEASES.md +34 -0
- package/dist/cli.js +6 -16
- package/dist/pi/packages.js +1 -18
- package/dist/telemetry/posthog.js +29 -261
- package/metadata/commands.mjs +3 -2
- package/package.json +4 -13
- package/prompts/audit.md +0 -11
- package/prompts/autoresearch.md +0 -19
- package/prompts/compare.md +1 -12
- package/prompts/deepresearch.md +1 -24
- package/prompts/draft.md +1 -12
- package/prompts/lit.md +1 -12
- package/prompts/log.md +0 -11
- package/prompts/recipe.md +0 -13
- package/prompts/replicate.md +0 -11
- package/prompts/review.md +0 -13
- package/prompts/summarize.md +4 -18
- package/scripts/check-pi-rpc.mjs +2 -1
- package/skills/alpha-research/SKILL.md +1 -1
- package/skills/autoresearch/SKILL.md +1 -1
- package/skills/preview/SKILL.md +7 -20
- package/skills/session-search/SKILL.md +5 -16
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { randomUUID, createHash } from "node:crypto";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { trace, SpanStatusCode } from "@opentelemetry/api";
|
|
5
|
-
import { logs, SeverityNumber } from "@opentelemetry/api-logs";
|
|
6
|
-
import { OTLPExporterBase, createOtlpNetworkExportDelegate, } from "@opentelemetry/otlp-exporter-base";
|
|
7
|
-
import { createOtlpHttpExporterMetrics } from "@opentelemetry/otlp-exporter-base/node-http";
|
|
8
|
-
import { JsonLogsSerializer, LogsExporterMetricsHelper, ProtobufTraceSerializer, TraceExporterMetricsHelper, } from "@opentelemetry/otlp-transformer";
|
|
9
|
-
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
10
|
-
import { BatchLogRecordProcessor, LoggerProvider, } from "@opentelemetry/sdk-logs";
|
|
11
|
-
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
12
|
-
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
13
|
-
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
|
|
14
4
|
import { PostHog } from "posthog-node";
|
|
15
5
|
import { getFeynmanHome, getFeynmanStateDir } from "../config/paths.js";
|
|
16
6
|
export const DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
|
|
@@ -25,102 +15,30 @@ export const TELEMETRY_NOTICE = [
|
|
|
25
15
|
"To opt out, set FEYNMAN_TELEMETRY=off. Learn more: https://www.feynman.is/docs/getting-started/configuration#telemetry",
|
|
26
16
|
].join("\n");
|
|
27
17
|
let posthogClient;
|
|
28
|
-
let tracerProvider;
|
|
29
|
-
let loggerProvider;
|
|
30
18
|
let activeConfig;
|
|
31
19
|
let telemetryInitialized = false;
|
|
32
20
|
let telemetryStartWarningPrinted = false;
|
|
33
21
|
let telemetryTransportFailed = false;
|
|
34
22
|
let telemetryNoticeThisProcess;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
tryStart() {
|
|
39
|
-
return !circuitOpen;
|
|
40
|
-
},
|
|
41
|
-
completeSuccess() { },
|
|
42
|
-
completeFailure(error) {
|
|
43
|
-
if (circuitOpen)
|
|
44
|
-
return;
|
|
45
|
-
circuitOpen = true;
|
|
46
|
-
onTransportFailure(error);
|
|
47
|
-
},
|
|
48
|
-
isOpen() {
|
|
49
|
-
return circuitOpen;
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function successfulTelemetryDropResponse() {
|
|
54
|
-
return new Response(null, { status: 204 });
|
|
55
|
-
}
|
|
56
|
-
export function createTelemetryCircuitBreakerFetch(fetchImpl, onTransportFailure, circuit = createTelemetryTransportCircuitBreaker(onTransportFailure)) {
|
|
23
|
+
/** One silent attempt per session: after the first failure, later requests are dropped. */
|
|
24
|
+
export function createTelemetryCircuitBreakerFetch(fetchImpl, onTransportFailure) {
|
|
25
|
+
let open = false;
|
|
57
26
|
return async (url, options) => {
|
|
58
|
-
if (!
|
|
59
|
-
return successfulTelemetryDropResponse();
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
const response = await fetchImpl(url, options);
|
|
63
|
-
if (response.status >= 200 && response.status < 400) {
|
|
64
|
-
circuit.completeSuccess();
|
|
65
|
-
return response;
|
|
66
|
-
}
|
|
67
|
-
circuit.completeFailure(new Error(`PostHog transport returned HTTP ${response.status}`));
|
|
68
|
-
return successfulTelemetryDropResponse();
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
circuit.completeFailure(error);
|
|
72
|
-
return successfulTelemetryDropResponse();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export function createOneShotOtlpTransport(options) {
|
|
77
|
-
return {
|
|
78
|
-
async send(data, timeoutMillis) {
|
|
79
|
-
if (!options.circuit.tryStart()) {
|
|
80
|
-
return { status: "success" };
|
|
81
|
-
}
|
|
82
|
-
const controller = new AbortController();
|
|
83
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMillis);
|
|
84
|
-
timeout.unref?.();
|
|
27
|
+
if (!open) {
|
|
85
28
|
try {
|
|
86
|
-
const response = await
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"Content-Type": options.contentType,
|
|
91
|
-
},
|
|
92
|
-
body: Buffer.from(data),
|
|
93
|
-
signal: controller.signal,
|
|
94
|
-
});
|
|
95
|
-
if (response.status < 200 || response.status >= 400) {
|
|
96
|
-
throw new Error(`OTLP transport returned HTTP ${response.status}`);
|
|
97
|
-
}
|
|
98
|
-
options.circuit.completeSuccess();
|
|
99
|
-
return { status: "success" };
|
|
29
|
+
const response = await fetchImpl(url, options);
|
|
30
|
+
if (response.status >= 200 && response.status < 400)
|
|
31
|
+
return response;
|
|
32
|
+
throw new Error(`PostHog transport returned HTTP ${response.status}`);
|
|
100
33
|
}
|
|
101
34
|
catch (error) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// through their global error handler.
|
|
105
|
-
options.circuit.completeFailure(error);
|
|
106
|
-
return { status: "success" };
|
|
35
|
+
open = true;
|
|
36
|
+
onTransportFailure(error);
|
|
107
37
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
shutdown() { },
|
|
38
|
+
}
|
|
39
|
+
return new Response(null, { status: 204 });
|
|
113
40
|
};
|
|
114
41
|
}
|
|
115
|
-
function createOneShotOtlpExporter(options) {
|
|
116
|
-
const metrics = createOtlpHttpExporterMetrics(options.componentType, options.metricsHelper, options.url, undefined);
|
|
117
|
-
const transport = createOneShotOtlpTransport(options);
|
|
118
|
-
return new OTLPExporterBase(createOtlpNetworkExportDelegate({
|
|
119
|
-
timeoutMillis: options.timeoutMillis,
|
|
120
|
-
concurrencyLimit: 1,
|
|
121
|
-
compression: "none",
|
|
122
|
-
}, options.serializer, metrics, transport));
|
|
123
|
-
}
|
|
124
42
|
function disableTelemetryAfterTransportFailure(error) {
|
|
125
43
|
if (telemetryTransportFailed)
|
|
126
44
|
return;
|
|
@@ -213,7 +131,6 @@ export function resolvePostHogTelemetryConfig(options = {}) {
|
|
|
213
131
|
projectToken,
|
|
214
132
|
distinctId: env.FEYNMAN_TELEMETRY_DISTINCT_ID?.trim() || getAnonymousDistinctId(options.home),
|
|
215
133
|
appVersion: options.appVersion,
|
|
216
|
-
serviceName: options.serviceName ?? "feynman-cli",
|
|
217
134
|
};
|
|
218
135
|
}
|
|
219
136
|
function normalizeTelemetryKey(key) {
|
|
@@ -262,16 +179,6 @@ function baseTelemetryProperties(config) {
|
|
|
262
179
|
$process_person_profile: false,
|
|
263
180
|
});
|
|
264
181
|
}
|
|
265
|
-
function toOtelAttributes(properties = {}) {
|
|
266
|
-
const normalized = normalizeTelemetryProperties(properties);
|
|
267
|
-
const attributes = {};
|
|
268
|
-
for (const [key, value] of Object.entries(normalized)) {
|
|
269
|
-
if (value === null)
|
|
270
|
-
continue;
|
|
271
|
-
attributes[key] = value;
|
|
272
|
-
}
|
|
273
|
-
return attributes;
|
|
274
|
-
}
|
|
275
182
|
export function stableTelemetryHash(value) {
|
|
276
183
|
if (!value)
|
|
277
184
|
return undefined;
|
|
@@ -289,13 +196,6 @@ export function telemetryErrorProperties(error) {
|
|
|
289
196
|
error_message_hash: stableTelemetryHash(message),
|
|
290
197
|
};
|
|
291
198
|
}
|
|
292
|
-
export function sanitizeTelemetryException(error) {
|
|
293
|
-
const properties = telemetryErrorProperties(error);
|
|
294
|
-
return {
|
|
295
|
-
name: String(properties.error_name ?? "unknown"),
|
|
296
|
-
message: `error_message_hash:${properties.error_message_hash ?? "unknown"}`,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
199
|
export function initializePostHogTelemetry(options = {}) {
|
|
300
200
|
if (telemetryInitialized)
|
|
301
201
|
return activeConfig;
|
|
@@ -305,81 +205,22 @@ export function initializePostHogTelemetry(options = {}) {
|
|
|
305
205
|
activeConfig = config;
|
|
306
206
|
if (!config)
|
|
307
207
|
return undefined;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
spanProcessors: [
|
|
319
|
-
new BatchSpanProcessor(createOneShotOtlpExporter({
|
|
320
|
-
url: `${config.host}/i/v1/traces`,
|
|
321
|
-
headers: { Authorization: `Bearer ${config.projectToken}` },
|
|
322
|
-
contentType: "application/x-protobuf",
|
|
323
|
-
fetchImpl: otlpFetch,
|
|
324
|
-
circuit,
|
|
325
|
-
timeoutMillis: 750,
|
|
326
|
-
componentType: "otlp_http_span_exporter",
|
|
327
|
-
serializer: ProtobufTraceSerializer,
|
|
328
|
-
metricsHelper: TraceExporterMetricsHelper,
|
|
329
|
-
}), { scheduledDelayMillis: 250, exportTimeoutMillis: 3000 }),
|
|
330
|
-
],
|
|
331
|
-
});
|
|
332
|
-
tracerProvider.register();
|
|
333
|
-
loggerProvider = new LoggerProvider({
|
|
334
|
-
resource,
|
|
335
|
-
processors: [
|
|
336
|
-
new BatchLogRecordProcessor({
|
|
337
|
-
exporter: createOneShotOtlpExporter({
|
|
338
|
-
url: `${config.host}/i/v1/logs`,
|
|
339
|
-
headers: { Authorization: `Bearer ${config.projectToken}` },
|
|
340
|
-
contentType: "application/json",
|
|
341
|
-
fetchImpl: otlpFetch,
|
|
342
|
-
circuit,
|
|
343
|
-
timeoutMillis: 750,
|
|
344
|
-
componentType: "otlp_http_log_exporter",
|
|
345
|
-
serializer: JsonLogsSerializer,
|
|
346
|
-
metricsHelper: LogsExporterMetricsHelper,
|
|
347
|
-
}),
|
|
348
|
-
scheduledDelayMillis: 250,
|
|
349
|
-
exportTimeoutMillis: 3000,
|
|
350
|
-
}),
|
|
351
|
-
],
|
|
352
|
-
});
|
|
353
|
-
logs.setGlobalLoggerProvider(loggerProvider);
|
|
354
|
-
const defaultPostHogFetch = (url, fetchOptions) => fetch(url, fetchOptions);
|
|
355
|
-
posthogClient = new PostHog(config.projectToken, {
|
|
356
|
-
host: config.host,
|
|
357
|
-
flushAt: 1,
|
|
358
|
-
flushInterval: 0,
|
|
359
|
-
isServer: false,
|
|
360
|
-
disableGeoip: true,
|
|
361
|
-
fetchRetryCount: 0,
|
|
362
|
-
fetch: createTelemetryCircuitBreakerFetch(options.posthogFetch ?? defaultPostHogFetch, disableTelemetryAfterTransportFailure, circuit),
|
|
363
|
-
});
|
|
364
|
-
posthogClient.on("error", () => {
|
|
365
|
-
if (process.env.FEYNMAN_DEBUG === "1" && !telemetryStartWarningPrinted) {
|
|
366
|
-
telemetryStartWarningPrinted = true;
|
|
367
|
-
process.stderr.write("[feynman] PostHog telemetry transport reported an error.\n");
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
return config;
|
|
371
|
-
}
|
|
372
|
-
catch (error) {
|
|
208
|
+
posthogClient = new PostHog(config.projectToken, {
|
|
209
|
+
host: config.host,
|
|
210
|
+
flushAt: 1,
|
|
211
|
+
flushInterval: 0,
|
|
212
|
+
isServer: false,
|
|
213
|
+
disableGeoip: true,
|
|
214
|
+
fetchRetryCount: 0,
|
|
215
|
+
fetch: createTelemetryCircuitBreakerFetch(options.posthogFetch ?? ((url, fetchOptions) => fetch(url, fetchOptions)), disableTelemetryAfterTransportFailure),
|
|
216
|
+
});
|
|
217
|
+
posthogClient.on("error", () => {
|
|
373
218
|
if (process.env.FEYNMAN_DEBUG === "1" && !telemetryStartWarningPrinted) {
|
|
374
219
|
telemetryStartWarningPrinted = true;
|
|
375
|
-
process.stderr.write(
|
|
220
|
+
process.stderr.write("[feynman] PostHog telemetry transport reported an error.\n");
|
|
376
221
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
tracerProvider = undefined;
|
|
380
|
-
loggerProvider = undefined;
|
|
381
|
-
return undefined;
|
|
382
|
-
}
|
|
222
|
+
});
|
|
223
|
+
return config;
|
|
383
224
|
}
|
|
384
225
|
export function captureTelemetryEvent(event, properties = {}) {
|
|
385
226
|
if (!activeConfig || !posthogClient)
|
|
@@ -405,90 +246,17 @@ export async function captureTelemetryEventImmediate(event, properties = {}) {
|
|
|
405
246
|
},
|
|
406
247
|
});
|
|
407
248
|
}
|
|
408
|
-
export function emitTelemetryLog(severityText, body, properties = {}) {
|
|
409
|
-
if (!activeConfig || !loggerProvider)
|
|
410
|
-
return;
|
|
411
|
-
const severityNumber = severityText === "error"
|
|
412
|
-
? SeverityNumber.ERROR
|
|
413
|
-
: severityText === "warn"
|
|
414
|
-
? SeverityNumber.WARN
|
|
415
|
-
: severityText === "debug"
|
|
416
|
-
? SeverityNumber.DEBUG
|
|
417
|
-
: severityText === "trace"
|
|
418
|
-
? SeverityNumber.TRACE
|
|
419
|
-
: SeverityNumber.INFO;
|
|
420
|
-
logs.getLogger("feynman").emit({
|
|
421
|
-
severityText,
|
|
422
|
-
severityNumber,
|
|
423
|
-
body,
|
|
424
|
-
attributes: {
|
|
425
|
-
...toOtelAttributes(baseTelemetryProperties(activeConfig)),
|
|
426
|
-
...toOtelAttributes(properties),
|
|
427
|
-
},
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
function createNoopSpan() {
|
|
431
|
-
return {
|
|
432
|
-
setAttributes() { },
|
|
433
|
-
recordException() { },
|
|
434
|
-
end() { },
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
export function startTelemetrySpan(name, properties = {}) {
|
|
438
|
-
if (!activeConfig || !tracerProvider)
|
|
439
|
-
return createNoopSpan();
|
|
440
|
-
const span = trace.getTracer("feynman").startSpan(name, {
|
|
441
|
-
attributes: {
|
|
442
|
-
...toOtelAttributes(baseTelemetryProperties(activeConfig)),
|
|
443
|
-
...toOtelAttributes(properties),
|
|
444
|
-
},
|
|
445
|
-
});
|
|
446
|
-
let ended = false;
|
|
447
|
-
return {
|
|
448
|
-
setAttributes(nextProperties) {
|
|
449
|
-
if (ended)
|
|
450
|
-
return;
|
|
451
|
-
span.setAttributes(toOtelAttributes(nextProperties));
|
|
452
|
-
},
|
|
453
|
-
recordException(error) {
|
|
454
|
-
if (ended)
|
|
455
|
-
return;
|
|
456
|
-
span.recordException(sanitizeTelemetryException(error));
|
|
457
|
-
span.setAttributes(toOtelAttributes(telemetryErrorProperties(error)));
|
|
458
|
-
},
|
|
459
|
-
end(status = "ok", nextProperties = {}) {
|
|
460
|
-
if (ended)
|
|
461
|
-
return;
|
|
462
|
-
ended = true;
|
|
463
|
-
if (Object.keys(nextProperties).length > 0) {
|
|
464
|
-
span.setAttributes(toOtelAttributes(nextProperties));
|
|
465
|
-
}
|
|
466
|
-
if (status === "error") {
|
|
467
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
471
|
-
}
|
|
472
|
-
span.end();
|
|
473
|
-
},
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
249
|
export async function shutdownPostHogTelemetry() {
|
|
477
250
|
const client = posthogClient;
|
|
478
|
-
const traces = tracerProvider;
|
|
479
|
-
const loggers = loggerProvider;
|
|
480
251
|
posthogClient = undefined;
|
|
481
|
-
tracerProvider = undefined;
|
|
482
|
-
loggerProvider = undefined;
|
|
483
252
|
activeConfig = undefined;
|
|
484
253
|
telemetryInitialized = false;
|
|
485
254
|
telemetryTransportFailed = false;
|
|
486
255
|
telemetryNoticeThisProcess = undefined;
|
|
487
|
-
|
|
488
|
-
client?.shutdown(3000)
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
]);
|
|
256
|
+
try {
|
|
257
|
+
await client?.shutdown(3000);
|
|
258
|
+
}
|
|
259
|
+
catch { }
|
|
492
260
|
}
|
|
493
261
|
function flagValue(args, flag) {
|
|
494
262
|
const prefix = `${flag}=`;
|
package/metadata/commands.mjs
CHANGED
|
@@ -54,8 +54,8 @@ export const livePackageCommandGroups = [
|
|
|
54
54
|
title: "Live Package Commands",
|
|
55
55
|
commands: [
|
|
56
56
|
{ name: "search", usage: "/search" },
|
|
57
|
-
{ name: "
|
|
58
|
-
{ name: "
|
|
57
|
+
{ name: "websearch", usage: "/websearch" },
|
|
58
|
+
{ name: "curator", usage: "/curator" },
|
|
59
59
|
{ name: "hotkeys", usage: "/hotkeys" },
|
|
60
60
|
{ name: "new", usage: "/new" },
|
|
61
61
|
{ name: "quit", usage: "/quit" },
|
|
@@ -161,6 +161,7 @@ export const legacyFlags = [
|
|
|
161
161
|
{ usage: "--session <path|id>", description: "Open a specific session." },
|
|
162
162
|
{ usage: "--fork <path|id>", description: "Fork a session into a new one." },
|
|
163
163
|
{ usage: "--no-session", description: "Use an in-memory session that is not persisted." },
|
|
164
|
+
{ usage: "--no-themes", description: "Skip theme loading (passed by ACP adapters such as pi-acp)." },
|
|
164
165
|
{ usage: "--export <session.jsonl> [out.html]", description: "Export a session file to HTML and exit." },
|
|
165
166
|
{ usage: "--doctor", description: "Alias for `feynman doctor`." },
|
|
166
167
|
{ usage: "--setup-preview", description: "Alias for `feynman setup preview`." },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@companion-ai/feynman",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Research-first CLI agent built on Pi and alphaXiv",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"prepack": "node ./scripts/clean-publish-artifacts.mjs && npm run build",
|
|
43
43
|
"start": "tsx src/index.ts",
|
|
44
44
|
"start:dist": "node ./bin/feynman.js",
|
|
45
|
-
"test": "node --import tsx --test --test-concurrency=1 tests/*.test.ts",
|
|
45
|
+
"test": "node --import tsx --import ./tests/isolate-tmpdir.ts --test --test-concurrency=1 tests/*.test.ts",
|
|
46
46
|
"typecheck": "tsc --noEmit",
|
|
47
47
|
"architecture:check": "node ./scripts/check-architecture.mjs"
|
|
48
48
|
},
|
|
@@ -79,17 +79,8 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@clack/prompts": "^1.7.0",
|
|
81
81
|
"@companion-ai/alpha-hub": "0.1.6",
|
|
82
|
-
"@earendil-works/pi-ai": "
|
|
83
|
-
"@earendil-works/pi-coding-agent": "
|
|
84
|
-
"@opentelemetry/api": "^1.9.1",
|
|
85
|
-
"@opentelemetry/api-logs": "^0.222.0",
|
|
86
|
-
"@opentelemetry/otlp-exporter-base": "^0.222.0",
|
|
87
|
-
"@opentelemetry/otlp-transformer": "^0.222.0",
|
|
88
|
-
"@opentelemetry/resources": "^2.11.0",
|
|
89
|
-
"@opentelemetry/sdk-logs": "^0.222.0",
|
|
90
|
-
"@opentelemetry/sdk-trace-base": "^2.11.0",
|
|
91
|
-
"@opentelemetry/sdk-trace-node": "^2.11.0",
|
|
92
|
-
"@opentelemetry/semantic-conventions": "^1.43.0",
|
|
82
|
+
"@earendil-works/pi-ai": "*",
|
|
83
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
93
84
|
"fast-xml-parser": "5.11.1",
|
|
94
85
|
"pi-btw": "0.6.0",
|
|
95
86
|
"pi-docparser": "4.0.0",
|
package/prompts/audit.md
CHANGED
|
@@ -4,17 +4,6 @@ args: <item>
|
|
|
4
4
|
section: Research Workflows
|
|
5
5
|
topLevelCli: true
|
|
6
6
|
---
|
|
7
|
-
## Tool Discipline (Read First)
|
|
8
|
-
|
|
9
|
-
Tool names are literal. Use only tools visible in the current tool set.
|
|
10
|
-
|
|
11
|
-
- Search with `web_search`; do not call `search_web`, `google_search`, `google:search`, `search_google`, or `WebSearch`.
|
|
12
|
-
- Fetch URLs with `fetch_content`; do not call bare `fetch`, `WebFetch`, `read_url_content`, or pass an array as `url`. Use `urls` for multiple URLs when the tool supports it.
|
|
13
|
-
- Use visible Feynman alpha tools such as `alpha_search` when present. For shell access, call `feynman alpha ...`; do not call the user's bare global `alpha` binary.
|
|
14
|
-
- To ask the user a question, write plain chat text and wait for the next user message. Do not call `ask_user_question`, `ask_user`, `ask_followup_question`, or `user_choice`.
|
|
15
|
-
- Do not use `Task` as an agent dispatcher. Use only the visible `subagent` tool when it exists.
|
|
16
|
-
- If a tool returns `Tool not found` or `Invalid URL`, do not retry the same invalid call. Map to a canonical visible tool and valid arguments, or record the capability as blocked.
|
|
17
|
-
|
|
18
7
|
Audit the paper and codebase for: $@
|
|
19
8
|
|
|
20
9
|
Derive a short slug from the audit target (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
|
package/prompts/autoresearch.md
CHANGED
|
@@ -4,17 +4,6 @@ args: <idea>
|
|
|
4
4
|
section: Research Workflows
|
|
5
5
|
topLevelCli: true
|
|
6
6
|
---
|
|
7
|
-
## Tool Discipline (Read First)
|
|
8
|
-
|
|
9
|
-
Tool names are literal. Use only tools visible in the current tool set.
|
|
10
|
-
|
|
11
|
-
- Search with `web_search`; do not call `search_web`, `google_search`, `google:search`, `search_google`, or `WebSearch`.
|
|
12
|
-
- Fetch URLs with `fetch_content`; do not call bare `fetch`, `WebFetch`, `read_url_content`, or pass an array as `url`. Use `urls` for multiple URLs when the tool supports it.
|
|
13
|
-
- Use visible Feynman alpha tools such as `alpha_search` when present. For shell access, call `feynman alpha ...`; do not call the user's bare global `alpha` binary.
|
|
14
|
-
- To ask the user a question, write plain chat text and wait for the next user message. Do not call `ask_user_question`, `ask_user`, `ask_followup_question`, or `user_choice`.
|
|
15
|
-
- Do not use `Task` as an agent dispatcher. Use only the visible `subagent` tool when it exists.
|
|
16
|
-
- If a tool returns `Tool not found` or `Invalid URL`, do not retry the same invalid call. Map to a canonical visible tool and valid arguments, or record the capability as blocked.
|
|
17
|
-
|
|
18
7
|
Start an autoresearch optimization loop for: $@
|
|
19
8
|
|
|
20
9
|
This command runs a bounded foreground research experiment loop using the visible tools in this session.
|
|
@@ -66,14 +55,6 @@ After the baseline and after meaningful iteration milestones, append a concise e
|
|
|
66
55
|
|
|
67
56
|
When reporting results, include every configuration tried from `autoresearch.jsonl` (kept, reverted, and failed) with its metric. Do not claim an effect from the single most favorable setting; state how the result varies across all tried settings and seeds.
|
|
68
57
|
|
|
69
|
-
## Optional tools
|
|
70
|
-
|
|
71
|
-
Use these only when they are visible in the current tool set:
|
|
72
|
-
|
|
73
|
-
- `init_experiment` - one-time session config (name, metric, unit, direction)
|
|
74
|
-
- `run_experiment` - run the benchmark command, capture output and wall-clock time
|
|
75
|
-
- `log_experiment` - record the benchmark result, evidence, and decision in the autoresearch log
|
|
76
|
-
|
|
77
58
|
## Subcommands
|
|
78
59
|
|
|
79
60
|
- `/autoresearch <text>` — start or resume the loop
|
package/prompts/compare.md
CHANGED
|
@@ -4,17 +4,6 @@ args: <topic>
|
|
|
4
4
|
section: Research Workflows
|
|
5
5
|
topLevelCli: true
|
|
6
6
|
---
|
|
7
|
-
## Tool Discipline (Read First)
|
|
8
|
-
|
|
9
|
-
Tool names are literal. Use only tools visible in the current tool set.
|
|
10
|
-
|
|
11
|
-
- Search with `web_search`; do not call `search_web`, `google_search`, `google:search`, `search_google`, or `WebSearch`.
|
|
12
|
-
- Fetch URLs with `fetch_content`; do not call bare `fetch`, `WebFetch`, `read_url_content`, or pass an array as `url`. Use `urls` for multiple URLs when the tool supports it.
|
|
13
|
-
- Use visible Feynman alpha tools such as `alpha_search` when present. For shell access, call `feynman alpha ...`; do not call the user's bare global `alpha` binary.
|
|
14
|
-
- To ask the user a question, write plain chat text and wait for the next user message. Do not call `ask_user_question`, `ask_user`, `ask_followup_question`, or `user_choice`.
|
|
15
|
-
- Do not use `Task` as an agent dispatcher. Use only the visible `subagent` tool when it exists.
|
|
16
|
-
- If a tool returns `Tool not found` or `Invalid URL`, do not retry the same invalid call. Map to a canonical visible tool and valid arguments, or record the capability as blocked.
|
|
17
|
-
|
|
18
7
|
Compare sources for: $@
|
|
19
8
|
|
|
20
9
|
Derive a short slug from the comparison topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
|
|
@@ -23,7 +12,7 @@ Requirements:
|
|
|
23
12
|
- Before starting, outline the comparison plan: which sources to compare, which dimensions to evaluate, expected output structure. Write the plan to `outputs/.plans/<slug>.md`. Briefly summarize the plan to the user and continue immediately. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
|
|
24
13
|
- Use the `researcher` subagent to gather source material when the comparison set is broad, and the `verifier` subagent to verify sources and add inline citations to the final matrix.
|
|
25
14
|
- Build a comparison matrix covering: source, key claim, evidence type, caveats, confidence.
|
|
26
|
-
-
|
|
15
|
+
- Use a Markdown table for quantitative metrics and Mermaid for method or architecture comparisons when the structure is source-supported.
|
|
27
16
|
- Distinguish agreement, disagreement, and uncertainty clearly.
|
|
28
17
|
- Save exactly one comparison to `outputs/<slug>-comparison.md`.
|
|
29
18
|
- End with a `Sources` section containing direct URLs for every source used.
|
package/prompts/deepresearch.md
CHANGED
|
@@ -4,22 +4,8 @@ args: <topic>
|
|
|
4
4
|
section: Research Workflows
|
|
5
5
|
topLevelCli: true
|
|
6
6
|
---
|
|
7
|
-
## Tool Discipline (Read First)
|
|
8
|
-
|
|
9
|
-
Tool names are literal. Use only tools visible in the current tool set.
|
|
10
|
-
|
|
11
|
-
- Search with `web_search`; do not call `search_web`, `google_search`, `google:search`, `search_google`, or `WebSearch`.
|
|
12
|
-
- Fetch URLs with `fetch_content`; do not call bare `fetch`, `WebFetch`, `read_url_content`, or pass an array as `url`. Use `urls` for multiple URLs when the tool supports it.
|
|
13
|
-
- Use visible Feynman alpha tools such as `alpha_search` when present. For shell access, call `feynman alpha ...`; do not call the user's bare global `alpha` binary.
|
|
14
|
-
- To ask the user a question, write plain chat text and wait for the next user message. Do not call `ask_user_question`, `ask_user`, `ask_followup_question`, or `user_choice`.
|
|
15
|
-
- Do not use `Task` as an agent dispatcher. Use only the visible `subagent` tool when it exists.
|
|
16
|
-
- If a tool returns `Tool not found` or `Invalid URL`, do not retry the same invalid call. Map to a canonical visible tool and valid arguments, or record the capability as blocked.
|
|
17
|
-
|
|
18
7
|
Run deep research for: $@
|
|
19
8
|
|
|
20
|
-
This is an execution request, not a request to explain or implement the workflow instructions.
|
|
21
|
-
Execute the workflow. Do not answer by describing the protocol, do not explain these instructions, and do not restate the protocol. Your first actions should be tool calls that create directories and write the plan artifact.
|
|
22
|
-
|
|
23
9
|
## Required Artifacts
|
|
24
10
|
|
|
25
11
|
Derive a short slug from the topic: lowercase, hyphenated, no filler words, at most 5 words.
|
|
@@ -45,8 +31,6 @@ Create `outputs/.plans/<slug>.md` immediately. The plan must include:
|
|
|
45
31
|
|
|
46
32
|
Make the scale decision before assigning owners in the plan. If the topic is a narrow "what is X" explainer, the plan must use lead-owned direct search tasks only; do not allocate researcher subagents in the task ledger.
|
|
47
33
|
|
|
48
|
-
Also save the plan with `memory_remember` using key `deepresearch.<slug>.plan` if that tool is available. If it is not available, continue without it.
|
|
49
|
-
|
|
50
34
|
After writing the plan, stop and ask for explicit confirmation before gathering evidence. Summarize the plan briefly and ask:
|
|
51
35
|
|
|
52
36
|
`Proceed with this deep research plan? Reply "yes" to continue, or tell me what to change.`
|
|
@@ -69,9 +53,7 @@ Use subagents only when decomposition clearly helps:
|
|
|
69
53
|
|
|
70
54
|
## Step 3: Gather Evidence
|
|
71
55
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Avoid crash-prone PDF parsing in this workflow. Do not call `alpha_get_paper` and do not fetch `.pdf` URLs unless the user explicitly asks for PDF extraction. Prefer paper metadata, abstracts, HTML pages, official docs, and web snippets. If only a PDF exists, cite the PDF URL from search metadata and mark full-text PDF parsing as blocked instead of fetching it.
|
|
56
|
+
Prefer abstracts, HTML pages, official docs, and paper metadata. Read full text only for the few papers the conclusions depend on.
|
|
75
57
|
|
|
76
58
|
If direct search was chosen:
|
|
77
59
|
- Skip researcher spawning entirely.
|
|
@@ -88,7 +70,6 @@ If subagents were chosen:
|
|
|
88
70
|
- Use only supported `subagent` keys. Do not add extra keys such as `artifacts` unless the tool schema explicitly exposes them.
|
|
89
71
|
- Use one async `workflowScript` with `await runs.all(...)` for parallel evidence gathering. Each item needs a unique stable `key`, plus its agent, short task, and output path. Set `globalConcurrencyLimit: 4` on the outer call.
|
|
90
72
|
- Read the ordered result array and record each child's `ok`, error, and returned output/artifact paths. Ordinary child failures are collected by `runs.all`; validation or infrastructure failure can still fail the workflow. Do not assume every output exists.
|
|
91
|
-
- Do not name exact tool commands in subagent tasks unless those tool names are visible in the current tool set.
|
|
92
73
|
- Prefer broad guidance such as "use paper search and web search"; if a PDF parser or paper fetch fails, the researcher must continue from metadata, abstracts, and web sources and mark PDF parsing as blocked.
|
|
93
74
|
|
|
94
75
|
Example shape:
|
|
@@ -169,8 +150,6 @@ Consume the review completion result and locate its returned output before proce
|
|
|
169
150
|
|
|
170
151
|
When applying reviewer fixes, do not issue one giant `edit` tool call with many replacements. Use small localized edits only for 1-3 simple corrections. For section rewrites, table rewrites, or more than 3 substantive fixes, read the cited draft and write a corrected full file to `outputs/.drafts/<slug>-revised.md` instead.
|
|
171
152
|
|
|
172
|
-
After applying reviewer, verifier, audit, or PI-style fixes, run an explicit on-disk verification before saying the fixes landed. Use `rg`, `grep`, `diff`, `wc`, `stat`, or a targeted read to prove the old unsupported wording is gone and the replacement wording exists. If an `edit` or `write` tool call fails, do not describe the fix as applied; record the failure in the plan/provenance, retry with a smaller edit or a full corrected file, and verify again. Provenance may only say an issue was fixed when this post-edit verification passed.
|
|
173
|
-
|
|
174
153
|
The final candidate is `outputs/.drafts/<slug>-revised.md` if it exists; otherwise it is `outputs/.drafts/<slug>-cited.md`.
|
|
175
154
|
|
|
176
155
|
## Step 7: Deliver
|
|
@@ -196,6 +175,4 @@ Write provenance next to it as `<slug>.provenance.md`:
|
|
|
196
175
|
|
|
197
176
|
Before responding, verify on disk that all required artifacts exist. If verification could not be completed, set `Verification: BLOCKED` or `PASS WITH NOTES` and list the missing checks.
|
|
198
177
|
|
|
199
|
-
Before responding, also verify that any fixes claimed in the provenance are reflected in the final candidate. If a fix removed a phrase, number, source, or claim, run a targeted `rg`/`grep` check for the removed content and a second check for the corrected content. Do not claim "all patches applied", "all checks pass", or "fixed" unless these commands or reads succeed.
|
|
200
|
-
|
|
201
178
|
Final response should be brief: link the final file, provenance file, and any blocked checks.
|
package/prompts/draft.md
CHANGED
|
@@ -4,17 +4,6 @@ args: <topic>
|
|
|
4
4
|
section: Research Workflows
|
|
5
5
|
topLevelCli: true
|
|
6
6
|
---
|
|
7
|
-
## Tool Discipline (Read First)
|
|
8
|
-
|
|
9
|
-
Tool names are literal. Use only tools visible in the current tool set.
|
|
10
|
-
|
|
11
|
-
- Search with `web_search`; do not call `search_web`, `google_search`, `google:search`, `search_google`, or `WebSearch`.
|
|
12
|
-
- Fetch URLs with `fetch_content`; do not call bare `fetch`, `WebFetch`, `read_url_content`, or pass an array as `url`. Use `urls` for multiple URLs when the tool supports it.
|
|
13
|
-
- Use visible Feynman alpha tools such as `alpha_search` when present. For shell access, call `feynman alpha ...`; do not call the user's bare global `alpha` binary.
|
|
14
|
-
- To ask the user a question, write plain chat text and wait for the next user message. Do not call `ask_user_question`, `ask_user`, `ask_followup_question`, or `user_choice`.
|
|
15
|
-
- Do not use `Task` as an agent dispatcher. Use only the visible `subagent` tool when it exists.
|
|
16
|
-
- If a tool returns `Tool not found` or `Invalid URL`, do not retry the same invalid call. Map to a canonical visible tool and valid arguments, or record the capability as blocked.
|
|
17
|
-
|
|
18
7
|
Write a paper-style draft for: $@
|
|
19
8
|
|
|
20
9
|
Derive a short slug from the topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
|
|
@@ -25,7 +14,7 @@ Requirements:
|
|
|
25
14
|
- Include at minimum: title, abstract, problem statement, related work, method or synthesis, evidence or experiments, limitations, conclusion.
|
|
26
15
|
- Use clean Markdown with LaTeX where equations materially help.
|
|
27
16
|
- Follow the system prompt's provenance rules for all results, figures, charts, images, tables, benchmarks, and quantitative comparisons. If evidence is missing, leave a placeholder or proposed experimental plan instead of claiming an outcome.
|
|
28
|
-
-
|
|
17
|
+
- Use Markdown tables for quantitative comparisons and Mermaid for architectures and pipelines. Plot only source-backed data, and save the plotting script next to the draft. Every figure or table needs provenance.
|
|
29
18
|
- Before delivery, sweep the draft for any claim that sounds stronger than its support. Mark tentative results as tentative and remove unsupported numerics instead of letting the verifier discover them later.
|
|
30
19
|
- Save exactly one draft to `papers/<slug>.md`.
|
|
31
20
|
- End with a `Sources` appendix with direct URLs for all primary references.
|
package/prompts/lit.md
CHANGED
|
@@ -4,17 +4,6 @@ args: <topic-or-lab-or-author>
|
|
|
4
4
|
section: Research Workflows
|
|
5
5
|
topLevelCli: true
|
|
6
6
|
---
|
|
7
|
-
## Tool Discipline (Read First)
|
|
8
|
-
|
|
9
|
-
Tool names are literal. Use only tools visible in the current tool set.
|
|
10
|
-
|
|
11
|
-
- Search with `web_search`; do not call `search_web`, `google_search`, `google:search`, `search_google`, or `WebSearch`.
|
|
12
|
-
- Fetch URLs with `fetch_content`; do not call bare `fetch`, `WebFetch`, `read_url_content`, or pass an array as `url`. Use `urls` for multiple URLs when the tool supports it.
|
|
13
|
-
- Use visible Feynman alpha tools such as `alpha_search` when present. For shell access, call `feynman alpha ...`; do not call the user's bare global `alpha` binary.
|
|
14
|
-
- To ask the user a question, write plain chat text and wait for the next user message. Do not call `ask_user_question`, `ask_user`, `ask_followup_question`, or `user_choice`.
|
|
15
|
-
- Do not use `Task` as an agent dispatcher. Use only the visible `subagent` tool when it exists.
|
|
16
|
-
- If a tool returns `Tool not found` or `Invalid URL`, do not retry the same invalid call. Map to a canonical visible tool and valid arguments, or record the capability as blocked.
|
|
17
|
-
|
|
18
7
|
Investigate the following topic, lab, PI, or author as a literature review: $@
|
|
19
8
|
|
|
20
9
|
Derive a short slug from the topic (lowercase, hyphens, no filler words, ≤5 words). Use this slug for all files in this run.
|
|
@@ -24,7 +13,7 @@ Derive a short slug from the topic (lowercase, hyphens, no filler words, ≤5 wo
|
|
|
24
13
|
1. **Plan** — Outline the scope: key questions, source types to search (papers, web, repos), time period, expected sections, and a small task ledger plus verification log. When the input appears to name a lab, PI, author, institution lab page, or author profile, run the review as a publication-corpus review: find the lab/author identity first, collect the reachable publication list, then map the research trajectory across that corpus. Write the plan to `outputs/.plans/<slug>.md`. Briefly summarize the plan to the user and continue immediately in the same turn with the next tool call; never end a turn with a message that only announces what you will do next. Do not ask for confirmation or wait for a proceed response unless the user explicitly requested plan review.
|
|
25
14
|
- When updating the plan ledger later, keep edits small and valid. If an `edit` tool call fails with a JSON parse error or the replacement would require embedding a large markdown block, rewrite the full corrected plan file with the file-writing tool instead, then continue to final artifact/provenance verification.
|
|
26
15
|
2. **Gather** — Use the `researcher` subagent when the sweep is wide enough to benefit from delegated paper triage before synthesis. For narrow topics, search directly. Researcher outputs go to `<slug>-research-*.md`. For publication-corpus reviews, the lead agent owns identity resolution and writes `notes/<slug>-publications.md` with reachable titles, years, venues, URLs/DOIs, and gaps before delegating trajectory synthesis. Prefer lab publication pages, author profiles, arXiv/OpenReview/Semantic Scholar pages, and paper search results that expose stable source URLs. Do not silently skip assigned questions; mark them `done`, `blocked`, or `superseded`.
|
|
27
|
-
3. **Synthesize** — Separate consensus, disagreements, and open questions. For publication-corpus reviews, also identify 3-5 research trajectories and the 3-5 papers that most changed the corpus direction; rank them by contrastive originality, methodology strength, and relationship to prior art rather than by author prestige alone. When useful, propose concrete next experiments or follow-up reading.
|
|
16
|
+
3. **Synthesize** — Separate consensus, disagreements, and open questions. For publication-corpus reviews, also identify 3-5 research trajectories and the 3-5 papers that most changed the corpus direction; rank them by contrastive originality, methodology strength, and relationship to prior art rather than by author prestige alone. When useful, propose concrete next experiments or follow-up reading. Use Mermaid diagrams for taxonomies, method pipelines, or lab trajectory maps when the structure is source-supported and changes the reader's research decision. Keep the output to research evidence, source coverage, and next research decisions; do not create non-research operational artifacts from a literature review run.
|
|
28
17
|
4. **Cite** — Spawn the `verifier` agent to add inline citations and verify every source URL in the draft.
|
|
29
18
|
5. **Verify** — Spawn the `reviewer` agent to check the cited draft for unsupported claims, logical gaps, zombie sections, and single-source critical findings. Fix FATAL issues before delivering. Note MAJOR issues in Open Questions. If FATAL issues were found, run one more verification pass after the fixes.
|
|
30
19
|
6. **Deliver** — Save the final literature review to `outputs/<slug>.md`. Write a provenance record alongside it as `outputs/<slug>.provenance.md` listing: date, sources consulted vs. accepted vs. rejected, verification status, and intermediate research files used; for publication-corpus reviews, include the publication-log path and unresolved corpus gaps. Before you stop, verify on disk that both files exist; do not stop at an intermediate cited draft alone.
|
package/prompts/log.md
CHANGED
|
@@ -3,17 +3,6 @@ description: Write a durable session log with completed work, findings, open que
|
|
|
3
3
|
section: Project & Session
|
|
4
4
|
topLevelCli: true
|
|
5
5
|
---
|
|
6
|
-
## Tool Discipline (Read First)
|
|
7
|
-
|
|
8
|
-
Tool names are literal. Use only tools visible in the current tool set.
|
|
9
|
-
|
|
10
|
-
- Search with `web_search`; do not call `search_web`, `google_search`, `google:search`, `search_google`, or `WebSearch`.
|
|
11
|
-
- Fetch URLs with `fetch_content`; do not call bare `fetch`, `WebFetch`, `read_url_content`, or pass an array as `url`. Use `urls` for multiple URLs when the tool supports it.
|
|
12
|
-
- Use visible Feynman alpha tools such as `alpha_search` when present. For shell access, call `feynman alpha ...`; do not call the user's bare global `alpha` binary.
|
|
13
|
-
- To ask the user a question, write plain chat text and wait for the next user message. Do not call `ask_user_question`, `ask_user`, `ask_followup_question`, or `user_choice`.
|
|
14
|
-
- Do not use `Task` as an agent dispatcher. Use only the visible `subagent` tool when it exists.
|
|
15
|
-
- If a tool returns `Tool not found` or `Invalid URL`, do not retry the same invalid call. Map to a canonical visible tool and valid arguments, or record the capability as blocked.
|
|
16
|
-
|
|
17
6
|
Write a session log for the current research work.
|
|
18
7
|
|
|
19
8
|
Requirements:
|