pi-pstack-workflow-kit 0.1.0 → 0.1.1

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.
Files changed (120) hide show
  1. package/README.md +33 -9
  2. package/lib/catalog.ts +53 -4
  3. package/lib/models.ts +10 -9
  4. package/lib/pool.ts +4 -6
  5. package/lib/state.ts +24 -24
  6. package/lib/transcript.ts +19 -15
  7. package/package.json +17 -20
  8. package/reference/PARITY.md +1 -1
  9. package/scripts/job-input.ts +38 -39
  10. package/scripts/run-job.mjs +9 -7
  11. package/skills/architect/SKILL.md +1 -1
  12. package/skills/arena/SKILL.md +1 -1
  13. package/skills/automate-me/SKILL.md +1 -1
  14. package/skills/benchmark-checklist/SKILL.md +1 -1
  15. package/skills/blast-radius/SKILL.md +1 -1
  16. package/skills/bro/SKILL.md +1 -1
  17. package/skills/check-compiler-errors/SKILL.md +1 -1
  18. package/skills/control-cli/SKILL.md +1 -1
  19. package/skills/control-ui/SKILL.md +1 -1
  20. package/skills/correct/SKILL.md +1 -1
  21. package/skills/create-formal-verification-skill/SKILL.md +1 -1
  22. package/skills/create-verification-skill/SKILL.md +1 -1
  23. package/skills/deslop/SKILL.md +1 -1
  24. package/skills/figure-it-out/SKILL.md +1 -1
  25. package/skills/fix-ci/SKILL.md +1 -1
  26. package/skills/fix-merge-conflicts/SKILL.md +1 -1
  27. package/skills/get-pr-comments/SKILL.md +1 -1
  28. package/skills/how/SKILL.md +1 -1
  29. package/skills/in-your-own-words/SKILL.md +1 -1
  30. package/skills/interrogate/SKILL.md +1 -1
  31. package/skills/ketchup/SKILL.md +1 -1
  32. package/skills/ketchup-video/SKILL.md +1 -1
  33. package/skills/loop-on-ci/SKILL.md +1 -1
  34. package/skills/maintain-formal-verification-skill/SKILL.md +1 -1
  35. package/skills/maintain-verification-skill/SKILL.md +1 -1
  36. package/skills/make-bot-ui/SKILL.md +1 -1
  37. package/skills/make-pr-easy-to-review/SKILL.md +1 -1
  38. package/skills/new-branch-and-pr/SKILL.md +1 -1
  39. package/skills/no-comments/SKILL.md +1 -1
  40. package/skills/poteto-help/SKILL.md +1 -1
  41. package/skills/poteto-mode/SKILL.md +1 -1
  42. package/skills/poteto-mode/playbooks/authoring-a-skill.md +1 -1
  43. package/skills/poteto-mode/playbooks/autonomous-run.md +1 -1
  44. package/skills/poteto-mode/playbooks/autopilot-full.md +1 -1
  45. package/skills/poteto-mode/playbooks/autopilot-stack.md +1 -1
  46. package/skills/poteto-mode/playbooks/babysit.md +1 -1
  47. package/skills/poteto-mode/playbooks/bug-fix.md +1 -1
  48. package/skills/poteto-mode/playbooks/eval.md +1 -1
  49. package/skills/poteto-mode/playbooks/feature.md +1 -1
  50. package/skills/poteto-mode/playbooks/hillclimb.md +1 -1
  51. package/skills/poteto-mode/playbooks/investigation.md +1 -1
  52. package/skills/poteto-mode/playbooks/multi-phase-plan.md +1 -1
  53. package/skills/poteto-mode/playbooks/opening-a-pr.md +1 -1
  54. package/skills/poteto-mode/playbooks/pause-safely.md +1 -1
  55. package/skills/poteto-mode/playbooks/perf-issue.md +1 -1
  56. package/skills/poteto-mode/playbooks/prototype.md +1 -1
  57. package/skills/poteto-mode/playbooks/refactoring.md +1 -1
  58. package/skills/poteto-mode/playbooks/runtime-forensics.md +1 -1
  59. package/skills/poteto-mode/playbooks/session-pickup.md +1 -1
  60. package/skills/poteto-mode/playbooks/shipping.md +1 -1
  61. package/skills/poteto-mode/playbooks/trace-forensics.md +1 -1
  62. package/skills/poteto-mode/playbooks/visual-parity.md +1 -1
  63. package/skills/poteto-mode/playbooks/worktree-cleanup.md +1 -1
  64. package/skills/pr-review-canvas/SKILL.md +1 -1
  65. package/skills/principle-attack-the-premise/SKILL.md +1 -1
  66. package/skills/principle-boundary-discipline/SKILL.md +1 -1
  67. package/skills/principle-build-the-lever/SKILL.md +1 -1
  68. package/skills/principle-encode-lessons-in-structure/SKILL.md +1 -1
  69. package/skills/principle-exhaust-the-design-space/SKILL.md +1 -1
  70. package/skills/principle-experience-first/SKILL.md +1 -1
  71. package/skills/principle-explain-the-number/SKILL.md +1 -1
  72. package/skills/principle-fix-root-causes/SKILL.md +1 -1
  73. package/skills/principle-foundational-thinking/SKILL.md +1 -1
  74. package/skills/principle-guard-the-context-window/SKILL.md +1 -1
  75. package/skills/principle-laziness-protocol/SKILL.md +1 -1
  76. package/skills/principle-make-operations-idempotent/SKILL.md +1 -1
  77. package/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +1 -1
  78. package/skills/principle-minimize-reader-load/SKILL.md +1 -1
  79. package/skills/principle-model-the-domain/SKILL.md +1 -1
  80. package/skills/principle-never-block-on-the-human/SKILL.md +1 -1
  81. package/skills/principle-outcome-oriented-execution/SKILL.md +1 -1
  82. package/skills/principle-prove-it-works/SKILL.md +1 -1
  83. package/skills/principle-redesign-from-first-principles/SKILL.md +1 -1
  84. package/skills/principle-separate-before-serializing-shared-state/SKILL.md +1 -1
  85. package/skills/principle-sequence-verifiable-units/SKILL.md +1 -1
  86. package/skills/principle-subtract-before-you-add/SKILL.md +1 -1
  87. package/skills/principle-test-behavior-not-implementation/SKILL.md +1 -1
  88. package/skills/principle-type-system-discipline/SKILL.md +1 -1
  89. package/skills/recall/SKILL.md +1 -1
  90. package/skills/reflect/SKILL.md +1 -1
  91. package/skills/review-and-ship/SKILL.md +1 -1
  92. package/skills/run-smoke-tests/SKILL.md +1 -1
  93. package/skills/setup-pstack/SKILL.md +1 -1
  94. package/skills/sharpen/SKILL.md +1 -1
  95. package/skills/show-me-your-work/SKILL.md +1 -1
  96. package/skills/statechart/SKILL.md +1 -1
  97. package/skills/swarm/SKILL.md +1 -1
  98. package/skills/tdd/SKILL.md +1 -1
  99. package/skills/teach/SKILL.md +1 -1
  100. package/skills/technical-writing/SKILL.md +1 -1
  101. package/skills/thermo-nuclear-code-quality-review/SKILL.md +1 -1
  102. package/skills/typescript-best-practices/SKILL.md +1 -1
  103. package/skills/unslop/SKILL.md +1 -1
  104. package/skills/verify-this/SKILL.md +1 -1
  105. package/skills/weekly-review/SKILL.md +1 -1
  106. package/skills/what-did-i-get-done/SKILL.md +1 -1
  107. package/skills/why/SKILL.md +1 -1
  108. package/skills/workflow-from-chats/SKILL.md +1 -1
  109. package/{extensions → src}/catalog-ui.ts +2 -2
  110. package/{extensions → src}/delegate.ts +40 -30
  111. package/{extensions → src}/forge.ts +18 -17
  112. package/{extensions → src}/git.ts +6 -1
  113. package/{extensions → src}/models.ts +87 -13
  114. package/{extensions → src}/parent-diff.ts +4 -3
  115. package/{extensions → src}/plan.ts +3 -3
  116. package/{extensions → src}/records.ts +8 -4
  117. package/{extensions → src}/support.ts +3 -2
  118. package/{extensions → src}/worktrees.ts +3 -3
  119. package/{extensions → src}/index.ts +0 -0
  120. package/{extensions → src}/session.ts +1 -1
