@devflow-tools/cli 0.12.6 → 0.13.1
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/dist/commands/benchmark-cmd.d.ts +5 -0
- package/dist/commands/benchmark-cmd.d.ts.map +1 -0
- package/dist/commands/benchmark-cmd.js +18 -0
- package/dist/commands/benchmark-cmd.js.map +1 -0
- package/dist/commands/connect.d.ts +8 -0
- package/dist/commands/connect.d.ts.map +1 -0
- package/dist/commands/connect.js +26 -0
- package/dist/commands/connect.js.map +1 -0
- package/dist/commands/context.d.ts +15 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +24 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +10 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/doctor.d.ts +56 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +156 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/graph.d.ts +11 -0
- package/dist/commands/graph.d.ts.map +1 -0
- package/dist/commands/graph.js +14 -0
- package/dist/commands/graph.js.map +1 -0
- package/dist/commands/index-cmd.d.ts +4 -0
- package/dist/commands/index-cmd.d.ts.map +1 -0
- package/dist/commands/index-cmd.js +15 -0
- package/dist/commands/index-cmd.js.map +1 -0
- package/dist/commands/init.d.ts +20 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +145 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/knowledge.d.ts +5 -0
- package/dist/commands/knowledge.d.ts.map +1 -0
- package/dist/commands/knowledge.js +23 -0
- package/dist/commands/knowledge.js.map +1 -0
- package/dist/commands/memory.d.ts +5 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +72 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/plugin/install.d.ts +3 -0
- package/dist/commands/plugin/install.d.ts.map +1 -0
- package/dist/commands/plugin/install.js +22 -0
- package/dist/commands/plugin/install.js.map +1 -0
- package/dist/commands/plugin/list.d.ts +3 -0
- package/dist/commands/plugin/list.d.ts.map +1 -0
- package/dist/commands/plugin/list.js +47 -0
- package/dist/commands/plugin/list.js.map +1 -0
- package/dist/commands/plugin/search.d.ts +3 -0
- package/dist/commands/plugin/search.d.ts.map +1 -0
- package/dist/commands/plugin/search.js +29 -0
- package/dist/commands/plugin/search.js.map +1 -0
- package/dist/commands/plugin/uninstall.d.ts +3 -0
- package/dist/commands/plugin/uninstall.d.ts.map +1 -0
- package/dist/commands/plugin/uninstall.js +21 -0
- package/dist/commands/plugin/uninstall.js.map +1 -0
- package/dist/commands/plugin-guide.d.ts +19 -0
- package/dist/commands/plugin-guide.d.ts.map +1 -0
- package/dist/commands/plugin-guide.js +131 -0
- package/dist/commands/plugin-guide.js.map +1 -0
- package/dist/commands/plugin-loader.d.ts +2 -0
- package/dist/commands/plugin-loader.d.ts.map +1 -0
- package/dist/commands/plugin-loader.js +2 -0
- package/dist/commands/plugin-loader.js.map +1 -0
- package/dist/commands/review.d.ts +6 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +75 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/server.d.ts +16 -0
- package/dist/commands/server.d.ts.map +1 -0
- package/dist/commands/server.js +88 -0
- package/dist/commands/server.js.map +1 -0
- package/dist/commands/session.d.ts +7 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +20 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +78 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/skill.d.ts +18 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +105 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/start.d.ts +5 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +58 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +33 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +2 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +12 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/workflow.d.ts +6 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +24 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +606 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/paths.d.ts +1 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/paths.js +4 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/plugin-registry.d.ts +18 -0
- package/dist/lib/plugin-registry.d.ts.map +1 -0
- package/dist/lib/plugin-registry.js +39 -0
- package/dist/lib/plugin-registry.js.map +1 -0
- package/dist/lib/plugin-setup.d.ts +23 -0
- package/dist/lib/plugin-setup.d.ts.map +1 -0
- package/dist/lib/plugin-setup.js +141 -0
- package/dist/lib/plugin-setup.js.map +1 -0
- package/dist/lib/with-server.d.ts +7 -0
- package/dist/lib/with-server.d.ts.map +1 -0
- package/dist/lib/with-server.js +28 -0
- package/dist/lib/with-server.js.map +1 -0
- package/dist/mode.d.ts +10 -0
- package/dist/mode.d.ts.map +1 -0
- package/dist/mode.js +40 -0
- package/dist/mode.js.map +1 -0
- package/dist/plugin-files/.claude-plugin/plugin.json +20 -0
- package/dist/plugin-files/CLAUDE.md +34 -0
- package/dist/plugin-files/dist/command-registry.json +299 -0
- package/dist/plugin-files/dist/skills/devflow:animation/SKILL.md +94 -0
- package/dist/plugin-files/dist/skills/devflow:context/SKILL.md +90 -0
- package/dist/plugin-files/dist/skills/devflow:css/SKILL.md +94 -0
- package/dist/plugin-files/dist/skills/devflow:docker/SKILL.md +97 -0
- package/dist/plugin-files/dist/skills/devflow:electron/SKILL.md +97 -0
- package/dist/plugin-files/dist/skills/devflow:git/SKILL.md +97 -0
- package/dist/plugin-files/dist/skills/devflow:graph/SKILL.md +80 -0
- package/dist/plugin-files/dist/skills/devflow:graphql/SKILL.md +99 -0
- package/dist/plugin-files/dist/skills/devflow:knowledge/SKILL.md +80 -0
- package/dist/plugin-files/dist/skills/devflow:memory/SKILL.md +79 -0
- package/dist/plugin-files/dist/skills/devflow:nest/SKILL.md +99 -0
- package/dist/plugin-files/dist/skills/devflow:nextjs/SKILL.md +97 -0
- package/dist/plugin-files/dist/skills/devflow:performance/SKILL.md +97 -0
- package/dist/plugin-files/dist/skills/devflow:react/SKILL.md +89 -0
- package/dist/plugin-files/dist/skills/devflow:tailwind/SKILL.md +94 -0
- package/dist/plugin-files/dist/skills/devflow:taro/SKILL.md +96 -0
- package/dist/plugin-files/dist/skills/devflow:ui-layout/SKILL.md +94 -0
- package/dist/plugin-files/dist/skills/devflow:vue/SKILL.md +105 -0
- package/dist/plugin-files/dist/skills/devflow:workflow/SKILL.md +80 -0
- package/dist/plugin-files/hooks/constitution.md +20 -0
- package/dist/plugin-files/hooks/post-tool-use +20 -0
- package/dist/plugin-files/hooks/pre-tool-use +23 -0
- package/dist/plugin-files/hooks/session-start +176 -0
- package/dist/plugin-files/hooks/stop +32 -0
- package/dist/plugin-files/hooks.json +52 -0
- package/dist/plugin-files/package.json +31 -0
- package/package.json +27 -27
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: devflow:workflow
|
|
3
|
+
description: 执行标准化开发工作流 — Bug 修复、功能开发、代码审查
|
|
4
|
+
required_mcp_tools:
|
|
5
|
+
- run_workflow
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<HARD-GATE>
|
|
9
|
+
收到 devflow:workflow 时,必须先调用以下 MCP 工具之一:
|
|
10
|
+
run_workflow
|
|
11
|
+
</HARD-GATE>
|
|
12
|
+
|
|
13
|
+
## MANDATORY FIRST STEP - Skill Registration
|
|
14
|
+
|
|
15
|
+
> **IMPORTANT: Before ANY other action, execute the registration command below. This is NON-NEGOTIABLE.**
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
mkdir -p ~/.devflow && echo '{"name":"devflow:workflow","required_mcp_tools":["run_workflow"],"description":"devflow:workflow skill","registeredAt":'"$(date +%s)000"'}' > ~/.devflow/current-skill.json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
After registration, you **MUST** use ONLY these MCP tools for all work in this skill:
|
|
22
|
+
- `mcp__devflow__run_workflow`
|
|
23
|
+
|
|
24
|
+
**Never use direct tools** (Read, Write, Edit, Bash, Grep, etc.) for tasks that can be handled by the MCP tools above.
|
|
25
|
+
|
|
26
|
+
When the skill execution is complete, clean up:
|
|
27
|
+
```bash
|
|
28
|
+
rm -f ~/.devflow/current-skill.json ~/.devflow/current-execution-id
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 工作流(必须按顺序执行)
|
|
32
|
+
|
|
33
|
+
### Step 1: 获取精确上下文
|
|
34
|
+
调用 `mcp__devflow__get_project_context` 获取与用户问题相关的代码、记忆和知识库信息。
|
|
35
|
+
这一步确保你拿到的是项目真实状态,而非凭空猜测。
|
|
36
|
+
|
|
37
|
+
### Step 2: 分析
|
|
38
|
+
基于 Step 1 返回的上下文,分析问题根因或设计方案。
|
|
39
|
+
此时可以自由使用 Read 查看具体文件。
|
|
40
|
+
|
|
41
|
+
### Step 3: 执行
|
|
42
|
+
根据分析结果修改代码,逐文件编辑。
|
|
43
|
+
|
|
44
|
+
### Step 4: 验证
|
|
45
|
+
运行类型检查和测试,确保改动正确。
|
|
46
|
+
|
|
47
|
+
## 可用工具
|
|
48
|
+
|
|
49
|
+
| 工具 | 何时调用 |
|
|
50
|
+
|------|----------|
|
|
51
|
+
| `mcp__devflow__get_project_context` | 每次任务第一步(必须) |
|
|
52
|
+
| `mcp__devflow__run_workflow` | 按需调用 |
|
|
53
|
+
|
|
54
|
+
## 规则
|
|
55
|
+
- 永远从 `mcp__devflow__get_project_context` 开始——你不知道项目里有什么
|
|
56
|
+
- 上下文返回后,用 Read 确认关键文件
|
|
57
|
+
- 改完代码后跑类型检查
|
|
58
|
+
|
|
59
|
+
## 规则
|
|
60
|
+
- 永远从 `get_project_context` 开始——你不知道项目里有什么
|
|
61
|
+
- 上下文返回后,用 Read 确认关键文件
|
|
62
|
+
- 改完代码后跑类型检查
|
|
63
|
+
|
|
64
|
+
## 规则
|
|
65
|
+
- 永远从 `run_workflow` 开始——你不知道项目里有什么
|
|
66
|
+
- 上下文返回后,用 Read 确认关键文件
|
|
67
|
+
- 改完代码后跑类型检查
|
|
68
|
+
|
|
69
|
+
# /devflow:workflow
|
|
70
|
+
|
|
71
|
+
## 执行
|
|
72
|
+
|
|
73
|
+
调用 `mcp__devflow__run_workflow` MCP 工具:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
type = "bugfix" | "feature" | "review"
|
|
77
|
+
input = 用户的查询内容
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
MCP 工具提供标准化的 DAG 步骤编排、人工确认节点、执行追踪和遥测记录。工作流执行过程中,MCP 工具会返回需要你介入的步骤,此时才根据步骤指引执行具体操作。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<EXTREMELY_IMPORTANT>
|
|
2
|
+
你正在使用 DevFlow MCP Gateway。
|
|
3
|
+
|
|
4
|
+
## MCP 优先原则
|
|
5
|
+
|
|
6
|
+
收到 /devflow:* 命令时,必须先调用 SKILL.md 中列出的 MCP 工具。
|
|
7
|
+
Hook 会自动拦截不符合规范的原生工具调用,并按提示引导你使用正确的 MCP 工具。
|
|
8
|
+
|
|
9
|
+
正确流程:
|
|
10
|
+
1. 调用 Skill 加载命令
|
|
11
|
+
2. 立即调用 MCP 工具
|
|
12
|
+
3. 基于 MCP 结果回答
|
|
13
|
+
4. 如需补充信息,使用 Read 工具读取 MCP 未包含的关联文件
|
|
14
|
+
|
|
15
|
+
绝对不要:
|
|
16
|
+
- 在调用 MCP 之前用 grep/find/Glob/Explore 搜索代码
|
|
17
|
+
- 用 WebSearch/WebFetch 替代 get_knowledge
|
|
18
|
+
- 用 Agent(Explore) 替代 MCP 工具
|
|
19
|
+
- 尝试绕过 Hook 拦截
|
|
20
|
+
</EXTREMELY_IMPORTANT>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# DevFlow PostToolUse Hook — talks to hook-daemon via hook-client
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$SCRIPT_DIR/..}"
|
|
7
|
+
CLIENT_JS="$PLUGIN_ROOT/dist/hooks/hook-client.js"
|
|
8
|
+
FALLBACK_JS="$PLUGIN_ROOT/dist/hooks/post-tool-use.js"
|
|
9
|
+
|
|
10
|
+
INPUT="$(cat)"
|
|
11
|
+
|
|
12
|
+
if [ -f "$CLIENT_JS" ]; then
|
|
13
|
+
node "$CLIENT_JS" post-tool-use "$INPUT" 2>/dev/null || {
|
|
14
|
+
echo "$INPUT" | node "$FALLBACK_JS" 2>/dev/null || true
|
|
15
|
+
}
|
|
16
|
+
elif [ -f "$FALLBACK_JS" ]; then
|
|
17
|
+
echo "$INPUT" | node "$FALLBACK_JS" 2>/dev/null || true
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
exit 0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# DevFlow PreToolUse Hook — talks to hook-daemon via hook-client
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$SCRIPT_DIR/..}"
|
|
7
|
+
CLIENT_JS="$PLUGIN_ROOT/dist/hooks/hook-client.js"
|
|
8
|
+
FALLBACK_JS="$PLUGIN_ROOT/dist/hooks/pre-tool-use.js"
|
|
9
|
+
|
|
10
|
+
if [ -f "$CLIENT_JS" ]; then
|
|
11
|
+
node "$CLIENT_JS" pre-tool-use || {
|
|
12
|
+
echo '[devflow] hook-client failed, trying fallback' >&2
|
|
13
|
+
if [ -f "$FALLBACK_JS" ]; then
|
|
14
|
+
node "$FALLBACK_JS" || echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
|
|
15
|
+
else
|
|
16
|
+
echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
|
|
17
|
+
fi
|
|
18
|
+
}
|
|
19
|
+
elif [ -f "$FALLBACK_JS" ]; then
|
|
20
|
+
node "$FALLBACK_JS" || echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
|
|
21
|
+
else
|
|
22
|
+
echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
|
|
23
|
+
fi
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Try to get project summary from devflow doctor
|
|
5
|
+
SUMMARY=""
|
|
6
|
+
DOCTOR_OUTPUT=""
|
|
7
|
+
|
|
8
|
+
# Try global devflow first, then npx fallback
|
|
9
|
+
if command -v devflow &>/dev/null; then
|
|
10
|
+
DOCTOR_OUTPUT=$(devflow doctor --json 2>/dev/null || echo "")
|
|
11
|
+
elif command -v npx &>/dev/null; then
|
|
12
|
+
DOCTOR_OUTPUT=$(npx --yes @devflow-tools/cli doctor --json 2>/dev/null || echo "")
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
if [ -n "$DOCTOR_OUTPUT" ] && echo "$DOCTOR_OUTPUT" | python3 -c "import sys,json; json.load(sys.stdin)" 2>/dev/null; then
|
|
16
|
+
PROJECT_NAME=$(echo "$DOCTOR_OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('project',{}).get('name','') or d.get('projectName',''))" 2>/dev/null || echo "")
|
|
17
|
+
FILES=$(echo "$DOCTOR_OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('project',{}).get('files', d.get('indexedFiles','?')))" 2>/dev/null || echo "?")
|
|
18
|
+
TECH=$(echo "$DOCTOR_OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); s=d.get('project',{}).get('techStack',[]); print(', '.join(s) if s else 'unknown')" 2>/dev/null || echo "unknown")
|
|
19
|
+
ENGINES=$(echo "$DOCTOR_OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); e=d.get('engines',{}); print(' '.join([f'{k} {\"✓\" if v else \"✗\"}' for k,v in e.items()]))" 2>/dev/null || echo "")
|
|
20
|
+
PLUGINS=$(echo "$DOCTOR_OUTPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); p=d.get('plugins',[]); print(', '.join(p))" 2>/dev/null || echo "")
|
|
21
|
+
|
|
22
|
+
SUMMARY="DevFlow 已就绪。项目 ${PROJECT_NAME:-unknown} (${TECH})。${FILES} 个文件已索引。引擎:${ENGINES}。已装插件:${PLUGINS}。使用 /devflow:context 查代码,/devflow:react 获取 React 专家能力。"
|
|
23
|
+
else
|
|
24
|
+
SUMMARY="DevFlow 插件已加载。如尚未初始化项目,请运行 devflow init。使用 /devflow 查看可用命令。"
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# Generate session token for MCP Gateway authentication
|
|
28
|
+
# Clean up stale receipt from previous session
|
|
29
|
+
PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
30
|
+
RECEIPT_DIR="${TMPDIR:-/tmp}/.devflow-receipts"
|
|
31
|
+
mkdir -p "$RECEIPT_DIR" 2>/dev/null || true
|
|
32
|
+
SESSION_ID=$(echo -n "$PROJECT_ROOT" | shasum -a 256 2>/dev/null | cut -c1-16 || echo "default")
|
|
33
|
+
RECEIPT_FILE="$RECEIPT_DIR/${SESSION_ID}.json"
|
|
34
|
+
OVERRIDE_FILE="$RECEIPT_DIR/${SESSION_ID}.override"
|
|
35
|
+
rm -f "$RECEIPT_FILE" "$OVERRIDE_FILE" 2>/dev/null || true
|
|
36
|
+
|
|
37
|
+
# ── Clean up stale execution from previous session (if stop hook didn't fire) ──
|
|
38
|
+
EXEC_FILE="${HOME}/.devflow/current-execution-id"
|
|
39
|
+
SKILL_FILE="${HOME}/.devflow/current-skill.json"
|
|
40
|
+
if [ -f "$EXEC_FILE" ]; then
|
|
41
|
+
EXEC_ID=$(cat "$EXEC_FILE" 2>/dev/null || echo "")
|
|
42
|
+
if [ -n "$EXEC_ID" ]; then
|
|
43
|
+
NOW_MS="$(date +%s)000"
|
|
44
|
+
python3 -c "
|
|
45
|
+
import urllib.request, json
|
|
46
|
+
try:
|
|
47
|
+
payload = json.dumps({
|
|
48
|
+
'executionId': '${EXEC_ID}',
|
|
49
|
+
'finishedAt': ${NOW_MS},
|
|
50
|
+
'status': 'completed',
|
|
51
|
+
'summary': {
|
|
52
|
+
'totalToolCalls': 0,
|
|
53
|
+
'mcpToolCalls': 0,
|
|
54
|
+
'directToolCalls': 0,
|
|
55
|
+
'subagentCount': 0,
|
|
56
|
+
'totalTokens': 0,
|
|
57
|
+
'totalDuration': 0,
|
|
58
|
+
'mcpComplianceRate': 0
|
|
59
|
+
}
|
|
60
|
+
}).encode()
|
|
61
|
+
req = urllib.request.Request(
|
|
62
|
+
'http://127.0.0.1:13337/api/telemetry/skill-execution/complete',
|
|
63
|
+
data=payload,
|
|
64
|
+
headers={'Content-Type': 'application/json', 'X-API-Key': 'dev-key-000000'},
|
|
65
|
+
method='POST'
|
|
66
|
+
)
|
|
67
|
+
urllib.request.urlopen(req, timeout=5)
|
|
68
|
+
except:
|
|
69
|
+
pass
|
|
70
|
+
" 2>/dev/null || true
|
|
71
|
+
fi
|
|
72
|
+
rm -f "$EXEC_FILE" "$SKILL_FILE" 2>/dev/null || true
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Determine plugin root directory (same way as superpowers)
|
|
76
|
+
if [ -z "${CLAUDE_PLUGIN_ROOT:-}" ]; then
|
|
77
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
78
|
+
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
79
|
+
else
|
|
80
|
+
PLUGIN_ROOT="$CLAUDE_PLUGIN_ROOT"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
# Read DevFlow Constitution from file (avoids shell escaping issues)
|
|
84
|
+
CONSTITUTION_FILE="${PLUGIN_ROOT}/skills/devflow/SKILL.md"
|
|
85
|
+
if [ -f "${PLUGIN_ROOT}/hooks/constitution.md" ]; then
|
|
86
|
+
CONSTITUTION_FILE="${PLUGIN_ROOT}/hooks/constitution.md"
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
if [ -f "$CONSTITUTION_FILE" ]; then
|
|
90
|
+
GLOBAL_CONSTRAINT=$(cat "$CONSTITUTION_FILE" 2>/dev/null || echo "DevFlow Constitution 加载失败")
|
|
91
|
+
else
|
|
92
|
+
GLOBAL_CONSTRAINT="DevFlow Constitution 文件未找到。使用 /devflow: 命令时请优先调用 MCP 工具。"
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# Append Gateway status to summary
|
|
96
|
+
GATEWAY_STATUS="\n\n━━━━━━ DevFlow Gateway ━━━━━━\n"
|
|
97
|
+
# Check if devflow MCP server is configured (token will be auto-generated by ensureSessionToken)
|
|
98
|
+
if [ -f ~/.claude/.mcp.json ] && grep -q '"devflow"' ~/.claude/.mcp.json 2>/dev/null; then
|
|
99
|
+
GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🟢 DevFlow MCP 已配置\nGate 层数: 4 (宪法 → 派发 → 拦截 → 纠正)\n"
|
|
100
|
+
elif [ -f .mcp.json ] && grep -q '"devflow"' .mcp.json 2>/dev/null; then
|
|
101
|
+
GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🟢 DevFlow MCP 已配置(项目级)\nGate 层数: 4 (宪法 → 派发 → 拦截 → 纠正)\n"
|
|
102
|
+
else
|
|
103
|
+
GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🔴 未配置 DevFlow MCP Server\n请将 devflow MCP 配置加入 .mcp.json\n"
|
|
104
|
+
fi
|
|
105
|
+
GATEWAY_STATUS="${GATEWAY_STATUS}━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
106
|
+
|
|
107
|
+
# ── MCP Tool Usage Protocol (injected into every session) ──
|
|
108
|
+
MCP_PROTOCOL="
|
|
109
|
+
|
|
110
|
+
## DevFlow MCP 工具使用协议(必须遵守)
|
|
111
|
+
|
|
112
|
+
当用户使用 /devflow: 开头的技能时(如 /devflow:react、/devflow:vue、/devflow:context 等),你必须按以下流程操作:
|
|
113
|
+
|
|
114
|
+
### Step 1: 获取上下文(必须先执行)
|
|
115
|
+
调用 mcp__devflow__get_project_context,参数格式:{\"query\": \"用户的问题描述\"}
|
|
116
|
+
这个工具返回项目中的相关文件、符号、风险提示和下一步建议。
|
|
117
|
+
不要跳过这一步。不要用 Explore、Agent、Grep 或 Bash 代替。
|
|
118
|
+
|
|
119
|
+
### Step 2: 按需调用领域工具
|
|
120
|
+
根据技能类型调用对应的 MCP 工具:
|
|
121
|
+
- React 性能问题 → mcp__devflow__react_audit_performance(无需参数)
|
|
122
|
+
- React Bug → mcp__devflow__react_diagnose_bug
|
|
123
|
+
- React Hooks 审查 → mcp__devflow__react_review_hooks
|
|
124
|
+
- Vue 问题 → mcp__devflow__vue_diagnose_bug
|
|
125
|
+
- NestJS 问题 → mcp__devflow__nest_diagnose_bug
|
|
126
|
+
- 代码搜索 → mcp__devflow__search_symbol
|
|
127
|
+
- 知识查询 → mcp__devflow__get_knowledge
|
|
128
|
+
|
|
129
|
+
### Step 3: 基于工具返回结果进行分析
|
|
130
|
+
用 Read 确认工具返回的关键文件,然后给出分析结论。
|
|
131
|
+
|
|
132
|
+
### 铁律
|
|
133
|
+
- 永远不要用 Explore、Agent、Grep 或 Glob 替代 MCP 工具的第一步上下文获取
|
|
134
|
+
- 所有 mcp__devflow__ 工具的 projectRoot 参数都是可选的,无需传
|
|
135
|
+
- 如果 MCP 工具返回错误,重试一次;再失败则回退到直接读文件"
|
|
136
|
+
|
|
137
|
+
SUMMARY="${SUMMARY}${MCP_PROTOCOL}${GLOBAL_CONSTRAINT}${GATEWAY_STATUS}"
|
|
138
|
+
|
|
139
|
+
# Escape for JSON
|
|
140
|
+
ESCAPED=$(echo "$SUMMARY" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))")
|
|
141
|
+
|
|
142
|
+
# Output context injection in Claude Code format (always output, even without CLAUDE_PLUGIN_ROOT)
|
|
143
|
+
printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": %s\n }\n}\n' "$ESCAPED"
|
|
144
|
+
|
|
145
|
+
# ── Start hook daemon (background, Unix socket) ──
|
|
146
|
+
DAEMON_JS="${PLUGIN_ROOT}/dist/hooks/hook-daemon.js"
|
|
147
|
+
if [ -f "$DAEMON_JS" ]; then
|
|
148
|
+
# Kill any stale daemon from previous session
|
|
149
|
+
STALE_PID=$(pgrep -f "hook-daemon.js" 2>/dev/null || true)
|
|
150
|
+
if [ -n "$STALE_PID" ]; then
|
|
151
|
+
kill "$STALE_PID" 2>/dev/null || true
|
|
152
|
+
sleep 0.5
|
|
153
|
+
fi
|
|
154
|
+
node "$DAEMON_JS" "${CLAUDE_PROJECT_DIR:-$(pwd)}" &
|
|
155
|
+
echo "[devflow] Hook daemon started (PID $!)" >&2
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
# ── Trigger memory extraction for previous session events (best-effort, async) ──
|
|
159
|
+
(python3 -c "
|
|
160
|
+
import urllib.request, json, sys
|
|
161
|
+
try:
|
|
162
|
+
req = urllib.request.Request(
|
|
163
|
+
'http://127.0.0.1:13337/api/memory/process?rootPath=${CLAUDE_PROJECT_DIR:-$(pwd)}',
|
|
164
|
+
data=b'{}',
|
|
165
|
+
headers={'Content-Type': 'application/json', 'X-API-Key': 'dev-key-000000'},
|
|
166
|
+
method='POST',
|
|
167
|
+
)
|
|
168
|
+
resp = urllib.request.urlopen(req, timeout=30)
|
|
169
|
+
result = json.loads(resp.read())
|
|
170
|
+
print('DevFlow memory: {} extracted, {} approved, {} pending'.format(
|
|
171
|
+
result.get('extracted', 0), result.get('approved', 0), result.get('pending', 0)), file=sys.stderr)
|
|
172
|
+
except Exception as e:
|
|
173
|
+
print('DevFlow memory extraction skipped: {}'.format(e), file=sys.stderr)
|
|
174
|
+
" 2>/dev/null || true) &
|
|
175
|
+
|
|
176
|
+
exit 0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# DevFlow Stop Hook — graceful daemon shutdown + cleanup
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$SCRIPT_DIR/..}"
|
|
7
|
+
|
|
8
|
+
# 1. Tell daemon to stop via hook-client
|
|
9
|
+
CLIENT_JS="$PLUGIN_ROOT/dist/hooks/hook-client.js"
|
|
10
|
+
if [ -f "$CLIENT_JS" ]; then
|
|
11
|
+
node "$CLIENT_JS" stop </dev/null 2>/dev/null || true
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
# 2. Fallback: kill any remaining daemon process
|
|
15
|
+
DAEMON_PID=$(pgrep -f "hook-daemon.js" 2>/dev/null || true)
|
|
16
|
+
if [ -n "$DAEMON_PID" ]; then
|
|
17
|
+
kill "$DAEMON_PID" 2>/dev/null || true
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# 3. Run existing stop.js cleanup (session close, memory extraction)
|
|
21
|
+
STOP_JS="$PLUGIN_ROOT/dist/hooks/stop.js"
|
|
22
|
+
if [ -f "$STOP_JS" ]; then
|
|
23
|
+
node "$STOP_JS" 2>/dev/null || true
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# 4. Clean up stale receipt files for this project
|
|
27
|
+
PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
28
|
+
SESSION_ID=$(echo -n "$PROJECT_ROOT" | shasum -a 256 2>/dev/null | cut -c1-16 || echo "")
|
|
29
|
+
RECEIPT_FILE="${TMPDIR:-/tmp}/.devflow-receipts/${SESSION_ID}.json"
|
|
30
|
+
rm -f "$RECEIPT_FILE" 2>/dev/null || true
|
|
31
|
+
|
|
32
|
+
exit 0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start\"",
|
|
10
|
+
"async": false
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"PreToolUse": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": "*",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/pre-tool-use\"",
|
|
22
|
+
"async": false
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"PostToolUse": [
|
|
28
|
+
{
|
|
29
|
+
"matcher": "*",
|
|
30
|
+
"hooks": [
|
|
31
|
+
{
|
|
32
|
+
"type": "command",
|
|
33
|
+
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/post-tool-use\"",
|
|
34
|
+
"async": false
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"Stop": [
|
|
40
|
+
{
|
|
41
|
+
"matcher": "",
|
|
42
|
+
"hooks": [
|
|
43
|
+
{
|
|
44
|
+
"type": "command",
|
|
45
|
+
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/stop\"",
|
|
46
|
+
"async": false
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@devflow-tools/claude-code-plugin",
|
|
3
|
+
"version": "0.13.0",
|
|
4
|
+
"description": "DevFlow — Developer Intelligence Platform for Claude Code",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "npx tsx scripts/inject-gates.ts",
|
|
8
|
+
"deploy": "npx tsx scripts/inject-gates.ts --deploy"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@devflow-tools/mcp-server": "^0.13.0"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"pi-package",
|
|
15
|
+
"skills",
|
|
16
|
+
"development",
|
|
17
|
+
"context",
|
|
18
|
+
"knowledge-base"
|
|
19
|
+
],
|
|
20
|
+
"pi": {
|
|
21
|
+
"skills": [
|
|
22
|
+
"./skills"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"hooks",
|
|
28
|
+
"hooks.json",
|
|
29
|
+
"skills"
|
|
30
|
+
]
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devflow-tools/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,31 +12,31 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@colbymchenry/codegraph": "^1.1.1",
|
|
15
|
-
"@devflow-tools/adapters": "^0.
|
|
16
|
-
"@devflow-tools/benchmark": "^0.
|
|
17
|
-
"@devflow-tools/context-engine": "^0.
|
|
18
|
-
"@devflow-tools/database": "^0.
|
|
19
|
-
"@devflow-tools/knowledge-engine": "^0.
|
|
20
|
-
"@devflow-tools/mcp-server": "^0.
|
|
21
|
-
"@devflow-tools/memory-engine": "^0.
|
|
22
|
-
"@devflow-tools/plugin-animation": "^0.
|
|
23
|
-
"@devflow-tools/plugin-css": "^0.
|
|
24
|
-
"@devflow-tools/plugin-docker": "^0.
|
|
25
|
-
"@devflow-tools/plugin-electron": "^0.
|
|
26
|
-
"@devflow-tools/plugin-git": "^0.
|
|
27
|
-
"@devflow-tools/plugin-graphql": "^0.
|
|
28
|
-
"@devflow-tools/plugin-nest": "^0.
|
|
29
|
-
"@devflow-tools/plugin-nextjs": "^0.
|
|
30
|
-
"@devflow-tools/plugin-performance": "^0.
|
|
31
|
-
"@devflow-tools/plugin-react": "^0.
|
|
32
|
-
"@devflow-tools/plugin-tailwind": "^0.
|
|
33
|
-
"@devflow-tools/plugin-taro": "^0.
|
|
34
|
-
"@devflow-tools/plugin-ui-layout": "^0.
|
|
35
|
-
"@devflow-tools/plugin-vue": "^0.
|
|
36
|
-
"@devflow-tools/sdk": "^0.
|
|
37
|
-
"@devflow-tools/server": "^0.
|
|
38
|
-
"@devflow-tools/telemetry": "^0.
|
|
39
|
-
"@devflow-tools/workflow-engine": "^0.
|
|
15
|
+
"@devflow-tools/adapters": "^0.13.1",
|
|
16
|
+
"@devflow-tools/benchmark": "^0.13.1",
|
|
17
|
+
"@devflow-tools/context-engine": "^0.13.1",
|
|
18
|
+
"@devflow-tools/database": "^0.13.1",
|
|
19
|
+
"@devflow-tools/knowledge-engine": "^0.13.1",
|
|
20
|
+
"@devflow-tools/mcp-server": "^0.13.1",
|
|
21
|
+
"@devflow-tools/memory-engine": "^0.13.1",
|
|
22
|
+
"@devflow-tools/plugin-animation": "^0.13.1",
|
|
23
|
+
"@devflow-tools/plugin-css": "^0.13.1",
|
|
24
|
+
"@devflow-tools/plugin-docker": "^0.13.1",
|
|
25
|
+
"@devflow-tools/plugin-electron": "^0.13.1",
|
|
26
|
+
"@devflow-tools/plugin-git": "^0.13.1",
|
|
27
|
+
"@devflow-tools/plugin-graphql": "^0.13.1",
|
|
28
|
+
"@devflow-tools/plugin-nest": "^0.13.1",
|
|
29
|
+
"@devflow-tools/plugin-nextjs": "^0.13.1",
|
|
30
|
+
"@devflow-tools/plugin-performance": "^0.13.1",
|
|
31
|
+
"@devflow-tools/plugin-react": "^0.13.1",
|
|
32
|
+
"@devflow-tools/plugin-tailwind": "^0.13.1",
|
|
33
|
+
"@devflow-tools/plugin-taro": "^0.13.1",
|
|
34
|
+
"@devflow-tools/plugin-ui-layout": "^0.13.1",
|
|
35
|
+
"@devflow-tools/plugin-vue": "^0.13.1",
|
|
36
|
+
"@devflow-tools/sdk": "^0.13.1",
|
|
37
|
+
"@devflow-tools/server": "^0.13.1",
|
|
38
|
+
"@devflow-tools/telemetry": "^0.13.1",
|
|
39
|
+
"@devflow-tools/workflow-engine": "^0.13.1",
|
|
40
40
|
"@inquirer/prompts": "^7.10.1",
|
|
41
41
|
"chalk": "^5.3.0",
|
|
42
42
|
"commander": "^12.0.0"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"dist",
|
|
50
50
|
"bin"
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "28618c4d84bea33bdd4f433bfc740c1ce2591d51"
|
|
53
53
|
}
|