@plotday/twister 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/bin/commands/build.js +108 -0
- package/bin/commands/build.js.map +1 -0
- package/bin/commands/create.js +230 -0
- package/bin/commands/create.js.map +1 -0
- package/bin/commands/deploy.js +292 -0
- package/bin/commands/deploy.js.map +1 -0
- package/bin/commands/generate.js +301 -0
- package/bin/commands/generate.js.map +1 -0
- package/bin/commands/lint.js +69 -0
- package/bin/commands/lint.js.map +1 -0
- package/bin/commands/login.js +140 -0
- package/bin/commands/login.js.map +1 -0
- package/bin/commands/priority-create.js +102 -0
- package/bin/commands/priority-create.js.map +1 -0
- package/bin/commands/priority-list.js +47 -0
- package/bin/commands/priority-list.js.map +1 -0
- package/bin/commands/twist-logs.js +187 -0
- package/bin/commands/twist-logs.js.map +1 -0
- package/bin/index.js +129 -0
- package/bin/index.js.map +1 -0
- package/bin/package.json +3 -0
- package/bin/plot.cjs +3 -0
- package/bin/templates/AGENTS.template.md +403 -0
- package/bin/templates/CLAUDE.template.md +1 -0
- package/bin/templates/README.template.md +189 -0
- package/bin/utils/bundle.js +106 -0
- package/bin/utils/bundle.js.map +1 -0
- package/bin/utils/output.js +133 -0
- package/bin/utils/output.js.map +1 -0
- package/bin/utils/packageManager.js +65 -0
- package/bin/utils/packageManager.js.map +1 -0
- package/bin/utils/sse.js +100 -0
- package/bin/utils/sse.js.map +1 -0
- package/bin/utils/token.js +75 -0
- package/bin/utils/token.js.map +1 -0
- package/cli/templates/AGENTS.template.md +403 -0
- package/cli/templates/CLAUDE.template.md +1 -0
- package/cli/templates/README.template.md +189 -0
- package/dist/common/calendar.d.ts +144 -0
- package/dist/common/calendar.d.ts.map +1 -0
- package/dist/common/calendar.js +2 -0
- package/dist/common/calendar.js.map +1 -0
- package/dist/common/messaging.d.ts +84 -0
- package/dist/common/messaging.d.ts.map +1 -0
- package/dist/common/messaging.js +2 -0
- package/dist/common/messaging.js.map +1 -0
- package/dist/creator-docs.d.ts +11 -0
- package/dist/creator-docs.d.ts.map +1 -0
- package/dist/creator-docs.js +27 -0
- package/dist/creator-docs.js.map +1 -0
- package/dist/docs/.nojekyll +1 -0
- package/dist/docs/assets/favicon.svg +8 -0
- package/dist/docs/assets/hierarchy.js +1 -0
- package/dist/docs/assets/highlight.css +134 -0
- package/dist/docs/assets/icons.js +18 -0
- package/dist/docs/assets/icons.svg +1 -0
- package/dist/docs/assets/main.js +60 -0
- package/dist/docs/assets/navigation.js +1 -0
- package/dist/docs/assets/search.js +1 -0
- package/dist/docs/assets/style.css +1633 -0
- package/dist/docs/classes/tool.ITool.html +4 -0
- package/dist/docs/classes/tool.Tool.html +116 -0
- package/dist/docs/classes/tools_ai.AI.html +27 -0
- package/dist/docs/classes/tools_callbacks.Callbacks.html +45 -0
- package/dist/docs/classes/tools_integrations.Integrations.html +26 -0
- package/dist/docs/classes/tools_network.Network.html +68 -0
- package/dist/docs/classes/tools_plot.Plot.html +82 -0
- package/dist/docs/classes/tools_store.Store.html +53 -0
- package/dist/docs/classes/tools_tasks.Tasks.html +39 -0
- package/dist/docs/classes/tools_twists.Twists.html +59 -0
- package/dist/docs/classes/twist.Twist.html +96 -0
- package/dist/docs/documents/Advanced.html +91 -0
- package/dist/docs/documents/Building_Custom_Tools.html +200 -0
- package/dist/docs/documents/Built-in_Tools.html +170 -0
- package/dist/docs/documents/CLI_Reference.html +193 -0
- package/dist/docs/documents/Core_Concepts.html +163 -0
- package/dist/docs/documents/Getting_Started.html +94 -0
- package/dist/docs/documents/Runtime_Environment.html +128 -0
- package/dist/docs/enums/plot.ActivityLinkType.html +12 -0
- package/dist/docs/enums/plot.ActivityType.html +10 -0
- package/dist/docs/enums/plot.ActorType.html +10 -0
- package/dist/docs/enums/plot.ConferencingProvider.html +14 -0
- package/dist/docs/enums/tag.Tag.html +45 -0
- package/dist/docs/enums/tools_ai.AIModel.html +31 -0
- package/dist/docs/enums/tools_integrations.AuthLevel.html +7 -0
- package/dist/docs/enums/tools_integrations.AuthProvider.html +24 -0
- package/dist/docs/enums/tools_plot.ActivityAccess.html +8 -0
- package/dist/docs/enums/tools_plot.ContactAccess.html +5 -0
- package/dist/docs/enums/tools_plot.PriorityAccess.html +8 -0
- package/dist/docs/hierarchy.html +1 -0
- package/dist/docs/index.html +100 -0
- package/dist/docs/interfaces/common_calendar.Calendar.html +13 -0
- package/dist/docs/interfaces/common_calendar.CalendarTool.html +49 -0
- package/dist/docs/interfaces/common_calendar.SyncOptions.html +8 -0
- package/dist/docs/interfaces/tools_ai.AIRequest.html +46 -0
- package/dist/docs/interfaces/tools_ai.AIResponse.html +19 -0
- package/dist/docs/interfaces/tools_ai.FilePart.html +14 -0
- package/dist/docs/interfaces/tools_ai.ImagePart.html +11 -0
- package/dist/docs/interfaces/tools_ai.ReasoningPart.html +7 -0
- package/dist/docs/interfaces/tools_ai.RedactedReasoningPart.html +5 -0
- package/dist/docs/interfaces/tools_ai.TextPart.html +5 -0
- package/dist/docs/interfaces/tools_ai.ToolCallPart.html +9 -0
- package/dist/docs/interfaces/tools_ai.ToolExecutionOptions.html +9 -0
- package/dist/docs/interfaces/tools_ai.ToolResultPart.html +9 -0
- package/dist/docs/interfaces/tools_twists.TwistSource.html +13 -0
- package/dist/docs/interfaces/utils_types.ToolShed.html +11 -0
- package/dist/docs/modules/common_calendar.html +1 -0
- package/dist/docs/modules/index.html +1 -0
- package/dist/docs/modules/plot.html +1 -0
- package/dist/docs/modules/tag.html +1 -0
- package/dist/docs/modules/tool.html +1 -0
- package/dist/docs/modules/tools_ai.html +1 -0
- package/dist/docs/modules/tools_callbacks.html +1 -0
- package/dist/docs/modules/tools_integrations.html +1 -0
- package/dist/docs/modules/tools_network.html +1 -0
- package/dist/docs/modules/tools_plot.html +1 -0
- package/dist/docs/modules/tools_store.html +1 -0
- package/dist/docs/modules/tools_tasks.html +1 -0
- package/dist/docs/modules/tools_twists.html +1 -0
- package/dist/docs/modules/twist.html +1 -0
- package/dist/docs/modules/utils_types.html +1 -0
- package/dist/docs/modules.html +1 -0
- package/dist/docs/types/common_calendar.CalendarAuth.html +7 -0
- package/dist/docs/types/plot.Activity.html +64 -0
- package/dist/docs/types/plot.ActivityLink.html +22 -0
- package/dist/docs/types/plot.ActivityMeta.html +11 -0
- package/dist/docs/types/plot.ActivityUpdate.html +13 -0
- package/dist/docs/types/plot.Actor.html +15 -0
- package/dist/docs/types/plot.ActorId.html +4 -0
- package/dist/docs/types/plot.NewActivity.html +16 -0
- package/dist/docs/types/plot.NewContact.html +13 -0
- package/dist/docs/types/plot.NewPriority.html +5 -0
- package/dist/docs/types/plot.NoteType.html +1 -0
- package/dist/docs/types/plot.PickPriorityConfig.html +22 -0
- package/dist/docs/types/plot.Priority.html +8 -0
- package/dist/docs/types/tools_ai.AIAssistantMessage.html +4 -0
- package/dist/docs/types/tools_ai.AIMessage.html +3 -0
- package/dist/docs/types/tools_ai.AISource.html +11 -0
- package/dist/docs/types/tools_ai.AISystemMessage.html +7 -0
- package/dist/docs/types/tools_ai.AITool.html +19 -0
- package/dist/docs/types/tools_ai.AIToolMessage.html +4 -0
- package/dist/docs/types/tools_ai.AIToolSet.html +1 -0
- package/dist/docs/types/tools_ai.AIUsage.html +10 -0
- package/dist/docs/types/tools_ai.AIUserMessage.html +4 -0
- package/dist/docs/types/tools_ai.DataContent.html +2 -0
- package/dist/docs/types/tools_ai.ModelPreferences.html +24 -0
- package/dist/docs/types/tools_callbacks.Callback.html +8 -0
- package/dist/docs/types/tools_integrations.AuthToken.html +16 -0
- package/dist/docs/types/tools_integrations.Authorization.html +10 -0
- package/dist/docs/types/tools_network.WebhookRequest.html +15 -0
- package/dist/docs/types/tools_plot.ActivityIntentHandler.html +9 -0
- package/dist/docs/types/tools_twists.Log.html +6 -0
- package/dist/docs/types/tools_twists.TwistPermissions.html +12 -0
- package/dist/docs/types/utils_types.BuiltInTools.html +5 -0
- package/dist/docs/types/utils_types.CallbackMethods.html +3 -0
- package/dist/docs/types/utils_types.ExtractBuildReturn.html +2 -0
- package/dist/docs/types/utils_types.InferOptions.html +2 -0
- package/dist/docs/types/utils_types.InferTools.html +3 -0
- package/dist/docs/types/utils_types.NoFunctions.html +3 -0
- package/dist/docs/types/utils_types.NonFunction.html +2 -0
- package/dist/docs/types/utils_types.PromiseValues.html +3 -0
- package/dist/docs/types/utils_types.ToolBuilder.html +3 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-docs/common/calendar.d.ts +9 -0
- package/dist/llm-docs/common/calendar.d.ts.map +1 -0
- package/dist/llm-docs/common/calendar.js +8 -0
- package/dist/llm-docs/common/calendar.js.map +1 -0
- package/dist/llm-docs/common/messaging.d.ts +9 -0
- package/dist/llm-docs/common/messaging.d.ts.map +1 -0
- package/dist/llm-docs/common/messaging.js +8 -0
- package/dist/llm-docs/common/messaging.js.map +1 -0
- package/dist/llm-docs/creator-docs.d.ts +9 -0
- package/dist/llm-docs/creator-docs.d.ts.map +1 -0
- package/dist/llm-docs/creator-docs.js +8 -0
- package/dist/llm-docs/creator-docs.js.map +1 -0
- package/dist/llm-docs/index.d.ts +11 -0
- package/dist/llm-docs/index.d.ts.map +1 -0
- package/dist/llm-docs/index.js +42 -0
- package/dist/llm-docs/index.js.map +1 -0
- package/dist/llm-docs/plot.d.ts +9 -0
- package/dist/llm-docs/plot.d.ts.map +1 -0
- package/dist/llm-docs/plot.js +8 -0
- package/dist/llm-docs/plot.js.map +1 -0
- package/dist/llm-docs/tag.d.ts +9 -0
- package/dist/llm-docs/tag.d.ts.map +1 -0
- package/dist/llm-docs/tag.js +8 -0
- package/dist/llm-docs/tag.js.map +1 -0
- package/dist/llm-docs/tool.d.ts +9 -0
- package/dist/llm-docs/tool.d.ts.map +1 -0
- package/dist/llm-docs/tool.js +8 -0
- package/dist/llm-docs/tool.js.map +1 -0
- package/dist/llm-docs/tools/ai.d.ts +9 -0
- package/dist/llm-docs/tools/ai.d.ts.map +1 -0
- package/dist/llm-docs/tools/ai.js +8 -0
- package/dist/llm-docs/tools/ai.js.map +1 -0
- package/dist/llm-docs/tools/callbacks.d.ts +9 -0
- package/dist/llm-docs/tools/callbacks.d.ts.map +1 -0
- package/dist/llm-docs/tools/callbacks.js +8 -0
- package/dist/llm-docs/tools/callbacks.js.map +1 -0
- package/dist/llm-docs/tools/integrations.d.ts +9 -0
- package/dist/llm-docs/tools/integrations.d.ts.map +1 -0
- package/dist/llm-docs/tools/integrations.js +8 -0
- package/dist/llm-docs/tools/integrations.js.map +1 -0
- package/dist/llm-docs/tools/network.d.ts +9 -0
- package/dist/llm-docs/tools/network.d.ts.map +1 -0
- package/dist/llm-docs/tools/network.js +8 -0
- package/dist/llm-docs/tools/network.js.map +1 -0
- package/dist/llm-docs/tools/plot.d.ts +9 -0
- package/dist/llm-docs/tools/plot.d.ts.map +1 -0
- package/dist/llm-docs/tools/plot.js +8 -0
- package/dist/llm-docs/tools/plot.js.map +1 -0
- package/dist/llm-docs/tools/store.d.ts +9 -0
- package/dist/llm-docs/tools/store.d.ts.map +1 -0
- package/dist/llm-docs/tools/store.js +8 -0
- package/dist/llm-docs/tools/store.js.map +1 -0
- package/dist/llm-docs/tools/tasks.d.ts +9 -0
- package/dist/llm-docs/tools/tasks.d.ts.map +1 -0
- package/dist/llm-docs/tools/tasks.js +8 -0
- package/dist/llm-docs/tools/tasks.js.map +1 -0
- package/dist/llm-docs/tools/twists.d.ts +9 -0
- package/dist/llm-docs/tools/twists.d.ts.map +1 -0
- package/dist/llm-docs/tools/twists.js +8 -0
- package/dist/llm-docs/tools/twists.js.map +1 -0
- package/dist/llm-docs/twist-guide-template.d.ts +9 -0
- package/dist/llm-docs/twist-guide-template.d.ts.map +1 -0
- package/dist/llm-docs/twist-guide-template.js +8 -0
- package/dist/llm-docs/twist-guide-template.js.map +1 -0
- package/dist/llm-docs/twist.d.ts +9 -0
- package/dist/llm-docs/twist.d.ts.map +1 -0
- package/dist/llm-docs/twist.js +8 -0
- package/dist/llm-docs/twist.js.map +1 -0
- package/dist/plot.d.ts +463 -0
- package/dist/plot.d.ts.map +1 -0
- package/dist/plot.js +68 -0
- package/dist/plot.js.map +1 -0
- package/dist/tag.d.ts +47 -0
- package/dist/tag.d.ts.map +1 -0
- package/dist/tag.js +51 -0
- package/dist/tag.js.map +1 -0
- package/dist/tool.d.ts +242 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +283 -0
- package/dist/tool.js.map +1 -0
- package/dist/tools/ai.d.ts +697 -0
- package/dist/tools/ai.d.ts.map +1 -0
- package/dist/tools/ai.js +104 -0
- package/dist/tools/ai.js.map +1 -0
- package/dist/tools/callbacks.d.ts +96 -0
- package/dist/tools/callbacks.d.ts.map +1 -0
- package/dist/tools/callbacks.js +40 -0
- package/dist/tools/callbacks.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/integrations.d.ts +142 -0
- package/dist/tools/integrations.d.ts.map +1 -0
- package/dist/tools/integrations.js +79 -0
- package/dist/tools/integrations.js.map +1 -0
- package/dist/tools/network.d.ts +188 -0
- package/dist/tools/network.d.ts.map +1 -0
- package/dist/tools/network.js +87 -0
- package/dist/tools/network.js.map +1 -0
- package/dist/tools/plot.d.ts +252 -0
- package/dist/tools/plot.d.ts.map +1 -0
- package/dist/tools/plot.js +72 -0
- package/dist/tools/plot.js.map +1 -0
- package/dist/tools/store.d.ts +90 -0
- package/dist/tools/store.d.ts.map +1 -0
- package/dist/tools/store.js +48 -0
- package/dist/tools/store.js.map +1 -0
- package/dist/tools/tasks.d.ts +93 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +58 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/twists.d.ts +213 -0
- package/dist/tools/twists.d.ts.map +1 -0
- package/dist/tools/twists.js +26 -0
- package/dist/tools/twists.js.map +1 -0
- package/dist/twist-guide.d.ts +2 -0
- package/dist/twist-guide.d.ts.map +1 -0
- package/dist/twist-guide.js +9 -0
- package/dist/twist-guide.js.map +1 -0
- package/dist/twist.d.ts +204 -0
- package/dist/twist.d.ts.map +1 -0
- package/dist/twist.js +216 -0
- package/dist/twist.js.map +1 -0
- package/dist/utils/types.d.ts +91 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +206 -0
- package/tsconfig.base.json +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Plot Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://plot.day" target="_blank" rel="noopener noreferrer">
|
|
3
|
+
<img width="48" height="48" alt="favicon" src="https://github.com/user-attachments/assets/f38501fd-bb37-4671-a0bc-fd35fa25360d" alt="Plot logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
<h1 align="center">
|
|
7
|
+
Plot Twist Creator
|
|
8
|
+
</h1>
|
|
9
|
+
<p align="center">
|
|
10
|
+
The official Creator for building <a href="https://plot.day">Plot</a> Twists -<br/>
|
|
11
|
+
smart automations that connect, organize, and prioritize your work.
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://twist.plot.day"><strong>📚 Full Documentation →</strong></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
Choose your path:
|
|
21
|
+
|
|
22
|
+
- **[No Code](#no-code-quick-start)** - Write natural language, deploy in minutes
|
|
23
|
+
- **[TypeScript](#developer-quick-start)** - Full control with code
|
|
24
|
+
|
|
25
|
+
### No-Code Quick Start
|
|
26
|
+
|
|
27
|
+
Create twists using natural language - no programming required!
|
|
28
|
+
|
|
29
|
+
**1. Create `plot-twist.md`:**
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
# My Calendar Twist
|
|
33
|
+
|
|
34
|
+
I want a twist that:
|
|
35
|
+
|
|
36
|
+
- Syncs my Google Calendar events into Plot
|
|
37
|
+
- Creates tasks for upcoming meetings
|
|
38
|
+
- Sends reminders 10 minutes before meetings
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**2. Deploy:**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx @plotday/twister login
|
|
45
|
+
npx @plotday/twister deploy
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
That's it! [Learn more →](https://twist.plot.day/documents/Getting_Started.html#no-code-twists)
|
|
49
|
+
|
|
50
|
+
### Developer Quick Start
|
|
51
|
+
|
|
52
|
+
Build twists with TypeScript for maximum flexibility.
|
|
53
|
+
|
|
54
|
+
**1. Create a new twist:**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx @plotday/twister create
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**2. Implement your twist:**
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import {
|
|
64
|
+
ActivityType,
|
|
65
|
+
Twist,
|
|
66
|
+
type Priority,
|
|
67
|
+
type ToolBuilder,
|
|
68
|
+
} from "@plotday/twister";
|
|
69
|
+
import { Plot } from "@plotday/twister/tools/plot";
|
|
70
|
+
|
|
71
|
+
export default class MyTwist extends Twist<MyTwist> {
|
|
72
|
+
build(build: ToolBuilder) {
|
|
73
|
+
return {
|
|
74
|
+
plot: build(Plot),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async activate(priority: Pick<Priority, "id">) {
|
|
79
|
+
await this.tools.plot.createActivity({
|
|
80
|
+
type: ActivityType.Note,
|
|
81
|
+
title: "Welcome! Your twist is now active.",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**3. Deploy:**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm run plot login
|
|
91
|
+
npm run deploy
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
[Complete guide →](https://twist.plot.day/documents/Getting_Started.html)
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Core Concepts
|
|
99
|
+
|
|
100
|
+
### Twists
|
|
101
|
+
|
|
102
|
+
Twists are smart automations that connect, organize, and prioritize your work. They implement opinionated workflows and respond to lifecycle events.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// Lifecycle methods
|
|
106
|
+
async activate(priority) // When twist is added to a priority
|
|
107
|
+
async deactivate() // When twist is removed
|
|
108
|
+
async upgrade() // When new version is deployed
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Twist Tools
|
|
112
|
+
|
|
113
|
+
Twist tools provide capabilities to twists. They are usually unopinionated and do nothing on their own. Use built-in tools or create your own.
|
|
114
|
+
|
|
115
|
+
**Built-in Tools:**
|
|
116
|
+
|
|
117
|
+
- **Plot** - Manage activities and priorities
|
|
118
|
+
- **Store** - Persistent key-value storage
|
|
119
|
+
- **AI** - Language models with structured output
|
|
120
|
+
- **Integrations** - OAuth authentication
|
|
121
|
+
- **Network** - HTTP access and webhooks
|
|
122
|
+
- **Tasks** - Background task execution
|
|
123
|
+
- **Callbacks** - Persistent function references
|
|
124
|
+
|
|
125
|
+
[View all tools →](https://twist.plot.day/documents/Built-in_Tools.html)
|
|
126
|
+
|
|
127
|
+
### Activities
|
|
128
|
+
|
|
129
|
+
The core data type representing tasks, events, and notes.
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
await this.tools.plot.createActivity({
|
|
133
|
+
type: ActivityType.Task,
|
|
134
|
+
title: "Review pull request",
|
|
135
|
+
links: [
|
|
136
|
+
{
|
|
137
|
+
type: ActivityLinkType.external,
|
|
138
|
+
title: "View PR",
|
|
139
|
+
url: "https://github.com/org/repo/pull/123",
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
[Learn more →](https://twist.plot.day/documents/Core_Concepts.html)
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## CLI Commands
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Authentication
|
|
153
|
+
plot login
|
|
154
|
+
|
|
155
|
+
# Twist management
|
|
156
|
+
plot create # Create new twist project
|
|
157
|
+
plot generate # Generate code from plot-twist.md
|
|
158
|
+
plot deploy # Deploy to Plot
|
|
159
|
+
plot logs # Stream real-time twist logs
|
|
160
|
+
|
|
161
|
+
# Priority management
|
|
162
|
+
plot priority list # List all priorities
|
|
163
|
+
plot priority create # Create new priority
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
[Complete CLI reference →](https://twist.plot.day/documents/CLI_Reference.html)
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Documentation
|
|
171
|
+
|
|
172
|
+
**[📚 Full Documentation at twist.plot.day](https://twist.plot.day)**
|
|
173
|
+
|
|
174
|
+
### Guides
|
|
175
|
+
|
|
176
|
+
- [Getting Started](https://twist.plot.day/documents/Getting_Started.html) - Complete walkthrough
|
|
177
|
+
- [Core Concepts](https://twist.plot.day/documents/Core_Concepts.html) - Twists, tools, and architecture
|
|
178
|
+
- [Built-in Tools](https://twist.plot.day/documents/Built-in_Tools.html) - Plot, Store, AI, and more
|
|
179
|
+
- [Building Custom Tools](https://twist.plot.day/documents/Building_Custom_Tools.html) - Create reusable twist tools
|
|
180
|
+
- [Runtime Environment](https://twist.plot.day/documents/Runtime_Environment.html) - Execution constraints and optimization
|
|
181
|
+
- [Advanced Topics](https://twist.plot.day/documents/Advanced.html) - Complex patterns and techniques
|
|
182
|
+
|
|
183
|
+
### Reference
|
|
184
|
+
|
|
185
|
+
- [CLI Reference](https://twist.plot.day/documents/CLI_Reference.html) - Complete command documentation
|
|
186
|
+
- [API Reference](https://twist.plot.day) - TypeDoc-generated API docs
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Examples
|
|
191
|
+
|
|
192
|
+
### Simple Note Twist
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
export default class WelcomeTwist extends Twist<WelcomeTwist> {
|
|
196
|
+
build(build: ToolBuilder) {
|
|
197
|
+
return { plot: build(Plot) };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async activate(priority: Pick<Priority, "id">) {
|
|
201
|
+
await this.tools.plot.createActivity({
|
|
202
|
+
type: ActivityType.Note,
|
|
203
|
+
title: "Welcome to Plot! 👋",
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### GitHub Integration
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
export default class GitHubTwist extends Twist<GitHubTwist> {
|
|
213
|
+
build(build: ToolBuilder) {
|
|
214
|
+
return {
|
|
215
|
+
plot: build(Plot),
|
|
216
|
+
network: build(Network, {
|
|
217
|
+
urls: ["https://api.github.com/*"],
|
|
218
|
+
}),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async activate(priority: Pick<Priority, "id">) {
|
|
223
|
+
// Set up webhook for issue updates
|
|
224
|
+
const webhookUrl = await this.tools.network.createWebhook("onIssueUpdate");
|
|
225
|
+
await this.set("webhook_url", webhookUrl);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async onIssueUpdate(request: WebhookRequest) {
|
|
229
|
+
// Sync GitHub issues to Plot activities
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
[More examples →](https://twist.plot.day/documents/Getting_Started.html)
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## TypeScript Configuration
|
|
239
|
+
|
|
240
|
+
Extend the Twist Creator's base configuration in your `tsconfig.json`:
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"extends": "@plotday/twister/tsconfig.base.json",
|
|
245
|
+
"include": ["src/*.ts"]
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Support
|
|
252
|
+
|
|
253
|
+
- **Documentation**: [twist.plot.day](https://twist.plot.day)
|
|
254
|
+
- **Issues**: [github.com/plotday/plot/issues](https://github.com/plotday/plot/issues)
|
|
255
|
+
- **Website**: [plot.day](https://plot.day)
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
MIT © Plot Technologies Inc.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildCommand = buildCommand;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const bundle_1 = require("../utils/bundle");
|
|
40
|
+
const out = __importStar(require("../utils/output"));
|
|
41
|
+
/**
|
|
42
|
+
* Build command - bundles the twist without deploying.
|
|
43
|
+
*
|
|
44
|
+
* This command is useful for:
|
|
45
|
+
* - Testing that your twist builds successfully
|
|
46
|
+
* - Inspecting the bundled output
|
|
47
|
+
* - CI/CD pipelines that separate build and deploy steps
|
|
48
|
+
*
|
|
49
|
+
* @param options - Build configuration
|
|
50
|
+
*/
|
|
51
|
+
async function buildCommand(options) {
|
|
52
|
+
const twistPath = path.resolve(process.cwd(), options.dir);
|
|
53
|
+
// Verify we're in an twist directory
|
|
54
|
+
const packageJsonPath = path.join(twistPath, "package.json");
|
|
55
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
56
|
+
out.error("package.json not found. Are you in an twist directory?", "Run this command from your twist's root directory");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
// Read package.json for twist name
|
|
60
|
+
let twistName = "twist";
|
|
61
|
+
try {
|
|
62
|
+
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
|
|
63
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
64
|
+
twistName = packageJson.displayName || packageJson.name || "twist";
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
// Continue with default name if parsing fails
|
|
68
|
+
}
|
|
69
|
+
out.header(`Building ${twistName}`);
|
|
70
|
+
try {
|
|
71
|
+
// Bundle the twist
|
|
72
|
+
out.progress("Bundling...");
|
|
73
|
+
const result = await (0, bundle_1.bundleTwist)(twistPath, {
|
|
74
|
+
minify: false,
|
|
75
|
+
sourcemap: true,
|
|
76
|
+
});
|
|
77
|
+
// Show warnings if any
|
|
78
|
+
if (result.warnings.length > 0) {
|
|
79
|
+
out.warning(`Build completed with ${result.warnings.length} warning(s)`);
|
|
80
|
+
for (const warning of result.warnings.slice(0, 10)) {
|
|
81
|
+
console.warn(` ${warning}`);
|
|
82
|
+
}
|
|
83
|
+
if (result.warnings.length > 10) {
|
|
84
|
+
console.warn(` ... and ${result.warnings.length - 10} more warnings`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Get bundle stats
|
|
88
|
+
const buildDir = path.join(twistPath, "build");
|
|
89
|
+
const bundlePath = path.join(buildDir, "index.js");
|
|
90
|
+
const stats = fs.statSync(bundlePath);
|
|
91
|
+
const sizeKB = (stats.size / 1024).toFixed(2);
|
|
92
|
+
// Show success
|
|
93
|
+
out.success(`Built successfully`);
|
|
94
|
+
out.plain(` Output: ${path.relative(process.cwd(), bundlePath)}`);
|
|
95
|
+
out.plain(` Size: ${sizeKB} KB`);
|
|
96
|
+
// Tip for next steps
|
|
97
|
+
out.blank();
|
|
98
|
+
out.plain("Next steps:");
|
|
99
|
+
out.plain(" • Run 'plot deploy' to deploy this twist");
|
|
100
|
+
out.plain(" • Or inspect the bundled output in build/index.js");
|
|
101
|
+
out.blank();
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
out.error("Build failed", String(error));
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../cli/commands/build.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,oCAiEC;AArFD,uCAAyB;AACzB,2CAA6B;AAE7B,4CAA8C;AAC9C,qDAAuC;AAMvC;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAAC,OAAqB;IACtD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAE3D,qCAAqC;IACrC,MAA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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createCommand = createCommand;
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
44
|
+
const out = __importStar(require("../utils/output"));
|
|
45
|
+
const packageManager_1 = require("../utils/packageManager");
|
|
46
|
+
async function createCommand(options) {
|
|
47
|
+
out.header("Create a new Plot twist");
|
|
48
|
+
let response;
|
|
49
|
+
// If both name and displayName are provided via CLI, use them directly
|
|
50
|
+
if (options.name && options.displayName) {
|
|
51
|
+
// Validate name
|
|
52
|
+
if (!/^[a-z0-9-]+$/.test(options.name)) {
|
|
53
|
+
out.error("Name must be kebab-case (lowercase, hyphens only)");
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
// Validate displayName
|
|
57
|
+
if (options.displayName.length === 0) {
|
|
58
|
+
out.error("Display name is required");
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
response = {
|
|
62
|
+
name: options.name,
|
|
63
|
+
displayName: options.displayName,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Use interactive prompts
|
|
68
|
+
const promptResponse = await (0, prompts_1.default)([
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
name: "name",
|
|
72
|
+
message: "Package name:",
|
|
73
|
+
initial: options.dir || options.name || undefined,
|
|
74
|
+
validate: (value) => /^[a-z0-9-]+$/.test(value) ||
|
|
75
|
+
"Must be kebab-case (lowercase, hyphens only)",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "text",
|
|
79
|
+
name: "displayName",
|
|
80
|
+
message: "Display name:",
|
|
81
|
+
initial: options.displayName || undefined,
|
|
82
|
+
validate: (value) => value.length > 0 || "Name is required",
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
if (Object.keys(promptResponse).length === 0) {
|
|
86
|
+
out.plain("\nCancelled.");
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
response = promptResponse;
|
|
90
|
+
}
|
|
91
|
+
const twistDir = options.dir || response.name;
|
|
92
|
+
const twistPath = path.resolve(process.cwd(), twistDir);
|
|
93
|
+
if (fs.existsSync(twistPath)) {
|
|
94
|
+
out.error(`Directory "${twistDir}" already exists`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
out.progress(`Creating ${response.displayName}...`);
|
|
98
|
+
// Create directory structure
|
|
99
|
+
fs.mkdirSync(twistPath, { recursive: true });
|
|
100
|
+
fs.mkdirSync(path.join(twistPath, "src"), { recursive: true });
|
|
101
|
+
// Read SDK version from package.json
|
|
102
|
+
let sdkVersion = "^0.1.0"; // Fallback version
|
|
103
|
+
try {
|
|
104
|
+
const sdkPackagePath = path.join(__dirname, "..", "..", "package.json");
|
|
105
|
+
const sdkPackage = JSON.parse(fs.readFileSync(sdkPackagePath, "utf-8"));
|
|
106
|
+
sdkVersion = `^${sdkPackage.version}`;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.warn("Warning: Could not read Twist Creator version, using fallback");
|
|
110
|
+
}
|
|
111
|
+
// Generate a unique twist ID
|
|
112
|
+
const plotTwistId = crypto.randomUUID();
|
|
113
|
+
// Create package.json
|
|
114
|
+
const packageJson = {
|
|
115
|
+
name: response.name,
|
|
116
|
+
displayName: response.displayName || response.name,
|
|
117
|
+
main: "src/index.ts",
|
|
118
|
+
types: "src/index.ts",
|
|
119
|
+
plotTwistId: plotTwistId,
|
|
120
|
+
scripts: {
|
|
121
|
+
lint: "plot lint",
|
|
122
|
+
deploy: "plot deploy",
|
|
123
|
+
},
|
|
124
|
+
dependencies: {
|
|
125
|
+
"@plotday/twister": sdkVersion,
|
|
126
|
+
},
|
|
127
|
+
devDependencies: {
|
|
128
|
+
typescript: "^5.8.3",
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
fs.writeFileSync(path.join(twistPath, "package.json"), JSON.stringify(packageJson, null, 2) + "\n");
|
|
132
|
+
// Create tsconfig.json
|
|
133
|
+
const tsconfigJson = {
|
|
134
|
+
extends: "@plotday/twister/tsconfig.base.json",
|
|
135
|
+
include: ["src/*.ts"],
|
|
136
|
+
};
|
|
137
|
+
fs.writeFileSync(path.join(twistPath, "tsconfig.json"), JSON.stringify(tsconfigJson, null, 2) + "\n");
|
|
138
|
+
const twistTemplate = `import {
|
|
139
|
+
type Activity,
|
|
140
|
+
Twist,
|
|
141
|
+
type Priority,
|
|
142
|
+
type ToolBuilder,
|
|
143
|
+
} from "@plotday/twister";
|
|
144
|
+
import { Plot } from "@plotday/twister/tools/plot";
|
|
145
|
+
|
|
146
|
+
export default class MyTwist extends Twist<MyTwist> {
|
|
147
|
+
build(build: ToolBuilder) {
|
|
148
|
+
return {
|
|
149
|
+
plot: build(Plot),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async activate(_priority: Pick<Priority, "id">) {
|
|
154
|
+
// Called when twist is enabled for a priority
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async activity(activity: Activity) {
|
|
158
|
+
// Called when an activity is routed to this twist
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
fs.writeFileSync(path.join(twistPath, "src", "index.ts"), twistTemplate);
|
|
163
|
+
// Detect and use appropriate package manager
|
|
164
|
+
const packageManager = (0, packageManager_1.detectPackageManager)();
|
|
165
|
+
const packageManagerCommand = packageManager === "npm" ? "npm run" : packageManager;
|
|
166
|
+
// Copy README.md from template
|
|
167
|
+
const readmeTemplatePath = path.join(__dirname, "..", "templates", "README.template.md");
|
|
168
|
+
try {
|
|
169
|
+
let readmeContent = fs.readFileSync(readmeTemplatePath, "utf-8");
|
|
170
|
+
// Replace template variables
|
|
171
|
+
readmeContent = readmeContent.replace(/\{\{displayName\}\}/g, response.displayName);
|
|
172
|
+
readmeContent = readmeContent.replace(/\{\{name\}\}/g, response.name);
|
|
173
|
+
readmeContent = readmeContent.replace(/\{\{packageManager\}\}/g, packageManagerCommand);
|
|
174
|
+
fs.writeFileSync(path.join(twistPath, "README.md"), readmeContent);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.warn("Warning: Could not copy README template");
|
|
178
|
+
}
|
|
179
|
+
// Copy AGENTS.md from template
|
|
180
|
+
const twistsTemplatePath = path.join(__dirname, "..", "templates", "AGENTS.template.md");
|
|
181
|
+
try {
|
|
182
|
+
let twistsContent = fs.readFileSync(twistsTemplatePath, "utf-8");
|
|
183
|
+
// Replace template variables
|
|
184
|
+
twistsContent = twistsContent.replace(/\{\{packageManager\}\}/g, packageManagerCommand);
|
|
185
|
+
fs.writeFileSync(path.join(twistPath, "AGENTS.md"), twistsContent);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
console.warn("Warning: Could not copy AGENTS template");
|
|
189
|
+
}
|
|
190
|
+
// Copy CLAUDE.md from template
|
|
191
|
+
const claudeTemplatePath = path.join(__dirname, "..", "templates", "CLAUDE.template.md");
|
|
192
|
+
try {
|
|
193
|
+
const claudeContent = fs.readFileSync(claudeTemplatePath, "utf-8");
|
|
194
|
+
fs.writeFileSync(path.join(twistPath, "CLAUDE.md"), claudeContent);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
console.warn("Warning: Could not copy CLAUDE template");
|
|
198
|
+
}
|
|
199
|
+
// Create .gitignore
|
|
200
|
+
const gitignore = `node_modules/
|
|
201
|
+
build/
|
|
202
|
+
.env
|
|
203
|
+
`;
|
|
204
|
+
fs.writeFileSync(path.join(twistPath, ".gitignore"), gitignore);
|
|
205
|
+
// Initialize git
|
|
206
|
+
try {
|
|
207
|
+
(0, child_process_1.execSync)("git init", { cwd: twistPath, stdio: "ignore" });
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
// Silently fail - not critical
|
|
211
|
+
}
|
|
212
|
+
const installCommand = packageManager === "yarn" ? "yarn" : `${packageManager} install`;
|
|
213
|
+
// Install dependencies
|
|
214
|
+
try {
|
|
215
|
+
(0, child_process_1.execSync)(installCommand, { cwd: twistPath, stdio: "ignore" });
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
out.warning("Couldn't install dependencies", [
|
|
219
|
+
`Run '${installCommand}' in ${twistDir}`,
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
out.success(`${response.displayName} created`);
|
|
223
|
+
out.nextSteps([
|
|
224
|
+
`cd ${twistDir}`,
|
|
225
|
+
`${packageManager === "npm" ? "npm run" : packageManager} lint`,
|
|
226
|
+
`${packageManager === "npm" ? "npm run" : packageManager} deploy`,
|
|
227
|
+
]);
|
|
228
|
+
out.blank();
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../cli/commands/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,sCA6OC;AA3PD,iDAAyC;AACzC,uCAAyB;AACzB,2CAA6B;AAC7B,sDAA8B;AAE9B,qDAAuC;AACvC,4DAA+D;AAQxD,KAAK,UAAU,aAAa,CAAC,OAAsB;IACxD,GAAG,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAEtC,IAAI,QAA+C,CAAC;IAEpD,uEAAuE;IACvE,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxC,gBAAgB;QAChB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,GAAG,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,uBAAuB;QACvB,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,KAAK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