create-command-center 0.0.0-stage → 0.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/LICENSE +21 -0
- package/LICENSE.agent-skills +21 -0
- package/README.md +62 -2
- package/RELEASING.md +29 -0
- package/UPSTREAM.md +13 -0
- package/bin/create-command-center.mjs +34 -0
- package/installer/build-parsers.mjs +21 -0
- package/installer/install.mjs +103 -0
- package/installer/template/AGENTS.md +9 -0
- package/installer/template/README.md +13 -0
- package/installer/template/gitignore +5 -0
- package/installer/template/repos/index.md +5 -0
- package/package.json +41 -4
- package/references/accessibility-checklist.md +160 -0
- package/references/definition-of-done.md +67 -0
- package/references/observability-checklist.md +92 -0
- package/references/orchestration-patterns.md +370 -0
- package/references/performance-checklist.md +239 -0
- package/references/security-checklist.md +250 -0
- package/references/testing-patterns.md +236 -0
- package/skills/accessibility-engineering/SKILL.md +133 -0
- package/skills/accessibility-engineering/scripts/audit-a11y.sh +233 -0
- package/skills/api-and-interface-design/SKILL.md +369 -0
- package/skills/browser-testing-with-devtools/SKILL.md +319 -0
- package/skills/cc/SKILL.md +26 -0
- package/skills/cc/assets/config.md +28 -0
- package/skills/cc/assets/progress.md +23 -0
- package/skills/cc/references/jobs.md +30 -0
- package/skills/cc/references/registration.md +63 -0
- package/skills/cc/scripts/checks.mjs +109 -0
- package/skills/cc/scripts/errors.mjs +3 -0
- package/skills/cc/scripts/home.mjs +60 -0
- package/skills/cc/scripts/init.mjs +499 -0
- package/skills/cc/scripts/inspection.mjs +315 -0
- package/skills/cc/scripts/vendor/LICENSE.parsers.txt +70 -0
- package/skills/cc/scripts/vendor/parsers.mjs +9951 -0
- package/skills/ci-cd-and-automation/SKILL.md +395 -0
- package/skills/code-review-and-quality/SKILL.md +402 -0
- package/skills/code-simplification/SKILL.md +331 -0
- package/skills/constraint-driven-development/SKILL.md +319 -0
- package/skills/constraint-driven-development/references/floor-guard.md +182 -0
- package/skills/constraint-driven-development/scripts/quality-gate.mjs +45 -0
- package/skills/context-engineering/SKILL.md +353 -0
- package/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/skills/deprecation-and-migration/SKILL.md +252 -0
- package/skills/documentation-and-adrs/SKILL.md +320 -0
- package/skills/doubt-driven-development/SKILL.md +245 -0
- package/skills/frontend-ui-engineering/SKILL.md +346 -0
- package/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/skills/idea-refine/SKILL.md +195 -0
- package/skills/idea-refine/examples.md +238 -0
- package/skills/idea-refine/frameworks.md +99 -0
- package/skills/idea-refine/refinement-criteria.md +113 -0
- package/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/skills/incremental-implementation/SKILL.md +249 -0
- package/skills/interview-me/SKILL.md +235 -0
- package/skills/observability-and-instrumentation/SKILL.md +238 -0
- package/skills/performance-optimization/SKILL.md +267 -0
- package/skills/performance-optimization/references/optimization-patterns.md +250 -0
- package/skills/planning-and-task-breakdown/SKILL.md +259 -0
- package/skills/security-and-hardening/SKILL.md +216 -0
- package/skills/security-and-hardening/references/hardening-patterns.md +333 -0
- package/skills/shipping-and-launch/SKILL.md +336 -0
- package/skills/source-driven-development/SKILL.md +217 -0
- package/skills/spec-driven-development/SKILL.md +307 -0
- package/skills/test-driven-development/SKILL.md +400 -0
- package/skills/using-agent-skills/SKILL.md +194 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { readFile, readdir, lstat, realpath } from 'node:fs/promises';
|
|
2
|
+
import { join, dirname, relative, resolve, isAbsolute, sep, posix } from 'node:path';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { parseToml, parseYaml, makeMatcher } from './vendor/parsers.mjs';
|
|
5
|
+
import { failure } from './errors.mjs';
|
|
6
|
+
|
|
7
|
+
function inside(root, path) {
|
|
8
|
+
const rel = relative(root, path);
|
|
9
|
+
return !isAbsolute(rel) && rel !== '..' && !rel.startsWith(`..${sep}`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function contents(root, path) {
|
|
13
|
+
const absolute = resolve(root, path);
|
|
14
|
+
if (!inside(root, absolute) || !inside(await realpath(root), await realpath(absolute)) || !(await lstat(await realpath(absolute))).isFile()) {
|
|
15
|
+
throw failure('INSPECTION_INVALID', 'Inspection input must be a file inside its root.', { paths: [path] });
|
|
16
|
+
}
|
|
17
|
+
return readFile(absolute);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function evidence(path, field) { return { path, field }; }
|
|
21
|
+
|
|
22
|
+
function parseData(path, bytes) {
|
|
23
|
+
const text = bytes.toString('utf8');
|
|
24
|
+
if (/\.json$/.test(path) || posix.basename(path) === 'Pipfile.lock') return JSON.parse(text);
|
|
25
|
+
if (/\.ya?ml$/.test(path)) return parseYaml(text, { maxAliasCount: 50, schema: 'core', logLevel: 'silent' });
|
|
26
|
+
return parseToml(text);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function instructionScopes(paths) {
|
|
30
|
+
return paths.map(path => ({ path, scope: posix.dirname(path), kind: posix.dirname(path) === '.' ? 'root' : 'nested' }))
|
|
31
|
+
.sort((a, b) => {
|
|
32
|
+
const left = a.scope === '.' ? 0 : a.scope.split('/').length;
|
|
33
|
+
const right = b.scope === '.' ? 0 : b.scope.split('/').length;
|
|
34
|
+
return left - right || a.path.localeCompare(b.path, 'en');
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function applicableInstructions(scopes, directory) {
|
|
39
|
+
const path = directory.replaceAll('\\', '/').replace(/\/$/, '') || '.';
|
|
40
|
+
return scopes.filter(item => item.scope === '.' || item.scope === path || path.startsWith(`${item.scope}/`));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function buildCatalog(home) {
|
|
44
|
+
const root = join(home, 'skills');
|
|
45
|
+
const skills = [];
|
|
46
|
+
const diagnostics = [];
|
|
47
|
+
const paths = [];
|
|
48
|
+
for (const entry of (await readdir(root, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name, 'en'))) {
|
|
49
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
50
|
+
const path = `skills/${entry.name}/SKILL.md`;
|
|
51
|
+
let bytes;
|
|
52
|
+
try { bytes = await contents(home, path); }
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (!['ENOENT', 'INSPECTION_INVALID'].includes(error.code)) throw error;
|
|
55
|
+
diagnostics.push({ code: 'SKILL_MALFORMED', path, message: 'SKILL.md is missing or outside the home.' });
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
paths.push(path);
|
|
59
|
+
try {
|
|
60
|
+
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(bytes.toString('utf8'));
|
|
61
|
+
if (!frontmatter) throw new Error('Missing frontmatter.');
|
|
62
|
+
const value = parseYaml(frontmatter[1], { maxAliasCount: 50, schema: 'core', logLevel: 'silent' });
|
|
63
|
+
if (typeof value?.name !== 'string' || !/^[a-z0-9][a-z0-9-]*$/.test(value.name) || typeof value.description !== 'string' || !value.description.trim()) throw new Error('Invalid name or description.');
|
|
64
|
+
skills.push({ name: value.name, description: value.description, path, digest: createHash('sha256').update(bytes).digest('hex'), valid: value.name === entry.name });
|
|
65
|
+
if (value.name !== entry.name) diagnostics.push({ code: 'SKILL_MALFORMED', path, message: 'Skill name differs from its folder.' });
|
|
66
|
+
} catch {
|
|
67
|
+
diagnostics.push({ code: 'SKILL_MALFORMED', path, message: 'Invalid skill frontmatter.' });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const name of new Set(skills.map(skill => skill.name))) {
|
|
71
|
+
if (skills.filter(skill => skill.name === name).length > 1) diagnostics.push({ code: 'SKILL_AMBIGUOUS', name, message: 'Multiple home skills declare this name.' });
|
|
72
|
+
}
|
|
73
|
+
return { skills, diagnostics, paths };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function snapshot(checkout, inspection, home, catalog) {
|
|
77
|
+
const projectPaths = [...new Set(['instructions', 'manifests', 'lockfiles', 'ci', 'documentation'].flatMap(key => inspection[key]))].sort();
|
|
78
|
+
const files = [];
|
|
79
|
+
for (const [root, paths, kind] of [[checkout, projectPaths, 'project'], [home, catalog.paths, 'catalog']]) {
|
|
80
|
+
for (const path of paths) files.push({ kind, path, digest: createHash('sha256').update(await contents(root, path)).digest('hex') });
|
|
81
|
+
}
|
|
82
|
+
return { files, catalogDiagnostics: catalog.diagnostics };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function compareSnapshots(previous, current) {
|
|
86
|
+
const key = item => `${item.kind}:${item.path}`;
|
|
87
|
+
const before = new Map(previous.files.map(item => [key(item), item.digest]));
|
|
88
|
+
const after = new Map(current.files.map(item => [key(item), item.digest]));
|
|
89
|
+
const paths = [...new Set([...before.keys(), ...after.keys()])].filter(path => before.get(path) !== after.get(path));
|
|
90
|
+
if (JSON.stringify(previous.catalogDiagnostics) !== JSON.stringify(current.catalogDiagnostics)) paths.push('catalog:skills/');
|
|
91
|
+
return [...new Set(paths)].sort();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function strings(value) {
|
|
95
|
+
if (value === undefined) return [];
|
|
96
|
+
if (!Array.isArray(value) || value.some(item => typeof item !== 'string')) throw new Error('Workspace patterns must be an array of strings.');
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function workspace(patterns, excludes, source, field) {
|
|
101
|
+
return { patterns: strings(patterns), excludes: strings(excludes), members: [], evidence: [evidence(source, field)], status: 'resolved' };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function declaredScripts(value, source, field, diagnostics) {
|
|
105
|
+
const scripts = {};
|
|
106
|
+
if (value === undefined) return scripts;
|
|
107
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
108
|
+
diagnostics.push({ code: 'MANIFEST_INVALID', path: source, message: `${field} must be a mapping.` });
|
|
109
|
+
return scripts;
|
|
110
|
+
}
|
|
111
|
+
for (const [name, command] of Object.entries(value)) {
|
|
112
|
+
if (typeof command !== 'string') diagnostics.push({ code: 'MANIFEST_INVALID', path: source, message: `Unsupported script declaration in ${field}.` });
|
|
113
|
+
else scripts[name] = { command, evidence: evidence(source, `${field}.${name}`) };
|
|
114
|
+
}
|
|
115
|
+
return scripts;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function project(ecosystem, manifest, data = {}) {
|
|
119
|
+
return { ecosystem, path: posix.dirname(manifest), manifest, languages: [ecosystem === 'node' ? 'javascript' : ecosystem], scripts: {}, manager: { name: null, status: 'unknown', evidence: [] }, evidence: { path: evidence(manifest, 'file'), languages: evidence(manifest, 'file') }, ...data };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function manager(project, name, source, field) {
|
|
123
|
+
project.manager = { name, status: 'resolved', evidence: [evidence(source, field)] };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function goValue(text, key) {
|
|
127
|
+
const match = new RegExp(`^\\s*${key}\\s+("[^"\\r\\n]+"|[^\\s/][^\\s]*)`, 'm').exec(text);
|
|
128
|
+
return match?.[1].replace(/^"|"$/g, '') || null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function goUses(text) {
|
|
132
|
+
const values = [];
|
|
133
|
+
for (const line of text.split(/\r?\n/)) {
|
|
134
|
+
const match = /^\s*use\s+([^()]+?)\s*(?:\/\/.*)?$/.exec(line);
|
|
135
|
+
if (match) values.push(match[1].trim().replace(/^"|"$/g, ''));
|
|
136
|
+
}
|
|
137
|
+
for (const block of text.matchAll(/^\s*use\s*\(([\s\S]*?)\)/gm)) {
|
|
138
|
+
for (const line of block[1].split(/\r?\n/)) {
|
|
139
|
+
const value = line.replace(/\/\/.*$/, '').trim().replace(/^"|"$/g, '');
|
|
140
|
+
if (value) values.push(value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return values;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export async function collectFacts(checkout, inspection) {
|
|
147
|
+
const projects = [];
|
|
148
|
+
const diagnostics = [];
|
|
149
|
+
const parsed = new Map();
|
|
150
|
+
const allPaths = [...new Set([...inspection.manifests, ...inspection.lockfiles])].sort();
|
|
151
|
+
for (const path of allPaths) {
|
|
152
|
+
const leaf = posix.basename(path);
|
|
153
|
+
const bytes = await contents(checkout, path);
|
|
154
|
+
try {
|
|
155
|
+
if (['package.json', 'package-lock.json', 'npm-shrinkwrap.json', 'pyproject.toml', 'Pipfile', 'Pipfile.lock', 'uv.lock', 'poetry.lock', 'Cargo.toml', 'Cargo.lock', 'pnpm-lock.yaml', 'pnpm-workspace.yaml'].includes(leaf)) parsed.set(path, parseData(path, bytes));
|
|
156
|
+
if (leaf === 'package.json') {
|
|
157
|
+
const value = parsed.get(path);
|
|
158
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Expected an object.');
|
|
159
|
+
const item = project('node', path, { name: typeof value.name === 'string' ? value.name : null });
|
|
160
|
+
item.evidence.name = evidence(path, 'name');
|
|
161
|
+
if (value.dependencies?.typescript || value.devDependencies?.typescript) {
|
|
162
|
+
item.languages.push('typescript');
|
|
163
|
+
item.evidence.typescript = evidence(path, value.dependencies?.typescript ? 'dependencies.typescript' : 'devDependencies.typescript');
|
|
164
|
+
}
|
|
165
|
+
item.scripts = declaredScripts(value.scripts, path, 'scripts', diagnostics);
|
|
166
|
+
if (typeof value.engines?.node === 'string') { item.runtime = value.engines.node; item.evidence.runtime = evidence(path, 'engines.node'); }
|
|
167
|
+
if (value.packageManager !== undefined) {
|
|
168
|
+
if (typeof value.packageManager === 'string' && /^(npm|pnpm|yarn|bun)@\S+$/.test(value.packageManager)) manager(item, value.packageManager.split('@')[0], path, 'packageManager');
|
|
169
|
+
else diagnostics.push({ code: 'MANAGER_UNKNOWN', path, message: 'Unsupported packageManager declaration.' });
|
|
170
|
+
}
|
|
171
|
+
if (value.workspaces !== undefined) {
|
|
172
|
+
const patterns = Array.isArray(value.workspaces) ? value.workspaces : value.workspaces?.packages;
|
|
173
|
+
if (!Array.isArray(patterns) || patterns.some(pattern => typeof pattern !== 'string')) throw new Error('Invalid workspaces.');
|
|
174
|
+
item.workspace = workspace(patterns, [], path, 'workspaces');
|
|
175
|
+
}
|
|
176
|
+
projects.push(item);
|
|
177
|
+
} else if (leaf === 'pyproject.toml') {
|
|
178
|
+
const value = parsed.get(path);
|
|
179
|
+
const item = project('python', path, { name: value.project?.name || value.tool?.poetry?.name || null });
|
|
180
|
+
item.evidence.name = evidence(path, value.project?.name ? 'project.name' : 'tool.poetry.name');
|
|
181
|
+
item.runtime = value.project?.['requires-python'] || value.tool?.poetry?.dependencies?.python || null;
|
|
182
|
+
item.evidence.runtime = evidence(path, value.project?.['requires-python'] ? 'project.requires-python' : 'tool.poetry.dependencies.python');
|
|
183
|
+
if (value['build-system']) item.buildSystem = { backend: value['build-system']['build-backend'] || null, requires: strings(value['build-system'].requires), evidence: evidence(path, 'build-system') };
|
|
184
|
+
item.scripts = declaredScripts(value.project?.scripts || value.tool?.poetry?.scripts, path, value.project?.scripts ? 'project.scripts' : 'tool.poetry.scripts', diagnostics);
|
|
185
|
+
if (value.tool?.uv !== undefined) manager(item, 'uv', path, 'tool.uv');
|
|
186
|
+
if (value.tool?.poetry !== undefined) {
|
|
187
|
+
if (item.manager.name) diagnostics.push({ code: 'MANAGER_CONFLICT', path, message: 'Both uv and Poetry are declared.' });
|
|
188
|
+
else manager(item, 'poetry', path, 'tool.poetry');
|
|
189
|
+
}
|
|
190
|
+
if (value.tool?.uv?.workspace) item.workspace = workspace(value.tool.uv.workspace.members, value.tool.uv.workspace.exclude, path, 'tool.uv.workspace');
|
|
191
|
+
projects.push(item);
|
|
192
|
+
} else if (leaf === 'Pipfile') {
|
|
193
|
+
const item = project('python', path);
|
|
194
|
+
manager(item, 'pipenv', path, 'file');
|
|
195
|
+
item.scripts = declaredScripts(parsed.get(path).scripts, path, 'scripts', diagnostics);
|
|
196
|
+
projects.push(item);
|
|
197
|
+
} else if (leaf === 'requirements.txt') {
|
|
198
|
+
if (!inspection.manifests.includes(posix.join(posix.dirname(path), 'pyproject.toml')) && !inspection.manifests.includes(posix.join(posix.dirname(path), 'Pipfile'))) {
|
|
199
|
+
const item = project('python', path); manager(item, 'pip', path, 'file'); projects.push(item);
|
|
200
|
+
}
|
|
201
|
+
} else if (leaf === 'go.mod') {
|
|
202
|
+
const text = bytes.toString('utf8');
|
|
203
|
+
const item = project('go', path, { name: goValue(text, 'module'), runtime: goValue(text, 'go'), toolchain: goValue(text, 'toolchain') });
|
|
204
|
+
if (!item.name) throw new Error('Missing module declaration.');
|
|
205
|
+
item.evidence.name = evidence(path, 'module'); item.evidence.runtime = evidence(path, 'go'); item.evidence.toolchain = evidence(path, 'toolchain');
|
|
206
|
+
manager(item, 'go', path, 'module'); projects.push(item);
|
|
207
|
+
} else if (leaf === 'Cargo.toml') {
|
|
208
|
+
const value = parsed.get(path);
|
|
209
|
+
const item = project('rust', path, { name: value.package?.name || null, runtime: value.package?.['rust-version'] || null });
|
|
210
|
+
item.evidence.name = evidence(path, 'package.name'); item.evidence.runtime = evidence(path, 'package.rust-version');
|
|
211
|
+
manager(item, 'cargo', path, 'file');
|
|
212
|
+
if (value.workspace) item.workspace = workspace(value.workspace.members, value.workspace.exclude, path, 'workspace');
|
|
213
|
+
projects.push(item);
|
|
214
|
+
} else if (leaf === 'go.work') {
|
|
215
|
+
// Attach below, after all go.mod files have been read.
|
|
216
|
+
parsed.set(path, goUses(bytes.toString('utf8')));
|
|
217
|
+
} else if (inspection.manifests.includes(path) && leaf !== 'pnpm-workspace.yaml') {
|
|
218
|
+
diagnostics.push({ code: 'UNSUPPORTED_MANIFEST', path, message: 'Detected manifest; structured parsing is unavailable.' });
|
|
219
|
+
}
|
|
220
|
+
} catch {
|
|
221
|
+
diagnostics.push({ code: 'MANIFEST_INVALID', path, message: 'Manifest or lockfile could not be parsed with its documented data format.' });
|
|
222
|
+
parsed.delete(path);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (const path of inspection.manifests.filter(path => posix.basename(path) === 'pnpm-workspace.yaml')) {
|
|
227
|
+
const value = parsed.get(path);
|
|
228
|
+
if (!value) continue;
|
|
229
|
+
if (!Array.isArray(value.packages) || value.packages.some(pattern => typeof pattern !== 'string')) {
|
|
230
|
+
diagnostics.push({ code: 'MANIFEST_INVALID', path, message: 'pnpm workspace packages must be an array of patterns.' });
|
|
231
|
+
parsed.delete(path); continue;
|
|
232
|
+
}
|
|
233
|
+
if (!projects.some(item => item.ecosystem === 'node' && item.path === posix.dirname(path))) {
|
|
234
|
+
const item = project('node', path);
|
|
235
|
+
item.workspace = workspace(value.packages, [], path, 'packages');
|
|
236
|
+
projects.push(item);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
for (const item of projects) {
|
|
240
|
+
const directory = posix.dirname(item.manifest);
|
|
241
|
+
const lockManagers = { node: { 'package-lock.json': 'npm', 'npm-shrinkwrap.json': 'npm', 'pnpm-lock.yaml': 'pnpm', 'yarn.lock': 'yarn', 'bun.lock': 'bun', 'bun.lockb': 'bun' }, python: { 'uv.lock': 'uv', 'poetry.lock': 'poetry', 'Pipfile.lock': 'pipenv' } };
|
|
242
|
+
const evidenceItems = [...item.manager.evidence];
|
|
243
|
+
const choices = new Set(item.manager.name ? [item.manager.name] : []);
|
|
244
|
+
const workspacePath = posix.join(directory, 'pnpm-workspace.yaml');
|
|
245
|
+
if (item.ecosystem === 'node' && parsed.has(workspacePath)) { choices.add('pnpm'); evidenceItems.push(evidence(workspacePath, 'file')); }
|
|
246
|
+
item.lockfiles = [];
|
|
247
|
+
const ecosystemLocks = { node: Object.keys(lockManagers.node), python: Object.keys(lockManagers.python), go: ['go.sum'], rust: ['Cargo.lock'] };
|
|
248
|
+
for (const path of inspection.lockfiles.filter(path => posix.dirname(path) === directory && ecosystemLocks[item.ecosystem].includes(posix.basename(path)))) {
|
|
249
|
+
const name = lockManagers[item.ecosystem]?.[posix.basename(path)];
|
|
250
|
+
if (name) { choices.add(name); evidenceItems.push(evidence(path, 'file')); }
|
|
251
|
+
const value = parsed.get(path);
|
|
252
|
+
item.lockfiles.push({ path, version: value?.lockfileVersion ?? value?.version ?? value?._meta?.['pipfile-spec'] ?? null,
|
|
253
|
+
parsing: parsed.has(path) ? 'parsed' : 'presence_only', evidence: evidence(path, 'file') });
|
|
254
|
+
}
|
|
255
|
+
if (choices.size > 1 || diagnostics.some(diagnostic => diagnostic.code === 'MANAGER_CONFLICT' && diagnostic.path === item.manifest)) {
|
|
256
|
+
item.manager = { name: null, status: 'conflicting', evidence: evidenceItems };
|
|
257
|
+
diagnostics.push({ code: 'MANAGER_CONFLICT', path: item.manifest, message: 'Package-manager evidence conflicts.' });
|
|
258
|
+
} else if (choices.size === 1) item.manager = { name: [...choices][0], status: 'resolved', evidence: evidenceItems };
|
|
259
|
+
if (item.ecosystem === 'node') {
|
|
260
|
+
const declaration = parsed.get(workspacePath);
|
|
261
|
+
if (declaration) {
|
|
262
|
+
const patterns = strings(declaration.packages);
|
|
263
|
+
if (item.workspace && JSON.stringify(item.workspace.patterns) !== JSON.stringify(patterns)) {
|
|
264
|
+
item.workspace.status = 'conflicting';
|
|
265
|
+
diagnostics.push({ code: 'WORKSPACE_CONFLICT', path: workspacePath, message: 'Workspace declarations disagree.' });
|
|
266
|
+
} else item.workspace ||= workspace(patterns, [], workspacePath, 'packages');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
for (const path of inspection.manifests.filter(path => posix.basename(path) === 'go.work')) {
|
|
271
|
+
const members = parsed.get(path);
|
|
272
|
+
if (!members) continue;
|
|
273
|
+
const directory = posix.dirname(path);
|
|
274
|
+
let item = projects.find(project => project.ecosystem === 'go' && project.path === directory);
|
|
275
|
+
if (!item) { item = project('go', path); manager(item, 'go', path, 'use'); projects.push(item); }
|
|
276
|
+
item.workspace = workspace(members, [], path, 'use');
|
|
277
|
+
}
|
|
278
|
+
for (const key of new Set(projects.map(item => `${item.ecosystem}:${item.path}`))) {
|
|
279
|
+
const group = projects.filter(item => `${item.ecosystem}:${item.path}` === key);
|
|
280
|
+
if (group.length < 2) continue;
|
|
281
|
+
const names = new Set(group.map(item => item.manager.name).filter(Boolean));
|
|
282
|
+
const evidenceItems = [...new Map(group.flatMap(item => item.manager.evidence).map(item => [JSON.stringify(item), item])).values()];
|
|
283
|
+
if (names.size > 1 || group.some(item => item.manager.status === 'conflicting')) {
|
|
284
|
+
for (const item of group) item.manager = { name: null, status: 'conflicting', evidence: evidenceItems };
|
|
285
|
+
diagnostics.push({ code: 'MANAGER_CONFLICT', path: group[0].manifest, message: 'Project manifests in the same directory declare different managers.' });
|
|
286
|
+
} else if (names.size === 1) {
|
|
287
|
+
for (const item of group) item.manager = { name: [...names][0], status: 'resolved', evidence: evidenceItems };
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
for (const item of projects.filter(project => project.workspace)) {
|
|
291
|
+
const value = item.workspace;
|
|
292
|
+
if (value.status === 'conflicting') continue;
|
|
293
|
+
const include = value.patterns.filter(pattern => !pattern.startsWith('!'));
|
|
294
|
+
const exclude = [...value.excludes, ...value.patterns.filter(pattern => pattern.startsWith('!')).map(pattern => pattern.slice(1))];
|
|
295
|
+
const absolutePattern = pattern => posix.normalize(posix.join(item.path, pattern.replaceAll('\\', '/')));
|
|
296
|
+
if ([...include, ...exclude].some(pattern => isAbsolute(pattern) || /^[a-z]:/i.test(pattern) || absolutePattern(pattern) === '..' || absolutePattern(pattern).startsWith('../'))) {
|
|
297
|
+
value.status = 'unresolved'; diagnostics.push({ code: 'WORKSPACE_INVALID', path: item.manifest, message: 'Workspace pattern escapes the repository scope.' }); continue;
|
|
298
|
+
}
|
|
299
|
+
const candidates = projects.filter(candidate => candidate.ecosystem === item.ecosystem);
|
|
300
|
+
for (const pattern of include) {
|
|
301
|
+
const matcher = makeMatcher(absolutePattern(pattern), { dot: true });
|
|
302
|
+
const matches = candidates.filter(candidate => matcher(candidate.path));
|
|
303
|
+
if (!matches.length) diagnostics.push({ code: 'WORKSPACE_MEMBER_MISSING', path: item.manifest, message: `No discovered project matches workspace member ${pattern}.` });
|
|
304
|
+
for (const candidate of matches) if (!exclude.some(pattern => makeMatcher(absolutePattern(pattern), { dot: true })(candidate.path))) value.members.push(candidate.path);
|
|
305
|
+
}
|
|
306
|
+
if (['rust', 'python'].includes(item.ecosystem) && item.name) value.members.push(item.path);
|
|
307
|
+
value.members = [...new Set(value.members)].sort();
|
|
308
|
+
}
|
|
309
|
+
for (const item of projects.filter(project => project.manager.status === 'unknown')) {
|
|
310
|
+
const parents = projects.filter(parent => parent !== item && parent.ecosystem === item.ecosystem && parent.workspace?.status === 'resolved' && parent.workspace.members.includes(item.path)).sort((a, b) => b.path.length - a.path.length);
|
|
311
|
+
if (parents[0]) item.manager = { ...parents[0].manager, inheritedFrom: parents[0].path };
|
|
312
|
+
}
|
|
313
|
+
projects.sort((a, b) => a.path.localeCompare(b.path, 'en') || a.ecosystem.localeCompare(b.ecosystem, 'en') || a.manifest.localeCompare(b.manifest, 'en'));
|
|
314
|
+
return { projects, diagnostics: diagnostics.sort((a, b) => a.path.localeCompare(b.path, 'en') || a.code.localeCompare(b.code, 'en')) };
|
|
315
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Bundled data parsers. Rebuild with npm run build:parsers.
|
|
2
|
+
|
|
3
|
+
smol-toml 1.9.1
|
|
4
|
+
|
|
5
|
+
Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
6
|
+
|
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
+
list of conditions and the following disclaimer.
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the
|
|
14
|
+
documentation and/or other materials provided with the distribution.
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
may be used to endorse or promote products derived from this software without
|
|
17
|
+
specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
yaml 2.9.1
|
|
32
|
+
|
|
33
|
+
Copyright Eemeli Aro <eemeli@gmail.com>
|
|
34
|
+
|
|
35
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
36
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
37
|
+
and this permission notice appear in all copies.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
40
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
41
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
42
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
43
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
44
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
45
|
+
THIS SOFTWARE.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
picomatch 4.0.7
|
|
49
|
+
|
|
50
|
+
The MIT License (MIT)
|
|
51
|
+
|
|
52
|
+
Copyright (c) 2017-present, Jon Schlinkert.
|
|
53
|
+
|
|
54
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
55
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
56
|
+
in the Software without restriction, including without limitation the rights
|
|
57
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
58
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
59
|
+
furnished to do so, subject to the following conditions:
|
|
60
|
+
|
|
61
|
+
The above copyright notice and this permission notice shall be included in
|
|
62
|
+
all copies or substantial portions of the Software.
|
|
63
|
+
|
|
64
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
65
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
66
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
67
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
68
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
69
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
70
|
+
THE SOFTWARE.
|