@devflow-tools/cli 0.3.1 → 0.4.0

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 (45) hide show
  1. package/README.md +50 -0
  2. package/dist/commands/doctor.d.ts +25 -0
  3. package/dist/commands/doctor.d.ts.map +1 -1
  4. package/dist/commands/doctor.js +77 -1
  5. package/dist/commands/doctor.js.map +1 -1
  6. package/dist/commands/init.d.ts +6 -2
  7. package/dist/commands/init.d.ts.map +1 -1
  8. package/dist/commands/init.js +53 -2
  9. package/dist/commands/init.js.map +1 -1
  10. package/dist/commands/session.d.ts +7 -0
  11. package/dist/commands/session.d.ts.map +1 -0
  12. package/dist/commands/session.js +20 -0
  13. package/dist/commands/session.js.map +1 -0
  14. package/dist/index.js +67 -3
  15. package/dist/index.js.map +1 -1
  16. package/dist/lib/plugin-setup.d.ts +23 -0
  17. package/dist/lib/plugin-setup.d.ts.map +1 -0
  18. package/dist/lib/plugin-setup.js +141 -0
  19. package/dist/lib/plugin-setup.js.map +1 -0
  20. package/dist/plugin-files/.claude-plugin/plugin.json +20 -0
  21. package/dist/plugin-files/CLAUDE.md +34 -0
  22. package/dist/plugin-files/dist/command-registry.json +235 -0
  23. package/dist/plugin-files/dist/skills/devflow:context/SKILL.md +29 -0
  24. package/dist/plugin-files/dist/skills/devflow:docker/SKILL.md +49 -0
  25. package/dist/plugin-files/dist/skills/devflow:electron/SKILL.md +49 -0
  26. package/dist/plugin-files/dist/skills/devflow:graph/SKILL.md +24 -0
  27. package/dist/plugin-files/dist/skills/devflow:graphql/SKILL.md +48 -0
  28. package/dist/plugin-files/dist/skills/devflow:knowledge/SKILL.md +24 -0
  29. package/dist/plugin-files/dist/skills/devflow:memory/SKILL.md +23 -0
  30. package/dist/plugin-files/dist/skills/devflow:nest/SKILL.md +48 -0
  31. package/dist/plugin-files/dist/skills/devflow:nextjs/SKILL.md +45 -0
  32. package/dist/plugin-files/dist/skills/devflow:performance/SKILL.md +49 -0
  33. package/dist/plugin-files/dist/skills/devflow:react/SKILL.md +57 -0
  34. package/dist/plugin-files/dist/skills/devflow:tailwind/SKILL.md +45 -0
  35. package/dist/plugin-files/dist/skills/devflow:taro/SKILL.md +48 -0
  36. package/dist/plugin-files/dist/skills/devflow:vue/SKILL.md +52 -0
  37. package/dist/plugin-files/dist/skills/devflow:workflow/SKILL.md +24 -0
  38. package/dist/plugin-files/hooks/constitution.md +20 -0
  39. package/dist/plugin-files/hooks/post-tool-use +106 -0
  40. package/dist/plugin-files/hooks/pre-tool-use +147 -0
  41. package/dist/plugin-files/hooks/session-start +96 -0
  42. package/dist/plugin-files/hooks/stop +31 -0
  43. package/dist/plugin-files/hooks.json +40 -0
  44. package/dist/plugin-files/package.json +29 -0
  45. package/package.json +25 -23
