@withone/cli 1.13.1 → 1.13.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/cli",
3
- "version": "1.13.1",
3
+ "version": "1.13.2",
4
4
  "description": "CLI for managing One",
5
5
  "type": "module",
6
6
  "files": [
@@ -32,6 +32,22 @@ You have access to the One CLI's workflow engine, which lets you create and exec
32
32
 
33
33
  **You MUST follow this process to build a correct workflow:**
34
34
 
35
+ ### Step 0: Design the workflow
36
+
37
+ Before touching any CLI commands, understand what you are building:
38
+
39
+ 1. **Clarify the end goal.** What output does the user actually need? A report? A notification? An enriched dataset? Do not assume — ask if unclear.
40
+ 2. **Map the full value chain.** List every step required to deliver that output at production quality. Fetching raw data is never the final step — ask yourself: "If I handed this raw API response to the user, would they be satisfied?" If no, you need analysis or enrichment steps.
41
+ 3. **Identify where AI analysis is needed.** Any time raw data needs summarization, scoring, classification, comparison, or natural-language generation, plan a `bash` step using `claude --print`. See the AI-Augmented Patterns section below.
42
+ 4. **Write the step sequence as a plain list** before constructing JSON. Example:
43
+ - Fetch competitor pricing from API
44
+ - Write data to temp file
45
+ - Claude analyzes competitive positioning (bash step)
46
+ - Parse Claude's JSON output (code step)
47
+ - Send formatted report via email
48
+
49
+ **Common mistake:** Jumping straight to `one actions search` and building a workflow that only fetches and pipes raw data. The result is a shallow data dump, not a useful workflow. Always design first.
50
+
35
51
  ### Step 1: Discover connections
36
52
 
37
53
  ```bash
@@ -693,7 +709,158 @@ To modify an existing workflow:
693
709
  }
694
710
  ```
695
711
 
696
- ## CLI Commands Reference
712
+ ### Example 4: AI-Augmented — Fetch CRM data, analyze with Claude, email report
713
+
714
+ This example demonstrates the **file-write → bash → code** pattern. Instead of just piping raw data, it uses Claude to perform competitive analysis and delivers an actionable report.
715
+
716
+ ```json
717
+ {
718
+ "key": "competitor-analysis",
719
+ "name": "AI Competitor Analysis",
720
+ "description": "Fetch deals from HubSpot, analyze competitive landscape with Claude, email the report",
721
+ "version": "1",
722
+ "inputs": {
723
+ "hubspotConnectionKey": {
724
+ "type": "string",
725
+ "required": true,
726
+ "connection": { "platform": "hub-spot" }
727
+ },
728
+ "gmailConnectionKey": {
729
+ "type": "string",
730
+ "required": true,
731
+ "connection": { "platform": "gmail" }
732
+ },
733
+ "reportEmail": {
734
+ "type": "string",
735
+ "required": true,
736
+ "description": "Email address to send the analysis report to"
737
+ }
738
+ },
739
+ "steps": [
740
+ {
741
+ "id": "fetchDeals",
742
+ "name": "Fetch recent deals from HubSpot",
743
+ "type": "action",
744
+ "action": {
745
+ "platform": "hub-spot",
746
+ "actionId": "HUBSPOT_LIST_DEALS_ACTION_ID",
747
+ "connectionKey": "$.input.hubspotConnectionKey",
748
+ "queryParams": { "limit": "100" }
749
+ }
750
+ },
751
+ {
752
+ "id": "writeDeals",
753
+ "name": "Write deals data for Claude analysis",
754
+ "type": "file-write",
755
+ "fileWrite": {
756
+ "path": "/tmp/competitor-analysis-deals.json",
757
+ "content": "$.steps.fetchDeals.response"
758
+ }
759
+ },
760
+ {
761
+ "id": "analyzeCompetitors",
762
+ "name": "Claude analyzes competitive landscape",
763
+ "type": "bash",
764
+ "bash": {
765
+ "command": "cat /tmp/competitor-analysis-deals.json | claude --print 'You are a competitive intelligence analyst. Analyze these CRM deals and return a JSON object with: {\"totalDeals\": number, \"competitorMentions\": [{\"competitor\": \"name\", \"count\": number, \"winRate\": number, \"commonObjections\": [\"...\"]}], \"summary\": \"2-3 paragraph executive summary\", \"recommendations\": [\"actionable items\"]}. Return ONLY valid JSON.' --output-format json",
766
+ "timeout": 120000,
767
+ "parseJson": true
768
+ }
769
+ },
770
+ {
771
+ "id": "formatReport",
772
+ "name": "Format analysis into email body",
773
+ "type": "code",
774
+ "code": {
775
+ "source": "const a = $.steps.analyzeCompetitors.output;\nconst competitors = a.competitorMentions.map(c => `- ${c.competitor}: ${c.count} mentions, ${c.winRate}% win rate. Objections: ${c.commonObjections.join(', ')}`).join('\\n');\nreturn {\n subject: `Competitive Analysis — ${a.totalDeals} deals analyzed`,\n body: `${a.summary}\\n\\nCompetitor Breakdown:\\n${competitors}\\n\\nRecommendations:\\n${a.recommendations.map((r, i) => `${i+1}. ${r}`).join('\\n')}`\n};"
776
+ }
777
+ },
778
+ {
779
+ "id": "sendReport",
780
+ "name": "Email the analysis report",
781
+ "type": "action",
782
+ "action": {
783
+ "platform": "gmail",
784
+ "actionId": "GMAIL_SEND_EMAIL_ACTION_ID",
785
+ "connectionKey": "$.input.gmailConnectionKey",
786
+ "data": {
787
+ "to": "{{$.input.reportEmail}}",
788
+ "subject": "{{$.steps.formatReport.output.subject}}",
789
+ "body": "{{$.steps.formatReport.output.body}}"
790
+ }
791
+ }
792
+ }
793
+ ]
794
+ }
795
+ ```
796
+
797
+ Execute with:
798
+ ```bash
799
+ one --agent flow execute competitor-analysis --allow-bash -i reportEmail=team@company.com
800
+ ```
801
+
802
+ ## 9. AI-Augmented Workflow Patterns
803
+
804
+ Use this pattern whenever raw API data needs analysis, summarization, scoring, classification, or natural-language generation. This is the difference between a shallow data pipe and a workflow that delivers real value.
805
+
806
+ ### The file-write → bash → code pattern
807
+
808
+ **Step A: `file-write`** — Write raw data to a temp file. API responses are often too large to inline into a shell command.
809
+
810
+ ```json
811
+ {
812
+ "id": "writeData",
813
+ "name": "Write raw data for analysis",
814
+ "type": "file-write",
815
+ "fileWrite": {
816
+ "path": "/tmp/{{$.input.flowKey}}-data.json",
817
+ "content": "$.steps.fetchData.response"
818
+ }
819
+ }
820
+ ```
821
+
822
+ **Step B: `bash`** — Call `claude --print` to analyze the data. This is where intelligence happens.
823
+
824
+ ```json
825
+ {
826
+ "id": "analyze",
827
+ "name": "AI analysis",
828
+ "type": "bash",
829
+ "bash": {
830
+ "command": "cat /tmp/{{$.input.flowKey}}-data.json | claude --print 'You are a [domain] analyst. Analyze this data and return JSON with: {\"summary\": \"...\", \"insights\": [...], \"score\": 0-100, \"recommendations\": [...]}. Return ONLY valid JSON, no markdown.' --output-format json",
831
+ "timeout": 120000,
832
+ "parseJson": true
833
+ }
834
+ }
835
+ ```
836
+
837
+ **Step C: `code`** — Parse and structure the AI output for downstream steps.
838
+
839
+ ```json
840
+ {
841
+ "id": "formatResult",
842
+ "name": "Structure analysis for output",
843
+ "type": "code",
844
+ "code": {
845
+ "source": "const analysis = $.steps.analyze.output;\nreturn {\n report: `Summary: ${analysis.summary}\\n\\nInsights:\\n${analysis.insights.map((insight, i) => `${i+1}. ${insight}`).join('\\n')}`,\n score: analysis.score\n};"
846
+ }
847
+ }
848
+ ```
849
+
850
+ ### When to use this pattern
851
+
852
+ - **Use it** when the user expects analysis, not raw data (e.g., "analyze my competitors", "qualify these leads", "summarize these reviews")
853
+ - **Use it** when data from one API needs intelligent transformation before being sent to another (e.g., generating a personalized email based on CRM data)
854
+ - **Don't use it** for simple field mapping or filtering — use `transform` or `code` steps instead
855
+
856
+ ### Prompt engineering tips for bash steps
857
+
858
+ - **Request JSON output** so downstream code steps can parse it — include `Return ONLY valid JSON, no markdown.` in the prompt and use `--output-format json`
859
+ - **Be specific about the analysis** — "Score each lead 0-100 based on company size, role seniority, and engagement recency" beats "analyze these leads"
860
+ - **Include domain context** — "You are a B2B sales analyst" produces better results than a generic prompt
861
+ - **Keep prompts focused** — one analysis task per bash step; chain multiple bash steps for multi-stage analysis
862
+
863
+ ## 10. CLI Commands Reference
697
864
 
698
865
  ```bash
699
866
  # Create a workflow