pybao-cli 1.3.3

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 (185) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +440 -0
  3. package/README.zh-CN.md +338 -0
  4. package/cli-acp.js +82 -0
  5. package/cli.js +105 -0
  6. package/dist/REPL-WPV32MTF.js +42 -0
  7. package/dist/REPL-WPV32MTF.js.map +7 -0
  8. package/dist/acp-75HO2LBV.js +1357 -0
  9. package/dist/acp-75HO2LBV.js.map +7 -0
  10. package/dist/agentsValidate-6Z57ARKC.js +373 -0
  11. package/dist/agentsValidate-6Z57ARKC.js.map +7 -0
  12. package/dist/ask-NXXXCGY4.js +125 -0
  13. package/dist/ask-NXXXCGY4.js.map +7 -0
  14. package/dist/autoUpdater-PJMGNPUG.js +17 -0
  15. package/dist/autoUpdater-PJMGNPUG.js.map +7 -0
  16. package/dist/chunk-27GYWUY2.js +72 -0
  17. package/dist/chunk-27GYWUY2.js.map +7 -0
  18. package/dist/chunk-3DFBSQIT.js +23 -0
  19. package/dist/chunk-3DFBSQIT.js.map +7 -0
  20. package/dist/chunk-3KNGJX7Q.js +794 -0
  21. package/dist/chunk-3KNGJX7Q.js.map +7 -0
  22. package/dist/chunk-3PDD7M4T.js +164 -0
  23. package/dist/chunk-3PDD7M4T.js.map +7 -0
  24. package/dist/chunk-3ZNSAB7B.js +515 -0
  25. package/dist/chunk-3ZNSAB7B.js.map +7 -0
  26. package/dist/chunk-4SNFQYCY.js +511 -0
  27. package/dist/chunk-4SNFQYCY.js.map +7 -0
  28. package/dist/chunk-4XPNRLJG.js +1609 -0
  29. package/dist/chunk-4XPNRLJG.js.map +7 -0
  30. package/dist/chunk-5P7HBXTD.js +12 -0
  31. package/dist/chunk-5P7HBXTD.js.map +7 -0
  32. package/dist/chunk-6RZIUY5K.js +191 -0
  33. package/dist/chunk-6RZIUY5K.js.map +7 -0
  34. package/dist/chunk-6WELHKDA.js +240 -0
  35. package/dist/chunk-6WELHKDA.js.map +7 -0
  36. package/dist/chunk-7AAE6EO2.js +145 -0
  37. package/dist/chunk-7AAE6EO2.js.map +7 -0
  38. package/dist/chunk-A3BVXXA3.js +47 -0
  39. package/dist/chunk-A3BVXXA3.js.map +7 -0
  40. package/dist/chunk-A6PUMROK.js +152 -0
  41. package/dist/chunk-A6PUMROK.js.map +7 -0
  42. package/dist/chunk-BH3Y62E3.js +11 -0
  43. package/dist/chunk-BH3Y62E3.js.map +7 -0
  44. package/dist/chunk-BJSWTHRM.js +16 -0
  45. package/dist/chunk-BJSWTHRM.js.map +7 -0
  46. package/dist/chunk-BQA2EOUU.js +124 -0
  47. package/dist/chunk-BQA2EOUU.js.map +7 -0
  48. package/dist/chunk-CZZKRPE2.js +19 -0
  49. package/dist/chunk-CZZKRPE2.js.map +7 -0
  50. package/dist/chunk-ERMQRV55.js +24 -0
  51. package/dist/chunk-ERMQRV55.js.map +7 -0
  52. package/dist/chunk-HB2P6645.js +34 -0
  53. package/dist/chunk-HB2P6645.js.map +7 -0
  54. package/dist/chunk-HIRIJ2LQ.js +1256 -0
  55. package/dist/chunk-HIRIJ2LQ.js.map +7 -0
  56. package/dist/chunk-ICTEVBLN.js +735 -0
  57. package/dist/chunk-ICTEVBLN.js.map +7 -0
  58. package/dist/chunk-JKGOGSFT.js +128 -0
  59. package/dist/chunk-JKGOGSFT.js.map +7 -0
  60. package/dist/chunk-JZDE77EH.js +836 -0
  61. package/dist/chunk-JZDE77EH.js.map +7 -0
  62. package/dist/chunk-M624LT6O.js +17 -0
  63. package/dist/chunk-M624LT6O.js.map +7 -0
  64. package/dist/chunk-OMELVAJD.js +96 -0
  65. package/dist/chunk-OMELVAJD.js.map +7 -0
  66. package/dist/chunk-OUXHGDLH.js +95 -0
  67. package/dist/chunk-OUXHGDLH.js.map +7 -0
  68. package/dist/chunk-PCXUZ6AT.js +249 -0
  69. package/dist/chunk-PCXUZ6AT.js.map +7 -0
  70. package/dist/chunk-Q24ZGKIE.js +1097 -0
  71. package/dist/chunk-Q24ZGKIE.js.map +7 -0
  72. package/dist/chunk-QBHEERCF.js +30254 -0
  73. package/dist/chunk-QBHEERCF.js.map +7 -0
  74. package/dist/chunk-QIHB5PYM.js +472 -0
  75. package/dist/chunk-QIHB5PYM.js.map +7 -0
  76. package/dist/chunk-RQVLBMP7.js +24 -0
  77. package/dist/chunk-RQVLBMP7.js.map +7 -0
  78. package/dist/chunk-SWYJOV5E.js +490 -0
  79. package/dist/chunk-SWYJOV5E.js.map +7 -0
  80. package/dist/chunk-T6GVXTNQ.js +21 -0
  81. package/dist/chunk-T6GVXTNQ.js.map +7 -0
  82. package/dist/chunk-T7GPUZVK.js +766 -0
  83. package/dist/chunk-T7GPUZVK.js.map +7 -0
  84. package/dist/chunk-TXFCNQDE.js +2934 -0
  85. package/dist/chunk-TXFCNQDE.js.map +7 -0
  86. package/dist/chunk-UNNVICVU.js +95 -0
  87. package/dist/chunk-UNNVICVU.js.map +7 -0
  88. package/dist/chunk-UUNVJZWA.js +515 -0
  89. package/dist/chunk-UUNVJZWA.js.map +7 -0
  90. package/dist/chunk-VRGR4ZTQ.js +49 -0
  91. package/dist/chunk-VRGR4ZTQ.js.map +7 -0
  92. package/dist/chunk-VTVTEE5N.js +2613 -0
  93. package/dist/chunk-VTVTEE5N.js.map +7 -0
  94. package/dist/chunk-WPTPPOYN.js +936 -0
  95. package/dist/chunk-WPTPPOYN.js.map +7 -0
  96. package/dist/chunk-XXFY63TM.js +196 -0
  97. package/dist/chunk-XXFY63TM.js.map +7 -0
  98. package/dist/chunk-Z3HMXDXP.js +654 -0
  99. package/dist/chunk-Z3HMXDXP.js.map +7 -0
  100. package/dist/chunk-ZJGXEWKF.js +138 -0
  101. package/dist/chunk-ZJGXEWKF.js.map +7 -0
  102. package/dist/cli-RFYBXM7F.js +3917 -0
  103. package/dist/cli-RFYBXM7F.js.map +7 -0
  104. package/dist/commands-YOXMODDO.js +46 -0
  105. package/dist/commands-YOXMODDO.js.map +7 -0
  106. package/dist/config-5OPX3H2K.js +81 -0
  107. package/dist/config-5OPX3H2K.js.map +7 -0
  108. package/dist/context-THRRBPFP.js +30 -0
  109. package/dist/context-THRRBPFP.js.map +7 -0
  110. package/dist/costTracker-ELNBZ2DN.js +19 -0
  111. package/dist/costTracker-ELNBZ2DN.js.map +7 -0
  112. package/dist/customCommands-4XOZH44N.js +25 -0
  113. package/dist/customCommands-4XOZH44N.js.map +7 -0
  114. package/dist/env-EL4KBHMB.js +22 -0
  115. package/dist/env-EL4KBHMB.js.map +7 -0
  116. package/dist/index.js +34 -0
  117. package/dist/index.js.map +7 -0
  118. package/dist/kodeAgentSessionId-PROTVRBR.js +13 -0
  119. package/dist/kodeAgentSessionId-PROTVRBR.js.map +7 -0
  120. package/dist/kodeAgentSessionLoad-UMPV7MC3.js +18 -0
  121. package/dist/kodeAgentSessionLoad-UMPV7MC3.js.map +7 -0
  122. package/dist/kodeAgentSessionResume-YJS4FVQM.js +16 -0
  123. package/dist/kodeAgentSessionResume-YJS4FVQM.js.map +7 -0
  124. package/dist/kodeAgentStreamJson-3T26CHCP.js +13 -0
  125. package/dist/kodeAgentStreamJson-3T26CHCP.js.map +7 -0
  126. package/dist/kodeAgentStreamJsonSession-BZS2VDCY.js +131 -0
  127. package/dist/kodeAgentStreamJsonSession-BZS2VDCY.js.map +7 -0
  128. package/dist/kodeAgentStructuredStdio-TNB6U6SP.js +10 -0
  129. package/dist/kodeAgentStructuredStdio-TNB6U6SP.js.map +7 -0
  130. package/dist/kodeHooks-VUAWIY2D.js +36 -0
  131. package/dist/kodeHooks-VUAWIY2D.js.map +7 -0
  132. package/dist/llm-A3BCM4Q2.js +3118 -0
  133. package/dist/llm-A3BCM4Q2.js.map +7 -0
  134. package/dist/llmLazy-ZJSRLZVD.js +15 -0
  135. package/dist/llmLazy-ZJSRLZVD.js.map +7 -0
  136. package/dist/loader-HZQBWO74.js +28 -0
  137. package/dist/loader-HZQBWO74.js.map +7 -0
  138. package/dist/mcp-XKOJ55B2.js +49 -0
  139. package/dist/mcp-XKOJ55B2.js.map +7 -0
  140. package/dist/mentionProcessor-ANYU5MLF.js +211 -0
  141. package/dist/mentionProcessor-ANYU5MLF.js.map +7 -0
  142. package/dist/messages-75DL5XBP.js +63 -0
  143. package/dist/messages-75DL5XBP.js.map +7 -0
  144. package/dist/model-OPJGJZRC.js +30 -0
  145. package/dist/model-OPJGJZRC.js.map +7 -0
  146. package/dist/openai-DT54BAFP.js +29 -0
  147. package/dist/openai-DT54BAFP.js.map +7 -0
  148. package/dist/outputStyles-TPFVI52O.js +28 -0
  149. package/dist/outputStyles-TPFVI52O.js.map +7 -0
  150. package/dist/package.json +4 -0
  151. package/dist/pluginRuntime-W74PYSZ4.js +218 -0
  152. package/dist/pluginRuntime-W74PYSZ4.js.map +7 -0
  153. package/dist/pluginValidation-FALYRVI2.js +17 -0
  154. package/dist/pluginValidation-FALYRVI2.js.map +7 -0
  155. package/dist/prompts-J4TPRMJ3.js +48 -0
  156. package/dist/prompts-J4TPRMJ3.js.map +7 -0
  157. package/dist/query-K3QKBVDN.js +50 -0
  158. package/dist/query-K3QKBVDN.js.map +7 -0
  159. package/dist/responsesStreaming-HMB74TRD.js +10 -0
  160. package/dist/responsesStreaming-HMB74TRD.js.map +7 -0
  161. package/dist/ripgrep-XJGSUBG7.js +17 -0
  162. package/dist/ripgrep-XJGSUBG7.js.map +7 -0
  163. package/dist/skillMarketplace-AUGKNCPW.js +37 -0
  164. package/dist/skillMarketplace-AUGKNCPW.js.map +7 -0
  165. package/dist/state-DQYRXKTG.js +16 -0
  166. package/dist/state-DQYRXKTG.js.map +7 -0
  167. package/dist/theme-MS5HDUBJ.js +14 -0
  168. package/dist/theme-MS5HDUBJ.js.map +7 -0
  169. package/dist/toolPermissionContext-GYD5LYFK.js +17 -0
  170. package/dist/toolPermissionContext-GYD5LYFK.js.map +7 -0
  171. package/dist/toolPermissionSettings-4MPZVYDR.js +18 -0
  172. package/dist/toolPermissionSettings-4MPZVYDR.js.map +7 -0
  173. package/dist/tools-QW6SIJLJ.js +47 -0
  174. package/dist/tools-QW6SIJLJ.js.map +7 -0
  175. package/dist/userInput-F2PGBRFU.js +311 -0
  176. package/dist/userInput-F2PGBRFU.js.map +7 -0
  177. package/dist/uuid-GYYCQ6QK.js +9 -0
  178. package/dist/uuid-GYYCQ6QK.js.map +7 -0
  179. package/dist/yoga.wasm +0 -0
  180. package/package.json +136 -0
  181. package/scripts/binary-utils.cjs +62 -0
  182. package/scripts/cli-acp-wrapper.cjs +82 -0
  183. package/scripts/cli-wrapper.cjs +105 -0
  184. package/scripts/postinstall.js +144 -0
  185. package/yoga.wasm +0 -0
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('node:fs')
4
+ const path = require('node:path')
5
+ const { spawnSync } = require('node:child_process')
6
+
7
+ function findPackageRoot(startDir) {
8
+ let dir = startDir
9
+ for (let i = 0; i < 25; i++) {
10
+ if (fs.existsSync(path.join(dir, 'package.json'))) return dir
11
+ const parent = path.dirname(dir)
12
+ if (parent === dir) break
13
+ dir = parent
14
+ }
15
+ return startDir
16
+ }
17
+
18
+ function readPackageJson(packageRoot) {
19
+ try {
20
+ const p = path.join(packageRoot, 'package.json')
21
+ return JSON.parse(fs.readFileSync(p, 'utf8'))
22
+ } catch {
23
+ return null
24
+ }
25
+ }
26
+
27
+ function hasFlag(flag) {
28
+ return process.argv.includes(flag)
29
+ }
30
+
31
+ function printHelpLite() {
32
+ process.stdout.write(
33
+ `Usage: kode [options] [command] [prompt]\n\n` +
34
+ `Common options:\n` +
35
+ ` -h, --help Show full help\n` +
36
+ ` -v, --version Show version\n` +
37
+ ` -p, --print Print response and exit (non-interactive)\n` +
38
+ ` -c, --cwd <cwd> Set working directory\n`,
39
+ )
40
+ }
41
+
42
+ function run(cmd, args) {
43
+ const result = spawnSync(cmd, args, {
44
+ stdio: 'inherit',
45
+ env: { ...process.env, KODE_PACKAGED: process.env.KODE_PACKAGED || '1' },
46
+ })
47
+ if (result.error) {
48
+ throw result.error
49
+ }
50
+ process.exit(typeof result.status === 'number' ? result.status : 1)
51
+ }
52
+
53
+ function main() {
54
+ const packageRoot = findPackageRoot(__dirname)
55
+ const pkg = readPackageJson(packageRoot)
56
+ const version = pkg?.version || ''
57
+ const { getCachedBinaryPath } = require(path.join(
58
+ packageRoot,
59
+ 'scripts',
60
+ 'binary-utils.cjs',
61
+ ))
62
+
63
+ if (hasFlag('--help-lite')) {
64
+ printHelpLite()
65
+ process.exit(0)
66
+ }
67
+
68
+ if (hasFlag('--version') || hasFlag('-v')) {
69
+ process.stdout.write(`${version}\n`)
70
+ process.exit(0)
71
+ }
72
+
73
+ // 1) Prefer native binary (Windows OOTB, no Bun required)
74
+ if (version) {
75
+ const binPath = getCachedBinaryPath({ version })
76
+ if (fs.existsSync(binPath)) {
77
+ run(binPath, process.argv.slice(2))
78
+ }
79
+ }
80
+
81
+ // 2) Fallback: Node.js runtime (npm install should work without Bun)
82
+ const distEntry = path.join(packageRoot, 'dist', 'index.js')
83
+ if (fs.existsSync(distEntry)) {
84
+ run(process.execPath, [distEntry, ...process.argv.slice(2)])
85
+ }
86
+
87
+ // 3) Final fallback: explain what to do
88
+ process.stderr.write(
89
+ [
90
+ '❌ Kode is not runnable on this system.',
91
+ '',
92
+ 'Tried:',
93
+ '- Native binary (postinstall download)',
94
+ '- Node.js runtime fallback',
95
+ '',
96
+ 'Fix:',
97
+ '- Reinstall (ensure network access), or set KODE_BINARY_BASE_URL to a mirror',
98
+ '- Or download a standalone binary from GitHub Releases',
99
+ '',
100
+ ].join('\n'),
101
+ )
102
+ process.exit(1)
103
+ }
104
+
105
+ main()
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Postinstall responsibilities:
4
+ // - Best-effort download of the platform binary to a user-writable cache (Windows OOTB).
5
+ // - Never fail installation (script should be non-blocking and robust).
6
+
7
+ const fs = require('node:fs')
8
+ const path = require('node:path')
9
+ const https = require('node:https')
10
+ const { chmodSync } = require('node:fs')
11
+
12
+ const {
13
+ getCachedBinaryPath,
14
+ getGithubReleaseBinaryUrl,
15
+ getPlatformArch,
16
+ } = require('./binary-utils.cjs')
17
+
18
+ function safeLog(line) {
19
+ try {
20
+ console.log(line)
21
+ } catch {}
22
+ }
23
+
24
+ function safeWarn(line) {
25
+ try {
26
+ console.warn(line)
27
+ } catch {}
28
+ }
29
+
30
+ function readPackageJson() {
31
+ try {
32
+ const pkgPath = path.join(process.cwd(), 'package.json')
33
+ return JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
34
+ } catch {
35
+ return null
36
+ }
37
+ }
38
+
39
+ function ensureDir(dirPath) {
40
+ fs.mkdirSync(dirPath, { recursive: true })
41
+ }
42
+
43
+ function downloadFile(url, destPath, redirectCount = 0) {
44
+ return new Promise((resolve, reject) => {
45
+ if (redirectCount > 8) {
46
+ reject(new Error('Too many redirects'))
47
+ return
48
+ }
49
+
50
+ const req = https.get(
51
+ url,
52
+ {
53
+ headers: {
54
+ 'User-Agent': '@shareai-lab/kode postinstall',
55
+ Accept: 'application/octet-stream',
56
+ },
57
+ },
58
+ res => {
59
+ const status = res.statusCode || 0
60
+ const location = res.headers.location
61
+ if (status >= 300 && status < 400 && location) {
62
+ res.resume()
63
+ resolve(downloadFile(location, destPath, redirectCount + 1))
64
+ return
65
+ }
66
+
67
+ if (status !== 200) {
68
+ res.resume()
69
+ reject(new Error(`HTTP ${status}`))
70
+ return
71
+ }
72
+
73
+ const tmpPath = `${destPath}.tmp-${process.pid}`
74
+ const file = fs.createWriteStream(tmpPath)
75
+ res.pipe(file)
76
+ file.on('finish', () => {
77
+ file.close(() => {
78
+ fs.renameSync(tmpPath, destPath)
79
+ resolve()
80
+ })
81
+ })
82
+ file.on('error', err => {
83
+ try { fs.unlinkSync(tmpPath) } catch {}
84
+ reject(err)
85
+ })
86
+ },
87
+ )
88
+
89
+ req.on('error', reject)
90
+ })
91
+ }
92
+
93
+ async function maybeInstallBinary() {
94
+ if (process.env.KODE_SKIP_BINARY_DOWNLOAD) {
95
+ return
96
+ }
97
+
98
+ const pkg = readPackageJson()
99
+ const version = pkg?.version
100
+ if (!version) return
101
+
102
+ const platformArch = getPlatformArch()
103
+ const dest = getCachedBinaryPath({ version })
104
+ if (fs.existsSync(dest)) {
105
+ return
106
+ }
107
+
108
+ try {
109
+ ensureDir(path.dirname(dest))
110
+ } catch {
111
+ return
112
+ }
113
+
114
+ const url = getGithubReleaseBinaryUrl({ version })
115
+ safeLog(`📦 Kode: installing native binary for ${platformArch} (v${version})`)
116
+
117
+ try {
118
+ await downloadFile(url, dest)
119
+ if (process.platform !== 'win32') {
120
+ try {
121
+ chmodSync(dest, 0o755)
122
+ } catch {}
123
+ }
124
+ safeLog(`✅ Kode: native binary ready at ${dest}`)
125
+ } catch (err) {
126
+ safeWarn(`⚠️ Kode: could not download native binary (${platformArch})`)
127
+ safeWarn(` URL: ${url}`)
128
+ safeWarn(
129
+ ` Reason: ${err instanceof Error ? err.message : String(err)}`,
130
+ )
131
+ safeWarn(` This is non-fatal. pyb-ts will fall back to Bun if available.`)
132
+ }
133
+ }
134
+
135
+ async function postinstallNotice() {
136
+ safeLog('✅ @shareai-lab/kode installed. Commands available: kode, kwa, kd')
137
+ safeLog(' If shell cannot find them, reload your terminal or reinstall globally:')
138
+ safeLog(' npm i -g @shareai-lab/kode (or use: npx @shareai-lab/kode)')
139
+ await maybeInstallBinary()
140
+ }
141
+
142
+ if (process.env.npm_lifecycle_event === 'postinstall') {
143
+ postinstallNotice().catch(() => {})
144
+ }
package/yoga.wasm ADDED
Binary file