cli-mem 0.3.0__tar.gz → 0.3.2__tar.gz
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.
- {cli_mem-0.3.0 → cli_mem-0.3.2}/PKG-INFO +1 -1
- {cli_mem-0.3.0 → cli_mem-0.3.2}/pyproject.toml +1 -1
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/__init__.py +1 -1
- cli_mem-0.3.2/src/mem/_generable.py +35 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/patterns.py +11 -5
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/variables.py +1 -15
- {cli_mem-0.3.0 → cli_mem-0.3.2}/.github/workflows/ci.yml +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/.github/workflows/release.yml +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/.gitignore +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/ARCHITECTURE.md +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/LICENSE +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/PHILOSOPHY.md +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/README.md +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/assets/.gitkeep +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/docs/decisions/001-jsonl-over-sqlite.md +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/docs/decisions/002-apple-fm-sdk-for-patterns.md +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/docs/decisions/003-no-daemon.md +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/docs/decisions/004-per-repo-jsonl.md +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/hooks/mem.zsh +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/install.sh +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/capture.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/cli.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/groups.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/models.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/search.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/src/mem/storage.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/tests/conftest.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/tests/test_capture.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/tests/test_groups.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/tests/test_patterns.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/tests/test_search.py +0 -0
- {cli_mem-0.3.0 → cli_mem-0.3.2}/tests/test_storage.py +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Apple FM SDK generable types for mem.
|
|
2
|
+
|
|
3
|
+
This module is intentionally separate from variables.py because
|
|
4
|
+
``from __future__ import annotations`` (PEP 563) converts all type
|
|
5
|
+
hints to strings, which breaks apple-fm-sdk's @fm.generable decorator
|
|
6
|
+
when it tries to resolve nested type references like
|
|
7
|
+
``list[CredentialDetection]`` via ``typing.get_type_hints()``.
|
|
8
|
+
|
|
9
|
+
By keeping these classes in their own module without deferred
|
|
10
|
+
annotations, the SDK can inspect the concrete types at decoration time.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
import apple_fm_sdk as fm
|
|
15
|
+
|
|
16
|
+
@fm.generable("Detected credential in a shell command")
|
|
17
|
+
class CredentialDetection:
|
|
18
|
+
original_value: str = fm.guide(
|
|
19
|
+
"The literal sensitive value found in the command"
|
|
20
|
+
)
|
|
21
|
+
suggested_name: str = fm.guide(
|
|
22
|
+
"A descriptive variable name like ACME_API_TOKEN"
|
|
23
|
+
)
|
|
24
|
+
reason: str = fm.guide(
|
|
25
|
+
"Why this looks like a credential (e.g., 'JWT token', 'API key')"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
@fm.generable("List of credentials detected in a shell command")
|
|
29
|
+
class CredentialList:
|
|
30
|
+
credentials: list[CredentialDetection] = fm.guide("All detected credentials")
|
|
31
|
+
|
|
32
|
+
except ImportError:
|
|
33
|
+
# SDK not available — classes won't be used, but module still importable.
|
|
34
|
+
CredentialDetection = None
|
|
35
|
+
CredentialList = None
|
|
@@ -95,18 +95,24 @@ async def _generalize_commands(tool: str, unique_commands: list[str]) -> dict[st
|
|
|
95
95
|
"""Generalize each unique command via Apple FM guided generation.
|
|
96
96
|
|
|
97
97
|
Returns a mapping from concrete command -> generalized pattern.
|
|
98
|
-
Uses
|
|
98
|
+
Uses a fresh session per command to avoid exceeding the on-device
|
|
99
|
+
model's context window when processing many commands.
|
|
99
100
|
"""
|
|
100
101
|
import apple_fm_sdk as fm
|
|
101
102
|
|
|
102
103
|
GeneralizedCommand = _get_generable_types()
|
|
103
|
-
session = fm.LanguageModelSession()
|
|
104
104
|
cmd_to_pattern: dict[str, str] = {}
|
|
105
105
|
|
|
106
106
|
for cmd in unique_commands:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
try:
|
|
108
|
+
session = fm.LanguageModelSession()
|
|
109
|
+
prompt = GENERALIZE_PROMPT.format(tool=tool, command=cmd)
|
|
110
|
+
result = await session.respond(prompt, generating=GeneralizedCommand)
|
|
111
|
+
cmd_to_pattern[cmd] = result.pattern
|
|
112
|
+
except Exception:
|
|
113
|
+
# Skip commands that fail (too long, context issues, etc.)
|
|
114
|
+
# Fall back to the raw command as its own pattern.
|
|
115
|
+
cmd_to_pattern[cmd] = cmd
|
|
110
116
|
|
|
111
117
|
return cmd_to_pattern
|
|
112
118
|
|
|
@@ -278,21 +278,7 @@ async def _detect_credentials_async(cmd: str) -> list[tuple[str, str, str]]:
|
|
|
278
278
|
"""
|
|
279
279
|
import apple_fm_sdk as fm
|
|
280
280
|
|
|
281
|
-
|
|
282
|
-
class CredentialDetection:
|
|
283
|
-
original_value: str = fm.guide(
|
|
284
|
-
"The literal sensitive value found in the command"
|
|
285
|
-
)
|
|
286
|
-
suggested_name: str = fm.guide(
|
|
287
|
-
"A descriptive variable name like ACME_API_TOKEN"
|
|
288
|
-
)
|
|
289
|
-
reason: str = fm.guide(
|
|
290
|
-
"Why this looks like a credential (e.g., 'JWT token', 'API key')"
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
@fm.generable("List of credentials detected in a shell command")
|
|
294
|
-
class CredentialList:
|
|
295
|
-
credentials: list[CredentialDetection] = fm.guide("All detected credentials")
|
|
281
|
+
from mem._generable import CredentialList
|
|
296
282
|
|
|
297
283
|
session = fm.LanguageModelSession()
|
|
298
284
|
prompt = (
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|