@shrkcrft/cli 0.1.0-alpha.24 → 0.1.0-alpha.26

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.
Files changed (52) hide show
  1. package/dist/command-registry.d.ts +10 -0
  2. package/dist/command-registry.d.ts.map +1 -1
  3. package/dist/command-registry.js +16 -0
  4. package/dist/commands/changelog-data.d.ts +25 -0
  5. package/dist/commands/changelog-data.d.ts.map +1 -0
  6. package/dist/commands/changelog-data.js +94 -0
  7. package/dist/commands/changelog.command.d.ts +3 -0
  8. package/dist/commands/changelog.command.d.ts.map +1 -0
  9. package/dist/commands/changelog.command.js +100 -0
  10. package/dist/commands/changes.command.d.ts.map +1 -1
  11. package/dist/commands/changes.command.js +4 -0
  12. package/dist/commands/check.command.d.ts.map +1 -1
  13. package/dist/commands/check.command.js +134 -19
  14. package/dist/commands/command-catalog.d.ts.map +1 -1
  15. package/dist/commands/command-catalog.js +8 -0
  16. package/dist/commands/compress.command.d.ts.map +1 -1
  17. package/dist/commands/compress.command.js +46 -2
  18. package/dist/commands/constructs.command.d.ts.map +1 -1
  19. package/dist/commands/constructs.command.js +49 -14
  20. package/dist/commands/context.command.d.ts.map +1 -1
  21. package/dist/commands/context.command.js +31 -19
  22. package/dist/commands/gate.command.d.ts.map +1 -1
  23. package/dist/commands/gate.command.js +63 -3
  24. package/dist/commands/gen.command.d.ts.map +1 -1
  25. package/dist/commands/gen.command.js +65 -9
  26. package/dist/commands/graph-code-subverbs.d.ts.map +1 -1
  27. package/dist/commands/graph-code-subverbs.js +14 -2
  28. package/dist/commands/graph.command.d.ts.map +1 -1
  29. package/dist/commands/graph.command.js +68 -1
  30. package/dist/commands/policy-lint.command.d.ts.map +1 -1
  31. package/dist/commands/policy-lint.command.js +46 -8
  32. package/dist/commands/registry-resolve.d.ts +41 -0
  33. package/dist/commands/registry-resolve.d.ts.map +1 -0
  34. package/dist/commands/registry-resolve.js +89 -0
  35. package/dist/commands/registry.command.d.ts.map +1 -1
  36. package/dist/commands/registry.command.js +86 -13
  37. package/dist/commands/reuse.command.d.ts +20 -0
  38. package/dist/commands/reuse.command.d.ts.map +1 -1
  39. package/dist/commands/reuse.command.js +156 -20
  40. package/dist/commands/smart-context.command.d.ts.map +1 -1
  41. package/dist/commands/smart-context.command.js +20 -5
  42. package/dist/commands/task.command.d.ts.map +1 -1
  43. package/dist/commands/task.command.js +33 -16
  44. package/dist/exit-codes.d.ts +49 -0
  45. package/dist/exit-codes.d.ts.map +1 -0
  46. package/dist/exit-codes.js +61 -0
  47. package/dist/main.d.ts.map +1 -1
  48. package/dist/main.js +26 -1
  49. package/dist/validation/typecheck-emitted.d.ts +36 -0
  50. package/dist/validation/typecheck-emitted.d.ts.map +1 -0
  51. package/dist/validation/typecheck-emitted.js +109 -0
  52. package/package.json +33 -33
