@temps-sdk/cli 0.1.37 → 0.2.0-beta.1

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 (130) hide show
  1. package/README.md +14 -0
  2. package/dist/index.js +32148 -34152
  3. package/dist/skills/temps/SKILL.md +148 -0
  4. package/dist/skills/temps/agents/openai.yaml +7 -0
  5. package/dist/skills/temps/evals/evals.json +112 -0
  6. package/dist/skills/temps/howtos/backup-recovery.md +41 -0
  7. package/dist/skills/temps/howtos/ci-automation.md +17 -0
  8. package/dist/skills/temps/howtos/curated-services.md +69 -0
  9. package/dist/skills/temps/howtos/deploy-application.md +36 -0
  10. package/dist/skills/temps/howtos/diagnose-deployment.md +17 -0
  11. package/dist/skills/temps/howtos/edge-rules.md +135 -0
  12. package/dist/skills/temps/howtos/framework-routing.md +28 -0
  13. package/dist/skills/temps/howtos/javascript-typescript.md +57 -0
  14. package/dist/skills/temps/howtos/managed-services.md +83 -0
  15. package/dist/skills/temps/howtos/observability-onboarding.md +52 -0
  16. package/dist/skills/temps/howtos/projects-and-monorepos.md +50 -0
  17. package/dist/skills/temps/howtos/python.md +42 -0
  18. package/dist/skills/temps/howtos/rust.md +30 -0
  19. package/dist/skills/temps/references/cli-runtime.md +60 -0
  20. package/dist/skills/temps/references/commands/INDEX.md +102 -0
  21. package/dist/skills/temps/references/commands/access.md +53 -0
  22. package/dist/skills/temps/references/commands/ai.md +47 -0
  23. package/dist/skills/temps/references/commands/alarms.md +91 -0
  24. package/dist/skills/temps/references/commands/analytics.md +568 -0
  25. package/dist/skills/temps/references/commands/apikeys.md +98 -0
  26. package/dist/skills/temps/references/commands/audit.md +41 -0
  27. package/dist/skills/temps/references/commands/backups.md +269 -0
  28. package/dist/skills/temps/references/commands/cloud.md +385 -0
  29. package/dist/skills/temps/references/commands/cluster.md +31 -0
  30. package/dist/skills/temps/references/commands/configure.md +62 -0
  31. package/dist/skills/temps/references/commands/containers.md +110 -0
  32. package/dist/skills/temps/references/commands/context.md +55 -0
  33. package/dist/skills/temps/references/commands/custom-domains.md +98 -0
  34. package/dist/skills/temps/references/commands/data.md +87 -0
  35. package/dist/skills/temps/references/commands/delivery-profiles.md +69 -0
  36. package/dist/skills/temps/references/commands/delivery.md +116 -0
  37. package/dist/skills/temps/references/commands/deploy-image.md +23 -0
  38. package/dist/skills/temps/references/commands/deploy-local-image.md +28 -0
  39. package/dist/skills/temps/references/commands/deploy-static.md +23 -0
  40. package/dist/skills/temps/references/commands/deploy.md +23 -0
  41. package/dist/skills/temps/references/commands/deployments.md +173 -0
  42. package/dist/skills/temps/references/commands/dns-provider.md +196 -0
  43. package/dist/skills/temps/references/commands/dns.md +181 -0
  44. package/dist/skills/temps/references/commands/domains.md +188 -0
  45. package/dist/skills/temps/references/commands/drop.md +23 -0
  46. package/dist/skills/temps/references/commands/dsn.md +84 -0
  47. package/dist/skills/temps/references/commands/edge-rules.md +218 -0
  48. package/dist/skills/temps/references/commands/email-domains.md +160 -0
  49. package/dist/skills/temps/references/commands/email-providers.md +96 -0
  50. package/dist/skills/temps/references/commands/emails.md +79 -0
  51. package/dist/skills/temps/references/commands/env-pull.md +18 -0
  52. package/dist/skills/temps/references/commands/env-push.md +19 -0
  53. package/dist/skills/temps/references/commands/environments.md +500 -0
  54. package/dist/skills/temps/references/commands/errors.md +763 -0
  55. package/dist/skills/temps/references/commands/facets.md +63 -0
  56. package/dist/skills/temps/references/commands/flags.md +246 -0
  57. package/dist/skills/temps/references/commands/funnels.md +92 -0
  58. package/dist/skills/temps/references/commands/incidents.md +115 -0
  59. package/dist/skills/temps/references/commands/init.md +18 -0
  60. package/dist/skills/temps/references/commands/instances.md +62 -0
  61. package/dist/skills/temps/references/commands/instantiations.md +57 -0
  62. package/dist/skills/temps/references/commands/ip-access.md +153 -0
  63. package/dist/skills/temps/references/commands/link.md +17 -0
  64. package/dist/skills/temps/references/commands/load-balancer.md +73 -0
  65. package/dist/skills/temps/references/commands/login.md +22 -0
  66. package/dist/skills/temps/references/commands/logout.md +16 -0
  67. package/dist/skills/temps/references/commands/logs.md +290 -0
  68. package/dist/skills/temps/references/commands/mcp-servers.md +74 -0
  69. package/dist/skills/temps/references/commands/mcp.md +72 -0
  70. package/dist/skills/temps/references/commands/metrics.md +79 -0
  71. package/dist/skills/temps/references/commands/migrate.md +118 -0
  72. package/dist/skills/temps/references/commands/monitors.md +162 -0
  73. package/dist/skills/temps/references/commands/network-policy.md +120 -0
  74. package/dist/skills/temps/references/commands/nodes.md +254 -0
  75. package/dist/skills/temps/references/commands/notification-preferences.md +47 -0
  76. package/dist/skills/temps/references/commands/notifications.md +233 -0
  77. package/dist/skills/temps/references/commands/open.md +19 -0
  78. package/dist/skills/temps/references/commands/otel-forward.md +226 -0
  79. package/dist/skills/temps/references/commands/otel.md +38 -0
  80. package/dist/skills/temps/references/commands/platform.md +151 -0
  81. package/dist/skills/temps/references/commands/plugin.md +222 -0
  82. package/dist/skills/temps/references/commands/presets.md +37 -0
  83. package/dist/skills/temps/references/commands/project-groups.md +292 -0
  84. package/dist/skills/temps/references/commands/projects.md +329 -0
  85. package/dist/skills/temps/references/commands/providers.md +290 -0
  86. package/dist/skills/temps/references/commands/proxy-logs.md +85 -0
  87. package/dist/skills/temps/references/commands/revenue.md +52 -0
  88. package/dist/skills/temps/references/commands/rollback.md +20 -0
  89. package/dist/skills/temps/references/commands/runtime-logs.md +21 -0
  90. package/dist/skills/temps/references/commands/sandbox.md +518 -0
  91. package/dist/skills/temps/references/commands/scans.md +113 -0
  92. package/dist/skills/temps/references/commands/secrets.md +75 -0
  93. package/dist/skills/temps/references/commands/server.md +50 -0
  94. package/dist/skills/temps/references/commands/services.md +642 -0
  95. package/dist/skills/temps/references/commands/session-replay.md +84 -0
  96. package/dist/skills/temps/references/commands/settings.md +84 -0
  97. package/dist/skills/temps/references/commands/setup.md +25 -0
  98. package/dist/skills/temps/references/commands/skills.md +93 -0
  99. package/dist/skills/temps/references/commands/start.md +21 -0
  100. package/dist/skills/temps/references/commands/status-pages.md +455 -0
  101. package/dist/skills/temps/references/commands/status.md +19 -0
  102. package/dist/skills/temps/references/commands/stop.md +16 -0
  103. package/dist/skills/temps/references/commands/surveys.md +165 -0
  104. package/dist/skills/temps/references/commands/teams.md +143 -0
  105. package/dist/skills/temps/references/commands/templates.md +67 -0
  106. package/dist/skills/temps/references/commands/tokens.md +77 -0
  107. package/dist/skills/temps/references/commands/traces.md +100 -0
  108. package/dist/skills/temps/references/commands/traefik-discovery.md +123 -0
  109. package/dist/skills/temps/references/commands/tunnels.md +139 -0
  110. package/dist/skills/temps/references/commands/up.md +27 -0
  111. package/dist/skills/temps/references/commands/users.md +115 -0
  112. package/dist/skills/temps/references/commands/webhooks.md +171 -0
  113. package/dist/skills/temps/references/commands/whoami.md +15 -0
  114. package/dist/skills/temps/references/commands/workflow.md +44 -0
  115. package/dist/skills/temps/references/commands/workflows.md +216 -0
  116. package/dist/skills/temps/references/observability/analytics.md +146 -0
  117. package/dist/skills/temps/references/observability/error-tracking.md +73 -0
  118. package/dist/skills/temps/references/observability/hygiene.md +112 -0
  119. package/dist/skills/temps/references/observability/logs.md +43 -0
  120. package/dist/skills/temps/references/observability/metrics.md +41 -0
  121. package/dist/skills/temps/references/observability/tracing.md +392 -0
  122. package/dist/skills/temps/references/runtime-contract.md +115 -0
  123. package/dist/skills/temps/references/workflows/platform-operations.md +164 -0
  124. package/dist/skills/temps/scripts/detect_project_capabilities.py +239 -0
  125. package/dist/skills/temps/scripts/generate_command_references.py +144 -0
  126. package/dist/skills/temps/scripts/test_detect_project_capabilities.py +124 -0
  127. package/dist/skills/temps/scripts/test_generate_command_references.py +128 -0
  128. package/dist/skills/temps/scripts/test_validate_skill.py +43 -0
  129. package/dist/skills/temps/scripts/validate_skill.py +97 -0
  130. package/package.json +7 -2
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2024-2026 Temps Contributors
3
+ # SPDX-License-Identifier: MIT OR Apache-2.0
4
+
5
+ """Read-only framework and Temps observability capability detector."""
6
+
7
+ from __future__ import annotations
8
+
9
+ import argparse
10
+ import json
11
+ import os
12
+ import stat
13
+ from pathlib import Path
14
+
15
+
16
+ IGNORED_DIRS = {
17
+ ".agents",
18
+ ".claude",
19
+ ".codex",
20
+ ".git",
21
+ ".next",
22
+ ".nuxt",
23
+ ".svelte-kit",
24
+ ".venv",
25
+ "build",
26
+ "dist",
27
+ "docs",
28
+ "examples",
29
+ "node_modules",
30
+ "skills",
31
+ "target",
32
+ "test",
33
+ "tests",
34
+ "vendor",
35
+ "__tests__",
36
+ }
37
+ MAX_FILE_BYTES = 512_000
38
+ TEXT_SUFFIXES = {
39
+ ".cjs",
40
+ ".go",
41
+ ".html",
42
+ ".js",
43
+ ".jsx",
44
+ ".mjs",
45
+ ".py",
46
+ ".rb",
47
+ ".rs",
48
+ ".toml",
49
+ ".ts",
50
+ ".tsx",
51
+ ".vue",
52
+ ".yaml",
53
+ ".yml",
54
+ }
55
+
56
+ MANIFEST_NAMES = {
57
+ "Cargo.toml",
58
+ "Gemfile",
59
+ "composer.json",
60
+ "go.mod",
61
+ "package.json",
62
+ "pyproject.toml",
63
+ "requirements.txt",
64
+ }
65
+
66
+ PACKAGE_FRAMEWORK_MARKERS = {
67
+ "nextjs": ("\"next\"",),
68
+ "react": ("\"react\"",),
69
+ "vue": ("\"vue\"", "\"nuxt\""),
70
+ "svelte": ("\"svelte\"", "\"@sveltejs/kit\""),
71
+ "node": ("\"express\"", "\"fastify\"", "\"@nestjs/core\""),
72
+ }
73
+
74
+ FILE_FRAMEWORK_MARKERS = {
75
+ "python": ("pyproject.toml", "requirements.txt"),
76
+ "rust": ("Cargo.toml",),
77
+ "go": ("go.mod",),
78
+ "ruby": ("Gemfile",),
79
+ "php": ("composer.json",),
80
+ }
81
+
82
+ CAPABILITY_MARKERS = {
83
+ "analytics": (
84
+ (
85
+ "@temps-sdk/react-analytics",
86
+ "@temps-sdk/analytics-browser",
87
+ "@temps-sdk/vue-analytics",
88
+ "@temps-sdk/svelte-analytics",
89
+ ),
90
+ ("TempsAnalyticsProvider", "TempsAnalytics", "temps-event-name", "data-temps-event"),
91
+ ),
92
+ "error_tracking": (
93
+ ("@sentry/", "sentry-sdk", "sentry =", "github.com/getsentry/sentry-go"),
94
+ ("sentry_sdk.init", "sentry::init", "sentry.Init", "Sentry.init"),
95
+ ),
96
+ "tracing": (
97
+ (
98
+ "@opentelemetry/",
99
+ "opentelemetry-",
100
+ "opentelemetry_",
101
+ "tracing-opentelemetry",
102
+ "go.opentelemetry.io/otel",
103
+ ),
104
+ (
105
+ "TracerProvider",
106
+ "NodeSDK",
107
+ "configure_opentelemetry",
108
+ "install_batch",
109
+ "OTLPSpanExporter",
110
+ "start_as_current_span",
111
+ ),
112
+ ),
113
+ }
114
+
115
+
116
+ def candidate_files(root: Path):
117
+ resolved_root = root.resolve()
118
+ for path in root.rglob("*"):
119
+ if any(part in IGNORED_DIRS for part in path.parts):
120
+ continue
121
+ if not (
122
+ path.name in MANIFEST_NAMES
123
+ or path.suffix in TEXT_SUFFIXES
124
+ or path.suffix == ".csproj"
125
+ ):
126
+ continue
127
+ try:
128
+ relative = path.relative_to(root)
129
+ current = root
130
+ if any((current := current / part).is_symlink() for part in relative.parts):
131
+ continue
132
+ resolved_path = path.resolve(strict=True)
133
+ if not resolved_path.is_relative_to(resolved_root):
134
+ continue
135
+ except (OSError, RuntimeError, ValueError):
136
+ continue
137
+ yield path
138
+
139
+
140
+ def read_candidate(path: Path) -> str | None:
141
+ # Opening a FIFO read-only blocks until a writer connects. Open candidates
142
+ # non-blocking first, then use fstat on the descriptor as the authoritative
143
+ # file-type check before reading any bytes.
144
+ flags = (
145
+ os.O_RDONLY
146
+ | getattr(os, "O_NOFOLLOW", 0)
147
+ | getattr(os, "O_NONBLOCK", 0)
148
+ )
149
+ try:
150
+ descriptor = os.open(path, flags)
151
+ except OSError:
152
+ return None
153
+ try:
154
+ metadata = os.fstat(descriptor)
155
+ if not stat.S_ISREG(metadata.st_mode) or metadata.st_size > MAX_FILE_BYTES:
156
+ return None
157
+ with os.fdopen(descriptor, "rb", closefd=False) as file:
158
+ contents = file.read(MAX_FILE_BYTES + 1)
159
+ if len(contents) > MAX_FILE_BYTES:
160
+ return None
161
+ return contents.decode("utf-8", errors="ignore")
162
+ except OSError:
163
+ return None
164
+ finally:
165
+ os.close(descriptor)
166
+
167
+
168
+ def detect(root: Path) -> dict[str, object]:
169
+ files: list[tuple[Path, str]] = []
170
+ for path in candidate_files(root):
171
+ text = read_candidate(path)
172
+ if text is not None:
173
+ files.append((path, text))
174
+
175
+ frameworks: list[dict[str, str]] = []
176
+ package_manifests = [(path, text) for path, text in files if path.name == "package.json"]
177
+ for name, markers in PACKAGE_FRAMEWORK_MARKERS.items():
178
+ match = next(
179
+ (path for path, text in package_manifests if any(marker in text for marker in markers)),
180
+ None,
181
+ )
182
+ if match:
183
+ frameworks.append({"name": name, "evidence": str(match.relative_to(root))})
184
+ for name, marker_names in FILE_FRAMEWORK_MARKERS.items():
185
+ match = next((path for path, _ in files if path.name in marker_names), None)
186
+ if match:
187
+ frameworks.append({"name": name, "evidence": str(match.relative_to(root))})
188
+ dotnet = next((path for path, _ in files if path.suffix == ".csproj"), None)
189
+ if dotnet:
190
+ frameworks.append({"name": "dotnet", "evidence": str(dotnet.relative_to(root))})
191
+
192
+ capabilities: dict[str, dict[str, object]] = {}
193
+ for name, (dependency_markers, initialization_markers) in CAPABILITY_MARKERS.items():
194
+ dependency_evidence: list[str] = []
195
+ initialization_evidence: list[str] = []
196
+ for path, text in files:
197
+ relative = str(path.relative_to(root))
198
+ if path.name in MANIFEST_NAMES and any(marker in text for marker in dependency_markers):
199
+ dependency_evidence.append(relative)
200
+ if path.name not in MANIFEST_NAMES and any(marker in text for marker in initialization_markers):
201
+ initialization_evidence.append(relative)
202
+ dependency_evidence = sorted(set(dependency_evidence))[:5]
203
+ initialization_evidence = sorted(set(initialization_evidence))[:5]
204
+ if initialization_evidence:
205
+ status = "configured"
206
+ elif dependency_evidence:
207
+ status = "partial"
208
+ else:
209
+ status = "missing"
210
+ capabilities[name] = {
211
+ "status": status,
212
+ "dependency_evidence": dependency_evidence,
213
+ "initialization_evidence": initialization_evidence,
214
+ }
215
+
216
+ return {
217
+ "root": str(root),
218
+ "frameworks": frameworks,
219
+ "capabilities": capabilities,
220
+ "note": (
221
+ "Static evidence only: partial means a dependency exists without initialization; "
222
+ "configured still requires a real signal before claiming the integration works."
223
+ ),
224
+ }
225
+
226
+
227
+ def main() -> int:
228
+ parser = argparse.ArgumentParser(description=__doc__)
229
+ parser.add_argument("--root", type=Path, default=Path.cwd())
230
+ args = parser.parse_args()
231
+ root = args.root.resolve()
232
+ if not root.is_dir():
233
+ parser.error(f"project root is not a directory: {root}")
234
+ print(json.dumps(detect(root), indent=2, sort_keys=True))
235
+ return 0
236
+
237
+
238
+ if __name__ == "__main__":
239
+ raise SystemExit(main())
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2024-2026 Temps Contributors
3
+ # SPDX-License-Identifier: MIT OR Apache-2.0
4
+
5
+ """Split the generated Temps CLI catalog into one reference per command group."""
6
+
7
+ from __future__ import annotations
8
+
9
+ import argparse
10
+ import re
11
+ from pathlib import Path
12
+
13
+
14
+ HEADING = re.compile(r"^## `([^`]+)`(?:.*)$", re.MULTILINE)
15
+ SUBHEADING = re.compile(r"^### `([^`]+)`(?:.*)$", re.MULTILINE)
16
+ FOOTER = re.compile(r"^---\n\n## Examples\n", re.MULTILINE)
17
+ GENERATED_MARKER = (
18
+ "<!-- Generated from skills/temps-cli/references/COMMANDS.md. "
19
+ "Do not edit manually. -->"
20
+ )
21
+
22
+
23
+ def slug(command: str) -> str:
24
+ value = command.lower().replace(":", "-")
25
+ value = re.sub(r"[^a-z0-9]+", "-", value).strip("-")
26
+ if not value:
27
+ raise ValueError(f"cannot create filename for command {command!r}")
28
+ return value
29
+
30
+
31
+ def anchor(title: str) -> str:
32
+ value = title.lower().replace(":", "")
33
+ return re.sub(r"[^a-z0-9 -]", "", value).replace(" ", "-")
34
+
35
+
36
+ def split_catalog(
37
+ source: Path,
38
+ destination: Path,
39
+ *,
40
+ canonical_destination: Path | None = None,
41
+ ) -> list[tuple[str, Path]]:
42
+ if destination.is_symlink():
43
+ raise ValueError(f"destination must not be a symlink: {destination}")
44
+
45
+ destination_is_canonical = (
46
+ canonical_destination is not None
47
+ and destination.resolve() == canonical_destination.resolve()
48
+ )
49
+ if destination.exists() and not destination_is_canonical and any(destination.iterdir()):
50
+ raise ValueError(
51
+ "non-canonical destination must be absent or empty; refusing to overwrite "
52
+ f"files in {destination}"
53
+ )
54
+
55
+ text = source.read_text(encoding="utf-8")
56
+ matches = list(HEADING.finditer(text))
57
+ if not matches:
58
+ raise ValueError(f"no command headings found in {source}")
59
+ footer = FOOTER.search(text)
60
+ catalog_end = footer.start() if footer else len(text)
61
+
62
+ destination.mkdir(parents=True, exist_ok=True)
63
+ generated: list[tuple[str, Path]] = []
64
+ expected_names: set[str] = {"INDEX.md"}
65
+
66
+ for index, match in enumerate(matches):
67
+ command = match.group(1)
68
+ end = matches[index + 1].start() if index + 1 < len(matches) else catalog_end
69
+ body = text[match.start() : end].rstrip() + "\n"
70
+ filename = f"{slug(command)}.md"
71
+ expected_names.add(filename)
72
+ output = destination / filename
73
+ if output.is_symlink():
74
+ raise ValueError(f"generated reference must not be a symlink: {output}")
75
+ header = (
76
+ f"{GENERATED_MARKER}\n\n"
77
+ f"# `{command}` command reference\n\n"
78
+ "Apply [the CLI runtime and safety contract](../cli-runtime.md) "
79
+ "before executing a command. Runtime `--help` is authoritative.\n\n"
80
+ )
81
+ subcommands = [item.group(1) for item in SUBHEADING.finditer(body)]
82
+ if (header + body).count("\n") + 1 > 300 and subcommands:
83
+ header += "## Contents\n\n"
84
+ header += "\n".join(
85
+ f"- [`{subcommand}`](#{anchor(subcommand)})" for subcommand in subcommands
86
+ )
87
+ header += "\n\n"
88
+ output.write_text(header + body, encoding="utf-8")
89
+ generated.append((command, output))
90
+
91
+ if destination_is_canonical:
92
+ for old_file in destination.glob("*.md"):
93
+ if old_file.name in expected_names or old_file.name == "INDEX.md":
94
+ continue
95
+ if old_file.is_symlink():
96
+ raise ValueError(f"generated reference must not be a symlink: {old_file}")
97
+ if old_file.read_text(encoding="utf-8").startswith(GENERATED_MARKER):
98
+ old_file.unlink()
99
+
100
+ index_lines = [
101
+ "<!-- Generated by scripts/generate_command_references.py. -->",
102
+ "",
103
+ "# Temps CLI command groups",
104
+ "",
105
+ "Read one command-group reference at a time. Use runtime `--help` when",
106
+ "syntax may have changed.",
107
+ "",
108
+ ]
109
+ for command, output in generated:
110
+ index_lines.append(f"- [`{command}`]({output.name})")
111
+ index_lines.append("")
112
+ index_output = destination / "INDEX.md"
113
+ if index_output.is_symlink():
114
+ raise ValueError(f"generated index must not be a symlink: {index_output}")
115
+ index_output.write_text("\n".join(index_lines), encoding="utf-8")
116
+ return generated
117
+
118
+
119
+ def main() -> int:
120
+ skill_root = Path(__file__).resolve().parents[1]
121
+ canonical_destination = skill_root / "references" / "commands"
122
+ parser = argparse.ArgumentParser(description=__doc__)
123
+ parser.add_argument(
124
+ "--source",
125
+ type=Path,
126
+ default=skill_root.parent / "temps-cli" / "references" / "COMMANDS.md",
127
+ )
128
+ parser.add_argument(
129
+ "--destination",
130
+ type=Path,
131
+ default=canonical_destination,
132
+ )
133
+ args = parser.parse_args()
134
+ generated = split_catalog(
135
+ args.source.resolve(),
136
+ args.destination,
137
+ canonical_destination=canonical_destination,
138
+ )
139
+ print(f"generated {len(generated)} command references in {args.destination}")
140
+ return 0
141
+
142
+
143
+ if __name__ == "__main__":
144
+ raise SystemExit(main())
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2024-2026 Temps Contributors
3
+ # SPDX-License-Identifier: MIT OR Apache-2.0
4
+
5
+ """Regression tests for the read-only capability detector."""
6
+
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ import tempfile
11
+ import threading
12
+ import unittest
13
+ from pathlib import Path
14
+ from typing import Any, cast
15
+
16
+ from detect_project_capabilities import detect
17
+
18
+
19
+ class CapabilityDetectorTests(unittest.TestCase):
20
+ def test_dependency_without_initialization_is_partial(self) -> None:
21
+ with tempfile.TemporaryDirectory() as directory:
22
+ root = Path(directory)
23
+ (root / "package.json").write_text(
24
+ '{"dependencies":{"@sentry/nextjs":"1.0.0"}}', encoding="utf-8"
25
+ )
26
+
27
+ result = detect(root)
28
+
29
+ self.assertEqual(result["capabilities"]["error_tracking"]["status"], "partial")
30
+
31
+ def test_source_initialization_is_configured(self) -> None:
32
+ with tempfile.TemporaryDirectory() as directory:
33
+ root = Path(directory)
34
+ (root / "package.json").write_text(
35
+ '{"dependencies":{"@opentelemetry/sdk-node":"1.0.0"}}', encoding="utf-8"
36
+ )
37
+ (root / "instrumentation.ts").write_text(
38
+ "const sdk = new NodeSDK({}); sdk.start();", encoding="utf-8"
39
+ )
40
+
41
+ result = detect(root)
42
+
43
+ self.assertEqual(result["capabilities"]["tracing"]["status"], "configured")
44
+
45
+ def test_environment_placeholder_is_not_configuration(self) -> None:
46
+ with tempfile.TemporaryDirectory() as directory:
47
+ root = Path(directory)
48
+ (root / "compose.yaml").write_text(
49
+ "environment:\n SENTRY_DSN: ${SENTRY_DSN}\n OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_ENDPOINT}\n",
50
+ encoding="utf-8",
51
+ )
52
+
53
+ result = detect(root)
54
+
55
+ self.assertEqual(result["capabilities"]["error_tracking"]["status"], "missing")
56
+ self.assertEqual(result["capabilities"]["tracing"]["status"], "missing")
57
+
58
+ def test_dotnet_project_is_detected_by_suffix(self) -> None:
59
+ with tempfile.TemporaryDirectory() as directory:
60
+ root = Path(directory)
61
+ (root / "Example.csproj").write_text("<Project />", encoding="utf-8")
62
+
63
+ result = detect(root)
64
+
65
+ self.assertIn("dotnet", [item["name"] for item in result["frameworks"]])
66
+
67
+ def test_symlinked_file_outside_root_is_not_read(self) -> None:
68
+ with tempfile.TemporaryDirectory() as directory:
69
+ workspace = Path(directory)
70
+ root = workspace / "project"
71
+ root.mkdir()
72
+ outside = workspace / "outside.ts"
73
+ outside.write_text("Sentry.init({});", encoding="utf-8")
74
+ (root / "instrumentation.ts").symlink_to(outside)
75
+
76
+ result = detect(root)
77
+
78
+ self.assertEqual(result["capabilities"]["error_tracking"]["status"], "missing")
79
+ self.assertEqual(
80
+ result["capabilities"]["error_tracking"]["initialization_evidence"],
81
+ [],
82
+ )
83
+
84
+ def test_symlinked_directory_outside_root_is_not_read(self) -> None:
85
+ with tempfile.TemporaryDirectory() as directory:
86
+ workspace = Path(directory)
87
+ root = workspace / "project"
88
+ root.mkdir()
89
+ outside = workspace / "outside"
90
+ outside.mkdir()
91
+ (outside / "package.json").write_text(
92
+ '{"dependencies":{"@sentry/nextjs":"1.0.0"}}', encoding="utf-8"
93
+ )
94
+ (root / "linked").symlink_to(outside, target_is_directory=True)
95
+
96
+ result = detect(root)
97
+
98
+ self.assertEqual(result["capabilities"]["error_tracking"]["status"], "missing")
99
+
100
+ @unittest.skipUnless(hasattr(os, "mkfifo"), "FIFO files are not supported")
101
+ def test_named_pipe_is_ignored_without_blocking(self) -> None:
102
+ with tempfile.TemporaryDirectory() as directory:
103
+ root = Path(directory)
104
+ os.mkfifo(root / "package.json")
105
+ outcome: dict[str, object] = {}
106
+
107
+ def run_detection() -> None:
108
+ outcome["result"] = detect(root)
109
+
110
+ detector = threading.Thread(target=run_detection, daemon=True)
111
+ detector.start()
112
+ detector.join(timeout=1)
113
+
114
+ self.assertFalse(detector.is_alive(), "capability detection blocked on a FIFO")
115
+ result = cast(dict[str, Any], outcome["result"])
116
+ self.assertIsInstance(result, dict)
117
+ self.assertEqual(
118
+ result["capabilities"]["error_tracking"]["status"],
119
+ "missing",
120
+ )
121
+
122
+
123
+ if __name__ == "__main__":
124
+ unittest.main()
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2024-2026 Temps Contributors
3
+ # SPDX-License-Identifier: MIT OR Apache-2.0
4
+
5
+ """Regression tests for the command-reference splitter."""
6
+
7
+ from __future__ import annotations
8
+
9
+ import tempfile
10
+ import unittest
11
+ from pathlib import Path
12
+
13
+ from generate_command_references import split_catalog
14
+
15
+
16
+ class CommandReferenceGeneratorTests(unittest.TestCase):
17
+ def test_splits_groups_and_excludes_monolithic_footer(self) -> None:
18
+ with tempfile.TemporaryDirectory() as directory:
19
+ root = Path(directory)
20
+ source = root / "COMMANDS.md"
21
+ destination = root / "commands"
22
+ source.write_text(
23
+ "# CLI\n\n## `alpha`\n\nAlpha.\n\n## `beta`\n\nBeta.\n\n"
24
+ "---\n\n## Examples\n\nNot a command group.\n",
25
+ encoding="utf-8",
26
+ )
27
+
28
+ generated = split_catalog(source, destination)
29
+
30
+ self.assertEqual([command for command, _ in generated], ["alpha", "beta"])
31
+ self.assertNotIn("## Examples", (destination / "beta.md").read_text(encoding="utf-8"))
32
+ self.assertIn("[`alpha`](alpha.md)", (destination / "INDEX.md").read_text(encoding="utf-8"))
33
+
34
+ def test_adds_contents_to_a_long_group(self) -> None:
35
+ with tempfile.TemporaryDirectory() as directory:
36
+ root = Path(directory)
37
+ source = root / "COMMANDS.md"
38
+ destination = root / "commands"
39
+ body = "\n".join(f"line {number}" for number in range(301))
40
+ source.write_text(
41
+ f"# CLI\n\n## `services`\n\n### `services list`\n\n{body}\n",
42
+ encoding="utf-8",
43
+ )
44
+
45
+ split_catalog(source, destination)
46
+
47
+ output = (destination / "services.md").read_text(encoding="utf-8")
48
+ self.assertIn("## Contents", output)
49
+ self.assertIn("[`services list`](#services-list)", output)
50
+
51
+ def test_rejects_nonempty_noncanonical_destination(self) -> None:
52
+ with tempfile.TemporaryDirectory() as directory:
53
+ root = Path(directory)
54
+ source = root / "COMMANDS.md"
55
+ destination = root / "docs"
56
+ destination.mkdir()
57
+ (destination / "handwritten.md").write_text("keep me", encoding="utf-8")
58
+ source.write_text("# CLI\n\n## `alpha`\n\nAlpha.\n", encoding="utf-8")
59
+
60
+ with self.assertRaisesRegex(ValueError, "refusing to overwrite"):
61
+ split_catalog(source, destination)
62
+
63
+ self.assertEqual(
64
+ (destination / "handwritten.md").read_text(encoding="utf-8"),
65
+ "keep me",
66
+ )
67
+
68
+ def test_rejects_symlink_destination(self) -> None:
69
+ with tempfile.TemporaryDirectory() as directory:
70
+ root = Path(directory)
71
+ source = root / "COMMANDS.md"
72
+ target = root / "target"
73
+ target.mkdir()
74
+ destination = root / "commands"
75
+ destination.symlink_to(target, target_is_directory=True)
76
+ source.write_text("# CLI\n\n## `alpha`\n\nAlpha.\n", encoding="utf-8")
77
+
78
+ with self.assertRaisesRegex(ValueError, "must not be a symlink"):
79
+ split_catalog(source, destination)
80
+
81
+ def test_canonical_cleanup_only_removes_generated_files(self) -> None:
82
+ with tempfile.TemporaryDirectory() as directory:
83
+ root = Path(directory)
84
+ source = root / "COMMANDS.md"
85
+ destination = root / "commands"
86
+ destination.mkdir()
87
+ stale = destination / "stale.md"
88
+ stale.write_text(
89
+ "<!-- Generated from skills/temps-cli/references/COMMANDS.md. "
90
+ "Do not edit manually. -->\n\nstale\n",
91
+ encoding="utf-8",
92
+ )
93
+ handwritten = destination / "handwritten.md"
94
+ handwritten.write_text("keep me", encoding="utf-8")
95
+ source.write_text("# CLI\n\n## `alpha`\n\nAlpha.\n", encoding="utf-8")
96
+
97
+ split_catalog(
98
+ source,
99
+ destination,
100
+ canonical_destination=destination,
101
+ )
102
+
103
+ self.assertFalse(stale.exists())
104
+ self.assertEqual(handwritten.read_text(encoding="utf-8"), "keep me")
105
+
106
+ def test_rejects_symlinked_generated_file(self) -> None:
107
+ with tempfile.TemporaryDirectory() as directory:
108
+ root = Path(directory)
109
+ source = root / "COMMANDS.md"
110
+ destination = root / "commands"
111
+ destination.mkdir()
112
+ outside = root / "outside.md"
113
+ outside.write_text("keep me", encoding="utf-8")
114
+ (destination / "alpha.md").symlink_to(outside)
115
+ source.write_text("# CLI\n\n## `alpha`\n\nAlpha.\n", encoding="utf-8")
116
+
117
+ with self.assertRaisesRegex(ValueError, "must not be a symlink"):
118
+ split_catalog(
119
+ source,
120
+ destination,
121
+ canonical_destination=destination,
122
+ )
123
+
124
+ self.assertEqual(outside.read_text(encoding="utf-8"), "keep me")
125
+
126
+
127
+ if __name__ == "__main__":
128
+ unittest.main()
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2024-2026 Temps Contributors
3
+ # SPDX-License-Identifier: MIT OR Apache-2.0
4
+
5
+ import tempfile
6
+ import unittest
7
+ from pathlib import Path
8
+ from validate_skill import CLI_SKILLS, check_cli_references
9
+
10
+
11
+ class CliReferenceTests(unittest.TestCase):
12
+ def test_latest_and_source_attribution_are_allowed_but_fixed_invocations_fail(self):
13
+ with tempfile.TemporaryDirectory() as directory:
14
+ root = Path(directory)
15
+ for skill in CLI_SKILLS:
16
+ (root / skill).mkdir()
17
+ (root / skill / 'SKILL.md').write_text(
18
+ 'Generated from: @temps-sdk/cli@1.2.3\nbunx @temps-sdk/cli@latest --help')
19
+ self.assertEqual(check_cli_references(root), [])
20
+ (root / 'temps/SKILL.md').write_text('npx @temps-sdk/cli@1.2.3 --help')
21
+ self.assertEqual(len(check_cli_references(root)), 1)
22
+
23
+ def test_beta_is_allowed_but_mixing_channels_fails(self):
24
+ with tempfile.TemporaryDirectory() as directory:
25
+ root = Path(directory)
26
+ for skill in CLI_SKILLS:
27
+ (root / skill).mkdir()
28
+ (root / skill / 'SKILL.md').write_text(
29
+ 'Generated from: @temps-sdk/cli@0.2.0-beta.1\nbunx @temps-sdk/cli@beta --help')
30
+ self.assertEqual(check_cli_references(root), [])
31
+ (root / 'temps/SKILL.md').write_text('npx @temps-sdk/cli@latest --help')
32
+ errors = check_cli_references(root)
33
+ self.assertEqual(len(errors), 1)
34
+ self.assertIn('mix channels', errors[0])
35
+ (root / 'temps/SKILL.md').write_text('npx @temps-sdk/cli@beta.1 --help')
36
+ self.assertIn('stale CLI invocation pin', check_cli_references(root)[0])
37
+
38
+ def test_checked_in_skills(self):
39
+ self.assertEqual(check_cli_references(Path(__file__).resolve().parents[2]), [])
40
+
41
+
42
+ if __name__ == '__main__':
43
+ unittest.main()