@kmlckj/licos-ai-cli 0.0.15 → 0.0.18

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.
@@ -0,0 +1,26 @@
1
+ # 项目上下文
2
+
3
+ ## 技术栈
4
+
5
+ - **项目类型**: AGENT
6
+ - **运行时**: Python + LangGraph/LangChain + licos-agent-runtime
7
+ - **入口**: `src/agents/agent.py`
8
+
9
+ ## 目录结构
10
+
11
+ ```text
12
+ ├── config/
13
+ │ └── agent_llm_config.json
14
+ ├── scripts/
15
+ ├── src/
16
+ │ ├── main.py
17
+ │ ├── agents/
18
+ │ │ └── agent.py
19
+ │ ├── tools/
20
+ │ └── storage/
21
+ └── AGENTS.md
22
+ ```
23
+
24
+ ## 项目说明
25
+
26
+ 本文件用于记录用户项目可维护的长期上下文,例如业务目标、已经实现的工具、外部 API 约定、测试样例和后续注意事项。
@@ -7,12 +7,16 @@ LICOS 智能体项目模板,基于 Python、LangGraph、LangChain 和 `licos-a
7
7
  ```text
8
8
  .
9
9
  ├── .licos
10
+ ├── config/
11
+ │ └── agent_llm_config.json
12
+ ├── AGENTS.md
10
13
  ├── pyproject.toml
11
14
  ├── scripts/
12
15
  └── src/
13
16
  ├── main.py
