@fieldwangai/agentflow 0.1.29 → 0.1.31
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/agents/agentflow-node-executor-code.md +3 -2
- package/agents/agentflow-node-executor-planning.md +3 -2
- package/agents/agentflow-node-executor-requirement.md +3 -2
- package/agents/agentflow-node-executor-test.md +3 -2
- package/agents/agentflow-node-executor-ui.md +3 -2
- package/agents/agentflow-node-executor.md +3 -2
- package/agents/en/agentflow-node-executor.md +3 -2
- package/agents/zh/agentflow-node-executor.md +3 -2
- package/bin/lib/agent-runners.mjs +63 -14
- package/bin/lib/api-runner.mjs +30 -4
- package/bin/lib/apply.mjs +6 -5
- package/bin/lib/auth.mjs +240 -0
- package/bin/lib/catalog-agents.mjs +2 -2
- package/bin/lib/catalog-flows.mjs +196 -17
- package/bin/lib/composer-agent.mjs +22 -1
- package/bin/lib/composer-skill-router.mjs +10 -78
- package/bin/lib/flow-import.mjs +2 -2
- package/bin/lib/flow-write.mjs +20 -20
- package/bin/lib/help.mjs +2 -2
- package/bin/lib/locales/en.json +29 -1
- package/bin/lib/locales/zh.json +31 -3
- package/bin/lib/main.mjs +6 -1
- package/bin/lib/node-exec-context.mjs +5 -5
- package/bin/lib/node-execute.mjs +15 -10
- package/bin/lib/paths.mjs +69 -13
- package/bin/lib/recent-runs.mjs +2 -2
- package/bin/lib/run-node-statuses-from-disk.mjs +3 -3
- package/bin/lib/runtime-context.mjs +225 -0
- package/bin/lib/scheduler.mjs +42 -38
- package/bin/lib/skill-registry.mjs +145 -0
- package/bin/lib/ui-server.mjs +1517 -57
- package/bin/lib/user-env.mjs +83 -0
- package/bin/lib/workspace-tree.mjs +4 -3
- package/bin/lib/workspace.mjs +9 -11
- package/bin/pipeline/build-node-prompt.mjs +29 -4
- package/bin/pipeline/get-env.mjs +5 -29
- package/bin/pipeline/get-exec-id.mjs +2 -2
- package/bin/pipeline/get-resolved-values.mjs +1 -0
- package/bin/pipeline/pre-process-node.mjs +328 -6
- package/bin/pipeline/run-tool-nodejs.mjs +7 -0
- package/bin/pipeline/validate-flow.mjs +2 -0
- package/builtin/nodes/agent_subAgent.md +12 -3
- package/builtin/nodes/control_cd_workspace.md +45 -0
- package/builtin/nodes/control_load_skills.md +50 -0
- package/builtin/nodes/control_user_workspace.md +20 -0
- package/builtin/nodes/display_ascii.md +22 -0
- package/builtin/nodes/display_markdown.md +22 -0
- package/builtin/nodes/display_mermaid.md +22 -0
- package/builtin/nodes/tool_git_checkout.md +57 -0
- package/builtin/nodes/tool_nodejs.md +8 -1
- package/builtin/nodes/tool_print.md +4 -1
- package/builtin/web-ui/dist/assets/index-BVWwQpvg.css +1 -0
- package/builtin/web-ui/dist/assets/index-CvNy1n3f.js +197 -0
- package/builtin/web-ui/dist/index.html +2 -2
- package/package.json +1 -1
- package/skills/agentflow-flow-recipes/SKILL.md +24 -0
- package/skills/agentflow-flow-recipes/references/recipes.md +63 -0
- package/skills/agentflow-node-reference/SKILL.md +25 -0
- package/skills/agentflow-node-reference/references/builtin-nodes.md +210 -0
- package/skills/agentflow-placeholder-reference/SKILL.md +24 -0
- package/skills/agentflow-placeholder-reference/references/placeholders.md +20 -0
- package/skills/agentflow-runtime-reference/SKILL.md +25 -0
- package/skills/agentflow-runtime-reference/references/runtime.md +64 -0
- package/skills/agentflow-workspace-ascii/SKILL.md +42 -0
- package/skills/agentflow-workspace-graph/SKILL.md +67 -0
- package/skills/agentflow-workspace-markdown/SKILL.md +44 -0
- package/skills/agentflow-workspace-mermaid/SKILL.md +43 -0
- package/builtin/web-ui/dist/assets/index-0vJxkTJz.css +0 -1
- package/builtin/web-ui/dist/assets/index-h69bpxLI.js +0 -190
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import yaml from "js-yaml";
|
|
5
|
+
|
|
6
|
+
const fileCache = new Map();
|
|
7
|
+
const CACHE_TTL_MS = 60_000;
|
|
8
|
+
|
|
9
|
+
function readFileCached(absPath) {
|
|
10
|
+
const now = Date.now();
|
|
11
|
+
const cached = fileCache.get(absPath);
|
|
12
|
+
if (cached && now - cached.ts < CACHE_TTL_MS) return cached.content;
|
|
13
|
+
try {
|
|
14
|
+
const content = fs.readFileSync(absPath, "utf-8");
|
|
15
|
+
fileCache.set(absPath, { content, ts: now });
|
|
16
|
+
return content;
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function stripSkillFrontmatter(content) {
|
|
23
|
+
const raw = String(content || "");
|
|
24
|
+
const match = raw.match(/^---\s*\r?\n[\s\S]*?\r?\n---\s*\r?\n?/);
|
|
25
|
+
return match ? raw.slice(match[0].length).trim() : raw.trim();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function parseSkillFrontmatter(content) {
|
|
29
|
+
const match = String(content || "").match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
|
|
30
|
+
if (!match) return {};
|
|
31
|
+
try {
|
|
32
|
+
return yaml.load(match[1]) || {};
|
|
33
|
+
} catch {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function parseSkillFile(absPath, source = {}) {
|
|
39
|
+
const content = readFileCached(absPath);
|
|
40
|
+
if (!content) return null;
|
|
41
|
+
const meta = parseSkillFrontmatter(content);
|
|
42
|
+
const name = String(meta.name || path.basename(path.dirname(absPath))).trim();
|
|
43
|
+
if (!name) return null;
|
|
44
|
+
const body = stripSkillFrontmatter(content);
|
|
45
|
+
const sourceId = String(source.source || source.id || "unknown").trim() || "unknown";
|
|
46
|
+
const sourceLabel = String(source.sourceLabel || source.label || sourceId).trim() || sourceId;
|
|
47
|
+
return {
|
|
48
|
+
key: `${sourceId}:${name}`,
|
|
49
|
+
id: name,
|
|
50
|
+
name,
|
|
51
|
+
description: String(meta.description || "").trim(),
|
|
52
|
+
source: sourceId,
|
|
53
|
+
sourceLabel,
|
|
54
|
+
path: absPath,
|
|
55
|
+
body,
|
|
56
|
+
content,
|
|
57
|
+
installedBy: source.installedBy || "",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function listSkillFiles(dir) {
|
|
62
|
+
try {
|
|
63
|
+
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) return [];
|
|
64
|
+
return fs.readdirSync(dir, { withFileTypes: true })
|
|
65
|
+
.filter((entry) => entry.isDirectory())
|
|
66
|
+
.map((entry) => path.join(dir, entry.name, "SKILL.md"))
|
|
67
|
+
.filter((skillPath) => fs.existsSync(skillPath));
|
|
68
|
+
} catch {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function workspaceSkillSources(root, prefix, labelPrefix) {
|
|
74
|
+
if (!root) return [];
|
|
75
|
+
const abs = path.resolve(root);
|
|
76
|
+
return [
|
|
77
|
+
{ source: `${prefix}-agents`, sourceLabel: `${labelPrefix}/.agents`, dir: path.join(abs, ".agents", "skills"), installedBy: "filesystem" },
|
|
78
|
+
{ source: `${prefix}-cursor`, sourceLabel: `${labelPrefix}/.cursor`, dir: path.join(abs, ".cursor", "skills"), installedBy: "filesystem" },
|
|
79
|
+
{ source: `${prefix}-codex`, sourceLabel: `${labelPrefix}/.codex`, dir: path.join(abs, ".codex", "skills"), installedBy: "filesystem" },
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function defaultSkillSources(packageRoot, workspaceRoot) {
|
|
84
|
+
const sources = [
|
|
85
|
+
{
|
|
86
|
+
source: "builtin",
|
|
87
|
+
sourceLabel: "AgentFlow",
|
|
88
|
+
dir: path.join(path.resolve(packageRoot), "skills"),
|
|
89
|
+
installedBy: "agentflow",
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
if (workspaceRoot) sources.push(...workspaceSkillSources(workspaceRoot, "workspace", "工作区"));
|
|
93
|
+
const home = os.homedir();
|
|
94
|
+
sources.push(
|
|
95
|
+
{ source: "global-agents", sourceLabel: "全局 .agents", dir: path.join(home, ".agents", "skills"), installedBy: "global" },
|
|
96
|
+
{ source: "global-cursor", sourceLabel: "全局 .cursor", dir: path.join(home, ".cursor", "skills"), installedBy: "global" },
|
|
97
|
+
{ source: "global-codex", sourceLabel: "全局 .codex", dir: path.join(home, ".codex", "skills"), installedBy: "skillhub" },
|
|
98
|
+
);
|
|
99
|
+
return sources;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function listSkillsFromSources(sources, opts = {}) {
|
|
103
|
+
const include = new Set((opts.include || []).map((x) => String(x).trim()).filter(Boolean));
|
|
104
|
+
const exclude = new Set((opts.exclude || []).map((x) => String(x).trim()).filter(Boolean));
|
|
105
|
+
const skills = [];
|
|
106
|
+
const warnings = [];
|
|
107
|
+
const seenKeys = new Set();
|
|
108
|
+
const seenPaths = new Set();
|
|
109
|
+
for (const source of sources || []) {
|
|
110
|
+
const dir = path.resolve(source.dir || "");
|
|
111
|
+
if (!fs.existsSync(dir)) {
|
|
112
|
+
if (opts.warnMissing) warnings.push(`skills path not found: ${dir}`);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const skillPath of listSkillFiles(dir)) {
|
|
116
|
+
const skill = parseSkillFile(skillPath, source);
|
|
117
|
+
if (!skill) continue;
|
|
118
|
+
if (include.size > 0 && !include.has(skill.name) && !include.has(skill.key)) continue;
|
|
119
|
+
if (exclude.has(skill.name) || exclude.has(skill.key)) continue;
|
|
120
|
+
if (seenPaths.has(skill.path)) continue;
|
|
121
|
+
if (seenKeys.has(skill.key)) continue;
|
|
122
|
+
seenPaths.add(skill.path);
|
|
123
|
+
seenKeys.add(skill.key);
|
|
124
|
+
skills.push(skill);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
skills.sort((a, b) => {
|
|
128
|
+
const bySource = a.sourceLabel.localeCompare(b.sourceLabel);
|
|
129
|
+
if (bySource !== 0) return bySource;
|
|
130
|
+
return a.name.localeCompare(b.name);
|
|
131
|
+
});
|
|
132
|
+
return { skills, warnings };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function listSkills(packageRoot, workspaceRoot, opts = {}) {
|
|
136
|
+
return listSkillsFromSources(defaultSkillSources(packageRoot, workspaceRoot), opts).skills;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function readSkillDetail(packageRoot, workspaceRoot, keyOrName) {
|
|
140
|
+
const wanted = String(keyOrName || "").trim();
|
|
141
|
+
if (!wanted) return null;
|
|
142
|
+
const item = listSkills(packageRoot, workspaceRoot).find((skill) => skill.key === wanted || skill.name === wanted);
|
|
143
|
+
if (!item) return null;
|
|
144
|
+
return item;
|
|
145
|
+
}
|