@gtheys/pi-flow 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +833 -2
- package/adhoc/tracker.ts +360 -0
- package/aven/client.ts +996 -0
- package/aven/status.ts +395 -0
- package/brainstorm/args.ts +24 -0
- package/brainstorm/artifact.ts +67 -0
- package/brainstorm/paths.ts +43 -0
- package/brainstorm/prompt.ts +172 -0
- package/brainstorm/refs.ts +41 -0
- package/config.schema.json +161 -0
- package/config.ts +577 -0
- package/feedback/args.ts +21 -0
- package/feedback/prompt.ts +177 -0
- package/feedback/triage.ts +88 -0
- package/flow/agent-role.ts +46 -0
- package/flow/answer-wake.ts +212 -0
- package/flow/answer.ts +183 -0
- package/flow/args.ts +48 -0
- package/flow/ask-emitter.ts +331 -0
- package/flow/attribution.ts +145 -0
- package/flow/aven-resolve-exec.ts +95 -0
- package/flow/aven-resolve.ts +80 -0
- package/flow/awaiting-approval.ts +32 -0
- package/flow/binding-heal.ts +68 -0
- package/flow/cost-autopush.ts +162 -0
- package/flow/cost-command.ts +122 -0
- package/flow/cost-rows-journal.ts +296 -0
- package/flow/cost-rows-push.ts +112 -0
- package/flow/cost-rows-rows.ts +209 -0
- package/flow/cost-rows.ts +228 -0
- package/flow/cost.ts +173 -0
- package/flow/durable-refs.ts +287 -0
- package/flow/effect-gate.ts +137 -0
- package/flow/ensure-labels.ts +44 -0
- package/flow/frame.ts +172 -0
- package/flow/gates.ts +211 -0
- package/flow/jira-ref.ts +212 -0
- package/flow/label-gate.ts +149 -0
- package/flow/land-gate.ts +98 -0
- package/flow/lifecycle-policy.ts +162 -0
- package/flow/live-wait.ts +52 -0
- package/flow/liveness.ts +408 -0
- package/flow/loop-deps.ts +210 -0
- package/flow/loop-settle.ts +531 -0
- package/flow/loop.ts +437 -0
- package/flow/orchestrate.ts +45 -0
- package/flow/phase-command.ts +287 -0
- package/flow/phase-emoji.ts +13 -0
- package/flow/phase-prompts.ts +251 -0
- package/flow/picker.ts +307 -0
- package/flow/push.ts +475 -0
- package/flow/reconcile-command.ts +253 -0
- package/flow/reconcile-deps.ts +329 -0
- package/flow/reconcile.ts +738 -0
- package/flow/ref-kind.ts +80 -0
- package/flow/resume-picker.ts +222 -0
- package/flow/resume.ts +116 -0
- package/flow/run-health.ts +252 -0
- package/flow/run-liveness.ts +33 -0
- package/flow/state-metrics.ts +559 -0
- package/flow/status.ts +105 -0
- package/flow/step-output.ts +416 -0
- package/flow/steps.ts +73 -0
- package/flow/terminal-purge.ts +281 -0
- package/flow/turn-generation.ts +19 -0
- package/flow/v2-emission.ts +381 -0
- package/flow/v2-resume.ts +100 -0
- package/flow/vocabulary.ts +261 -0
- package/flow/widget.ts +448 -0
- package/flow/worktree-context.ts +136 -0
- package/flow-diagram/assemble.ts +27 -0
- package/flow-diagram/command.ts +252 -0
- package/flow-diagram/translate.ts +862 -0
- package/flow-diagram/vendor/harness-profiler/LICENSE +21 -0
- package/flow-diagram/vendor/harness-profiler/PIN.md +64 -0
- package/flow-diagram/vendor/harness-profiler/hp.js +960 -0
- package/flow-diagram/vendor/harness-profiler/load.ts +66 -0
- package/flow-diagram/vendor/harness-profiler/view.html +436 -0
- package/gates.ts +20 -0
- package/herdr/sync.ts +355 -0
- package/herdr/viewer.ts +432 -0
- package/implement/args.ts +21 -0
- package/implement/prompt.ts +98 -0
- package/implement/retry.ts +57 -0
- package/implement/routing.ts +31 -0
- package/index.ts +3206 -0
- package/mode-profile.ts +56 -0
- package/package.json +205 -4
- package/phase-state.ts +18 -0
- package/plan/args.ts +20 -0
- package/plan/prompt.ts +251 -0
- package/plan/size-check.ts +46 -0
- package/plan-tools/helpers.ts +177 -0
- package/plan-tools/jira-branch-tool.ts +54 -0
- package/plan-tools/jira-branch.ts +109 -0
- package/plan-tools/jira-issue.ts +85 -0
- package/plan-tools/resolve-feature-path.ts +30 -0
- package/plan-tools/resolve-notes-path.ts +37 -0
- package/plan-tools/resolve-spec-path.ts +31 -0
- package/pr-quality/index.ts +908 -0
- package/review/LICENSE +19 -0
- package/review/deviation.ts +252 -0
- package/review/review.ts +3053 -0
- package/review/sem-guidance.d.mts +8 -0
- package/review/sem-guidance.mjs +89 -0
- package/review/verdict.ts +13 -0
- package/run-state.ts +2046 -0
- package/run-title.ts +91 -0
- package/server/consumer.ts +146 -0
- package/server/daemon.ts +1094 -0
- package/server/lifecycle.ts +679 -0
- package/server/pending.ts +267 -0
- package/server/staleness.ts +320 -0
- package/server/writer.ts +86 -0
- package/shared/diff-base.ts +138 -0
- package/shared/flow-base.ts +210 -0
- package/shared/sonarqube-utils.ts +415 -0
- package/shared/stable-range.ts +102 -0
- package/slugify.ts +13 -0
- package/sonarqube/sonarqube.ts +821 -0
- package/spec-review/approve.ts +91 -0
- package/spec-review/args.ts +21 -0
- package/spec-review/aven-spec.ts +142 -0
- package/spec-review/commands.ts +336 -0
- package/spec-review/escape-regexp.ts +7 -0
- package/spec-review/open-in-pane.ts +166 -0
- package/spec-review/picker.ts +74 -0
- package/spec-review/prompt.ts +72 -0
- package/spec-review/publish-args.ts +33 -0
- package/spec-review/publish.ts +210 -0
- package/telemetry/attributes.ts +118 -0
- package/telemetry/content.ts +140 -0
- package/telemetry/dispatch.ts +521 -0
- package/telemetry/exporter.ts +124 -0
- package/telemetry/index.ts +776 -0
- package/telemetry/loki.ts +224 -0
- package/tools/code-review-parse.ts +518 -0
- package/tools/code-review.ts +312 -0
- package/tools/deviation.ts +737 -0
- package/tools/flow-submit.ts +302 -0
- package/tools/land.ts +608 -0
- package/tools/phase-complete.ts +476 -0
- package/tools/result.ts +18 -0
- package/tools/review-deps.ts +44 -0
- package/tools/run-attempt.ts +312 -0
- package/tools/spec-approve.ts +265 -0
- package/validate/args.ts +22 -0
- package/validate/deviation-gate.ts +229 -0
- package/validate/gate-target.ts +371 -0
- package/validate/gate.ts +79 -0
- package/validate/paths.ts +20 -0
- package/validate/personal.ts +104 -0
- package/validate/prompt.ts +525 -0
- package/validate/review-gate.ts +134 -0
- package/validate/subtask-range.ts +113 -0
- package/work-mode.ts +19 -0
- package/worktree/bootstrap.ts +243 -0
- package/worktree/branch.ts +168 -0
- package/worktree/herdr.ts +447 -0
- package/worktree/index.ts +1447 -0
- package/worktree/orphan.ts +384 -0
- package/worktree/remove-guards.ts +99 -0
- package/worktree/residue.ts +216 -0
- package/worktree/sweep.ts +526 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// AIDEV-NOTE (PMR-R8AG): minimal OTLP/HTTP JSON trace exporter. Hand-rolled
|
|
2
|
+
// on purpose — no OTel SDK dependency, no growing buffers, no retry queue.
|
|
3
|
+
// Fire-and-forget with a short timeout; failures are dropped silently after
|
|
4
|
+
// at most one journal note per process (never a rejected promise into the
|
|
5
|
+
// host). Tempo's OTLP/HTTP receiver accepts this JSON at <endpoint>/v1/traces.
|
|
6
|
+
export interface TelemetrySpan {
|
|
7
|
+
traceId: string
|
|
8
|
+
spanId: string
|
|
9
|
+
parentSpanId?: string
|
|
10
|
+
name: string
|
|
11
|
+
/** OTel span kind: 1 INTERNAL, 2 SERVER, 3 CLIENT. */
|
|
12
|
+
kind: number
|
|
13
|
+
startTimeUnixNano: string
|
|
14
|
+
endTimeUnixNano: string
|
|
15
|
+
attributes: Record<string, string>
|
|
16
|
+
/** 2 = ERROR, 1 = OK, 0 = UNSET. */
|
|
17
|
+
statusCode: number
|
|
18
|
+
statusMessage?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ExportOutcome {
|
|
22
|
+
ok: boolean
|
|
23
|
+
error?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type TelemetryFetch = (
|
|
27
|
+
url: string,
|
|
28
|
+
init: {
|
|
29
|
+
method: string
|
|
30
|
+
headers: Record<string, string>
|
|
31
|
+
body: string
|
|
32
|
+
signal: AbortSignal
|
|
33
|
+
},
|
|
34
|
+
) => Promise<{ status: number }>
|
|
35
|
+
|
|
36
|
+
function attrValue(value: string): { stringValue: string } {
|
|
37
|
+
return { stringValue: value }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Build the OTLP export request body (pure). Attribute values ride as
|
|
42
|
+
* strings; numeric gen_ai usage tokens are formatted strings, which OTLP
|
|
43
|
+
* JSON accepts and Tempo indexes fine.
|
|
44
|
+
*/
|
|
45
|
+
export function buildOtlpBody(
|
|
46
|
+
resourceAttributes: Record<string, string>,
|
|
47
|
+
spans: readonly TelemetrySpan[],
|
|
48
|
+
): string {
|
|
49
|
+
const resourceAttrs = Object.keys(resourceAttributes).map((key) => ({
|
|
50
|
+
key,
|
|
51
|
+
value: attrValue(resourceAttributes[key]),
|
|
52
|
+
}))
|
|
53
|
+
const otlpSpans = spans.map((span) => {
|
|
54
|
+
const out: Record<string, unknown> = {
|
|
55
|
+
traceId: span.traceId,
|
|
56
|
+
spanId: span.spanId,
|
|
57
|
+
name: span.name,
|
|
58
|
+
kind: span.kind,
|
|
59
|
+
startTimeUnixNano: span.startTimeUnixNano,
|
|
60
|
+
endTimeUnixNano: span.endTimeUnixNano,
|
|
61
|
+
attributes: Object.keys(span.attributes).map((key) => ({
|
|
62
|
+
key,
|
|
63
|
+
value: attrValue(span.attributes[key]),
|
|
64
|
+
})),
|
|
65
|
+
status: { code: span.statusCode },
|
|
66
|
+
}
|
|
67
|
+
if (span.parentSpanId !== undefined) {
|
|
68
|
+
out.parentSpanId = span.parentSpanId
|
|
69
|
+
}
|
|
70
|
+
if (span.statusMessage !== undefined) {
|
|
71
|
+
out.status = { code: span.statusCode, message: span.statusMessage }
|
|
72
|
+
}
|
|
73
|
+
return out
|
|
74
|
+
})
|
|
75
|
+
return JSON.stringify({
|
|
76
|
+
resourceSpans: [
|
|
77
|
+
{
|
|
78
|
+
resource: { attributes: resourceAttrs },
|
|
79
|
+
scopeSpans: [
|
|
80
|
+
{
|
|
81
|
+
scope: { name: 'pi-flow-telemetry', version: '1.0.0' },
|
|
82
|
+
spans: otlpSpans,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* POST one batch of spans. Timeout via AbortSignal (default 2500 ms);
|
|
92
|
+
* any failure maps to {ok:false, error} — the caller decides whether to
|
|
93
|
+
* note it once, then drops it.
|
|
94
|
+
*/
|
|
95
|
+
export async function exportSpans(
|
|
96
|
+
endpoint: string,
|
|
97
|
+
headers: Record<string, string>,
|
|
98
|
+
resourceAttributes: Record<string, string>,
|
|
99
|
+
spans: readonly TelemetrySpan[],
|
|
100
|
+
fetchImpl: TelemetryFetch,
|
|
101
|
+
timeoutMs = 2500,
|
|
102
|
+
): Promise<ExportOutcome> {
|
|
103
|
+
if (spans.length === 0) return { ok: true }
|
|
104
|
+
const controller = new AbortController()
|
|
105
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
106
|
+
try {
|
|
107
|
+
const base = endpoint.replace(/\/+$/, '')
|
|
108
|
+
const response = await fetchImpl(`${base}/v1/traces`, {
|
|
109
|
+
method: 'POST',
|
|
110
|
+
headers: { 'content-type': 'application/json', ...headers },
|
|
111
|
+
body: buildOtlpBody(resourceAttributes, spans),
|
|
112
|
+
signal: controller.signal,
|
|
113
|
+
})
|
|
114
|
+
if (response.status < 200 || response.status >= 300) {
|
|
115
|
+
return { ok: false, error: `OTLP endpoint responded ${response.status}` }
|
|
116
|
+
}
|
|
117
|
+
return { ok: true }
|
|
118
|
+
} catch (err) {
|
|
119
|
+
const message = err instanceof Error ? err.message : `${err}`
|
|
120
|
+
return { ok: false, error: message }
|
|
121
|
+
} finally {
|
|
122
|
+
clearTimeout(timer)
|
|
123
|
+
}
|
|
124
|
+
}
|