@deepwissen/preflight 0.0.0-stage → 0.4.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/dist/scopes.js ADDED
@@ -0,0 +1,93 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join, resolve, dirname, basename } from "node:path";
4
+ import { findSkillFiles } from "./discover.js";
5
+ // Claude Code keeps non-skill data under ~/.claude; never walk those when scanning
6
+ // the user scope (projects/ holds transcripts and can be enormous).
7
+ const USER_NOISE = [
8
+ "projects",
9
+ "todos",
10
+ "statsig",
11
+ "shell-snapshots",
12
+ "ide",
13
+ "logs",
14
+ "history",
15
+ "plugins",
16
+ "backups",
17
+ ];
18
+ /** Project scope: the committed, team-shared skills in <cwd>/.claude/skills. */
19
+ export function projectScope(cwd = process.cwd()) {
20
+ const root = resolve(cwd);
21
+ const claude = join(root, ".claude");
22
+ return {
23
+ name: "project",
24
+ scanRoot: root,
25
+ skillsDir: join(claude, "skills"),
26
+ skip: [],
27
+ settingsFiles: [join(claude, "settings.json"), join(claude, "settings.local.json")],
28
+ };
29
+ }
30
+ /** User scope: personal skills in ~/.claude/skills, shared across all projects. */
31
+ export function userScope() {
32
+ const base = join(homedir(), ".claude");
33
+ return {
34
+ name: "user",
35
+ scanRoot: base,
36
+ skillsDir: join(base, "skills"),
37
+ skip: USER_NOISE,
38
+ settingsFiles: [join(base, "settings.json"), join(base, "settings.local.json")],
39
+ };
40
+ }
41
+ /** Pick the scopes a command should act on from --global / --all flags. */
42
+ export function scopesFor(flags) {
43
+ if (flags.all)
44
+ return [projectScope(), userScope()];
45
+ if (flags.global)
46
+ return [userScope()];
47
+ return [projectScope()];
48
+ }
49
+ /** Lightweight list of a scope's skill names (lowercased) — reads only each
50
+ * file's frontmatter `name` (falling back to the directory/filename), no scan. */
51
+ export function scopeSkillNames(scope) {
52
+ const names = [];
53
+ for (const rel of findSkillFiles(scope.scanRoot, scope.skip)) {
54
+ let name = "";
55
+ try {
56
+ const head = readFileSync(join(scope.scanRoot, rel), "utf8").slice(0, 2000);
57
+ const m = /^[ \t]*name[ \t]*:[ \t]*(.+?)[ \t]*$/m.exec(head);
58
+ if (m)
59
+ name = m[1].replace(/^["']|["']$/g, "");
60
+ }
61
+ catch {
62
+ /* unreadable — fall through to path derivation */
63
+ }
64
+ if (!name) {
65
+ const file = basename(rel);
66
+ name = /^skill\.md$/i.test(file) ? basename(dirname(rel)) : file.replace(/\.md$/i, "");
67
+ }
68
+ if (name)
69
+ names.push(name.toLowerCase());
70
+ }
71
+ return names;
72
+ }
73
+ /**
74
+ * Cross-scope hints for a single-scope view: warn when a shown skill is shadowed
75
+ * by (or shadows) a same-named skill in the other scope, and nudge that the other
76
+ * scope's skills aren't shown. Personal (user) always wins over project. Pure.
77
+ */
78
+ export function shadowNotices(opts) {
79
+ const otherSet = new Set(opts.other);
80
+ const collisions = [...new Set(opts.shown)].filter((n) => otherSet.has(n)).sort();
81
+ const notices = [];
82
+ for (const name of collisions) {
83
+ notices.push(opts.global
84
+ ? ` ⚠ "${name}" also exists as a project skill — this personal one runs; the project one is shadowed.`
85
+ : ` ⚠ "${name}" is also a personal skill (~/.claude) — the personal one runs; this project one is shadowed.`);
86
+ }
87
+ if (opts.other.length > 0) {
88
+ const label = opts.global ? "project" : "personal";
89
+ notices.push(` ℹ ${opts.other.length} ${label} skill(s) not shown — run \`preflight ${opts.command} --all\` to include them.`);
90
+ }
91
+ return notices;
92
+ }
93
+ //# sourceMappingURL=scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.js","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,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AAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAClF,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CACV,IAAI,CAAC,MAAM;YACT,CAAC,CAAC,QAAQ,IAAI,yFAAyF;YACvG,CAAC,CAAC,QAAQ,IAAI,+FAA+F,CAChH,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;QACnD,OAAO,CAAC,IAAI,CACV,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,yCAAyC,IAAI,CAAC,OAAO,2BAA2B,CAClH,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@deepwissen/preflight",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.0",
4
+ "description": "Get your AI agent flight-ready — inventory, scope, and scan the skills it carries, before it flies.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "preflight": "./dist/bin.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/deepwissen/preflight.git"
19
+ },
20
+ "homepage": "https://github.com/deepwissen/preflight#readme",
21
+ "keywords": [
22
+ "ai",
23
+ "claude",
24
+ "skills",
25
+ "agent",
26
+ "security",
27
+ "preflight"
28
+ ],
29
+ "scripts": {
30
+ "build": "tsc",
31
+ "test": "vitest run",
32
+ "typecheck": "tsc --noEmit",
33
+ "check:floor": "node scripts/check-engine-floor.mjs",
34
+ "prepublishOnly": "npm run build"
35
+ },
36
+ "dependencies": {
37
+ "@deepwissen/preflight-core": "^0.1.31"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^20.11.0",
41
+ "typescript": "^5.4.0",
42
+ "vitest": "^4.1.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }