@miphamai/cli 0.5.0 → 0.5.1
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/bin/mipham +51 -24
- package/package.json +1 -1
- package/src/config/defaults.ts +2 -1
- package/src/tools/network/web-fetch.ts +1 -1
- package/src/ui/app.tsx +4 -2
- package/src/ui/commands.ts +2 -2
- package/src/workflow/sandbox.ts +7 -3
- package/dist/mipham +0 -0
package/bin/mipham
CHANGED
|
@@ -1,45 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Mipham Code
|
|
3
|
+
* Mipham Code — @miphamai/cli
|
|
4
4
|
* Multi-model open-core intelligent coding terminal by MiphamAI
|
|
5
5
|
* License: Apache-2.0 | https://mipham.ai/code
|
|
6
|
+
*
|
|
7
|
+
* Node.js wrapper: detects Bun and re-launches with it for the full
|
|
8
|
+
* interactive experience. Version and package name are read from
|
|
9
|
+
* package.json (single source of truth).
|
|
6
10
|
*/
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
import { spawnSync } from 'node:child_process'
|
|
13
|
+
import { readFileSync } from 'node:fs'
|
|
14
|
+
import { fileURLToPath } from 'node:url'
|
|
15
|
+
import path from 'node:path'
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// Node.js runtime — prompt to use Bun for best experience
|
|
16
|
-
const nodeVersion = process.versions.node
|
|
17
|
-
const [major] = nodeVersion.split('.').map(Number)
|
|
17
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
18
|
+
const pkg = JSON.parse(readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'))
|
|
19
|
+
const VERSION = pkg.version
|
|
20
|
+
const PKG_NAME = pkg.name
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
// ── Check whether Bun is available ──────────────────────────────────────────
|
|
23
|
+
function hasBun() {
|
|
24
|
+
try {
|
|
25
|
+
const result = spawnSync('bun', ['--version'], { stdio: 'pipe', timeout: 5000 })
|
|
26
|
+
return result.status === 0
|
|
27
|
+
} catch {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ── Bun available: re-launch with Bun for the full TUI ──────────────────────
|
|
33
|
+
if (hasBun()) {
|
|
34
|
+
const tsEntry = path.join(__dirname, 'mipham.ts')
|
|
35
|
+
const result = spawnSync('bun', ['run', tsEntry, ...process.argv.slice(2)], {
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
env: process.env,
|
|
38
|
+
})
|
|
39
|
+
process.exit(result.status ?? 0)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ── No Bun: show version info and install guidance ─────────────────────────
|
|
43
|
+
const nodeVersion = process.versions.node
|
|
44
|
+
const [major] = nodeVersion.split('.').map(Number)
|
|
45
|
+
|
|
46
|
+
if (!major || major < 22) {
|
|
47
|
+
process.stderr.write(`
|
|
21
48
|
\`mipham\` requires Node.js 22+ or Bun 1.2+.
|
|
22
49
|
|
|
23
50
|
Current Node.js: ${nodeVersion}
|
|
24
51
|
|
|
25
|
-
Quick install:
|
|
26
|
-
|
|
52
|
+
Quick install Bun:
|
|
53
|
+
curl -fsSL https://bun.sh/install | bash
|
|
54
|
+
|
|
55
|
+
Then run:
|
|
27
56
|
mipham
|
|
28
57
|
|
|
29
|
-
|
|
30
|
-
curl -fsSL https://mipham.ai/install.sh | bash
|
|
58
|
+
Docs: https://mipham.ai/code/docs
|
|
31
59
|
`)
|
|
32
|
-
|
|
33
|
-
|
|
60
|
+
process.exit(1)
|
|
61
|
+
}
|
|
34
62
|
|
|
35
|
-
|
|
36
|
-
\x1b[0;36m\x1b[1m✦ Mipham Code
|
|
37
|
-
\x1b[0;36m
|
|
63
|
+
process.stdout.write(`
|
|
64
|
+
\x1b[0;36m\x1b[1m✦ Mipham Code v${VERSION}\x1b[0m
|
|
65
|
+
\x1b[0;36m ${PKG_NAME} — Multi-model coding agent by MiphamAI\x1b[0m
|
|
38
66
|
|
|
39
67
|
\x1b[0;33m⚠ Bun runtime is recommended for the best Mipham Code experience.\x1b[0m
|
|
40
68
|
|
|
41
69
|
Quick install Bun:
|
|
42
|
-
\x1b[0;
|
|
70
|
+
\x1b[0;32mcurl -fsSL https://bun.sh/install | bash\x1b[0m
|
|
43
71
|
|
|
44
72
|
Then run:
|
|
45
73
|
\x1b[0;32mmipham\x1b[0m
|
|
@@ -47,5 +75,4 @@ Then run:
|
|
|
47
75
|
Install: \x1b[0;34mhttps://mipham.ai/code/install\x1b[0m
|
|
48
76
|
Docs: \x1b[0;34mhttps://mipham.ai/code/docs\x1b[0m
|
|
49
77
|
`)
|
|
50
|
-
|
|
51
|
-
}
|
|
78
|
+
process.exit(0)
|
package/package.json
CHANGED
package/src/config/defaults.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { MiphamConfig } from '../shared/index.ts'
|
|
2
2
|
import { DEFAULT_PROVIDERS } from '../shared/index.ts'
|
|
3
|
+
import { PACKAGE_VERSION } from '@mipham/shared'
|
|
3
4
|
|
|
4
5
|
export const DEFAULT_CONFIG: MiphamConfig = {
|
|
5
|
-
version:
|
|
6
|
+
version: PACKAGE_VERSION,
|
|
6
7
|
defaultProvider: 'anthropic',
|
|
7
8
|
defaultModel: 'claude-sonnet-4-6',
|
|
8
9
|
permission: 'auto',
|
|
@@ -28,7 +28,7 @@ export const webFetchTool: ToolDefinition = {
|
|
|
28
28
|
const timer = setTimeout(() => controller.abort(), 30_000) // 30s timeout
|
|
29
29
|
|
|
30
30
|
const response = await fetch(url, {
|
|
31
|
-
headers: { 'User-Agent': 'Mipham-Code/0.
|
|
31
|
+
headers: { 'User-Agent': 'Mipham-Code/0.5.0' },
|
|
32
32
|
redirect: 'follow',
|
|
33
33
|
signal: controller.signal,
|
|
34
34
|
})
|
package/src/ui/app.tsx
CHANGED
|
@@ -43,7 +43,9 @@ interface AgentProgress {
|
|
|
43
43
|
startTime: number
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
import { PACKAGE_VERSION } from '@mipham/shared'
|
|
47
|
+
|
|
48
|
+
const VERSION = PACKAGE_VERSION
|
|
47
49
|
|
|
48
50
|
type PermissionMode = 'auto' | 'ask' | 'bypass'
|
|
49
51
|
|
|
@@ -357,7 +359,7 @@ export function App({
|
|
|
357
359
|
<Text bold color="cyan">
|
|
358
360
|
Mipham Code
|
|
359
361
|
</Text>
|
|
360
|
-
<Text dimColor>
|
|
362
|
+
<Text dimColor> v{VERSION}</Text>
|
|
361
363
|
{sessionTitle ? (
|
|
362
364
|
<Text color="yellow"> — {sessionTitle}</Text>
|
|
363
365
|
) : (
|
package/src/ui/commands.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { QueryEngine } from '../core/engine'
|
|
|
8
8
|
import type { MiphamConfig } from '../shared/index.ts'
|
|
9
9
|
import type { SkillsLoader } from '../skills/loader'
|
|
10
10
|
import { McpClient } from '../mcp/client'
|
|
11
|
-
import { NPM_INSTALL_COMMAND, NPM_UPDATE_COMMAND } from '@mipham/shared'
|
|
11
|
+
import { NPM_INSTALL_COMMAND, NPM_UPDATE_COMMAND, PACKAGE_VERSION } from '@mipham/shared'
|
|
12
12
|
|
|
13
13
|
export interface CommandContext {
|
|
14
14
|
engine: QueryEngine
|
|
@@ -51,7 +51,7 @@ type CommandHandler = (
|
|
|
51
51
|
|
|
52
52
|
const helpCmd: CommandHandler = (_ctx) => ({
|
|
53
53
|
content: stripIndent`
|
|
54
|
-
Mipham Code
|
|
54
|
+
Mipham Code v${PACKAGE_VERSION} — Commands
|
|
55
55
|
|
|
56
56
|
── Session ──────────────────────────
|
|
57
57
|
/help Show this help
|
package/src/workflow/sandbox.ts
CHANGED
|
@@ -35,7 +35,9 @@ export function createSandbox(
|
|
|
35
35
|
throw new Error('Date.now() is disabled in workflow sandbox. Pass timestamps via args.')
|
|
36
36
|
}
|
|
37
37
|
const val = (OriginalDate as unknown as Record<string, unknown>)[prop as string]
|
|
38
|
-
return typeof val === 'function'
|
|
38
|
+
return typeof val === 'function'
|
|
39
|
+
? (val as (...args: unknown[]) => unknown).bind(OriginalDate)
|
|
40
|
+
: val
|
|
39
41
|
},
|
|
40
42
|
})
|
|
41
43
|
|
|
@@ -46,7 +48,7 @@ export function createSandbox(
|
|
|
46
48
|
throw new Error('Math.random() is disabled in workflow sandbox. Use a seed from args.')
|
|
47
49
|
}
|
|
48
50
|
const val = (Math as unknown as Record<string, unknown>)[prop as string]
|
|
49
|
-
return typeof val === 'function' ? (val as
|
|
51
|
+
return typeof val === 'function' ? (val as (...args: unknown[]) => unknown).bind(Math) : val
|
|
50
52
|
},
|
|
51
53
|
})
|
|
52
54
|
|
|
@@ -61,7 +63,9 @@ export function createSandbox(
|
|
|
61
63
|
throw new Error('crypto.randomUUID() is disabled in workflow sandbox.')
|
|
62
64
|
}
|
|
63
65
|
const val = (globalCrypto as Record<string, unknown>)[prop as string]
|
|
64
|
-
return typeof val === 'function'
|
|
66
|
+
return typeof val === 'function'
|
|
67
|
+
? (val as (...args: unknown[]) => unknown).bind(globalCrypto)
|
|
68
|
+
: val
|
|
65
69
|
},
|
|
66
70
|
})
|
|
67
71
|
}
|
package/dist/mipham
DELETED
|
Binary file
|