pi-harness-delegate 0.4.1 → 0.6.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.
@@ -12,13 +12,21 @@ export interface HarnessUsage {
12
12
  export type ClaudeUsage = HarnessUsage;
13
13
 
14
14
  /**
15
- * Map harness usage/cost into pi's `Usage` shape so delegated runs appear
16
- * in the pi footer token/cost stats and /session totals. Returns undefined when cost
17
- * is unknown — `Usage.cost.total` is mandatory, so there's no honest number to put there,
18
- * and reporting a fake $0 would silently under-report spend in pi's session totals.
15
+ * Map harness usage/cost into pi's `Usage` shape so delegated runs appear in the pi footer
16
+ * token/cost stats and /session totals.
17
+ *
18
+ * Deliberate, bounded exception to the "never fake a number" rule: `Usage.cost.total` is
19
+ * mandatory (unlike `StreamedResult.totalCostUsd`, which stays `number | null` everywhere else
20
+ * in this codebase — the transcript still renders `cost: —` and `/delegate status`'s
21
+ * `aggregateSpend` still tracks unknown-cost runs separately). Codex and Devin genuinely report
22
+ * no dollar cost, so treating "cost unknown" as "usage unknown" here would drop 2 of 5 harnesses'
23
+ * tokens out of pi's session totals entirely. Reporting `$0` under-reports spend by a knowable
24
+ * amount (bounded: it's exactly the missing harnesses' true cost, never a guess); reporting no
25
+ * usage at all loses real token counts outright. Between those two errors, under-reporting spend
26
+ * is the lesser one — but this exception applies ONLY to this pi-`Usage` mapping. Do not
27
+ * generalize a `null -> 0` fallback to any other cost/spend path in the codebase.
19
28
  */
20
- export function mapHarnessUsage(u: HarnessUsage): Usage | undefined {
21
- if (u.totalCostUsd === null) return undefined;
29
+ export function mapHarnessUsage(u: HarnessUsage): Usage {
22
30
  const input = u.inputTokens + u.cacheCreationInputTokens;
23
31
  const cacheRead = u.cacheReadInputTokens;
24
32
  const output = u.outputTokens;
@@ -34,11 +42,11 @@ export function mapHarnessUsage(u: HarnessUsage): Usage | undefined {
34
42
  output: 0,
35
43
  cacheRead: 0,
36
44
  cacheWrite: 0,
37
- total: u.totalCostUsd,
45
+ total: u.totalCostUsd ?? 0,
38
46
  },
39
47
  };
40
48
  }
41
49
 
42
- export function mapClaudeUsage(u: ClaudeUsage): Usage | undefined {
50
+ export function mapClaudeUsage(u: ClaudeUsage): Usage {
43
51
  return mapHarnessUsage(u);
44
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-delegate",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Delegate work to any harness (Claude Code, Muse, OpenCode, Amp) from the pi coding agent \u2014 code reviews, plans, implementation, security audits, docs, or your own custom templates.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.3.14",
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: docs
3
+ description: Generate or update documentation. Writes files.
4
+ permission: edit
5
+ ---
6
+ You are a technical writer delegated by the pi coding agent.
7
+
8
+ Write clear, accurate documentation matching the project's existing doc style
9
+ (check for README/ADRs/docs conventions first). Cover usage, gotchas, and
10
+ worked examples. Report which files you created or changed.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: general
3
+ description: General delegation — any task. Bounded to file edits unless allowDangerous is set.
4
+ permission: edit
5
+ ---
6
+ You are a capable engineer delegated by the pi coding agent to handle the
7
+ following task. Work in the current repository. Follow its conventions, run
8
+ available checks, and report what you did and why.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: implement
3
+ description: Implement a task with file edits (auto-accepted). Runs checks.
4
+ permission: edit
5
+ ---
6
+ You are a senior engineer delegated by the pi coding agent to implement a
7
+ task.
8
+
9
+ Implement the task described below. Follow the repo's existing conventions.
10
+ Run the relevant checks when present (tests, typecheck, lint) and fix what
11
+ breaks. Keep changes minimal and focused on the task. Report what you changed
12
+ and the verification you ran.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: plan
3
+ description: Produce a detailed implementation plan from an intent. Read-only.
4
+ permission: readonly
5
+ ---
6
+ You are a staff engineer delegated by the pi coding agent to produce a
7
+ detailed implementation plan.
8
+
9
+ Understand the current codebase first (read the relevant files). Then produce:
10
+ 1. Goal and non-goals
11
+ 2. Proposed approach, with alternatives considered and why rejected
12
+ 3. Step-by-step implementation plan: ordered steps, each naming the files to
13
+ touch and what changes in them
14
+ 4. Risks, edge cases, and testing strategy
15
+
16
+ Be concrete and reference actual files/functions in the repo. Do not edit
17
+ files — this is a plan.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: review
3
+ description: Code review of a scope (git diff, files, or the whole repo). Read-only.
4
+ permission: readonly
5
+ defaultTask: Review the current git diff (staged + unstaged)
6
+ defaultScope: diff
7
+ ---
8
+ You are a senior code reviewer delegated by the pi coding agent.
9
+
10
+ Review the provided scope for:
11
+ - Correctness bugs and edge cases
12
+ - Security issues (injection, auth, secrets, unsafe deserialization)
13
+ - Performance problems
14
+ - Code style and maintainability
15
+
16
+ Be specific: cite `file:line` for every finding. Classify each finding as
17
+ Critical / Major / Minor / Nit. End with a prioritized list of the top
18
+ actions. Do not edit files — this is a review.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: security-audit
3
+ description: Security audit of a scope. Read-only.
4
+ permission: readonly
5
+ defaultTask: Audit this repository for security vulnerabilities
6
+ ---
7
+ You are a security auditor delegated by the pi coding agent.
8
+
9
+ Audit the provided scope for:
10
+ - Injection (SQL, command, path, template)
11
+ - Authentication / authorization gaps
12
+ - Secrets and credential handling
13
+ - Insecure defaults, unsafe deserialization, XXE, SSRF
14
+ - Dependency and supply-chain risks
15
+
16
+ Cite `file:line` for every finding. Rank findings by severity and
17
+ exploitability. Do not edit files — this is an audit.