@clawpify/skills 1.0.4 → 1.0.6

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/clawpify/SKILL.md CHANGED
@@ -1,134 +1,36 @@
1
1
  ---
2
2
  name: clawpify
3
3
  description: Query and manage Shopify stores via GraphQL Admin API. Use for products, orders, customers, inventory, discounts, and all Shopify data operations.
4
- dependencies:
5
- - Tool: shopify_graphql (from MCP server or custom function)
6
4
  ---
7
5
 
8
6
  # Shopify GraphQL Admin API
9
7
 
10
- A comprehensive skill for interacting with Shopify's GraphQL Admin API. This skill enables Claude to query and manage all aspects of Shopify store data.
11
-
12
- ## When to Use This Skill
13
-
14
- Use this skill when the user asks about:
15
- - Products (list, search, create, update, delete)
16
- - Orders (view, cancel, fulfill)
17
- - Customers (list, create, update)
18
- - Inventory (check levels, adjust quantities)
19
- - Discounts (create codes, manage promotions)
20
- - Any other Shopify store operations
21
-
22
- ## Critical Operations Requiring Permission
23
-
24
- IMPORTANT: Before executing any of the following operations, you MUST ask for explicit user permission:
25
-
26
- - Refunds: Create refunds (permanent financial transactions)
27
- - Order Cancellations: Cancel orders (may trigger refunds)
28
- - Gift Card Deactivation: Permanently disable gift cards
29
- - Inventory Adjustments: Modify stock levels
30
- - Product Deletions: Permanently remove products
31
- - Discount Activations: Change pricing for customers
32
-
33
- Always show what will be changed and wait for user confirmation.
34
-
35
8
  ## How to Use
36
9
 
37
- 1. Use the `shopify_graphql` tool to execute queries
38
- 2. Check for `errors` (GraphQL issues) and `userErrors` (validation issues)
39
- 3. Use pagination with `first`/`after` for large result sets
10
+ 1. Use `load_skill_reference` to load the relevant reference FIRST
11
+ 2. Use `shopify_graphql` to execute queries based on the loaded reference
12
+ 3. Check for `errors` and `userErrors` in responses
40
13
  4. Format all IDs as: `gid://shopify/Resource/123`
41
14
 
42
- ## Available References
43
-
44
- For detailed patterns and examples, refer to the reference documents:
45
- - products.md - Products and variants management
46
- - orders.md - Order operations
47
- - customers.md - Customer management
48
- - inventory.md - Inventory and locations
49
- - discounts.md - Discount codes and promotions
50
- - collections.md - Product collections
51
- - fulfillments.md - Order fulfillment and shipping
52
- - refunds.md - Process refunds
53
- - draft-orders.md - Draft order creation
54
- - gift-cards.md - Gift card management
55
- - webhooks.md - Event subscriptions
56
- - locations.md - Store locations
57
- - marketing.md - Marketing activities
58
- - markets.md - Multi-market setup
59
- - menus.md - Navigation menus
60
- - metafields.md - Custom data fields
61
- - pages.md - Store pages
62
- - blogs.md - Blog management
63
- - files.md - File uploads
64
- - shipping.md - Shipping configuration
65
- - shop.md - Store information
66
- - subscriptions.md - Subscription management
67
- - translations.md - Content translations
68
- - segments.md - Customer segments
69
- - bulk-operations.md - Bulk data operations
70
-
71
- ## Quick Examples
72
-
73
- ### List Recent Orders
74
- ```graphql
75
- query {
76
- orders(first: 10, sortKey: CREATED_AT, reverse: true) {
77
- nodes {
78
- id
79
- name
80
- totalPriceSet {
81
- shopMoney { amount currencyCode }
82
- }
83
- customer { displayName }
84
- }
85
- }
86
- }
87
- ```
88
-
89
- ### Search Products
90
- ```graphql
91
- query {
92
- products(first: 10, query: "title:*shirt* AND status:ACTIVE") {
93
- nodes {
94
- id
95
- title
96
- status
97
- }
98
- }
99
- }
100
- ```
15
+ ## Critical Operations Requiring Permission
101
16
 
102
- ### Check Inventory
103
- ```graphql
104
- query GetInventory($id: ID!) {
105
- inventoryItem(id: $id) {
106
- id
107
- inventoryLevels(first: 5) {
108
- nodes {
109
- quantities(names: ["available"]) {
110
- name
111
- quantity
112
- }
113
- location { name }
114
- }
115
- }
116
- }
117
- }
118
- ```
17
+ IMPORTANT: Before executing any of the following, you MUST ask for explicit user permission:
119
18
 
120
- ## Error Handling
19
+ - Refunds, order cancellations, gift card deactivation
20
+ - Inventory adjustments, product deletions, discount activations
121
21
 
