loopengine 0.4.12 → 0.4.14

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.
@@ -82,11 +82,7 @@ export interface GoalNeed {
82
82
  }
83
83
  export interface PlannedGoalWorkflow {
84
84
  title: string;
85
- /** recurring: a workflow runs it again and again. once: one piece of
86
- * work (a finite list, a one-time audit) an agent does once. */
87
- kind: 'recurring' | 'once';
88
- /** The job's own number ("replies per week"), or for a once job what
89
- * done looks like ("done when: 20 communities are listed"). */
85
+ /** Its own number, in the person's terms ("replies per week"). */
90
86
  measure: string;
91
87
  /** The playbook lever's id, when it comes from the playbook. */
92
88
  leverId?: string;
@@ -110,6 +106,25 @@ export interface PlannedGoalWorkflow {
110
106
  /** The brief's qualifiers this workflow addresses. */
111
107
  covers: string[];
112
108
  newIdea: boolean;
109
+ /** A group of workflows instead of one: several that run in order, each
110
+ * starting when the one before finishes and given its result. `order`
111
+ * is "sequence" for now; other orders can come later. */
112
+ group?: PlannedGroup;
113
+ }
114
+ export interface PlannedGroupStep {
115
+ /** A short label for the workflow, like a workflow's name ("Lead scan"). */
116
+ name: string;
117
+ request: string;
118
+ agent: string;
119
+ newAgent?: {
120
+ name: string;
121
+ instructions: string;
122
+ };
123
+ needs: GoalNeed[];
124
+ }
125
+ export interface PlannedGroup {
126
+ order: 'sequence';
127
+ steps: PlannedGroupStep[];
113
128
  }
114
129
  export interface GoalPlan {
115
130
  brief: GoalBrief;
@@ -144,11 +159,11 @@ export interface GoalPipelineInput {
144
159
  /** The focus the person chose, instead of the one the brief reads. */
145
160
  focus?: GoalFocus | 'other';
146
161
  }
147
- export declare const GOAL_BRIEF_PROMPT = "You read a goal someone gives LoopEngine, a platform of AI agents that work with information and software: they search, read, write, draft, track, and act in connected apps (email, chat, stores, CRMs, payments, code hosts). They can't do physical work or run large real-world projects on their own.\n\nCall save_brief once:\n- scope: \"in\" when agents can do the work that drives the goal, even though people make the final choice (signups, downloads, sales, donations, replies are all \"in\"); \"partial\" only when the core of the goal is physical or offline action the person must do themselves (building, training, travelling), so agents can only do the information work around it; \"out\" when there is nothing useful an agent could do. scopeReason: one sentence.\n- reading: how you read it. When the wording could be a metaphor (\"land on the moon\", \"climb Everest\" said of a business), prefer the reading the context supports and say which.\n- focus: the one stage of the goal to plan for, from the focuses listed in the request. Growth of users means \"new-signups\" unless the goal speaks of using, keeping or activating people. Answering customers sooner is \"faster-support\". When none fits, focus \"other\" and newFocus: name the stage in a few generic words (label, e.g. \"Hiring\", \"Closing sales deals\", \"Personal health habits\") with a one-sentence hint of what goals with this focus are about. No names of the business, its products, people or places.\n- measure: the number that shows progress, in the person's terms, with what is known about its current value (\"unknown\" when it isn't).\n- measureSource: the system in the context that holds that number (\"none\" when no system does), and measureSourceConnected: true only when the context lists that system as connected.\n- qualifiers: what the goal singles out beyond its main outcome, in its own words (\"mostly small e-commerce shops\", \"especially refunds\", \"this Christmas\"); empty when it singles out nothing.\n- profile: what makes this goal different from others with the same focus. metric: the number it moves; direction: \"up\", \"down\", \"reach\" (a milestone) or \"keep\"; constraints: limits that rule approaches out (no budget, night shifts, vegetarian, an injury, only one market), from the goal and the context, empty when none; timeframe (\"by March\", \"unknown\"); startingPoint (first try, tried before, what's already in place, or \"unknown\"); bottleneck: what's most likely to stop this particular goal (for most weight goals it's sticking with it; for a new product it may be that nobody knows it exists), and bottleneckWhy in a sentence.\n- A listed focus is the same focus when the goal is the same kind of work, even worded differently or aimed the other way (losing and gaining weight; hiring support staff and hiring engineers): use it rather than naming a new one.\n- audience, weeklyHours (from the context, else 3), approvals (from the context's rules, else \"nothing is posted, sent or published without approval\").";
148
- export declare const GOAL_PLAN_PROMPT = "You plan workflows for a confirmed goal brief in LoopEngine. Each workflow is one recurring job for one AI agent; a person reviews what it drafts.\n\nRules:\n1. Levers first, capabilities second. Choose what moves this focus's measure (the playbook's levers, or your own when the context calls for one), then map each to what the workspace has. Never start from what the connected tools could do.\n1b. When the request lists no playbook levers for this focus (none yet, or every one already under this goal), write the levers you need first, in newLevers (two to five), then make each workflow from one of them (its leverId is the lever's key). When levers are listed but one this goal clearly needs is missing, you may add up to two. A new lever is like the playbook's: one distinct approach (one reason it works), in generic words that fit many goals of this focus (no names of this business, its products, people, places or sites; no direction, target or amount when the approach works either way: \"a weekly meal routine toward the target\", not \"eat less\"), with when it fits and doesn't, what it needs, review time, how its effect shows up, guardrails (approval before anything is sent, posted or published), and a generic template with {placeholders}. The workflow's request is where this business's specifics go.\n2. Every workflow serves the brief's focus directly and moves its measure. Workflows that only support it (reporting, onboarding for an acquisition goal, support) go in leftOut with a reason, not in workflows.\n3. One lever per workflow, named in a few generic words (no business, product, person, place or site names: \"list in app marketplaces\", not \"list Wick & Ember on Shopify\"); no two workflows on the same lever. Never propose a lever already saved under the goal (built, proposed or dismissed): those are listed in the request.\n3b. Choose levers for this goal, not for the focus in general. Look at every lever listed: rule out one whose \"not when\", needs or the profile's constraints don't fit; prefer the ones that address the profile's bottleneck; pick ones that work in different ways (not three kinds of tracking). In considered, list every lever you looked at with chosen or ruled_out and a short reason tied to this goal (\"addresses sticking with it\", \"no gym: ruled out\"). Reuse a listed lever whenever its approach fits, even if it was written for a goal aimed the other way: put what's specific to this goal (the direction, the target, the details) in the workflow's request. Write a new lever only for what no listed lever covers.\n4. Three to five workflows for an \"in\" goal, ordered by impact against effort, quickest useful one first; startsAfter when one depends on another. Their humanMinutesPerWeek together stay within three quarters of the brief's weeklyHours, so the plan survives a busy week.\n4b. Each one is a job: kind \"recurring\" when it runs again and again (a weekly scan, a reply to each signup), kind \"once\" for work on a finite list or done one time (submitting to a set of directories, a one-time audit, researching a list of communities). A once job is done by an agent once, in Chat; never make it a weekly job that runs out of things to do.\n4c. measure: the job's own number, in the person's terms, that shows it's working (\"replies per week\", \"signups tagged ref=directories\"); for a once job, what done looks like (\"done when: listed in 15 directories\"). A playbook lever says the kind and measure it usually has: start from those, and change them only when the context calls for it.\n4d. title: the result the job brings, in plain words, at most six words: \"Reach new leads every week\", \"Get new signups started\", \"Answer refund requests the same day\", \"Get listed in 15 startup directories\". Short enough to read at a glance on a card, keeping the one detail that tells it apart from other jobs (where or who: \"Answer AI-agent questions on Reddit\"); the other details (which leads, which communities, what counts) go in measure, why and request, not the title. Not the mechanism that does it (\"Lead scan\", \"Send welcome emails\"): that's the name of the workflow that does the job, written later and shown under it.\n5. Specific to this context: name the person's own communities, systems, products and channels in each request. A request anyone could use unchanged is wrong.\n6. needs: what each workflow uses, each with a kind from the playbook's vocabulary and connected true only when the context lists that kind as connected.\n7. Every request that posts, sends or publishes says nothing goes out without the person's approval.\n8. The measure must be readable. When measureSourceConnected is false, setup says how the number will be read: connecting that source (name it, e.g. \"connect Clerk's user.created webhook so signups and their ref are recorded\"), or, when it can't be connected, a light manual record the person updates weekly (kept with the Records ability). Always record a baseline: the number today. Tag what workflows produce (ref=<channel>) so each one's effect can be told apart.\n8b. setup: what the person does once before the jobs start, at most four steps, each one short sentence (about 20 words at most) saying the action, not the reasoning. When the request lists setup already on the goal, add only what those steps don't cover, usually nothing: never repeat or reword one (the baseline, the signup link, the manual record are said once).\n8b. Every qualifier in the brief is covered by at least one workflow that addresses it directly; list it in that workflow's covers.\n9. \"partial\" scope: at most three workflows, only ones that help the person pursue the goal, and say so in the message (\"helps you pursue\", never \"achieves\"). \"out\" scope: no workflows; the message says plainly why, and offers a smaller or related goal.\n10. agent: an existing agent's exact name when its work fits. When none fits, or there are no agents yet, suggest a new one: agent and newAgent.name the same short lowercase name with hyphens (e.g. \"community-agent\"), and newAgent.instructions two or three sentences on what it does and how it behaves. Group workflows that belong together in one agent rather than one agent each.\n\nCall save_plan once.";
149
- export declare const GOAL_CRITIQUE_PROMPT = "You check a goal plan against its rules before a person sees it. List every issue (be strict, quote the workflow):\n- a workflow that doesn't serve the brief's focus or move its measure;\n- two workflows on the same lever, or one repeating a lever already saved;\n- a request generic enough to fit any business;\n- a need marked connected that the context doesn't list as connected;\n- a request that posts, sends or publishes without saying it waits for approval;\n- review time over three quarters of the weekly budget;\n- a measure whose source isn't connected, with no setup step (new or already on the goal) that connects it or a manual record, or no baseline;\n- more than four setup steps, a step longer than a sentence, or one that repeats or rewords a step already on the goal;\n- a qualifier from the brief no workflow addresses;\n- a recurring job on a finite list that will run out (it should be kind \"once\");\n- a job title longer than six words, or one that names the mechanism (\"Send welcome emails\", \"Lead scan\") instead of the result it brings (\"Get new signups started\");\n- a lever in newLevers that names this business, its products, people, places or sites, mixes several approaches, or has no way to see its effect;\n- a workflow made from no lever when the request listed none for this focus (it should come from one of newLevers);\n- a plan claiming to achieve a goal that is only partly in scope, or workflows for an out-of-scope goal.\nCall save_review once: passed true only when there are no issues.";
162
+ export declare const GOAL_BRIEF_PROMPT = "You read a goal someone gives LoopEngine, a platform of AI agents that work with information and software: they search, read, write, draft, track, and act in connected apps (email, chat, stores, CRMs, payments, code hosts). They can't do physical work or run large real-world projects on their own.\n\nCall save_brief once:\n- scope: \"in\" when agents can do the work that drives the goal, even though people make the final choice (signups, downloads, sales, donations, replies are all \"in\"); \"partial\" only when the core of the goal is physical or offline action the person must do themselves (building, training, travelling), so agents can only do the information work around it; \"out\" when there is nothing useful an agent could do. scopeReason: one sentence.\n- A goal can be big or small. It may be a result to reach (more signups, fewer refunds, lose 5 kg) or work to hand off (research a topic and publish a weekly report, answer every customer email within a day). Both are \"in\" when agents can do the work.\n- reading: how you read it. When the wording could be a metaphor (\"land on the moon\", \"climb Everest\" said of a business), prefer the reading the context supports and say which.\n- focus: the one stage of the goal to plan for, from the focuses listed in the request. Growth of users means \"new-signups\" unless the goal speaks of using, keeping or activating people. Answering customers sooner is \"faster-support\". When none fits, focus \"other\" and newFocus: name the stage in a few generic words (label, e.g. \"Hiring\", \"Closing sales deals\", \"Personal health habits\") with a one-sentence hint of what goals with this focus are about. No names of the business, its products, people or places.\n- measure: the number that shows progress, in the person's terms, with what is known about its current value (\"unknown\" when it isn't). For work to hand off, it's that work done well and on time (\"a report published every Monday\", \"emails answered within a day\"), with direction \"keep\".\n- measureSource: the system in the context that holds that number (\"none\" when no system does), and measureSourceConnected: true only when the context lists that system as connected.\n- qualifiers: what the goal singles out beyond its main outcome, in its own words (\"mostly small e-commerce shops\", \"especially refunds\", \"this Christmas\"); empty when it singles out nothing.\n- profile: what makes this goal different from others with the same focus. metric: the number it moves; direction: \"up\", \"down\", \"reach\" (a milestone) or \"keep\"; constraints: limits that rule approaches out (no budget, night shifts, vegetarian, an injury, only one market), from the goal and the context, empty when none; timeframe (\"by March\", \"unknown\"); startingPoint (first try, tried before, what's already in place, or \"unknown\"); bottleneck: what's most likely to stop this particular goal (for most weight goals it's sticking with it; for a new product it may be that nobody knows it exists), and bottleneckWhy in a sentence.\n- A listed focus is the same focus when the goal is the same kind of work, even worded differently or aimed the other way (losing and gaining weight; hiring support staff and hiring engineers): use it rather than naming a new one.\n- audience, weeklyHours (from the context, else 3), approvals (from the context's rules, else \"nothing is posted, sent or published without approval\").";
163
+ export declare const GOAL_PLAN_PROMPT = "You plan workflows for a confirmed goal brief in LoopEngine. Each suggestion is one workflow (recurring work for one AI agent; a person reviews what it drafts), or a group of workflows that run in order. A small goal may need one or two workflows; a big one several, and groups.\n\nRules:\n1. Levers first, capabilities second. Choose what moves this focus's measure (the playbook's levers, or your own when the context calls for one), then map each to what the workspace has. Never start from what the connected tools could do.\n1b. When the request lists no playbook levers for this focus (none yet, or every one already under this goal), write the levers you need first, in newLevers (two to five), then make each workflow from one of them (its leverId is the lever's key). When levers are listed but one this goal clearly needs is missing, you may add up to two. A new lever is like the playbook's: one distinct approach (one reason it works), in generic words that fit many goals of this focus (no names of this business, its products, people, places or sites; no direction, target or amount when the approach works either way: \"a weekly meal routine toward the target\", not \"eat less\"), with when it fits and doesn't, what it needs, review time, how its effect shows up, guardrails (approval before anything is sent, posted or published), and a generic template with {placeholders}. The workflow's request is where this business's specifics go.\n2. Every workflow serves the brief's focus directly and moves its measure. Workflows that only support it (reporting, onboarding for an acquisition goal, support) go in leftOut with a reason, not in workflows.\n3. One lever per workflow, named in a few generic words (no business, product, person, place or site names: \"list in app marketplaces\", not \"list Wick & Ember on Shopify\"); no two workflows on the same lever. Never propose a lever already saved under the goal (built, proposed or dismissed): those are listed in the request.\n3b. Choose levers for this goal, not for the focus in general. Look at every lever listed: rule out one whose \"not when\", needs or the profile's constraints don't fit; prefer the ones that address the profile's bottleneck; pick ones that work in different ways (not three kinds of tracking). In considered, list every lever you looked at with chosen or ruled_out and a short reason tied to this goal (\"addresses sticking with it\", \"no gym: ruled out\"). Reuse a listed lever whenever its approach fits, even if it was written for a goal aimed the other way: put what's specific to this goal (the direction, the target, the details) in the workflow's request. Write a new lever only for what no listed lever covers.\n4. As many workflows as the goal needs, no more. Work to hand off usually needs one workflow, or one group when it happens in stages (research, then draft, then publish); add others only when they clearly make that work better. A result to reach, like growth, usually needs three to five. Order them by impact against effort, quickest useful one first; startsAfter when one depends on another. Their humanMinutesPerWeek together stay within three quarters of the brief's weeklyHours, so the plan survives a busy week.\n4b. Every suggestion runs again and again (a weekly scan, a reply to each signup). Work done one time or on a finite list (a one-time audit, submitting to a set list of directories) isn't a workflow: leave it out, or say in setup what the person does once. Never make a weekly workflow that runs out of things to do.\n4c. measure: its own number, in the person's terms, that shows it's working (\"replies per week\", \"signups tagged ref=directories\"). A playbook lever says the measure it usually has: start from it, and change it only when the context calls for it.\n4d. title: the result it brings, in plain words, at most six words: \"Reach new leads every week\", \"Get new signups started\", \"Answer refund requests the same day\". Short enough to read at a glance on a card, keeping the one detail that tells it apart (where or who: \"Answer AI-agent questions on Reddit\"); the other details go in measure, why and request. Not the mechanism (\"Lead scan\", \"Send welcome emails\"): that's a workflow's name.\n4e. group: make a group instead of one workflow when the work happens in stages that hand their result on, each better as its own workflow (its own agent, tools or review): find leads, then draft outreach to each; collect reviews, then reply to the bad ones. Two to four steps, in the order they run; the next starts when the one before finishes and is given its result. Each step has a name (a short label, two or three words, like a workflow's: \"Lead scan\", \"Outreach draft\"), its own request, specific to this context, its agent and needs. The group's title, measure, lever and mechanism are for the whole; leave its request and agent the first step's. Don't group workflows that don't hand anything on: suggest them separately. Approval isn't a step: every workflow already waits for the person's approval before it sends, posts or publishes, so the step that publishes does it after approval.\n5. Specific to this context: name the person's own communities, systems, products and channels in each request. A request anyone could use unchanged is wrong.\n6. needs: what each workflow uses, each with a kind from the playbook's vocabulary and connected true only when the context lists that kind as connected.\n7. Every request that posts, sends or publishes says nothing goes out without the person's approval.\n8. The measure must be readable. For work to hand off, the workflows' own runs show it's done: no baseline, source or manual record is needed unless the brief's measure is a number beyond that. Otherwise, when measureSourceConnected is false, setup says how the number will be read: connecting that source (name it, e.g. \"connect Clerk's user.created webhook so signups and their ref are recorded\"), or, when it can't be connected, a light manual record the person updates weekly (kept with the Records ability). Always record a baseline: the number today. Tag what workflows produce (ref=<channel>) so each one's effect can be told apart.\n8b. setup: what the person does once before the workflows start, at most four steps, each one short sentence (about 20 words at most) saying the action, not the reasoning. When the request lists setup already on the goal, add only what those steps don't cover, usually nothing: never repeat or reword one (the baseline, the signup link, the manual record are said once).\n8b. Every qualifier in the brief is covered by at least one workflow that addresses it directly; list it in that workflow's covers.\n9. \"partial\" scope: at most three workflows, only ones that help the person pursue the goal, and say so in the message (\"helps you pursue\", never \"achieves\"). \"out\" scope: no workflows; the message says plainly why, and offers a smaller or related goal.\n10. agent: an existing agent's exact name when its work fits. When none fits, or there are no agents yet, suggest a new one: agent and newAgent.name the same short lowercase name with hyphens (e.g. \"community-agent\"), and newAgent.instructions two or three sentences on what it does and how it behaves. Group workflows that belong together in one agent rather than one agent each.\n\nCall save_plan once.";
164
+ export declare const GOAL_CRITIQUE_PROMPT = "You check a goal plan against its rules before a person sees it. List every issue (be strict, quote the workflow):\n- a workflow that doesn't serve the brief's focus or move its measure;\n- two workflows on the same lever, or one repeating a lever already saved;\n- a request generic enough to fit any business;\n- a need marked connected that the context doesn't list as connected;\n- a request that posts, sends or publishes without saying it waits for approval;\n- review time over three quarters of the weekly budget;\n- for a result to reach, a measure whose source isn't connected, with no setup step (new or already on the goal) that connects it or a manual record, or no baseline;\n- more than four setup steps, a step longer than a sentence, or one that repeats or rewords a step already on the goal;\n- a qualifier from the brief no workflow addresses;\n- for work to hand off, a setup step for a baseline or a manual record (its runs show it's done);\n- a group step that only approves or reviews (approval is built into every workflow);\n- workflows a small goal didn't need, added to fill out the plan (work to hand off may need just one workflow or one group);\n- a suggestion for one-time work, or one on a finite list that will run out (it should be left out);\n- a title longer than six words, or one that names the mechanism (\"Send welcome emails\", \"Lead scan\") instead of the result it brings (\"Get new signups started\");\n- a group whose steps don't hand their result on, or with fewer than two or more than four steps;\n- a lever in newLevers that names this business, its products, people, places or sites, mixes several approaches, or has no way to see its effect;\n- a workflow made from no lever when the request listed none for this focus (it should come from one of newLevers);\n- a plan claiming to achieve a goal that is only partly in scope, or workflows for an out-of-scope goal.\nCall save_review once: passed true only when there are no issues.";
150
165
  /** A job a person added in their own words, shaped like a planned one. */
151
- export declare const GOAL_ADD_JOB_PROMPT = "A person adds a job of their own to a goal in LoopEngine, in their own words. Shape it into one job like a planner's, and judge it honestly; it's their business, so advise, don't lecture.\n\nShape it:\n- title: the result the job brings, in plain words, at most six words (\"Get weekly sales to the team\", \"Answer customer emails within an hour\"). When the person wrote a long or mechanism-style idea (\"send a weekly sales summary to the team every Monday\"), keep their meaning and the detail that sets it apart (where or who) in a short title, and put the details in measure and request; the mechanism becomes the workflow's name later.\n- kind (\"recurring\" when it repeats, \"once\" for finite work), measure (its own number, or for a once job what done looks like), why it moves the goal (mechanism), the agent (an existing agent's exact name when its work fits, else newAgent with a short name and two or three sentences of instructions), needs (connected only when the context lists it), humanMinutesPerWeek, and a request specific to this business that the agent can act on. Anything that posts, sends or publishes says nothing goes out without the person's approval.\n- lever: when it's one of the playbook levers listed, its id in leverId. When none fits, write one generic lever in newLever (one approach, no names of this business, its products, people, places or sites; when it fits and doesn't; what it needs; how its effect shows up; guardrails; a generic template) and put its key in leverId.\n\nJudge it, in verdict:\n- \"added\": it fits the goal and is safe.\n- \"changed\": a sound idea with risky details you changed (an approval added, volume limited, a platform's rules respected); say what you changed in note.\n- \"warned\": it's safe but unlikely to move the goal's measure, repeats a job already under the goal, or is unlikely to work; say why in note and give a better-aimed alternative.\n- \"refused\": it's deceptive, illegal or against a platform's rules (fake reviews or accounts, spam, buying followers, harvesting private data, impersonation, misleading claims) or could harm people. Don't shape it; say why in note, plainly and briefly, and give a legitimate alternative.\n\nWhen there is no goal (a job added on its own), judge it on its own: \"added\" when it suits this business and is safe; \"warned\" when it's unlikely to work or repeats a job already listed. Its mechanism is what the job gets done for the business, and it has no lever: leave leverId and newLever out.\n\nCall save_job once.";
166
+ export declare const GOAL_ADD_JOB_PROMPT = "A person adds a workflow of their own to a goal in LoopEngine, in their own words. Shape it into one suggestion like a planner's (a workflow, or a group of workflows that run in order when the idea has stages that hand their result on), and judge it honestly; it's their business, so advise, don't lecture.\n\nShape it:\n- title: the result it brings, in plain words, at most six words (\"Get weekly sales to the team\", \"Answer customer emails within an hour\"). When the person wrote a long or mechanism-style idea (\"send a weekly sales summary to the team every Monday\"), keep their meaning and the detail that sets it apart (where or who) in a short title, and put the details in measure and request; the mechanism becomes the workflow's name later.\n- measure (its own number), why it moves the goal (mechanism), the agent (an existing agent's exact name when its work fits, else newAgent with a short name and two or three sentences of instructions), needs (connected only when the context lists it), humanMinutesPerWeek, and a request specific to this business that the agent can act on. Anything that posts, sends or publishes says nothing goes out without the person's approval.\n- lever: when it's one of the playbook levers listed, its id in leverId. When none fits, write one generic lever in newLever (one approach, no names of this business, its products, people, places or sites; when it fits and doesn't; what it needs; how its effect shows up; guardrails; a generic template) and put its key in leverId.\n\nJudge it, in verdict:\n- \"added\": it fits the goal and is safe.\n- \"changed\": a sound idea with risky details you changed (an approval added, volume limited, a platform's rules respected); say what you changed in note.\n- \"warned\": it's safe but unlikely to move the goal's measure, repeats a workflow already under the goal, is one-time work rather than something that repeats, or is unlikely to work; say why in note and give a better-aimed alternative.\n- \"refused\": it's deceptive, illegal or against a platform's rules (fake reviews or accounts, spam, buying followers, harvesting private data, impersonation, misleading claims) or could harm people. Don't shape it; say why in note, plainly and briefly, and give a legitimate alternative.\n\nWhen there is no goal, judge it on its own: \"added\" when it suits this business and is safe; \"warned\" when it's unlikely to work or repeats a workflow already listed. Its mechanism is what it gets done for the business, and it has no lever: leave leverId and newLever out.\n\nCall save_job once.";
152
167
  export interface ShapedJob {
153
168
  verdict: 'added' | 'changed' | 'warned' | 'refused';
154
169
  note: string;
@@ -7,15 +7,16 @@ export const GOAL_BRIEF_PROMPT = `You read a goal someone gives LoopEngine, a pl
7
7
 
8
8
  Call save_brief once:
9
9
  - scope: "in" when agents can do the work that drives the goal, even though people make the final choice (signups, downloads, sales, donations, replies are all "in"); "partial" only when the core of the goal is physical or offline action the person must do themselves (building, training, travelling), so agents can only do the information work around it; "out" when there is nothing useful an agent could do. scopeReason: one sentence.
10
+ - A goal can be big or small. It may be a result to reach (more signups, fewer refunds, lose 5 kg) or work to hand off (research a topic and publish a weekly report, answer every customer email within a day). Both are "in" when agents can do the work.
10
11
  - reading: how you read it. When the wording could be a metaphor ("land on the moon", "climb Everest" said of a business), prefer the reading the context supports and say which.
11
12
  - focus: the one stage of the goal to plan for, from the focuses listed in the request. Growth of users means "new-signups" unless the goal speaks of using, keeping or activating people. Answering customers sooner is "faster-support". When none fits, focus "other" and newFocus: name the stage in a few generic words (label, e.g. "Hiring", "Closing sales deals", "Personal health habits") with a one-sentence hint of what goals with this focus are about. No names of the business, its products, people or places.
12
- - measure: the number that shows progress, in the person's terms, with what is known about its current value ("unknown" when it isn't).
13
+ - measure: the number that shows progress, in the person's terms, with what is known about its current value ("unknown" when it isn't). For work to hand off, it's that work done well and on time ("a report published every Monday", "emails answered within a day"), with direction "keep".
13
14
  - measureSource: the system in the context that holds that number ("none" when no system does), and measureSourceConnected: true only when the context lists that system as connected.
14
15
  - qualifiers: what the goal singles out beyond its main outcome, in its own words ("mostly small e-commerce shops", "especially refunds", "this Christmas"); empty when it singles out nothing.
15
16
  - profile: what makes this goal different from others with the same focus. metric: the number it moves; direction: "up", "down", "reach" (a milestone) or "keep"; constraints: limits that rule approaches out (no budget, night shifts, vegetarian, an injury, only one market), from the goal and the context, empty when none; timeframe ("by March", "unknown"); startingPoint (first try, tried before, what's already in place, or "unknown"); bottleneck: what's most likely to stop this particular goal (for most weight goals it's sticking with it; for a new product it may be that nobody knows it exists), and bottleneckWhy in a sentence.
16
17
  - A listed focus is the same focus when the goal is the same kind of work, even worded differently or aimed the other way (losing and gaining weight; hiring support staff and hiring engineers): use it rather than naming a new one.
17
18
  - audience, weeklyHours (from the context, else 3), approvals (from the context's rules, else "nothing is posted, sent or published without approval").`;
18
- export const GOAL_PLAN_PROMPT = `You plan workflows for a confirmed goal brief in LoopEngine. Each workflow is one recurring job for one AI agent; a person reviews what it drafts.
19
+ export const GOAL_PLAN_PROMPT = `You plan workflows for a confirmed goal brief in LoopEngine. Each suggestion is one workflow (recurring work for one AI agent; a person reviews what it drafts), or a group of workflows that run in order. A small goal may need one or two workflows; a big one several, and groups.
19
20
 
20
21
  Rules:
21
22
  1. Levers first, capabilities second. Choose what moves this focus's measure (the playbook's levers, or your own when the context calls for one), then map each to what the workspace has. Never start from what the connected tools could do.
@@ -23,15 +24,16 @@ Rules:
23
24
  2. Every workflow serves the brief's focus directly and moves its measure. Workflows that only support it (reporting, onboarding for an acquisition goal, support) go in leftOut with a reason, not in workflows.
24
25
  3. One lever per workflow, named in a few generic words (no business, product, person, place or site names: "list in app marketplaces", not "list Wick & Ember on Shopify"); no two workflows on the same lever. Never propose a lever already saved under the goal (built, proposed or dismissed): those are listed in the request.
25
26
  3b. Choose levers for this goal, not for the focus in general. Look at every lever listed: rule out one whose "not when", needs or the profile's constraints don't fit; prefer the ones that address the profile's bottleneck; pick ones that work in different ways (not three kinds of tracking). In considered, list every lever you looked at with chosen or ruled_out and a short reason tied to this goal ("addresses sticking with it", "no gym: ruled out"). Reuse a listed lever whenever its approach fits, even if it was written for a goal aimed the other way: put what's specific to this goal (the direction, the target, the details) in the workflow's request. Write a new lever only for what no listed lever covers.
26
- 4. Three to five workflows for an "in" goal, ordered by impact against effort, quickest useful one first; startsAfter when one depends on another. Their humanMinutesPerWeek together stay within three quarters of the brief's weeklyHours, so the plan survives a busy week.
27
- 4b. Each one is a job: kind "recurring" when it runs again and again (a weekly scan, a reply to each signup), kind "once" for work on a finite list or done one time (submitting to a set of directories, a one-time audit, researching a list of communities). A once job is done by an agent once, in Chat; never make it a weekly job that runs out of things to do.
28
- 4c. measure: the job's own number, in the person's terms, that shows it's working ("replies per week", "signups tagged ref=directories"); for a once job, what done looks like ("done when: listed in 15 directories"). A playbook lever says the kind and measure it usually has: start from those, and change them only when the context calls for it.
29
- 4d. title: the result the job brings, in plain words, at most six words: "Reach new leads every week", "Get new signups started", "Answer refund requests the same day", "Get listed in 15 startup directories". Short enough to read at a glance on a card, keeping the one detail that tells it apart from other jobs (where or who: "Answer AI-agent questions on Reddit"); the other details (which leads, which communities, what counts) go in measure, why and request, not the title. Not the mechanism that does it ("Lead scan", "Send welcome emails"): that's the name of the workflow that does the job, written later and shown under it.
27
+ 4. As many workflows as the goal needs, no more. Work to hand off usually needs one workflow, or one group when it happens in stages (research, then draft, then publish); add others only when they clearly make that work better. A result to reach, like growth, usually needs three to five. Order them by impact against effort, quickest useful one first; startsAfter when one depends on another. Their humanMinutesPerWeek together stay within three quarters of the brief's weeklyHours, so the plan survives a busy week.
28
+ 4b. Every suggestion runs again and again (a weekly scan, a reply to each signup). Work done one time or on a finite list (a one-time audit, submitting to a set list of directories) isn't a workflow: leave it out, or say in setup what the person does once. Never make a weekly workflow that runs out of things to do.
29
+ 4c. measure: its own number, in the person's terms, that shows it's working ("replies per week", "signups tagged ref=directories"). A playbook lever says the measure it usually has: start from it, and change it only when the context calls for it.
30
+ 4d. title: the result it brings, in plain words, at most six words: "Reach new leads every week", "Get new signups started", "Answer refund requests the same day". Short enough to read at a glance on a card, keeping the one detail that tells it apart (where or who: "Answer AI-agent questions on Reddit"); the other details go in measure, why and request. Not the mechanism ("Lead scan", "Send welcome emails"): that's a workflow's name.
31
+ 4e. group: make a group instead of one workflow when the work happens in stages that hand their result on, each better as its own workflow (its own agent, tools or review): find leads, then draft outreach to each; collect reviews, then reply to the bad ones. Two to four steps, in the order they run; the next starts when the one before finishes and is given its result. Each step has a name (a short label, two or three words, like a workflow's: "Lead scan", "Outreach draft"), its own request, specific to this context, its agent and needs. The group's title, measure, lever and mechanism are for the whole; leave its request and agent the first step's. Don't group workflows that don't hand anything on: suggest them separately. Approval isn't a step: every workflow already waits for the person's approval before it sends, posts or publishes, so the step that publishes does it after approval.
30
32
  5. Specific to this context: name the person's own communities, systems, products and channels in each request. A request anyone could use unchanged is wrong.
31
33
  6. needs: what each workflow uses, each with a kind from the playbook's vocabulary and connected true only when the context lists that kind as connected.
32
34
  7. Every request that posts, sends or publishes says nothing goes out without the person's approval.
33
- 8. The measure must be readable. When measureSourceConnected is false, setup says how the number will be read: connecting that source (name it, e.g. "connect Clerk's user.created webhook so signups and their ref are recorded"), or, when it can't be connected, a light manual record the person updates weekly (kept with the Records ability). Always record a baseline: the number today. Tag what workflows produce (ref=<channel>) so each one's effect can be told apart.
34
- 8b. setup: what the person does once before the jobs start, at most four steps, each one short sentence (about 20 words at most) saying the action, not the reasoning. When the request lists setup already on the goal, add only what those steps don't cover, usually nothing: never repeat or reword one (the baseline, the signup link, the manual record are said once).
35
+ 8. The measure must be readable. For work to hand off, the workflows' own runs show it's done: no baseline, source or manual record is needed unless the brief's measure is a number beyond that. Otherwise, when measureSourceConnected is false, setup says how the number will be read: connecting that source (name it, e.g. "connect Clerk's user.created webhook so signups and their ref are recorded"), or, when it can't be connected, a light manual record the person updates weekly (kept with the Records ability). Always record a baseline: the number today. Tag what workflows produce (ref=<channel>) so each one's effect can be told apart.
36
+ 8b. setup: what the person does once before the workflows start, at most four steps, each one short sentence (about 20 words at most) saying the action, not the reasoning. When the request lists setup already on the goal, add only what those steps don't cover, usually nothing: never repeat or reword one (the baseline, the signup link, the manual record are said once).
35
37
  8b. Every qualifier in the brief is covered by at least one workflow that addresses it directly; list it in that workflow's covers.
36
38
  9. "partial" scope: at most three workflows, only ones that help the person pursue the goal, and say so in the message ("helps you pursue", never "achieves"). "out" scope: no workflows; the message says plainly why, and offers a smaller or related goal.
37
39
  10. agent: an existing agent's exact name when its work fits. When none fits, or there are no agents yet, suggest a new one: agent and newAgent.name the same short lowercase name with hyphens (e.g. "community-agent"), and newAgent.instructions two or three sentences on what it does and how it behaves. Group workflows that belong together in one agent rather than one agent each.
@@ -44,11 +46,15 @@ export const GOAL_CRITIQUE_PROMPT = `You check a goal plan against its rules bef
44
46
  - a need marked connected that the context doesn't list as connected;
45
47
  - a request that posts, sends or publishes without saying it waits for approval;
46
48
  - review time over three quarters of the weekly budget;
47
- - a measure whose source isn't connected, with no setup step (new or already on the goal) that connects it or a manual record, or no baseline;
49
+ - for a result to reach, a measure whose source isn't connected, with no setup step (new or already on the goal) that connects it or a manual record, or no baseline;
48
50
  - more than four setup steps, a step longer than a sentence, or one that repeats or rewords a step already on the goal;
49
51
  - a qualifier from the brief no workflow addresses;
50
- - a recurring job on a finite list that will run out (it should be kind "once");
51
- - a job title longer than six words, or one that names the mechanism ("Send welcome emails", "Lead scan") instead of the result it brings ("Get new signups started");
52
+ - for work to hand off, a setup step for a baseline or a manual record (its runs show it's done);
53
+ - a group step that only approves or reviews (approval is built into every workflow);
54
+ - workflows a small goal didn't need, added to fill out the plan (work to hand off may need just one workflow or one group);
55
+ - a suggestion for one-time work, or one on a finite list that will run out (it should be left out);
56
+ - a title longer than six words, or one that names the mechanism ("Send welcome emails", "Lead scan") instead of the result it brings ("Get new signups started");
57
+ - a group whose steps don't hand their result on, or with fewer than two or more than four steps;
52
58
  - a lever in newLevers that names this business, its products, people, places or sites, mixes several approaches, or has no way to see its effect;
53
59
  - a workflow made from no lever when the request listed none for this focus (it should come from one of newLevers);
54
60
  - a plan claiming to achieve a goal that is only partly in scope, or workflows for an out-of-scope goal.
@@ -92,7 +98,6 @@ const NEW_LEVER_SCHEMA = {
92
98
  properties: {
93
99
  key: { type: 'string', description: 'a short lowercase-hyphenated key; workflows made from it put this key in leverId' },
94
100
  name: { type: 'string', description: 'the approach in a few words' },
95
- kind: { type: 'string', enum: ['recurring', 'once'] },
96
101
  mechanism: { type: 'string', description: 'why it tends to move the measure, one sentence' },
97
102
  fitsWhen: { type: 'array', items: { type: 'string' } },
98
103
  notWhen: { type: 'array', items: { type: 'string' } },
@@ -117,9 +122,8 @@ const planTool = () => ({
117
122
  items: {
118
123
  type: 'object',
119
124
  properties: {
120
- title: { type: 'string', description: 'the result the job brings, at most six words ("Reach new leads every week", "Get new signups started"); details go in measure and request, and the mechanism ("Lead scan") is its workflow\'s name' },
121
- kind: { type: 'string', enum: ['recurring', 'once'] },
122
- measure: { type: 'string', description: "the job's own number, or for a once job what done looks like" },
125
+ title: { type: 'string', description: 'the result it brings, at most six words ("Reach new leads every week", "Get new signups started"); details go in measure and request, and the mechanism ("Lead scan") is a workflow\'s name' },
126
+ measure: { type: 'string', description: 'its own number, in the person\'s terms' },
123
127
  leverId: { type: 'string', description: "the playbook lever's id, or the key of one of your newLevers" },
124
128
  lever: { type: 'string', description: 'the lever in a few generic words, with no names of the business, its products, people, places or sites' },
125
129
  focus: { type: 'string' },
@@ -132,6 +136,28 @@ const planTool = () => ({
132
136
  startsAfter: { type: 'string' },
133
137
  measureLink: { type: 'string' },
134
138
  covers: { type: 'array', items: { type: 'string' }, description: "the brief's qualifiers it addresses" },
139
+ group: {
140
+ type: 'object',
141
+ description: 'only for work in stages that hand their result on: two to four workflows that run in order',
142
+ properties: {
143
+ order: { type: 'string', enum: ['sequence'] },
144
+ steps: {
145
+ type: 'array',
146
+ items: {
147
+ type: 'object',
148
+ properties: {
149
+ name: { type: 'string', description: 'a short label, two or three words ("Lead scan")' },
150
+ request: { type: 'string', description: 'the workflow request for this step, specific to this context' },
151
+ agent: { type: 'string' },
152
+ newAgent: { type: 'object', properties: { name: { type: 'string' }, instructions: { type: 'string' } }, required: ['name', 'instructions'] },
153
+ needs: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, kind: { type: 'string' }, connected: { type: 'boolean' } }, required: ['name', 'kind', 'connected'] } },
154
+ },
155
+ required: ['name', 'request', 'agent', 'needs'],
156
+ },
157
+ },
158
+ },
159
+ required: ['order', 'steps'],
160
+ },
135
161
  },
136
162
  required: ['title', 'lever', 'focus', 'mechanism', 'request', 'agent', 'needs', 'humanMinutesPerWeek', 'measureLink'],
137
163
  },
@@ -150,20 +176,20 @@ const planTool = () => ({
150
176
  },
151
177
  });
152
178
  /** A job a person added in their own words, shaped like a planned one. */
153
- export const GOAL_ADD_JOB_PROMPT = `A person adds a job of their own to a goal in LoopEngine, in their own words. Shape it into one job like a planner's, and judge it honestly; it's their business, so advise, don't lecture.
179
+ export const GOAL_ADD_JOB_PROMPT = `A person adds a workflow of their own to a goal in LoopEngine, in their own words. Shape it into one suggestion like a planner's (a workflow, or a group of workflows that run in order when the idea has stages that hand their result on), and judge it honestly; it's their business, so advise, don't lecture.
154
180
 
155
181
  Shape it:
156
- - title: the result the job brings, in plain words, at most six words ("Get weekly sales to the team", "Answer customer emails within an hour"). When the person wrote a long or mechanism-style idea ("send a weekly sales summary to the team every Monday"), keep their meaning and the detail that sets it apart (where or who) in a short title, and put the details in measure and request; the mechanism becomes the workflow's name later.
157
- - kind ("recurring" when it repeats, "once" for finite work), measure (its own number, or for a once job what done looks like), why it moves the goal (mechanism), the agent (an existing agent's exact name when its work fits, else newAgent with a short name and two or three sentences of instructions), needs (connected only when the context lists it), humanMinutesPerWeek, and a request specific to this business that the agent can act on. Anything that posts, sends or publishes says nothing goes out without the person's approval.
182
+ - title: the result it brings, in plain words, at most six words ("Get weekly sales to the team", "Answer customer emails within an hour"). When the person wrote a long or mechanism-style idea ("send a weekly sales summary to the team every Monday"), keep their meaning and the detail that sets it apart (where or who) in a short title, and put the details in measure and request; the mechanism becomes the workflow's name later.
183
+ - measure (its own number), why it moves the goal (mechanism), the agent (an existing agent's exact name when its work fits, else newAgent with a short name and two or three sentences of instructions), needs (connected only when the context lists it), humanMinutesPerWeek, and a request specific to this business that the agent can act on. Anything that posts, sends or publishes says nothing goes out without the person's approval.
158
184
  - lever: when it's one of the playbook levers listed, its id in leverId. When none fits, write one generic lever in newLever (one approach, no names of this business, its products, people, places or sites; when it fits and doesn't; what it needs; how its effect shows up; guardrails; a generic template) and put its key in leverId.
159
185
 
160
186
  Judge it, in verdict:
161
187
  - "added": it fits the goal and is safe.
162
188
  - "changed": a sound idea with risky details you changed (an approval added, volume limited, a platform's rules respected); say what you changed in note.
163
- - "warned": it's safe but unlikely to move the goal's measure, repeats a job already under the goal, or is unlikely to work; say why in note and give a better-aimed alternative.
189
+ - "warned": it's safe but unlikely to move the goal's measure, repeats a workflow already under the goal, is one-time work rather than something that repeats, or is unlikely to work; say why in note and give a better-aimed alternative.
164
190
  - "refused": it's deceptive, illegal or against a platform's rules (fake reviews or accounts, spam, buying followers, harvesting private data, impersonation, misleading claims) or could harm people. Don't shape it; say why in note, plainly and briefly, and give a legitimate alternative.
165
191
 
166
- When there is no goal (a job added on its own), judge it on its own: "added" when it suits this business and is safe; "warned" when it's unlikely to work or repeats a job already listed. Its mechanism is what the job gets done for the business, and it has no lever: leave leverId and newLever out.
192
+ When there is no goal, judge it on its own: "added" when it suits this business and is safe; "warned" when it's unlikely to work or repeats a workflow already listed. Its mechanism is what it gets done for the business, and it has no lever: leave leverId and newLever out.
167
193
 
168
194
  Call save_job once.`;
169
195
  const addJobTool = () => {
@@ -194,7 +220,7 @@ export async function shapeJob(modelCall, input) {
194
220
  const user = [
195
221
  contextText(input.context),
196
222
  input.brief ? briefText(input.brief) : '',
197
- input.brief ? (levers.length ? `Playbook levers for this focus:\n${levers.slice(0, MAX_LEVERS_IN_PROMPT * 2).map((l) => `- ${l.id}: ${l.name}. ${l.mechanism} Usually ${l.kind === 'once' ? 'a once job' : 'a recurring job'}; its measure: ${l.measureLink}.`).join('\n')}` : 'Playbook levers: none for this focus yet.') : '',
223
+ input.brief ? (levers.length ? `Playbook levers for this focus:\n${levers.slice(0, MAX_LEVERS_IN_PROMPT * 2).map((l) => `- ${l.id}: ${l.name}. ${l.mechanism} Its measure: ${l.measureLink}.`).join('\n')}` : 'Playbook levers: none for this focus yet.') : '',
198
224
  savedText(input.saved),
199
225
  input.goal ? `The goal:\n${input.goal}` : 'There is no goal: the person is adding this job on its own.',
200
226
  `The job the person wants to add, in their words:\n${input.idea}`,
@@ -276,7 +302,7 @@ function leversText(focus, saved = []) {
276
302
  return all.length
277
303
  ? 'Playbook levers: every one for this focus is already under this goal. Write new levers in newLevers (rule 1b: two to five, each a different approach from those already saved), and make each workflow from one of them.'
278
304
  : 'Playbook levers: none for this focus yet. Write the levers this goal needs in newLevers (rule 1b), and make each workflow from one of them.';
279
- return 'Playbook levers for this focus (id: name; why; fits when; not when; needs; minutes a week):\n' + levers.slice(0, MAX_LEVERS_IN_PROMPT).map((l) => `- ${l.id}: ${l.name}. ${l.mechanism} Fits when: ${l.fitsWhen.join('; ')}. Not when: ${l.notWhen.join('; ')}. Needs: ${[...(l.needs.anyOf?.length ? [`one of ${l.needs.anyOf.join('/')}`] : []), ...(l.needs.plus ?? [])].join(' + ')}. About ${l.humanMinutesPerWeek} min/week. Usually ${l.kind === 'once' ? 'a once job' : 'a recurring job'}; its measure: ${l.measureLink}. Template: ${l.template}`).join('\n');
305
+ return 'Playbook levers for this focus (id: name; why; fits when; not when; needs; minutes a week):\n' + levers.slice(0, MAX_LEVERS_IN_PROMPT).map((l) => `- ${l.id}: ${l.name}. ${l.mechanism} Fits when: ${l.fitsWhen.join('; ')}. Not when: ${l.notWhen.join('; ')}. Needs: ${[...(l.needs.anyOf?.length ? [`one of ${l.needs.anyOf.join('/')}`] : []), ...(l.needs.plus ?? [])].join(' + ')}. About ${l.humanMinutesPerWeek} min/week. Its measure: ${l.measureLink}. Template: ${l.template}`).join('\n');
280
306
  }
281
307
  function setupText(setup) {
282
308
  if (!setup?.length)
@@ -319,6 +345,32 @@ function newFocusFrom(raw) {
319
345
  return undefined;
320
346
  return { id, label, hint };
321
347
  }
348
+ /** A planned group of workflows, tidied: two to four steps, each with a
349
+ * name, a request and an agent (a new one's name made safe); undefined
350
+ * otherwise, and the suggestion is one workflow. */
351
+ function groupFrom(raw) {
352
+ const g = raw && typeof raw === 'object' ? raw : undefined;
353
+ if (!g || !Array.isArray(g.steps))
354
+ return undefined;
355
+ const steps = g.steps.flatMap((item) => {
356
+ const x = item && typeof item === 'object' ? item : {};
357
+ const name = str(x.name).slice(0, 60);
358
+ const request = str(x.request).slice(0, 2000);
359
+ const na = x.newAgent && typeof x.newAgent === 'object' ? x.newAgent : undefined;
360
+ const newAgentName = na ? agentName(str(na.name) || str(x.agent)) : '';
361
+ const agent = newAgentName || agentName(str(x.agent));
362
+ if (!name || !request || !agent)
363
+ return [];
364
+ const needs = (Array.isArray(x.needs) ? x.needs : []).flatMap((n) => {
365
+ if (!n || typeof n !== 'object')
366
+ return [];
367
+ const y = n;
368
+ return str(y.name) || str(y.kind) ? [{ name: str(y.name, str(y.kind)), kind: str(y.kind, str(y.name)).toLowerCase(), connected: y.connected === true }] : [];
369
+ });
370
+ return [{ name, request, agent, ...(newAgentName ? { newAgent: { name: newAgentName, instructions: str(na.instructions) } } : {}), needs }];
371
+ }).slice(0, 4);
372
+ return steps.length >= 2 ? { order: 'sequence', steps } : undefined;
373
+ }
322
374
  /** The levers a plan wrote, as a workspace's own levers under the focus
323
375
  * (ids "<focus>.x-<key>"), keyed by the key its workflows use. One with
324
376
  * unsafe text or a missing part is dropped. */
@@ -333,7 +385,6 @@ function newLeversFrom(raw, focus) {
333
385
  id: `${focus}.x-${key}`,
334
386
  focus,
335
387
  name: str(x.name).slice(0, 80),
336
- kind: x.kind === 'once' ? 'once' : 'recurring',
337
388
  mechanism: str(x.mechanism).slice(0, 400),
338
389
  fitsWhen: strings(x.fitsWhen).slice(0, 5),
339
390
  notWhen: strings(x.notWhen).slice(0, 5),
@@ -417,9 +468,9 @@ function parsePlan(raw, focus) {
417
468
  const y = n;
418
469
  return str(y.name) || str(y.kind) ? [{ name: str(y.name, str(y.kind)), kind: str(y.kind, str(y.name)).toLowerCase(), connected: y.connected === true }] : [];
419
470
  });
471
+ const group = groupFrom(x.group);
420
472
  return [{
421
473
  title,
422
- kind: x.kind === 'once' ? 'once' : 'recurring',
423
474
  measure: str(x.measure),
424
475
  ...(leverId ? { leverId } : {}),
425
476
  // An empty label falls back to the playbook lever's name, else the title.
@@ -435,6 +486,7 @@ function parsePlan(raw, focus) {
435
486
  measureLink: str(x.measureLink),
436
487
  covers: strings(x.covers),
437
488
  newIdea: !leverId,
489
+ ...(group ? { group } : {}),
438
490
  }];
439
491
  });
440
492
  // The plan's own levers that a workflow is made from: the ones to keep.
@@ -17,9 +17,6 @@ export interface Lever {
17
17
  id: string;
18
18
  focus: GoalFocus;
19
19
  name: string;
20
- /** The job it usually makes: recurring (a workflow that runs again and
21
- * again) or once (a finite piece of work, done once). */
22
- kind: 'recurring' | 'once';
23
20
  /** Why it works, in a sentence: shown as the plan's "Why". */
24
21
  mechanism: string;
25
22
  fitsWhen: string[];
@@ -81,10 +81,8 @@ export function parsePlaybook(raw, knownFocuses = GOAL_FOCUSES) {
81
81
  throw new Error(`${where}: needs.${k} must be a list of kinds`); return v; };
82
82
  const anyOf = kinds(needs.anyOf, 'anyOf');
83
83
  const plus = kinds(needs.plus, 'plus');
84
- if (l.kind !== undefined && l.kind !== 'recurring' && l.kind !== 'once')
85
- throw new Error(`${where}: kind must be "recurring" or "once"`);
86
84
  return {
87
- id, focus, name: text('name'), kind: (l.kind ?? 'recurring'), mechanism: text('mechanism'), fitsWhen: list('fitsWhen'), notWhen: list('notWhen'),
85
+ id, focus, name: text('name'), mechanism: text('mechanism'), fitsWhen: list('fitsWhen'), notWhen: list('notWhen'),
88
86
  needs: { ...(anyOf ? { anyOf } : {}), ...(plus ? { plus } : {}) },
89
87
  humanMinutesPerWeek: num('humanMinutesPerWeek'), firstResultDays: num('firstResultDays'), measureLink: text('measureLink'),
90
88
  guardrails: list('guardrails'), template: text('template'),
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 3,
2
+ "version": 4,
3
3
  "focuses": [
4
4
  {
5
5
  "id": "new-signups",
@@ -38,7 +38,6 @@
38
38
  "id": "new-signups.answer-intent-posts",
39
39
  "focus": "new-signups",
40
40
  "name": "Answer people asking for what you do",
41
- "kind": "recurring",
42
41
  "mechanism": "People with the problem ask about it in public; a genuinely helpful answer at that moment earns attention and clicks.",
43
42
  "fitsWhen": [
44
43
  "the problem is discussed in public communities",
@@ -72,7 +71,6 @@
72
71
  "id": "new-signups.directory-listings",
73
72
  "focus": "new-signups",
74
73
  "name": "Get listed where people look for tools",
75
- "kind": "once",
76
74
  "mechanism": "Directories, curated lists and comparison articles send visitors for months to every product they include.",
77
75
  "fitsWhen": [
78
76
  "the product is software people choose from lists",
@@ -99,7 +97,6 @@
99
97
  "id": "new-signups.use-case-pages",
100
98
  "focus": "new-signups",
101
99
  "name": "A page for each job people search for",
102
- "kind": "recurring",
103
100
  "mechanism": "People search for the job, not the product; a page answering that job brings visitors from search for a long time.",
104
101
  "fitsWhen": [
105
102
  "the product does several distinct jobs people search for",
@@ -126,7 +123,6 @@
126
123
  "id": "new-signups.creator-outreach",
127
124
  "focus": "new-signups",
128
125
  "name": "Pitch creators who cover this space",
129
- "kind": "recurring",
130
126
  "mechanism": "One newsletter, video or blog mention reaches thousands of the right people at once.",
131
127
  "fitsWhen": [
132
128
  "creators cover the category or its competitors",
@@ -156,7 +152,6 @@
156
152
  "id": "new-signups.competitor-switchers",
157
153
  "focus": "new-signups",
158
154
  "name": "Help people unhappy with a competitor",
159
- "kind": "recurring",
160
155
  "mechanism": "People complaining about the tool they use are the easiest to win, if the answer is helpful rather than a pitch.",
161
156
  "fitsWhen": [
162
157
  "there are well-known competitors people complain about publicly"
@@ -187,7 +182,6 @@
187
182
  "id": "new-signups.marketplace-listings",
188
183
  "focus": "new-signups",
189
184
  "name": "List in the marketplaces your users already use",
190
- "kind": "once",
191
185
  "mechanism": "App stores and integration marketplaces put the product in front of people already looking inside the tools they use.",
192
186
  "fitsWhen": [
193
187
  "the product integrates with platforms that have marketplaces (Shopify, Slack, Zapier…)"
@@ -206,13 +200,12 @@
206
200
  "guardrails": [
207
201
  "Nothing is posted, sent or published without the person’s approval."
208
202
  ],
209
- "template": "Find the marketplaces for {platforms} where {product} could be listed, check what each needs, and draft each listing for me to submit. Check monthly for new ones."
203
+ "template": "On the first Monday of each month, find marketplaces for {platforms} where {product} isn’t listed yet (new ones included), check what each needs, and draft each listing for me to submit in {channel}."
210
204
  },
211
205
  {
212
206
  "id": "new-signups.local-reviews",
213
207
  "focus": "new-signups",
214
208
  "name": "Ask happy customers for reviews",
215
- "kind": "recurring",
216
209
  "mechanism": "New customers choose by reviews; asking satisfied customers at the right moment multiplies them.",
217
210
  "fitsWhen": [
218
211
  "a business whose customers pick by reviews (local services, shops, apps)"
@@ -242,7 +235,6 @@
242
235
  "id": "activation.personal-welcome",
243
236
  "focus": "activation",
244
237
  "name": "A personal welcome",
245
- "kind": "recurring",
246
238
  "mechanism": "A personal note in the first hour gets replies and tells new users someone will help them succeed.",
247
239
  "fitsWhen": [
248
240
  "signups can be detected (webhook or list)",
@@ -271,7 +263,6 @@
271
263
  "id": "activation.first-step-nudge",
272
264
  "focus": "activation",
273
265
  "name": "Nudge people who haven’t taken the first step",
274
- "kind": "recurring",
275
266
  "mechanism": "Most signups stall before the first success; a timely, specific nudge brings many back.",
276
267
  "fitsWhen": [
277
268
  "the first key step can be checked for each user"
@@ -300,7 +291,6 @@
300
291
  "id": "activation.stuck-user-help",
301
292
  "focus": "activation",
302
293
  "name": "Spot users who are stuck",
303
- "kind": "recurring",
304
294
  "mechanism": "Errors and repeated failed attempts mark people about to give up; reaching out first saves them.",
305
295
  "fitsWhen": [
306
296
  "errors or failed attempts are visible per user"
@@ -328,7 +318,6 @@
328
318
  "id": "retention.value-recap",
329
319
  "focus": "retention",
330
320
  "name": "Show users what they got",
331
- "kind": "recurring",
332
321
  "mechanism": "People keep what they can see working; a short recap of results makes value visible.",
333
322
  "fitsWhen": [
334
323
  "the product produces results that can be counted per user"
@@ -357,7 +346,6 @@
357
346
  "id": "retention.quiet-account-check",
358
347
  "focus": "retention",
359
348
  "name": "Check in with accounts going quiet",
360
- "kind": "recurring",
361
349
  "mechanism": "Usage drops before people leave; a check-in at the drop finds the reason while there is still time.",
362
350
  "fitsWhen": [
363
351
  "usage per account can be tracked"
@@ -385,7 +373,6 @@
385
373
  "id": "retention.feedback-after-success",
386
374
  "focus": "retention",
387
375
  "name": "Ask for feedback right after a success",
388
- "kind": "recurring",
389
376
  "mechanism": "Asking at a moment of success gets honest feedback and strengthens the habit.",
390
377
  "fitsWhen": [
391
378
  "successes are visible per user"
@@ -414,7 +401,6 @@
414
401
  "id": "faster-support.reply-drafts",
415
402
  "focus": "faster-support",
416
403
  "name": "Draft replies from the customer’s data",
417
- "kind": "recurring",
418
404
  "mechanism": "Most replies need the same lookups; a draft that already has the order or account facts cuts each reply to a quick check.",
419
405
  "fitsWhen": [
420
406
  "support questions are about orders, accounts or bookings the agent can look up"
@@ -444,7 +430,6 @@
444
430
  "id": "faster-support.triage-routing",
445
431
  "focus": "faster-support",
446
432
  "name": "Sort and route what comes in",
447
- "kind": "recurring",
448
433
  "mechanism": "Tickets wait longest while nobody knows whose they are; sorting on arrival gets each to the right person or answer.",
449
434
  "fitsWhen": [
450
435
  "several kinds of request or several people handle them"
@@ -471,7 +456,6 @@
471
456
  "id": "faster-support.backlog-sweep",
472
457
  "focus": "faster-support",
473
458
  "name": "Sweep the backlog daily",
474
- "kind": "recurring",
475
459
  "mechanism": "Old unanswered requests hurt most; a daily list of what’s waiting longest stops anything from being forgotten.",
476
460
  "fitsWhen": [
477
461
  "requests sometimes wait more than a day"
@@ -498,7 +482,6 @@
498
482
  "id": "faster-support.faq-gaps",
499
483
  "focus": "faster-support",
500
484
  "name": "Find the questions your help pages don’t answer",
501
- "kind": "recurring",
502
485
  "mechanism": "The same questions keep coming because the answer isn’t written down; finding them prevents tickets.",
503
486
  "fitsWhen": [
504
487
  "there are help pages or an FAQ",
@@ -525,7 +508,6 @@
525
508
  "id": "revenue-recovery.failed-payments",
526
509
  "focus": "revenue-recovery",
527
510
  "name": "Follow up failed payments",
528
- "kind": "recurring",
529
511
  "mechanism": "Many failed payments are expired cards; a friendly, quick note recovers a large share.",
530
512
  "fitsWhen": [
531
513
  "subscriptions or invoices are paid by card"
@@ -555,7 +537,6 @@
555
537
  "id": "revenue-recovery.abandoned-checkouts",
556
538
  "focus": "revenue-recovery",
557
539
  "name": "Follow up abandoned checkouts",
558
- "kind": "recurring",
559
540
  "mechanism": "Shoppers who leave at checkout often meant to buy; a timely reminder brings some back.",
560
541
  "fitsWhen": [
561
542
  "an online store with checkout data"
@@ -585,7 +566,6 @@
585
566
  "id": "revenue-recovery.win-back",
586
567
  "focus": "revenue-recovery",
587
568
  "name": "Win back people who left",
588
- "kind": "recurring",
589
569
  "mechanism": "Some people who cancelled left for a reason that has since changed; asking why and what’s new brings some back.",
590
570
  "fitsWhen": [
591
571
  "cancellations are recorded with a date"
@@ -615,7 +595,6 @@
615
595
  "id": "ops-hygiene.exception-report",
616
596
  "focus": "ops-hygiene",
617
597
  "name": "A daily report of what went wrong",
618
- "kind": "recurring",
619
598
  "mechanism": "Problems hidden in systems grow; a short daily list of exceptions catches them while they are small.",
620
599
  "fitsWhen": [
621
600
  "orders, jobs or payments can fail or stall"
@@ -645,7 +624,6 @@
645
624
  "id": "ops-hygiene.stuck-items",
646
625
  "focus": "ops-hygiene",
647
626
  "name": "Find what’s stuck",
648
- "kind": "recurring",
649
627
  "mechanism": "Orders or tasks stuck in one state for days usually mean something broke; finding them early saves customers.",
650
628
  "fitsWhen": [
651
629
  "items move through states (orders, shipments, tickets)"
@@ -674,7 +652,6 @@
674
652
  "id": "ops-hygiene.deadline-reminders",
675
653
  "focus": "ops-hygiene",
676
654
  "name": "Remind before deadlines",
677
- "kind": "recurring",
678
655
  "mechanism": "Missed renewals, filings and follow-ups cost money; a reminder with what’s needed arrives in time.",
679
656
  "fitsWhen": [
680
657
  "recurring deadlines (renewals, invoices, filings)"