claudeos-core 1.2.1 → 1.2.3

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.

Potentially problematic release.


This version of claudeos-core might be problematic. Click here for more details.

@@ -1,173 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * ClaudeOS-Core — Import Linter
5
- *
6
- * Role: Validate @import paths in .claude/rules/, standard/, skills/, guide/
7
- * Validation items:
8
- * - BROKEN: @import pointing to non-existent file
9
- * - DUPLICATE: Same path imported multiple times in the same file
10
- * - CIRCULAR: Circular @import chain detected (DFS)
11
- *
12
- * Usage: npx claudeos-core <cmd> or node claudeos-core-tools/import-linter/index.js
13
- */
14
-
15
- const fs = require("fs");
16
- const path = require("path");
17
- const { glob } = require("glob");
18
-
19
- const ROOT = process.env.CLAUDEOS_ROOT || path.resolve(__dirname, "../..");
20
- const SCAN = [
21
- ".claude/rules",
22
- "claudeos-core/standard",
23
- "claudeos-core/skills",
24
- "claudeos-core/guide",
25
- "claudeos-core/database",
26
- "claudeos-core/mcp-guide",
27
- ];
28
-
29
- function rel(p) {
30
- return path.relative(ROOT, p).replace(/\\/g, "/");
31
- }
32
-
33
- function extractImports(f) {
34
- const content = fs.readFileSync(f, "utf-8");
35
- const result = [];
36
- let inCodeFence = false;
37
- content.split("\n").forEach((line, i) => {
38
- // Track code fence boundaries to skip @-lines inside code blocks
39
- if (/^```/.test(line)) { inCodeFence = !inCodeFence; return; }
40
- if (inCodeFence) return;
41
- const m = line.match(/^@(\.\.?\/[^\s]+)/);
42
- if (m) {
43
- const target = path.resolve(path.dirname(f), m[1]);
44
- result.push({
45
- raw: m[0],
46
- rawPath: m[1],
47
- resolved: target,
48
- resolvedRel: rel(target),
49
- exists: fs.existsSync(target),
50
- line: i + 1,
51
- });
52
- }
53
- });
54
- return result;
55
- }
56
-
57
- function detectCycles(adj) {
58
- const cycles = [];
59
- const visited = new Set();
60
- const inStack = new Set();
61
-
62
- function dfs(n, pathSoFar) {
63
- visited.add(n);
64
- inStack.add(n);
65
- for (const nb of adj[n] || []) {
66
- if (!visited.has(nb)) {
67
- const c = dfs(nb, [...pathSoFar, nb]);
68
- if (c) return c;
69
- } else if (inStack.has(nb)) {
70
- const ci = pathSoFar.indexOf(nb);
71
- return [...pathSoFar.slice(ci), nb];
72
- }
73
- }
74
- inStack.delete(n);
75
- return null;
76
- }
77
-
78
- for (const n of Object.keys(adj)) {
79
- if (!visited.has(n)) {
80
- const c = dfs(n, [n]);
81
- if (c) cycles.push(c);
82
- }
83
- }
84
- return cycles;
85
- }
86
-
87
- async function main() {
88
- console.log("\n╔══════════════════════════════════════╗");
89
- console.log("║ ClaudeOS-Core — Import Linter ║");
90
- console.log("╚══════════════════════════════════════╝\n");
91
-
92
- const errors = [];
93
- const warnings = [];
94
- let totalImports = 0;
95
- let totalFiles = 0;
96
- const adj = {};
97
-
98
- for (const d of SCAN) {
99
- const abs = path.join(ROOT, d);
100
- if (!fs.existsSync(abs)) {
101
- console.log(` ⏭️ Skipping: ${d}`);
102
- continue;
103
- }
104
-
105
- for (const f of await glob("**/*.md", { cwd: abs, absolute: true })) {
106
- const r = rel(f);
107
- const imps = extractImports(f);
108
- if (!imps.length) continue;
109
-
110
- totalFiles++;
111
- totalImports += imps.length;
112
- adj[r] = [];
113
- const seen = new Set();
114
-
115
- for (const i of imps) {
116
- adj[r].push(i.resolvedRel);
117
-
118
- if (!i.exists) {
119
- errors.push({
120
- type: "BROKEN",
121
- file: r,
122
- line: i.line,
123
- target: i.resolvedRel,
124
- msg: `${r}:${i.line} → ${i.resolvedRel} (NOT FOUND)`,
125
- });
126
- }
127
-
128
- if (seen.has(i.resolvedRel)) {
129
- warnings.push({
130
- type: "DUP",
131
- file: r,
132
- line: i.line,
133
- target: i.resolvedRel,
134
- msg: `${r}:${i.line} → ${i.resolvedRel} (DUPLICATE)`,
135
- });
136
- }
137
- seen.add(i.resolvedRel);
138
- }
139
- }
140
- }
141
-
142
- // Cycle detection
143
- for (const c of detectCycles(adj)) {
144
- errors.push({
145
- type: "CIRCULAR",
146
- cycle: c,
147
- msg: `Circular: ${c.join(" → ")}`,
148
- });
149
- }
150
-
151
- console.log(` Scanned ${totalFiles} files, ${totalImports} @imports\n`);
152
-
153
- if (!errors.length && !warnings.length) {
154
- console.log(` ✅ ${totalImports}/${totalImports} valid\n`);
155
- process.exit(0);
156
- }
157
-
158
- if (errors.length) {
159
- console.log(` ❌ ERRORS (${errors.length}):`);
160
- errors.forEach((e) => console.log(` ${e.msg}`));
161
- console.log();
162
- }
163
- if (warnings.length) {
164
- console.log(` ⚠️ WARNINGS (${warnings.length}):`);
165
- warnings.forEach((w) => console.log(` ${w.msg}`));
166
- console.log();
167
- }
168
-
169
- console.log(` Total issues: ${errors.length + warnings.length}\n`);
170
- process.exit(errors.length ? 1 : 0);
171
- }
172
-
173
- main().catch(console.error);