@justjoshn/pi-pstack-v2 0.1.7 → 0.2.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 (64) hide show
  1. package/README.md +19 -7
  2. package/docs/guide/01-setup.md +6 -6
  3. package/docs/guide/02-poteto-mode.md +1 -1
  4. package/docs/guide/07-overnight.md +3 -3
  5. package/docs/pi-mechanisms.md +35 -53
  6. package/package.json +5 -3
  7. package/skills/arena/SKILL.md +5 -5
  8. package/skills/automate-me/SKILL.md +2 -2
  9. package/skills/benchmark-checklist/SKILL.md +1 -1
  10. package/skills/control-cli/SKILL.md +1 -1
  11. package/skills/figure-it-out/SKILL.md +1 -1
  12. package/skills/how/SKILL.md +2 -2
  13. package/skills/interrogate/SKILL.md +2 -2
  14. package/skills/maintain-verification-skill/SKILL.md +1 -1
  15. package/skills/make-bot-ui/SKILL.md +2 -2
  16. package/skills/no-comments/SKILL.md +1 -1
  17. package/skills/poteto-help/SKILL.md +3 -3
  18. package/skills/poteto-mode/SKILL.md +9 -9
  19. package/skills/poteto-mode/playbooks/autopilot-full.md +5 -5
  20. package/skills/poteto-mode/playbooks/babysit.md +1 -1
  21. package/skills/poteto-mode/playbooks/bug-fix.md +1 -1
  22. package/skills/poteto-mode/playbooks/eval.md +3 -3
  23. package/skills/poteto-mode/playbooks/feature.md +2 -2
  24. package/skills/poteto-mode/playbooks/hillclimb.md +1 -1
  25. package/skills/poteto-mode/playbooks/opening-a-pr.md +1 -1
  26. package/skills/poteto-mode/playbooks/perf-issue.md +1 -1
  27. package/skills/poteto-mode/playbooks/refactoring.md +1 -1
  28. package/skills/poteto-mode/playbooks/shipping.md +2 -2
  29. package/skills/poteto-mode/playbooks/worktree-cleanup.md +1 -1
  30. package/skills/poteto-mode/worker.md +1 -1
  31. package/skills/recall/SKILL.md +3 -3
  32. package/skills/review-and-ship/SKILL.md +1 -1
  33. package/skills/setup-pstack/SKILL.md +2 -2
  34. package/skills/show-me-your-work/SKILL.md +2 -2
  35. package/skills/statechart/SKILL.md +1 -1
  36. package/skills/statechart/references/render.md +1 -1
  37. package/skills/swarm/SKILL.md +4 -4
  38. package/skills/workflow-from-chats/SKILL.md +1 -1
  39. package/src/gondolin/bash.ts +51 -0
  40. package/src/gondolin/fs-operations.ts +56 -0
  41. package/src/gondolin/grep.ts +96 -0
  42. package/src/gondolin/index.ts +58 -0
  43. package/src/gondolin/paths.ts +34 -0
  44. package/src/gondolin/search.ts +67 -0
  45. package/src/gondolin/tools.ts +40 -0
  46. package/src/gondolin/vm.ts +65 -0
  47. package/src/index.ts +31 -130
  48. package/src/jobs.ts +58 -315
  49. package/src/subagent/agents/poteto-agent.md +1 -1
  50. package/src/subagent/agents/worker.md +5 -0
  51. package/src/subagent/dispatch.ts +2 -2
  52. package/src/subagent/index.ts +33 -2
  53. package/src/subagent/render-call.ts +4 -2
  54. package/src/subagent/run-single.ts +9 -7
  55. package/src/subagent/schema.ts +28 -2
  56. package/src/subagent/types.ts +7 -0
  57. package/src/subagent/wake-jobs.ts +69 -0
  58. package/src/credentials.ts +0 -171
  59. package/src/git.ts +0 -94
  60. package/src/paths.ts +0 -16
  61. package/src/requests.ts +0 -182
  62. package/src/sandbox.ts +0 -284
  63. package/src/sweep.ts +0 -187
  64. package/src/transcript.ts +0 -79
