Sync up site-packages to devchat[main](8510de6a)
This commit is contained in:
parent
b65ff9cd19
commit
ca3c38d9de
@ -7,7 +7,7 @@ devchat-0.2.10.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
||||
devchat-0.2.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
||||
devchat-0.2.10.dist-info/direct_url.json,sha256=1wB_-Q0sLy-N5jRVP5JH0daRG37J_dnkfRV4Ae-DNvI,111
|
||||
devchat-0.2.10.dist-info/entry_points.txt,sha256=Glu9CHUNBjYbZXTQc3YW2rZFr2S_3AvqKu50gj3aWT4,50
|
||||
devchat/__init__.py,sha256=8UIF0BHrawuQ7_QbzFwaSsXWdCKPNJjhegCbsPgJchc,145
|
||||
devchat/__init__.py,sha256=nFQCLcJgn6getUyK3AsqtG5j87qLKeBEA3YtgnYn8nU,146
|
||||
devchat/__main__.py,sha256=RY7_u5N5S0Ye2YtBWeYkk9n8zia_z9oe3DnS1SHRxZA,110
|
||||
devchat/__pycache__/__init__.cpython-38.pyc,,
|
||||
devchat/__pycache__/__main__.cpython-38.pyc,,
|
||||
@ -34,7 +34,7 @@ devchat/_cli/log.py,sha256=QU7jXZC3FFEFH-_9KaHtMESiY8qGX4ocG8MKDpg0cSY,3278
|
||||
devchat/_cli/main.py,sha256=1IFbGSs6PbmoRmL3r0-SwlsGaNyl0mQ1tpUgYRW8GuQ,582
|
||||
devchat/_cli/prompt.py,sha256=PniymJQqNecYz02mrduYHXO5LeSjDxdraWyI_7dEtrE,2916
|
||||
devchat/_cli/route.py,sha256=9YVnry0OpW4B_RUiRtXqpblOZfQoFmSH6Xs7hflzmRg,2490
|
||||
devchat/_cli/router.py,sha256=jw6JkD0Edn6jw1-VStTCjnD6RVABWswyLCTMhlyiff8,6394
|
||||
devchat/_cli/router.py,sha256=XKzaSxQ5dVicVnoA-jqrecB-jXYDvIX82mVy5FlAWaU,6382
|
||||
devchat/_cli/run.py,sha256=QAidaTAvVLPyqylROiGgd5y5370K4ylJvUORjZoziVo,6657
|
||||
devchat/_cli/topic.py,sha256=Nxiir_0ArOQt377ywM8vxmEfGIGUfIRCiHSVD2z-nP8,1167
|
||||
devchat/_cli/utils.py,sha256=ooepOTF-0mLN6sg5wcnnwE52WkWWayZBo7NepEFxveI,5460
|
||||
@ -138,16 +138,16 @@ devchat/workflow/command/__pycache__/config.cpython-38.pyc,,
|
||||
devchat/workflow/command/__pycache__/env.cpython-38.pyc,,
|
||||
devchat/workflow/command/__pycache__/list.cpython-38.pyc,,
|
||||
devchat/workflow/command/__pycache__/update.cpython-38.pyc,,
|
||||
devchat/workflow/command/config.py,sha256=u-rdb6taXZ3c2Zbf5J3LzN8MzHHybjzli8FakP1RoU0,759
|
||||
devchat/workflow/command/config.py,sha256=4O22ebz-cx_CiKpEM7NnlbW02rb_OZk3vV_JKHMUPmk,713
|
||||
devchat/workflow/command/env.py,sha256=lTcWns9UnEKIRtr1wh9f1gVqBMPN5Tjr6f-r2d3LOKI,2367
|
||||
devchat/workflow/command/list.py,sha256=raCmNd8GcIQT-4URLbUkQKJJv9IHsuF43P8TZ8_mr30,2904
|
||||
devchat/workflow/command/update.py,sha256=jSrQ5bAVz8VSLzhtIZY5RF7WUhZ_RB-xgD_BO6kZFNI,9856
|
||||
devchat/workflow/command/list.py,sha256=sgX9DQ68VvoYEMndBoqa7mEep4aaSG--mWOS6iapWJ0,3384
|
||||
devchat/workflow/command/update.py,sha256=CnJE3P4RIAHrDv3_QPi47u0kGaZvP08el7C-lzLoxOU,9820
|
||||
devchat/workflow/command/update_flowchart.md,sha256=TrtZtK7K04yihUlIOvI10UCBTmZIumaRjRJJxkn85ow,1737
|
||||
devchat/workflow/env_manager.py,sha256=6A_bZZ1JkpPERQ_QFII8SBMcQDmQylBH3r2vv8wNtZw,5568
|
||||
devchat/workflow/envs.py,sha256=7vf71OG5JOlx8IGomjwDfOXPoRlJc11MmEOd4r4O5OY,297
|
||||
devchat/workflow/namespace.py,sha256=Zd6M0MXv8gHy0Np9kCOH9ZIelCZmRS6j_Uc1fnIuOiU,1592
|
||||
devchat/workflow/namespace.py,sha256=WBDL_S-Lt2xW6tvkhY9cIb6G_pwcJ3v5-tYhsPvPusI,1611
|
||||
devchat/workflow/path.py,sha256=ldTOXJmff7vP3YjFVo_0Awu2fTxZmAQOXlhD-_v7EkM,1110
|
||||
devchat/workflow/schema.py,sha256=XIDZ6uqejeXVSGNJBc0uqDMs2YGvQF8RgCxfP_R6NYQ,1746
|
||||
devchat/workflow/step.py,sha256=1LrXU29F58BA1UEoUfK9GCsKz9ZyzPypSQB00ULSKeg,5812
|
||||
devchat/workflow/user_setting.py,sha256=LPJbKCJkRuzdWNW-HIRfewgngeDNub0AckyfFtFeDUM,620
|
||||
devchat/workflow/step.py,sha256=0q7-sH_n3Gn1cqmq-8TJqr_lUXWd0JIwWOOyKixwYiw,5805
|
||||
devchat/workflow/user_setting.py,sha256=oPKLobDH36_kcQT5RAp5Oa0ZKw4cjXPzLn2zLOvdzvI,621
|
||||
devchat/workflow/workflow.py,sha256=7Pk6RORqmrE4gvF70ESgw5veUHNW9axAT0TKVp4MRg0,7677
|
||||
|
@ -1,4 +1,4 @@
|
||||
import os
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
os.environ["TIKTOKEN_CACHE_DIR"] = os.path.join(script_dir, "tiktoken_cache")
|
||||
os.environ["TIKTOKEN_CACHE_DIR"] = os.path.join(script_dir, "tiktoken_cache")
|
||||
|
@ -145,7 +145,7 @@ def llm_route(content: Optional[str], parent: Optional[str], reference: Optional
|
||||
workflow = Workflow.load(name) if name else None
|
||||
if workflow:
|
||||
print(assistant.prompt.formatted_header())
|
||||
|
||||
|
||||
return_code = 0
|
||||
if workflow.should_show_help(user_input):
|
||||
doc = workflow.get_help_doc(user_input)
|
||||
|
@ -1,7 +1,6 @@
|
||||
import json
|
||||
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple, List, Set, Tuple
|
||||
import click
|
||||
import oyaml as yaml
|
||||
|
||||
@ -11,12 +10,12 @@ from devchat.workflow.path import WORKFLOWS_BASE, WORKFLOWS_CONFIG_FILENAME
|
||||
@click.command(help="Workflow configuration.", name="config")
|
||||
@click.option("--json", "in_json", is_flag=True, help="Output in json format.")
|
||||
def config_cmd(in_json: bool):
|
||||
|
||||
|
||||
config_path = Path(WORKFLOWS_BASE) / WORKFLOWS_CONFIG_FILENAME
|
||||
config_content = {}
|
||||
if config_path.exists():
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
config_content = yaml.safe_load(f.read())
|
||||
with open(config_path, "r", encoding="utf-8") as file:
|
||||
config_content = yaml.safe_load(file.read())
|
||||
|
||||
if not in_json:
|
||||
click.echo(config_content)
|
||||
|
@ -1,15 +1,19 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple, List, Set, Tuple, Optional, Dict
|
||||
from typing import List, Set, Tuple, Dict
|
||||
from dataclasses import dataclass, asdict, field
|
||||
|
||||
import click
|
||||
import oyaml as yaml
|
||||
import yaml as pyyaml
|
||||
|
||||
from devchat.workflow.namespace import get_prioritized_namespace_path
|
||||
from devchat.workflow.path import COMMAND_FILENAMES
|
||||
from devchat.utils import get_logger
|
||||
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@dataclass
|
||||
class WorkflowMeta:
|
||||
name: str
|
||||
@ -41,28 +45,33 @@ def iter_namespace(
|
||||
interest_files = set(COMMAND_FILENAMES)
|
||||
result = []
|
||||
unique_names = set(existing_names)
|
||||
for f in root.rglob("*"):
|
||||
if f.is_file() and f.name in interest_files:
|
||||
rel_path = f.relative_to(root)
|
||||
parts = rel_path.parts
|
||||
workflow_name = ".".join(parts[:-1])
|
||||
is_first = workflow_name not in unique_names
|
||||
unique_names.add(workflow_name)
|
||||
for file in root.rglob("*"):
|
||||
try:
|
||||
if file.is_file() and file.name in interest_files:
|
||||
rel_path = file.relative_to(root)
|
||||
parts = rel_path.parts
|
||||
workflow_name = ".".join(parts[:-1])
|
||||
is_first = workflow_name not in unique_names
|
||||
|
||||
# load the config content from f
|
||||
with open(f, "r", encoding="utf-8") as fi:
|
||||
yaml_content = fi.read()
|
||||
command_conf = yaml.safe_load(yaml_content)
|
||||
# pop the "steps" field
|
||||
command_conf.pop("steps", None)
|
||||
# load the config content from file
|
||||
with open(file, "r", encoding="utf-8") as file_handle:
|
||||
yaml_content = file_handle.read()
|
||||
command_conf = yaml.safe_load(yaml_content)
|
||||
# pop the "steps" field
|
||||
command_conf.pop("steps", None)
|
||||
|
||||
workflow = WorkflowMeta(
|
||||
name=workflow_name,
|
||||
namespace=root.name,
|
||||
active=is_first,
|
||||
command_conf=command_conf,
|
||||
)
|
||||
result.append(workflow)
|
||||
workflow = WorkflowMeta(
|
||||
name=workflow_name,
|
||||
namespace=root.name,
|
||||
active=is_first,
|
||||
command_conf=command_conf,
|
||||
)
|
||||
unique_names.add(workflow_name)
|
||||
result.append(workflow)
|
||||
except pyyaml.scanner.ScannerError as err:
|
||||
logger.error("Failed to load %s: %s", rel_path, err)
|
||||
except Exception as err:
|
||||
logger.error("Unknown error when loading %s: %s", rel_path, err)
|
||||
|
||||
return result, unique_names
|
||||
|
||||
@ -75,19 +84,19 @@ def list_cmd(in_json: bool):
|
||||
workflows: List[WorkflowMeta] = []
|
||||
visited_names = set()
|
||||
for ns_path in namespace_paths:
|
||||
ws, visited_names = iter_namespace(ns_path, visited_names)
|
||||
workflows.extend(ws)
|
||||
ws_names, visited_names = iter_namespace(ns_path, visited_names)
|
||||
workflows.extend(ws_names)
|
||||
|
||||
if not in_json:
|
||||
# print basic info
|
||||
active_count = len([w for w in workflows if w.active])
|
||||
active_count = len([workflow for workflow in workflows if workflow.active])
|
||||
total_count = len(workflows)
|
||||
click.echo(f"workflows (active/total): {active_count}/{total_count}")
|
||||
for w in workflows:
|
||||
click.echo(w)
|
||||
for workflow in workflows:
|
||||
click.echo(workflow)
|
||||
|
||||
else:
|
||||
# convert workflows to json
|
||||
data = [asdict(w) for w in workflows]
|
||||
data = [asdict(workflow) for workflow in workflows]
|
||||
json_format = json.dumps(data)
|
||||
click.echo(json_format)
|
||||
|
@ -57,7 +57,7 @@ def _backup(workflow_base: Path, n: int = 5) -> Optional[Path]:
|
||||
"""
|
||||
|
||||
if not workflow_base.exists():
|
||||
return
|
||||
return None
|
||||
|
||||
backup_dir = workflow_base.parent / ".backup"
|
||||
backup_dir.mkdir(exist_ok=True)
|
||||
@ -180,7 +180,7 @@ def _clone_repo_to_dir(candidates: List[Tuple[str, str]], dst_dir: Path) -> bool
|
||||
clone_ok = False
|
||||
for url, branch in candidates:
|
||||
try:
|
||||
repo = Repo.clone_from(url, to_path=dst_dir, branch=branch)
|
||||
Repo.clone_from(url, to_path=dst_dir, branch=branch)
|
||||
click.echo(f"Cloned from {url}|{branch} to {dst_dir}")
|
||||
clone_ok = True
|
||||
break
|
||||
@ -274,8 +274,6 @@ def update_by_git(workflow_base: Path):
|
||||
)
|
||||
except GitCommandError as e:
|
||||
click.echo(f"Failed to update to the latest main: {e}. Skip update.")
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
def copy_workflows_usr():
|
||||
|
@ -34,14 +34,14 @@ def _load_custom_config() -> CustomConfig:
|
||||
if not os.path.exists(CUSTOM_CONFIG_FILE):
|
||||
return config
|
||||
|
||||
with open(CUSTOM_CONFIG_FILE, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
with open(CUSTOM_CONFIG_FILE, "r", encoding="utf-8") as file:
|
||||
content = file.read()
|
||||
yaml_content = yaml.safe_load(content)
|
||||
try:
|
||||
if yaml_content:
|
||||
config = CustomConfig.parse_obj(yaml_content)
|
||||
except ValidationError as e:
|
||||
logger.warning(f"Invalid custom config file: {e}")
|
||||
except ValidationError as err:
|
||||
logger.warning("Invalid custom config file: %s", err)
|
||||
|
||||
return config
|
||||
|
||||
@ -66,8 +66,8 @@ def get_prioritized_namespace_path() -> List[str]:
|
||||
|
||||
def main():
|
||||
paths = get_prioritized_namespace_path()
|
||||
for p in paths:
|
||||
print(p)
|
||||
for pathv in paths:
|
||||
print(pathv)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -53,6 +53,7 @@ class WorkflowStep:
|
||||
"""
|
||||
Setup the environment variables for the subprocess.
|
||||
"""
|
||||
_1 = wf_config
|
||||
command_raw = self.command_raw
|
||||
|
||||
env = os.environ.copy()
|
||||
@ -98,7 +99,7 @@ class WorkflowStep:
|
||||
"The command uses $workflow_python, "
|
||||
"but the workflow_python is not set yet."
|
||||
)
|
||||
|
||||
|
||||
args = []
|
||||
for p in parts:
|
||||
arg = p
|
||||
@ -116,7 +117,7 @@ class WorkflowStep:
|
||||
|
||||
if p.startswith(BuiltInVars.command_path):
|
||||
# NOTE: 在文档中说明 command.yml 中表示路径采用 POSIX 标准
|
||||
# 即,使用 / 分隔路径,而非 \ (Windows)
|
||||
# 即,使用 / 分隔路径,而非 \ (Windows)
|
||||
path_parts = p.split("/")
|
||||
# replace "$command_path" with the root path in path_parts
|
||||
arg = os.path.join(wf_config.root_path, *path_parts[1:])
|
||||
@ -125,9 +126,9 @@ class WorkflowStep:
|
||||
arg = arg.replace(BuiltInVars.user_input, rt_param.user_input)
|
||||
|
||||
args.append(arg)
|
||||
|
||||
|
||||
return args
|
||||
|
||||
|
||||
|
||||
def run(
|
||||
self, wf_config: WorkflowConfig, rt_param: RuntimeParameter
|
||||
@ -175,4 +176,3 @@ class WorkflowStep:
|
||||
proc.wait()
|
||||
return_code = proc.returncode
|
||||
return return_code, stdout_data["data"], stderr_data["data"]
|
||||
|
||||
|
@ -12,13 +12,12 @@ def _load_user_settings() -> UserSettings:
|
||||
if not settings_path.exists():
|
||||
return UserSettings()
|
||||
|
||||
with open(settings_path, "r", encoding="utf-8") as f:
|
||||
content = yaml.safe_load(f.read())
|
||||
|
||||
with open(settings_path, "r", encoding="utf-8") as file:
|
||||
content = yaml.safe_load(file.read())
|
||||
|
||||
if content:
|
||||
return UserSettings.parse_obj(content)
|
||||
|
||||
return UserSettings()
|
||||
|
||||
USER_SETTINGS = _load_user_settings()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user