@brainervirus/workit-pi 6.0.0 → 7.0.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 CHANGED
@@ -1,26 +1,24 @@
1
1
  # @brainervirus/workit-pi
2
2
 
3
3
  [![CI](https://github.com/BrainerVirus/workit/actions/workflows/ci.yml/badge.svg)](https://github.com/BrainerVirus/workit/actions/workflows/ci.yml)
4
- [![license: MIT](https://img.shields.io/badge/license-MIT-green.svg)](../../LICENSE)
5
-
6
- Workit native extension for Pi (stock 0.85.1 package contract) — seven core-backed operation tools plus read-only `workit_context`, eleven method skills, session/compaction continuity, and a coordinator that supervises fresh reviewer/investigator processes plus explicitly scoped implementers.
7
-
8
- ## Requirements
9
-
10
- - **Node.js ≥ 24**
11
- - **Pi coding agent 0.85.1** (peer dependency)
12
-
13
- ## Install
14
-
15
- Install this package alongside the Pi peer dependency. Pi discovers the
16
- extension and skills through the `pi` manifest section in `package.json`
17
- (`./dist/workit.js` plus `./skills`); see the Pi documentation for how it
18
- resolves extension packages in your setup.
19
-
20
- ## Notes
21
-
22
- - Supervised implementer workers run as observed child processes; they no longer acquire a checkout lease. Cancellation or restart uncertainty still blocks a replacement worker.
23
- - The extension is a workflow control, not an OS sandbox: a supported literal
24
- branch-creation command is checked against workspace naming policy; other
25
- shell forms stay under the host's native permission rules.
26
- - Pi project trust still gates mutations. Git and forge effects are bounded by Pi's own permissions plus the workspace autonomy grants (`workit grant show`); Workit asks no consent prompts of its own.
4
+ [![license: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/BrainerVirus/workit/blob/main/LICENSE)
5
+
6
+ [Workit](https://github.com/BrainerVirus/workit) for Pi (stock 0.85.1): a native extension with the
7
+ seven task families plus read-only `workit_context`, the eleven method
8
+ skills, session and compaction continuity, and a coordinator that launches
9
+ fresh reviewer/investigator processes and scoped implementers. Requires
10
+ Node.js 24+.
11
+
12
+ ```bash
13
+ pi install npm:@brainervirus/workit-pi
14
+ pi install ./packages/workit-pi -l --approve # local checkout
15
+ ```
16
+
17
+ Pi discovers the extension and skills from the package's `pi` manifest
18
+ (`./dist/workit.js`, `./skills`). Pi project trust still gates mutations.
19
+ The `tool_call` boundary applies branch policy and the
20
+ [before-write gate](https://github.com/BrainerVirus/workit/blob/main/docs/guides/verification.md) to write, edit and recognizable bash
21
+ writes (unrecognized shell writes stay agent-guided; an extension is not an OS
22
+ sandbox). Tools take flat fields.
23
+ Delivery limits come from Pi's permissions plus the workspace
24
+ [grants](https://github.com/BrainerVirus/workit/blob/main/docs/guides/grants.md).
package/dist/worker.js CHANGED
@@ -7206,6 +7206,14 @@ function object(shape, params) {
7206
7206
  };
7207
7207
  return new ZodObject(def);
7208
7208
  }
7209
+ function looseObject(shape, params) {
7210
+ return new ZodObject({
7211
+ type: "object",
7212
+ shape,
7213
+ catchall: unknown(),
7214
+ ...normalizeParams(params)
7215
+ });
7216
+ }
7209
7217
  var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
7210
7218
  $ZodUnion.init(inst, def);
7211
7219
  ZodType.init(inst, def);
@@ -7607,76 +7615,16 @@ var provenanceSchema = object({
7607
7615
  workerId: nullableId
7608
7616
  }).strict();
7609
7617
  var entrySchema = (data) => object({ id, recordedAt: utc, provenance: provenanceSchema, data }).strict();
7610
- var factSchema = object({
7611
- statement: text,
7612
- basis: _enum(["observed", "inferred", "unknown"]),
7613
- refs: array(refSchema)
7614
- }).strict().check((ctx) => {
7615
- if (ctx.value.basis === "observed" && ctx.value.refs.length === 0)
7616
- ctx.issues.push({
7617
- code: "custom",
7618
- input: ctx.value,
7619
- message: "observed facts require supporting references",
7620
- path: ["refs"]
7621
- });
7622
- });
7623
- var signalSchema = object({
7624
- value: union([boolean2(), literal("unknown")]),
7625
- basis: _enum(["observed", "inferred", "unknown"]),
7626
- reason: text,
7618
+ var RISK_TIERS = ["trivial", "normal", "high"];
7619
+ var judgmentSchema = object({
7620
+ riskTier: _enum(RISK_TIERS),
7621
+ behaviorChange: boolean2(),
7622
+ productChoiceOpen: boolean2(),
7623
+ needsPlan: boolean2(),
7624
+ note: text.nullable(),
7627
7625
  refs: array(refSchema)
7628
- }).strict().check((ctx) => {
7629
- const signal = ctx.value;
7630
- const valid = signal.value === "unknown" ? signal.basis === "unknown" : signal.basis === "observed" || signal.basis === "inferred";
7631
- if (!valid)
7632
- ctx.issues.push({
7633
- code: "custom",
7634
- input: signal,
7635
- message: "signal value and basis disagree",
7636
- path: []
7637
- });
7638
- if (signal.basis === "observed" && signal.refs.length === 0)
7639
- ctx.issues.push({
7640
- code: "custom",
7641
- input: signal,
7642
- message: "observed signals require supporting references",
7643
- path: ["refs"]
7644
- });
7645
- });
7646
- var signalSet = object({
7647
- approachUnknown: signalSchema,
7648
- productChoiceOpen: signalSchema,
7649
- behaviorChange: signalSchema,
7650
- mechanicalLowRisk: signalSchema,
7651
- durableAgreementNeeded: signalSchema,
7652
- coordinationPlanNeeded: signalSchema,
7653
- helperUseful: signalSchema,
7654
- testFirstPractical: signalSchema
7655
- }).strict();
7656
- var consequenceSchema = object({
7657
- area: _enum([
7658
- "behavior",
7659
- "public_contract",
7660
- "data",
7661
- "security",
7662
- "operations",
7663
- "reversibility",
7664
- "consumers"
7665
- ]),
7666
- fact: factSchema
7667
- }).strict();
7668
- var verificationSchema = object({
7669
- claim: text,
7670
- scope: scopeSchema,
7671
- availableChecks: array(refSchema),
7672
- gaps: array(text)
7673
- }).strict();
7674
- var assessmentSchema = object({
7675
- facts: array(factSchema),
7676
- signals: signalSet,
7677
- consequences: array(consequenceSchema),
7678
- verification: array(verificationSchema)
7679
7626
  }).strict();
7627
+ var legacyAssessmentSchema = looseObject({});
7680
7628
  var constraintSchema = object({
7681
7629
  id: nonEmpty,
7682
7630
  kind: _enum(["host", "project", "user"]),
@@ -7912,7 +7860,8 @@ var taskRecordSchema = object({
7912
7860
  progress: progressSchema,
7913
7861
  pauseReason: text.nullable().optional(),
7914
7862
  runtime: runtimeSchema.optional(),
7915
- assessments: array(entrySchema(assessmentSchema)),
7863
+ assessments: array(entrySchema(legacyAssessmentSchema)),
7864
+ judgments: array(entrySchema(judgmentSchema)).optional(),
7916
7865
  policy: policySchema.nullable(),
7917
7866
  policyChanges: array(policyChangeSchema),
7918
7867
  candidates: array(candidateSchema),
@@ -8035,14 +7984,15 @@ var taskOperations = {
8035
7984
  decisionIds: array(id).optional()
8036
7985
  })
8037
7986
  };
7987
+ var rawJudgment = record(string2(), unknown());
8038
7988
  var policyOperations = {
8039
7989
  assess: operation({
8040
7990
  action: literal("assess"),
8041
7991
  ...taskId,
8042
7992
  expectedRevision: revision.optional(),
8043
- assessment: assessmentSchema
7993
+ judgment: rawJudgment
8044
7994
  }),
8045
- preview: operation({ action: literal("preview"), ...taskId, assessment: assessmentSchema }),
7995
+ preview: operation({ action: literal("preview"), ...taskId, judgment: rawJudgment }),
8046
7996
  explain: operation({ action: literal("explain"), ...taskId })
8047
7997
  };
8048
7998
  var evidenceOperations = {
@@ -8081,7 +8031,10 @@ var decisionOperations = {
8081
8031
  ...taskId,
8082
8032
  expectedRevision: revision.optional(),
8083
8033
  purpose: decisionSchema.shape.purpose,
8084
- binding: decisionSchema.shape.binding,
8034
+ binding: decisionSchema.shape.binding.extend({
8035
+ taskId: id.optional(),
8036
+ workspaceId: id.optional()
8037
+ }),
8085
8038
  response: decisionSchema.shape.response,
8086
8039
  requirementIds: array(digest)
8087
8040
  }),
@@ -8135,6 +8088,15 @@ var operationSchemas = {
8135
8088
  worker: discriminatedUnion("action", Object.values(workerOperations)),
8136
8089
  state: discriminatedUnion("action", Object.values(stateOperations))
8137
8090
  };
8091
+ var OPERATION_ACTIONS = {
8092
+ task: Object.keys(taskOperations),
8093
+ policy: Object.keys(policyOperations),
8094
+ evidence: Object.keys(evidenceOperations),
8095
+ finding: Object.keys(findingOperations),
8096
+ decision: Object.keys(decisionOperations),
8097
+ worker: Object.keys(workerOperations),
8098
+ state: Object.keys(stateOperations)
8099
+ };
8138
8100
  var withImplicitTask = (options) => Object.values(options).map((option) => ("taskId" in option.shape) ? option.extend({ taskId: id.optional() }) : option);
8139
8101
  var advertised = (options) => discriminatedUnion("action", withImplicitTask(options));
8140
8102
  var advertisedOperationSchemas = {
@@ -8223,6 +8185,126 @@ function candidateDigest(input) {
8223
8185
  head: input.head
8224
8186
  });
8225
8187
  }
8188
+ // packages/workit-core/src/core/operation-input.ts
8189
+ var str = (d, values) => ({
8190
+ type: "string",
8191
+ ...values ? { enum: values } : {},
8192
+ ...d ? { d } : {}
8193
+ });
8194
+ var list = (d) => ({ type: "array", ...d ? { d } : {} });
8195
+ var bool = (d) => ({ type: "boolean", ...d ? { d } : {} });
8196
+ var int2 = (d) => ({ type: "integer", ...d ? { d } : {} });
8197
+ var scopeFields = {
8198
+ paths: list("Scope paths (default: whole checkout)."),
8199
+ exclusions: list(),
8200
+ scope: str("Scope description.")
8201
+ };
8202
+ var refs = list("Paths or URLs.");
8203
+ var FLAT = {
8204
+ task: {
8205
+ fields: {
8206
+ objective: str(),
8207
+ ...scopeFields,
8208
+ refs,
8209
+ reason: str(),
8210
+ summary: str(),
8211
+ nextAction: str(),
8212
+ blockers: list(),
8213
+ outcome: str(undefined, ["verified", "accepted_limitations", "stopped"]),
8214
+ decisionIds: list(),
8215
+ status: str(undefined, ["open", "closed", "all"]),
8216
+ query: str(),
8217
+ limit: int2(),
8218
+ view: str(undefined, ["summary", "full"])
8219
+ }
8220
+ },
8221
+ policy: {
8222
+ fields: {
8223
+ riskTier: str("low=trivial, medium=normal.", ["trivial", "normal", "high", "low", "medium"]),
8224
+ behaviorChange: bool("Observable behavior changes."),
8225
+ productChoiceOpen: bool("A product/preference choice is still open."),
8226
+ needsPlan: bool("Needs a written plan or spec first."),
8227
+ note: str(),
8228
+ refs: list("Plan/spec paths or URLs.")
8229
+ }
8230
+ },
8231
+ evidence: {
8232
+ fields: {
8233
+ kind: str(undefined, ["check", "review", "investigation", "artifact"]),
8234
+ claim: str(),
8235
+ result: str(undefined, ["passed", "failed", "missing", "skipped"]),
8236
+ summary: str(),
8237
+ exitCode: int2(),
8238
+ refs,
8239
+ requirementIds: list(),
8240
+ candidateId: str(),
8241
+ beforeCandidateId: str(),
8242
+ reviewSession: str("Reviewer session handle (review evidence).")
8243
+ }
8244
+ },
8245
+ finding: {
8246
+ fields: {
8247
+ claim: str(),
8248
+ consequence: str(),
8249
+ ...scopeFields,
8250
+ candidateId: str(),
8251
+ refs,
8252
+ findingId: str(),
8253
+ disposition: str(undefined, ["open", "fixed", "dismissed", "deferred"]),
8254
+ reason: str(),
8255
+ evidenceIds: list(),
8256
+ decisionIds: list()
8257
+ }
8258
+ },
8259
+ decision: {
8260
+ fields: {
8261
+ purpose: str(undefined, ["design", "action", "limitation", "preference"]),
8262
+ response: str(undefined, ["approved", "rejected", "stated"]),
8263
+ presented: str("What the user was asked."),
8264
+ choice: str("The user's stated choice (response=stated)."),
8265
+ ...scopeFields,
8266
+ refs,
8267
+ requirementIds: list(),
8268
+ decisionId: str(),
8269
+ reason: str()
8270
+ }
8271
+ },
8272
+ worker: {
8273
+ fields: {
8274
+ role: str(undefined, ["investigator", "reviewer", "implementer"]),
8275
+ objective: str(),
8276
+ ...scopeFields,
8277
+ decisionIds: list(),
8278
+ requirementIds: list(),
8279
+ candidateId: str(),
8280
+ stoppingCondition: str(),
8281
+ workerId: str(),
8282
+ outcome: str(undefined, ["completed", "failed", "cancelled"]),
8283
+ summary: str(),
8284
+ evidenceIds: list(),
8285
+ findingIds: list(),
8286
+ reason: str()
8287
+ }
8288
+ },
8289
+ state: {
8290
+ fields: { bundle: { type: "object", d: "An export bundle (object or JSON string)." } }
8291
+ }
8292
+ };
8293
+ var COMMON = {
8294
+ taskId: str("Omit for this branch's task."),
8295
+ expectedRevision: str(),
8296
+ expectedWorkspaceRevision: str()
8297
+ };
8298
+ var READ_TASK_FIELDS = new Set(["status", "query", "limit", "view"]);
8299
+ var READ_ONLY_ACTIONS = new Set(["list", "inspect", "preview", "explain", "export"]);
8300
+ var ENVELOPE = new Set([
8301
+ "schemaVersion",
8302
+ "action",
8303
+ "taskId",
8304
+ "expectedRevision",
8305
+ "expectedWorkspaceRevision",
8306
+ "judgment"
8307
+ ]);
8226
8308
  // packages/workit-core/src/core/package-root.ts
8227
8309
  import { existsSync } from "node:fs";
8228
8310
  import path from "node:path";
@@ -8292,6 +8374,25 @@ var heldInProcess = new Map;
8292
8374
  // packages/workit-core/src/git/rev.ts
8293
8375
  var MAX_BUFFER = 256 * 1024 * 1024;
8294
8376
  var MAX_UNTRACKED_BYTES = 5 * 1024 * 1024;
8377
+
8378
+ // packages/workit-core/src/ledger.ts
8379
+ var PASSING = new Set(["verified", "tests-verified", "type-check-only"]);
8380
+ var FAILING = new Set(["failed", "blocked"]);
8381
+ var STRONG_RESULTS = new Set(["verified", "tests-verified"]);
8382
+ var PR_ROW_TYPES = new Set(["pr.created", "pr.status", "pr.merged"]);
8383
+ var NETWORK_FS_TYPES = new Set([
8384
+ 26985,
8385
+ 20859,
8386
+ 4266872130,
8387
+ 4283649346,
8388
+ 1702057286,
8389
+ 1397113167,
8390
+ 12805120,
8391
+ 16914839,
8392
+ 1196443219,
8393
+ 198183888
8394
+ ]);
8395
+ var OBSERVED_ONLY = new Set(["check", ...PR_ROW_TYPES]);
8295
8396
  // packages/workit-core/src/core/config.ts
8296
8397
  var PRESETS = {
8297
8398
  gitflow: {
@@ -8394,6 +8495,7 @@ var workspaceConfigSchema = object({
8394
8495
  }).passthrough().optional(),
8395
8496
  autoApprove: union([boolean2(), array(nonBlank)]).optional(),
8396
8497
  defaultEndpoint: _enum(["commit", "pr"]).optional(),
8498
+ verification: _enum(["self", "independent"]).optional(),
8397
8499
  autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
8398
8500
  kind,
8399
8501
  union([boolean2(), literal("verified")]).optional()
@@ -8437,18 +8539,19 @@ var workspacesFileSchema = object({ workspaces: array(workspaceConfigSchema).opt
8437
8539
  var runtimeWorkspaceIndexSchema = object({
8438
8540
  workspaces: array(object({ name: nonBlank, glob: nonBlank }).passthrough()).optional()
8439
8541
  }).passthrough();
8440
- // packages/workit-core/src/core/policy-resolver.ts
8441
- var resolverInputSchema = object({
8442
- intent: intentSchema,
8443
- assessment: assessmentSchema,
8444
- constraints: array(constraintSchema),
8445
- prior: object({
8446
- decisions: array(decisionSchema),
8447
- findings: array(findingSchema),
8448
- requirements: array(requirementSchema)
8449
- }).strict(),
8450
- preferences: object({ fast: boolean2().optional(), thorough: boolean2().optional() }).strict().optional()
8451
- }).strict();
8542
+ // packages/workit-core/src/core/policy/judgment.ts
8543
+ var LEGACY_KEYS = new Set(["assessment", "facts", "signals", "consequences", "verification"]);
8544
+ var YES = new Set(["true", "yes", "y", "1", "on"]);
8545
+ var NO = new Set(["false", "no", "n", "0", "off", "none"]);
8546
+
8547
+ // packages/workit-core/src/autonomy.ts
8548
+ var DEFAULT_GRANTS = Object.freeze({
8549
+ push: true,
8550
+ pr: true,
8551
+ merge: false,
8552
+ release: false,
8553
+ rerun: true
8554
+ });
8452
8555
 
8453
8556
  // packages/workit-core/src/core/task-engine.ts
8454
8557
  var verifiedWorkers = new WeakMap;