@itpay/cli 0.1.10 → 0.2.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.
@@ -5,7 +5,7 @@
5
5
  "title": "Cart-First Checkout",
6
6
  "purpose": "Teach the agent to use the UCP cart handoff, including CORE-033 multi-item carts, instead of bypassing cart.",
7
7
  "when_to_use": [
8
- "The user selected one or more public catalog variants.",
8
+ "The user selected one or more public catalog purchase options.",
9
9
  "The agent needs an estimate before checkout.",
10
10
  "The agent needs to create a checkout from cart_id.",
11
11
  "A first-time wild agent may receive auth_qr as a first-purchase auth-to-payment entry before payment is verified."
@@ -14,7 +14,7 @@
14
14
  "needs": [
15
15
  "catalog_variant_id or catalog_variant_ids",
16
16
  "buyer email for secure delivery",
17
- "product-specific required input fields before cart creation"
17
+ "service-declared required input fields before cart creation"
18
18
  ],
19
19
  "optional": [
20
20
  "buyer phone"
@@ -27,14 +27,14 @@
27
27
  },
28
28
  "commands": [
29
29
  {
30
- "intent": "create a cart estimate for the selected UCP Variant.id",
30
+ "intent": "create a cart estimate for the selected purchase option",
31
31
  "command": "itp buyer cart create --variant <variant_id> --json",
32
- "success_signal": "response.cart.cart_id is present and agent_next_actions includes create_checkout_from_cart"
32
+ "success_signal": "response.cart.cart_id is present and response.cart_guidance tells the agent to show the cart to the human before checkout"
33
33
  },
34
34
  {
35
- "intent": "create a multi-item cart estimate for selected UCP Variant.id values",
35
+ "intent": "create a multi-item cart estimate for selected purchase options",
36
36
  "command": "itp buyer cart create --variants <variant_id_1>,<variant_id_2> --quantities 1,2 --json",
37
- "success_signal": "response.cart.line_items contains every selected variant and response.cart.amount is the estimated total"
37
+ "success_signal": "response.cart.line_items contains every selected purchase option and response.cart_guidance.double_check_required is true"
38
38
  },
39
39
  {
40
40
  "intent": "create an enterprise fuzzy search cart with required query input",
@@ -49,7 +49,7 @@
49
49
  {
50
50
  "intent": "view the current cart state without relying on model memory",
51
51
  "command": "itp buyer cart show <cart_id> --json",
52
- "success_signal": "response.cart.line_items and response.cart.totals reflect the server-side cart"
52
+ "success_signal": "response.cart.line_items and response.cart.totals reflect the server-side cart; show these fields to the human before checkout"
53
53
  },
54
54
  {
55
55
  "intent": "add one more selected UCP Variant.id to an existing cart before checkout",
@@ -74,15 +74,19 @@
74
74
  ],
75
75
  "agent_rules": [
76
76
  "CORE-033 supports multiple cart lines and bounded positive quantities when all items belong to the same supported settlement/provider group.",
77
- "Before cart creation, inspect product metadata input_schema_json and collect every required input field. Do not wait until after payment to ask for required query inputs.",
78
- "Enterprise fuzzy search requires input.company_name. This can be a keyword, brand, short name, or partial company name supplied by the user, such as 京东.",
79
- "Enterprise precise lookup requires input.company_name_or_credit_no. This must be a complete China mainland registered company name or unified social credit code. If the user only provides a brand/short name, resolve the exact name first or use fuzzy search before precise lookup.",
77
+ "Before cart creation, inspect product/selection metadata and input_schema_json. The service provider declares whether input is fuzzy, exact, or human/sensitive; the agent must not guess.",
78
+ "If service metadata says fuzzy input is allowed, collect the declared field, for example input.company_name can be a keyword, brand, short name, or partial company name such as 京东.",
79
+ "If service metadata says exact input is required, collect the declared exact field, for example input.company_name_or_credit_no must be a complete China mainland registered company name or unified social credit code.",
80
+ "If service metadata says input is sensitive, personal, or human-authorized, do not collect it in chat. Continue through the ItPay human authorization/input flow.",
80
81
  "Use --input key=value for service-specific inputs. For multiple query lines, prefer separate cart add commands so each line locks its own input.",
81
82
  "Cart line identity includes variant, offer, price, provider product, and normalized input. Only a completely identical line should merge by increasing quantity.",
82
83
  "If the same variant has a different company_name, company_name_or_credit_no, page number, setting, or any other input value, it must remain a separate cart line.",
83
84
  "Before checkout create, confirm buyer email is available for secure delivery. If it is missing, ask the human for the email before checkout; do not guess or use a placeholder.",
84
85
  "Use cart_id as the checkout handoff.",
85
86
  "Use buyer cart show before changing an existing cart and whenever you need current cart contents. Do not rely on chat memory for cart state.",
87
+ "After cart create/add/remove/show, present the cart contents to the human: service, purchase option, each input, quantity, price, and delivery mode.",
88
+ "If the cart has more than one line item, double-check every line with the human unless the user's prompt was already explicit and the server cart exactly matches it.",
89
+ "Cart confirmation is mandatory before checkout create. Selected service is not the same as confirmed cart.",
86
90
  "Use buyer cart add/remove before checkout when the user changes their mind. After checkout is created, treat the cart as locked.",
87
91
  "Do not override cart line_items during checkout.",
88
92
  "Cart, checkout, and catalog JSON money fields use minor units. For CNY, amount=10 or expected_amount=10 means CNY 0.10. Tell humans the display_amount or converted major-unit amount, never interpret amount as yuan.",
@@ -90,16 +94,21 @@
90
94
  "If the same cart is retried, expect the same checkout unless contact/client reference changes.",
91
95
  "The backend revalidates catalog, price, and delivery requirements.",
92
96
  "For first purchase, auth_qr means the ItPay first-purchase entry: provider login/registration/profile consent first, then ItPay should continue the same checkout to payment.",
97
+ "If this agent/device already has a valid buyer session token, checkout should skip auth_qr and can continue toward payment_intent_id.",
93
98
  "After presenting auth_qr, run buyer checkout resume and keep it active/waiting. Do not stop at QR display unless the human explicitly asks you to pause.",
94
99
  "Do not tell the user auth_qr is a completed payment or payment proof.",
95
100
  "For first purchase, show the ItPay auth entry as one human orchestration entry; after provider OAuth callback the same checkout exposes payment.",
96
101
  "After showing auth_qr, poll checkout or run buyer checkout resume until identity_status becomes identity_resolved and payment_intent_id appears.",
97
102
  "When auth completes, CLI should claim and store the buyer session so a repeat purchase by the same agent/device can skip auth.",
98
- "If checkout status/resume returns buyer_session.status=buyer_session_saved, the agent is now bound to that buyer account on this device. Continue with payment, delivery polling, or buyer vault commands; do not ask the human for a buyer session token."
103
+ "If checkout status/resume returns buyer_session.status=buyer_session_saved, the agent is now bound to that buyer account on this device. Continue with payment, delivery polling, or buyer vault commands; do not ask the human for a buyer session token.",
104
+ "Do not enter payment unless both conditions are true: a valid/saved buyer session exists and payment_intent_id exists.",
105
+ "If payment_intent_id exists but buyer_session is missing, do not show payment QR. Resume/status the same checkout until the buyer session is saved or verified."
99
106
  ],
100
107
  "forbidden": [
101
108
  "Use the UCP cart and buyer checkout commands for external-agent tests.",
102
109
  "Do not pass a different variant in checkout after cart is created.",
110
+ "Do not create checkout before showing the cart contents and getting confirmation.",
111
+ "Do not show a payment QR when buyer_session is missing, even if payment_intent_id is present.",
103
112
  "Do not create a second cart/checkout after a retryable timeout unless the user asks to abandon the previous one.",
104
113
  "Do not buy enterprise precise lookup with only a vague brand/short name unless you have resolved the exact registered company name.",
105
114
  "Do not claim enterprise API raw results are visible to the agent; they are delivered to the human Vault/claim UI."
@@ -3,10 +3,10 @@
3
3
  "role": "buyer",
4
4
  "topic": "catalog-search",
5
5
  "title": "Catalog Search For Buyer Agents",
6
- "purpose": "Help the agent find public ItPay services without login and without expensive repeated full searches.",
6
+ "purpose": "Help the agent read the service shelf, search the public ItPay service catalog, and choose a purchase option without guessing.",
7
7
  "when_to_use": [
8
8
  "The user describes a need but has not chosen a service.",
9
- "The agent needs product and variant details before recommendation.",
9
+ "The agent needs service and purchase option details before recommendation.",
10
10
  "The agent needs to search standardized API products such as ItPay enterprise data APIs."
11
11
  ],
12
12
  "required_state": {
@@ -14,10 +14,15 @@
14
14
  "must_not_need": ["buyer login", "payment intent", "ops token"]
15
15
  },
16
16
  "commands": [
17
+ {
18
+ "intent": "inspect the service shelf before guessing keywords or facets",
19
+ "command": "itp buyer shelf manifest --json",
20
+ "success_signal": "response.snapshot_version and response.snapshot_url are present; use snapshot/delta when the agent needs a shopping-list view of available services"
21
+ },
17
22
  {
18
23
  "intent": "search public catalog by natural language query",
19
24
  "command": "itp buyer catalog search --query \"企业工商信息 查询\" --json",
20
- "success_signal": "response.products contains variants with id, title, price, metadata"
25
+ "success_signal": "response.products contains services with purchase options, id, title, price, metadata, and response.catalog_guidance explains how to choose safely"
21
26
  },
22
27
  {
23
28
  "intent": "search API services by stable category and safe facets",
@@ -30,43 +35,45 @@
30
35
  "success_signal": "response.products includes the fuzzy enterprise search product before precise lookup"
31
36
  },
32
37
  {
33
- "intent": "get exact product details for a selected variant",
38
+ "intent": "get exact service details for a selected purchase option",
34
39
  "command": "itp buyer catalog get --variant <variant_id> --json",
35
- "success_signal": "response.selection.catalog_variant_id matches the selected variant"
36
- },
37
- {
38
- "intent": "discover low-cost shelf sync endpoints for repeated reads",
39
- "command": "itp buyer shelf manifest --json",
40
- "success_signal": "response.snapshot_version and response.snapshot_url are present"
40
+ "success_signal": "response.selection.catalog_variant_id matches the selected purchase option and response.catalog_guidance says to explain before cart creation"
41
41
  }
42
42
  ],
43
43
  "agent_rules": [
44
+ "Terminology: product means 服务, variant means 购买选项, variant_id means 购买选项 ID, catalog means 服务目录, shelf means 目录清单.",
45
+ "Before searching, remember the local agent does not know the current service catalog. Use this doc and the shelf manifest/snapshot as the shopping-list view when keywords or facets are unclear.",
46
+ "Catalog search is structured ItPay catalog search, not general web search. Convert the user's request into query plus category/provider/use-case/input-facet filters.",
44
47
  "Full search is allowed for explicit user search, not as a polling loop.",
45
48
  "For repeated discovery, prefer shelf manifest/snapshot/delta.",
46
49
  "For API services, map user intent to category/facet filters before relying on keyword ranking.",
47
50
  "Use stable categories: business_data_api, business_verification_api, identity_verification_api, phone_verification_api, risk_compliance_api, location_weather_api, finance_data_api.",
48
51
  "Use safe facets such as --use-case, --input-facet, --output-facet, --sensitivity-level, --delivery-mode, and --provider.",
49
- "Use product and variant metadata to explain options in user language.",
52
+ "Use service and purchase option metadata to explain options in user language.",
53
+ "If search returns zero products, do not invent a service or conclude too early. Loosen filters, change query terms, or go back to the shelf.",
54
+ "If search returns many products, narrow with category/provider/use-case/input-facet before recommending.",
55
+ "If search returns a small set, compare service description, price, required input, sensitivity level, and delivery mode.",
50
56
  "Money values from catalog JSON use minor units. For CNY, amount=10 means CNY 0.10, not CNY 10. Prefer display_amount when present, or divide amount/amount_minor by 100 before telling the user.",
51
57
  "For products with requires_human_input=true, do not ask for identity numbers or phone numbers in chat; rely on ItPay human authorization/input.",
52
- "Do not create checkout until the user intent maps to one selected variant or the user confirms a cart."
58
+ "Selecting a service is not buying. Explain the selected service and purchase option to the human, then ask for confirmation before cart creation.",
59
+ "Do not create checkout until the user intent maps to one selected purchase option and the user confirms the purchase."
53
60
  ],
54
61
  "forbidden": [
55
62
  "Do not require login for discovery.",
56
- "Do not invent catalog items or variant IDs.",
63
+ "Do not invent catalog items, services, purchase options, or variant IDs.",
57
64
  "Do not assume search result order means the user has approved purchase."
58
65
  ],
59
66
  "next_docs": [
60
67
  {
61
- "condition": "Need to recommend among variants",
68
+ "condition": "Need to recommend among services or purchase options",
62
69
  "topic": "product-recommendation",
63
70
  "command": "itp docs show product-recommendation --role buyer --json"
64
71
  },
65
72
  {
66
- "condition": "The user has chosen a variant",
73
+ "condition": "The user has chosen and confirmed a purchase option",
67
74
  "topic": "cart-checkout",
68
75
  "command": "itp docs show cart-checkout --role buyer --json"
69
76
  }
70
77
  ],
71
- "search_terms": ["catalog", "search", "shelf", "product", "variant", "api", "enterprise_data", "category", "facet", "business_data_api", "企业查询", "工商信息", "企业工商数据精准查询", "企业工商数据模糊查询", "搜索", "商品"]
78
+ "search_terms": ["catalog", "search", "shelf", "product", "variant", "purchase option", "api", "enterprise_data", "category", "facet", "business_data_api", "企业查询", "工商信息", "企业工商数据精准查询", "企业工商数据模糊查询", "搜索", "商品", "服务目录", "目录清单", "购买选项"]
72
79
  }
@@ -30,6 +30,8 @@
30
30
  "The claim link is short-lived and single-use.",
31
31
  "The agent may explain that ItPay intentionally separates agent operations from raw secret access.",
32
32
  "If the human wants the agent to analyze or use the delivered result, ask them to click 'Give to Agent / 一键给 Agent' in the ItPay page and confirm with Passkey.",
33
+ "Use clear user guidance: open the ItPay email or order/claim page, find 'Give to Agent / 一键给 Agent', select the fields the agent may read, then confirm with Passkey/WebAuthn.",
34
+ "Tell the user they do not need to copy claim links, tokens, portal text, grant ids, or raw results into chat. The agent will discover the grant with CLI after approval.",
33
35
  "After the human grants access, the agent should discover the grant with `itp buyer vault grants list --checkout <checkout_id> --json`; do not ask the human to paste the grant id. The CLI restores the buyer agent session from the checkout auth handoff when possible.",
34
36
  "If `buyer vault grants list` returns buyer_session.status=buyer_session_saved, the agent should proceed with the returned grant list; the saved session is intentionally not printed.",
35
37
  "If the human later wants the agent to install or use something, wait for an explicit human-granted install/capability flow."
@@ -30,6 +30,7 @@
30
30
  "If human_action.kind is auth_qr, present the ItPay first-purchase entry URL/QR and explain it starts account login/registration/profile authorization and should continue to payment for the same checkout after approval.",
31
31
  "For auth_qr, the ItPay auth entry is the primary handoff. oauth_start_url is fallback/debug and should not replace the ItPay orchestration page.",
32
32
  "For auth_qr, do not call payment-intent creation directly or create a new checkout; poll checkout or run buyer checkout resume until payment_intent_id appears.",
33
+ "Payment QR display requires both a valid/saved buyer session and payment_intent_id. If payment_intent_id appears before buyer_session is saved, run buyer checkout resume/status instead of showing payment QR.",
33
34
  "Do not stop after showing auth_qr unless the human explicitly asks you to pause. Keep waiting/resuming the same checkout so the post-auth payment handoff can continue.",
34
35
  "Do not describe auth_qr as payment success or payment proof. Only payment_intent.verified proves payment.",
35
36
  "MUST show local_qr_path first when present. Many agent clients do not reliably render remote QR images; local_qr_path is the most reliable desktop/chat display artifact.",
@@ -27,9 +27,13 @@
27
27
  }
28
28
  ],
29
29
  "agent_rules": [
30
+ "Payment wait is a recovery loop around the same payment_intent_id, not a one-shot command.",
30
31
  "wait.timeout is a heartbeat, not a payment failure.",
31
- "Continue waiting with the same payment_intent_id unless the command reaches its overall timeout or the user cancels.",
32
+ "Continue waiting with the same payment_intent_id unless the user explicitly cancels.",
33
+ "If the network drops, the process is interrupted, or there is no response, rerun payment wait with the same payment_intent_id or run checkout status/resume with the same checkout_id.",
34
+ "If status is unclear, tell the human it is unclear and continue querying the same payment_intent_id/checkout_id. Do not create a new checkout.",
32
35
  "Payment success is payment_intent.verified only.",
36
+ "Human text such as 'I paid' is not proof; continue waiting until payment_intent.verified.",
33
37
  "After verified, poll checkout or delivery status."
34
38
  ],
35
39
  "forbidden": [
@@ -28,7 +28,9 @@
28
28
  "agent_rules": [
29
29
  "QR refresh is display recovery only. ItPay may return the same QR again when the current provider QR is still valid.",
30
30
  "Use the same payment_intent_id.",
31
+ "If QR does not render, first use the returned local_qr_path, qr_png_url, or preferred_qr_url. Do not generate a new QR from guessed provider payload.",
31
32
  "For Alipay sandbox order-not-found, first ask the human to wait and scan/open the same QR/page again; use refresh only after that wait has failed.",
33
+ "If refresh succeeds, show only the returned ItPay QR/display URL and continue waiting on the same payment_intent_id.",
32
34
  "After refresh, continue waiting through the normal wait contract."
33
35
  ],
34
36
  "forbidden": [
@@ -17,7 +17,7 @@
17
17
  {
18
18
  "intent": "verify whether this agent/device already has a server-valid buyer session",
19
19
  "command": "itp status --refresh --json",
20
- "success_signal": "response.status is idle when authenticated, or response.next.command tells the agent how to start human auth"
20
+ "success_signal": "response.status is idle when authenticated, or response.next.command tells the agent how to start human auth; if response.recoverable_context.found is true, compare it with the current user intent before continuing or ignoring it"
21
21
  },
22
22
  {
23
23
  "intent": "list the available agent docs topics",
@@ -27,7 +27,7 @@
27
27
  {
28
28
  "intent": "search the public catalog for the current user request",
29
29
  "command": "itp buyer catalog search --query \"<user request>\" --json",
30
- "success_signal": "response.products contains public products and variants"
30
+ "success_signal": "response.products contains public services and purchase options; response.catalog_guidance tells the agent how to compare and when to ask the human"
31
31
  },
32
32
  {
33
33
  "intent": "search standardized API services with category/facet filters when intent is clear",
@@ -43,7 +43,9 @@
43
43
  "agent_rules": [
44
44
  "Use --json for every ItPay command.",
45
45
  "Use `itp status --refresh --json` before account, order, refund, or repeat-purchase decisions. Plain local memory is not identity.",
46
- "Search and explain options before buying unless the user already named a variant.",
46
+ "If `status --refresh` returns `recoverable_context.found=true`, do not blindly resume or blindly ignore it. Decide whether the old task is related to the current user intent; continue related tasks, ignore clearly unrelated tasks, and ask the human when unsure.",
47
+ "If the catalog is unclear, read catalog-search docs and use buyer shelf manifest/snapshot as the shopping-list view before guessing keywords.",
48
+ "Search and explain purchase options before buying unless the user already named a purchase option ID.",
47
49
  "Add the selected UCP Variant.id to cart; do not bypass cart for CORE-028 flows.",
48
50
  "When explaining prices, remember ItPay JSON money fields use minor units. For CNY, amount=10 means CNY 0.10. Prefer display_amount when present.",
49
51
  "Before checkout, make sure a buyer delivery email is available. If no email is known from the current buyer context, ask the human for it before creating checkout.",
@@ -34,7 +34,10 @@
34
34
  "agent_rules": [
35
35
  "Prefer resume over creating a new checkout.",
36
36
  "A timeout does not prove failure.",
37
+ "Network failure, broken connection, no response, or interrupted agent run does not prove payment failure.",
37
38
  "Use the same checkout_id/cart_id/payment_intent_id whenever possible.",
39
+ "For payment recovery, first retry payment wait or checkout status/resume with the same IDs. Escalate to QR refresh only for display/scanner problems.",
40
+ "If payment status is unknown, say it is unknown and keep checking the same payment/checkout; do not guess paid/unpaid.",
38
41
  "Report safe error messages only."
39
42
  ],
40
43
  "forbidden": [
@@ -35,7 +35,9 @@
35
35
  "Agent-visible status may say delivery_claimable/check_email/claim_link_sent.",
36
36
  "Raw protected content is human-first unless the human later shares it outside ItPay.",
37
37
  "If the user wants analysis, comparison, installation help, or structured use of the delivered result, you may ask the human to use the ItPay page's 'Give to Agent / 一键给 Agent' Passkey flow.",
38
+ "When guiding the human, be concrete: open the delivery email or ItPay order page, click Give to Agent / 一键给 Agent, choose fields, and confirm with Passkey/WebAuthn.",
38
39
  "If the human uses the portal's one-key agent authorization, discover the resulting grant with buyer vault commands; do not ask the human to paste content or grant IDs.",
40
+ "If no grant appears, explain that authorization may not be completed, may not have synced, may target a different checkout/order, or may have expired/revoked.",
39
41
  "Do not ask the human to paste the key into chat."
40
42
  ],
41
43
  "forbidden": [
@@ -41,7 +41,11 @@
41
41
  "If the response includes buyer_session.status=buyer_session_saved, continue directly to `buyer vault grants read <agent_read_grant_id> --json`; do not ask the human for session tokens, auth IDs, or grant IDs.",
42
42
  "Do not ask the human to copy or paste `agent_read_grant_id`; discover it with `buyer vault grants list`.",
43
43
  "If no grant is returned, tell the human to open their ItPay account portal, reveal with Passkey, choose fields, and confirm one-key agent authorization.",
44
+ "If no grant is returned, explain likely causes: the human has not authorized yet, selected the wrong order/page, authorization has not synced yet, checkout/order/artifact does not match, buyer session expired, or the grant expired/revoked.",
45
+ "When no grant is returned, retry the same checkout/order after a short wait before asking for reauthorization. Do not ask the human to copy grant ids or tokens.",
44
46
  "Use only fields returned in the grant view. Do not infer that unreturned fields are accessible.",
47
+ "When a grant view is returned, tell the user which fields are readable. If expires_at, ttl, or valid_until is present, tell the user the time limit; if no expiry is returned, say the response did not include an explicit expiry.",
48
+ "If the returned fields are not enough for the user's task, ask the human to reopen Give to Agent and add the needed fields. Do not ask them to paste the missing raw content.",
45
49
  "If the command still returns 401 or buyer_session_invalid after using `--checkout`, run `itp buyer checkout status <checkout_id> --json`, then retry `itp buyer vault grants list --checkout <checkout_id> --json`. Ask the human to reauthorize only if the checkout/auth handoff has expired."
46
50
  ],
47
51
  "forbidden": [
package/install.ps1 CHANGED
@@ -2,17 +2,21 @@ $ErrorActionPreference = "Stop"
2
2
 
3
3
  $SourceDir = Split-Path -Parent $MyInvocation.MyCommand.Path
4
4
  $ItpBin = Join-Path $SourceDir "bin\itp"
5
+ $LibDir = Join-Path $SourceDir "lib"
5
6
  $SkillsDir = Join-Path $SourceDir "skills"
6
7
  $DocsDir = Join-Path $SourceDir "docs"
7
8
  $NodeModules = Join-Path $SourceDir "node_modules"
9
+ $PackageFile = Join-Path $SourceDir "package.json"
8
10
  $Prefix = if ($env:ITP_PREFIX) { $env:ITP_PREFIX } else { Join-Path $HOME ".local" }
9
11
  $TargetDir = Join-Path $Prefix "bin"
10
12
  $TargetScript = Join-Path $TargetDir "itp.js"
11
13
  $TargetCmd = Join-Path $TargetDir "itp.cmd"
12
- $ModuleTarget = Join-Path $TargetDir "node_modules"
14
+ $LibTarget = Join-Path $Prefix "lib"
15
+ $ModuleTarget = Join-Path $Prefix "node_modules"
13
16
  $ShareTargetDir = Join-Path $Prefix "share\itpay_cli"
14
17
  $SkillsTarget = Join-Path $ShareTargetDir "skills"
15
18
  $DocsTarget = Join-Path $ShareTargetDir "docs"
19
+ $PackageTarget = Join-Path $ShareTargetDir "package.json"
16
20
 
17
21
  if (!(Test-Path $ItpBin)) {
18
22
  throw "itp binary not found at $ItpBin"
@@ -20,24 +24,32 @@ if (!(Test-Path $ItpBin)) {
20
24
 
21
25
  New-Item -ItemType Directory -Force -Path $TargetDir | Out-Null
22
26
  Copy-Item -Force $ItpBin $TargetScript
27
+ if (Test-Path $LibDir) {
28
+ if (Test-Path $LibTarget) {
29
+ Remove-Item -Recurse -Force $LibTarget
30
+ }
31
+ Copy-Item -Recurse -Force $LibDir $LibTarget
32
+ }
23
33
  if (Test-Path $NodeModules) {
24
34
  if (Test-Path $ModuleTarget) {
25
35
  Remove-Item -Recurse -Force $ModuleTarget
26
36
  }
27
37
  Copy-Item -Recurse -Force $NodeModules $ModuleTarget
28
38
  }
39
+ New-Item -ItemType Directory -Force -Path $ShareTargetDir | Out-Null
40
+ if (Test-Path $PackageFile) {
41
+ Copy-Item -Force $PackageFile $PackageTarget
42
+ }
29
43
  if (Test-Path $SkillsDir) {
30
44
  if (Test-Path $SkillsTarget) {
31
45
  Remove-Item -Recurse -Force $SkillsTarget
32
46
  }
33
- New-Item -ItemType Directory -Force -Path $ShareTargetDir | Out-Null
34
47
  Copy-Item -Recurse -Force $SkillsDir $SkillsTarget
35
48
  }
36
49
  if (Test-Path $DocsDir) {
37
50
  if (Test-Path $DocsTarget) {
38
51
  Remove-Item -Recurse -Force $DocsTarget
39
52
  }
40
- New-Item -ItemType Directory -Force -Path $ShareTargetDir | Out-Null
41
53
  Copy-Item -Recurse -Force $DocsDir $DocsTarget
42
54
  }
43
55
  Set-Content -Path $TargetCmd -Encoding ASCII -Value @"
package/install.sh CHANGED
@@ -3,6 +3,7 @@ set -eu
3
3
 
4
4
  SOURCE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
5
5
  ITP_BIN="$SOURCE_DIR/bin/itp"
6
+ LIB_DIR="$SOURCE_DIR/lib"
6
7
  SKILLS_DIR="$SOURCE_DIR/skills"
7
8
  DOCS_DIR="$SOURCE_DIR/docs"
8
9
  NODE_MODULES="$SOURCE_DIR/node_modules"
@@ -10,7 +11,9 @@ PREFIX="${ITP_PREFIX:-$HOME/.local}"
10
11
  TARGET_DIR="$PREFIX/bin"
11
12
  TARGET="$TARGET_DIR/itp"
12
13
  SHARE_TARGET_DIR="$PREFIX/share/itpay_cli"
13
- MODULE_TARGET="$TARGET_DIR/node_modules"
14
+ LIB_TARGET="$PREFIX/lib"
15
+ MODULE_TARGET="$PREFIX/node_modules"
16
+ PACKAGE_FILE="$SOURCE_DIR/package.json"
14
17
 
15
18
  if [ ! -f "$ITP_BIN" ]; then
16
19
  echo "itp binary not found at $ITP_BIN" >&2
@@ -22,21 +25,31 @@ chmod +x "$ITP_BIN"
22
25
  cp "$ITP_BIN" "$TARGET"
23
26
  chmod +x "$TARGET"
24
27
 
28
+ if [ -d "$LIB_DIR" ]; then
29
+ rm -rf "$LIB_TARGET"
30
+ cp -R "$LIB_DIR" "$LIB_TARGET"
31
+ find "$LIB_TARGET" -type f -exec chmod 0644 {} \;
32
+ fi
33
+
25
34
  if [ -d "$NODE_MODULES" ]; then
26
35
  rm -rf "$MODULE_TARGET"
27
36
  cp -R "$NODE_MODULES" "$MODULE_TARGET"
28
37
  fi
29
38
 
39
+ mkdir -p "$SHARE_TARGET_DIR"
40
+ if [ -f "$PACKAGE_FILE" ]; then
41
+ cp "$PACKAGE_FILE" "$SHARE_TARGET_DIR/package.json"
42
+ chmod 0644 "$SHARE_TARGET_DIR/package.json"
43
+ fi
44
+
30
45
  if [ -d "$SKILLS_DIR" ]; then
31
46
  rm -rf "$SHARE_TARGET_DIR/skills"
32
- mkdir -p "$SHARE_TARGET_DIR"
33
47
  cp -R "$SKILLS_DIR" "$SHARE_TARGET_DIR/skills"
34
48
  find "$SHARE_TARGET_DIR/skills" -type f -exec chmod 0644 {} \;
35
49
  fi
36
50
 
37
51
  if [ -d "$DOCS_DIR" ]; then
38
52
  rm -rf "$SHARE_TARGET_DIR/docs"
39
- mkdir -p "$SHARE_TARGET_DIR"
40
53
  cp -R "$DOCS_DIR" "$SHARE_TARGET_DIR/docs"
41
54
  find "$SHARE_TARGET_DIR/docs" -type f -exec chmod 0644 {} \;
42
55
  fi