@kmlckj/licos-ai-cli 0.0.6 → 0.0.8

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/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @kmlckj/licos-ai-cli
2
2
 
3
- LICOS AI 编码工作区 CLI 工具,提供基于前端技术栈的项目初始化和开发工具链。
3
+ LICOS AI 编码工作区 CLI 工具,提供基于前端、移动端和智能体技术栈的项目初始化和开发工具链。
4
4
 
5
5
  ## 特性
6
6
 
7
7
  - 快速初始化: 一键创建预配置的项目模板
8
8
  - AI 优先设计: 专为 AI Agent 消费设计,提供清晰的错误信息和自描述能力
9
- - 多模板支持: 支持 React、Next.js、Vite、Nuxt、Taro、Expo 等多种技术栈
9
+ - 多模板支持: 支持 React、Next.js、Vite、Nuxt、Taro、Expo、LangGraph Agent 等多种技术栈
10
10
  - 类型安全: 基于 JSON Schema 的参数校验
11
11
  - 命令代理: 统一的 dev/build/start 命令,抹平不同技术栈差异
12
12
 
@@ -79,6 +79,7 @@ run = ["bash", "./scripts/start.sh"]
79
79
  | `nuxt-vue` | Vue 3 + Nuxt,服务端渲染 |
80
80
  | `taro` | 小程序 + H5 跨端 |
81
81
  | `expo` | React Native 移动端 |
82
+ | `agent` | Python + LangGraph/LangChain 智能体 |
82
83
  | `native-static` | 纯静态 HTML/CSS/JS |
83
84
 
84
85
  ## 开发模板
