@soleri/cli 1.1.0 → 1.3.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.
- package/README.md +30 -1
- package/dist/commands/create.js +42 -4
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/hooks.js +40 -11
- package/dist/commands/hooks.js.map +1 -1
- package/dist/hook-packs/a11y/hookify.focus-ring-required.local.md +1 -0
- package/dist/hook-packs/a11y/hookify.semantic-html.local.md +1 -0
- package/dist/hook-packs/a11y/hookify.ux-touch-targets.local.md +1 -0
- package/dist/hook-packs/a11y/manifest.json +1 -0
- package/dist/hook-packs/clean-commits/hookify.no-ai-attribution.local.md +1 -0
- package/dist/hook-packs/clean-commits/manifest.json +1 -0
- package/dist/hook-packs/css-discipline/hookify.no-important.local.md +1 -0
- package/dist/hook-packs/css-discipline/hookify.no-inline-styles.local.md +1 -0
- package/dist/hook-packs/css-discipline/manifest.json +1 -0
- package/dist/hook-packs/full/manifest.json +1 -0
- package/dist/hook-packs/installer.d.ts +18 -5
- package/dist/hook-packs/installer.js +29 -10
- package/dist/hook-packs/installer.js.map +1 -1
- package/dist/hook-packs/installer.ts +42 -10
- package/dist/hook-packs/registry.d.ts +6 -2
- package/dist/hook-packs/registry.js +46 -13
- package/dist/hook-packs/registry.js.map +1 -1
- package/dist/hook-packs/registry.ts +49 -13
- package/dist/hook-packs/typescript-safety/hookify.no-any-types.local.md +1 -0
- package/dist/hook-packs/typescript-safety/hookify.no-console-log.local.md +1 -0
- package/dist/hook-packs/typescript-safety/manifest.json +1 -0
- package/dist/utils/checks.d.ts +1 -0
- package/dist/utils/checks.js +17 -0
- package/dist/utils/checks.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/create.ts +45 -3
- package/src/commands/hooks.ts +54 -11
- package/src/hook-packs/a11y/hookify.focus-ring-required.local.md +1 -0
- package/src/hook-packs/a11y/hookify.semantic-html.local.md +1 -0
- package/src/hook-packs/a11y/hookify.ux-touch-targets.local.md +1 -0
- package/src/hook-packs/a11y/manifest.json +1 -0
- package/src/hook-packs/clean-commits/hookify.no-ai-attribution.local.md +1 -0
- package/src/hook-packs/clean-commits/manifest.json +1 -0
- package/src/hook-packs/css-discipline/hookify.no-important.local.md +1 -0
- package/src/hook-packs/css-discipline/hookify.no-inline-styles.local.md +1 -0
- package/src/hook-packs/css-discipline/manifest.json +1 -0
- package/src/hook-packs/full/manifest.json +1 -0
- package/src/hook-packs/installer.ts +42 -10
- package/src/hook-packs/registry.ts +49 -13
- package/src/hook-packs/typescript-safety/hookify.no-any-types.local.md +1 -0
- package/src/hook-packs/typescript-safety/hookify.no-console-log.local.md +1 -0
- package/src/hook-packs/typescript-safety/manifest.json +1 -0
- package/src/utils/checks.ts +18 -0
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hook pack installer — copies hookify files to ~/.claude/
|
|
2
|
+
* Hook pack installer — copies hookify files to ~/.claude/ (global) or project .claude/ (local).
|
|
3
3
|
*/
|
|
4
|
-
import { existsSync, copyFileSync, unlinkSync, mkdirSync } from 'node:fs';
|
|
4
|
+
import { existsSync, copyFileSync, unlinkSync, mkdirSync, readFileSync } from 'node:fs';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { homedir } from 'node:os';
|
|
7
7
|
import { getPack } from './registry.js';
|
|
8
8
|
|
|
9
|
+
/** Resolve the target .claude/ directory. */
|
|
10
|
+
function resolveClaudeDir(projectDir?: string): string {
|
|
11
|
+
if (projectDir) return join(projectDir, '.claude');
|
|
12
|
+
return join(homedir(), '.claude');
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
/**
|
|
10
16
|
* Resolve all hookify file paths for a pack, handling composed packs.
|
|
11
17
|
* Returns a map of hook name → source file path.
|
|
@@ -38,16 +44,19 @@ function resolveHookFiles(packName: string): Map<string, string> {
|
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
/**
|
|
41
|
-
* Install a hook pack
|
|
47
|
+
* Install a hook pack to ~/.claude/ (default) or project .claude/ (--project).
|
|
42
48
|
* Skips files that already exist (idempotent).
|
|
43
49
|
*/
|
|
44
|
-
export function installPack(
|
|
50
|
+
export function installPack(
|
|
51
|
+
packName: string,
|
|
52
|
+
options?: { projectDir?: string },
|
|
53
|
+
): { installed: string[]; skipped: string[] } {
|
|
45
54
|
const pack = getPack(packName);
|
|
46
55
|
if (!pack) {
|
|
47
56
|
throw new Error(`Unknown hook pack: "${packName}"`);
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
const claudeDir =
|
|
59
|
+
const claudeDir = resolveClaudeDir(options?.projectDir);
|
|
51
60
|
mkdirSync(claudeDir, { recursive: true });
|
|
52
61
|
|
|
53
62
|
const hookFiles = resolveHookFiles(packName);
|
|
@@ -68,15 +77,18 @@ export function installPack(packName: string): { installed: string[]; skipped: s
|
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
/**
|
|
71
|
-
* Remove a hook pack's files from
|
|
80
|
+
* Remove a hook pack's files from target directory.
|
|
72
81
|
*/
|
|
73
|
-
export function removePack(
|
|
82
|
+
export function removePack(
|
|
83
|
+
packName: string,
|
|
84
|
+
options?: { projectDir?: string },
|
|
85
|
+
): { removed: string[] } {
|
|
74
86
|
const pack = getPack(packName);
|
|
75
87
|
if (!pack) {
|
|
76
88
|
throw new Error(`Unknown hook pack: "${packName}"`);
|
|
77
89
|
}
|
|
78
90
|
|
|
79
|
-
const claudeDir =
|
|
91
|
+
const claudeDir = resolveClaudeDir(options?.projectDir);
|
|
80
92
|
const removed: string[] = [];
|
|
81
93
|
|
|
82
94
|
for (const hook of pack.manifest.hooks) {
|
|
@@ -94,11 +106,14 @@ export function removePack(packName: string): { removed: string[] } {
|
|
|
94
106
|
* Check if a pack is installed.
|
|
95
107
|
* Returns true (all hooks present), false (none present), or 'partial'.
|
|
96
108
|
*/
|
|
97
|
-
export function isPackInstalled(
|
|
109
|
+
export function isPackInstalled(
|
|
110
|
+
packName: string,
|
|
111
|
+
options?: { projectDir?: string },
|
|
112
|
+
): boolean | 'partial' {
|
|
98
113
|
const pack = getPack(packName);
|
|
99
114
|
if (!pack) return false;
|
|
100
115
|
|
|
101
|
-
const claudeDir =
|
|
116
|
+
const claudeDir = resolveClaudeDir(options?.projectDir);
|
|
102
117
|
let present = 0;
|
|
103
118
|
|
|
104
119
|
for (const hook of pack.manifest.hooks) {
|
|
@@ -111,3 +126,20 @@ export function isPackInstalled(packName: string): boolean | 'partial' {
|
|
|
111
126
|
if (present === pack.manifest.hooks.length) return true;
|
|
112
127
|
return 'partial';
|
|
113
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Get the installed version of a hook from its file header.
|
|
132
|
+
* Returns null if no version found or file doesn't exist.
|
|
133
|
+
*/
|
|
134
|
+
export function getInstalledHookVersion(
|
|
135
|
+
hook: string,
|
|
136
|
+
options?: { projectDir?: string },
|
|
137
|
+
): string | null {
|
|
138
|
+
const claudeDir = resolveClaudeDir(options?.projectDir);
|
|
139
|
+
const filePath = join(claudeDir, `hookify.${hook}.local.md`);
|
|
140
|
+
if (!existsSync(filePath)) return null;
|
|
141
|
+
|
|
142
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
143
|
+
const match = content.match(/^# Version: (.+)$/m);
|
|
144
|
+
return match ? match[1] : null;
|
|
145
|
+
}
|
|
@@ -11,21 +11,27 @@ export interface HookPackManifest {
|
|
|
11
11
|
description: string;
|
|
12
12
|
hooks: string[];
|
|
13
13
|
composedFrom?: string[];
|
|
14
|
+
version?: string;
|
|
15
|
+
/** Whether this pack is built-in or user-defined */
|
|
16
|
+
source?: 'built-in' | 'local';
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
17
20
|
const __dirname = dirname(__filename);
|
|
18
21
|
|
|
19
22
|
/** Root directory containing all built-in hook packs. */
|
|
20
|
-
function
|
|
23
|
+
function getBuiltinRoot(): string {
|
|
21
24
|
return __dirname;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/** Local custom packs directory. */
|
|
28
|
+
function getLocalRoot(): string {
|
|
29
|
+
return join(process.cwd(), '.soleri', 'hook-packs');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Scan a directory for pack manifests. */
|
|
33
|
+
function scanPacksDir(root: string, source: 'built-in' | 'local'): HookPackManifest[] {
|
|
34
|
+
if (!existsSync(root)) return [];
|
|
29
35
|
const entries = readdirSync(root, { withFileTypes: true });
|
|
30
36
|
const packs: HookPackManifest[] = [];
|
|
31
37
|
|
|
@@ -36,6 +42,7 @@ export function listPacks(): HookPackManifest[] {
|
|
|
36
42
|
|
|
37
43
|
try {
|
|
38
44
|
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8')) as HookPackManifest;
|
|
45
|
+
manifest.source = source;
|
|
39
46
|
packs.push(manifest);
|
|
40
47
|
} catch {
|
|
41
48
|
// Skip malformed manifests
|
|
@@ -46,18 +53,47 @@ export function listPacks(): HookPackManifest[] {
|
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
/**
|
|
49
|
-
*
|
|
56
|
+
* List all available hook packs (built-in + local custom).
|
|
57
|
+
* Local packs in .soleri/hook-packs/ override built-in packs with the same name.
|
|
58
|
+
*/
|
|
59
|
+
export function listPacks(): HookPackManifest[] {
|
|
60
|
+
const builtIn = scanPacksDir(getBuiltinRoot(), 'built-in');
|
|
61
|
+
const local = scanPacksDir(getLocalRoot(), 'local');
|
|
62
|
+
|
|
63
|
+
// Local packs override built-in packs with same name
|
|
64
|
+
const byName = new Map<string, HookPackManifest>();
|
|
65
|
+
for (const pack of builtIn) byName.set(pack.name, pack);
|
|
66
|
+
for (const pack of local) byName.set(pack.name, pack);
|
|
67
|
+
|
|
68
|
+
return Array.from(byName.values());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get a specific pack by name. Local packs take precedence.
|
|
50
73
|
*/
|
|
51
74
|
export function getPack(name: string): { manifest: HookPackManifest; dir: string } | null {
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
const
|
|
75
|
+
// Check local first
|
|
76
|
+
const localDir = join(getLocalRoot(), name);
|
|
77
|
+
const localManifest = join(localDir, 'manifest.json');
|
|
78
|
+
if (existsSync(localManifest)) {
|
|
79
|
+
try {
|
|
80
|
+
const manifest = JSON.parse(readFileSync(localManifest, 'utf-8')) as HookPackManifest;
|
|
81
|
+
manifest.source = 'local';
|
|
82
|
+
return { manifest, dir: localDir };
|
|
83
|
+
} catch {
|
|
84
|
+
// Fall through to built-in
|
|
85
|
+
}
|
|
86
|
+
}
|
|
55
87
|
|
|
56
|
-
|
|
88
|
+
// Then built-in
|
|
89
|
+
const builtinDir = join(getBuiltinRoot(), name);
|
|
90
|
+
const builtinManifest = join(builtinDir, 'manifest.json');
|
|
91
|
+
if (!existsSync(builtinManifest)) return null;
|
|
57
92
|
|
|
58
93
|
try {
|
|
59
|
-
const manifest = JSON.parse(readFileSync(
|
|
60
|
-
|
|
94
|
+
const manifest = JSON.parse(readFileSync(builtinManifest, 'utf-8')) as HookPackManifest;
|
|
95
|
+
manifest.source = 'built-in';
|
|
96
|
+
return { manifest, dir: builtinDir };
|
|
61
97
|
} catch {
|
|
62
98
|
return null;
|
|
63
99
|
}
|
package/src/utils/checks.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { join } from 'node:path';
|
|
|
6
6
|
import { execFileSync } from 'node:child_process';
|
|
7
7
|
import { homedir } from 'node:os';
|
|
8
8
|
import { detectAgent } from './agent-context.js';
|
|
9
|
+
import { getInstalledPacks } from '../hook-packs/registry.js';
|
|
9
10
|
|
|
10
11
|
interface CheckResult {
|
|
11
12
|
status: 'pass' | 'fail' | 'warn';
|
|
@@ -134,6 +135,22 @@ function checkCognee(): CheckResult {
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
export function checkHookPacks(): CheckResult {
|
|
139
|
+
const installed = getInstalledPacks();
|
|
140
|
+
if (installed.length === 0) {
|
|
141
|
+
return {
|
|
142
|
+
status: 'warn',
|
|
143
|
+
label: 'Hook packs',
|
|
144
|
+
detail: 'none installed — run soleri hooks list-packs',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
status: 'pass',
|
|
149
|
+
label: 'Hook packs',
|
|
150
|
+
detail: installed.join(', '),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
137
154
|
export function runAllChecks(dir?: string): CheckResult[] {
|
|
138
155
|
return [
|
|
139
156
|
checkNodeVersion(),
|
|
@@ -143,6 +160,7 @@ export function runAllChecks(dir?: string): CheckResult[] {
|
|
|
143
160
|
checkNodeModules(dir),
|
|
144
161
|
checkAgentBuild(dir),
|
|
145
162
|
checkMcpRegistration(dir),
|
|
163
|
+
checkHookPacks(),
|
|
146
164
|
checkCognee(),
|
|
147
165
|
];
|
|
148
166
|
}
|