@devflow-tools/devflow 0.15.0 → 0.16.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.
Files changed (136) hide show
  1. package/acceptance-manifest.json +35 -0
  2. package/dist/cli.js +115 -28
  3. package/dist/dashboard/404.html +1 -0
  4. package/dist/dashboard/_next/static/PV20UFAxDva62WLq6zWVa/_buildManifest.js +1 -0
  5. package/dist/dashboard/_next/static/PV20UFAxDva62WLq6zWVa/_ssgManifest.js +1 -0
  6. package/dist/dashboard/_next/static/chunks/1dd3208c-f3e84932bdc53383.js +1 -0
  7. package/dist/dashboard/_next/static/chunks/221-893fab1a7d7d9317.js +1 -0
  8. package/dist/dashboard/_next/static/chunks/249-e04c1de6240fd78a.js +1 -0
  9. package/dist/dashboard/_next/static/chunks/343-09a7e255220705c5.js +1 -0
  10. package/dist/dashboard/_next/static/chunks/402-a2e4eb98bb6a524c.js +1 -0
  11. package/dist/dashboard/_next/static/chunks/429-eac85fdc49353ed8.js +1 -0
  12. package/dist/dashboard/_next/static/chunks/458-75822399a849befa.js +1 -0
  13. package/dist/dashboard/_next/static/chunks/528-7d4fc14903647f1e.js +2 -0
  14. package/dist/dashboard/_next/static/chunks/568-50487ea5e93fe11f.js +1 -0
  15. package/dist/dashboard/_next/static/chunks/697-05cf55b6c667773f.js +1 -0
  16. package/dist/dashboard/_next/static/chunks/6b3bb038-34d5cf36bd0210d6.js +1 -0
  17. package/dist/dashboard/_next/static/chunks/736-db1a009357c222d2.js +1 -0
  18. package/dist/dashboard/_next/static/chunks/806-195d4d5cc6c28f6c.js +1 -0
  19. package/dist/dashboard/_next/static/chunks/app/_not-found/page-5252c260804ee1ce.js +1 -0
  20. package/dist/dashboard/_next/static/chunks/app/accuracy/page-ca6a419d8b29eb4f.js +1 -0
  21. package/dist/dashboard/_next/static/chunks/app/benchmark/page-6c6d0acbcde4eb85.js +1 -0
  22. package/dist/dashboard/_next/static/chunks/app/context/page-1874ae1050524cb6.js +1 -0
  23. package/dist/dashboard/_next/static/chunks/app/doctor/page-d542f2ab8d6a1c59.js +1 -0
  24. package/dist/dashboard/_next/static/chunks/app/executions/page-b98ec834dcda8d93.js +1 -0
  25. package/dist/dashboard/_next/static/chunks/app/graph/page-f0e7e15288791e9c.js +1 -0
  26. package/dist/dashboard/_next/static/chunks/app/knowledge/page-86808abd0d47c026.js +1 -0
  27. package/dist/dashboard/_next/static/chunks/app/layout-4b78776412bd4fee.js +1 -0
  28. package/dist/dashboard/_next/static/chunks/app/memory/page-e169762426ac7a23.js +1 -0
  29. package/dist/dashboard/_next/static/chunks/app/page-c3e980fb2621470c.js +1 -0
  30. package/dist/dashboard/_next/static/chunks/app/replay/page-a8a465ed885df0cf.js +1 -0
  31. package/dist/dashboard/_next/static/chunks/app/runs/[id]/page-cc1d5182707fca5b.js +1 -0
  32. package/dist/dashboard/_next/static/chunks/app/runs/page-bbf0a58abd70430c.js +1 -0
  33. package/dist/dashboard/_next/static/chunks/app/settings/page-9602ff45892e7910.js +1 -0
  34. package/dist/dashboard/_next/static/chunks/app/timeline/page-a8eb3caf23be8a86.js +1 -0
  35. package/dist/dashboard/_next/static/chunks/app/tool-metrics/page-1f86f62b187f2b5e.js +1 -0
  36. package/dist/dashboard/_next/static/chunks/app/workflows/page-551939c9e86b26c6.js +1 -0
  37. package/dist/dashboard/_next/static/chunks/framework-58c3457e28c4602f.js +1 -0
  38. package/dist/dashboard/_next/static/chunks/main-3175faffdbfc3051.js +1 -0
  39. package/dist/dashboard/_next/static/chunks/main-app-202a5f91ead17fa7.js +1 -0
  40. package/dist/dashboard/_next/static/chunks/pages/_app-58c3f1a8a070bd35.js +1 -0
  41. package/dist/dashboard/_next/static/chunks/pages/_error-312a564ec7e2663f.js +1 -0
  42. package/dist/dashboard/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  43. package/dist/dashboard/_next/static/chunks/webpack-d6388c5dcd85b0c5.js +1 -0
  44. package/dist/dashboard/_next/static/css/322e14d06135256b.css +31 -0
  45. package/dist/dashboard/_next/static/css/7d4d1db5aa137b5a.css +3 -0
  46. package/dist/dashboard/accuracy.html +1 -0
  47. package/dist/dashboard/accuracy.txt +7 -0
  48. package/dist/dashboard/benchmark.html +1 -0
  49. package/dist/dashboard/benchmark.txt +7 -0
  50. package/dist/dashboard/context.html +1 -0
  51. package/dist/dashboard/context.txt +7 -0
  52. package/dist/dashboard/doctor.html +1 -0
  53. package/dist/dashboard/doctor.txt +7 -0
  54. package/dist/dashboard/executions.html +1 -0
  55. package/dist/dashboard/executions.txt +7 -0
  56. package/dist/dashboard/graph.html +1 -0
  57. package/dist/dashboard/graph.txt +7 -0
  58. package/dist/dashboard/index.html +1 -0
  59. package/dist/dashboard/index.txt +7 -0
  60. package/dist/dashboard/knowledge.html +1 -0
  61. package/dist/dashboard/knowledge.txt +7 -0
  62. package/dist/dashboard/locales/en.json +335 -0
  63. package/dist/dashboard/locales/zh.json +335 -0
  64. package/dist/dashboard/memory.html +1 -0
  65. package/dist/dashboard/memory.txt +7 -0
  66. package/dist/dashboard/replay.html +1 -0
  67. package/dist/dashboard/replay.txt +7 -0
  68. package/dist/dashboard/runs/_.html +1 -0
  69. package/dist/dashboard/runs/_.txt +8 -0
  70. package/dist/dashboard/runs.html +1 -0
  71. package/dist/dashboard/runs.txt +7 -0
  72. package/dist/dashboard/settings.html +1 -0
  73. package/dist/dashboard/settings.txt +7 -0
  74. package/dist/dashboard/timeline.html +1 -0
  75. package/dist/dashboard/timeline.txt +7 -0
  76. package/dist/dashboard/tool-metrics.html +1 -0
  77. package/dist/dashboard/tool-metrics.txt +7 -0
  78. package/dist/dashboard/workflows.html +1 -0
  79. package/dist/dashboard/workflows.txt +7 -0
  80. package/dist/fallback.html +1 -3
  81. package/dist/hooks/enforcer-summary.js +6 -0
  82. package/dist/hooks/hook-client.js +6 -8
  83. package/dist/hooks/hook-daemon.js +13 -7
  84. package/dist/hooks/post-tool-use-failure.js +2 -2
  85. package/dist/hooks/post-tool-use.js +3 -2
  86. package/dist/hooks/pre-compact.js +3 -2
  87. package/dist/hooks/pre-tool-use.js +2 -2
  88. package/dist/hooks/server-bootstrap.js +109 -0
  89. package/dist/hooks/session-end.js +2 -2
  90. package/dist/hooks/stop.js +2 -2
  91. package/dist/hooks/user-prompt-submit.js +2 -2
  92. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  93. package/dist/plugin/CLAUDE.md +34 -0
  94. package/dist/plugin/dist/command-registry.json +297 -0
  95. package/dist/plugin/dist/hooks/enforcer-summary.js +6 -0
  96. package/dist/plugin/dist/hooks/hook-client.js +6 -0
  97. package/dist/plugin/dist/hooks/hook-daemon.js +14 -0
  98. package/dist/plugin/dist/hooks/post-tool-use-failure.js +2 -0
  99. package/dist/plugin/dist/hooks/post-tool-use.js +3 -0
  100. package/dist/plugin/dist/hooks/pre-compact.js +3 -0
  101. package/dist/plugin/dist/hooks/pre-tool-use.js +2 -0
  102. package/dist/plugin/dist/hooks/server-bootstrap.js +109 -0
  103. package/dist/plugin/dist/hooks/session-end.js +2 -0
  104. package/dist/plugin/dist/hooks/stop.js +2 -0
  105. package/dist/plugin/dist/hooks/user-prompt-submit.js +2 -0
  106. package/dist/plugin/dist/skills/devflow:animation/SKILL.md +63 -0
  107. package/dist/plugin/dist/skills/devflow:context/SKILL.md +90 -0
  108. package/dist/plugin/dist/skills/devflow:css/SKILL.md +63 -0
  109. package/dist/plugin/dist/skills/devflow:docker/SKILL.md +67 -0
  110. package/dist/plugin/dist/skills/devflow:electron/SKILL.md +67 -0
  111. package/dist/plugin/dist/skills/devflow:git/SKILL.md +67 -0
  112. package/dist/plugin/dist/skills/devflow:graph/SKILL.md +80 -0
  113. package/dist/plugin/dist/skills/devflow:graphql/SKILL.md +66 -0
  114. package/dist/plugin/dist/skills/devflow:knowledge/SKILL.md +80 -0
  115. package/dist/plugin/dist/skills/devflow:memory/SKILL.md +79 -0
  116. package/dist/plugin/dist/skills/devflow:nest/SKILL.md +68 -0
  117. package/dist/plugin/dist/skills/devflow:nextjs/SKILL.md +65 -0
  118. package/dist/plugin/dist/skills/devflow:performance/SKILL.md +67 -0
  119. package/dist/plugin/dist/skills/devflow:react/SKILL.md +83 -0
  120. package/dist/plugin/dist/skills/devflow:tailwind/SKILL.md +65 -0
  121. package/dist/plugin/dist/skills/devflow:taro/SKILL.md +66 -0
  122. package/dist/plugin/dist/skills/devflow:ui-layout/SKILL.md +63 -0
  123. package/dist/plugin/dist/skills/devflow:vue/SKILL.md +72 -0
  124. package/dist/plugin/dist/skills/devflow:workflow/SKILL.md +80 -0
  125. package/dist/plugin/hooks/constitution.md +20 -0
  126. package/dist/plugin/hooks/post-tool-use +20 -0
  127. package/dist/plugin/hooks/post-tool-use-failure +19 -0
  128. package/dist/plugin/hooks/pre-compact +19 -0
  129. package/dist/plugin/hooks/pre-tool-use +23 -0
  130. package/dist/plugin/hooks/session-end +19 -0
  131. package/dist/plugin/hooks/session-start +259 -0
  132. package/dist/plugin/hooks/stop +26 -0
  133. package/dist/plugin/hooks/user-prompt-submit +19 -0
  134. package/dist/plugin/package.json +44 -0
  135. package/package.json +14 -13
  136. package/plugin-registry.json +30 -46
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$SCRIPT_DIR/..}"
6
+ CLIENT_JS="$PLUGIN_ROOT/dist/hooks/hook-client.js"
7
+ FALLBACK_JS="$PLUGIN_ROOT/dist/hooks/session-end.js"
8
+
9
+ INPUT="$(cat)"
10
+
11
+ if [ -f "$CLIENT_JS" ]; then
12
+ node "$CLIENT_JS" session-end "$INPUT" 2>/dev/null || {
13
+ echo "$INPUT" | DEVFLOW_HOOK_DEGRADED=1 node "$FALLBACK_JS" 2>/dev/null || true
14
+ }
15
+ elif [ -f "$FALLBACK_JS" ]; then
16
+ echo "$INPUT" | DEVFLOW_HOOK_DEGRADED=1 node "$FALLBACK_JS" 2>/dev/null || true
17
+ fi
18
+
19
+ exit 0
@@ -0,0 +1,259 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
5
+ SESSION_START_INPUT="$(cat)"
6
+
7
+ # Try to get project summary from devflow doctor
8
+ SUMMARY=""
9
+ DOCTOR_OUTPUT=""
10
+
11
+ # Try global devflow first, then npx fallback
12
+ if command -v devflow &>/dev/null; then
13
+ DOCTOR_OUTPUT=$(devflow doctor --json 2>/dev/null || echo "")
14
+ elif command -v npx &>/dev/null; then
15
+ DOCTOR_OUTPUT=$(npx --yes @devflow-tools/cli doctor --json 2>/dev/null || echo "")
16
+ fi
17
+
18
+ if [ -n "$DOCTOR_OUTPUT" ] && echo "$DOCTOR_OUTPUT" | python3 -c "import sys,json; json.load(sys.stdin)" 2>/dev/null; then
19
+ 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 "")
20
+ 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 "?")
21
+ 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")
22
+ 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 "")
23
+ 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 "")
24
+
25
+ SUMMARY="DevFlow 已就绪。项目 ${PROJECT_NAME:-unknown} (${TECH})。${FILES} 个文件已索引。引擎:${ENGINES}。已装插件:${PLUGINS}。使用 /devflow:context 查代码,/devflow:react 获取 React 专家能力。"
26
+ else
27
+ SUMMARY="DevFlow 插件已加载。如尚未初始化项目,请运行 devflow init。使用 /devflow 查看可用命令。"
28
+ fi
29
+
30
+ # Generate session token for MCP Gateway authentication
31
+ # Clean up stale receipt from previous session
32
+ RECEIPT_DIR="${TMPDIR:-/tmp}/.devflow-receipts"
33
+ mkdir -p "$RECEIPT_DIR" 2>/dev/null || true
34
+ SESSION_ID=$(echo -n "$PROJECT_ROOT" | shasum -a 256 2>/dev/null | cut -c1-16 || echo "default")
35
+ RECEIPT_FILE="$RECEIPT_DIR/${SESSION_ID}.json"
36
+ OVERRIDE_FILE="$RECEIPT_DIR/${SESSION_ID}.override"
37
+ rm -f "$RECEIPT_FILE" "$OVERRIDE_FILE" 2>/dev/null || true
38
+
39
+ # Determine plugin root directory (same way as superpowers)
40
+ if [ -z "${CLAUDE_PLUGIN_ROOT:-}" ]; then
41
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
42
+ PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
43
+ else
44
+ PLUGIN_ROOT="$CLAUDE_PLUGIN_ROOT"
45
+ fi
46
+
47
+ # Read DevFlow Constitution from file (avoids shell escaping issues)
48
+ CONSTITUTION_FILE="${PLUGIN_ROOT}/skills/devflow/SKILL.md"
49
+ if [ -f "${PLUGIN_ROOT}/hooks/constitution.md" ]; then
50
+ CONSTITUTION_FILE="${PLUGIN_ROOT}/hooks/constitution.md"
51
+ fi
52
+
53
+ if [ -f "$CONSTITUTION_FILE" ]; then
54
+ GLOBAL_CONSTRAINT=$(cat "$CONSTITUTION_FILE" 2>/dev/null || echo "DevFlow Constitution 加载失败")
55
+ else
56
+ GLOBAL_CONSTRAINT="DevFlow Constitution 文件未找到。使用 /devflow: 命令时请优先调用 MCP 工具。"
57
+ fi
58
+
59
+ # Read the active rule/gate counts from the canonical global database.
60
+ GATE_COUNT=4
61
+ RULE_COUNT=""
62
+ ENFORCER_SUMMARY_JS="${PLUGIN_ROOT}/dist/hooks/enforcer-summary.js"
63
+ if [ -f "$ENFORCER_SUMMARY_JS" ] && command -v node >/dev/null 2>&1; then
64
+ ENFORCER_SUMMARY=$(node "$ENFORCER_SUMMARY_JS" 2>/dev/null || echo "")
65
+ if [ -n "$ENFORCER_SUMMARY" ] && command -v python3 >/dev/null 2>&1; then
66
+ PARSED_COUNTS=$(printf '%s' "$ENFORCER_SUMMARY" | python3 -c "import json,sys; d=json.load(sys.stdin); g=d.get('gateCount'); r=d.get('ruleCount'); print(f'{g}|{r}' if isinstance(g,int) and isinstance(r,int) else '')" 2>/dev/null || echo "")
67
+ if [[ "$PARSED_COUNTS" =~ ^[0-9]+\|[0-9]+$ ]]; then
68
+ GATE_COUNT="${PARSED_COUNTS%%|*}"
69
+ RULE_COUNT="${PARSED_COUNTS##*|}"
70
+ fi
71
+ fi
72
+ fi
73
+ GATE_DETAIL="启用规则数未知"
74
+ if [ -n "$RULE_COUNT" ]; then
75
+ GATE_DETAIL="启用规则: ${RULE_COUNT}"
76
+ fi
77
+
78
+ # Append Gateway status to summary
79
+ GATEWAY_STATUS="\n\n━━━━━━ DevFlow Gateway ━━━━━━\n"
80
+ # Check if devflow MCP server is configured (token will be auto-generated by ensureSessionToken)
81
+ if [ -f ~/.claude/.mcp.json ] && grep -q '"devflow"' ~/.claude/.mcp.json 2>/dev/null; then
82
+ GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🟢 DevFlow MCP 已配置\nGate 层数: ${GATE_COUNT} (${GATE_DETAIL})\n"
83
+ elif [ -f .mcp.json ] && grep -q '"devflow"' .mcp.json 2>/dev/null; then
84
+ GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🟢 DevFlow MCP 已配置(项目级)\nGate 层数: ${GATE_COUNT} (${GATE_DETAIL})\n"
85
+ else
86
+ GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🔴 未配置 DevFlow MCP Server\n请将 devflow MCP 配置加入 .mcp.json\n"
87
+ fi
88
+ GATEWAY_STATUS="${GATEWAY_STATUS}━━━━━━━━━━━━━━━━━━━━━━━━━━━"
89
+
90
+ # ── MCP Tool Usage Protocol (injected into every session) ──
91
+ MCP_PROTOCOL="
92
+
93
+ ## DevFlow MCP 工具使用协议(必须遵守)
94
+
95
+ 当用户使用 /devflow: 开头的技能时(如 /devflow:react、/devflow:vue、/devflow:context 等),你必须按以下流程操作:
96
+
97
+ ### Step 1: 获取上下文(必须先执行)
98
+ 调用 mcp__devflow__get_project_context,参数格式:{\"query\": \"用户的问题描述\", \"projectRoot\": \"\${CLAUDE_PROJECT_DIR}\"}
99
+ 这个工具返回项目中的相关文件、符号、风险提示和下一步建议。
100
+ 不要跳过这一步。不要用 Explore、Agent、Grep 或 Bash 代替。
101
+
102
+ ### Step 2: 按需调用领域工具
103
+ 根据技能类型调用对应的 MCP 工具:
104
+ - React 性能问题 → mcp__devflow__react_audit_performance(参数:{\"projectRoot\": \"\${CLAUDE_PROJECT_DIR}\"})
105
+ - React Bug → mcp__devflow__react_diagnose_bug
106
+ - React Hooks 审查 → mcp__devflow__react_review_hooks
107
+ - Vue 问题 → mcp__devflow__vue_diagnose_bug
108
+ - NestJS 问题 → mcp__devflow__nest_diagnose_bug
109
+ - 代码搜索 → mcp__devflow__search_symbol
110
+ - 知识查询 → mcp__devflow__get_knowledge
111
+
112
+ ### Step 3: 基于工具返回结果进行分析
113
+ 用 Read 确认工具返回的关键文件,然后给出分析结论。
114
+
115
+ ### 铁律
116
+ - 永远不要用 Explore、Agent、Grep 或 Glob 替代 MCP 工具的第一步上下文获取
117
+ - Every mcp__devflow__ tool MUST pass projectRoot = \${CLAUDE_PROJECT_DIR}; missing projectRoot is rejected; no cwd fallback.
118
+ - 如果 MCP 工具返回错误,重试一次;再失败则回退到直接读文件"
119
+
120
+ MEMORY_DISTILL="
121
+
122
+ Next session instruction: call mcp__devflow__memory_request_distill once at session start; it safely reports when no memory events are pending."
123
+
124
+ DEVFLOW_DAEMON_REACHABLE=0
125
+ run_lifecycle() {
126
+ local PROJECT_HASH=""
127
+ local state_dir=""
128
+ local log_dir="${HOME}/.devflow/logs"
129
+ local fallback_dir="${TMPDIR:-/tmp}"
130
+
131
+ if command -v shasum >/dev/null 2>&1; then
132
+ PROJECT_HASH=$(printf '%s' "$PROJECT_ROOT" | shasum -a 256 2>/dev/null | cut -c1-16) || PROJECT_HASH=""
133
+ fi
134
+ [[ "$PROJECT_HASH" =~ ^[0-9a-f]{16}$ ]] || PROJECT_HASH=""
135
+
136
+ if [ -n "${DEVFLOW_STATE_DIR:-}" ]; then
137
+ state_dir="$DEVFLOW_STATE_DIR"
138
+ elif [ -n "$PROJECT_HASH" ]; then
139
+ state_dir="${HOME}/.devflow/state/${PROJECT_HASH}"
140
+ fi
141
+ if [ -n "$state_dir" ]; then
142
+ rm -f "${state_dir}/current-execution-id" "${state_dir}/current-skill.json" 2>/dev/null || true
143
+ fi
144
+
145
+ if mkdir -p "$log_dir" 2>/dev/null; then
146
+ DAEMON_LOG="${log_dir}/hook-daemon-${PROJECT_HASH:-fallback}.log"
147
+ SERVER_LOG="${HOME}/.devflow/logs/server.log"
148
+ elif [ -d "$fallback_dir" ]; then
149
+ DAEMON_LOG="${fallback_dir}/devflow-hook-daemon-${PROJECT_HASH:-fallback}.log"
150
+ SERVER_LOG="${fallback_dir}/devflow-server.log"
151
+ else
152
+ DAEMON_LOG="/dev/null"
153
+ SERVER_LOG="/dev/null"
154
+ fi
155
+
156
+ DAEMON_JS="${PLUGIN_ROOT}/dist/hooks/hook-daemon.js"
157
+ CLIENT_JS="${PLUGIN_ROOT}/dist/hooks/hook-client.js"
158
+
159
+ register_session() {
160
+ local suppress_fallback="${1:-1}"
161
+ [ -n "$SESSION_START_INPUT" ] || return 0
162
+ [ -f "$CLIENT_JS" ] || return 1
163
+ if DEVFLOW_HOOK_CLIENT_TIMEOUT_MS=250 \
164
+ DEVFLOW_HOOK_CLIENT_RETRY_DELAY_MS=50 \
165
+ DEVFLOW_HOOK_CLIENT_SUPPRESS_FALLBACK_LOG="$suppress_fallback" \
166
+ node "$CLIENT_JS" session-start "$SESSION_START_INPUT" >/dev/null 2>> "$DAEMON_LOG"; then
167
+ DEVFLOW_DAEMON_REACHABLE=1
168
+ return 0
169
+ fi
170
+ return 1
171
+ }
172
+
173
+ if [ -n "$SESSION_START_INPUT" ] && register_session 1; then
174
+ :
175
+ elif [ -f "$DAEMON_JS" ] && command -v nohup >/dev/null 2>&1 && command -v node >/dev/null 2>&1; then
176
+ if [ -n "$SESSION_START_INPUT" ]; then
177
+ nohup node "$DAEMON_JS" "$PROJECT_ROOT" "$SESSION_START_INPUT" </dev/null >> "$DAEMON_LOG" 2>&1 &
178
+ else
179
+ nohup node "$DAEMON_JS" "$PROJECT_ROOT" </dev/null >> "$DAEMON_LOG" 2>&1 &
180
+ fi
181
+ DAEMON_PID=$!
182
+ echo "[devflow] Hook daemon started for ${PROJECT_ROOT} (PID ${DAEMON_PID})" >&2 || true
183
+
184
+ if [ -n "$SESSION_START_INPUT" ]; then
185
+ for _ in 1 2 3 4 5 6 7 8; do
186
+ register_session 1 && break
187
+ sleep 0.05
188
+ done
189
+ fi
190
+ fi
191
+
192
+ if [ -n "$SESSION_START_INPUT" ] && [ "$DEVFLOW_DAEMON_REACHABLE" != "1" ]; then
193
+ register_session 0 || true
194
+ fi
195
+
196
+ SERVER_BOOTSTRAP_JS="${PLUGIN_ROOT}/dist/hooks/server-bootstrap.js"
197
+ if [ -f "$SERVER_BOOTSTRAP_JS" ] && command -v nohup >/dev/null 2>&1 && command -v node >/dev/null 2>&1; then
198
+ nohup node "$SERVER_BOOTSTRAP_JS" </dev/null >> "$SERVER_LOG" 2>&1 &
199
+ fi
200
+ }
201
+
202
+ run_lifecycle || true
203
+
204
+ DEGRADED_CONTEXT=""
205
+ if [ "$DEVFLOW_DAEMON_REACHABLE" != "1" ]; then
206
+ DEGRADED_CONTEXT="
207
+
208
+ WARNING: DevFlow is in degraded mode (daemon unreachable): 4-Gate enforcement is unavailable, memory prefetch cache is unavailable, and daemon-shared Hook state is unavailable. Run devflow doctor for details."
209
+ fi
210
+
211
+ MEMORY_SNAPSHOT="## Project memory\n本项目暂无记忆"
212
+ CONFIG_FILE="${PROJECT_ROOT}/.devflow/config.json"
213
+ MEMORY_RESPONSE=""
214
+ if [ -f "${CLIENT_JS:-}" ] && command -v node >/dev/null 2>&1; then
215
+ MEMORY_RESPONSE=$(DEVFLOW_HOOK_CLIENT_TIMEOUT_MS=1000 node "$CLIENT_JS" memory-snapshot </dev/null 2>/dev/null || echo "")
216
+ fi
217
+ if command -v python3 >/dev/null 2>&1; then
218
+ MEMORY_SNAPSHOT=$(DEVFLOW_MEMORY_RESPONSE="$MEMORY_RESPONSE" python3 - "$CONFIG_FILE" 2>/dev/null <<'PY'
219
+ import json,os,sys
220
+ try: cfg=json.load(open(sys.argv[1])).get('sessionStart',{}).get('injectMemories',True)
221
+ except Exception: cfg=True
222
+ if cfg is False: print(''); raise SystemExit
223
+ try: response=json.loads(os.environ.get('DEVFLOW_MEMORY_RESPONSE',''))
224
+ except Exception: response={}
225
+ print(response.get('markdown') or '## Project memory\n本项目暂无记忆')
226
+ PY
227
+ ) || MEMORY_SNAPSHOT="## Project memory\n本项目暂无记忆"
228
+ fi
229
+
230
+ ONBOARDING_SNAPSHOT=""
231
+ ONBOARDING_FILE="${PROJECT_ROOT}/.devflow/onboarding-pack.json"
232
+ if [ -f "$ONBOARDING_FILE" ] && command -v python3 >/dev/null 2>&1; then
233
+ ONBOARDING_SNAPSHOT=$(python3 - "$ONBOARDING_FILE" 2>/dev/null <<'PY'
234
+ import json,sys
235
+ def clean(value): return ' '.join(str(value).split())[:120]
236
+ try: data=json.load(open(sys.argv[1]))
237
+ except Exception: raise SystemExit
238
+ modules=[clean(item.get('name','')) for item in data.get('keyModules',[])[:6] if item.get('name')]
239
+ layers=[f"{clean(item.get('name',''))} ({int(item.get('files',0))} files)" for item in data.get('architectureLayers',[])[:6] if item.get('name')]
240
+ if modules or layers:
241
+ print('## Project map (auto-injected)')
242
+ if modules: print('Key modules: ' + ', '.join(modules))
243
+ if layers: print('Architecture: ' + ', '.join(layers))
244
+ PY
245
+ ) || ONBOARDING_SNAPSHOT=""
246
+ fi
247
+
248
+ SUMMARY="${SUMMARY}${DEGRADED_CONTEXT}${MEMORY_DISTILL}\n\n${ONBOARDING_SNAPSHOT}\n\n${MEMORY_SNAPSHOT}${MCP_PROTOCOL}${GLOBAL_CONSTRAINT}${GATEWAY_STATUS}"
249
+
250
+ if command -v python3 >/dev/null 2>&1 \
251
+ && ESCAPED=$(printf '%s\n' "$SUMMARY" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))" 2>/dev/null); then
252
+ :
253
+ else
254
+ ESCAPED='"Next session instruction: call mcp__devflow__memory_request_distill once at session start; it safely reports when no memory events are pending."'
255
+ fi
256
+
257
+ printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": %s\n }\n}\n' "$ESCAPED"
258
+
259
+ exit 0
@@ -0,0 +1,26 @@
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. Run existing stop.js cleanup (session close, memory extraction)
15
+ STOP_JS="$PLUGIN_ROOT/dist/hooks/stop.js"
16
+ if [ -f "$STOP_JS" ]; then
17
+ node "$STOP_JS" 2>/dev/null || true
18
+ fi
19
+
20
+ # 3. Clean up stale receipt files for this project
21
+ PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
22
+ SESSION_ID=$(echo -n "$PROJECT_ROOT" | shasum -a 256 2>/dev/null | cut -c1-16 || echo "")
23
+ RECEIPT_FILE="${TMPDIR:-/tmp}/.devflow-receipts/${SESSION_ID}.json"
24
+ rm -f "$RECEIPT_FILE" 2>/dev/null || true
25
+
26
+ exit 0
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$SCRIPT_DIR/..}"
6
+ CLIENT_JS="$PLUGIN_ROOT/dist/hooks/hook-client.js"
7
+ FALLBACK_JS="$PLUGIN_ROOT/dist/hooks/user-prompt-submit.js"
8
+
9
+ INPUT="$(cat)"
10
+
11
+ if [ -f "$CLIENT_JS" ]; then
12
+ node "$CLIENT_JS" user-prompt-submit "$INPUT" 2>/dev/null || {
13
+ echo "$INPUT" | DEVFLOW_HOOK_DEGRADED=1 node "$FALLBACK_JS" 2>/dev/null || true
14
+ }
15
+ elif [ -f "$FALLBACK_JS" ]; then
16
+ echo "$INPUT" | DEVFLOW_HOOK_DEGRADED=1 node "$FALLBACK_JS" 2>/dev/null || true
17
+ fi
18
+
19
+ exit 0
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@devflow-tools/claude-code-plugin",
3
+ "version": "0.16.1",
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
+ "dependencies": {
11
+ "@devflow-tools/database": "0.16.0",
12
+ "@devflow-tools/memory-engine": "0.16.1",
13
+ "@devflow-tools/sdk": "0.16.1",
14
+ "@devflow-tools/telemetry": "0.16.1",
15
+ "@devflow-tools/workflow-engine": "0.16.1"
16
+ },
17
+ "allowScripts": {
18
+ "better-sqlite3@12.11.1": true,
19
+ "sharp@0.32.6": true
20
+ },
21
+ "devDependencies": {
22
+ "@devflow-tools/mcp-server": "0.16.1"
23
+ },
24
+ "keywords": [
25
+ "pi-package",
26
+ "skills",
27
+ "development",
28
+ "context",
29
+ "knowledge-base"
30
+ ],
31
+ "pi": {
32
+ "skills": [
33
+ "./skills"
34
+ ]
35
+ },
36
+ "files": [
37
+ ".claude-plugin",
38
+ "CLAUDE.md",
39
+ "dist",
40
+ "hooks",
41
+ "hooks.json",
42
+ "skills"
43
+ ]
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devflow-tools/devflow",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "type": "module",
5
5
  "description": "DevFlow - Developer Intelligence Platform (Distribution Package)",
6
6
  "bin": {
@@ -15,17 +15,17 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@colbymchenry/codegraph": "^1.1.1",
18
- "@devflow-tools/adapters": "0.15.0",
19
- "@devflow-tools/benchmark": "0.15.0",
20
- "@devflow-tools/context-engine": "0.15.0",
21
- "@devflow-tools/database": "0.15.0",
22
- "@devflow-tools/knowledge-engine": "0.15.0",
23
- "@devflow-tools/mcp-server": "0.15.0",
24
- "@devflow-tools/memory-engine": "0.15.0",
25
- "@devflow-tools/sdk": "0.15.0",
26
- "@devflow-tools/server": "0.15.0",
27
- "@devflow-tools/telemetry": "0.15.0",
28
- "@devflow-tools/workflow-engine": "0.15.0",
18
+ "@devflow-tools/adapters": "0.16.1",
19
+ "@devflow-tools/benchmark": "0.16.1",
20
+ "@devflow-tools/context-engine": "0.16.1",
21
+ "@devflow-tools/database": "0.16.0",
22
+ "@devflow-tools/knowledge-engine": "0.16.1",
23
+ "@devflow-tools/mcp-server": "0.16.1",
24
+ "@devflow-tools/memory-engine": "0.16.1",
25
+ "@devflow-tools/sdk": "0.16.1",
26
+ "@devflow-tools/server": "0.16.1",
27
+ "@devflow-tools/telemetry": "0.16.1",
28
+ "@devflow-tools/workflow-engine": "0.16.1",
29
29
  "@inquirer/prompts": "^7.10.1",
30
30
  "@modelcontextprotocol/sdk": "^1.0.0",
31
31
  "@nestjs/common": "^10.4.0",
@@ -49,8 +49,9 @@
49
49
  "files": [
50
50
  "dist",
51
51
  "bin",
52
+ "acceptance-manifest.json",
52
53
  "plugin-registry.json",
53
54
  "scripts/postinstall.js"
54
55
  ],
55
- "gitHead": "716b2355d8bea1138f4b7551758044c3663fad0e"
56
+ "gitHead": "dfaeb66efe9c87c388fbe6f1b706e9fcf087ce6d"
56
57
  }
@@ -1,190 +1,174 @@
1
1
  {
2
2
  "version": "1.0.0",
3
- "lastUpdated": "2026-07-16T01:29:54.634Z",
3
+ "lastUpdated": "2026-07-22T03:28:02.463Z",
4
4
  "plugins": [
5
5
  {
6
6
  "name": "@devflow-tools/plugin-animation",
7
- "version": "0.15.0",
7
+ "version": "0.16.1",
8
8
  "description": "",
9
9
  "tags": [],
10
10
  "compatibleStacks": [
11
11
  "animation"
12
12
  ],
13
- "size": "248K",
14
- "author": "DevFlow Team",
15
- "homepage": ""
16
- },
17
- {
18
- "name": "@devflow-tools/claude-code-plugin",
19
- "version": "0.15.0",
20
- "description": "DevFlow — Developer Intelligence Platform for Claude Code",
21
- "tags": [
22
- "pi-package",
23
- "skills",
24
- "development",
25
- "context",
26
- "knowledge-base"
27
- ],
28
- "compatibleStacks": [],
29
- "size": "372K",
13
+ "size": "120876 B",
30
14
  "author": "DevFlow Team",
31
15
  "homepage": ""
32
16
  },
33
17
  {
34
18
  "name": "@devflow-tools/plugin-css",
35
- "version": "0.15.0",
19
+ "version": "0.16.1",
36
20
  "description": "",
37
21
  "tags": [],
38
22
  "compatibleStacks": [
39
23
  "css"
40
24
  ],
41
- "size": "240K",
25
+ "size": "108397 B",
42
26
  "author": "DevFlow Team",
43
27
  "homepage": ""
44
28
  },
45
29
  {
46
30
  "name": "@devflow-tools/plugin-docker",
47
- "version": "0.15.0",
31
+ "version": "0.16.1",
48
32
  "description": "",
49
33
  "tags": [],
50
34
  "compatibleStacks": [
51
35
  "docker"
52
36
  ],
53
- "size": "312K",
37
+ "size": "137194 B",
54
38
  "author": "DevFlow Team",
55
39
  "homepage": ""
56
40
  },
57
41
  {
58
42
  "name": "@devflow-tools/plugin-electron",
59
- "version": "0.15.0",
43
+ "version": "0.16.1",
60
44
  "description": "",
61
45
  "tags": [],
62
46
  "compatibleStacks": [
63
47
  "electron"
64
48
  ],
65
- "size": "344K",
49
+ "size": "152863 B",
66
50
  "author": "DevFlow Team",
67
51
  "homepage": ""
68
52
  },
69
53
  {
70
54
  "name": "@devflow-tools/plugin-git",
71
- "version": "0.15.0",
55
+ "version": "0.16.1",
72
56
  "description": "",
73
57
  "tags": [],
74
58
  "compatibleStacks": [
75
59
  "git"
76
60
  ],
77
- "size": "268K",
61
+ "size": "118745 B",
78
62
  "author": "DevFlow Team",
79
63
  "homepage": ""
80
64
  },
81
65
  {
82
66
  "name": "@devflow-tools/plugin-graphql",
83
- "version": "0.15.0",
67
+ "version": "0.16.1",
84
68
  "description": "",
85
69
  "tags": [],
86
70
  "compatibleStacks": [
87
71
  "graphql"
88
72
  ],
89
- "size": "276K",
73
+ "size": "120874 B",
90
74
  "author": "DevFlow Team",
91
75
  "homepage": ""
92
76
  },
93
77
  {
94
78
  "name": "@devflow-tools/plugin-nest",
95
- "version": "0.15.0",
79
+ "version": "0.16.1",
96
80
  "description": "",
97
81
  "tags": [],
98
82
  "compatibleStacks": [
99
83
  "nest"
100
84
  ],
101
- "size": "372K",
85
+ "size": "157982 B",
102
86
  "author": "DevFlow Team",
103
87
  "homepage": ""
104
88
  },
105
89
  {
106
90
  "name": "@devflow-tools/plugin-nextjs",
107
- "version": "0.15.0",
91
+ "version": "0.16.1",
108
92
  "description": "",
109
93
  "tags": [],
110
94
  "compatibleStacks": [
111
95
  "nextjs"
112
96
  ],
113
- "size": "276K",
97
+ "size": "119527 B",
114
98
  "author": "DevFlow Team",
115
99
  "homepage": ""
116
100
  },
117
101
  {
118
102
  "name": "@devflow-tools/plugin-performance",
119
- "version": "0.15.0",
103
+ "version": "0.16.1",
120
104
  "description": "",
121
105
  "tags": [],
122
106
  "compatibleStacks": [
123
107
  "performance"
124
108
  ],
125
- "size": "384K",
109
+ "size": "169348 B",
126
110
  "author": "DevFlow Team",
127
111
  "homepage": ""
128
112
  },
129
113
  {
130
114
  "name": "@devflow-tools/plugin-react",
131
- "version": "0.15.0",
115
+ "version": "0.16.1",
132
116
  "description": "",
133
117
  "tags": [],
134
118
  "compatibleStacks": [
135
119
  "react"
136
120
  ],
137
- "size": "752K",
121
+ "size": "255955 B",
138
122
  "author": "DevFlow Team",
139
123
  "homepage": ""
140
124
  },
141
125
  {
142
126
  "name": "@devflow-tools/plugin-tailwind",
143
- "version": "0.15.0",
127
+ "version": "0.16.1",
144
128
  "description": "",
145
129
  "tags": [],
146
130
  "compatibleStacks": [
147
131
  "tailwind"
148
132
  ],
149
- "size": "296K",
133
+ "size": "125530 B",
150
134
  "author": "DevFlow Team",
151
135
  "homepage": ""
152
136
  },
153
137
  {
154
138
  "name": "@devflow-tools/plugin-taro",
155
- "version": "0.15.0",
139
+ "version": "0.16.1",
156
140
  "description": "",
157
141
  "tags": [],
158
142
  "compatibleStacks": [
159
143
  "taro"
160
144
  ],
161
- "size": "296K",
145
+ "size": "129169 B",
162
146
  "author": "DevFlow Team",
163
147
  "homepage": ""
164
148
  },
165
149
  {
166
150
  "name": "@devflow-tools/plugin-ui-layout",
167
- "version": "0.15.0",
151
+ "version": "0.16.1",
168
152
  "description": "",
169
153
  "tags": [],
170
154
  "compatibleStacks": [
171
155
  "ui-layout"
172
156
  ],
173
- "size": "236K",
157
+ "size": "106245 B",
174
158
  "author": "DevFlow Team",
175
159
  "homepage": ""
176
160
  },
177
161
  {
178
162
  "name": "@devflow-tools/plugin-vue",
179
- "version": "0.15.0",
163
+ "version": "0.16.1",
180
164
  "description": "",
181
165
  "tags": [],
182
166
  "compatibleStacks": [
183
167
  "vue"
184
168
  ],
185
- "size": "336K",
169
+ "size": "137821 B",
186
170
  "author": "DevFlow Team",
187
171
  "homepage": ""
188
172
  }
189
173
  ]
190
- }
174
+ }