@@ -0,0 +1,14 @@
1
+ [project]
2
+ entrypoint = "src/main.py"
3
+ requires = ["python-3.12"]
4
+ template = "agent"
5
+
6
+ [dev]
7
+ build = ["bash", "scripts/setup.sh"]
8
+ run = ["bash", "scripts/http_run.sh", "-p", "<%= port %>"]
9
+ deps = ["git"]
10
+
11
+ [deploy]
12
+ build = ["bash", "scripts/setup.sh"]
13
+ run = ["bash", "scripts/http_run.sh", "-p", "<%= port %>"]
14
+ deps = ["git"]
@@ -0,0 +1,40 @@
1
+ # <%= appName %>
2
+
3
+ LICOS 智能体项目模板,基于 Python、LangGraph、LangChain 和 `licos-agent-runtime`。
4
+
5
+ ## 目录
6
+
7
+ ```text
8
+ .
9
+ ├── .licos
10
+ ├── pyproject.toml
11
+ ├── scripts/
12
+ └── src/
13
+ ├── main.py
14
+ └── agents/
15
+ └── agent.py
16
+ ```
17
+
18
+ ## 本地运行
19
+
20
+ ```bash
21
+ bash scripts/setup.sh
22
+ bash scripts/http_run.sh -p <%= port %>
23
+ ```
24
+
25
+ ## HTTP 接口
26
+
27
+ - `GET /health`
28
+ - `POST /run`
29
+ - `POST /stream_run`
30
+ - `POST /cancel/{run_id}`
31
+ - `POST /node_run/{node_id}`
32
+ - `GET /graph_parameter`
33
+ - `POST /v1/chat/completions`
34
+
35
+ ## 工作区约定
36
+
37
+ - `LICOS_WORKSPACE_PATH=/workspace`
38
+ - `LICOS_PROJECT_PATH=/workspace/projects`
39
+ - `.licos/` 平台数据目录只允许位于 `/workspace/.licos`
40
+ - 当前项目源码只放在 `/workspace/projects`
@@ -0,0 +1,13 @@
1
+ .venv/
2
+ venv/
3
+ __pycache__/
4
+ *.py[cod]
5
+ *.log
6
+ .env
7
+ .env.local
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ dist/
12
+ build/
13
+ *.egg-info/
@@ -0,0 +1,13 @@
1
+ [project]
2
+ name = "<%= appName %>"
3
+ version = "0.1.0"
4
+ description = "LICOS LangGraph agent project"
5
+ requires-python = ">=3.12"
6
+ dependencies = [
7
+ "licos-agent-runtime>=0.1.0",
8
+ ]
9
+
10
+ [tool.uv]
11
+ [[tool.uv.index]]
12
+ url = "https://mirrors.aliyun.com/pypi/simple/"
13
+ default = true
@@ -0,0 +1 @@
1
+ licos-agent-runtime>=0.1.0
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+ set -eo pipefail
3
+
4
+ PROJECT_DIR="${LICOS_PROJECT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
5
+ PORT="${PORT:-<%= port %>}"
6
+ HOST="${HOST:-0.0.0.0}"
7
+
8
+ while [ "$#" -gt 0 ]; do
9
+ case "$1" in
10
+ -p|--port)
11
+ PORT="$2"
12
+ shift 2
13
+ ;;
14
+ --host)
15
+ HOST="$2"
16
+ shift 2
17
+ ;;
18
+ *)
19
+ shift
20
+ ;;
21
+ esac
22
+ done
23
+
24
+ cd "$PROJECT_DIR"
25
+
26
+ export LICOS_PROJECT_PATH="$PROJECT_DIR"
27
+ export AGENT_PROJECT_TYPE="${AGENT_PROJECT_TYPE:-AGENT}"
28
+
29
+ exec python -m licos_agent_runtime --mode http --host "$HOST" --port "$PORT"
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+ set -eo pipefail
3
+
4
+ PROJECT_DIR="${LICOS_PROJECT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
5
+ INPUT="${1:-{\"messages\":[{\"role\":\"user\",\"content\":\"你好,介绍一下这个智能体项目。\"}]}}"
6
+
7
+ cd "$PROJECT_DIR"
8
+
9
+ export LICOS_PROJECT_PATH="$PROJECT_DIR"
10
+ export AGENT_PROJECT_TYPE="${AGENT_PROJECT_TYPE:-AGENT}"
11
+
12
+ python -m licos_agent_runtime --mode flow --input "$INPUT"
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ set -eo pipefail
3
+
4
+ PROJECT_DIR="${LICOS_PROJECT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
5
+ PACKAGE_NAME="${PACKAGE_NAME:-<%= appName %>.zip}"
6
+
7
+ cd "$PROJECT_DIR"
8
+
9
+ rm -f "$PACKAGE_NAME"
10
+ zip -r "$PACKAGE_NAME" . \
11
+ -x ".venv/*" \
12
+ -x "venv/*" \
13
+ -x "__pycache__/*" \
14
+ -x "*.pyc" \
15
+ -x ".git/*" \
16
+ -x ".pytest_cache/*" \
17
+ -x ".mypy_cache/*" \
18
+ -x ".ruff_cache/*" \
19
+ -x "dist/*" \
20
+ -x "build/*" \
21
+ -x "*.egg-info/*"
22
+
23
+ echo "$PROJECT_DIR/$PACKAGE_NAME"
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ set -eo pipefail
3
+
4
+ PROJECT_DIR="${LICOS_PROJECT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
5
+ cd "$PROJECT_DIR"
6
+
7
+ ensure_pip_config() {
8
+ mkdir -p "${HOME:-/root}/.pip"
9
+ cat > "${HOME:-/root}/.pip/pip.conf" <<'EOF'
10
+ [global]
11
+ index-url = https://mirrors.aliyun.com/pypi/simple/
12
+ extra-index-url = https://pypi.org/simple/
13
+ trusted-host = mirrors.aliyun.com
14
+ EOF
15
+ }
16
+
17
+ ensure_pip_config
18
+
19
+ PIP_ARGS=(--no-cache-dir)
20
+ if python -m pip install --help 2>/dev/null | grep -q -- "--break-system-packages"; then
21
+ PIP_ARGS+=(--break-system-packages)
22
+ fi
23
+ if [ -n "${PIP_TARGET:-}" ]; then
24
+ PIP_ARGS+=(--target "$PIP_TARGET")
25
+ fi
26
+
27
+ if command -v uv >/dev/null 2>&1 && [ -f "pyproject.toml" ]; then
28
+ if [ -n "${PIP_TARGET:-}" ]; then
29
+ echo "[setup] Deploy mode (uv): installing to PIP_TARGET=$PIP_TARGET"
30
+ uv export --frozen --no-hashes --no-dev | uv pip install --no-cache --target "$PIP_TARGET" -r -
31
+ else
32
+ echo "[setup] Dev mode (uv): syncing .venv"
33
+ if [ -f "uv.lock" ]; then
34
+ uv sync --frozen || uv sync
35
+ else
36
+ uv sync
37
+ fi
38
+ fi
39
+ elif [ -f "requirements.txt" ]; then
40
+ echo "[setup] Fallback mode (pip): installing from requirements.txt"
41
+ python -m pip install "${PIP_ARGS[@]}" -r requirements.txt
42
+ else
43
+ echo "[setup] no pyproject.toml or requirements.txt found, skipping install"
44
+ fi
@@ -0,0 +1,3 @@
1
+ from .agent import create_agent
2
+
3
+ __all__ = ["create_agent"]
@@ -0,0 +1,53 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, TypedDict
4
+
5
+ from langgraph.graph import END, START, StateGraph
6
+
7
+
8
+ class AgentState(TypedDict, total=False):
9
+ messages: list[Any]
10
+ input: str
11
+ content: str
12
+ output: str
13
+
14
+
15
+ def _message_content(message: Any) -> str:
16
+ if isinstance(message, dict):
17
+ value = message.get("content") or message.get("text") or ""
18
+ return str(value)
19
+ value = getattr(message, "content", None)
20
+ return str(value) if value is not None else str(message)
21
+
22
+
23
+ def _latest_user_text(messages: list[Any]) -> str:
24
+ for message in reversed(messages):
25
+ if isinstance(message, dict):
26
+ role = str(message.get("role") or "").lower()
27
+ if role in {"user", "human"}:
28
+ return _message_content(message)
29
+ continue
30
+ role = str(getattr(message, "type", "") or getattr(message, "role", "")).lower()
31
+ if role in {"user", "human"}:
32
+ return _message_content(message)
33
+ return _message_content(messages[-1]) if messages else ""
34
+
35
+
36
+ def assistant(state: AgentState) -> AgentState:
37
+ messages = list(state.get("messages") or [])
38
+ user_text = str(state.get("input") or "").strip() or _latest_user_text(messages)
39
+ response = (
40
+ "这是一个 LICOS 智能体模板。"
41
+ if not user_text
42
+ else f"这是一个 LICOS 智能体模板,已收到你的输入:{user_text}"
43
+ )
44
+ messages.append({"role": "assistant", "content": response})
45
+ return {"messages": messages, "content": response, "output": response}
46
+
47
+
48
+ def create_agent(_ctx: Any = None) -> Any:
49
+ builder = StateGraph(AgentState)
50
+ builder.add_node("assistant", assistant)
51
+ builder.add_edge(START, "assistant")
52
+ builder.add_edge("assistant", END)
53
+ return builder.compile()
@@ -0,0 +1,7 @@
1
+ from licos_agent_runtime.app import app
2
+
3
+
4
+ if __name__ == "__main__":
5
+ from licos_agent_runtime.__main__ import main
6
+
7
+ main()
@@ -0,0 +1 @@
1
+ """Project-local tools can be added here."""
@@ -0,0 +1,45 @@
1
+ const description = `Agent(智能体项目):\`licos init \${LICOS_PROJECT_PATH} --template agent\`
2
+ - 适用:Python + LangGraph/LangChain 智能体项目
3
+ - 使用 licos-agent-runtime 提供 /run、/stream_run、/cancel、OpenAI compatible 等运行时接口
4
+ - 项目源码位于 /workspace/projects,平台数据位于 /workspace/.licos`;
5
+
6
+ const config = {
7
+ description,
8
+ paramsSchema: {
9
+ type: 'object',
10
+ properties: {
11
+ appName: {
12
+ type: 'string',
13
+ minLength: 1,
14
+ pattern: '^[a-z0-9-]+$',
15
+ description: 'Application name (lowercase, alphanumeric and hyphens only)',
16
+ },
17
+ port: {
18
+ type: 'number',
19
+ default: 5000,
20
+ minimum: 1024,
21
+ maximum: 65535,
22
+ description: 'Development server port',
23
+ },
24
+ },
25
+ required: [],
26
+ additionalProperties: false,
27
+ },
28
+ defaultParams: {
29
+ appName: 'agent-project',
30
+ port: 5000,
31
+ },
32
+ onBeforeRender: async context => {
33
+ console.log(`Creating LICOS Agent project: ${context.appName}`);
34
+ return context;
35
+ },
36
+ onAfterRender: async (_context, outputPath) => {
37
+ console.log(`\nAgent project created at: ${outputPath}`);
38
+ console.log('\nConfiguration:');
39
+ console.log(' - Runtime: licos-agent-runtime');
40
+ console.log(' - Framework: LangGraph + LangChain');
41
+ console.log(` - Port: ${_context.port}`);
42
+ },
43
+ };
44
+
45
+ export default config;
@@ -1,5 +1,6 @@
1
1
  loglevel=error
