@newpeak/barista-cli 0.1.10 → 0.1.12

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.
Files changed (298) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +7 -3
  3. package/docs/ARCHITECTURE.md +0 -184
  4. package/docs/COMMANDS.md +0 -352
  5. package/docs/COMMAND_DESIGN_SPEC.md +0 -840
  6. package/docs/INTEGRATION_NOTES.md +0 -270
  7. package/docs/commands/REFERENCE.md +0 -323
  8. package/docs/commands/arabica/auth/index.md +0 -296
  9. package/docs/commands/liberica/auth/index.md +0 -133
  10. package/docs/commands/liberica/calendar/DESIGN.md +0 -333
  11. package/docs/commands/liberica/client-contacts/create.md +0 -152
  12. package/docs/commands/liberica/client-contacts/delete.md +0 -123
  13. package/docs/commands/liberica/client-contacts/get.md +0 -133
  14. package/docs/commands/liberica/client-contacts/list.md +0 -143
  15. package/docs/commands/liberica/client-contacts/update.md +0 -158
  16. package/docs/commands/liberica/context/index.md +0 -60
  17. package/docs/commands/liberica/currency/create.md +0 -145
  18. package/docs/commands/liberica/currency/delete.md +0 -121
  19. package/docs/commands/liberica/currency/disable.md +0 -119
  20. package/docs/commands/liberica/currency/enable.md +0 -115
  21. package/docs/commands/liberica/currency/get.md +0 -118
  22. package/docs/commands/liberica/currency/list.md +0 -149
  23. package/docs/commands/liberica/currency/update.md +0 -141
  24. package/docs/commands/liberica/employees/create.md +0 -185
  25. package/docs/commands/liberica/employees/disable.md +0 -138
  26. package/docs/commands/liberica/employees/enable.md +0 -137
  27. package/docs/commands/liberica/employees/get.md +0 -153
  28. package/docs/commands/liberica/employees/list.md +0 -168
  29. package/docs/commands/liberica/employees/update.md +0 -180
  30. package/docs/commands/liberica/locations/create.md +0 -195
  31. package/docs/commands/liberica/locations/list.md +0 -171
  32. package/docs/commands/liberica/materials/create.md +0 -293
  33. package/docs/commands/liberica/materials/delete.md +0 -240
  34. package/docs/commands/liberica/materials/disable.md +0 -150
  35. package/docs/commands/liberica/materials/enable.md +0 -146
  36. package/docs/commands/liberica/materials/get.md +0 -188
  37. package/docs/commands/liberica/materials/list.md +0 -198
  38. package/docs/commands/liberica/materials/update.md +0 -250
  39. package/docs/commands/liberica/orgs/list.md +0 -62
  40. package/docs/commands/liberica/positions/list.md +0 -61
  41. package/docs/commands/liberica/roles/list.md +0 -67
  42. package/docs/commands/liberica/stock/ledger.md +0 -209
  43. package/docs/commands/liberica/stock/list.md +0 -165
  44. package/docs/commands/liberica/supplier-contacts/create.md +0 -152
  45. package/docs/commands/liberica/supplier-contacts/delete.md +0 -123
  46. package/docs/commands/liberica/supplier-contacts/get.md +0 -133
  47. package/docs/commands/liberica/supplier-contacts/list.md +0 -143
  48. package/docs/commands/liberica/supplier-contacts/update.md +0 -158
  49. package/docs/commands/liberica/teams/issues/close.md +0 -161
  50. package/docs/commands/liberica/teams/issues/create.md +0 -212
  51. package/docs/commands/liberica/teams/issues/delete.md +0 -179
  52. package/docs/commands/liberica/teams/issues/get.md +0 -167
  53. package/docs/commands/liberica/teams/issues/list.md +0 -182
  54. package/docs/commands/liberica/teams/issues/tests-design.md +0 -341
  55. package/docs/commands/liberica/teams/issues/update.md +0 -202
  56. package/docs/commands/liberica/teams/projects/create.md +0 -174
  57. package/docs/commands/liberica/teams/projects/delete.md +0 -180
  58. package/docs/commands/liberica/teams/projects/get.md +0 -150
  59. package/docs/commands/liberica/teams/projects/list.md +0 -179
  60. package/docs/commands/liberica/teams/projects/update.md +0 -175
  61. package/docs/commands/liberica/teams/tasks/create.md +0 -163
  62. package/docs/commands/liberica/teams/tasks/delete.md +0 -109
  63. package/docs/commands/liberica/teams/tasks/get.md +0 -121
  64. package/docs/commands/liberica/teams/tasks/list.md +0 -148
  65. package/docs/commands/liberica/teams/tasks/update.md +0 -158
  66. package/docs/commands/liberica/teams/work-logs/create.md +0 -151
  67. package/docs/commands/liberica/teams/work-logs/delete.md +0 -130
  68. package/docs/commands/liberica/teams/work-logs/get.md +0 -131
  69. package/docs/commands/liberica/teams/work-logs/list.md +0 -153
  70. package/docs/commands/liberica/teams/work-logs/update.md +0 -150
  71. package/docs/commands/liberica/transfer-in-forms/batch-delete.md +0 -157
  72. package/docs/commands/liberica/transfer-in-forms/batch-review.md +0 -157
  73. package/docs/commands/liberica/transfer-in-forms/batch-unreview.md +0 -157
  74. package/docs/commands/liberica/transfer-in-forms/create.md +0 -220
  75. package/docs/commands/liberica/transfer-in-forms/get.md +0 -221
  76. package/docs/commands/liberica/transfer-in-forms/list.md +0 -242
  77. package/docs/commands/liberica/transfer-in-forms/update.md +0 -185
  78. package/docs/commands/liberica/transfer-out-forms/batch-delete.md +0 -187
  79. package/docs/commands/liberica/transfer-out-forms/batch-review.md +0 -157
  80. package/docs/commands/liberica/transfer-out-forms/batch-unreview.md +0 -157
  81. package/docs/commands/liberica/transfer-out-forms/create.md +0 -280
  82. package/docs/commands/liberica/transfer-out-forms/get.md +0 -211
  83. package/docs/commands/liberica/transfer-out-forms/list.md +0 -233
  84. package/docs/commands/liberica/transfer-out-forms/update.md +0 -286
  85. package/docs/commands/liberica/uoms/create.md +0 -136
  86. package/docs/commands/liberica/uoms/delete.md +0 -119
  87. package/docs/commands/liberica/uoms/disable.md +0 -117
  88. package/docs/commands/liberica/uoms/enable.md +0 -115
  89. package/docs/commands/liberica/uoms/get.md +0 -119
  90. package/docs/commands/liberica/uoms/list.md +0 -155
  91. package/docs/commands/liberica/uoms/update.md +0 -148
  92. package/docs/commands/liberica/users/create.md +0 -170
  93. package/docs/commands/liberica/users/get.md +0 -151
  94. package/docs/commands/liberica/users/list.md +0 -175
  95. package/docs/commands/liberica/warehouses/create.md +0 -222
  96. package/docs/commands/liberica/warehouses/list.md +0 -184
  97. package/src/commands/arabica/auth/index.ts +0 -277
  98. package/src/commands/arabica/auth/login.ts +0 -5
  99. package/src/commands/arabica/auth/logout.ts +0 -5
  100. package/src/commands/arabica/auth/register.ts +0 -5
  101. package/src/commands/arabica/auth/status.ts +0 -5
  102. package/src/commands/arabica/index.ts +0 -23
  103. package/src/commands/auth.ts +0 -107
  104. package/src/commands/context.ts +0 -60
  105. package/src/commands/liberica/auth/index.ts +0 -176
  106. package/src/commands/liberica/calendar/index.ts +0 -13
  107. package/src/commands/liberica/calendar/list.ts +0 -214
  108. package/src/commands/liberica/calendar/set.ts +0 -130
  109. package/src/commands/liberica/client-contacts/create.ts +0 -115
  110. package/src/commands/liberica/client-contacts/delete.ts +0 -140
  111. package/src/commands/liberica/client-contacts/get.ts +0 -103
  112. package/src/commands/liberica/client-contacts/index.ts +0 -19
  113. package/src/commands/liberica/client-contacts/list.ts +0 -118
  114. package/src/commands/liberica/client-contacts/update.ts +0 -137
  115. package/src/commands/liberica/clients/create.ts +0 -122
  116. package/src/commands/liberica/clients/delete.ts +0 -125
  117. package/src/commands/liberica/clients/get.ts +0 -88
  118. package/src/commands/liberica/clients/index.ts +0 -19
  119. package/src/commands/liberica/clients/list.ts +0 -123
  120. package/src/commands/liberica/clients/update.ts +0 -103
  121. package/src/commands/liberica/context/index.ts +0 -43
  122. package/src/commands/liberica/currency/create.ts +0 -183
  123. package/src/commands/liberica/currency/delete.ts +0 -124
  124. package/src/commands/liberica/currency/disable.ts +0 -147
  125. package/src/commands/liberica/currency/enable.ts +0 -128
  126. package/src/commands/liberica/currency/get.ts +0 -91
  127. package/src/commands/liberica/currency/index.ts +0 -23
  128. package/src/commands/liberica/currency/list.ts +0 -140
  129. package/src/commands/liberica/currency/update.ts +0 -129
  130. package/src/commands/liberica/dict-types/get.ts +0 -74
  131. package/src/commands/liberica/dict-types/index.ts +0 -15
  132. package/src/commands/liberica/dict-types/list.ts +0 -118
  133. package/src/commands/liberica/dict-types/update.ts +0 -134
  134. package/src/commands/liberica/dicts/create.ts +0 -175
  135. package/src/commands/liberica/dicts/delete.ts +0 -107
  136. package/src/commands/liberica/dicts/get.ts +0 -80
  137. package/src/commands/liberica/dicts/index.ts +0 -19
  138. package/src/commands/liberica/dicts/list.ts +0 -114
  139. package/src/commands/liberica/dicts/update.ts +0 -116
  140. package/src/commands/liberica/employees/create.ts +0 -275
  141. package/src/commands/liberica/employees/delete.ts +0 -122
  142. package/src/commands/liberica/employees/disable.ts +0 -97
  143. package/src/commands/liberica/employees/enable.ts +0 -97
  144. package/src/commands/liberica/employees/get.ts +0 -115
  145. package/src/commands/liberica/employees/index.ts +0 -23
  146. package/src/commands/liberica/employees/list.ts +0 -131
  147. package/src/commands/liberica/employees/update.ts +0 -157
  148. package/src/commands/liberica/index.ts +0 -81
  149. package/src/commands/liberica/materials/create.ts +0 -199
  150. package/src/commands/liberica/materials/delete.ts +0 -105
  151. package/src/commands/liberica/materials/disable.ts +0 -148
  152. package/src/commands/liberica/materials/enable.ts +0 -129
  153. package/src/commands/liberica/materials/get.ts +0 -83
  154. package/src/commands/liberica/materials/index.ts +0 -23
  155. package/src/commands/liberica/materials/list.ts +0 -142
  156. package/src/commands/liberica/materials/update.ts +0 -125
  157. package/src/commands/liberica/mould/get.ts +0 -111
  158. package/src/commands/liberica/mould/index.ts +0 -17
  159. package/src/commands/liberica/mould/list.ts +0 -157
  160. package/src/commands/liberica/mould/set-status.ts +0 -99
  161. package/src/commands/liberica/mould/stock-in.ts +0 -165
  162. package/src/commands/liberica/operations/active.ts +0 -153
  163. package/src/commands/liberica/operations/batch-delete.ts +0 -131
  164. package/src/commands/liberica/operations/copy.ts +0 -138
  165. package/src/commands/liberica/operations/create.ts +0 -223
  166. package/src/commands/liberica/operations/deactive.ts +0 -152
  167. package/src/commands/liberica/operations/delete.ts +0 -128
  168. package/src/commands/liberica/operations/design.md +0 -587
  169. package/src/commands/liberica/operations/get.ts +0 -112
  170. package/src/commands/liberica/operations/index.ts +0 -27
  171. package/src/commands/liberica/operations/list.ts +0 -180
  172. package/src/commands/liberica/operations/update.ts +0 -218
  173. package/src/commands/liberica/orgs/index.ts +0 -34
  174. package/src/commands/liberica/positions/index.ts +0 -30
  175. package/src/commands/liberica/roles/index.ts +0 -59
  176. package/src/commands/liberica/stock/index.ts +0 -13
  177. package/src/commands/liberica/stock/ledger.ts +0 -159
  178. package/src/commands/liberica/stock/list.ts +0 -128
  179. package/src/commands/liberica/supplier-contacts/create.ts +0 -120
  180. package/src/commands/liberica/supplier-contacts/delete.ts +0 -88
  181. package/src/commands/liberica/supplier-contacts/get.ts +0 -94
  182. package/src/commands/liberica/supplier-contacts/index.ts +0 -19
  183. package/src/commands/liberica/supplier-contacts/list.ts +0 -130
  184. package/src/commands/liberica/supplier-contacts/update.ts +0 -127
  185. package/src/commands/liberica/suppliers/create.ts +0 -149
  186. package/src/commands/liberica/suppliers/delete.ts +0 -102
  187. package/src/commands/liberica/suppliers/disable.ts +0 -145
  188. package/src/commands/liberica/suppliers/enable.ts +0 -126
  189. package/src/commands/liberica/suppliers/get.ts +0 -86
  190. package/src/commands/liberica/suppliers/index.ts +0 -23
  191. package/src/commands/liberica/suppliers/list.ts +0 -134
  192. package/src/commands/liberica/suppliers/update.ts +0 -128
  193. package/src/commands/liberica/teams/index.ts +0 -17
  194. package/src/commands/liberica/teams/issues/close.ts +0 -104
  195. package/src/commands/liberica/teams/issues/create.ts +0 -254
  196. package/src/commands/liberica/teams/issues/delete.ts +0 -58
  197. package/src/commands/liberica/teams/issues/get.ts +0 -78
  198. package/src/commands/liberica/teams/issues/index.ts +0 -21
  199. package/src/commands/liberica/teams/issues/list.ts +0 -144
  200. package/src/commands/liberica/teams/issues/update.ts +0 -141
  201. package/src/commands/liberica/teams/projects/create.ts +0 -159
  202. package/src/commands/liberica/teams/projects/delete.ts +0 -58
  203. package/src/commands/liberica/teams/projects/get.ts +0 -87
  204. package/src/commands/liberica/teams/projects/index.ts +0 -19
  205. package/src/commands/liberica/teams/projects/list.ts +0 -147
  206. package/src/commands/liberica/teams/projects/update.ts +0 -117
  207. package/src/commands/liberica/teams/tasks/create.ts +0 -102
  208. package/src/commands/liberica/teams/tasks/delete.ts +0 -92
  209. package/src/commands/liberica/teams/tasks/get.ts +0 -64
  210. package/src/commands/liberica/teams/tasks/index.ts +0 -19
  211. package/src/commands/liberica/teams/tasks/list.ts +0 -102
  212. package/src/commands/liberica/teams/tasks/update.ts +0 -122
  213. package/src/commands/liberica/teams/work-logs/create.ts +0 -204
  214. package/src/commands/liberica/teams/work-logs/delete.ts +0 -58
  215. package/src/commands/liberica/teams/work-logs/get.ts +0 -87
  216. package/src/commands/liberica/teams/work-logs/index.ts +0 -19
  217. package/src/commands/liberica/teams/work-logs/list.ts +0 -141
  218. package/src/commands/liberica/teams/work-logs/update.ts +0 -120
  219. package/src/commands/liberica/transfer-in-forms/batch-delete.ts +0 -152
  220. package/src/commands/liberica/transfer-in-forms/batch-review.ts +0 -151
  221. package/src/commands/liberica/transfer-in-forms/batch-unreview.ts +0 -152
  222. package/src/commands/liberica/transfer-in-forms/create.ts +0 -179
  223. package/src/commands/liberica/transfer-in-forms/get.ts +0 -107
  224. package/src/commands/liberica/transfer-in-forms/index.ts +0 -23
  225. package/src/commands/liberica/transfer-in-forms/list.ts +0 -97
  226. package/src/commands/liberica/transfer-in-forms/update.ts +0 -213
  227. package/src/commands/liberica/transfer-out-forms/batch-delete.ts +0 -83
  228. package/src/commands/liberica/transfer-out-forms/batch-review.ts +0 -148
  229. package/src/commands/liberica/transfer-out-forms/batch-unreview.ts +0 -56
  230. package/src/commands/liberica/transfer-out-forms/create.ts +0 -194
  231. package/src/commands/liberica/transfer-out-forms/get.ts +0 -114
  232. package/src/commands/liberica/transfer-out-forms/index.ts +0 -23
  233. package/src/commands/liberica/transfer-out-forms/list.ts +0 -125
  234. package/src/commands/liberica/transfer-out-forms/update.ts +0 -197
  235. package/src/commands/liberica/uoms/create.ts +0 -134
  236. package/src/commands/liberica/uoms/delete.ts +0 -105
  237. package/src/commands/liberica/uoms/disable.ts +0 -148
  238. package/src/commands/liberica/uoms/enable.ts +0 -129
  239. package/src/commands/liberica/uoms/get.ts +0 -83
  240. package/src/commands/liberica/uoms/index.ts +0 -23
  241. package/src/commands/liberica/uoms/list.ts +0 -129
  242. package/src/commands/liberica/uoms/update.ts +0 -124
  243. package/src/commands/liberica/users/create.ts +0 -133
  244. package/src/commands/liberica/users/delete.ts +0 -49
  245. package/src/commands/liberica/users/disable.ts +0 -41
  246. package/src/commands/liberica/users/enable.ts +0 -30
  247. package/src/commands/liberica/users/get.ts +0 -46
  248. package/src/commands/liberica/users/index.ts +0 -27
  249. package/src/commands/liberica/users/list.ts +0 -68
  250. package/src/commands/liberica/users/me.ts +0 -42
  251. package/src/commands/liberica/users/reset-password.ts +0 -42
  252. package/src/commands/liberica/users/update.ts +0 -48
  253. package/src/commands/liberica/warehouses/create.ts +0 -204
  254. package/src/commands/liberica/warehouses/delete.ts +0 -112
  255. package/src/commands/liberica/warehouses/disable.ts +0 -174
  256. package/src/commands/liberica/warehouses/enable.ts +0 -174
  257. package/src/commands/liberica/warehouses/get.ts +0 -101
  258. package/src/commands/liberica/warehouses/index.ts +0 -25
  259. package/src/commands/liberica/warehouses/list.ts +0 -136
  260. package/src/commands/liberica/warehouses/locations/create.ts +0 -209
  261. package/src/commands/liberica/warehouses/locations/delete.ts +0 -116
  262. package/src/commands/liberica/warehouses/locations/disable.ts +0 -174
  263. package/src/commands/liberica/warehouses/locations/enable.ts +0 -174
  264. package/src/commands/liberica/warehouses/locations/get.ts +0 -84
  265. package/src/commands/liberica/warehouses/locations/index.ts +0 -23
  266. package/src/commands/liberica/warehouses/locations/list.ts +0 -140
  267. package/src/commands/liberica/warehouses/locations/update.ts +0 -135
  268. package/src/commands/liberica/warehouses/update.ts +0 -142
  269. package/src/core/api/client.ts +0 -4443
  270. package/src/core/auth/token-manager.ts +0 -183
  271. package/src/core/config/manager.ts +0 -164
  272. package/src/index.ts +0 -35
  273. package/src/types/calendar.ts +0 -36
  274. package/src/types/client-contact.ts +0 -78
  275. package/src/types/client.ts +0 -115
  276. package/src/types/currency.ts +0 -90
  277. package/src/types/dict.ts +0 -121
  278. package/src/types/employee.ts +0 -102
  279. package/src/types/index.ts +0 -93
  280. package/src/types/location.ts +0 -66
  281. package/src/types/material.ts +0 -61
  282. package/src/types/mould-stock-in.ts +0 -82
  283. package/src/types/mould.ts +0 -74
  284. package/src/types/operation.ts +0 -72
  285. package/src/types/org.ts +0 -25
  286. package/src/types/position.ts +0 -24
  287. package/src/types/stock.ts +0 -161
  288. package/src/types/supplier-contact.ts +0 -78
  289. package/src/types/supplier.ts +0 -66
  290. package/src/types/team-issue.ts +0 -94
  291. package/src/types/team-project.ts +0 -74
  292. package/src/types/team-task.ts +0 -98
  293. package/src/types/team-work-log.ts +0 -87
  294. package/src/types/transfer-in-form.ts +0 -265
  295. package/src/types/transfer-out-form.ts +0 -290
  296. package/src/types/uom.ts +0 -60
  297. package/src/types/user.ts +0 -64
  298. package/src/types/warehouse.ts +0 -82
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ async function main() {
12
12
  program
13
13
  .name('barista')
14
14
  .description('Barista CLI - Bridge between AI agents and Liberica/Arabica')
15
- .version('0.1.10')
15
+ .version('0.1.12')
16
16
  .option('-e, --env <environment>', 'Target environment (dev|test|prod-cn|prod-jp)')
17
17
  .option('-t, --tenant <tenant>', 'Target tenant (for Liberica)')
18
18
  .option('--debug', 'Enable debug mode');
package/package.json CHANGED
@@ -1,19 +1,23 @@
1
1
  {
2
2
  "name": "@newpeak/barista-cli",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "AI Tools CLI for Liberica and Arabica services",
5
5
  "type": "module",
6
- "bin": "./bin/barista",
6
+ "bin": {
7
+ "barista": "./bin/barista"
8
+ },
7
9
  "scripts": {
8
10
  "build": "tsc",
9
11
  "dev": "tsc --watch",
10
- "start": "node ./bin/barista.js",
12
+ "start": "node ./bin/barista",
11
13
  "test": "vitest",
12
14
  "test:unit": "vitest run",
13
15
  "lint": "eslint src --ext .ts,.js",
14
16
  "format": "prettier --write src",
17
+ "prepare": "npm run build",
15
18
  "prepublishOnly": "npm run build"
16
19
  },
20
+ "files": ["dist", "bin", "package.json", "README.md"],
17
21
  "dependencies": {
18
22
  "commander": "^12.0.0",
19
23
  "axios": "^1.6.8",
@@ -1,184 +0,0 @@
1
- # Architecture Documentation
2
-
3
- ## Project Overview
4
-
5
- Barista CLI is an AI-native command-line tool that bridges AI agents (Claude Code, etc.) with the Liberica production management SaaS and Arabica sales platform. It provides a unified interface for managing production orders, products, and related operations across both services.
6
-
7
- ## Technical Stack
8
-
9
- | Component | Technology | Purpose |
10
- |-----------|------------|---------|
11
- | Language | TypeScript 5.4+ | Type safety, modern JS features |
12
- | CLI Framework | Commander.js 12 | Command parsing, help generation |
13
- | HTTP Client | Axios | API communication |
14
- | Auth Storage | Keytar | System keychain integration |
15
- | Config Storage | YAML (js-yaml) | Human-readable config files |
16
- | Output | Chalk + cli-table3 | Formatted CLI output |
17
- | Testing | Vitest | Unit and integration testing |
18
-
19
- ## Architecture Decisions
20
-
21
- ### 1. Direct HTTP Calls (NOT MCP)
22
-
23
- We use direct HTTP API calls instead of MCP (Model Context Protocol) for several reasons:
24
-
25
- - **Simplicity**: MCP adds unnecessary complexity for a CLI tool
26
- - **Control**: Direct HTTP gives full control over request/response handling
27
- - **Compatibility**: Works with any HTTP-capable environment
28
- - **Performance**: Lower overhead than protocol buffering
29
-
30
- ### 2. Token-Based Auth (NOT OAuth2)
31
-
32
- Token-based authentication was chosen over OAuth2 because:
33
-
34
- - **CLI-First**: OAuth2 flows are browser-based, not suited for CLI
35
- - **Simplicity**: Token storage and refresh is straightforward
36
- - **Security**: Tokens stored in system keychain, not files
37
- - **Backend Constraints**: Cannot modify backend authentication flow
38
-
39
- ### 3. JSON + Table Output (TTY Auto-Detection)
40
-
41
- Output format strategy:
42
-
43
- - **TTY Detected**: Show colored table output for human readability
44
- - **Pipe/Redirect**: Auto-switch to JSON for scripting and AI integration
45
- - **Explicit Flag**: `--json` flag forces JSON output regardless of TTY
46
-
47
- ## Multi-Environment Support
48
-
49
- Barista CLI supports four environments:
50
-
51
- | Environment | Liberica URL Pattern | Arabica URL |
52
- |-------------|---------------------|-------------|
53
- | dev | `{tenant}-dev.newpeaksh.com` | arabica-dev.newpeaksh.com |
54
- | test | `{tenant}-test.newpeaksh.com` | arabica-test.newpeaksh.com |
55
- | prod-cn | `{tenant}.newpeaksh.com` | www.newpeaksh.com |
56
- | prod-jp | `{tenant}.newpeakjp.com` | members.newpeakjp.com |
57
-
58
- ## Multi-Tenant Support
59
-
60
- Liberica is a multi-tenant system where each customer (tenant) has isolated data. The CLI supports:
61
-
62
- - **Tenant Switching**: `barista context use-tenant <name>`
63
- - **Per-Tenant Tokens**: Each tenant+environment combination has its own token
64
- - **URL Templating**: Tenant ID is injected into API URLs
65
-
66
- ## System Architecture
67
-
68
- ```
69
- ┌─────────────────────────────────────────────────────────────────┐
70
- │ Barista CLI │
71
- ├─────────────────────────────────────────────────────────────────┤
72
- │ bin/barista (entry point) │
73
- │ │ │
74
- │ ▼ │
75
- │ src/index.ts (main) │
76
- │ │ │
77
- │ ├── configManager ──────────────────► ~/.barista/config.yaml
78
- │ │ │
79
- │ ├── tokenManager ───────────────────► System Keychain │
80
- │ │ │
81
- │ ├── createContextCommand() │
82
- │ ├── createAuthCommand() │
83
- │ ├── createLibericaCommand() ────────► Liberica API │
84
- │ │ (Axios HTTP) │
85
- │ └── createArabicaCommand() ────────► Arabica API │
86
- │ (Axios HTTP) │
87
- └─────────────────────────────────────────────────────────────────┘
88
- ```
89
-
90
- ## Module Structure
91
-
92
- ```
93
- src/
94
- ├── index.ts # Main entry, Commander setup
95
- ├── commands/
96
- │ ├── context.ts # Context management commands
97
- │ ├── auth.ts # Authentication commands
98
- │ ├── liberica/
99
- │ │ └── index.ts # Liberica service commands
100
- │ └── arabica/
101
- │ └── index.ts # Arabica service commands
102
- ├── core/
103
- │ ├── config/
104
- │ │ └── manager.ts # Config loading/saving
105
- │ └── auth/
106
- │ └── token-manager.ts # Keychain token storage
107
- ├── types/
108
- │ └── index.ts # TypeScript interfaces
109
- └── utils/
110
- └── (formatters, validators, etc.)
111
- ```
112
-
113
- ## Constraints
114
-
115
- **Critical Constraint**: Cannot modify backend code
116
-
117
- - Liberica and Arabica backend systems are external and immutable
118
- - CLI must work within existing API contracts
119
- - No backend changes can be requested to accommodate CLI needs
120
- - API responses must be handled as-is
121
-
122
- ## Configuration File
123
-
124
- Config is stored at `~/.barista/config.yaml`:
125
-
126
- ```yaml
127
- defaults:
128
- env: dev
129
- tenant: default
130
- service: liberica
131
-
132
- environments:
133
- dev:
134
- liberica:
135
- baseUrl: "https://{tenant}-dev.newpeaksh.com"
136
- timeout: 30000
137
- arabica:
138
- baseUrl: "https://arabica-dev.newpeaksh.com"
139
- timeout: 30000
140
-
141
- output:
142
- format: table
143
- color: true
144
- timestamp: true
145
- ```
146
-
147
- ## Security Considerations
148
-
149
- 1. **Token Storage**: All tokens stored in system keychain, never in files
150
- 2. **Environment Isolation**: Each environment+service+tenant combination has separate token
151
- 3. **No Credential Logging**: Tokens never appear in logs or error messages
152
- 4. **Secure Defaults**: Config created with minimal defaults on first run
153
-
154
- ## Error Handling
155
-
156
- All API errors follow a standard response structure:
157
-
158
- ```typescript
159
- interface APIResponse<T> {
160
- success: boolean;
161
- data?: T;
162
- error?: {
163
- code: string;
164
- message: string;
165
- details?: unknown;
166
- };
167
- meta?: {
168
- requestId?: string;
169
- timestamp?: string;
170
- pagination?: PaginationInfo;
171
- };
172
- }
173
- ```
174
-
175
- ## Detailed Specifications
176
-
177
- For detailed command specifications, API schemas, and implementation details, refer to the plans in `.sisyphus/plans/`.
178
-
179
- ## Future Considerations
180
-
181
- - [ ] Add integration tests with mock servers
182
- - [ ] Support for config file templates
183
- - [ ] Interactive wizard for initial setup
184
- - [ ] Completion scripts for bash/zsh
package/docs/COMMANDS.md DELETED
@@ -1,352 +0,0 @@
1
- # Command Development Guide
2
-
3
- ## 完整命令参考
4
-
5
- 所有命令的完整清单(包括已实现和待开发)请查看 [命令参考](./commands/REFERENCE.md)。
6
-
7
- ## Command Naming Convention
8
-
9
- All Barista CLI commands follow a consistent naming pattern:
10
-
11
- ```
12
- barista <service> <resource> <action> [options]
13
- ```
14
-
15
- **Examples:**
16
- - `barista liberica orders list`
17
- - `barista liberica products search --keyword "coffee"`
18
- - `barista arabica members get 12345`
19
- - `barista context show`
20
-
21
- ## Command Structure
22
-
23
- ```
24
- barista
25
- ├── context # Context management
26
- │ ├── show
27
- │ ├── use-env
28
- │ └── use-tenant
29
- ├── auth # Authentication
30
- │ ├── login
31
- │ ├── status
32
- │ └── logout
33
- ├── liberica # Liberica service
34
- │ ├── orders
35
- │ ├── products
36
- │ └── production
37
- └── arabica # Arabica service
38
- ├── members
39
- ├── enterprises
40
- ├── products
41
- ├── subscriptions
42
- └── access
43
- ```
44
-
45
- ## Creating a New Command
46
-
47
- ### Step 1: Create Command File
48
-
49
- Create a new file in `src/commands/{service}/`:
50
-
51
- ```typescript
52
- // src/commands/liberica/orders.ts
53
- import { Command } from 'commander';
54
- import chalk from 'chalk';
55
- import { configManager } from '../../core/config/manager.js';
56
- import { tokenManager } from '../../core/auth/token-manager.js';
57
- import axios from 'axios';
58
-
59
- export function createOrdersCommand(): Command {
60
- const ordersCommand = new Command('orders');
61
- ordersCommand.description('Manage Liberica orders');
62
-
63
- // List subcommand
64
- ordersCommand
65
- .command('list')
66
- .description('List all orders')
67
- .option('--page <number>', 'Page number', '1')
68
- .option('--size <number>', 'Page size', '20')
69
- .option('--json', 'Output as JSON')
70
- .action(async (options) => {
71
- const context = configManager.getCurrentContext();
72
- const token = await tokenManager.getToken({
73
- service: 'liberica',
74
- environment: context.environment,
75
- tenant: context.tenant,
76
- });
77
-
78
- if (!token) {
79
- console.error(chalk.red('✗ Not logged in. Run "barista auth login" first.'));
80
- process.exit(1);
81
- }
82
-
83
- try {
84
- const baseUrl = configManager.getEnvironmentUrl('liberica', context.environment);
85
- const response = await axios.get(`${baseUrl}/api/v1/orders`, {
86
- headers: { Authorization: `Bearer ${token}` },
87
- params: { page: options.page, size: options.size },
88
- });
89
-
90
- if (options.json) {
91
- console.log(JSON.stringify(response.data, null, 2));
92
- } else {
93
- // Render table output
94
- console.log(chalk.bold('\n📋 Orders\n'));
95
- // ... table rendering logic
96
- }
97
- } catch (error) {
98
- console.error(chalk.red('✗ Failed to fetch orders:'), error.message);
99
- process.exit(1);
100
- }
101
- });
102
-
103
- return ordersCommand;
104
- }
105
- ```
106
-
107
- ### Step 2: Register in Parent index.ts
108
-
109
- Update `src/commands/liberica/index.ts`:
110
-
111
- ```typescript
112
- import { Command } from 'commander';
113
- import { createOrdersCommand } from './orders.js';
114
-
115
- export function createLibericaCommand(): Command {
116
- const libericaCommand = new Command('liberica');
117
- libericaCommand.description('Liberica production management operations');
118
-
119
- libericaCommand.addCommand(createOrdersCommand());
120
- // Add more subcommands here...
121
-
122
- return libericaCommand;
123
- }
124
- ```
125
-
126
- ### Step 3: Write Tests
127
-
128
- Create `tests/unit/commands/liberica/orders.test.ts`:
129
-
130
- ```typescript
131
- import { describe, it, expect, vi, beforeEach } from 'vitest';
132
- import { createOrdersCommand } from '../../../src/commands/liberica/orders.js';
133
-
134
- describe('liberica orders', () => {
135
- beforeEach(() => {
136
- vi.clearAllMocks();
137
- });
138
-
139
- it('should create orders command', () => {
140
- const command = createOrdersCommand();
141
- expect(command.name()).toBe('orders');
142
- });
143
- });
144
- ```
145
-
146
- ### Step 4: Verify
147
-
148
- ```bash
149
- npm run build
150
- npm test
151
- node ./bin/barista liberica orders --help
152
- ```
153
-
154
- ## Output Formatting Standards
155
-
156
- ### JSON Output
157
-
158
- Use `--json` flag for machine-readable output:
159
-
160
- ```bash
161
- barista liberica orders list --json
162
- ```
163
-
164
- Output:
165
- ```json
166
- {
167
- "success": true,
168
- "data": {
169
- "items": [...],
170
- "pagination": { "page": 1, "size": 20, "total": 100 }
171
- }
172
- }
173
- ```
174
-
175
- ### Table Output (TTY)
176
-
177
- For human-readable output when stdout is a terminal:
178
-
179
- ```typescript
180
- import chalk from 'chalk';
181
- import Table from 'cli-table3';
182
-
183
- function formatOrdersTable(orders: Order[]): void {
184
- const table = new Table({
185
- head: ['ID', 'Product', 'Quantity', 'Status', 'Created'],
186
- colWidths: [10, 30, 10, 15, 20],
187
- });
188
-
189
- for (const order of orders) {
190
- table.push([
191
- order.id,
192
- order.productName,
193
- order.quantity,
194
- formatStatus(order.status),
195
- order.createdAt,
196
- ]);
197
- }
198
-
199
- console.log(table.toString());
200
- }
201
-
202
- function formatStatus(status: string): string {
203
- const colors: Record<string, chalk.Chalk> = {
204
- pending: chalk.yellow,
205
- in_production: chalk.blue,
206
- completed: chalk.green,
207
- cancelled: chalk.red,
208
- };
209
- return colors[status] ? colors[status](status) : status;
210
- }
211
- ```
212
-
213
- ### Auto-Detection
214
-
215
- Detect output format automatically:
216
-
217
- ```typescript
218
- function shouldUseJson(): boolean {
219
- return process.stdout.isTTY === false || process.argv.includes('--json');
220
- }
221
- ```
222
-
223
- ## Error Handling Patterns
224
-
225
- ### API Errors
226
-
227
- ```typescript
228
- import { APIResponse } from '../../types/index.js';
229
-
230
- async function fetchOrders(): Promise<Order[]> {
231
- try {
232
- const response = await axios.get<APIResponse<Order[]>>('/api/orders');
233
-
234
- if (!response.data.success) {
235
- throw new Error(response.data.error?.message || 'Unknown error');
236
- }
237
-
238
- return response.data.data || [];
239
- } catch (error) {
240
- if (axios.isAxiosError(error)) {
241
- if (error.response) {
242
- // Server responded with error
243
- const status = error.response.status;
244
- if (status === 401) {
245
- throw new Error('Authentication failed. Run "barista auth login"');
246
- } else if (status === 403) {
247
- throw new Error('Access denied');
248
- }
249
- } else if (error.request) {
250
- // No response received
251
- throw new Error('Network error. Check your connection.');
252
- }
253
- }
254
- throw error;
255
- }
256
- }
257
- ```
258
-
259
- ### User Errors
260
-
261
- ```typescript
262
- function validateOrderId(id: string): number {
263
- const numericId = parseInt(id, 10);
264
- if (isNaN(numericId) || numericId <= 0) {
265
- console.error(chalk.red(`✗ Invalid order ID: ${id}`));
266
- process.exit(1);
267
- }
268
- return numericId;
269
- }
270
- ```
271
-
272
- ## Dry-Run Mode Implementation
273
-
274
- For destructive operations, implement dry-run:
275
-
276
- ```typescript
277
- ordersCommand
278
- .command('cancel <order-id>')
279
- .description('Cancel an order')
280
- .option('--dry-run', 'Preview without executing')
281
- .option('--confirm', 'Skip confirmation prompt')
282
- .action(async (orderId: string, options) => {
283
- const order = await fetchOrder(orderId);
284
-
285
- console.log(chalk.bold('\n🔍 Cancel Order Preview\n'));
286
- console.log(` ${chalk.gray('Order ID:')} ${orderId}`);
287
- console.log(` ${chalk.gray('Product:')} ${order.productName}`);
288
- console.log(` ${chalk.gray('Quantity:')} ${order.quantity}\n`);
289
-
290
- if (options.dryRun) {
291
- console.log(chalk.yellow('⚠ Dry-run mode: No changes made\n'));
292
- return;
293
- }
294
-
295
- if (!options.confirm) {
296
- const { confirmed } = await inquirer.prompt([
297
- { type: 'confirm', name: 'confirmed', message: 'Confirm cancellation?' },
298
- ]);
299
- if (!confirmed) {
300
- console.log(chalk.gray('Cancelled.'));
301
- return;
302
- }
303
- }
304
-
305
- await cancelOrder(orderId);
306
- console.log(chalk.green('✓ Order cancelled\n'));
307
- });
308
- ```
309
-
310
- ## Testing Commands
311
-
312
- ### Mocking Dependencies
313
-
314
- ```typescript
315
- import { describe, it, expect, vi } from 'vitest';
316
- import axios from 'axios';
317
-
318
- vi.mock('axios');
319
- const mockedAxios = vi.mocked(axios);
320
-
321
- describe('orders list', () => {
322
- it('should list orders successfully', async () => {
323
- mockedAxios.get.mockResolvedValue({
324
- data: {
325
- success: true,
326
- data: [
327
- { id: '1', productName: 'Coffee Machine', quantity: 10 },
328
- ],
329
- },
330
- });
331
-
332
- // Test implementation...
333
- });
334
- });
335
- ```
336
-
337
- ## Full Command Reference
338
-
339
- ### 已实现命令
340
-
341
- 查看 [命令参考](./commands/REFERENCE.md) 获取完整的命令清单和状态。
342
-
343
- ### 命令设计规范
344
-
345
- **新增命令必须先编写设计文档**,参考 `COMMAND_DESIGN_SPEC.md` 第2节模板,包含:
346
- - 后端接口引用(Controller、DTO位置)
347
- - CLI参数设计
348
- - 字段映射表
349
- - 错误码引用
350
- - 开发流程检查清单
351
-
352
- 所有待开发命令的状态和优先级请查看 [命令参考](./commands/REFERENCE.md)。