14
- └── agents/
15
- └── agent.py
17
+ ├── agents/
18
+ └── agent.py
19
+ └── tools/
16
20
  ```
17
21
 
18
22
  ## 本地运行
@@ -30,4 +34,24 @@ bash scripts/http_run.sh -p <%= port %>
30
34
  - `POST /cancel/{run_id}`
31
35
  - `POST /node_run/{node_id}`
32
36
  - `GET /graph_parameter`
33
- - `POST /v1/chat/completions`
37
+ - `GET /agent/config`
38
+ - `GET /agent/canvas`
39
+ - `POST /agent/canvas`
40
+ - `POST /v1/chat/completions`
41
+
42
+ ## 智能体配置
43
+
44
+ `config/agent_llm_config.json` 是平台预览读取智能体配置和工具列表的来源:
45
+
46
+ - `config`:模型、温度、超时、thinking 等运行参数
47
+ - `sp`:系统提示词
48
+ - `up`:用户提示补充
49
+ - `tools`:已配置工具名称列表,新增或删除工具时需要同步维护
50
+
51
+ ## 项目上下文
52
+
53
+ 项目内的 `AGENTS.md` 用于记录可由用户维护的项目上下文,例如业务目标、已实现工具和测试样例。新增工具时通常需要同步:
54
+
55
+ - `src/tools/*_tool.py`:工具实现
56
+ - `src/agents/agent.py`:导入并注册工具
57
+ - `config/agent_llm_config.json`:更新 `tools`,必要时更新 `sp` / `up`
@@ -0,0 +1,13 @@
1
+ {
2
+ "config": {
3
+ "model": "auto",
4
+ "temperature": 0.7,
5
+ "top_p": 0.9,
6
+ "max_completion_tokens": 10000,
7
+ "timeout": 600,
8
+ "thinking": "auto"
9
+ },
10
+ "sp": "你是一个 LICOS 智能体。请根据用户需求完成任务,并在需要时调用已配置工具。",
11
+ "up": "",
12
+ "tools": []
13
+ }
@@ -4,7 +4,7 @@ version = "0.1.0"
4
4
  description = "LICOS LangGraph agent project"
5
5
  requires-python = ">=3.12"
6
6
  dependencies = [
7
- "licos-agent-runtime>=0.2.3",
7
+ "licos-agent-runtime>=0.2.6",
8
8
  ]
9
9
 
10
10
  [tool.uv]
@@ -1 +1 @@
1
- licos-agent-runtime>=0.2.3
1
+ licos-agent-runtime>=0.2.6
@@ -1,17 +1,52 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import json
4
+ import os
5
+ from pathlib import Path
3
6
  from typing import Any, TypedDict
4
7
 
5
8
  from langgraph.graph import END, START, StateGraph
6
9
 
10
+ AGENT_CONFIG_PATH = Path("config") / "agent_llm_config.json"
11
+
7
12
 
8
13
  class AgentState(TypedDict, total=False):
9
14
  messages: list[Any]
15
+ attachments: list[dict[str, Any]]
16
+ files: list[dict[str, Any]]
10
17
  input: str
11
18
  content: str
12
19
  output: str
13
20
 
14
21
 
22
+ def _project_root() -> Path:
23
+ value = os.environ.get("LICOS_PROJECT_PATH")
24
+ return Path(value).resolve() if value else Path.cwd()
25
+
26
+
27
+ def load_agent_config() -> dict[str, Any]:
28
+ path = _project_root() / AGENT_CONFIG_PATH
29
+ try:
30
+ data = json.loads(path.read_text(encoding="utf-8"))
31
+ except (OSError, json.JSONDecodeError):
32
+ return {}
33
+ return data if isinstance(data, dict) else {}
34
+
35
+
36
+ def _system_prompt(config: dict[str, Any]) -> str:
37
+ value = config.get("sp")
38
+ if isinstance(value, str) and value.strip():
39
+ return value.strip()
40
+ return "你是一个 LICOS 智能体。请根据用户需求完成任务。"
41
+
42
+
43
+ def _configured_tools(config: dict[str, Any]) -> list[str]:
44
+ value = config.get("tools")
45
+ if not isinstance(value, list):
46
+ return []
47
+ return [str(item).strip() for item in value if str(item).strip()]
48
+
49
+
15
50
  def _message_content(message: Any) -> str:
16
51
  if isinstance(message, dict):
17
52
  value = message.get("content") or message.get("text") or ""
@@ -36,10 +71,14 @@ def _latest_user_text(messages: list[Any]) -> str:
36
71
  def assistant(state: AgentState) -> AgentState:
37
72
  messages = list(state.get("messages") or [])
38
73
  user_text = str(state.get("input") or "").strip() or _latest_user_text(messages)
74
+ config = load_agent_config()
75
+ system_prompt = _system_prompt(config)
76
+ tools = _configured_tools(config)
77
+ tool_text = "、".join(tools) if tools else "暂无"
39
78
  response = (
40
- "这是一个 LICOS 智能体模板。"
79
+ f"{system_prompt}\n\n当前已配置工具:{tool_text}。"
41
80
  if not user_text
42
- else f"这是一个 LICOS 智能体模板,已收到你的输入:{user_text}"
81
+ else f"{system_prompt}\n\n已收到你的输入:{user_text}"
43
82
  )
44
83
  messages.append({"role": "assistant", "content": response})
45
84
  return {"messages": messages, "content": response, "output": response}
@@ -47,7 +86,15 @@ def assistant(state: AgentState) -> AgentState:
47
86
 
48
87
  def create_agent(_ctx: Any = None) -> Any:
49
88
  builder = StateGraph(AgentState)
50
- builder.add_node("assistant", assistant)
51
- builder.add_edge(START, "assistant")
52
- builder.add_edge("assistant", END)
89
+ builder.add_node(
90
+ "agent",
91
+ assistant,
92
+ metadata={
93
+ "title": "agent节点",
94
+ "description": "默认智能体节点",
95
+ "dependencies": {"llm_config": [AGENT_CONFIG_PATH.as_posix()]},
96
+ },
97
+ )
98
+ builder.add_edge(START, "agent")
99
+ builder.add_edge("agent", END)
53
100
  return builder.compile()
@@ -1,6 +1,7 @@
1
1
  const description = `Agent(智能体项目):\`licos init \${LICOS_PROJECT_PATH} --template agent\`
2
2
  - 适用:Python + LangGraph/LangChain 智能体项目
3
3
  - 使用 licos-agent-runtime 提供 /run、/stream_run、/cancel、OpenAI compatible 等运行时接口
4
+ - 使用 config/agent_llm_config.json 维护智能体配置和工具列表,并通过 /agent/config、/agent/canvas 暴露给预览
4
5
  - 项目源码位于 /workspace/projects,平台数据位于 /workspace/.licos`;
5
6
 
6
7
  const config = {
@@ -3,7 +3,7 @@
3
3
  "templates": [
4
4
  {
5
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",
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- 使用 config/agent_llm_config.json 维护智能体配置和工具列表,并通过 /agent/config、/agent/canvas 暴露给预览\n- 项目源码位于 /workspace/projects,平台数据位于 /workspace/.licos",
7
7
  "location": "./agent",
8
8
  "paramsSchema": {
9
9
  "type": "object",
@@ -0,0 +1,25 @@
1
+ # 项目上下文
2
+
3
+ ## 技术栈
4
+
5
+ - **项目类型**: WORKFLOW
6
+ - **运行时**: Python + LangGraph + licos-agent-runtime
7
+ - **入口**: `src/graphs/graph.py`
8
+
9
+ ## 目录结构
10
+
11
+ ```text
12
+ ├── config/
13
+ ├── scripts/
14
+ ├── src/
15
+ │ ├── main.py
16
+ │ └── graphs/
17
+ │ ├── graph.py
18
+ │ ├── state.py
19
+ │ └── nodes/
20
+ └── AGENTS.md
21
+ ```
22
+
23
+ ## 项目说明
24
+
25
+ 本文件用于记录用户项目可维护的长期上下文,例如业务目标、节点清单、外部 API 约定、输入输出样例、测试方式和后续注意事项。
@@ -7,6 +7,8 @@ LICOS 工作流项目模板,基于 Python、LangGraph 和 `licos-agent-runtime
7
7
  ```text
8
8
  .
9
9
  ├── .licos
10
+ ├── AGENTS.md
11
+ ├── config/
10
12
  ├── pyproject.toml
11
13
  ├── scripts/
12
14
  └── src/
@@ -30,5 +32,16 @@ bash scripts/http_run.sh -p <%= port %>
30
32
  - `POST /cancel/{run_id}`
31
33
  - `POST /node_run/{node_id}`
32
34
  - `GET /graph_parameter`
35
+ - `GET /agent/canvas`
36
+ - `POST /agent/canvas`
37
+ - `POST /agent/canvas_submit`
38
+ - `POST /v1/api/project/{project_id}/agent/canvas`
39
+ - `POST /v1/api/project/{project_id}/agent/canvas_submit`
33
40
 
34
41
  `POST /stream_run` 使用工作流流式协议,事件类型包括 `workflow_start`、`workflow_end`、`node_start`、`node_end`、`error`、`ping`。
42
+
43
+ `/agent/canvas` 返回工作流画布结构,`/agent/canvas_submit` 接收前端编辑后的 `after_canvas` 并生成给 Agent 执行源码修改的 `QueryDiff` 文本。
44
+
45
+ ## 项目上下文
46
+
47
+ 项目内的 `AGENTS.md` 用于记录可由用户维护的项目上下文,例如业务目标、节点清单、输入输出样例和测试方式。
@@ -4,7 +4,7 @@ version = "0.1.0"
4
4
  description = "LICOS LangGraph workflow project"
5
5
  requires-python = ">=3.12"
6
6
  dependencies = [
7
- "licos-agent-runtime>=0.2.3",
7
+ "licos-agent-runtime>=0.2.6",
8
8
  ]
9
9
 
10
10
  [tool.uv]
@@ -1 +1 @@
1
- licos-agent-runtime>=0.2.3
1
+ licos-agent-runtime>=0.2.6
@@ -30,7 +30,15 @@ def create_graph(_ctx: Any = None) -> Any:
30
30
  input_schema=WorkflowInput,
31
31
  output_schema=WorkflowOutput,
32
32
  )
33
- builder.add_node("generate_answer", generate_answer, metadata={"title": "生成结果"})
33
+ builder.add_node(
34
+ "generate_answer",
35
+ generate_answer,
36
+ metadata={
37
+ "title": "生成结果",
38
+ "description": "根据输入主题生成工作流输出",
39
+ "type": "action",
40
+ },
41
+ )
34
42
  builder.add_edge(START, "generate_answer")
35
43
  builder.add_edge("generate_answer", END)
36
44
  return builder.compile()
@@ -1,6 +1,7 @@
1
1
  const description = `Workflow(工作流项目):\`licos init \${LICOS_PROJECT_PATH} --template workflow\`
2
2
  - 适用:Python + LangGraph 工作流项目
3
- - 使用 licos-agent-runtime 提供 /run、/stream_run、/cancel、/node_run、/graph_parameter 接口
3
+ - 使用 licos-agent-runtime 提供 /run、/stream_run、/cancel、/node_run、/graph_parameter、/agent/canvas、/agent/canvas_submit 接口
4
+ - /agent/canvas 返回工作流画布节点,/agent/canvas_submit 接收前端编辑后的画布并生成 QueryDiff
4
5
  - /stream_run 输出 workflow_start、node_start、node_end、workflow_end、error、ping 事件`;
5
6
 
6
7
  const config = {
package/lib/cli.js CHANGED
@@ -2107,7 +2107,7 @@ const EventBuilder = {
2107
2107
  };
2108
2108
 
2109
2109
  var name = "@kmlckj/licos-ai-cli";
2110
- var version = "0.0.15";
2110
+ var version = "0.0.18";
2111
2111
  var description = "LICOS AI coding workspace CLI - project template engine and dev tools";
2112
2112
  var license = "MIT";
2113
2113
  var author = "kmlckj";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmlckj/licos-ai-cli",
3
- "version": "0.0.15",
3
+ "version": "0.0.18",
4
4
  "description": "LICOS AI coding workspace CLI - project template engine and dev tools",
5
5
  "license": "MIT",
6
6
  "author": "kmlckj",