foliko 2.0.22 → 2.0.23
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/.editorconfig +56 -56
- package/.lintstagedrc +7 -7
- package/.prettierignore +29 -29
- package/.prettierrc +11 -11
- package/Dockerfile +63 -63
- package/install.ps1 +129 -129
- package/install.sh +121 -121
- package/package.json +2 -5
- package/plugins/core/workflow/context.js +941 -941
- package/plugins/core/workflow/engine.js +66 -66
- package/plugins/core/workflow/js-runner.js +318 -318
- package/plugins/core/workflow/json-runner.js +323 -323
- package/plugins/core/workflow/stages/choice.js +74 -74
- package/plugins/core/workflow/stages/each.js +123 -123
- package/plugins/core/workflow/stages/parallel.js +69 -69
- package/skills/find-skills/SKILL.md +133 -133
- package/src/agent/chat.js +188 -221
- package/src/agent/sub.js +28 -25
- package/src/agent/tool-loop.js +648 -0
- package/src/llm/provider.js +12 -28
- package/src/plugin/base.js +17 -14
- package/src/plugin/manager.js +19 -0
- package/tests/core/chat-tool.test.js +187 -187
- package/tests/core/disable-thinking.test.js +64 -0
- package/tests/core/reasoning-content.test.js +129 -0
- package/tests/core/strip-stale-tool-calls.test.js +154 -0
- package/tests/core/tool-loop.test.js +208 -0
package/.editorconfig
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
# EditorConfig is awesome: https://EditorConfig.org
|
|
2
|
-
|
|
3
|
-
# top-most EditorConfig file
|
|
4
|
-
root = true
|
|
5
|
-
|
|
6
|
-
# 代码文件
|
|
7
|
-
[*]
|
|
8
|
-
charset = utf-8
|
|
9
|
-
end_of_line = lf
|
|
10
|
-
insert_final_newline = true
|
|
11
|
-
trim_trailing_whitespace = true
|
|
12
|
-
|
|
13
|
-
# JavaScript / Node.js
|
|
14
|
-
[*.{js,jsx,mjs,cjs}]
|
|
15
|
-
indent_style = space
|
|
16
|
-
indent_size = 2
|
|
17
|
-
|
|
18
|
-
# TypeScript
|
|
19
|
-
[*.{ts,tsx}]
|
|
20
|
-
indent_style = space
|
|
21
|
-
indent_size = 2
|
|
22
|
-
|
|
23
|
-
# JSON
|
|
24
|
-
[*.json]
|
|
25
|
-
indent_style = space
|
|
26
|
-
indent_size = 2
|
|
27
|
-
|
|
28
|
-
# YAML
|
|
29
|
-
[*.{yaml,yml}]
|
|
30
|
-
indent_style = space
|
|
31
|
-
indent_size = 2
|
|
32
|
-
|
|
33
|
-
# Markdown
|
|
34
|
-
[*.md]
|
|
35
|
-
trim_trailing_whitespace = false
|
|
36
|
-
indent_style = space
|
|
37
|
-
indent_size = 2
|
|
38
|
-
|
|
39
|
-
# Shell
|
|
40
|
-
[*.sh]
|
|
41
|
-
indent_style = space
|
|
42
|
-
indent_size = 2
|
|
43
|
-
|
|
44
|
-
# PowerShell
|
|
45
|
-
[*.ps1]
|
|
46
|
-
indent_style = space
|
|
47
|
-
indent_size = 4
|
|
48
|
-
|
|
49
|
-
# Dockerfile
|
|
50
|
-
[Dockerfile]
|
|
51
|
-
indent_style = space
|
|
52
|
-
indent_size = 4
|
|
53
|
-
|
|
54
|
-
# Makefile
|
|
55
|
-
[Makefile]
|
|
56
|
-
indent_style = tab
|
|
1
|
+
# EditorConfig is awesome: https://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
# 代码文件
|
|
7
|
+
[*]
|
|
8
|
+
charset = utf-8
|
|
9
|
+
end_of_line = lf
|
|
10
|
+
insert_final_newline = true
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
|
|
13
|
+
# JavaScript / Node.js
|
|
14
|
+
[*.{js,jsx,mjs,cjs}]
|
|
15
|
+
indent_style = space
|
|
16
|
+
indent_size = 2
|
|
17
|
+
|
|
18
|
+
# TypeScript
|
|
19
|
+
[*.{ts,tsx}]
|
|
20
|
+
indent_style = space
|
|
21
|
+
indent_size = 2
|
|
22
|
+
|
|
23
|
+
# JSON
|
|
24
|
+
[*.json]
|
|
25
|
+
indent_style = space
|
|
26
|
+
indent_size = 2
|
|
27
|
+
|
|
28
|
+
# YAML
|
|
29
|
+
[*.{yaml,yml}]
|
|
30
|
+
indent_style = space
|
|
31
|
+
indent_size = 2
|
|
32
|
+
|
|
33
|
+
# Markdown
|
|
34
|
+
[*.md]
|
|
35
|
+
trim_trailing_whitespace = false
|
|
36
|
+
indent_style = space
|
|
37
|
+
indent_size = 2
|
|
38
|
+
|
|
39
|
+
# Shell
|
|
40
|
+
[*.sh]
|
|
41
|
+
indent_style = space
|
|
42
|
+
indent_size = 2
|
|
43
|
+
|
|
44
|
+
# PowerShell
|
|
45
|
+
[*.ps1]
|
|
46
|
+
indent_style = space
|
|
47
|
+
indent_size = 4
|
|
48
|
+
|
|
49
|
+
# Dockerfile
|
|
50
|
+
[Dockerfile]
|
|
51
|
+
indent_style = space
|
|
52
|
+
indent_size = 4
|
|
53
|
+
|
|
54
|
+
# Makefile
|
|
55
|
+
[Makefile]
|
|
56
|
+
indent_style = tab
|
package/.lintstagedrc
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"*.{js,jsx,ts,tsx}": ["prettier --write", "git add"],
|
|
3
|
-
"*.{json,yaml,yml}": ["prettier --write", "git add"],
|
|
4
|
-
"*.{md,mdx}": ["prettier --write", "git add"],
|
|
5
|
-
"*.{css,scss,less}": ["prettier --write", "git add"],
|
|
6
|
-
"*.{html,svg}": ["prettier --write", "git add"]
|
|
7
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"*.{js,jsx,ts,tsx}": ["prettier --write", "git add"],
|
|
3
|
+
"*.{json,yaml,yml}": ["prettier --write", "git add"],
|
|
4
|
+
"*.{md,mdx}": ["prettier --write", "git add"],
|
|
5
|
+
"*.{css,scss,less}": ["prettier --write", "git add"],
|
|
6
|
+
"*.{html,svg}": ["prettier --write", "git add"]
|
|
7
|
+
}
|
package/.prettierignore
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# 依赖
|
|
2
|
-
node_modules/
|
|
3
|
-
pnpm-lock.yaml
|
|
4
|
-
yarn.lock
|
|
5
|
-
package-lock.json
|
|
6
|
-
|
|
7
|
-
# 构建输出
|
|
8
|
-
dist/
|
|
9
|
-
build/
|
|
10
|
-
out/
|
|
11
|
-
|
|
12
|
-
# 插件目录(第三方代码)
|
|
13
|
-
plugins/
|
|
14
|
-
|
|
15
|
-
# 测试报告
|
|
16
|
-
reports/
|
|
17
|
-
test_report.md
|
|
18
|
-
|
|
19
|
-
# 配置文件(不需要格式化)
|
|
20
|
-
.env
|
|
21
|
-
.env.example
|
|
22
|
-
|
|
23
|
-
# 静态资源
|
|
24
|
-
images/
|
|
25
|
-
audio/
|
|
26
|
-
public/
|
|
27
|
-
|
|
28
|
-
# 锁文件
|
|
29
|
-
*.lock
|
|
1
|
+
# 依赖
|
|
2
|
+
node_modules/
|
|
3
|
+
pnpm-lock.yaml
|
|
4
|
+
yarn.lock
|
|
5
|
+
package-lock.json
|
|
6
|
+
|
|
7
|
+
# 构建输出
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
out/
|
|
11
|
+
|
|
12
|
+
# 插件目录(第三方代码)
|
|
13
|
+
plugins/
|
|
14
|
+
|
|
15
|
+
# 测试报告
|
|
16
|
+
reports/
|
|
17
|
+
test_report.md
|
|
18
|
+
|
|
19
|
+
# 配置文件(不需要格式化)
|
|
20
|
+
.env
|
|
21
|
+
.env.example
|
|
22
|
+
|
|
23
|
+
# 静态资源
|
|
24
|
+
images/
|
|
25
|
+
audio/
|
|
26
|
+
public/
|
|
27
|
+
|
|
28
|
+
# 锁文件
|
|
29
|
+
*.lock
|
package/.prettierrc
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"semi": true,
|
|
3
|
-
"singleQuote": true,
|
|
4
|
-
"tabWidth": 2,
|
|
5
|
-
"trailingComma": "es5",
|
|
6
|
-
"printWidth": 100,
|
|
7
|
-
"bracketSpacing": true,
|
|
8
|
-
"arrowParens": "always",
|
|
9
|
-
"endOfLine": "lf",
|
|
10
|
-
"plugins": []
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"semi": true,
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"tabWidth": 2,
|
|
5
|
+
"trailingComma": "es5",
|
|
6
|
+
"printWidth": 100,
|
|
7
|
+
"bracketSpacing": true,
|
|
8
|
+
"arrowParens": "always",
|
|
9
|
+
"endOfLine": "lf",
|
|
10
|
+
"plugins": []
|
|
11
|
+
}
|
package/Dockerfile
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# ========== Foliko - 插件化 Agent 框架 ==========
|
|
2
|
-
# 基于 Node.js 20 LTS
|
|
3
|
-
|
|
4
|
-
FROM node:25-slim
|
|
5
|
-
|
|
6
|
-
# 安装无头浏览器(Chromium)和构建工具
|
|
7
|
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
8
|
-
build-essential \
|
|
9
|
-
python3 \
|
|
10
|
-
python3-pip \
|
|
11
|
-
curl \
|
|
12
|
-
git \
|
|
13
|
-
wget \
|
|
14
|
-
gnupg \
|
|
15
|
-
# Chromium 及依赖
|
|
16
|
-
chromium \
|
|
17
|
-
chromium-sandbox \
|
|
18
|
-
libnss3 \
|
|
19
|
-
libatk1.0-0 \
|
|
20
|
-
libatk-bridge2.0-0 \
|
|
21
|
-
libcups2 \
|
|
22
|
-
libdrm2 \
|
|
23
|
-
libxkbcommon0 \
|
|
24
|
-
libxcomposite1 \
|
|
25
|
-
libxdamage1 \
|
|
26
|
-
libxfixes3 \
|
|
27
|
-
libxrandr2 \
|
|
28
|
-
libgbm1 \
|
|
29
|
-
libasound2 \
|
|
30
|
-
libpango-1.0-0 \
|
|
31
|
-
libpangocairo-1.0-0 \
|
|
32
|
-
libgtk-3-0 \
|
|
33
|
-
fonts-liberation \
|
|
34
|
-
xdg-utils \
|
|
35
|
-
&& rm -rf /var/lib/apt/lists/* \
|
|
36
|
-
&& ln -sf /usr/bin/python3 /usr/bin/python \
|
|
37
|
-
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
|
38
|
-
|
|
39
|
-
# 设置 Chromium 环境变量(无头模式运行)
|
|
40
|
-
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
|
41
|
-
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
42
|
-
ENV CHROME_BIN=/usr/bin/chromium
|
|
43
|
-
|
|
44
|
-
# 安装 uv(快速的 Python 包管理器)
|
|
45
|
-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
46
|
-
ENV PATH="/root/.local/bin:$PATH"
|
|
47
|
-
|
|
48
|
-
# 设置工作目录
|
|
49
|
-
WORKDIR /app
|
|
50
|
-
|
|
51
|
-
# 全局安装 foliko CLI
|
|
52
|
-
# RUN npm install -g foliko
|
|
53
|
-
|
|
54
|
-
# 暴露端口
|
|
55
|
-
# 3000: Web 服务端口
|
|
56
|
-
EXPOSE 3000
|
|
57
|
-
|
|
58
|
-
# 环境变量(可以在 docker-compose 或运行时覆盖)
|
|
59
|
-
ENV NODE_ENV=production
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# 默认命令:运行聊天界面
|
|
63
|
-
# CMD ["foliko", "chat"]
|
|
1
|
+
# ========== Foliko - 插件化 Agent 框架 ==========
|
|
2
|
+
# 基于 Node.js 20 LTS
|
|
3
|
+
|
|
4
|
+
FROM node:25-slim
|
|
5
|
+
|
|
6
|
+
# 安装无头浏览器(Chromium)和构建工具
|
|
7
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
8
|
+
build-essential \
|
|
9
|
+
python3 \
|
|
10
|
+
python3-pip \
|
|
11
|
+
curl \
|
|
12
|
+
git \
|
|
13
|
+
wget \
|
|
14
|
+
gnupg \
|
|
15
|
+
# Chromium 及依赖
|
|
16
|
+
chromium \
|
|
17
|
+
chromium-sandbox \
|
|
18
|
+
libnss3 \
|
|
19
|
+
libatk1.0-0 \
|
|
20
|
+
libatk-bridge2.0-0 \
|
|
21
|
+
libcups2 \
|
|
22
|
+
libdrm2 \
|
|
23
|
+
libxkbcommon0 \
|
|
24
|
+
libxcomposite1 \
|
|
25
|
+
libxdamage1 \
|
|
26
|
+
libxfixes3 \
|
|
27
|
+
libxrandr2 \
|
|
28
|
+
libgbm1 \
|
|
29
|
+
libasound2 \
|
|
30
|
+
libpango-1.0-0 \
|
|
31
|
+
libpangocairo-1.0-0 \
|
|
32
|
+
libgtk-3-0 \
|
|
33
|
+
fonts-liberation \
|
|
34
|
+
xdg-utils \
|
|
35
|
+
&& rm -rf /var/lib/apt/lists/* \
|
|
36
|
+
&& ln -sf /usr/bin/python3 /usr/bin/python \
|
|
37
|
+
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
|
38
|
+
|
|
39
|
+
# 设置 Chromium 环境变量(无头模式运行)
|
|
40
|
+
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
|
41
|
+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
42
|
+
ENV CHROME_BIN=/usr/bin/chromium
|
|
43
|
+
|
|
44
|
+
# 安装 uv(快速的 Python 包管理器)
|
|
45
|
+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
46
|
+
ENV PATH="/root/.local/bin:$PATH"
|
|
47
|
+
|
|
48
|
+
# 设置工作目录
|
|
49
|
+
WORKDIR /app
|
|
50
|
+
|
|
51
|
+
# 全局安装 foliko CLI
|
|
52
|
+
# RUN npm install -g foliko
|
|
53
|
+
|
|
54
|
+
# 暴露端口
|
|
55
|
+
# 3000: Web 服务端口
|
|
56
|
+
EXPOSE 3000
|
|
57
|
+
|
|
58
|
+
# 环境变量(可以在 docker-compose 或运行时覆盖)
|
|
59
|
+
ENV NODE_ENV=production
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# 默认命令:运行聊天界面
|
|
63
|
+
# CMD ["foliko", "chat"]
|
package/install.ps1
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
# Foliko Installer
|
|
2
|
-
|
|
3
|
-
# Fix execution policy first
|
|
4
|
-
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force -ErrorAction SilentlyContinue
|
|
5
|
-
|
|
6
|
-
Write-Host "Foliko Installer"
|
|
7
|
-
Write-Host "================="
|
|
8
|
-
Write-Host ""
|
|
9
|
-
|
|
10
|
-
# Refresh PATH
|
|
11
|
-
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
12
|
-
|
|
13
|
-
# ============ Check/Install Node.js ============
|
|
14
|
-
Write-Host "Checking Node.js..."
|
|
15
|
-
if (Get-Command node -ErrorAction SilentlyContinue) {
|
|
16
|
-
Write-Host "Node.js installed: $(node --version)" -ForegroundColor Green
|
|
17
|
-
} else {
|
|
18
|
-
Write-Host "Node.js not found, installing..." -ForegroundColor Yellow
|
|
19
|
-
|
|
20
|
-
$nodeUrl = "https://nodejs.org/dist/v20.11.0/node-v20.11.0-x64.msi"
|
|
21
|
-
$nodeInstaller = "$env:TEMP\node-installer.msi"
|
|
22
|
-
|
|
23
|
-
Write-Host "Downloading Node.js..." -ForegroundColor Cyan
|
|
24
|
-
Invoke-WebRequest -Uri $nodeUrl -OutFile $nodeInstaller -UseBasicParsing
|
|
25
|
-
|
|
26
|
-
Write-Host "Installing Node.js (may require admin)..." -ForegroundColor Cyan
|
|
27
|
-
Start-Process msiexec.exe -ArgumentList "/i", $nodeInstaller, "/quiet", "/norestart" -Wait
|
|
28
|
-
|
|
29
|
-
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
30
|
-
Start-Sleep -Seconds 3
|
|
31
|
-
|
|
32
|
-
if (Get-Command node -ErrorAction SilentlyContinue) {
|
|
33
|
-
Write-Host "Node.js installed: $(node --version)" -ForegroundColor Green
|
|
34
|
-
Remove-Item $nodeInstaller -Force -ErrorAction SilentlyContinue
|
|
35
|
-
} else {
|
|
36
|
-
Write-Host "Node.js installation failed" -ForegroundColor Red
|
|
37
|
-
Write-Host "Download manually: https://nodejs.org/" -ForegroundColor Yellow
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
Write-Host ""
|
|
41
|
-
|
|
42
|
-
# ============ Check/Install Python ============
|
|
43
|
-
Write-Host "Checking Python..."
|
|
44
|
-
if (Get-Command python -ErrorAction SilentlyContinue) {
|
|
45
|
-
Write-Host "Python installed: $(python --version)" -ForegroundColor Green
|
|
46
|
-
} else {
|
|
47
|
-
Write-Host "Python not found, installing..." -ForegroundColor Yellow
|
|
48
|
-
|
|
49
|
-
$pythonUrl = "https://www.python.org/ftp/python/3.12.1/python-3.12.1-amd64.exe"
|
|
50
|
-
$pythonInstaller = "$env:TEMP\python-installer.exe"
|
|
51
|
-
|
|
52
|
-
Write-Host "Downloading Python..." -ForegroundColor Cyan
|
|
53
|
-
Invoke-WebRequest -Uri $pythonUrl -OutFile $pythonInstaller -UseBasicParsing
|
|
54
|
-
|
|
55
|
-
Write-Host "Installing Python (may require admin)..." -ForegroundColor Cyan
|
|
56
|
-
Start-Process $pythonInstaller -ArgumentList "/quiet", "InstallAllUsers=1", "PrependPath=1", "Include_pip=1" -Wait
|
|
57
|
-
|
|
58
|
-
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
59
|
-
Start-Sleep -Seconds 3
|
|
60
|
-
|
|
61
|
-
if (Get-Command python -ErrorAction SilentlyContinue) {
|
|
62
|
-
Write-Host "Python installed: $(python --version)" -ForegroundColor Green
|
|
63
|
-
Remove-Item $pythonInstaller -Force -ErrorAction SilentlyContinue
|
|
64
|
-
} else {
|
|
65
|
-
Write-Host "Python installation failed" -ForegroundColor Red
|
|
66
|
-
Write-Host "Download manually: https://www.python.org/downloads/" -ForegroundColor Yellow
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
Write-Host ""
|
|
70
|
-
|
|
71
|
-
# ============ Check/Install uv ============
|
|
72
|
-
Write-Host "Checking uv..."
|
|
73
|
-
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
|
74
|
-
Write-Host "uv installed: $(uv --version)" -ForegroundColor Green
|
|
75
|
-
} else {
|
|
76
|
-
Write-Host "uv not found, installing..." -ForegroundColor Yellow
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
Write-Host "Downloading uv..." -ForegroundColor Cyan
|
|
80
|
-
Invoke-WebRequest -Uri "https://astral.sh/uv/install.ps1" -OutFile "$env:TEMP\install-uv.ps1" -UseBasicParsing
|
|
81
|
-
powershell -ExecutionPolicy Bypass -File "$env:TEMP\install-uv.ps1" -Version "0.4.0" -PowerShell -Admin
|
|
82
|
-
Remove-Item "$env:TEMP\install-uv.ps1" -Force -ErrorAction SilentlyContinue
|
|
83
|
-
|
|
84
|
-
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
85
|
-
|
|
86
|
-
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
|
87
|
-
Write-Host "uv installed: $(uv --version)" -ForegroundColor Green
|
|
88
|
-
}
|
|
89
|
-
} catch {
|
|
90
|
-
Write-Host "uv installation failed (optional, can be skipped)" -ForegroundColor Yellow
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
Write-Host ""
|
|
94
|
-
|
|
95
|
-
# ============ Clean npm cache and install Foliko ============
|
|
96
|
-
Write-Host "Cleaning npm cache..." -ForegroundColor Cyan
|
|
97
|
-
npm cache clean --force 2>$null | Out-Null
|
|
98
|
-
|
|
99
|
-
Write-Host "Installing Foliko..." -ForegroundColor Cyan
|
|
100
|
-
npm install -g foliko --ignore-scripts 2>&1 | Out-Null
|
|
101
|
-
|
|
102
|
-
# Get npm global bin path
|
|
103
|
-
$npmPrefix = npm config get prefix 2>$null
|
|
104
|
-
$npmBinPath = $npmPrefix -replace "\\$", ""
|
|
105
|
-
|
|
106
|
-
# Add to PATH permanently for current user
|
|
107
|
-
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
108
|
-
if ($userPath -notlike "*$npmBinPath*") {
|
|
109
|
-
[Environment]::SetEnvironmentVariable("Path", "$userPath;$npmBinPath", "User")
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
# Also add to current session PATH
|
|
113
|
-
$env:Path = "$npmBinPath;$env:Path"
|
|
114
|
-
Start-Sleep -Seconds 2
|
|
115
|
-
|
|
116
|
-
# Check if installation succeeded
|
|
117
|
-
if (Test-Path "$npmBinPath\foliko.cmd") {
|
|
118
|
-
Write-Host ""
|
|
119
|
-
Write-Host "Installation complete!" -ForegroundColor Green
|
|
120
|
-
Write-Host ""
|
|
121
|
-
Write-Host "Please restart your terminal or run:" -ForegroundColor Cyan
|
|
122
|
-
Write-Host ' $env:Path = "C:\Users\Administrator\AppData\Roaming\npm;' + '$env:Path"' -ForegroundColor White
|
|
123
|
-
Write-Host ""
|
|
124
|
-
Write-Host "Then run: foliko chat" -ForegroundColor Yellow
|
|
125
|
-
} else {
|
|
126
|
-
Write-Host ""
|
|
127
|
-
Write-Host "Installation may have failed." -ForegroundColor Yellow
|
|
128
|
-
Write-Host "Run: npm install -g foliko"
|
|
129
|
-
}
|
|
1
|
+
# Foliko Installer
|
|
2
|
+
|
|
3
|
+
# Fix execution policy first
|
|
4
|
+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force -ErrorAction SilentlyContinue
|
|
5
|
+
|
|
6
|
+
Write-Host "Foliko Installer"
|
|
7
|
+
Write-Host "================="
|
|
8
|
+
Write-Host ""
|
|
9
|
+
|
|
10
|
+
# Refresh PATH
|
|
11
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
12
|
+
|
|
13
|
+
# ============ Check/Install Node.js ============
|
|
14
|
+
Write-Host "Checking Node.js..."
|
|
15
|
+
if (Get-Command node -ErrorAction SilentlyContinue) {
|
|
16
|
+
Write-Host "Node.js installed: $(node --version)" -ForegroundColor Green
|
|
17
|
+
} else {
|
|
18
|
+
Write-Host "Node.js not found, installing..." -ForegroundColor Yellow
|
|
19
|
+
|
|
20
|
+
$nodeUrl = "https://nodejs.org/dist/v20.11.0/node-v20.11.0-x64.msi"
|
|
21
|
+
$nodeInstaller = "$env:TEMP\node-installer.msi"
|
|
22
|
+
|
|
23
|
+
Write-Host "Downloading Node.js..." -ForegroundColor Cyan
|
|
24
|
+
Invoke-WebRequest -Uri $nodeUrl -OutFile $nodeInstaller -UseBasicParsing
|
|
25
|
+
|
|
26
|
+
Write-Host "Installing Node.js (may require admin)..." -ForegroundColor Cyan
|
|
27
|
+
Start-Process msiexec.exe -ArgumentList "/i", $nodeInstaller, "/quiet", "/norestart" -Wait
|
|
28
|
+
|
|
29
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
30
|
+
Start-Sleep -Seconds 3
|
|
31
|
+
|
|
32
|
+
if (Get-Command node -ErrorAction SilentlyContinue) {
|
|
33
|
+
Write-Host "Node.js installed: $(node --version)" -ForegroundColor Green
|
|
34
|
+
Remove-Item $nodeInstaller -Force -ErrorAction SilentlyContinue
|
|
35
|
+
} else {
|
|
36
|
+
Write-Host "Node.js installation failed" -ForegroundColor Red
|
|
37
|
+
Write-Host "Download manually: https://nodejs.org/" -ForegroundColor Yellow
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
Write-Host ""
|
|
41
|
+
|
|
42
|
+
# ============ Check/Install Python ============
|
|
43
|
+
Write-Host "Checking Python..."
|
|
44
|
+
if (Get-Command python -ErrorAction SilentlyContinue) {
|
|
45
|
+
Write-Host "Python installed: $(python --version)" -ForegroundColor Green
|
|
46
|
+
} else {
|
|
47
|
+
Write-Host "Python not found, installing..." -ForegroundColor Yellow
|
|
48
|
+
|
|
49
|
+
$pythonUrl = "https://www.python.org/ftp/python/3.12.1/python-3.12.1-amd64.exe"
|
|
50
|
+
$pythonInstaller = "$env:TEMP\python-installer.exe"
|
|
51
|
+
|
|
52
|
+
Write-Host "Downloading Python..." -ForegroundColor Cyan
|
|
53
|
+
Invoke-WebRequest -Uri $pythonUrl -OutFile $pythonInstaller -UseBasicParsing
|
|
54
|
+
|
|
55
|
+
Write-Host "Installing Python (may require admin)..." -ForegroundColor Cyan
|
|
56
|
+
Start-Process $pythonInstaller -ArgumentList "/quiet", "InstallAllUsers=1", "PrependPath=1", "Include_pip=1" -Wait
|
|
57
|
+
|
|
58
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
59
|
+
Start-Sleep -Seconds 3
|
|
60
|
+
|
|
61
|
+
if (Get-Command python -ErrorAction SilentlyContinue) {
|
|
62
|
+
Write-Host "Python installed: $(python --version)" -ForegroundColor Green
|
|
63
|
+
Remove-Item $pythonInstaller -Force -ErrorAction SilentlyContinue
|
|
64
|
+
} else {
|
|
65
|
+
Write-Host "Python installation failed" -ForegroundColor Red
|
|
66
|
+
Write-Host "Download manually: https://www.python.org/downloads/" -ForegroundColor Yellow
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
Write-Host ""
|
|
70
|
+
|
|
71
|
+
# ============ Check/Install uv ============
|
|
72
|
+
Write-Host "Checking uv..."
|
|
73
|
+
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
|
74
|
+
Write-Host "uv installed: $(uv --version)" -ForegroundColor Green
|
|
75
|
+
} else {
|
|
76
|
+
Write-Host "uv not found, installing..." -ForegroundColor Yellow
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
Write-Host "Downloading uv..." -ForegroundColor Cyan
|
|
80
|
+
Invoke-WebRequest -Uri "https://astral.sh/uv/install.ps1" -OutFile "$env:TEMP\install-uv.ps1" -UseBasicParsing
|
|
81
|
+
powershell -ExecutionPolicy Bypass -File "$env:TEMP\install-uv.ps1" -Version "0.4.0" -PowerShell -Admin
|
|
82
|
+
Remove-Item "$env:TEMP\install-uv.ps1" -Force -ErrorAction SilentlyContinue
|
|
83
|
+
|
|
84
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
85
|
+
|
|
86
|
+
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
|
87
|
+
Write-Host "uv installed: $(uv --version)" -ForegroundColor Green
|
|
88
|
+
}
|
|
89
|
+
} catch {
|
|
90
|
+
Write-Host "uv installation failed (optional, can be skipped)" -ForegroundColor Yellow
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
Write-Host ""
|
|
94
|
+
|
|
95
|
+
# ============ Clean npm cache and install Foliko ============
|
|
96
|
+
Write-Host "Cleaning npm cache..." -ForegroundColor Cyan
|
|
97
|
+
npm cache clean --force 2>$null | Out-Null
|
|
98
|
+
|
|
99
|
+
Write-Host "Installing Foliko..." -ForegroundColor Cyan
|
|
100
|
+
npm install -g foliko --ignore-scripts 2>&1 | Out-Null
|
|
101
|
+
|
|
102
|
+
# Get npm global bin path
|
|
103
|
+
$npmPrefix = npm config get prefix 2>$null
|
|
104
|
+
$npmBinPath = $npmPrefix -replace "\\$", ""
|
|
105
|
+
|
|
106
|
+
# Add to PATH permanently for current user
|
|
107
|
+
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
108
|
+
if ($userPath -notlike "*$npmBinPath*") {
|
|
109
|
+
[Environment]::SetEnvironmentVariable("Path", "$userPath;$npmBinPath", "User")
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Also add to current session PATH
|
|
113
|
+
$env:Path = "$npmBinPath;$env:Path"
|
|
114
|
+
Start-Sleep -Seconds 2
|
|
115
|
+
|
|
116
|
+
# Check if installation succeeded
|
|
117
|
+
if (Test-Path "$npmBinPath\foliko.cmd") {
|
|
118
|
+
Write-Host ""
|
|
119
|
+
Write-Host "Installation complete!" -ForegroundColor Green
|
|
120
|
+
Write-Host ""
|
|
121
|
+
Write-Host "Please restart your terminal or run:" -ForegroundColor Cyan
|
|
122
|
+
Write-Host ' $env:Path = "C:\Users\Administrator\AppData\Roaming\npm;' + '$env:Path"' -ForegroundColor White
|
|
123
|
+
Write-Host ""
|
|
124
|
+
Write-Host "Then run: foliko chat" -ForegroundColor Yellow
|
|
125
|
+
} else {
|
|
126
|
+
Write-Host ""
|
|
127
|
+
Write-Host "Installation may have failed." -ForegroundColor Yellow
|
|
128
|
+
Write-Host "Run: npm install -g foliko"
|
|
129
|
+
}
|