cc4pm 1.8.0

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 (108) hide show
  1. package/.claude-plugin/README.md +17 -0
  2. package/.claude-plugin/plugin.json +25 -0
  3. package/LICENSE +21 -0
  4. package/README.md +157 -0
  5. package/README.zh-CN.md +134 -0
  6. package/contexts/dev.md +20 -0
  7. package/contexts/research.md +26 -0
  8. package/contexts/review.md +22 -0
  9. package/examples/CLAUDE.md +100 -0
  10. package/examples/statusline.json +19 -0
  11. package/examples/user-CLAUDE.md +109 -0
  12. package/install.sh +17 -0
  13. package/manifests/install-components.json +173 -0
  14. package/manifests/install-modules.json +335 -0
  15. package/manifests/install-profiles.json +75 -0
  16. package/package.json +117 -0
  17. package/schemas/ecc-install-config.schema.json +58 -0
  18. package/schemas/hooks.schema.json +197 -0
  19. package/schemas/install-components.schema.json +56 -0
  20. package/schemas/install-modules.schema.json +105 -0
  21. package/schemas/install-profiles.schema.json +45 -0
  22. package/schemas/install-state.schema.json +210 -0
  23. package/schemas/package-manager.schema.json +23 -0
  24. package/schemas/plugin.schema.json +58 -0
  25. package/scripts/ci/catalog.js +83 -0
  26. package/scripts/ci/validate-agents.js +81 -0
  27. package/scripts/ci/validate-commands.js +135 -0
  28. package/scripts/ci/validate-hooks.js +239 -0
  29. package/scripts/ci/validate-install-manifests.js +211 -0
  30. package/scripts/ci/validate-no-personal-paths.js +63 -0
  31. package/scripts/ci/validate-rules.js +81 -0
  32. package/scripts/ci/validate-skills.js +54 -0
  33. package/scripts/claw.js +468 -0
  34. package/scripts/doctor.js +110 -0
  35. package/scripts/ecc.js +194 -0
  36. package/scripts/hooks/auto-tmux-dev.js +88 -0
  37. package/scripts/hooks/check-console-log.js +71 -0
  38. package/scripts/hooks/check-hook-enabled.js +12 -0
  39. package/scripts/hooks/cost-tracker.js +78 -0
  40. package/scripts/hooks/doc-file-warning.js +63 -0
  41. package/scripts/hooks/evaluate-session.js +100 -0
  42. package/scripts/hooks/insaits-security-monitor.py +269 -0
  43. package/scripts/hooks/insaits-security-wrapper.js +88 -0
  44. package/scripts/hooks/post-bash-build-complete.js +27 -0
  45. package/scripts/hooks/post-bash-pr-created.js +36 -0
  46. package/scripts/hooks/post-edit-console-warn.js +54 -0
  47. package/scripts/hooks/post-edit-format.js +109 -0
  48. package/scripts/hooks/post-edit-typecheck.js +96 -0
  49. package/scripts/hooks/pre-bash-dev-server-block.js +187 -0
  50. package/scripts/hooks/pre-bash-git-push-reminder.js +28 -0
  51. package/scripts/hooks/pre-bash-tmux-reminder.js +33 -0
  52. package/scripts/hooks/pre-compact.js +48 -0
  53. package/scripts/hooks/pre-write-doc-warn.js +9 -0
  54. package/scripts/hooks/quality-gate.js +168 -0
  55. package/scripts/hooks/run-with-flags-shell.sh +32 -0
  56. package/scripts/hooks/run-with-flags.js +120 -0
  57. package/scripts/hooks/session-end-marker.js +15 -0
  58. package/scripts/hooks/session-end.js +299 -0
  59. package/scripts/hooks/session-start.js +97 -0
  60. package/scripts/hooks/suggest-compact.js +80 -0
  61. package/scripts/install-apply.js +137 -0
  62. package/scripts/install-plan.js +254 -0
  63. package/scripts/lib/hook-flags.js +74 -0
  64. package/scripts/lib/install/apply.js +23 -0
  65. package/scripts/lib/install/config.js +82 -0
  66. package/scripts/lib/install/request.js +113 -0
  67. package/scripts/lib/install/runtime.js +42 -0
  68. package/scripts/lib/install-executor.js +605 -0
  69. package/scripts/lib/install-lifecycle.js +763 -0
  70. package/scripts/lib/install-manifests.js +305 -0
  71. package/scripts/lib/install-state.js +120 -0
  72. package/scripts/lib/install-targets/antigravity-project.js +9 -0
  73. package/scripts/lib/install-targets/claude-home.js +10 -0
  74. package/scripts/lib/install-targets/codex-home.js +10 -0
  75. package/scripts/lib/install-targets/cursor-project.js +10 -0
  76. package/scripts/lib/install-targets/helpers.js +89 -0
  77. package/scripts/lib/install-targets/opencode-home.js +10 -0
  78. package/scripts/lib/install-targets/registry.js +64 -0
  79. package/scripts/lib/orchestration-session.js +299 -0
  80. package/scripts/lib/package-manager.d.ts +119 -0
  81. package/scripts/lib/package-manager.js +431 -0
  82. package/scripts/lib/project-detect.js +428 -0
  83. package/scripts/lib/resolve-formatter.js +185 -0
  84. package/scripts/lib/session-adapters/canonical-session.js +138 -0
  85. package/scripts/lib/session-adapters/claude-history.js +149 -0
  86. package/scripts/lib/session-adapters/dmux-tmux.js +80 -0
  87. package/scripts/lib/session-adapters/registry.js +111 -0
  88. package/scripts/lib/session-aliases.d.ts +136 -0
  89. package/scripts/lib/session-aliases.js +481 -0
  90. package/scripts/lib/session-manager.d.ts +131 -0
  91. package/scripts/lib/session-manager.js +464 -0
  92. package/scripts/lib/shell-split.js +86 -0
  93. package/scripts/lib/skill-improvement/amendify.js +89 -0
  94. package/scripts/lib/skill-improvement/evaluate.js +59 -0
  95. package/scripts/lib/skill-improvement/health.js +118 -0
  96. package/scripts/lib/skill-improvement/observations.js +108 -0
  97. package/scripts/lib/tmux-worktree-orchestrator.js +491 -0
  98. package/scripts/lib/utils.d.ts +183 -0
  99. package/scripts/lib/utils.js +543 -0
  100. package/scripts/list-installed.js +90 -0
  101. package/scripts/orchestrate-codex-worker.sh +92 -0
  102. package/scripts/orchestrate-worktrees.js +108 -0
  103. package/scripts/orchestration-status.js +62 -0
  104. package/scripts/repair.js +97 -0
  105. package/scripts/session-inspect.js +150 -0
  106. package/scripts/setup-package-manager.js +204 -0
  107. package/scripts/skill-create-output.js +244 -0
  108. package/scripts/uninstall.js +96 -0
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Cross-platform utility functions for Claude Code hooks and scripts.
3
+ * Works on Windows, macOS, and Linux.
4
+ */
5
+
6
+ import type { ExecSyncOptions } from 'child_process';
7
+
8
+ // Platform detection
9
+ export const isWindows: boolean;
10
+ export const isMacOS: boolean;
11
+ export const isLinux: boolean;
12
+
13
+ // --- Directories ---
14
+
15
+ /** Get the user's home directory (cross-platform) */
16
+ export function getHomeDir(): string;
17
+
18
+ /** Get the Claude config directory (~/.claude) */
19
+ export function getClaudeDir(): string;
20
+
21
+ /** Get the sessions directory (~/.claude/sessions) */
22
+ export function getSessionsDir(): string;
23
+
24
+ /** Get the learned skills directory (~/.claude/skills/learned) */
25
+ export function getLearnedSkillsDir(): string;
26
+
27
+ /** Get the temp directory (cross-platform) */
28
+ export function getTempDir(): string;
29
+
30
+ /**
31
+ * Ensure a directory exists, creating it recursively if needed.
32
+ * Handles EEXIST race conditions from concurrent creation.
33
+ * @throws If directory cannot be created (e.g., permission denied)
34
+ */
35
+ export function ensureDir(dirPath: string): string;
36
+
37
+ // --- Date/Time ---
38
+
39
+ /** Get current date in YYYY-MM-DD format */
40
+ export function getDateString(): string;
41
+
42
+ /** Get current time in HH:MM format */
43
+ export function getTimeString(): string;
44
+
45
+ /** Get current datetime in YYYY-MM-DD HH:MM:SS format */
46
+ export function getDateTimeString(): string;
47
+
48
+ // --- Session/Project ---
49
+
50
+ /**
51
+ * Get short session ID from CLAUDE_SESSION_ID environment variable.
52
+ * Returns last 8 characters, falls back to project name then the provided fallback.
53
+ */
54
+ export function getSessionIdShort(fallback?: string): string;
55
+
56
+ /** Get the git repository name from the current working directory */
57
+ export function getGitRepoName(): string | null;
58
+
59
+ /** Get project name from git repo or current directory basename */
60
+ export function getProjectName(): string | null;
61
+
62
+ // --- File operations ---
63
+
64
+ export interface FileMatch {
65
+ /** Absolute path to the matching file */
66
+ path: string;
67
+ /** Modification time in milliseconds since epoch */
68
+ mtime: number;
69
+ }
70
+
71
+ export interface FindFilesOptions {
72
+ /** Maximum age in days. Only files modified within this many days are returned. */
73
+ maxAge?: number | null;
74
+ /** Whether to search subdirectories recursively */
75
+ recursive?: boolean;
76
+ }
77
+
78
+ /**
79
+ * Find files matching a glob-like pattern in a directory.
80
+ * Supports `*` (any chars), `?` (single char), and `.` (literal dot).
81
+ * Results are sorted by modification time (newest first).
82
+ */
83
+ export function findFiles(dir: string, pattern: string, options?: FindFilesOptions): FileMatch[];
84
+
85
+ /**
86
+ * Read a text file safely. Returns null if the file doesn't exist or can't be read.
87
+ */
88
+ export function readFile(filePath: string): string | null;
89
+
90
+ /** Write a text file, creating parent directories if needed */
91
+ export function writeFile(filePath: string, content: string): void;
92
+
93
+ /** Append to a text file, creating parent directories if needed */
94
+ export function appendFile(filePath: string, content: string): void;
95
+
96
+ export interface ReplaceInFileOptions {
97
+ /**
98
+ * When true and search is a string, replaces ALL occurrences (uses String.replaceAll).
99
+ * Ignored for RegExp patterns — use the `g` flag instead.
100
+ */
101
+ all?: boolean;
102
+ }
103
+
104
+ /**
105
+ * Replace text in a file (cross-platform sed alternative).
106
+ * @returns true if the file was found and updated, false if file not found
107
+ */
108
+ export function replaceInFile(filePath: string, search: string | RegExp, replace: string, options?: ReplaceInFileOptions): boolean;
109
+
110
+ /**
111
+ * Count occurrences of a pattern in a file.
112
+ * The global flag is enforced automatically for correct counting.
113
+ */
114
+ export function countInFile(filePath: string, pattern: string | RegExp): number;
115
+
116
+ export interface GrepMatch {
117
+ /** 1-based line number */
118
+ lineNumber: number;
119
+ /** Full content of the matching line */
120
+ content: string;
121
+ }
122
+
123
+ /** Search for a pattern in a file and return matching lines with line numbers */
124
+ export function grepFile(filePath: string, pattern: string | RegExp): GrepMatch[];
125
+
126
+ // --- Hook I/O ---
127
+
128
+ export interface ReadStdinJsonOptions {
129
+ /**
130
+ * Timeout in milliseconds. Prevents hooks from hanging indefinitely
131
+ * if stdin never closes. Default: 5000
132
+ */
133
+ timeoutMs?: number;
134
+ /**
135
+ * Maximum stdin data size in bytes. Prevents unbounded memory growth.
136
+ * Default: 1048576 (1MB)
137
+ */
138
+ maxSize?: number;
139
+ }
140
+
141
+ /**
142
+ * Read JSON from stdin (for hook input).
143
+ * Returns an empty object if stdin is empty, times out, or contains invalid JSON.
144
+ * Never rejects — safe to use without try-catch in hooks.
145
+ */
146
+ export function readStdinJson(options?: ReadStdinJsonOptions): Promise<Record<string, unknown>>;
147
+
148
+ /** Log a message to stderr (visible to user in Claude Code terminal) */
149
+ export function log(message: string): void;
150
+
151
+ /** Output data to stdout (returned to Claude's context) */
152
+ export function output(data: string | Record<string, unknown>): void;
153
+
154
+ // --- System ---
155
+
156
+ /**
157
+ * Check if a command exists in PATH.
158
+ * Only allows alphanumeric, dash, underscore, and dot characters.
159
+ * WARNING: Spawns a child process (where.exe on Windows, which on Unix).
160
+ */
161
+ export function commandExists(cmd: string): boolean;
162
+
163
+ export interface CommandResult {
164
+ success: boolean;
165
+ /** Trimmed stdout on success, stderr or error message on failure */
166
+ output: string;
167
+ }
168
+
169
+ /**
170
+ * Run a shell command and return the output.
171
+ * SECURITY: Only use with trusted, hardcoded commands.
172
+ * Never pass user-controlled input directly.
173
+ */
174
+ export function runCommand(cmd: string, options?: ExecSyncOptions): CommandResult;
175
+
176
+ /** Check if the current directory is inside a git repository */
177
+ export function isGitRepo(): boolean;
178
+
179
+ /**
180
+ * Get git modified files (staged + unstaged), optionally filtered by regex patterns.
181
+ * Invalid regex patterns are silently skipped.
182
+ */
183
+ export function getGitModifiedFiles(patterns?: string[]): string[];