package/src/transcript.ts DELETED
@@ -1,79 +0,0 @@
1
- import { lstatSync, readdirSync, readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
-
4
- import { parseSessionEntries, type SessionEntry } from '@earendil-works/pi-coding-agent';
5
-
6
- type Report = { path: string; answers: string[]; toolCalls: number };
7
- type Assistant = Extract<SessionEntry, { type: 'message' }>;
8
-
9
- const isAssistant = (entry: SessionEntry): entry is Assistant => entry.type === 'message' && entry.message.role === 'assistant';
10
-
11
- /** The entries from the last one back to the root, oldest first. A cycle in parent ids ends the walk. */
12
- function branchOf(turns: SessionEntry[]): SessionEntry[] {
13
- const byId = new Map(turns.map((entry) => [entry.id, entry]));
14
- const walk = (entry: SessionEntry | undefined, seen: ReadonlySet<string>): SessionEntry[] => (entry && !seen.has(entry.id) ? [entry, ...walk(entry.parentId ? byId.get(entry.parentId) : undefined, new Set([...seen, entry.id]))] : []);
15
- return walk(turns.at(-1), new Set()).toReversed();
16
- }
17
-
18
- /** What one assistant turn contributes to the answers, or nothing. */
19
- function answerOf(entry: Assistant, last: boolean): string[] {
20
- const message = entry.message;
21
- if (message.role !== 'assistant') return [];
22
- const text = message.content
23
- .filter((block) => block.type === 'text')
24
- .map((block) => block.text)
25
- .join('\n');
26
- const ended = [`[Worker answer ended with ${message.stopReason}]`, text, message.errorMessage].filter(Boolean).join('\n');
27
- switch (message.stopReason) {
28
- case 'stop':
29
- return text.trim() ? [text] : [];
30
- case 'error':
31
- case 'aborted':
32
- // A failed turn the worker went on from was retried, so only the one it ended on is its answer.
33
- return last ? [ended] : [];
34
- case 'length':
35
- return [ended];
36
- case 'toolUse':
37
- case 'pending':
38
- case 'deferred':
39
- return [];
40
- default: {
41
- const unhandled: never = message.stopReason;
42
- throw new Error(`Unhandled worker stop reason: ${unhandled}`);
43
- }
44
- }
45
- }
46
-
47
- function reportOf(path: string, entries: ReturnType<typeof parseSessionEntries>, since: string): Report {
48
- const turns = entries.filter((entry): entry is SessionEntry => entry.type !== 'session');
49
- const branch = branchOf(turns);
50
- const prompt = branch.findLastIndex((entry) => entry.type === 'message' && entry.message.role === 'user');
51
- if (prompt < 0 || !(Date.parse(branch[prompt]?.timestamp ?? '') >= Date.parse(since))) return { path, answers: [], toolCalls: 0 };
52
- const after = branch.slice(prompt + 1);
53
- const assistants = after.filter(isAssistant);
54
- return {
55
- path,
56
- answers: assistants.flatMap((entry) => answerOf(entry, entry === assistants.at(-1))),
57
- toolCalls: after.filter((entry) => entry.type === 'message' && entry.message.role === 'toolResult').length,
58
- };
59
- }
60
-
61
- /** A worker's completed answers since its brief, and how many tool calls it made. */
62
- export function workerReport(sessionDir: string | undefined, since: string): Report | undefined {
63
- if (!sessionDir) return undefined;
64
- try {
65
- if (!lstatSync(sessionDir).isDirectory()) return undefined;
66
- const files = readdirSync(sessionDir)
67
- .filter((name) => name.endsWith('.jsonl'))
68
- .map((name) => ({ path: join(sessionDir, name), stat: lstatSync(join(sessionDir, name)) }))
69
- .filter(({ stat }) => stat.isFile())
70
- .toSorted((a, b) => b.stat.mtimeMs - a.stat.mtimeMs);
71
- for (const { path } of files) {
72
- const entries = parseSessionEntries(readFileSync(path, 'utf8'));
73
- if (entries[0]?.type === 'session') return reportOf(path, entries, since);
74
- }
75
- } catch {
76
- return undefined;
77
- }
78
- return undefined;
79
- }