@kmlckj/licos-ai-cli 0.0.5 → 0.0.7

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,70 @@
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
+ PIP_ARGS=(--no-cache-dir)
8
+ if python -m pip --help 2>/dev/null | grep -q -- "--break-system-packages"; then
9
+ PIP_ARGS+=(--break-system-packages)
10
+ fi
11
+ if [ -n "${PIP_TARGET:-}" ]; then
12
+ PIP_ARGS+=(--target "$PIP_TARGET")
13
+ fi
14
+
15
+ runtime_available() {
16
+ python - <<'PY' >/dev/null 2>&1
17
+ import licos_agent_runtime
18
+ PY
19
+ }
20
+
21
+ has_extra_requirements() {
22
+ [ -f "requirements.txt" ] && grep -Ev '^[[:space:]]*(#|$|licos-agent-runtime([<>=!~ ].*)?)[[:space:]]*$' requirements.txt >/dev/null 2>&1
23
+ }
24
+
25
+ install_filtered_requirements() {
26
+ local tmp_req
27
+ tmp_req="$(mktemp)"
28
+ grep -Ev '^[[:space:]]*(#|$|licos-agent-runtime([<>=!~ ].*)?)[[:space:]]*$' requirements.txt > "$tmp_req" || true
29
+ if [ -s "$tmp_req" ]; then
30
+ python -m pip install "${PIP_ARGS[@]}" -r "$tmp_req"
31
+ fi
32
+ rm -f "$tmp_req"
33
+ }
34
+
35
+ RUNTIME_SOURCE="${LICOS_AGENT_RUNTIME_SOURCE:-/opt/licos-agent-runtime}"
36
+ if [ -d "$RUNTIME_SOURCE" ]; then
37
+ echo "[setup] Installing licos-agent-runtime from $RUNTIME_SOURCE"
38
+ python -m pip install "${PIP_ARGS[@]}" "$RUNTIME_SOURCE"
39
+ install_filtered_requirements
40
+ exit 0
41
+ fi
42
+
43
+ if runtime_available; then
44
+ if has_extra_requirements; then
45
+ echo "[setup] licos-agent-runtime already available, installing extra requirements"
46
+ install_filtered_requirements
47
+ else
48
+ echo "[setup] licos-agent-runtime already available, no extra requirements"
49
+ fi
50
+ exit 0
51
+ fi
52
+
53
+ if command -v uv >/dev/null 2>&1 && [ -f "pyproject.toml" ]; then
54
+ if [ -n "${PIP_TARGET:-}" ]; then
55
+ echo "[setup] Deploy mode (uv): installing to PIP_TARGET=$PIP_TARGET"
56
+ uv export --frozen --no-hashes --no-dev | uv pip install --no-cache --target "$PIP_TARGET" -r -
57
+ else
58
+ echo "[setup] Dev mode (uv): syncing .venv"
59
+ if [ -f "uv.lock" ]; then
60
+ uv sync --frozen || uv sync
61
+ else
62
+ uv sync
63
+ fi
64
+ fi
65
+ elif [ -f "requirements.txt" ]; then
66
+ echo "[setup] Fallback mode (pip): installing from requirements.txt"
67
+ pip install -r requirements.txt
68
+ else
69
+ echo "[setup] no pyproject.toml or requirements.txt found, skipping install"
70
+ 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;
@@ -10,7 +10,7 @@
10
10
  "lint": "tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "@kmlckj/licos-platform-sdk": "0.4.0",
13
+ "@kmlckj/licos-platform-sdk": "0.5.0",
14
14
  "@supabase/supabase-js": "2.95.3",
15
15
  "cors": "^2.8.5",
16
16
  "dayjs": "^1.11.19",
@@ -11,7 +11,7 @@
11
11
  "ts-check": "tsc -p tsconfig.json"
12
12
  },
13
13
  "dependencies": {
14
- "@kmlckj/licos-platform-sdk": "0.4.0",
14
+ "@kmlckj/licos-platform-sdk": "0.5.0",
15
15
  "@aws-sdk/client-s3": "^3.958.0",
16
16
  "@aws-sdk/lib-storage": "^3.958.0",
17
17
  "@hookform/resolvers": "^5.2.2",
@@ -12,7 +12,7 @@
12
12
  "start": "bash ./scripts/start.sh"
13
13
  },
14
14
  "dependencies": {
15
- "@kmlckj/licos-platform-sdk": "0.4.0",
15
+ "@kmlckj/licos-platform-sdk": "0.5.0",
16
16
  "@nuxt/image": "^1.8.1",
17
17
  "nuxt": "^4.3.1",
18
18
  "tailwind-merge": "^2.6.0",
@@ -11,7 +11,7 @@
11
11
  "start:prod": "node dist/main"
12
12
  },
13
13
  "dependencies": {
14
- "@kmlckj/licos-platform-sdk": "0.4.0",
14
+ "@kmlckj/licos-platform-sdk": "0.5.0",
15
15
  "@aws-sdk/client-s3": "^3.958.0",
16
16
  "@aws-sdk/lib-storage": "^3.958.0",
17
17
  "@nestjs/common": "^10.4.15",
@@ -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",
@@ -11,7 +11,7 @@
11
11
  "ts-check": "tsc -p tsconfig.json"
12
12
  },
13
13
  "dependencies": {
14
- "@kmlckj/licos-platform-sdk": "0.4.0",
14
+ "@kmlckj/licos-platform-sdk": "0.5.0",
15
15
  "@supabase/supabase-js": "2.95.3",
16
16
  "dotenv": "^17.2.3",
17
17
  "express": "^4.21.2"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmlckj/licos-ai-cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "LICOS AI coding workspace CLI - project template engine and dev tools",
5
5
  "license": "MIT",
6
6
  "author": "kmlckj",