@selesai/code 0.1.19 → 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 (157) hide show
  1. package/dist/agents/architect.md +4 -3
  2. package/dist/agents/builder.md +5 -4
  3. package/dist/agents/commentator.md +3 -2
  4. package/dist/agents/explorer.md +4 -4
  5. package/dist/agents/recapper.md +4 -3
  6. package/dist/config.d.ts +6 -7
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +7 -9
  9. package/dist/config.js.map +1 -1
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +3 -1
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/compaction/compaction.d.ts.map +1 -1
  14. package/dist/core/compaction/compaction.js +18 -24
  15. package/dist/core/compaction/compaction.js.map +1 -1
  16. package/dist/core/extensions/loader.d.ts.map +1 -1
  17. package/dist/core/extensions/loader.js +2 -0
  18. package/dist/core/extensions/loader.js.map +1 -1
  19. package/dist/core/extensions/types.d.ts +8 -1
  20. package/dist/core/extensions/types.d.ts.map +1 -1
  21. package/dist/core/extensions/types.js.map +1 -1
  22. package/dist/core/skills.d.ts.map +1 -1
  23. package/dist/core/skills.js +25 -11
  24. package/dist/core/skills.js.map +1 -1
  25. package/dist/defaults/models.json +143 -39
  26. package/dist/defaults/settings.json +2 -29
  27. package/dist/extensions/package.json +5 -4
  28. package/dist/extensions/pi-intercom/index.ts +12 -5
  29. package/dist/extensions/pi-powerline-footer/index.ts +4 -1
  30. package/dist/extensions/pi-powerline-footer/tps.ts +286 -0
  31. package/dist/extensions/pi-powerline-footer/welcome.ts +47 -46
  32. package/dist/extensions/pi-subagents/README.md +12 -5
  33. package/dist/extensions/pi-subagents/agents/context-builder.md +2 -2
  34. package/dist/extensions/pi-subagents/agents/researcher.md +4 -5
  35. package/dist/extensions/pi-subagents/package.json +8 -5
  36. package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +1 -1
  37. package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +1 -1
  38. package/dist/extensions/pi-subagents/src/agents/agent-management.ts +1 -1
  39. package/dist/extensions/pi-subagents/src/agents/agents.ts +3 -3
  40. package/dist/extensions/pi-subagents/src/extension/control-notices.ts +1 -1
  41. package/dist/extensions/pi-subagents/src/extension/doctor.ts +3 -3
  42. package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +1 -1
  43. package/dist/extensions/pi-subagents/src/extension/index.ts +29 -2
  44. package/dist/extensions/pi-subagents/src/profiles/profiles.ts +2 -2
  45. package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +72 -13
  46. package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +1 -1
  47. package/dist/extensions/pi-subagents/src/runs/background/notify.ts +1 -1
  48. package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +85 -41
  49. package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +1 -1
  50. package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +1 -1
  51. package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +46 -3
  52. package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +2 -2
  53. package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +1 -3
  54. package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +2 -2
  55. package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +18 -18
  56. package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +24 -24
  57. package/dist/extensions/pi-subagents/src/runs/shared/spawn-timing.ts +46 -0
  58. package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +2 -2
  59. package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +4 -4
  60. package/dist/extensions/pi-subagents/src/shared/fork-context.ts +1 -1
  61. package/dist/extensions/pi-subagents/src/shared/types.ts +6 -6
  62. package/dist/extensions/pi-subagents/src/shared/utils.ts +3 -3
  63. package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +1 -1
  64. package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +1 -1
  65. package/dist/extensions/pi-subagents/src/tui/render-helpers.ts +1 -1
  66. package/dist/extensions/pi-subagents/src/tui/render.ts +1 -1
  67. package/dist/extensions/pi-subagents/test/unit/spawn-timing.test.ts +45 -0
  68. package/dist/extensions/pi-subagents/tsconfig.runner.json +17 -0
  69. package/dist/extensions/pi-web-agent/package.json +31 -0
  70. package/dist/extensions/pi-web-agent/src/backends/config.ts +205 -0
  71. package/dist/extensions/pi-web-agent/src/backends/doctor.ts +136 -0
  72. package/dist/extensions/pi-web-agent/src/backends/factory.ts +152 -0
  73. package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +25 -0
  74. package/dist/extensions/pi-web-agent/src/cache/ttl-cache.ts +28 -0
  75. package/dist/extensions/pi-web-agent/src/changelog-notice.ts +133 -0
  76. package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +946 -0
  77. package/dist/extensions/pi-web-agent/src/extension.ts +126 -0
  78. package/dist/extensions/pi-web-agent/src/extract/readability.ts +118 -0
  79. package/dist/extensions/pi-web-agent/src/fetch/browser-resolution.ts +199 -0
  80. package/dist/extensions/pi-web-agent/src/fetch/firecrawl-fetch.ts +100 -0
  81. package/dist/extensions/pi-web-agent/src/fetch/headless-fetch.ts +117 -0
  82. package/dist/extensions/pi-web-agent/src/fetch/http-fetch.ts +67 -0
  83. package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +60 -0
  84. package/dist/extensions/pi-web-agent/src/orchestration/candidate-selector.ts +50 -0
  85. package/dist/extensions/pi-web-agent/src/orchestration/direct-url.ts +52 -0
  86. package/dist/extensions/pi-web-agent/src/orchestration/evidence-quality.ts +105 -0
  87. package/dist/extensions/pi-web-agent/src/orchestration/evidence-ranker.ts +45 -0
  88. package/dist/extensions/pi-web-agent/src/orchestration/index.ts +28 -0
  89. package/dist/extensions/pi-web-agent/src/orchestration/query-planner.ts +47 -0
  90. package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +376 -0
  91. package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +64 -0
  92. package/dist/extensions/pi-web-agent/src/orchestration/research-worker.ts +181 -0
  93. package/dist/extensions/pi-web-agent/src/orchestration/source-profile.ts +101 -0
  94. package/dist/extensions/pi-web-agent/src/orchestration/stop-decider.ts +81 -0
  95. package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +208 -0
  96. package/dist/extensions/pi-web-agent/src/presentation/config.ts +75 -0
  97. package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +61 -0
  98. package/dist/extensions/pi-web-agent/src/presentation/fetch-presentation.ts +54 -0
  99. package/dist/extensions/pi-web-agent/src/presentation/search-presentation.ts +41 -0
  100. package/dist/extensions/pi-web-agent/src/presentation/select-view.ts +20 -0
  101. package/dist/extensions/pi-web-agent/src/presentation/types.ts +63 -0
  102. package/dist/extensions/pi-web-agent/src/search/brave.ts +114 -0
  103. package/dist/extensions/pi-web-agent/src/search/duckduckgo.ts +72 -0
  104. package/dist/extensions/pi-web-agent/src/search/searxng.ts +96 -0
  105. package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +71 -0
  106. package/dist/extensions/pi-web-agent/src/tools/web-fetch-headless.ts +31 -0
  107. package/dist/extensions/pi-web-agent/src/tools/web-fetch.ts +31 -0
  108. package/dist/extensions/pi-web-agent/src/tools/web-search.ts +157 -0
  109. package/dist/extensions/pi-web-agent/src/types.ts +88 -0
  110. package/dist/extensions/ponytail/index.js +189 -0
  111. package/dist/extensions/ponytail/package.json +8 -0
  112. package/dist/extensions/ponytail/ponytail-config.cjs +122 -0
  113. package/dist/extensions/ponytail/ponytail-instructions.cjs +94 -0
  114. package/dist/extensions/ponytail/test/extension.test.js +167 -0
  115. package/dist/extensions/ponytail/test/helpers.test.js +92 -0
  116. package/dist/extensions/question/constants.ts +38 -0
  117. package/dist/extensions/question/dialog-adapter.ts +74 -0
  118. package/dist/extensions/question/helpers.ts +102 -0
  119. package/dist/extensions/question/index.ts +671 -0
  120. package/dist/extensions/question/navigation.ts +14 -0
  121. package/dist/extensions/question/package.json +18 -0
  122. package/dist/extensions/question/question-list.ts +498 -0
  123. package/dist/extensions/question/row-layout.ts +162 -0
  124. package/dist/extensions/question/schemas.ts +69 -0
  125. package/dist/extensions/question/selection-mode.ts +49 -0
  126. package/dist/extensions/question/shortcuts.ts +53 -0
  127. package/dist/extensions/question/tests/helpers.test.ts +178 -0
  128. package/dist/extensions/question/tests/question-list.test.ts +230 -0
  129. package/dist/extensions/question/tests/row-layout.test.ts +136 -0
  130. package/dist/extensions/question/tests/shortcuts.test.ts +85 -0
  131. package/dist/extensions/question/tests/ui-protocol.test.ts +143 -0
  132. package/dist/extensions/question/tui-adapter.ts +33 -0
  133. package/dist/extensions/question/types.ts +102 -0
  134. package/dist/extensions/question/ui-protocol.ts +46 -0
  135. package/dist/extensions/tokenin-onboarding.ts +265 -2
  136. package/dist/extensions/web-agent-onboarding.ts +222 -0
  137. package/dist/extensions/workflow/adapter.ts +588 -0
  138. package/dist/extensions/workflow/extension.ts +24 -0
  139. package/dist/extensions/workflow/modes/prototype.ts +156 -0
  140. package/dist/extensions/workflow/modes/quick.ts +138 -0
  141. package/dist/extensions/workflow/package.json +17 -0
  142. package/dist/extensions/workflow/state-machine.ts +386 -0
  143. package/dist/index.d.ts +1 -1
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +1 -1
  146. package/dist/index.js.map +1 -1
  147. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  148. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  149. package/dist/modes/interactive/interactive-mode.js +57 -13
  150. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  151. package/dist/utils/mime.d.ts.map +1 -1
  152. package/dist/utils/mime.js +24 -1
  153. package/dist/utils/mime.js.map +1 -1
  154. package/docs/docs.json +4 -0
  155. package/docs/workflows.md +206 -0
  156. package/package.json +5 -1
  157. package/README.md +0 -198
