@hupan56/wlkj 2.7.12 → 3.1.2
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/bin/cli.js +1435 -1107
- package/package.json +29 -29
- package/templates/qoder/agents/insight-planning.md +1 -1
- package/templates/qoder/agents/insight-research.md +28 -15
- package/templates/qoder/commands/optional/wl-insight.md +161 -161
- package/templates/qoder/commands/optional/wl-report.md +20 -39
- package/templates/qoder/commands/optional/wl-status.md +4 -4
- package/templates/qoder/commands/wl-code.md +2 -2
- package/templates/qoder/commands/wl-design.md +6 -6
- package/templates/qoder/commands/wl-init.md +3 -3
- package/templates/qoder/commands/wl-prd.md +26 -13
- package/templates/qoder/commands/wl-req.md +43 -0
- package/templates/qoder/commands/wl-search.md +78 -47
- package/templates/qoder/commands/wl-task.md +343 -40
- package/templates/qoder/commands/wl-test.md +43 -17
- package/templates/qoder/config.yaml +52 -14
- package/templates/qoder/hooks/post-tool-use.py +181 -0
- package/templates/qoder/hooks/session-start.py +94 -23
- package/templates/qoder/hooks/stop-eval.py +207 -0
- package/templates/qoder/hooks/user-prompt-submit.py +139 -0
- package/templates/qoder/rules/wl-pipeline.md +85 -49
- package/templates/qoder/scripts/README.md +102 -0
- package/templates/qoder/scripts/capability/__init__.py +26 -0
- package/templates/qoder/scripts/capability/__main__.py +72 -0
- package/templates/qoder/scripts/capability/adapters/__init__.py +29 -0
- package/templates/qoder/scripts/capability/adapters/cli.py +316 -0
- package/templates/qoder/scripts/capability/adapters/mcp.py +334 -0
- package/templates/qoder/scripts/capability/adapters/qw.py +271 -0
- package/templates/qoder/scripts/capability/caps/__init__.py +27 -0
- package/templates/qoder/scripts/capability/caps/context.py +36 -0
- package/templates/qoder/scripts/capability/caps/cron.py +50 -0
- package/templates/qoder/scripts/capability/caps/identity.py +43 -0
- package/templates/qoder/scripts/capability/caps/memory.py +71 -0
- package/templates/qoder/scripts/capability/caps/notify.py +41 -0
- package/templates/qoder/scripts/capability/caps/present.py +48 -0
- package/templates/qoder/scripts/capability/caps/repo.py +31 -0
- package/templates/qoder/scripts/capability/caps/sandbox.py +43 -0
- package/templates/qoder/scripts/capability/chain.py +92 -0
- package/templates/qoder/scripts/capability/memory_chain.py +41 -0
- package/templates/qoder/scripts/capability/registry.py +246 -0
- package/templates/qoder/scripts/capability/registry_mcp.py +250 -0
- package/templates/qoder/scripts/capability/smoke_test.py +211 -0
- package/templates/qoder/scripts/capability/smoke_test_report.json +94 -0
- package/templates/qoder/scripts/deployment/setup/__init__.py +11 -0
- package/templates/qoder/scripts/deployment/setup/carriers.py +669 -0
- package/templates/qoder/scripts/deployment/setup/carriers_verify.py +148 -0
- package/templates/qoder/scripts/{init_doctor.py → deployment/setup/init_doctor.py} +100 -39
- package/templates/qoder/scripts/{install_qoderwork.py → deployment/setup/install_qoderwork.py} +48 -30
- package/templates/qoder/scripts/{platform_doctor.py → deployment/setup/platform_doctor.py} +271 -259
- package/templates/qoder/scripts/{repo_root.py → deployment/setup/repo_root.py} +9 -2
- package/templates/qoder/scripts/{setup.py → deployment/setup/setup.py} +143 -14
- package/templates/qoder/scripts/{setup_lanhu.py → deployment/setup/setup_lanhu.py} +979 -963
- package/templates/qoder/scripts/domain/design/__init__.py +0 -0
- package/templates/qoder/scripts/{fill_prototype.py → domain/design/fill_prototype.py} +17 -5
- package/templates/qoder/scripts/{gen_design_doc.py → domain/design/gen_design_doc.py} +406 -394
- package/templates/qoder/scripts/domain/kg/__init__.py +11 -0
- package/templates/qoder/scripts/domain/kg/build/__init__.py +0 -0
- package/templates/qoder/scripts/domain/kg/build/build_entity_registry.py +201 -0
- package/templates/qoder/scripts/domain/kg/build/build_relations.py +132 -0
- package/templates/qoder/scripts/{build_style_index.py → domain/kg/build/build_style_index.py} +50 -15
- package/templates/qoder/scripts/domain/kg/build/build_workflows.py +149 -0
- package/templates/qoder/scripts/{kg_build.py → domain/kg/build/kg_build.py} +685 -612
- package/templates/qoder/scripts/{kg_build_db.py → domain/kg/build/kg_build_db.py} +338 -327
- package/templates/qoder/scripts/{kg_incremental.py → domain/kg/build/kg_incremental.py} +425 -393
- package/templates/qoder/scripts/{learn_aggregate.py → domain/kg/build/learn_aggregate.py} +212 -201
- package/templates/qoder/scripts/domain/kg/extract/__init__.py +0 -0
- package/templates/qoder/scripts/{common → domain/kg/extract}/extract.py +430 -419
- package/templates/qoder/scripts/domain/kg/extract/test_extract.py +115 -0
- package/templates/qoder/scripts/{common → domain/kg/extract}/ts_extract.py +614 -536
- package/templates/qoder/scripts/domain/kg/graph/__init__.py +0 -0
- package/templates/qoder/scripts/{kg_link_db.py → domain/kg/graph/kg_link_db.py} +235 -224
- package/templates/qoder/scripts/domain/kg/graph/kg_semantic.py +683 -0
- package/templates/qoder/scripts/{kg.py → domain/kg/kg.py} +871 -708
- package/templates/qoder/scripts/domain/kg/kg_capabilities.py +182 -0
- package/templates/qoder/scripts/domain/kg/search/__init__.py +0 -0
- package/templates/qoder/scripts/{context_pack.py → domain/kg/search/context_pack.py} +45 -17
- package/templates/qoder/scripts/{enrich_prompt.py → domain/kg/search/enrich_prompt.py} +238 -226
- package/templates/qoder/scripts/domain/kg/search/prefetch.py +384 -0
- package/templates/qoder/scripts/{common → domain/kg/search}/search_engine.py +207 -205
- package/templates/qoder/scripts/{search_index.py → domain/kg/search/search_index.py} +210 -88
- package/templates/qoder/scripts/domain/kg/server/__init__.py +0 -0
- package/templates/qoder/scripts/domain/kg/server/kgd.py +549 -0
- package/templates/qoder/scripts/domain/kg/server/perf_bench.py +197 -0
- package/templates/qoder/scripts/domain/kg/storage/__init__.py +0 -0
- package/templates/qoder/scripts/{kg_duckdb.py → domain/kg/storage/kg_duckdb.py} +70 -45
- package/templates/qoder/scripts/domain/learning/__init__.py +0 -0
- package/templates/qoder/scripts/{learn.py → domain/learning/learn.py} +157 -146
- package/templates/qoder/scripts/domain/report/__init__.py +11 -0
- package/templates/qoder/scripts/{add_session.py → domain/report/add_session.py} +256 -244
- package/templates/qoder/scripts/{export.py → domain/report/export.py} +72 -4
- package/templates/qoder/scripts/{report.py → domain/report/report.py} +292 -281
- package/templates/qoder/scripts/domain/report/report_snapshot.py +261 -0
- package/templates/qoder/scripts/domain/report/role.py +39 -0
- package/templates/qoder/scripts/{status.py → domain/report/status.py} +737 -628
- package/templates/qoder/scripts/domain/report/status_snapshot.py +191 -0
- package/templates/qoder/scripts/domain/requirement/__init__.py +0 -0
- package/templates/qoder/scripts/{archive_prd.py → domain/requirement/archive_prd.py} +389 -377
- package/templates/qoder/scripts/domain/requirement/req.py +228 -0
- package/templates/qoder/scripts/domain/task/__init__.py +11 -0
- package/templates/qoder/scripts/{git_sync.py → domain/task/git_sync.py} +90 -50
- package/templates/qoder/scripts/{syncgate.py → domain/task/syncgate.py} +18 -7
- package/templates/qoder/scripts/domain/task/task.py +229 -0
- package/templates/qoder/scripts/domain/task/task_lifecycle.py +606 -0
- package/templates/qoder/scripts/domain/task/task_query.py +162 -0
- package/templates/qoder/scripts/domain/task/task_relations.py +425 -0
- package/templates/qoder/scripts/{team_sync.py → domain/task/team_sync.py} +101 -23
- package/templates/qoder/scripts/domain/task/zentao_sync.py +370 -0
- package/templates/qoder/scripts/foundation/__init__.py +0 -0
- package/templates/qoder/scripts/foundation/bootstrap.py +145 -0
- package/templates/qoder/scripts/foundation/core/__init__.py +0 -0
- package/templates/qoder/scripts/foundation/core/cmd_registry.py +112 -0
- package/templates/qoder/scripts/foundation/core/config.py +187 -0
- package/templates/qoder/scripts/{common → foundation/core}/paths.py +706 -400
- package/templates/qoder/scripts/foundation/data/__init__.py +0 -0
- package/templates/qoder/scripts/foundation/data/contract.py +317 -0
- package/templates/qoder/scripts/{common → foundation/data}/events.py +2 -2
- package/templates/qoder/scripts/foundation/data/result.py +223 -0
- package/templates/qoder/scripts/{common → foundation/data}/task_utils.py +427 -392
- package/templates/qoder/scripts/foundation/identity/__init__.py +0 -0
- package/templates/qoder/scripts/foundation/identity/check_publish.py +103 -0
- package/templates/qoder/scripts/{common → foundation/identity}/developer.py +239 -238
- package/templates/qoder/scripts/foundation/identity/guard.py +159 -0
- package/templates/qoder/scripts/{common → foundation/identity}/identity.py +132 -9
- package/templates/qoder/scripts/foundation/identity/roles.py +60 -0
- package/templates/qoder/scripts/foundation/integrations/__init__.py +0 -0
- package/templates/qoder/scripts/{common → foundation/integrations}/active_task.py +30 -15
- package/templates/qoder/scripts/{common → foundation/integrations}/feishu.py +11 -10
- package/templates/qoder/scripts/{common → foundation/integrations}/terms.py +3 -3
- package/templates/qoder/scripts/foundation/integrations/zentao_client.py +220 -0
- package/templates/qoder/scripts/foundation/io/__init__.py +0 -0
- package/templates/qoder/scripts/{common → foundation/io}/filelock.py +1 -1
- package/templates/qoder/scripts/{common → foundation/io}/reqid.py +1 -1
- package/templates/qoder/scripts/foundation/protocol/__init__.py +0 -0
- package/templates/qoder/scripts/foundation/protocol/duckdb_conn.py +39 -0
- package/templates/qoder/scripts/foundation/protocol/mcp_base.py +268 -0
- package/templates/qoder/scripts/foundation/utils/__init__.py +0 -0
- package/templates/qoder/scripts/{common → foundation/utils}/eval_api.py +12 -1
- package/templates/qoder/scripts/{common → foundation/utils}/pip_install.py +23 -6
- package/templates/qoder/scripts/{common → foundation/utils}/platform_guard.py +1 -1
- package/templates/qoder/scripts/orchestration/__init__.py +0 -0
- package/templates/qoder/scripts/orchestration/wlkj.py +185 -0
- package/templates/qoder/scripts/protocol/__init__.py +0 -0
- package/templates/qoder/scripts/protocol/browser/README.md +207 -0
- package/templates/qoder/scripts/protocol/browser/SKILL.md +265 -0
- package/templates/qoder/scripts/protocol/browser/config.env +9 -0
- package/templates/qoder/scripts/protocol/browser/references/cdp-api.md +110 -0
- package/templates/qoder/scripts/protocol/browser/references/migration-2.5.3.md +72 -0
- package/templates/qoder/scripts/protocol/browser/references/site-patterns/.gitkeep +0 -0
- package/templates/qoder/scripts/protocol/browser/scripts/browser-discovery.mjs +138 -0
- package/templates/qoder/scripts/protocol/browser/scripts/cdp-proxy.mjs +672 -0
- package/templates/qoder/scripts/protocol/browser/scripts/check-deps.mjs +206 -0
- package/templates/qoder/scripts/protocol/browser/scripts/find-url.mjs +253 -0
- package/templates/qoder/scripts/protocol/browser/scripts/match-site.mjs +46 -0
- package/templates/qoder/scripts/protocol/browser/templates/config.env.template +9 -0
- package/templates/qoder/scripts/protocol/mcp/__init__.py +11 -0
- package/templates/qoder/scripts/protocol/mcp/kg_mcp_server.py +478 -0
- package/templates/qoder/scripts/{lanhu_stdio_wrapper.py → protocol/mcp/lanhu_stdio_wrapper.py} +131 -119
- package/templates/qoder/scripts/protocol/mcp/mcp_doctor.py +548 -0
- package/templates/qoder/scripts/protocol/mcp/mcp_launcher.py +600 -0
- package/templates/qoder/scripts/protocol/mcp/mysql_mcp_server.py +461 -0
- package/templates/qoder/scripts/protocol/mcp/zentao_mcp_server.py +1920 -0
- package/templates/qoder/scripts/protocol/transports/__init__.py +56 -0
- package/templates/qoder/scripts/protocol/transports/base.py +87 -0
- package/templates/qoder/scripts/protocol/transports/cli.py +132 -0
- package/templates/qoder/scripts/protocol/transports/http.py +141 -0
- package/templates/qoder/scripts/protocol/transports/stdio.py +293 -0
- package/templates/qoder/scripts/run_weekly_update.bat +27 -18
- package/templates/qoder/scripts/run_weekly_update.sh +22 -13
- package/templates/qoder/scripts/validation/__init__.py +0 -0
- package/templates/qoder/scripts/validation/eval/__init__.py +0 -0
- package/templates/qoder/scripts/validation/eval/perf-report-2026-06-24.md +139 -0
- package/templates/qoder/scripts/validation/eval/qwork_harness.py +617 -0
- package/templates/qoder/scripts/validation/eval/report-commands.md +220 -0
- package/templates/qoder/scripts/validation/eval/transcript_timing.py +386 -0
- package/templates/qoder/scripts/validation/metrics/__init__.py +0 -0
- package/templates/qoder/scripts/{eval_prd.py → validation/metrics/eval_prd.py} +84 -15
- package/templates/qoder/scripts/validation/metrics/usability_score.py +750 -0
- package/templates/qoder/scripts/validation/test/__init__.py +11 -0
- package/templates/qoder/scripts/validation/test/assertion_gen.py +551 -0
- package/templates/qoder/scripts/{autotest.py → validation/test/autotest.py} +1234 -1751
- package/templates/qoder/scripts/validation/test/autotest_auth.py +109 -0
- package/templates/qoder/scripts/{autotest_batch.py → validation/test/autotest_batch.py} +255 -224
- package/templates/qoder/scripts/validation/test/autotest_data.py +680 -0
- package/templates/qoder/scripts/validation/test/autotest_opencli.py +646 -0
- package/templates/qoder/scripts/{autotest_run.py → validation/test/autotest_run.py} +323 -297
- package/templates/qoder/scripts/validation/test/autotest_webaccess.py +571 -0
- package/templates/qoder/scripts/{benchmark.py → validation/test/benchmark.py} +17 -5
- package/templates/qoder/scripts/{kg_auto_login.py → validation/test/kg_auto_login.py} +208 -196
- package/templates/qoder/scripts/{kg_test_runner.py → validation/test/kg_test_runner.py} +13 -2
- package/templates/qoder/scripts/{page_probe.py → validation/test/page_probe.py} +470 -459
- package/templates/qoder/scripts/validation/test/smoke_all_commands.py +170 -0
- package/templates/qoder/settings.json +23 -2
- package/templates/qoder/skills/design-import/SKILL.md +235 -226
- package/templates/qoder/skills/design-review/SKILL.md +91 -82
- package/templates/qoder/skills/prd-generator/SKILL.md +38 -24
- package/templates/qoder/skills/prd-review/SKILL.md +8 -6
- package/templates/qoder/skills/prototype-generator/SKILL.md +296 -247
- package/templates/qoder/skills/spec-coder/SKILL.md +24 -15
- package/templates/qoder/skills/spec-generator/SKILL.md +24 -12
- package/templates/qoder/skills/test-generator/SKILL.md +9 -7
- package/templates/qoder/skills/wl-code/SKILL.md +25 -13
- package/templates/qoder/skills/wl-commit/SKILL.md +10 -9
- package/templates/qoder/skills/wl-design/SKILL.md +7 -5
- package/templates/qoder/skills/wl-init/SKILL.md +8 -8
- package/templates/qoder/skills/wl-insight/SKILL.md +25 -12
- package/templates/qoder/skills/wl-prd-full/SKILL.md +59 -8
- package/templates/qoder/skills/wl-prd-quick/SKILL.md +7 -7
- package/templates/qoder/skills/wl-prd-review/SKILL.md +18 -6
- package/templates/qoder/skills/wl-report/SKILL.md +27 -25
- package/templates/qoder/skills/wl-search/SKILL.md +151 -80
- package/templates/qoder/skills/wl-spec/SKILL.md +9 -7
- package/templates/qoder/skills/wl-status/SKILL.md +50 -18
- package/templates/qoder/skills/wl-task/SKILL.md +94 -12
- package/templates/qoder/skills/wl-test/SKILL.md +154 -45
- package/templates/qoder/templates/prd-full-template.md +7 -0
- package/templates/root/AGENTS.md +275 -237
- package/templates/root/requirements.txt +3 -0
- package/templates/root//344/275/277/347/224/250/350/257/264/346/230/216.md +3 -3
- package/templates/root//346/226/260/346/211/213/346/214/207/345/215/227.md +2 -2
- package/templates/qoder/hooks/inject-workflow-state.py +0 -169
- package/templates/qoder/scripts/__pycache__/check_mcp_launch.cpython-39.pyc +0 -0
- package/templates/qoder/scripts/__pycache__/install_qoderwork.cpython-39.pyc +0 -0
- package/templates/qoder/scripts/__pycache__/mcp_launcher.cpython-39.pyc +0 -0
- package/templates/qoder/scripts/__pycache__/platform_doctor.cpython-39.pyc +0 -0
- package/templates/qoder/scripts/check_carriers.py +0 -238
- package/templates/qoder/scripts/check_mcp.py +0 -298
- package/templates/qoder/scripts/check_mcp_launch.py +0 -183
- package/templates/qoder/scripts/check_qoderwork_consistency.py +0 -166
- package/templates/qoder/scripts/collect_prds.py +0 -31
- package/templates/qoder/scripts/common/mentions.py +0 -134
- package/templates/qoder/scripts/common/utf8.py +0 -38
- package/templates/qoder/scripts/extract_api_params.py +0 -246
- package/templates/qoder/scripts/extract_routes.py +0 -54
- package/templates/qoder/scripts/extract_routes_tree.py +0 -78
- package/templates/qoder/scripts/handoff.py +0 -22
- package/templates/qoder/scripts/init_developer.py +0 -76
- package/templates/qoder/scripts/kg_mcp_server.py +0 -801
- package/templates/qoder/scripts/kg_semantic.py +0 -150
- package/templates/qoder/scripts/mcp_launcher.py +0 -414
- package/templates/qoder/scripts/mysql_mcp_server.py +0 -396
- package/templates/qoder/scripts/parse_prds.py +0 -33
- package/templates/qoder/scripts/role.py +0 -51
- package/templates/qoder/scripts/sync_carriers.py +0 -259
- package/templates/qoder/scripts/task.py +0 -1261
- package/templates/qoder/scripts/workspace_init.py +0 -102
- package/templates/qoder/scripts/zentao_mcp_server.py +0 -424
- package/templates/qoder/skills/prompt-enrich/SKILL.md +0 -90
- /package/templates/qoder/scripts/{common → deployment}/__init__.py +0 -0
- /package/templates/qoder/{skills/prototype-generator/SKILL.md.zcode-79180-2af4721f-f9a6-412c-88db-c0af680d211b.tmp → scripts/domain/__init__.py} +0 -0
- /package/templates/qoder/scripts/{common → domain/kg/graph}/graph_traverse.py +0 -0
- /package/templates/qoder/scripts/{common → domain/kg/server}/repowiki.py +0 -0
- /package/templates/qoder/scripts/{common → foundation/io}/atomicio.py +0 -0
- /package/templates/qoder/scripts/{secure-ls.js → validation/test/secure-ls.js} +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
mentions.py - @提及解析与飞书通知 (阶段 D4)
|
|
4
|
-
|
|
5
|
-
从 PRD 评审/任务评论/报告内容里提取 @用户名, 映射到飞书 user_key,
|
|
6
|
-
通过飞书机器人推送提及通知。
|
|
7
|
-
|
|
8
|
-
触发点:
|
|
9
|
-
- PRD 评审意见里有 @某人
|
|
10
|
-
- 任务评论 (task.py comment, 未来) 有 @某人
|
|
11
|
-
- 报告里 @某人
|
|
12
|
-
|
|
13
|
-
member.json 扩展字段: feishu_user_key (可选, 飞书 open_id/user_id)
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
import os
|
|
17
|
-
import re
|
|
18
|
-
import sys
|
|
19
|
-
from typing import List, Tuple, Optional
|
|
20
|
-
|
|
21
|
-
_THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
22
|
-
if _THIS_DIR not in sys.path:
|
|
23
|
-
sys.path.insert(0, _THIS_DIR)
|
|
24
|
-
|
|
25
|
-
try:
|
|
26
|
-
from .identity import get_member, list_members
|
|
27
|
-
from .feishu import send_card, is_enabled
|
|
28
|
-
except ImportError:
|
|
29
|
-
from identity import get_member, list_members
|
|
30
|
-
from feishu import send_card, is_enabled
|
|
31
|
-
|
|
32
|
-
__all__ = [
|
|
33
|
-
"extract_mentions",
|
|
34
|
-
"resolve_to_feishu_keys",
|
|
35
|
-
"notify_mentions",
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
# @提及模式: @用户名 (支持中文/英文/数字/下划线, 2-32 字符)
|
|
39
|
-
MENTION_RE = re.compile(r'@([\w\u4e00-\u9fa5\-]{2,32})')
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def extract_mentions(text: str, exclude: Optional[str] = None) -> List[str]:
|
|
43
|
-
"""从文本提取 @提及的用户名。
|
|
44
|
-
|
|
45
|
-
Args:
|
|
46
|
-
text: 要扫描的文本。
|
|
47
|
-
exclude: 排除的用户名 (通常是作者自己, 避免自提及)。
|
|
48
|
-
|
|
49
|
-
Returns:
|
|
50
|
-
去重后的用户名列表 (只保留在注册表里的成员)。
|
|
51
|
-
"""
|
|
52
|
-
raw = set(m.group(1) for m in MENTION_RE.finditer(text))
|
|
53
|
-
if exclude:
|
|
54
|
-
raw.discard(exclude)
|
|
55
|
-
# 只保留已注册的成员 (避免 @system @all 等噪音)
|
|
56
|
-
members = list_members()
|
|
57
|
-
return sorted(name for name in raw if name in members)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def resolve_to_feishu_keys(names: List[str]) -> List[Tuple[str, str]]:
|
|
61
|
-
"""把用户名映射到飞书 user_key。
|
|
62
|
-
|
|
63
|
-
Args:
|
|
64
|
-
names: 用户名列表。
|
|
65
|
-
|
|
66
|
-
Returns:
|
|
67
|
-
[(name, feishu_user_key), ...] 只含配了 feishu_user_key 的成员。
|
|
68
|
-
"""
|
|
69
|
-
out = []
|
|
70
|
-
for name in names:
|
|
71
|
-
m = get_member(name)
|
|
72
|
-
if m and m.get('feishu_user_key'):
|
|
73
|
-
out.append((name, m['feishu_user_key']))
|
|
74
|
-
return out
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def notify_mentions(
|
|
78
|
-
text: str,
|
|
79
|
-
context: str,
|
|
80
|
-
author: Optional[str] = None,
|
|
81
|
-
link: Optional[str] = None,
|
|
82
|
-
) -> int:
|
|
83
|
-
"""扫描文本里的 @提及, 给每个被提及者发飞书通知。
|
|
84
|
-
|
|
85
|
-
Args:
|
|
86
|
-
text: 含 @提及的文本 (如 PRD 评审意见)。
|
|
87
|
-
context: 上下文描述 (如 "REQ-2026-007 评审")。
|
|
88
|
-
author: 提及的发起人 (从 .developer 读)。
|
|
89
|
-
link: 相关链接 (可选)。
|
|
90
|
-
|
|
91
|
-
Returns:
|
|
92
|
-
成功通知的人数。
|
|
93
|
-
"""
|
|
94
|
-
if not is_enabled():
|
|
95
|
-
return 0
|
|
96
|
-
|
|
97
|
-
names = extract_mentions(text, exclude=author)
|
|
98
|
-
if not names:
|
|
99
|
-
return 0
|
|
100
|
-
|
|
101
|
-
# 解析到飞书 user_key
|
|
102
|
-
keyed = resolve_to_feishu_keys(names)
|
|
103
|
-
# 未配 feishu_user_key 的成员, 仍然在通知内容里显示名字 (但不定向)
|
|
104
|
-
unkeyed = [n for n in names if n not in dict(keyed)]
|
|
105
|
-
|
|
106
|
-
sent = 0
|
|
107
|
-
for name, user_key in keyed:
|
|
108
|
-
lines = [
|
|
109
|
-
f'**你被 @{author or "某人"} 提及了**',
|
|
110
|
-
f'上下文: {context}',
|
|
111
|
-
]
|
|
112
|
-
if link:
|
|
113
|
-
lines.append(f'链接: {link}')
|
|
114
|
-
lines.append(f'飞书 ID: {user_key}')
|
|
115
|
-
try:
|
|
116
|
-
if send_card(f'@提及: {context}', lines, event_type=None, theme='orange'):
|
|
117
|
-
sent += 1
|
|
118
|
-
except Exception:
|
|
119
|
-
pass
|
|
120
|
-
|
|
121
|
-
# 未配 key 的合并发一条到群 (作为 fallback)
|
|
122
|
-
if unkeyed and not keyed:
|
|
123
|
-
lines = [
|
|
124
|
-
f'**{", ".join(unkeyed)} 被 @{author or "某人"} 提及**',
|
|
125
|
-
f'(以上成员未配置 feishu_user_key, 此为群广播)',
|
|
126
|
-
f'上下文: {context}',
|
|
127
|
-
]
|
|
128
|
-
try:
|
|
129
|
-
send_card(f'@提及: {context}', lines, event_type=None, theme='grey')
|
|
130
|
-
sent += 1
|
|
131
|
-
except Exception:
|
|
132
|
-
pass
|
|
133
|
-
|
|
134
|
-
return sent
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
utf8.py - 统一的 stdout/stderr UTF-8 配置 (防御性)
|
|
4
|
-
|
|
5
|
-
解决审计 C2: 10 个脚本的裸 sys.stdout.reconfigure(encoding='utf-8') 在
|
|
6
|
-
stdout 被捕获时 (Qoder IDE 内嵌终端/管道) 会 AttributeError 崩溃。
|
|
7
|
-
|
|
8
|
-
用法 (替换裸 reconfigure):
|
|
9
|
-
from common.utf8 import ensure_utf8_stdio
|
|
10
|
-
ensure_utf8_stdio()
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
import sys
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def ensure_utf8_stdio() -> None:
|
|
17
|
-
"""把 stdout/stderr 切到 UTF-8, 失败则忽略 (不崩溃)。
|
|
18
|
-
|
|
19
|
-
安全性:
|
|
20
|
-
- TextIOWrapper 有 reconfigure -> 切换
|
|
21
|
-
- 其他类型 (管道包装/None) -> 静默跳过
|
|
22
|
-
- 永远不抛异常
|
|
23
|
-
"""
|
|
24
|
-
for stream_name in ("stdout", "stderr"):
|
|
25
|
-
stream = getattr(sys, stream_name, None)
|
|
26
|
-
if stream is None:
|
|
27
|
-
continue
|
|
28
|
-
reconfigure = getattr(stream, "reconfigure", None)
|
|
29
|
-
if reconfigure is None:
|
|
30
|
-
continue # 不是 TextIOWrapper, 跳过
|
|
31
|
-
try:
|
|
32
|
-
reconfigure(encoding="utf-8", errors="replace")
|
|
33
|
-
except (TypeError, ValueError, OSError, IOError):
|
|
34
|
-
# errors 参数不支持或底层不可重配 -> 尝试仅 encoding
|
|
35
|
-
try:
|
|
36
|
-
reconfigure(encoding="utf-8")
|
|
37
|
-
except Exception:
|
|
38
|
-
pass # 彻底失败也不阻塞脚本主逻辑
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
extract_api_params.py - 从 TS 类型 + Java Bo 提取 API 参数, 生成智能默认值
|
|
5
|
-
读主库 kg.duckdb(只读), 写 api-params.json(避免 DuckDB 写入性能问题)。
|
|
6
|
-
后续 MySQL 接入后, 用真实数据覆盖默认值。
|
|
7
|
-
"""
|
|
8
|
-
import sys, os, re, json, time, glob, duckdb
|
|
9
|
-
from datetime import datetime
|
|
10
|
-
|
|
11
|
-
try:
|
|
12
|
-
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
13
|
-
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
|
14
|
-
except Exception:
|
|
15
|
-
pass
|
|
16
|
-
|
|
17
|
-
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
18
|
-
BASE = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
19
|
-
KG_PATH = os.path.join(BASE, 'data', 'index', 'kg.duckdb')
|
|
20
|
-
PARAMS_FILE = os.path.join(BASE, 'data', 'index', 'api-params.json')
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# ── TS 解析 ──────────────────────────────────────────────────
|
|
24
|
-
|
|
25
|
-
def parse_ts_param_types():
|
|
26
|
-
"""扫所有 TS api 文件, 建 {fn_name: param_type} 映射。"""
|
|
27
|
-
fn_map = {}
|
|
28
|
-
ts_root = os.path.join(BASE, 'data', 'code', 'fywl-ui', 'apps', 'ics', 'src', 'api')
|
|
29
|
-
for tf in glob.glob(os.path.join(ts_root, '**', '*.ts'), recursive=True):
|
|
30
|
-
try:
|
|
31
|
-
if os.path.getsize(tf) > 50000:
|
|
32
|
-
continue
|
|
33
|
-
txt = open(tf, encoding='utf-8', errors='ignore').read()
|
|
34
|
-
except Exception:
|
|
35
|
-
continue
|
|
36
|
-
for m in re.finditer(r'export\s+(?:async\s+)?function\s+(\w+)\s*\(\s*(?:\w+)?\s*(?::\s*(\w+|Partial<[^>]+>))?', txt):
|
|
37
|
-
fn_map[m.group(1)] = m.group(2) or 'none'
|
|
38
|
-
for m in re.finditer(r'export\s+const\s+(\w+)\s*=\s*\(\s*(?:\w+)?\s*(?::\s*(\w+|Partial<[^>]+>|Record<[^>]+>))?', txt):
|
|
39
|
-
fn_map[m.group(1)] = m.group(2) or 'none'
|
|
40
|
-
return fn_map
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# ── Java Bo 解析 ─────────────────────────────────────────────
|
|
44
|
-
|
|
45
|
-
def build_bo_index():
|
|
46
|
-
"""预扫所有 Bo/Dto/Query 类, 建 {类名: 路径} 索引。"""
|
|
47
|
-
index = {}
|
|
48
|
-
root = os.path.join(BASE, 'data', 'code', 'fywl-ics')
|
|
49
|
-
for pattern in ['**/*Bo.java', '**/*Dto.java', '**/*QueryBo.java', '**/*Query.java']:
|
|
50
|
-
for f in glob.glob(os.path.join(root, pattern), recursive=True):
|
|
51
|
-
if 'target' in f or '/classes/' in f:
|
|
52
|
-
continue
|
|
53
|
-
base_name = os.path.basename(f).replace('.java', '')
|
|
54
|
-
for suffix in ['QueryBo', 'Bo', 'Dto', 'Query']:
|
|
55
|
-
if base_name.endswith(suffix):
|
|
56
|
-
index[base_name] = f
|
|
57
|
-
short = base_name[:-len(suffix)]
|
|
58
|
-
if short not in index:
|
|
59
|
-
index[short] = f
|
|
60
|
-
break
|
|
61
|
-
else:
|
|
62
|
-
index[base_name] = f
|
|
63
|
-
return index
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def gen_default(java_type, field_name):
|
|
67
|
-
"""按 Java 类型 + 字段名生成智能默认值。"""
|
|
68
|
-
FIELD_DEFAULTS = {
|
|
69
|
-
'pageNum': 1, 'pageSize': 10, 'page': 1, 'size': 10, 'current': 1,
|
|
70
|
-
'id': 1, 'parentId': 0, 'pid': 0, 'deptId': 100,
|
|
71
|
-
'userId': 1, 'tenantId': '000000',
|
|
72
|
-
'status': 0, 'type': '', 'code': '', 'name': 'test',
|
|
73
|
-
'phone': '13800000000', 'mobile': '13800000000', 'email': 'test@test.com',
|
|
74
|
-
'isAsc': 'asc', 'orderByColumn': 'id',
|
|
75
|
-
}
|
|
76
|
-
if field_name in FIELD_DEFAULTS:
|
|
77
|
-
return FIELD_DEFAULTS[field_name]
|
|
78
|
-
fn = (field_name or '').lower()
|
|
79
|
-
if 'phone' in fn or 'mobile' in fn:
|
|
80
|
-
return '13800000000'
|
|
81
|
-
if 'email' in fn:
|
|
82
|
-
return 'test@test.com'
|
|
83
|
-
if 'date' in fn or 'time' in fn:
|
|
84
|
-
return '2026-01-01'
|
|
85
|
-
if 'name' in fn:
|
|
86
|
-
return 'test'
|
|
87
|
-
if 'code' in fn:
|
|
88
|
-
return 'TEST001'
|
|
89
|
-
if fn == 'id' or fn.endswith('id'):
|
|
90
|
-
return 1
|
|
91
|
-
jt = (java_type or '').strip()
|
|
92
|
-
if jt in ('Long', 'long', 'Integer', 'int', 'BigInteger', 'BigDecimal', 'Number'):
|
|
93
|
-
return 1
|
|
94
|
-
if jt in ('String', 'CharSequence', 'char'):
|
|
95
|
-
return 'test'
|
|
96
|
-
if jt in ('Boolean', 'boolean'):
|
|
97
|
-
return False
|
|
98
|
-
if jt in ('Date', 'LocalDate', 'LocalDateTime', 'Timestamp'):
|
|
99
|
-
return '2026-01-01'
|
|
100
|
-
if jt in ('Double', 'double', 'Float', 'float'):
|
|
101
|
-
return 1.0
|
|
102
|
-
if jt.startswith('List') or jt.startswith('Set') or jt.startswith('Collection'):
|
|
103
|
-
return []
|
|
104
|
-
if jt.startswith('Map'):
|
|
105
|
-
return {}
|
|
106
|
-
return None
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def parse_bo_fields(java_path):
|
|
110
|
-
"""解析 Java Bo 类的字段+类型+校验注解。"""
|
|
111
|
-
try:
|
|
112
|
-
if not os.path.isfile(java_path) or os.path.getsize(java_path) > 80000:
|
|
113
|
-
return []
|
|
114
|
-
txt = open(java_path, encoding='utf-8', errors='ignore').read()
|
|
115
|
-
except Exception:
|
|
116
|
-
return []
|
|
117
|
-
fields = []
|
|
118
|
-
try:
|
|
119
|
-
for m in re.finditer(
|
|
120
|
-
r'((?:@\w+(?:\([^)]*\))?\s*)*)'
|
|
121
|
-
r'(?:private\s+)?(\w+(?:<[^>]+>)?)\s+(\w+)\s*;', txt):
|
|
122
|
-
anns, jtype, fname = m.group(1), m.group(2), m.group(3)
|
|
123
|
-
if fname in ('serialVersionUID', 'logger', 'LOG') or fname.isupper():
|
|
124
|
-
continue
|
|
125
|
-
required = bool(re.search(r'@(?:NotNull|NotBlank|NotEmpty|Valid)\b', anns))
|
|
126
|
-
fields.append({'name': fname, 'type': jtype, 'required': required})
|
|
127
|
-
except Exception:
|
|
128
|
-
pass
|
|
129
|
-
return fields
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
_BO_CACHE = {}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def bo_to_params(bo_class, bo_index):
|
|
136
|
-
"""从 Bo 类名解析出参数 JSON (带缓存)。"""
|
|
137
|
-
if not bo_class or bo_class in _BO_CACHE:
|
|
138
|
-
return _BO_CACHE.get(bo_class)
|
|
139
|
-
jf = bo_index.get(bo_class) or bo_index.get(bo_class + 'Bo') or bo_index.get(bo_class + 'Dto')
|
|
140
|
-
if not jf:
|
|
141
|
-
_BO_CACHE[bo_class] = None
|
|
142
|
-
return None
|
|
143
|
-
fields = parse_bo_fields(jf)
|
|
144
|
-
if not fields:
|
|
145
|
-
_BO_CACHE[bo_class] = None
|
|
146
|
-
return None
|
|
147
|
-
params = {}
|
|
148
|
-
for f in fields:
|
|
149
|
-
val = gen_default(f['type'], f['name'])
|
|
150
|
-
if f['required'] and val is None:
|
|
151
|
-
val = 1 if 'id' in f['name'].lower() else 'test'
|
|
152
|
-
params[f['name']] = val
|
|
153
|
-
_BO_CACHE[bo_class] = params
|
|
154
|
-
return params
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# ── 参数生成 ─────────────────────────────────────────────────
|
|
158
|
-
|
|
159
|
-
def gen_params(ptype, bo_index=None):
|
|
160
|
-
"""按 TS 参数类型生成默认参数 JSON。Bo 类型解析 Java 字段。"""
|
|
161
|
-
if ptype == 'PageQuery':
|
|
162
|
-
return {'pageNum': 1, 'pageSize': 10, 'isAsc': 'asc', 'orderByColumn': 'id'}, 'PageQuery'
|
|
163
|
-
if ptype in ('ID', 'Id'):
|
|
164
|
-
return {'id': 1}, 'ID'
|
|
165
|
-
if ptype == 'IDS':
|
|
166
|
-
return {'ids': [1]}, 'IDS'
|
|
167
|
-
if ptype == 'string':
|
|
168
|
-
return {'id': '1'}, 'string'
|
|
169
|
-
if ptype == 'number':
|
|
170
|
-
return {'id': 1}, 'number'
|
|
171
|
-
if ptype and ptype not in ('any', 'none', 'Recordable', 'Partial', 'Record', 'boolean', 'Blob'):
|
|
172
|
-
if bo_index:
|
|
173
|
-
bp = bo_to_params(ptype, bo_index)
|
|
174
|
-
if bp:
|
|
175
|
-
return bp, 'Bo:' + ptype
|
|
176
|
-
return {}, 'Bo:' + ptype
|
|
177
|
-
if ptype == 'any':
|
|
178
|
-
return {}, 'any'
|
|
179
|
-
return {}, 'none'
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
# ── 主流程 ───────────────────────────────────────────────────
|
|
183
|
-
|
|
184
|
-
def main():
|
|
185
|
-
t0 = time.time()
|
|
186
|
-
|
|
187
|
-
# 1. 读主库(只读)拿接口列表
|
|
188
|
-
kg = duckdb.connect(KG_PATH, read_only=True)
|
|
189
|
-
rows = kg.execute("SELECT fn_name, url, verb FROM api_functions WHERE url IS NOT NULL").fetchall()
|
|
190
|
-
kg.close()
|
|
191
|
-
sys.stderr.write('[%.1fs] DuckDB: %d rows\n' % (time.time() - t0, len(rows)))
|
|
192
|
-
|
|
193
|
-
# 2. TS 参数类型
|
|
194
|
-
fn_map = parse_ts_param_types()
|
|
195
|
-
sys.stderr.write('[%.1fs] TS: %d fns\n' % (time.time() - t0, len(fn_map)))
|
|
196
|
-
|
|
197
|
-
# 2b. Bo 类索引
|
|
198
|
-
bo_index = build_bo_index()
|
|
199
|
-
sys.stderr.write('[%.1fs] Bo index: %d\n' % (time.time() - t0, len(bo_index)))
|
|
200
|
-
|
|
201
|
-
# 3. 生成参数
|
|
202
|
-
results = []
|
|
203
|
-
source_dist = {}
|
|
204
|
-
for fn, url, verb in rows:
|
|
205
|
-
if not url or url.startswith('$'):
|
|
206
|
-
continue
|
|
207
|
-
ptype = fn_map.get(fn, 'none')
|
|
208
|
-
params, source = gen_params(ptype, bo_index)
|
|
209
|
-
req = [k for k, v in params.items() if v is not None]
|
|
210
|
-
results.append({
|
|
211
|
-
'url': url, 'verb': verb or '', 'param_source': source,
|
|
212
|
-
'params': params, 'required': req,
|
|
213
|
-
})
|
|
214
|
-
skey = source.split(':')[0]
|
|
215
|
-
source_dist[skey] = source_dist.get(skey, 0) + 1
|
|
216
|
-
|
|
217
|
-
sys.stderr.write('[%.1fs] Generated: %d\n' % (time.time() - t0, len(results)))
|
|
218
|
-
|
|
219
|
-
# 4. 写 JSON
|
|
220
|
-
output = {
|
|
221
|
-
'version': '1.0',
|
|
222
|
-
'extracted_at': datetime.now().isoformat()[:19],
|
|
223
|
-
'total': len(results),
|
|
224
|
-
'apis': results,
|
|
225
|
-
}
|
|
226
|
-
with open(PARAMS_FILE, 'w', encoding='utf-8') as f:
|
|
227
|
-
json.dump(output, f, ensure_ascii=False, indent=2)
|
|
228
|
-
sys.stderr.write('[%.1fs] Written: %s\n' % (time.time() - t0, PARAMS_FILE))
|
|
229
|
-
|
|
230
|
-
# 5. 报告
|
|
231
|
-
sys.stderr.write('\n=== API 参数提取 ===\n')
|
|
232
|
-
sys.stderr.write('总接口: %d, 已提取: %d\n' % (len(rows), len(results)))
|
|
233
|
-
for s, c in sorted(source_dist.items(), key=lambda x: -x[1]):
|
|
234
|
-
sys.stderr.write(' %-15s %d\n' % (s, c))
|
|
235
|
-
|
|
236
|
-
# 样本
|
|
237
|
-
for r in results:
|
|
238
|
-
if r['param_source'] not in ('none', 'any') and r['params']:
|
|
239
|
-
sys.stderr.write('\n样本: %s [%s] %s\n' % (
|
|
240
|
-
r['url'][:50], r['param_source'],
|
|
241
|
-
json.dumps(r['params'], ensure_ascii=False)[:60]))
|
|
242
|
-
break
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if __name__ == '__main__':
|
|
246
|
-
main()
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import sys, os, re, glob, json
|
|
2
|
-
sys.stdout.reconfigure(encoding='utf-8')
|
|
3
|
-
|
|
4
|
-
# 扫前端路由文件, 提取 path -> component 映射
|
|
5
|
-
router_dir = 'E:/YFHJ/new/AiProject/qoderAll/data/code/fywl-ui/apps/ics/src/router'
|
|
6
|
-
routes = []
|
|
7
|
-
|
|
8
|
-
for rf in glob.glob(os.path.join(router_dir, '**', '*.ts'), recursive=True):
|
|
9
|
-
try:
|
|
10
|
-
txt = open(rf, encoding='utf-8', errors='ignore').read()
|
|
11
|
-
except:
|
|
12
|
-
continue
|
|
13
|
-
# 匹配 path: 'xxx' 和 component: () => import('xxx')
|
|
14
|
-
# 或 path: 'xxx', name: 'yyy'
|
|
15
|
-
for m in re.finditer(
|
|
16
|
-
r"path:\s*['\"`]([^'\"`]+)['\"`]"
|
|
17
|
-
r"[^}]*?(?:name:\s*['\"]([^'\"]+)['\"])?"
|
|
18
|
-
r"[^}]*?(?:component:\s*\([^)]*\)\s*=>\s*import\(['\"]([^'\"]+)['\"]\))?",
|
|
19
|
-
txt, re.S):
|
|
20
|
-
path, name, component = m.group(1), m.group(2) or '', m.group(3) or ''
|
|
21
|
-
if path and not path.startswith(':') and len(path) > 1:
|
|
22
|
-
routes.append({'path': path, 'name': name, 'component': component})
|
|
23
|
-
|
|
24
|
-
# 也扫后台菜单路由(通常在数据库 sys_menu 表, 但前端可能有硬编码)
|
|
25
|
-
# 搜 views 目录下的 Vue 文件路径作为页面标识
|
|
26
|
-
vue_views = glob.glob('E:/YFHJ/new/AiProject/qoderAll/data/code/fywl-ui/apps/ics/src/views/**/*.vue', recursive=True)
|
|
27
|
-
view_paths = [v.replace('\\', '/').split('/views/')[-1].replace('.vue', '') for v in vue_views]
|
|
28
|
-
|
|
29
|
-
print('路由定义: %d 条' % len(routes))
|
|
30
|
-
print('Vue 页面: %d 个' % len(view_paths))
|
|
31
|
-
|
|
32
|
-
# 保存路由索引
|
|
33
|
-
output = {
|
|
34
|
-
'version': '1.0',
|
|
35
|
-
'total_routes': len(routes),
|
|
36
|
-
'total_views': len(view_paths),
|
|
37
|
-
'routes': routes,
|
|
38
|
-
'views': sorted(view_paths),
|
|
39
|
-
}
|
|
40
|
-
out_path = 'E:/YFHJ/new/AiProject/qoderAll/data/index/frontend-routes.json'
|
|
41
|
-
with open(out_path, 'w', encoding='utf-8') as f:
|
|
42
|
-
json.dump(output, f, ensure_ascii=False, indent=2)
|
|
43
|
-
print('已保存: %s' % out_path)
|
|
44
|
-
|
|
45
|
-
# 样本
|
|
46
|
-
print('\n样本路由:')
|
|
47
|
-
for r in routes[:8]:
|
|
48
|
-
print(' %s -> %s' % (r['path'], r['component'][:50] if r['component'] else r['name']))
|
|
49
|
-
|
|
50
|
-
# 保险相关
|
|
51
|
-
print('\n保险相关路由:')
|
|
52
|
-
for r in routes:
|
|
53
|
-
if 'insur' in r['path'].lower() or '保险' in r.get('name', ''):
|
|
54
|
-
print(' %s' % r['path'])
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""extract_routes_tree.py — 从 getRouters API 拉完整菜单树, 递归拼接准确 path, 存成 menu-routes-tree.json.
|
|
3
|
-
解决 menu-routes.json 扁平丢失父子关系、search_index 用 component 猜 URL 导致 404 的问题。
|
|
4
|
-
用法: python extract_routes_tree.py
|
|
5
|
-
"""
|
|
6
|
-
import json, os, sys, requests
|
|
7
|
-
|
|
8
|
-
SCRIPTS = os.path.dirname(os.path.abspath(__file__))
|
|
9
|
-
PROJECT = os.path.normpath(os.path.join(SCRIPTS, '..', '..'))
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def read_developer():
|
|
13
|
-
f = os.path.join(PROJECT, '.qoder', '.developer')
|
|
14
|
-
for ln in open(f, encoding='utf-8'):
|
|
15
|
-
if ln.strip().startswith('name='):
|
|
16
|
-
return ln.strip().split('=', 1)[1].strip()
|
|
17
|
-
raise RuntimeError('无 .developer, 先 /wl-init')
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
dev = read_developer()
|
|
21
|
-
auth_file = os.path.join(PROJECT, 'workspace', 'members', dev, 'auth-state.json')
|
|
22
|
-
if not os.path.exists(auth_file):
|
|
23
|
-
print('无 auth-state, 先登录: python .qoder/scripts/kg_auto_login.py'); sys.exit(1)
|
|
24
|
-
auth = json.load(open(auth_file, encoding='utf-8'))
|
|
25
|
-
token = auth['access_token']
|
|
26
|
-
base = auth['base_url']; prefix = auth.get('api_prefix', '/test-api')
|
|
27
|
-
|
|
28
|
-
print('拉取 getRouters...')
|
|
29
|
-
r = requests.get(base + prefix + '/system/menu/getRouters',
|
|
30
|
-
headers={'Authorization': 'Bearer ' + token, 'clientid': 'e5cd7e4891bf95d1d19206ce24a7b32e'},
|
|
31
|
-
timeout=20)
|
|
32
|
-
d = r.json()
|
|
33
|
-
if d.get('code') != 200:
|
|
34
|
-
print('getRouters 失败:', d.get('msg')); sys.exit(1)
|
|
35
|
-
tree = d.get('data') or []
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def walk(nodes, parent_path=''):
|
|
39
|
-
"""递归拼接准确 path, 返回 [{full_path, name, component}].
|
|
40
|
-
name 优先用 meta.title(中文), 回退 name(i18n key)."""
|
|
41
|
-
out = []
|
|
42
|
-
for n in nodes:
|
|
43
|
-
seg = n.get('path', '').lstrip('/')
|
|
44
|
-
meta = n.get('meta') or {}
|
|
45
|
-
name = meta.get('title', '') or n.get('name', '')
|
|
46
|
-
comp = n.get('component', '')
|
|
47
|
-
full = (parent_path.rstrip('/') + '/' + seg) if parent_path else '/' + seg
|
|
48
|
-
while '//' in full:
|
|
49
|
-
full = full.replace('//', '/')
|
|
50
|
-
kids = n.get('children') or []
|
|
51
|
-
if kids:
|
|
52
|
-
out.extend(walk(kids, full))
|
|
53
|
-
elif comp and comp != '#' and ':' not in full:
|
|
54
|
-
out.append({'path': full, 'name': name, 'component': comp, 'i18n_key': n.get('name', '')})
|
|
55
|
-
return out
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
pages = walk(tree)
|
|
59
|
-
# 去重
|
|
60
|
-
seen = set(); uniq = []
|
|
61
|
-
for p in pages:
|
|
62
|
-
if p['path'] not in seen:
|
|
63
|
-
seen.add(p['path']); uniq.append(p)
|
|
64
|
-
|
|
65
|
-
out_file = os.path.join(PROJECT, 'data', 'index', 'menu-routes-tree.json')
|
|
66
|
-
json.dump({
|
|
67
|
-
'source': 'getRouters API (父子树递归拼接, 准确 path)',
|
|
68
|
-
'total': len(uniq),
|
|
69
|
-
'routes': uniq,
|
|
70
|
-
}, open(out_file, 'w', encoding='utf-8'), ensure_ascii=False, indent=2)
|
|
71
|
-
|
|
72
|
-
print('已存 %d 条准确路由 -> %s' % (len(uniq), out_file))
|
|
73
|
-
print()
|
|
74
|
-
# 验证关键页面
|
|
75
|
-
for kw in ['abnormalRecords', 'insurance', 'ticket']:
|
|
76
|
-
hits = [p for p in uniq if kw.lower() in (p['path'] + p['name']).lower()]
|
|
77
|
-
for h in hits[:2]:
|
|
78
|
-
print(' %-12s -> %s' % (h['name'][:10], h['path']))
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# handoff.py - Handoff management
|
|
2
|
-
import os, json
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
BASE = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
5
|
-
|
|
6
|
-
def create_handoff(task_id, from_role, to_role, artifacts, checklist):
|
|
7
|
-
td = os.path.join(BASE, 'workspace', 'tasks', task_id, 'handoff')
|
|
8
|
-
os.makedirs(td, exist_ok=True)
|
|
9
|
-
fname = from_role + '-to-' + to_role + '.json'
|
|
10
|
-
data = {
|
|
11
|
-
'task_id': task_id,
|
|
12
|
-
'from_role': from_role,
|
|
13
|
-
'to_role': to_role,
|
|
14
|
-
'artifacts': artifacts,
|
|
15
|
-
'checklist': [{'item': c, 'status': 'pending'} for c in checklist],
|
|
16
|
-
'status': 'pending',
|
|
17
|
-
'created_at': datetime.now().isoformat()
|
|
18
|
-
}
|
|
19
|
-
with open(os.path.join(td, fname), 'w') as f:
|
|
20
|
-
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
21
|
-
print('OK: handoff ' + from_role + ' -> ' + to_role)
|
|
22
|
-
return data
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
QODER Pipeline - 开发者初始化
|
|
5
|
-
|
|
6
|
-
Usage:
|
|
7
|
-
python init_developer.py <developer-name>
|
|
8
|
-
|
|
9
|
-
功能:
|
|
10
|
-
- 创建 .qoder/.developer 文件 (gitignored, 包含开发者身份信息)
|
|
11
|
-
- 创建 .qoder/workspace/<name>/ 目录结构
|
|
12
|
-
- 创建初始日志文件 journal-1.md
|
|
13
|
-
- 创建工作空间索引 index.md
|
|
14
|
-
|
|
15
|
-
参考: Trellis 的 init_developer.py 设计
|
|
16
|
-
|
|
17
|
-
示例:
|
|
18
|
-
python .qoder/scripts/init_developer.py zhangsan
|
|
19
|
-
python .qoder/scripts/init_developer.py john
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
from __future__ import annotations
|
|
23
|
-
|
|
24
|
-
import sys
|
|
25
|
-
import os
|
|
26
|
-
|
|
27
|
-
# 将 scripts 目录加入路径
|
|
28
|
-
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
29
|
-
|
|
30
|
-
from common.paths import (
|
|
31
|
-
DIR_WORKFLOW,
|
|
32
|
-
FILE_DEVELOPER,
|
|
33
|
-
get_developer,
|
|
34
|
-
get_repo_root,
|
|
35
|
-
)
|
|
36
|
-
from common.developer import init_developer, show_developer_info
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def main() -> None:
|
|
40
|
-
"""CLI 入口。"""
|
|
41
|
-
if len(sys.argv) < 2:
|
|
42
|
-
print(f"Usage: {sys.argv[0]} <developer-name> [role]")
|
|
43
|
-
print()
|
|
44
|
-
print("Example:")
|
|
45
|
-
print(f" {sys.argv[0]} zhangsan")
|
|
46
|
-
print(f" {sys.argv[0]} zhangsan pm")
|
|
47
|
-
sys.exit(1)
|
|
48
|
-
|
|
49
|
-
name = sys.argv[1]
|
|
50
|
-
role = sys.argv[2] if len(sys.argv) > 2 else None
|
|
51
|
-
|
|
52
|
-
# 检查是否已初始化
|
|
53
|
-
existing = get_developer()
|
|
54
|
-
if existing == name:
|
|
55
|
-
print(f"Developer already initialized: {existing}")
|
|
56
|
-
print()
|
|
57
|
-
print("Current developer info:")
|
|
58
|
-
show_developer_info()
|
|
59
|
-
sys.exit(0)
|
|
60
|
-
elif existing:
|
|
61
|
-
print(f"Switching developer: {existing} -> {name}")
|
|
62
|
-
|
|
63
|
-
# 初始化 (幂等, 也用于切换开发者)
|
|
64
|
-
if init_developer(name, role):
|
|
65
|
-
print()
|
|
66
|
-
print("Next steps:")
|
|
67
|
-
print(f" 1. Your workspace is at: workspace/members/{name}/")
|
|
68
|
-
print(f" 2. Start creating tasks: python .qoder/scripts/task.py create \"My Task\"")
|
|
69
|
-
print(f" 3. Check status: python .qoder/scripts/task.py list")
|
|
70
|
-
sys.exit(0)
|
|
71
|
-
else:
|
|
72
|
-
sys.exit(1)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if __name__ == "__main__":
|
|
76
|
-
main()
|