@@ -0,0 +1,109 @@
1
+ import * as ts from 'typescript';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { dirname, resolve } from 'node:path';
4
+ const TSCONFIG_NAMES = ['tsconfig.json', 'tsconfig.base.json'];
5
+ function findTsconfig(projectRoot) {
6
+ for (const name of TSCONFIG_NAMES) {
7
+ const p = resolve(projectRoot, name);
8
+ if (existsSync(p))
9
+ return p;
10
+ }
11
+ return null;
12
+ }
13
+ /**
14
+ * Typecheck a set of EMITTED (not-yet-written) files against the project's
15
+ * detected tsconfig, without touching disk. Builds a `ts.Program` whose root
16
+ * names are the emitted files, over a compiler host that overlays the rendered
17
+ * bodies for those paths and reads everything else (imports, lib) from disk — so
18
+ * a scaffold that references a real project symbol resolves, and a template bug
19
+ * (bad syntax, a dangling import, a type mismatch) surfaces BEFORE apply instead
20
+ * of at the human's next build.
21
+ *
22
+ * Only diagnostics located IN the emitted files are reported; pre-existing
23
+ * errors elsewhere in the project are ignored (this is a generation gate, not a
24
+ * whole-repo typecheck).
25
+ */
26
+ export function typecheckEmittedFiles(projectRoot, files) {
27
+ const tsFiles = files.filter((f) => /\.tsx?$/.test(f.absPath));
28
+ if (tsFiles.length === 0) {
29
+ return { ran: false, errors: [], note: 'no TS/TSX files in the emit set' };
30
+ }
31
+ let options = {
32
+ target: ts.ScriptTarget.ES2022,
33
+ module: ts.ModuleKind.ESNext,
34
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
35
+ strict: true,
36
+ esModuleInterop: true,
37
+ };
38
+ const tsconfigPath = findTsconfig(projectRoot);
39
+ if (tsconfigPath) {
40
+ const read = ts.readConfigFile(tsconfigPath, (p) => {
41
+ try {
42
+ return readFileSync(p, 'utf8');
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ });
48
+ if (!read.error) {
49
+ const parsed = ts.parseJsonConfigFileContent(read.config, ts.sys, dirname(tsconfigPath));
50
+ options = parsed.options;
51
+ }
52
+ }
53
+ // Force a non-emitting, lib-skipping check regardless of the project's config.
54
+ options.noEmit = true;
55
+ options.skipLibCheck = true;
56
+ options.incremental = false;
57
+ delete options.composite;
58
+ delete options.outDir;
59
+ delete options.declaration;
60
+ const overlay = new Map(tsFiles.map((f) => [resolve(f.absPath), f.contents]));
61
+ const host = ts.createCompilerHost(options, true);
62
+ const origGetSourceFile = host.getSourceFile.bind(host);
63
+ const origReadFile = host.readFile.bind(host);
64
+ const origFileExists = host.fileExists.bind(host);
65
+ host.readFile = (fileName) => {
66
+ const k = resolve(fileName);
67
+ return overlay.has(k) ? overlay.get(k) : origReadFile(fileName);
68
+ };
69
+ host.fileExists = (fileName) => overlay.has(resolve(fileName)) || origFileExists(fileName);
70
+ host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreate) => {
71
+ const k = resolve(fileName);
72
+ const body = overlay.get(k);
73
+ if (body !== undefined) {
74
+ return ts.createSourceFile(fileName, body, languageVersionOrOptions, true);
75
+ }
76
+ return origGetSourceFile(fileName, languageVersionOrOptions, onError, shouldCreate);
77
+ };
78
+ const rootNames = tsFiles.map((f) => resolve(f.absPath));
79
+ const program = ts.createProgram({ rootNames, options, host });
80
+ const errors = [];
81
+ for (const rn of rootNames) {
82
+ const sf = program.getSourceFile(rn);
83
+ if (!sf)
84
+ continue;
85
+ const diags = [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)];
86
+ for (const d of diags) {
87
+ if (d.category !== ts.DiagnosticCategory.Error)
88
+ continue;
89
+ let line = 0;
90
+ let column = 0;
91
+ if (d.file && typeof d.start === 'number') {
92
+ const lc = d.file.getLineAndCharacterOfPosition(d.start);
93
+ line = lc.line + 1;
94
+ column = lc.character + 1;
95
+ }
96
+ errors.push({
97
+ file: resolve(d.file?.fileName ?? rn),
98
+ line,
99
+ column,
100
+ message: ts.flattenDiagnosticMessageText(d.messageText, '\n'),
101
+ });
102
+ }
103
+ }
104
+ return {
105
+ ran: true,
106
+ errors,
107
+ ...(tsconfigPath ? { note: `checked against ${tsconfigPath}` } : { note: 'no tsconfig found — used defaults' }),
108
+ };
109
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shrkcrft/cli",
3
- "version": "0.1.0-alpha.24",
3
+ "version": "0.1.0-alpha.26",
4
4
  "description": "SharkCraft CLI (`shrk`): structured project intelligence for AI coding agents.",
5
5
  "license": "MIT",
6
6
  "author": "SharkCraft contributors",
@@ -47,38 +47,38 @@
47
47
  "typecheck": "tsc --noEmit -p tsconfig.json"
48
48
  },