122
- Always check responses:
123
- - `errors` array = GraphQL syntax issues
124
- - `userErrors` in mutations = validation problems
22
+ Always show what will be changed and wait for confirmation.
125
23
 
126
- ## Best Practices
24
+ ## Available References
127
25
 
128
- 1. Request only needed fields to optimize response size
129
- 2. Use pagination for lists that may grow
130
- 3. Check userErrors in all mutation responses
131
- 4. Ask permission before dangerous operations
132
- 5. Format results clearly for the user
133
- 6. Use bulk operations for large data exports/imports
134
- 7. Handle rate limits with exponential backoff
26
+ Load the reference for your domain using `load_skill_reference` before writing queries:
27
+
28
+ **Store**: [shop](reference/shop.md) | [locations](reference/locations.md) | [markets](reference/markets.md)
29
+ **Catalog**: [products](reference/products.md) | [collections](reference/collections.md) | [inventory](reference/inventory.md)
30
+ **Sales**: [orders](reference/orders.md) | [draft-orders](reference/draft-orders.md) | [fulfillments](reference/fulfillments.md) | [refunds](reference/refunds.md)
31
+ **Customers**: [customers](reference/customers.md) | [segments](reference/segments.md) | [gift-cards](reference/gift-cards.md)
32
+ **Pricing**: [discounts](reference/discounts.md) | [subscriptions](reference/subscriptions.md)
33
+ **Content**: [pages](reference/pages.md) | [blogs](reference/blogs.md) | [menus](reference/menus.md) | [translations](reference/translations.md) | [files](reference/files.md)
34
+ **Custom data**: [metafields](reference/metafields.md)
35
+ **Automation**: [webhooks](reference/webhooks.md) | [bulk-operations](reference/bulk-operations.md)
36
+ **Growth**: [marketing](reference/marketing.md) | [shipping](reference/shipping.md)
package/dist/agent.d.ts CHANGED
@@ -1,18 +1,148 @@
1
1
  import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ShopifyClient } from "./shopify";