2
- registry=https://registry.npmmirror.com
2
+ registry=https://registry.npmmirror.com/
3
+ @kmlckj:registry=https://registry.npmjs.org/
3
4
 
4
5
  strictStorePkgContentCheck=false
5
6
  verifyStoreIntegrity=false
@@ -0,0 +1,2 @@
1
+ registry=https://registry.npmmirror.com/
2
+ @kmlckj:registry=https://registry.npmjs.org/
@@ -1,5 +1,6 @@
1
1
  loglevel=error
2
- registry=https://registry.npmmirror.com
2
+ registry=https://registry.npmmirror.com/
3
+ @kmlckj:registry=https://registry.npmjs.org/
3
4
 
4
5
  strictStorePkgContentCheck=false
5
6
  verifyStoreIntegrity=false
@@ -0,0 +1,2 @@
1
+ registry=https://registry.npmmirror.com/
2
+ @kmlckj:registry=https://registry.npmjs.org/
@@ -1,5 +1,6 @@
1
1
  loglevel=error
2
- registry=https://registry.npmmirror.com
2
+ registry=https://registry.npmmirror.com/
3
+ @kmlckj:registry=https://registry.npmjs.org/
3
4
 
4
5
  strictStorePkgContentCheck=false
5
6
  verifyStoreIntegrity=false