@@ -0,0 +1,96 @@
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
+ SESSION_TOKEN=""
29
+ if command -v devflow &>/dev/null; then
30
+ SESSION_TOKEN=$(devflow session token --expires 3600 2>/dev/null || echo "")
31
+ elif command -v npx &>/dev/null; then
32
+ SESSION_TOKEN=$(npx --yes @devflow-tools/cli session token --expires 3600 2>/dev/null || echo "")
33
+ fi
34
+
35
+ TOKEN_VALUE=""
36
+ if [ -n "$SESSION_TOKEN" ] && echo "$SESSION_TOKEN" | python3 -c "import sys,json; json.load(sys.stdin)" 2>/dev/null; then
37
+ TOKEN_VALUE=$(echo "$SESSION_TOKEN" | python3 -c "import sys,json; print(json.load(sys.stdin).get('token',''))" 2>/dev/null || echo "")
38
+ fi
39
+
40
+ # Clean up stale receipt from previous session
41
+ PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
42
+ RECEIPT_DIR="${TMPDIR:-/tmp}/.devflow-receipts"
43
+ mkdir -p "$RECEIPT_DIR" 2>/dev/null || true
44
+ SESSION_ID=$(echo -n "$PROJECT_ROOT" | shasum -a 256 2>/dev/null | cut -c1-16 || echo "default")
45
+ RECEIPT_FILE="$RECEIPT_DIR/${SESSION_ID}.json"
46
+ OVERRIDE_FILE="$RECEIPT_DIR/${SESSION_ID}.override"
47
+ rm -f "$RECEIPT_FILE" "$OVERRIDE_FILE" 2>/dev/null || true
48
+
49
+ # Determine plugin root directory (same way as superpowers)
50
+ if [ -z "${CLAUDE_PLUGIN_ROOT:-}" ]; then
51
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
52
+ PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
53
+ else
54
+ PLUGIN_ROOT="$CLAUDE_PLUGIN_ROOT"
55
+ fi
56
+
57
+ # Read DevFlow Constitution from file (avoids shell escaping issues)
58
+ CONSTITUTION_FILE="${PLUGIN_ROOT}/skills/devflow/SKILL.md"
59
+ if [ -f "${PLUGIN_ROOT}/hooks/constitution.md" ]; then
60
+ CONSTITUTION_FILE="${PLUGIN_ROOT}/hooks/constitution.md"
61
+ fi
62
+
63
+ if [ -f "$CONSTITUTION_FILE" ]; then
64
+ GLOBAL_CONSTRAINT=$(cat "$CONSTITUTION_FILE" 2>/dev/null || echo "DevFlow Constitution 加载失败")
65
+ else
66
+ GLOBAL_CONSTRAINT="DevFlow Constitution 文件未找到。使用 /devflow: 命令时请优先调用 MCP 工具。"
67
+ fi
68
+
69
+ # Append Gateway status to summary
70
+ GATEWAY_STATUS="\n\n━━━━━━ DevFlow Gateway ━━━━━━\n"
71
+ # Check if devflow MCP server is configured (token will be auto-generated by ensureSessionToken)
72
+ if [ -f ~/.claude/.mcp.json ] && grep -q '"devflow"' ~/.claude/.mcp.json 2>/dev/null; then
73
+ GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🟢 DevFlow MCP 已配置\nGate 层数: 4 (宪法 → 派发 → 拦截 → 纠正)\n"
74
+ elif [ -f .mcp.json ] && grep -q '"devflow"' .mcp.json 2>/dev/null; then
75
+ GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🟢 DevFlow MCP 已配置(项目级)\nGate 层数: 4 (宪法 → 派发 → 拦截 → 纠正)\n"
76
+ else
77
+ GATEWAY_STATUS="${GATEWAY_STATUS}Status: 🔴 未配置 DevFlow MCP Server\n请将 devflow MCP 配置加入 .mcp.json\n"
78
+ fi
79
+ GATEWAY_STATUS="${GATEWAY_STATUS}━━━━━━━━━━━━━━━━━━━━━━━━━━━"
80
+
81
+ SUMMARY="${SUMMARY}${GLOBAL_CONSTRAINT}${GATEWAY_STATUS}"
82
+
83
+ # Escape for JSON
84
+ ESCAPED=$(echo "$SUMMARY" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))")
85
+
86
+ # Output context injection in Claude Code format
87
+ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
88
+ if [ -n "$TOKEN_VALUE" ]; then
89
+ ESCAPED_TOKEN=$(echo "$TOKEN_VALUE" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))")
90
+ printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": %s\n },\n "env": {\n "DEVFLOW_SESSION_TOKEN": %s\n }\n}\n' "$ESCAPED" "$ESCAPED_TOKEN"
91
+ else
92
+ printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": %s\n }\n}\n' "$ESCAPED"
93
+ fi
94
+ fi
95
+
96
+ exit 0
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Stop Hook — DevFlow session cleanup
5
+ # Cleans up receipt/override files and outputs violation summary.
6
+
7
+ PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
8
+ RECEIPT_DIR="${TMPDIR:-/tmp}/.devflow-receipts"
9
+ SESSION_ID=$(echo -n "$PROJECT_ROOT" | shasum -a 256 2>/dev/null | cut -c1-16 || echo "default")
10
+ RECEIPT_FILE="$RECEIPT_DIR/${SESSION_ID}.json"
11
+ OVERRIDE_FILE="$RECEIPT_DIR/${SESSION_ID}.override"
12
+
13
+ if [ -f "$RECEIPT_FILE" ]; then
14
+ # Read and output summary
15
+ python3 -c "
16
+ import json
17
+ with open('$RECEIPT_FILE') as f:
18
+ d = json.load(f)
19
+ bypass = d.get('bypassCount', 0)
20
+ print(f'会话违规统计: {bypass}/3')
21
+ if bypass > 0:
22
+ print(f'最后一次拦截: {d.get(\"lastAttempt\", \"N/A\")}')
23
+ " 2>/dev/null || true
24
+
25
+ # Cleanup
26
+ rm -f "$RECEIPT_FILE"
27
+ fi
28
+
29
+ rm -f "$OVERRIDE_FILE"
30
+
31
+ exit 0
@@ -0,0 +1,40 @@
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": "Bash|Glob|Grep|WebSearch|WebFetch|Agent",
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": "Bash|Glob|Grep|WebSearch|WebFetch|Agent",
30
+ "hooks": [
31
+ {
32
+ "type": "command",
33
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/post-tool-use\"",
34
+ "async": false
35
+ }
36
+ ]
37
+ }
38
+ ]
39
+ }
40
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@devflow-tools/claude-code-plugin",
3
+ "version": "0.4.0",
4
+ "private": true,
5
+ "description": "DevFlow — Developer Intelligence Platform for Claude Code",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "npx tsx scripts/inject-gates.ts",
9
+ "deploy": "npx tsx scripts/inject-gates.ts --deploy"
10
+ },
11
+ "keywords": [
12
+ "pi-package",
13
+ "skills",
14
+ "development",
15
+ "context",
16
+ "knowledge-base"
17
+ ],
18
+ "pi": {
19
+ "skills": [
20
+ "./skills"
21
+ ]
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "hooks",
26
+ "hooks.json",
27
+ "skills"
28
+ ]
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devflow-tools/cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {
@@ -8,33 +8,35 @@
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsc -b",
11
+ "postbuild": "npx tsx scripts/build-plugin-files.ts",
11
12
  "test": "cgnode ../../node_modules/.bin/vitest run",
12
13
  "typecheck": "tsc --noEmit",
13
14
  "clean": "rm -rf dist"
14
15
  },