@@ -43,8 +43,9 @@ export async function saveParentDiff(
43
43
  git.probe(["diff", "--no-index", "--", "/dev/null", file], repo, remaining),
44
44
  ),
45
45
  );
46
- for (const [i, patch] of patches.entries()) {
47
- const r = patch.status === "fulfilled" ? patch.value : undefined;
46
+ for (const [i, file] of batch.entries()) {
47
+ const patch = patches[i];
48
+ const r = patch?.status === "fulfilled" ? patch.value : undefined;
48
49
  if (r && (r.code === 0 || r.code === 1)) {
49
50
  const bytes = Buffer.byteLength(r.stdout);
50
51
  if (bytes <= remaining) {
@@ -53,7 +54,7 @@ export async function saveParentDiff(
53
54
  continue;
54
55
  }
55
56
  }
56
- omitted.push(batch[i]);
57
+ omitted.push(file);
57
58
  }
58
59
  next += batch.length;
59
60
  }
@@ -21,11 +21,11 @@ import {
21
21
  artifacts,
22
22
  atomicWrite,
23
23
  fail,
24
+ type Notify,
24
25
  result,
26
+ stringEnum,
25
27
  text,
26
28
  unreachable,
27
- type Notify,
28
- stringEnum,
29
29
  } from "./support.ts";
30
30
 
31
31
  const planParameters = Type.Object({
@@ -66,7 +66,7 @@ export function registerPlan(pi: ExtensionAPI, session: Session, notify: Notify)
66
66
  handler: async (args, ctx) => {
67
67
  const [route, ...words] = args.trim().split(/\s+/);
68
68
  const goal = words.join(" ");
69
- if (!routes.includes(route) || !goal)
69
+ if (!route || !routes.includes(route) || !goal)
70
70
  return notify(ctx, `Choose a route and goal:\n${routes.join(", ")}`);
71
71
  session.commit(ctx, { plan: startPlan(route, goal) });
72
72
  sendWorkflow(pi, "pb-" + route, goal);
@@ -4,9 +4,10 @@ import { dirname, join } from "node:path";
4
4
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
5
5
  import { Type } from "typebox";
6
6
 
7
- import { catalog, packageFile } from "../lib/catalog.ts";
7
+ import { nativeNode, packageFile } from "../lib/catalog.ts";
8
8
  import { isJobKind } from "../lib/jobs.ts";
9
- import { artifacts, hasErrorCode, result, tsvRow, type Notify } from "./support.ts";
9
+ import { parseJson } from "../lib/validation.ts";
10
+ import { artifacts, hasErrorCode, type Notify, result, tsvRow } from "./support.ts";
10
11
 
11
12
  export function registerRecords(pi: ExtensionAPI, notify: Notify) {
12
13
  pi.registerCommand("pstack-automation", {
@@ -19,8 +20,11 @@ export function registerRecords(pi: ExtensionAPI, notify: Notify) {
19
20
  kind === "custom"
20
21
  ? { instructions: "Supply explicit task, approved tools, trigger and finish predicate." }
21
22
  : {
22
- instructions: packageFile(catalog.paths[kind]),
23
- config: JSON.parse(packageFile("reference/benny/config.example.json")),
23
+ instructions: nativeNode(kind).instructions,
24
+ config: parseJson(
25
+ packageFile("reference/benny/config.example.json"),
26
+ "Benny configuration example",
27
+ ),
24
28
  };
25
29
  const job = { version: 1, enabled: false, kind, cwd: ctx.cwd, tools: [], ...draft };
26
30
  await mkdir(dirname(path), { recursive: true, mode: 0o700 });
@@ -9,7 +9,8 @@ import { Type } from "typebox";
9
9
 
10
10
  import { isRecord } from "../lib/validation.ts";
11
11
 
12
- export const agentDir = () => process.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent");
12
+ export const agentDir = () => process.env["PI_CODING_AGENT_DIR"] ?? join(homedir(), ".pi", "agent");
13
+ export const piBin = process.env["PSTACK_PI_BIN"] ?? "pi";
13
14
  export const artifacts = (ctx: ExtensionContext) =>
14
15
  join(agentDir(), "pstack", "sessions", ctx.sessionManager.getSessionId());
15
16
  export const text = (value: unknown) =>
@@ -27,7 +28,7 @@ export function unreachable(value: never): never {
27
28
  throw new Error(`Unhandled case: ${String(value)}`);
28
29
  }
29
30
  export const hasErrorCode = (error: unknown, code: string) =>
30
- isRecord(error) && error.code === code;
31
+ isRecord(error) && error["code"] === code;
31
32
  export async function atomicWrite(path: string, data: string) {
32
33
  await mkdir(dirname(path), { recursive: true, mode: 0o700 });
33
34
  const temporary = `${path}.${randomUUID()}.tmp`;
@@ -5,13 +5,13 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
5
5
  import { Type } from "typebox";
6
6
 
7
7
  import { pool } from "../lib/pool.ts";
8
- import { gitIn, type Git } from "./git.ts";
8
+ import { type Git, gitIn } from "./git.ts";
9
9
  import { artifacts, fail, hasErrorCode, result, stringEnum } from "./support.ts";
10
10
 
11
11
  export interface Worktree {
12
12
  path: string;
13
- head?: string;
14
- branch?: string;
13
+ head?: string | undefined;
14
+ branch?: string | undefined;
15
15
  locked: boolean;
16
16
  prunable: boolean;
17
17
  bare: boolean;
File without changes
@@ -5,9 +5,9 @@ import {
5
5
  activePlan,
6
6
  initialState,
7
7
  restore,
8
+ type State,
8
9
  stateType,
9
10
  stopped,
10
- type State,
11
11
  type TaskStatus,
12
12
  type Wake,
13
13
  } from "../lib/state.ts";