@@ -0,0 +1,156 @@
1
+ import type {
2
+ Phase,
3
+ PromptContext,
4
+ WorkflowConfig,
5
+ WorkflowModeRegistration,
6
+ } from "../state-machine.ts";
7
+
8
+ // ponytail: prototype workflow — full 7-phase tool-driven loop:
9
+ // grill → research → plan → reuse → handoff → loop → audit.
10
+ // skipRules + closeArtifacts are wired by the adapter (git reuse-skip is
11
+ // shared by every mode today); this file is pure phase/prompt config.
12
+
13
+ const phases: Phase[] = [
14
+ "grilling",
15
+ "research",
16
+ "plan",
17
+ "reuse",
18
+ "handoff",
19
+ "loop",
20
+ "audit",
21
+ ];
22
+
23
+ const prompts: Partial<Record<Phase, (ctx: PromptContext) => string>> = {
24
+ grilling: ({ artifactDir, userPrompt }) =>
25
+ `You are in the GRILLING phase of a prototype workflow.
26
+
27
+ User request:
28
+ ${userPrompt}
29
+
30
+ Use the question tool to grill the user until requirements are unambiguous. Ask focused clarifying questions ONE question tool call at a time. Adapt each follow-up to what the user reveals. Dig into scope, constraints, success criteria, and edge cases. Use your judgement — no fixed checklist.
31
+
32
+ For each question tool call:
33
+ - Provide a concise question.
34
+ - Pass a short context summary when it depends on prior findings.
35
+ - Prefer options when choices are known. Give each option a clear label and a brief description.
36
+ - Always set allowFreeform=true so the user can type a custom answer.
37
+ - Keep allowMultiple=false unless multiple selections genuinely apply.
38
+
39
+ Example:
40
+ question({
41
+ question: "What should the output format be?",
42
+ context: "The user wants a report generator. We need to pick the default export format.",
43
+ options: [
44
+ { label: "Markdown", description: "Simple, version-control friendly" },
45
+ { label: "PDF", description: "Polished, shareable document" },
46
+ ],
47
+ allowFreeform: true,
48
+ })
49
+
50
+ When shared understanding is reached, do NOT write the file yet. Show a concise requirements summary draft and ask exactly: "Approve writing this requirements summary to ${artifactDir}/requirements.md?" Allow "keep grilling" or added details.
51
+
52
+ Artifact target: ${artifactDir}/requirements.md
53
+ - Name that exact full path in the approval question.
54
+ - Do NOT shorten, translate, censor, sanitize, or invent a different path.
55
+ - Only after explicit approval, call write_workflow_artifact with content only. Do not use write.
56
+
57
+ The workflow advances once ${artifactDir}/requirements.md exists.`,
58
+ research: ({ artifactDir }) =>
59
+ `You are in the RESEARCH phase (optional).
60
+
61
+ Only research if the task depends on fast-changing external knowledge (libraries, frameworks, languages/SDKs, APIs, or unfamiliar alternatives). Skip what you already know well.
62
+
63
+ Decide: is research needed?
64
+ - If YES: use web_search_exa or webfetch via bash to gather current, authoritative information, then synthesize actionable findings (versions, APIs, pitfalls, recommended approaches).
65
+ - If NO: skip real research.
66
+
67
+ Either way, call write_workflow_artifact with research.md content. If skipped, state briefly why. If researched, record findings the plan can rely on.
68
+
69
+ The workflow advances once ${artifactDir}/research.md exists.`,
70
+ plan: ({ artifactDir }) =>
71
+ `You are in the PLAN phase.
72
+
73
+ Produce the concrete build plan for the actual prototype/output — not a plan for research. Use ${artifactDir}/requirements.md and ${artifactDir}/research.md (if it contains real findings). Cover what to build, how, in what order, which components, and what the finished prototype looks like.
74
+
75
+ If research was skipped, proceed directly — you already understand the user's intent from grilling.
76
+
77
+ Spawn the ARCHITECT sub-agent via the subagent tool (subagent_type "architect"). Do NOT pass a model parameter. Craft a tailored prompt from ${artifactDir}/requirements.md and ${artifactDir}/research.md so the architect plans for THIS task. The architect returns the plan; the workflow saves it to ${artifactDir}/plan.md.
78
+
79
+ The workflow advances once ${artifactDir}/plan.md exists.`,
80
+ reuse: ({ artifactDir }) =>
81
+ `You are in the REUSE phase (optional).
82
+
83
+ Decide whether codebase exploration is useful. Skip if the project is empty, the task creates something wholly new, or there is clearly nothing to reuse.
84
+
85
+ If unsure, ask the user one focused question: "Should I explore the existing codebase for reusable patterns before implementing?" Then follow their answer.
86
+
87
+ If YES (or user confirms): spawn the EXPLORER sub-agent via the subagent tool (subagent_type "explorer"). Do NOT pass a model parameter. Craft a specific prompt from ${artifactDir}/requirements.md and ${artifactDir}/plan.md pointing it at relevant areas, patterns, and dependencies (e.g., Tailwind setup, state-machine usage). Synthesize the findings into ${artifactDir}/reuse.md: what is reusable, where, and how to leverage it.
88
+
89
+ If NO: call write_workflow_artifact with a brief skip note explaining why.
90
+
91
+ The workflow advances once ${artifactDir}/reuse.md exists.`,
92
+ handoff: ({ artifactDir }) =>
93
+ `You are in the HANDOFF phase.
94
+
95
+ Compile a self-contained handoff document so loop-phase sub-agents understand full project context without re-grilling.
96
+
97
+ Draw from all prior phases:
98
+ - ${artifactDir}/requirements.md (grilling outcomes)
99
+ - ${artifactDir}/research.md (research, or the skip note)
100
+ - ${artifactDir}/plan.md (the build plan)
101
+ - ${artifactDir}/reuse.md (codebase exploration findings)
102
+
103
+ Spawn the RECAPPER sub-agent via the subagent tool (subagent_type "recapper"). Do NOT pass a model parameter. Craft a tailored prompt pointing the recapper at all four artifact files and telling it what the prototype is about. The recapper returns the handoff; the workflow saves it to ${artifactDir}/handoff.md.
104
+
105
+ The workflow advances once ${artifactDir}/handoff.md exists.`,
106
+ loop: ({ artifactDir }) =>
107
+ `You are in the LOOP (orchestration) phase. Delegate implementation to sub-agents — do not write code yourself.
108
+
109
+ Use read to inspect ${artifactDir}/plan.md, ${artifactDir}/handoff.md, ${artifactDir}/research.md, and ${artifactDir}/reuse.md. Using that context, GENERATE YOUR OWN delegation prompts (no static template):
110
+ 1. Dispatch ONE builder sub-agent via the subagent tool (subagent_type "builder"). Do NOT pass a model parameter. Give it plan + handoff + any research/reuse context, tailored to this task. Instruct it to implement every task in plan.md in order. All code changes go in the workspace, never in ${artifactDir}.
111
+ 2. Dispatch ONE commentator sub-agent via the subagent tool (subagent_type "commentator"). Do NOT pass a model parameter. Review the builder's diff against plan.md. Generate the review prompt YOURSELF based on what matters for this task.
112
+ 3. If the commentator reports blocking issues, dispatch the builder again with the issues to fix, then re-run the commentator. Repeat until no issues.
113
+ 4. Call write_workflow_artifact with a one-line summary of the finished plan.
114
+
115
+ Tailor prompts to the task — not generic. The workflow advances to audit once ${artifactDir}/loop-complete.md exists.`,
116
+ audit: ({ artifactDir }) =>
117
+ `You are in the AUDIT (review) phase.
118
+
119
+ Review uncommitted changes for correctness, plan adherence, and over-engineering. Use ponytail-review style: cut bloat, unnecessary abstractions, dead flexibility, and reinvented stdlib/native behavior.
120
+
121
+ 1. Spawn the COMMENTATOR sub-agent via the subagent tool (subagent_type "commentator"). Do NOT pass a model parameter. Craft a tailored prompt from the full uncommitted diff and ${artifactDir}/plan.md. The commentator returns its review; the workflow saves it to ${artifactDir}/review.md.
122
+ 2. If ${artifactDir}/review.md lists actionable issues, spawn the BUILDER sub-agent via the subagent tool (subagent_type "builder"). Do NOT pass a model parameter. Instruct it to fix every issue in the workspace, never in ${artifactDir}.
123
+ 3. Re-dispatch the commentator until ${artifactDir}/review.md says the review is clean and no issues remain.
124
+
125
+ The workflow closes once ${artifactDir}/review.md exists and the commentator reports no outstanding issues.`,
126
+ };
127
+
128
+ const config: WorkflowConfig = {
129
+ mode: "prototype",
130
+ phases,
131
+ phaseArtifacts: {
132
+ grilling: "requirements.md",
133
+ research: "research.md",
134
+ plan: "plan.md",
135
+ reuse: "reuse.md",
136
+ handoff: "handoff.md",
137
+ loop: "loop-complete.md",
138
+ audit: "review.md",
139
+ },
140
+ prompts,
141
+ closeArtifacts: ["review.md"],
142
+ statusKey: "prototype",
143
+ entryType: "prototype-phase",
144
+ footerLabel: "prototype",
145
+ };
146
+
147
+ export const prototypeMode: WorkflowModeRegistration = {
148
+ config,
149
+ commandName: "prototype",
150
+ commandDescription:
151
+ "Run the prototype workflow (grill → research → plan → reuse → handoff → loop → audit)",
152
+ toolNames: { start: "start_workflow", end: "end_workflow" },
153
+ toolLabels: { start: "Start Workflow", end: "End Workflow" },
154
+ };
155
+
156
+ export default prototypeMode;
@@ -0,0 +1,138 @@
1
+ import type {
2
+ Phase,
3
+ PromptContext,
4
+ WorkflowConfig,
5
+ WorkflowModeRegistration,
6
+ } from "../state-machine.ts";
7
+
8
+ // ponytail: quick workflow — same tool-driven loop as prototype, but shorter:
9
+ // grill (max 4 questions) → plan → reuse → handoff → loop → audit.
10
+ // No research phase. skipRules + closeArtifacts wired by the adapter.
11
+
12
+ const phases: Phase[] = [
13
+ "grilling",
14
+ "plan",
15
+ "reuse",
16
+ "handoff",
17
+ "loop",
18
+ "audit",
19
+ ];
20
+
21
+ const prompts: Partial<Record<Phase, (ctx: PromptContext) => string>> = {
22
+ grilling: ({ artifactDir, userPrompt }) =>
23
+ `You are in the GRILLING phase of a QUICK workflow.
24
+
25
+ User request:
26
+ ${userPrompt}
27
+
28
+ Use the question tool to grill the user. Ask AT MOST 4 focused clarifying questions — ONE question tool call at a time. Adapt each follow-up to prior answers. Dig into scope, constraints, success criteria, and edge cases.
29
+
30
+ For each question tool call:
31
+ - Provide a concise question.
32
+ - Pass a short context summary when it depends on prior findings.
33
+ - Prefer options when choices are known. Give each option a clear label and a brief description.
34
+ - Always set allowFreeform=true so the user can type a custom answer.
35
+ - Keep allowMultiple=false unless multiple selections genuinely apply.
36
+
37
+ Example:
38
+ question({
39
+ question: "What should the output format be?",
40
+ context: "The user wants a report generator. We need to pick the default export format.",
41
+ options: [
42
+ { label: "Markdown", description: "Simple, version-control friendly" },
43
+ { label: "PDF", description: "Polished, shareable document" },
44
+ ],
45
+ allowFreeform: true,
46
+ })
47
+
48
+ When you have enough clarity OR up to 10 questions max (less is better) have been asked, stop grilling. Show a concise requirements summary, then ask exactly: "Approve writing this requirements summary to ${artifactDir}/requirements.md?"
49
+
50
+ Artifact target: ${artifactDir}/requirements.md
51
+ - Name that exact full path in the approval question.
52
+ - Do NOT shorten, translate, censor, sanitize, or invent a different path.
53
+ - Only after explicit approval, call write_workflow_artifact with content only. Do not use write.
54
+
55
+ The workflow advances once ${artifactDir}/requirements.md exists.`,
56
+ plan: ({ artifactDir }) =>
57
+ `You are in the PLAN phase.
58
+
59
+ This is a QUICK workflow — no separate research phase. Use ${artifactDir}/requirements.md to produce the concrete build plan: what to build, how, in order, components, and what the finished prototype looks like.
60
+
61
+ Spawn the ARCHITECT sub-agent via the subagent tool (subagent_type "architect"). Do NOT pass a model parameter. Craft a tailored prompt from ${artifactDir}/requirements.md so the architect plans for THIS task. The architect returns the plan; the workflow saves it to ${artifactDir}/plan.md.
62
+
63
+ The workflow advances once ${artifactDir}/plan.md exists.`,
64
+ reuse: ({ artifactDir }) =>
65
+ `You are in the REUSE phase (optional).
66
+
67
+ Decide whether codebase exploration is useful. Skip if the project is empty, the task creates something wholly new, or there is clearly nothing to reuse.
68
+
69
+ If unsure, ask the user one focused question: "Should I explore the existing codebase for reusable patterns before implementing?" Then follow their answer.
70
+
71
+ If YES (or user confirms): spawn the EXPLORER sub-agent via the subagent tool (subagent_type "explorer"). Do NOT pass a model parameter. Craft a specific prompt from ${artifactDir}/requirements.md and ${artifactDir}/plan.md pointing it at relevant areas, patterns, and dependencies. Synthesize the findings into ${artifactDir}/reuse.md: what is reusable, where, and how to leverage it.
72
+
73
+ If NO: call write_workflow_artifact with a brief skip note explaining why.
74
+
75
+ The workflow advances once ${artifactDir}/reuse.md exists.`,
76
+ handoff: ({ artifactDir }) =>
77
+ `You are in the HANDOFF phase.
78
+
79
+ Compile a self-contained handoff document so loop-phase sub-agents understand full project context without re-grilling.
80
+
81
+ Draw from all prior phases:
82
+ - ${artifactDir}/requirements.md
83
+ - ${artifactDir}/plan.md
84
+ - ${artifactDir}/reuse.md
85
+
86
+ Spawn the RECAPPER sub-agent via the subagent tool (subagent_type "recapper"). Do NOT pass a model parameter. Craft a tailored prompt pointing the recapper at all three artifact files and telling it what the prototype is about. The recapper returns the handoff; the workflow saves it to ${artifactDir}/handoff.md.
87
+
88
+ The workflow advances once ${artifactDir}/handoff.md exists.`,
89
+ loop: ({ artifactDir }) =>
90
+ `You are in the LOOP (orchestration) phase. Delegate implementation to sub-agents — do not write code yourself.
91
+
92
+ Use read to inspect ${artifactDir}/plan.md, ${artifactDir}/handoff.md, and ${artifactDir}/reuse.md. Using that context, GENERATE YOUR OWN delegation prompts:
93
+ 1. Dispatch ONE builder sub-agent via the subagent tool (subagent_type "builder"). Do NOT pass a model parameter. Give it plan + handoff + reuse context, tailored to this task. Instruct it to implement every task in plan.md in order. All code changes go in the workspace, never in ${artifactDir}.
94
+ 2. Dispatch ONE commentator sub-agent via the subagent tool (subagent_type "commentator"). Do NOT pass a model parameter. Review the builder's diff against plan.md. Generate the review prompt YOURSELF.
95
+ 3. If the commentator reports blocking issues, dispatch the builder again with the issues to fix, then re-run the commentator. Repeat until no issues.
96
+ 4. Call write_workflow_artifact with a one-line summary of the finished plan.
97
+
98
+ The workflow advances to audit once ${artifactDir}/loop-complete.md exists.`,
99
+ audit: ({ artifactDir }) =>
100
+ `You are in the AUDIT (review) phase.
101
+
102
+ Review uncommitted changes for correctness, plan adherence, and over-engineering. Use ponytail-review style: cut bloat, unnecessary abstractions, dead flexibility, and reinvented stdlib/native behavior.
103
+
104
+ 1. Spawn the COMMENTATOR sub-agent via the subagent tool (subagent_type "commentator"). Do NOT pass a model parameter. Craft a tailored prompt from the full uncommitted diff and ${artifactDir}/plan.md. The commentator returns its review; the workflow saves it to ${artifactDir}/review.md.
105
+ 2. If ${artifactDir}/review.md lists actionable issues, spawn the BUILDER sub-agent via the subagent tool (subagent_type "builder"). Do NOT pass a model parameter. Instruct it to fix every issue in the workspace, never in ${artifactDir}.
106
+ 3. Re-dispatch the commentator until ${artifactDir}/review.md says the review is clean and no issues remain.
107
+
108
+ The workflow closes once ${artifactDir}/review.md exists and the commentator reports no outstanding issues.`,
109
+ };
110
+
111
+ const config: WorkflowConfig = {
112
+ mode: "quick",
113
+ phases,
114
+ phaseArtifacts: {
115
+ grilling: "requirements.md",
116
+ plan: "plan.md",
117
+ reuse: "reuse.md",
118
+ handoff: "handoff.md",
119
+ loop: "loop-complete.md",
120
+ audit: "review.md",
121
+ },
122
+ prompts,
123
+ closeArtifacts: ["review.md"],
124
+ statusKey: "quick",
125
+ entryType: "quick-phase",
126
+ footerLabel: "quick",
127
+ };
128
+
129
+ export const quickMode: WorkflowModeRegistration = {
130
+ config,
131
+ commandName: "quick",
132
+ commandDescription:
133
+ "Run the quick workflow (grill → plan → reuse → handoff → loop → audit)",
134
+ toolNames: { start: "start_quick_workflow", end: "end_quick_workflow" },
135
+ toolLabels: { start: "Start Quick Workflow", end: "End Quick Workflow" },
136
+ };
137
+
138
+ export default quickMode;
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@selesai/workflow",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "description": "Selesai workflow engine + modes (prototype, quick). Loaded as a bundled pi extension package.",
6
+ "type": "module",
7
+ "pi": {
8
+ "extensions": [
9
+ "./extension.ts"
10
+ ]
11
+ },
12
+ "peerDependencies": {
13
+ "@earendil-works/pi-coding-agent": "*",
14
+ "@earendil-works/pi-tui": "*",
15
+ "typebox": "*"
16
+ }
17
+ }