@@ -0,0 +1,2 @@
1
+ registry=https://registry.npmmirror.com/
2
+ @kmlckj:registry=https://registry.npmjs.org/
@@ -1,5 +1,6 @@
1
1
  loglevel=error
2
- registry=https://registry.npmmirror.com
2
+ registry=https://registry.npmmirror.com/
3
+ @kmlckj:registry=https://registry.npmjs.org/
3
4
 
4
5
  strictStorePkgContentCheck=false
5
6
  verifyStoreIntegrity=false
@@ -0,0 +1,2 @@
1
+ registry=https://registry.npmmirror.com/
2
+ @kmlckj:registry=https://registry.npmjs.org/
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft-07/schema",
3
3
  "templates": [
4
+ {
5
+ "name": "agent",
6
+ "description": "Agent(智能体项目):`licos init ${LICOS_PROJECT_PATH} --template agent`\n- 适用:Python + LangGraph/LangChain 智能体项目\n- 使用 licos-agent-runtime 提供 /run、/stream_run、/cancel、OpenAI compatible 等运行时接口\n- 项目源码位于 /workspace/projects,平台数据位于 /workspace/.licos",
7
+ "location": "./agent",
8
+ "paramsSchema": {
9
+ "type": "object",
10
+ "properties": {
11
+ "appName": {
12
+ "type": "string",
13
+ "minLength": 1,
14
+ "pattern": "^[a-z0-9-]+$",
15
+ "description": "Application name (lowercase, alphanumeric and hyphens only)"
16
+ },
17
+ "port": {
18
+ "type": "number",
19
+ "default": 5000,
20
+ "minimum": 1024,
21
+ "maximum": 65535,
22
+ "description": "Development server port"
23
+ }
24
+ },
25
+ "required": [],
26
+ "additionalProperties": false
27
+ }
28
+ },
4
29
  {
5
30
  "name": "expo",
6
31
  "description": "Expo template for React Native applications",
@@ -1,5 +1,6 @@
1
1
  loglevel=error
2
- registry=https://registry.npmmirror.com
2
+ registry=https://registry.npmmirror.com/
3
+ @kmlckj:registry=https://registry.npmjs.org/
3
4
 
4
5
  strictStorePkgContentCheck=false
5
6
  verifyStoreIntegrity=false
@@ -0,0 +1,2 @@
1
+ registry=https://registry.npmmirror.com/
2
+ @kmlckj:registry=https://registry.npmjs.org/
package/lib/cli.js CHANGED
@@ -2107,8 +2107,8 @@ const EventBuilder = {
2107
2107
  };
2108
2108
 
2109
2109
  var name = "@kmlckj/licos-ai-cli";
2110
- var version = "0.0.3";
2111
- var description = "licos-coding devtools cli";
2110
+ var version = "0.0.8";
2111
+ var description = "LICOS AI coding workspace CLI - project template engine and dev tools";
2112
2112
  var license = "MIT";
2113
2113
  var author = "kmlckj";
2114
2114
  var maintainers = [
@@ -8214,7 +8214,7 @@ const ensureDir = async (dir) => {
8214
8214
  */
8215
8215
  const convertDotfileName = (filePath) => {
8216
8216
  // 白名单:需要从 _ 开头转换为 . 开头的文件
8217
- const dotfileWhitelist = ['_gitignore', '_npmrc'];
8217
+ const dotfileWhitelist = ['_gitignore', '_npmrc', '_pnpmrc'];
8218
8218
 
8219
8219
  const fileName = path.basename(filePath);
8220
8220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmlckj/licos-ai-cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "LICOS AI coding workspace CLI - project template engine and dev tools",
5
5
  "license": "MIT",
6
6
  "author": "kmlckj",