pi-background-tasks 0.9.0 → 1.0.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/BACKGROUND-TASKS-INSTRUCTIONS.md +63 -0
- package/PUBLISHING.md +43 -29
- package/README.md +233 -441
- package/TESTING.md +16 -10
- package/TEST_PLAN.md +43 -17
- package/docs/INDEX.md +157 -0
- package/docs/api/eventbus-v1.md +166 -0
- package/docs/assets/architecture.svg +78 -0
- package/docs/assets/footer-dock.svg +47 -0
- package/docs/assets/logo.svg +49 -0
- package/docs/attestations.json +189 -0
- package/docs/choose-a-workflow.md +98 -0
- package/docs/commands/bg-clear.md +70 -0
- package/docs/commands/bg-update.md +82 -0
- package/docs/commands/bg.md +90 -0
- package/docs/commands/fusion-models.md +70 -0
- package/docs/commands/fusion.md +69 -0
- package/docs/commands/jobs.md +74 -0
- package/docs/commands/kill.md +82 -0
- package/docs/commands/logs.md +90 -0
- package/docs/commands/task-manager.md +109 -0
- package/docs/concepts/completion-delivery.md +66 -0
- package/docs/concepts/context-projection-and-budgeting.md +79 -0
- package/docs/getting-started.md +122 -0
- package/docs/manifest.json +1825 -0
- package/docs/operations/configuration.md +110 -0
- package/docs/operations/releasing.md +67 -0
- package/docs/operations/testing.md +101 -0
- package/docs/operations/troubleshooting.md +38 -0
- package/docs/read-before-edit.md +94 -0
- package/docs/reference/runtime-contracts.md +213 -0
- package/docs/reference/shortcuts-and-dock.md +70 -0
- package/docs/subsystems/attested-pi-runs.md +141 -0
- package/docs/subsystems/background-task-runtime.md +85 -0
- package/docs/subsystems/child-launch-durability-and-safety.md +57 -0
- package/docs/subsystems/delegation.md +190 -0
- package/docs/subsystems/docs-freshness-gate.md +26 -0
- package/docs/subsystems/fusion.md +123 -0
- package/docs/subsystems/host-ui-and-telemetry.md +83 -0
- package/docs/tools/bg_delegate.md +193 -0
- package/docs/tools/bg_kill.md +114 -0
- package/docs/tools/bg_logs.md +133 -0
- package/docs/tools/bg_result.md +120 -0
- package/docs/tools/bg_run.md +168 -0
- package/docs/tools/bg_run_pi_attested.md +170 -0
- package/docs/tools/bg_status.md +111 -0
- package/docs/tools/fusion_investigate.md +116 -0
- package/docs/tools/fusion_reason.md +75 -0
- package/docs/tools/fusion_research.md +162 -0
- package/docs/tools/fusion_validate.md +206 -0
- package/logo.png +0 -0
- package/package.json +27 -9
- package/src/core/delegate/budget.ts +1 -1
- package/src/core/delegate/launch.ts +5 -0
- package/src/core/fusion/artifacts.ts +34 -4
- package/src/core/fusion/budget.ts +112 -20
- package/src/core/fusion/child-protocol.ts +82 -0
- package/src/core/fusion/clean-context.ts +91 -0
- package/src/core/fusion/config.ts +124 -35
- package/src/core/fusion/context.ts +29 -7
- package/src/core/fusion/evaluation.ts +392 -15
- package/src/core/fusion/orchestrator.ts +217 -23
- package/src/core/fusion/pi-child.ts +227 -24
- package/src/core/fusion/prompts.ts +39 -26
- package/src/core/fusion/source-policy.ts +257 -0
- package/src/core/fusion/types.ts +156 -11
- package/src/core/fusion/web-fetch.ts +104 -15
- package/src/core/fusion/workflows.ts +119 -65
- package/src/extension.ts +3 -3
- package/src/fusion-child-extension.ts +375 -141
- package/src/fusion-extension.ts +585 -240
- package/src/testing/normalize.ts +0 -22
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# pi-background-tasks — Mandatory Agent Gateway
|
|
2
|
+
|
|
3
|
+
**Read this before you read code, edit docs, edit code, or run anything in this package.**
|
|
4
|
+
This gateway is for AI agents maintaining `pi-background-tasks`. It is package-local, deterministic, and intentionally stricter than generic repo instructions.
|
|
5
|
+
|
|
6
|
+
**Logo reference:** use the package-local docs logo when present: [`docs/assets/logo.svg`](docs/assets/logo.svg). Do not invent remote logos; asset files remain asset-owner territory and must be verified in the docs/assets payload check.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Required read-before-edit order
|
|
11
|
+
|
|
12
|
+
1. [`docs/INDEX.md`](docs/INDEX.md) — generated package navigation index. If it is absent, stale, or not generated yet, stop relying on memory and report that the docs-engine lane must create/update it.
|
|
13
|
+
2. [`docs/read-before-edit.md`](docs/read-before-edit.md) — generated source-path to owning-doc read gate. If absent or stale, run/ask for the docs-engine gate before editing production sources.
|
|
14
|
+
3. The owning authored doc for the surface you are touching.
|
|
15
|
+
|
|
16
|
+
Current authored ownership map:
|
|
17
|
+
|
|
18
|
+
| Surface/source area | Owning doc |
|
|
19
|
+
|---|---|
|
|
20
|
+
| EventBus API; `src/core/extension-api.ts` | `docs/api/eventbus-v1.md` |
|
|
21
|
+
| Shared context projection and estimator; `src/core/context/**` | `docs/concepts/context-projection-and-budgeting.md` |
|
|
22
|
+
| Pi child launch resolution and durable file primitives; `src/core/pi-launch.ts`, `src/core/durable-fs.ts` | `docs/subsystems/child-launch-durability-and-safety.md` |
|
|
23
|
+
| Paths, artifacts, config, env, defaults, schema registry | `docs/reference/runtime-contracts.md` |
|
|
24
|
+
| Symptom triage | `docs/operations/troubleshooting.md` |
|
|
25
|
+
| QA/test operations | `docs/operations/testing.md`, then `TESTING.md`, then `TEST_PLAN.md` |
|
|
26
|
+
| Release/package maintenance | `docs/operations/releasing.md`, then `PUBLISHING.md` |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Hard rules
|
|
31
|
+
|
|
32
|
+
- **Code is authority for runtime facts; docs describe code.** Do not change code to satisfy prose. When code and docs disagree, update docs or file a code-owner blocker.
|
|
33
|
+
- **Generated regions are not hand-edited.** Regions named `<!-- pi-docs:begin ... -->` / `<!-- pi-docs:end ... -->`, `docs/INDEX.md`, `docs/read-before-edit.md`, README generated facts, and `docs/manifest.json` belong to the docs engine.
|
|
34
|
+
- **No silent truncation, fallback, or route substitution.** Oversized data must be persisted with hashes or rejected loudly. Unavailable model routes, missing context windows, stale config, malformed frames, missing artifacts, and unknown schemas are hard errors.
|
|
35
|
+
- **Parent and child tools are distinct.** Parent tools include `bg_run`, `bg_delegate`, `bg_result`, `bg_status`, `bg_logs`, `bg_kill`, `bg_run_pi_attested`, and the public Fusion tools. Delegate children are inspect-only (`read`, `grep`, `find`, `ls`, `delegate_read_artifact`). Fusion children receive only the workflow-specific candidate tools; evaluator/merger are no-tools.
|
|
36
|
+
- **Frontier routing is subscription-only.** GPT/Codex and Claude-class work must use Pi subscription/OAuth channels. Never route them through metered OpenAI, Anthropic API, OpenRouter, Azure, or other paid API channels.
|
|
37
|
+
- **Durability and integrity are contract surfaces.** Terminal task truth is published only after output/metadata durability. Delegate/Fusion artifacts and attested Pi sidecars carry hashes and schema versions; do not replace these with best-effort writes.
|
|
38
|
+
- **No self-certification.** If a doc freshness or attestation mechanism exists, do not stamp the same change as verified without the required independent check. If the mechanism is absent, say so plainly.
|
|
39
|
+
- **Do not use Fusion tools or commands for package maintenance.** Read files and run focused local checks only.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Runtime roots
|
|
44
|
+
|
|
45
|
+
- Task runtime: `.pi/tasks/<session-id>-<pid>/` under the active project cwd.
|
|
46
|
+
- Fusion runtime: `.pi/fusion/<session-id>-<pid>/<run-id>/` under the active project cwd.
|
|
47
|
+
- Delegate artifacts: task-owned artifact directories referenced from task metadata/result packages.
|
|
48
|
+
- Fusion model config: `fusion-models.json` under Pi's agent directory (`getAgentDir()`), not the project `.pi/tasks` tree.
|
|
49
|
+
- Package entrypoint: `extensions/background-tasks.ts` via `package.json.pi.extensions`.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Docs generate/verify/attestation workflow
|
|
54
|
+
|
|
55
|
+
Current `package.json` exposes the docs-engine lane:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run docs:generate
|
|
59
|
+
npm run docs:verify
|
|
60
|
+
npm run docs:attest/record -- <doc_id> --reviewer <identity-after-semantic-review> --verdict PASS --notes <review-notes>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`npm run docs:attest` is an alias for the attestation recorder and still requires a doc id, reviewer, verdict, and notes after semantic review. Do not self-award PASS. For docs-only maintenance under a constrained operator request, use the requested focused subset (frontmatter, package-local links, targeted source/doc grep) and report that full docs verification/attestation was not run.
|
package/PUBLISHING.md
CHANGED
|
@@ -1,67 +1,81 @@
|
|
|
1
1
|
# Publishing pi-background-tasks
|
|
2
2
|
|
|
3
|
-
Release checklist for npm publishing and standalone git publishing.
|
|
3
|
+
Release checklist for npm publishing and standalone git publishing.
|
|
4
|
+
|
|
5
|
+
The release version is always read from `package.json`:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# From the pi-background-tasks package root:
|
|
9
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
10
|
+
printf 'pi-background-tasks@%s\n' "$VERSION"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Observed standalone git tags currently stop at `v0.6.0`; do **not** advertise a `v$VERSION` git install target until that tag exists in the standalone package repository.
|
|
4
14
|
|
|
5
15
|
## Preconditions
|
|
6
16
|
|
|
7
17
|
- npm account with publish rights for `pi-background-tasks`.
|
|
8
|
-
- Standalone GitHub repository
|
|
9
|
-
- Clean worktree.
|
|
10
|
-
-
|
|
18
|
+
- Standalone GitHub repository: `github.com/ismailsaleekh/pi-background-tasks`.
|
|
19
|
+
- Clean worktree and final release commit in the standalone package repository.
|
|
20
|
+
- Frontier model evidence, if any, uses Pi subscription/OAuth channels only; never metered APIs.
|
|
21
|
+
- No automated publish, push, or tag from repair runs unless the operator explicitly requests it.
|
|
11
22
|
|
|
12
|
-
##
|
|
23
|
+
## Ordinary release checks
|
|
13
24
|
|
|
14
25
|
```bash
|
|
15
|
-
|
|
16
|
-
npm run test
|
|
17
|
-
npm run test:
|
|
26
|
+
npm run typecheck
|
|
27
|
+
npm run test:type-safety
|
|
28
|
+
npm run test:unit
|
|
29
|
+
npm run test:sdk
|
|
30
|
+
npm run test:rpc
|
|
31
|
+
npm run test:component
|
|
32
|
+
npm run test:package
|
|
33
|
+
npm run test:hook-contract
|
|
18
34
|
npm run smoke
|
|
19
35
|
npm run smoke:large-context
|
|
36
|
+
npm run docs:verify
|
|
37
|
+
npm run payload:check
|
|
38
|
+
# On a tag ref only: GITHUB_REF_TYPE=tag GITHUB_REF_NAME=v$VERSION npm run release:check-version
|
|
20
39
|
npm run pack:dry-run
|
|
21
40
|
npm run test:compat
|
|
22
41
|
npm view pi-background-tasks name version --json
|
|
23
42
|
```
|
|
24
43
|
|
|
25
|
-
`npm run test:
|
|
44
|
+
`npm run test:full` is the full interactive gate (default gate plus PTY and agent-loop). Run it when certifying full TUI/agent-loop behavior, not for docs-only maintenance.
|
|
26
45
|
|
|
27
|
-
|
|
46
|
+
## Payload verification
|
|
47
|
+
|
|
48
|
+
Use `npm pack --dry-run --json --ignore-scripts` output as the payload source of truth for payload inspection. Verify that `extensions/`, `src/`, `docs/`, `README.md`, `TESTING.md`, `TEST_PLAN.md`, `PUBLISHING.md`, `BACKGROUND-TASKS-INSTRUCTIONS.md`, root `logo.png`, and `LICENSE` match current `package.json.files`, and that tests/scripts/local `.pi` artifacts/node_modules/nested tarballs are excluded.
|
|
28
49
|
|
|
29
50
|
## Publish to npm
|
|
30
51
|
|
|
52
|
+
Only after operator approval:
|
|
53
|
+
|
|
31
54
|
```bash
|
|
32
|
-
cd packages/pi-background-tasks
|
|
33
55
|
npm login
|
|
34
56
|
npm publish --access public
|
|
35
57
|
```
|
|
36
58
|
|
|
37
|
-
|
|
59
|
+
Post-publish smoke with isolated Pi state:
|
|
38
60
|
|
|
39
61
|
```bash
|
|
40
|
-
PI_CODING_AGENT_DIR=$(mktemp -d) pi -e npm:pi-background-tasks
|
|
41
|
-
pi install npm:pi-background-tasks
|
|
62
|
+
PI_CODING_AGENT_DIR=$(mktemp -d) pi -e npm:pi-background-tasks@$VERSION --offline --no-tools --no-session -p "/jobs"
|
|
63
|
+
pi install npm:pi-background-tasks@$VERSION
|
|
42
64
|
```
|
|
43
65
|
|
|
44
|
-
##
|
|
66
|
+
## Standalone git tag certification
|
|
45
67
|
|
|
46
|
-
|
|
68
|
+
Pi git package installs treat the repository root as the package root. Do not point Pi at the `ai-pipeline` monorepo root for this package.
|
|
47
69
|
|
|
48
|
-
|
|
49
|
-
cd packages/pi-background-tasks
|
|
50
|
-
git status --short --branch
|
|
51
|
-
git log --oneline -3
|
|
52
|
-
git remote -v
|
|
53
|
-
git push origin main
|
|
54
|
-
git tag v0.9.0
|
|
55
|
-
git push origin v0.9.0
|
|
56
|
-
```
|
|
70
|
+
Before any git install instructions are published, verify in the standalone repo that tag `v$VERSION` exists and points at the release commit. `npm run release:check-version` requires an explicit tag ref (`GITHUB_REF_TYPE=tag`, `GITHUB_REF_NAME=v$VERSION`) and never publishes. If the tag does not exist, the git channel is not certified for this release.
|
|
57
71
|
|
|
58
|
-
|
|
72
|
+
Git install smoke only after the tag exists:
|
|
59
73
|
|
|
60
74
|
```bash
|
|
61
|
-
PI_CODING_AGENT_DIR=$(mktemp -d) pi -e git:github.com/ismailsaleekh/pi-background-tasks@
|
|
62
|
-
pi install git:github.com/ismailsaleekh/pi-background-tasks@
|
|
75
|
+
PI_CODING_AGENT_DIR=$(mktemp -d) pi -e git:github.com/ismailsaleekh/pi-background-tasks@v$VERSION --offline --no-tools --no-session -p "/jobs"
|
|
76
|
+
pi install git:github.com/ismailsaleekh/pi-background-tasks@v$VERSION
|
|
63
77
|
```
|
|
64
78
|
|
|
65
79
|
## pi.dev/packages
|
|
66
80
|
|
|
67
|
-
The package includes the `pi-package` keyword and a `pi.extensions` manifest. After npm publish, it should be discoverable by pi.dev package indexing. If it does not appear automatically,
|
|
81
|
+
The package includes the `pi-package` keyword and a `pi.extensions` manifest. After npm publish, it should be discoverable by pi.dev package indexing. If it does not appear automatically, refresh according to the package-gallery process.
|