Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ diffpy macro language.

.. code-block:: bash

diffpy.app runmacro <macro_file.dp-in>
diffpy-app runmacro <macro_file.dp-in>

To follow the example,

Expand All @@ -43,7 +43,7 @@ To follow the example,

.. code-block:: bash

diffpy.app runmacro example_macro.dp-in
diffpy-app runmacro example_macro.dp-in

How to write macro
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -160,23 +160,23 @@ local environment. To use this application, run:

.. code-block:: bash

diffpy.app agentify
diffpy-app agentify

``claude`` and ``codex`` agent skills are supported, and ``claude`` is used
by default. To specify the agent skill, use the ``--agent`` option:

.. code-block:: bash

diffpy.app agentify --agent codex
diffpy-app agentify --agent codex

To deploy the agentic skill to the system directory, use the ``--system`` flag:

.. code-block:: bash

diffpy.app agentify --system
diffpy-app agentify --system

To update the existing ``diffpy.cmi`` agentic skill, use the ``--update`` flag:

.. code-block:: bash

diffpy.app agentify --update
diffpy-app agentify --update
23 changes: 23 additions & 0 deletions news/skipif-no-internet.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Ensure ``git`` is installed and internet connection for ``agentify``.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ exclude = [] # exclude packages matching these glob patterns (empty by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)

[project.scripts]
"diffpy.apps" = "diffpy.apps.apps:main"
"diffpy.app" = "diffpy.apps.apps:main"
"diffpy-apps" = "diffpy.apps.apps:main"
"diffpy-app" = "diffpy.apps.apps:main"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements/pip.txt"]}
Expand Down
20 changes: 20 additions & 0 deletions src/diffpy/apps/app_agentify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shutil
import socket
import subprocess
import tempfile
from pathlib import Path
Expand All @@ -7,7 +8,26 @@
DIR_NAME = "cmi-skill"


def ensure_setup():
def internet_available():
try:
socket.create_connection(("github.com", 443), timeout=3)
return True
except OSError:
return False

git_available = shutil.which("git") is not None
agentify_available = internet_available() and git_available
return agentify_available


def agentify(args):
if not ensure_setup():
raise ValueError(
"Internet connection or git unavailable. "
"Please ensure git is installed and you have an active internet "
f"connection to {REPO_URL}."
)
agent = args.agent
system_flag = args.system
if agent == "claude":
Expand Down
8 changes: 7 additions & 1 deletion tests/test_agentify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

import pytest

from diffpy.apps.app_agentify import agentify
from diffpy.apps.app_agentify import agentify, ensure_setup

pytestmark = pytest.mark.skipif(
not ensure_setup(),
reason="Internet connection or git unavailable. Skipping agentify tests.",
allow_module_level=True,
)


@pytest.mark.parametrize(
Expand Down
Loading