safeword 0.6.3 → 0.6.4
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/dist/{check-PECCGHEA.js → check-ICZISZ3R.js} +41 -23
- package/dist/check-ICZISZ3R.js.map +1 -0
- package/dist/chunk-E5ZC6R5H.js +720 -0
- package/dist/chunk-E5ZC6R5H.js.map +1 -0
- package/dist/chunk-JGXYBPNM.js +454 -0
- package/dist/chunk-JGXYBPNM.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/diff-FOJDBKKF.js +168 -0
- package/dist/diff-FOJDBKKF.js.map +1 -0
- package/dist/reset-JU2E65XN.js +74 -0
- package/dist/reset-JU2E65XN.js.map +1 -0
- package/dist/setup-UKMYK5TE.js +103 -0
- package/dist/setup-UKMYK5TE.js.map +1 -0
- package/dist/{sync-4XBMKLXS.js → sync-5MOXVTH4.js} +33 -32
- package/dist/sync-5MOXVTH4.js.map +1 -0
- package/dist/upgrade-NSLDFWNR.js +73 -0
- package/dist/upgrade-NSLDFWNR.js.map +1 -0
- package/package.json +1 -1
- package/templates/SAFEWORD.md +8 -28
- package/dist/check-PECCGHEA.js.map +0 -1
- package/dist/chunk-6CVTH67L.js +0 -43
- package/dist/chunk-6CVTH67L.js.map +0 -1
- package/dist/chunk-75FKNZUM.js +0 -15
- package/dist/chunk-75FKNZUM.js.map +0 -1
- package/dist/chunk-ARIAOK2F.js +0 -110
- package/dist/chunk-ARIAOK2F.js.map +0 -1
- package/dist/chunk-FRPJITGG.js +0 -35
- package/dist/chunk-FRPJITGG.js.map +0 -1
- package/dist/chunk-IWWBZVHT.js +0 -274
- package/dist/chunk-IWWBZVHT.js.map +0 -1
- package/dist/diff-ZACVJKOU.js +0 -171
- package/dist/diff-ZACVJKOU.js.map +0 -1
- package/dist/reset-5SRM3P6J.js +0 -145
- package/dist/reset-5SRM3P6J.js.map +0 -1
- package/dist/setup-65EVU5OT.js +0 -437
- package/dist/setup-65EVU5OT.js.map +0 -1
- package/dist/sync-4XBMKLXS.js.map +0 -1
- package/dist/upgrade-P3WX3ODU.js +0 -153
- package/dist/upgrade-P3WX3ODU.js.map +0 -1
- /package/templates/prompts/{review.md → quality-review.md} +0 -0
|
@@ -2,20 +2,22 @@ import {
|
|
|
2
2
|
isNewerVersion
|
|
3
3
|
} from "./chunk-W66Z3C5H.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-ORQHKDT2.js";
|
|
7
|
-
import {
|
|
5
|
+
createProjectContext,
|
|
8
6
|
header,
|
|
9
7
|
info,
|
|
10
8
|
keyValue,
|
|
9
|
+
reconcile,
|
|
11
10
|
success,
|
|
12
11
|
warn
|
|
13
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JGXYBPNM.js";
|
|
14
13
|
import {
|
|
14
|
+
SAFEWORD_SCHEMA,
|
|
15
15
|
exists,
|
|
16
|
-
readFile,
|
|
17
16
|
readFileSafe
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-E5ZC6R5H.js";
|
|
18
|
+
import {
|
|
19
|
+
VERSION
|
|
20
|
+
} from "./chunk-ORQHKDT2.js";
|
|
19
21
|
|
|
20
22
|
// src/commands/check.ts
|
|
21
23
|
import { join } from "path";
|
|
@@ -34,9 +36,8 @@ async function checkLatestVersion(timeout = 3e3) {
|
|
|
34
36
|
return null;
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
function checkHealth(cwd) {
|
|
39
|
+
async function checkHealth(cwd) {
|
|
38
40
|
const safewordDir = join(cwd, ".safeword");
|
|
39
|
-
const issues = [];
|
|
40
41
|
if (!exists(safewordDir)) {
|
|
41
42
|
return {
|
|
42
43
|
configured: false,
|
|
@@ -44,25 +45,37 @@ function checkHealth(cwd) {
|
|
|
44
45
|
cliVersion: VERSION,
|
|
45
46
|
updateAvailable: false,
|
|
46
47
|
latestVersion: null,
|
|
47
|
-
issues: []
|
|
48
|
+
issues: [],
|
|
49
|
+
missingPackages: []
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
const versionPath = join(safewordDir, "version");
|
|
51
53
|
const projectVersion = readFileSafe(versionPath)?.trim() ?? null;
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const ctx = createProjectContext(cwd);
|
|
55
|
+
const result = await reconcile(SAFEWORD_SCHEMA, "upgrade", ctx, { dryRun: true });
|
|
56
|
+
const issues = [];
|
|
57
|
+
const writeActions = result.actions.filter((a) => a.type === "write");
|
|
58
|
+
for (const action of writeActions) {
|
|
59
|
+
if (action.type === "write") {
|
|
60
|
+
const fullPath = join(cwd, action.path);
|
|
61
|
+
if (!exists(fullPath)) {
|
|
62
|
+
issues.push(`Missing: ${action.path}`);
|
|
63
|
+
}
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
const textPatchActions = result.actions.filter((a) => a.type === "text-patch");
|
|
67
|
+
for (const action of textPatchActions) {
|
|
68
|
+
if (action.type === "text-patch") {
|
|
69
|
+
const fullPath = join(cwd, action.path);
|
|
70
|
+
if (!exists(fullPath)) {
|
|
71
|
+
issues.push(`${action.path} file missing`);
|
|
72
|
+
} else {
|
|
73
|
+
const content = readFileSafe(fullPath) ?? "";
|
|
74
|
+
if (!content.includes(action.definition.marker)) {
|
|
75
|
+
issues.push(`${action.path} missing safeword link`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
|
-
} else {
|
|
65
|
-
issues.push("AGENTS.md file missing");
|
|
66
79
|
}
|
|
67
80
|
const settingsPath = join(cwd, ".claude", "settings.json");
|
|
68
81
|
if (!exists(settingsPath)) {
|
|
@@ -74,13 +87,14 @@ function checkHealth(cwd) {
|
|
|
74
87
|
cliVersion: VERSION,
|
|
75
88
|
updateAvailable: false,
|
|
76
89
|
latestVersion: null,
|
|
77
|
-
issues
|
|
90
|
+
issues,
|
|
91
|
+
missingPackages: result.packagesToInstall
|
|
78
92
|
};
|
|
79
93
|
}
|
|
80
94
|
async function check(options) {
|
|
81
95
|
const cwd = process.cwd();
|
|
82
96
|
header("Safeword Health Check");
|
|
83
|
-
const health = checkHealth(cwd);
|
|
97
|
+
const health = await checkHealth(cwd);
|
|
84
98
|
if (!health.configured) {
|
|
85
99
|
info("Not configured. Run `safeword setup` to initialize.");
|
|
86
100
|
return;
|
|
@@ -121,6 +135,10 @@ Upgrade available for project config`);
|
|
|
121
135
|
warn(issue);
|
|
122
136
|
}
|
|
123
137
|
info("\nRun `safeword upgrade` to repair configuration");
|
|
138
|
+
} else if (health.missingPackages.length > 0) {
|
|
139
|
+
header("Missing Packages");
|
|
140
|
+
info(`${health.missingPackages.length} linting packages not installed`);
|
|
141
|
+
info("Run `safeword sync` to install missing packages");
|
|
124
142
|
} else {
|
|
125
143
|
success("\nConfiguration is healthy");
|
|
126
144
|
}
|
|
@@ -128,4 +146,4 @@ Upgrade available for project config`);
|
|
|
128
146
|
export {
|
|
129
147
|
check
|
|
130
148
|
};
|
|
131
|
-
//# sourceMappingURL=check-
|
|
149
|
+
//# sourceMappingURL=check-ICZISZ3R.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/check.ts"],"sourcesContent":["/**\n * Check command - Verify project health and configuration\n *\n * Uses reconcile() with dryRun to detect missing files and configuration issues.\n */\n\nimport { join } from 'node:path';\nimport { VERSION } from '../version.js';\nimport { exists, readFileSafe } from '../utils/fs.js';\nimport { info, success, warn, header, keyValue } from '../utils/output.js';\nimport { isNewerVersion } from '../utils/version.js';\nimport { createProjectContext } from '../utils/context.js';\nimport { reconcile } from '../reconcile.js';\nimport { SAFEWORD_SCHEMA } from '../schema.js';\n\nexport interface CheckOptions {\n offline?: boolean;\n}\n\ninterface HealthStatus {\n configured: boolean;\n projectVersion: string | null;\n cliVersion: string;\n updateAvailable: boolean;\n latestVersion: string | null;\n issues: string[];\n missingPackages: string[];\n}\n\n/**\n * Check for latest version from npm (with timeout)\n */\nasync function checkLatestVersion(timeout = 3000): Promise<string | null> {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n const response = await fetch('https://registry.npmjs.org/safeword/latest', {\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) return null;\n\n const data = (await response.json()) as { version?: string };\n return data.version ?? null;\n } catch {\n return null;\n }\n}\n\n/**\n * Check project configuration health using reconcile dryRun\n */\nasync function checkHealth(cwd: string): Promise<HealthStatus> {\n const safewordDir = join(cwd, '.safeword');\n\n // Check if configured\n if (!exists(safewordDir)) {\n return {\n configured: false,\n projectVersion: null,\n cliVersion: VERSION,\n updateAvailable: false,\n latestVersion: null,\n issues: [],\n missingPackages: [],\n };\n }\n\n // Read project version\n const versionPath = join(safewordDir, 'version');\n const projectVersion = readFileSafe(versionPath)?.trim() ?? null;\n\n // Use reconcile with dryRun to detect issues\n const ctx = createProjectContext(cwd);\n const result = await reconcile(SAFEWORD_SCHEMA, 'upgrade', ctx, { dryRun: true });\n\n const issues: string[] = [];\n\n // Check for missing owned files (write actions indicate missing/changed files)\n const writeActions = result.actions.filter(a => a.type === 'write');\n for (const action of writeActions) {\n if (action.type === 'write') {\n const fullPath = join(cwd, action.path);\n if (!exists(fullPath)) {\n issues.push(`Missing: ${action.path}`);\n }\n }\n }\n\n // Check for missing text patches (e.g., AGENTS.md link)\n const textPatchActions = result.actions.filter(a => a.type === 'text-patch');\n for (const action of textPatchActions) {\n if (action.type === 'text-patch') {\n const fullPath = join(cwd, action.path);\n if (!exists(fullPath)) {\n issues.push(`${action.path} file missing`);\n } else {\n const content = readFileSafe(fullPath) ?? '';\n if (!content.includes(action.definition.marker)) {\n issues.push(`${action.path} missing safeword link`);\n }\n }\n }\n }\n\n // Check for missing .claude/settings.json\n const settingsPath = join(cwd, '.claude', 'settings.json');\n if (!exists(settingsPath)) {\n issues.push('Missing: .claude/settings.json');\n }\n\n return {\n configured: true,\n projectVersion,\n cliVersion: VERSION,\n updateAvailable: false,\n latestVersion: null,\n issues,\n missingPackages: result.packagesToInstall,\n };\n}\n\nexport async function check(options: CheckOptions): Promise<void> {\n const cwd = process.cwd();\n\n header('Safeword Health Check');\n\n const health = await checkHealth(cwd);\n\n // Not configured\n if (!health.configured) {\n info('Not configured. Run `safeword setup` to initialize.');\n return;\n }\n\n // Show versions\n keyValue('Safeword CLI', `v${health.cliVersion}`);\n keyValue('Project config', health.projectVersion ? `v${health.projectVersion}` : 'unknown');\n\n // Check for updates (unless offline)\n if (!options.offline) {\n info('\\nChecking for updates...');\n const latestVersion = await checkLatestVersion();\n\n if (latestVersion) {\n health.latestVersion = latestVersion;\n health.updateAvailable = isNewerVersion(health.cliVersion, latestVersion);\n\n if (health.updateAvailable) {\n warn(`Update available: v${latestVersion}`);\n info('Run `npm install -g safeword` to upgrade');\n } else {\n success('CLI is up to date');\n }\n } else {\n warn(\"Couldn't check for updates (offline?)\");\n }\n } else {\n info('\\nSkipped update check (offline mode)');\n }\n\n // Check project version vs CLI version\n if (health.projectVersion && isNewerVersion(health.cliVersion, health.projectVersion)) {\n warn(`Project config (v${health.projectVersion}) is newer than CLI (v${health.cliVersion})`);\n info('Consider upgrading the CLI');\n } else if (health.projectVersion && isNewerVersion(health.projectVersion, health.cliVersion)) {\n info(`\\nUpgrade available for project config`);\n info(\n `Run \\`safeword upgrade\\` to update from v${health.projectVersion} to v${health.cliVersion}`,\n );\n }\n\n // Show issues\n if (health.issues.length > 0) {\n header('Issues Found');\n for (const issue of health.issues) {\n warn(issue);\n }\n info('\\nRun `safeword upgrade` to repair configuration');\n } else if (health.missingPackages.length > 0) {\n header('Missing Packages');\n info(`${health.missingPackages.length} linting packages not installed`);\n info('Run `safeword sync` to install missing packages');\n } else {\n success('\\nConfiguration is healthy');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,YAAY;AA0BrB,eAAe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