15
16
  "dependencies": {
16
17
  "@colbymchenry/codegraph": "^1.1.1",
17
- "@devflow-tools/adapters": "^0.3.0",
18
- "@devflow-tools/benchmark": "^0.3.0",
19
- "@devflow-tools/context-engine": "^0.3.0",
20
- "@devflow-tools/knowledge-engine": "^0.3.0",
21
- "@devflow-tools/memory-engine": "^0.3.0",
22
- "@devflow-tools/plugin-animation": "^0.3.0",
23
- "@devflow-tools/plugin-css": "^0.3.0",
24
- "@devflow-tools/plugin-docker": "^0.3.0",
25
- "@devflow-tools/plugin-electron": "^0.3.0",
26
- "@devflow-tools/plugin-git": "^0.3.0",
27
- "@devflow-tools/plugin-graphql": "^0.3.0",
28
- "@devflow-tools/plugin-nest": "^0.3.0",
29
- "@devflow-tools/plugin-nextjs": "^0.3.0",
30
- "@devflow-tools/plugin-performance": "^0.3.0",
31
- "@devflow-tools/plugin-react": "^0.3.0",
32
- "@devflow-tools/plugin-tailwind": "^0.3.0",
33
- "@devflow-tools/plugin-taro": "^0.3.0",
34
- "@devflow-tools/plugin-ui-layout": "^0.3.0",
35
- "@devflow-tools/plugin-vue": "^0.3.0",
36
- "@devflow-tools/sdk": "^0.3.0",
37
- "@devflow-tools/workflow-engine": "^0.3.0",
18
+ "@devflow-tools/adapters": "^0.4.0",
19
+ "@devflow-tools/benchmark": "^0.4.0",
20
+ "@devflow-tools/context-engine": "^0.4.0",
21
+ "@devflow-tools/knowledge-engine": "^0.4.0",
22
+ "@devflow-tools/mcp-server": "^0.4.0",
23
+ "@devflow-tools/memory-engine": "^0.4.0",
24
+ "@devflow-tools/plugin-animation": "^0.4.0",
25
+ "@devflow-tools/plugin-css": "^0.4.0",
26
+ "@devflow-tools/plugin-docker": "^0.4.0",
27
+ "@devflow-tools/plugin-electron": "^0.4.0",
28
+ "@devflow-tools/plugin-git": "^0.4.0",
29
+ "@devflow-tools/plugin-graphql": "^0.4.0",
30
+ "@devflow-tools/plugin-nest": "^0.4.0",
31
+ "@devflow-tools/plugin-nextjs": "^0.4.0",
32
+ "@devflow-tools/plugin-performance": "^0.4.0",
33
+ "@devflow-tools/plugin-react": "^0.4.0",
34
+ "@devflow-tools/plugin-tailwind": "^0.4.0",
35
+ "@devflow-tools/plugin-taro": "^0.4.0",
36
+ "@devflow-tools/plugin-ui-layout": "^0.4.0",
37
+ "@devflow-tools/plugin-vue": "^0.4.0",
38
+ "@devflow-tools/sdk": "^0.4.0",
39
+ "@devflow-tools/workflow-engine": "^0.4.0",
38
40
  "chalk": "^5.3.0",
39
41
  "commander": "^12.0.0"
40
42
  },
@@ -46,5 +48,5 @@
46
48
  "dist",
47
49
  "bin"
48
50
  ],
49
- "gitHead": "2d52bb1401b6501a527cac7de0f664c18bf60dcf"
51
+ "gitHead": "c76bcf3a2bb8ac12b871738d6661979eb45090c6"
50
52
  }