49
49
  "dependencies": {
50
- "@shrkcrft/core": "^0.1.0-alpha.24",
51
- "@shrkcrft/compress": "^0.1.0-alpha.24",
52
- "@shrkcrft/config": "^0.1.0-alpha.24",
53
- "@shrkcrft/workspace": "^0.1.0-alpha.24",
54
- "@shrkcrft/knowledge": "^0.1.0-alpha.24",
55
- "@shrkcrft/context": "^0.1.0-alpha.24",
56
- "@shrkcrft/rules": "^0.1.0-alpha.24",
57
- "@shrkcrft/paths": "^0.1.0-alpha.24",
58
- "@shrkcrft/templates": "^0.1.0-alpha.24",
59
- "@shrkcrft/plugin-api": "^0.1.0-alpha.24",
60
- "@shrkcrft/dashboard": "^0.1.0-alpha.24",
61
- "@shrkcrft/dashboard-api": "^0.1.0-alpha.24",
62
- "@shrkcrft/pipelines": "^0.1.0-alpha.24",
63
- "@shrkcrft/presets": "^0.1.0-alpha.24",
64
- "@shrkcrft/boundaries": "^0.1.0-alpha.24",
65
- "@shrkcrft/graph": "^0.1.0-alpha.24",
66
- "@shrkcrft/rule-graph": "^0.1.0-alpha.24",
67
- "@shrkcrft/structural-search": "^0.1.0-alpha.24",
68
- "@shrkcrft/impact-engine": "^0.1.0-alpha.24",
69
- "@shrkcrft/context-planner": "^0.1.0-alpha.24",
70
- "@shrkcrft/architecture-guard": "^0.1.0-alpha.24",
71
- "@shrkcrft/framework-scanners": "^0.1.0-alpha.24",
72
- "@shrkcrft/api-surface-diff": "^0.1.0-alpha.24",
73
- "@shrkcrft/quality-gates": "^0.1.0-alpha.24",
74
- "@shrkcrft/migrate": "^0.1.0-alpha.24",
75
- "@shrkcrft/generator": "^0.1.0-alpha.24",
76
- "@shrkcrft/importer": "^0.1.0-alpha.24",
77
- "@shrkcrft/inspector": "^0.1.0-alpha.24",
78
- "@shrkcrft/ai": "^0.1.0-alpha.24",
79
- "@shrkcrft/embeddings": "^0.1.0-alpha.24",
80
- "@shrkcrft/shared": "^0.1.0-alpha.24",
81
- "@shrkcrft/mcp-server": "^0.1.0-alpha.24",
50
+ "@shrkcrft/core": "^0.1.0-alpha.26",
51
+ "@shrkcrft/compress": "^0.1.0-alpha.26",
52
+ "@shrkcrft/config": "^0.1.0-alpha.26",
53
+ "@shrkcrft/workspace": "^0.1.0-alpha.26",
54
+ "@shrkcrft/knowledge": "^0.1.0-alpha.26",
55
+ "@shrkcrft/context": "^0.1.0-alpha.26",
56
+ "@shrkcrft/rules": "^0.1.0-alpha.26",
57
+ "@shrkcrft/paths": "^0.1.0-alpha.26",
58
+ "@shrkcrft/templates": "^0.1.0-alpha.26",
59
+ "@shrkcrft/plugin-api": "^0.1.0-alpha.26",
60
+ "@shrkcrft/dashboard": "^0.1.0-alpha.26",
61
+ "@shrkcrft/dashboard-api": "^0.1.0-alpha.26",
62
+ "@shrkcrft/pipelines": "^0.1.0-alpha.26",
63
+ "@shrkcrft/presets": "^0.1.0-alpha.26",
64
+ "@shrkcrft/boundaries": "^0.1.0-alpha.26",
65
+ "@shrkcrft/graph": "^0.1.0-alpha.26",
66
+ "@shrkcrft/rule-graph": "^0.1.0-alpha.26",
67
+ "@shrkcrft/structural-search": "^0.1.0-alpha.26",
68
+ "@shrkcrft/impact-engine": "^0.1.0-alpha.26",
69
+ "@shrkcrft/context-planner": "^0.1.0-alpha.26",
70
+ "@shrkcrft/architecture-guard": "^0.1.0-alpha.26",
71
+ "@shrkcrft/framework-scanners": "^0.1.0-alpha.26",
72
+ "@shrkcrft/api-surface-diff": "^0.1.0-alpha.26",
73
+ "@shrkcrft/quality-gates": "^0.1.0-alpha.26",
74
+ "@shrkcrft/migrate": "^0.1.0-alpha.26",
75
+ "@shrkcrft/generator": "^0.1.0-alpha.26",
76
+ "@shrkcrft/importer": "^0.1.0-alpha.26",
77
+ "@shrkcrft/inspector": "^0.1.0-alpha.26",
78
+ "@shrkcrft/ai": "^0.1.0-alpha.26",
79
+ "@shrkcrft/embeddings": "^0.1.0-alpha.26",
80
+ "@shrkcrft/shared": "^0.1.0-alpha.26",
81
+ "@shrkcrft/mcp-server": "^0.1.0-alpha.26",
82
82
  "@huggingface/transformers": "^3.7.5"
83
83
  },
84
84
  "publishConfig": {