3
+ import type { MemoryStore } from "./memory";
4
+ /** Accumulated token usage and estimated cost for a single chat() call. */
5
+ export interface TokenUsage {
6
+ inputTokens: number;
7
+ outputTokens: number;
8
+ cacheCreationInputTokens: number;
9
+ cacheReadInputTokens: number;
10
+ /** Estimated USD cost based on the configured pricing. */
11
+ totalCost: number;
12
+ }
13
+ /** Per-model pricing in USD per million tokens. */
14
+ export interface ModelPricing {
15
+ inputPerMillion: number;
16
+ outputPerMillion: number;
17
+ cacheWritePerMillion: number;
18
+ cacheReadPerMillion: number;
19
+ }
20
+ /** A user-provided tool + handler that extends the agent's capabilities. */
21
+ export interface AgentPlugin {
22
+ tool: Anthropic.Tool;
23
+ handler: (input: Record<string, any>) => Promise<string>;
24
+ }
25
+ /** Lifecycle hooks for observability and custom behavior. */
26
+ export interface AgentHooks {
27
+ /** Fires before a chat request is processed. */
28
+ onRequest?: (message: string, history: Anthropic.MessageParam[]) => void | Promise<void>;
29
+ /** Fires before each Anthropic API call (including retries in the loop). */
30
+ onApiCall?: (params: {
31
+ model: string;
32
+ messages: Anthropic.MessageParam[];
33
+ tools: Anthropic.Tool[];
34
+ }) => void | Promise<void>;
35
+ /** Fires before a tool handler is executed. */
36
+ onToolCall?: (toolName: string, input: Record<string, any>) => void | Promise<void>;
37
+ /** Fires after a tool handler returns. */
38
+ onToolResult?: (toolName: string, result: string, isError: boolean) => void | Promise<void>;
39
+ /** Fires after the final text response is assembled. */
40
+ onResponse?: (response: string, usage: TokenUsage) => void | Promise<void>;
41
+ /** Fires when an error is caught during the chat loop. */
42
+ onError?: (error: Error) => void | Promise<void>;
43
+ }
44
+ /** Extended thinking configuration. */
45
+ export interface ThinkingConfig {
46
+ /** Token budget for thinking. Must be >= 1024. */
47
+ budgetTokens: number;
48
+ }
49
+ /** Full configuration accepted by the ShopifyAgent constructor. */
50
+ export interface AgentConfig {
51
+ shopify: ShopifyClient;
52
+ skillContent: string;
53
+ model?: string;
54
+ /** Override the default system instruction sent to the model. */
55
+ systemInstruction?: string;
56
+ /** Override default Claude Sonnet pricing. */
57
+ pricing?: ModelPricing;
58
+ /** Register plugins at construction time. */
59
+ plugins?: AgentPlugin[];
60
+ /** Lifecycle hooks for observability. */
61
+ hooks?: AgentHooks;
62
+ /** Enable extended thinking so the model plans before executing. */
63
+ thinking?: ThinkingConfig;
64
+ /** Maximum tool-use loop iterations before the agent stops. Defaults to 20. */
65
+ maxIterations?: number;
66
+ /** Persistent memory store for conversation history across sessions. */
67
+ memory?: MemoryStore;
68
+ }
69
+ /** Return value of a single chat() invocation. */
70
+ export interface ChatResult {
71
+ response: string;
72
+ history: Anthropic.MessageParam[];
73
+ usage: TokenUsage;
74
+ /** Concatenated thinking text when extended thinking is enabled. */
75
+ thinking?: string;
76
+ /** Number of tool-use loop iterations used in this call. */
77
+ iterationsUsed: number;
78
+ }
79
+ /** Events yielded by chatStream(). */
80
+ export type StreamEvent = {
81
+ type: "thinking";
82
+ text: string;
83
+ } | {
84
+ type: "text";
85
+ text: string;
86
+ } | {
87
+ type: "tool_call";
88
+ name: string;
89
+ input: Record<string, any>;
90
+ } | {
91
+ type: "tool_result";
92
+ name: string;
93
+ result: string;
94
+ isError: boolean;
95
+ } | {
96
+ type: "done";
97
+ response: string;
98
+ thinking?: string;
99
+ usage: TokenUsage;
100
+ iterationsUsed: number;
101
+ history: Anthropic.MessageParam[];
102
+ };
103
+ export declare const DEFAULT_SYSTEM_INSTRUCTION = "You're Clawpify. You help run a Shopify store. The merchant texts you to get stuff done";
3
104
  export declare class ShopifyAgent {
4
105
  private anthropic;
5
106
  private shopify;
6
107
  private skillContent;
108
+ private systemInstruction;
7
109
  private model;
8
- constructor(config: {
9
- shopify: ShopifyClient;
10
- skillContent: string;
11
- model?: string;
12
- });
13
- chat(userMessage: string, conversationHistory?: Anthropic.MessageParam[]): Promise<{
14
- response: string;
15
- history: Anthropic.MessageParam[];
16
- }>;
110
+ private pricing;
111
+ private plugins;
112
+ private hooks;
113
+ private thinkingConfig;
114
+ private maxIterations;
115
+ private memory;
116
+ constructor(config: AgentConfig);
117
+ /** Register a plugin at runtime. Throws if a tool with the same name already exists. */
118
+ registerPlugin(plugin: AgentPlugin): void;
119
+ /** Build the system prompt array with prompt caching. */
120
+ private buildSystemPrompt;
121
+ /** Build the tools list with cache_control on the last tool. */
122
+ private buildTools;
123
+ /** Compute max_tokens accounting for thinking budget. */
124
+ private getMaxTokens;
125
+ /** Build optional thinking param for the API call. */
126
+ private getThinkingParam;
127
+ /** Execute a single tool call by name. Returns content and error flag. */
128
+ private executeTool;
129
+ /** Process all tool_use blocks from a response, returning tool results. */
130
+ private processToolCalls;
131
+ /**
132
+ * Send a message and get a complete response (non-streaming).
133
+ * Runs the agentic tool-use loop until the model produces a final text response.
134
+ */
135
+ chat(userMessage: string, conversationHistory?: Anthropic.MessageParam[]): Promise<ChatResult>;
136
+ /**
137
+ * Send a message and stream the response as typed events.
138
+ * Same agentic loop as chat() but yields incremental text/thinking deltas.
139
+ */
140
+ chatStream(userMessage: string, conversationHistory?: Anthropic.MessageParam[]): AsyncGenerator<StreamEvent>;
141
+ /**
142
+ * Chat with automatic session memory.
143
+ * Loads conversation history from the memory store, runs chat(), and saves
144
+ * the updated history back. Requires a MemoryStore to be configured.
145
+ */
146
+ chatWithMemory(sessionId: string, userMessage: string): Promise<ChatResult>;
17
147
  }
18
148
  //# sourceMappingURL=agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAsB1C,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,EAAE;QAClB,OAAO,EAAE,aAAa,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAOK,IAAI,CACR,WAAW,EAAE,MAAM,EACnB,mBAAmB,GAAE,SAAS,CAAC,YAAY,EAAO,GACjD,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,CAAC,YAAY,EAAE,CAAA;KAAE,CAAC;CAyFpE"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAA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