@krisada-m/ksd-intelligence 0.0.0-stage → 1.1.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/.antigravity-plugin/plugin.json +20 -0
- package/LICENSE +21 -0
- package/README.md +195 -2
- package/agy-skills/erosiano-review/SKILL.md +17 -0
- package/dist/adapters/agy/skills.js +252 -0
- package/dist/adapters/cli/check-changed.js +3 -0
- package/dist/adapters/cli/main.js +1013 -0
- package/dist/adapters/cli/policy-bin.js +10 -0
- package/dist/adapters/cli/review-verdict.js +3 -0
- package/dist/adapters/omp/extension.js +884 -0
- package/dist/adapters/omp/skills.js +130 -0
- package/dist/adapters/ui/hud.js +389 -0
- package/dist/adapters/ui/tree.js +471 -0
- package/dist/core/audit/index.js +2 -0
- package/dist/core/audit/log.js +505 -0
- package/dist/core/audit/summary.js +188 -0
- package/dist/core/changes/changes.js +591 -0
- package/dist/core/changes/git.js +266 -0
- package/dist/core/changes/plan.js +109 -0
- package/dist/core/changes/render.js +356 -0
- package/dist/core/engine/build.js +178 -0
- package/dist/core/engine/child.js +389 -0
- package/dist/core/engine/host.js +206 -0
- package/dist/core/engine/lock.js +133 -0
- package/dist/core/engine/protocol.js +43 -0
- package/dist/core/engine/runtime.js +44 -0
- package/dist/core/engine/status.js +452 -0
- package/dist/core/engine/typescript.js +194 -0
- package/dist/core/engine/workspace.js +72 -0
- package/dist/core/graph/graph.js +127 -0
- package/dist/core/graph/limits.js +16 -0
- package/dist/core/impact/query.js +1292 -0
- package/dist/core/impact/render.js +590 -0
- package/dist/core/impact/session.js +694 -0
- package/dist/core/indexing/declarations.js +455 -0
- package/dist/core/indexing/differential.js +345 -0
- package/dist/core/indexing/doctor.js +120 -0
- package/dist/core/indexing/indexer.js +811 -0
- package/dist/core/indexing/keys.js +451 -0
- package/dist/core/indexing/lexical.js +212 -0
- package/dist/core/indexing/packages.js +57 -0
- package/dist/core/indexing/program.js +171 -0
- package/dist/core/indexing/resolve.js +1004 -0
- package/dist/core/indexing/stamp.js +52 -0
- package/dist/core/indexing/surface.js +335 -0
- package/dist/core/indexing/ui-progress.js +37 -0
- package/dist/core/indexing/verify.js +76 -0
- package/dist/core/kernel/config.js +383 -0
- package/dist/core/kernel/glob.js +105 -0
- package/dist/core/kernel/guards.js +4 -0
- package/dist/core/kernel/types.js +3 -0
- package/dist/core/kernel/verdict.js +142 -0
- package/dist/core/knowledge/anchors.js +139 -0
- package/dist/core/knowledge/knowledge.js +95 -0
- package/dist/core/knowledge/learning.js +102 -0
- package/dist/core/knowledge/render.js +76 -0
- package/dist/core/knowledge/store.js +109 -0
- package/dist/core/knowledge/yaml.js +87 -0
- package/dist/core/search/lexical.js +382 -0
- package/dist/core/search/render.js +98 -0
- package/dist/core/search/segments.js +118 -0
- package/dist/core/verify/parse.js +127 -0
- package/dist/core/verify/render.js +67 -0
- package/dist/core/verify/report.js +40 -0
- package/dist/core/verify/revision.js +79 -0
- package/dist/core/verify/run.js +117 -0
- package/dist/core/verify/store.js +66 -0
- package/dist/core/verify/verify.js +173 -0
- package/dist/core/workspace/init.js +267 -0
- package/dist/core/workspace/probe.js +56 -0
- package/dist/core/workspace/scan.js +420 -0
- package/dist/engineering/baseline.js +337 -0
- package/dist/engineering/change-scope.js +500 -0
- package/dist/engineering/check-changed.js +40 -0
- package/dist/engineering/config.js +129 -0
- package/dist/engineering/dist/policy.d.ts +17 -0
- package/dist/engineering/dist/policy.js +150 -0
- package/dist/engineering/dist/runtime.d.ts +40 -0
- package/dist/engineering/dist/runtime.js +77 -0
- package/dist/engineering/dist/sdlc.d.ts +7 -0
- package/dist/engineering/dist/sdlc.js +27 -0
- package/dist/engineering/eslint-rules/index.js +107 -0
- package/dist/engineering/index.d.ts +7 -0
- package/dist/engineering/index.js +319 -0
- package/dist/engineering/intelligence.js +44 -0
- package/dist/engineering/package.json +36 -0
- package/dist/engineering/policy.js +2 -0
- package/dist/engineering/practice-tool.js +72 -0
- package/dist/engineering/practices.js +283 -0
- package/dist/engineering/practices.json +2453 -0
- package/dist/engineering/review-verdict.js +262 -0
- package/dist/engineering/sdlc.js +2 -0
- package/dist/index.js +20 -0
- package/dist/storage/records.js +245 -0
- package/dist/storage/sqlite.js +314 -0
- package/dist/workflow/catalog.js +69 -0
- package/dist/workflow/classify.js +55 -0
- package/dist/workflow/loader.js +140 -0
- package/dist/workflow/packs.js +469 -0
- package/dist/workflow/registry.js +359 -0
- package/dist/workflow/render.js +61 -0
- package/dist/workflow/router.js +141 -0
- package/dist/workflow/sources.js +229 -0
- package/dist/workflow/types.js +44 -0
- package/dist/workflow/updates.js +532 -0
- package/engineering.lock.json +94 -0
- package/package.json +81 -4
- package/rules/engineering.md +20 -0
- package/scripts/agy-mcp.mjs +27 -0
- package/scripts/mcp/engineering.mjs +91 -0
- package/scripts/mcp/stdio.mjs +304 -0
- package/scripts/mcp/tools.mjs +491 -0
- package/skills/ksd-intelligence/SKILL.md +54 -0
- package/skills/matt-sdlc/SKILL.md +42 -0
- package/skills/osmani-quality/SKILL.md +38 -0
- package/skills/poteto-mode/SKILL.md +40 -0
- package/skills/pstack-analysis/SKILL.md +36 -0
- package/skills.lock.json +71 -0
- package/skills.registry.json +181 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, posix } from 'node:path';
|
|
3
|
+
import { isRecord } from '../kernel/guards.js';
|
|
4
|
+
const ENTRY_FIELDS = ['main', 'module', 'types', 'typings', 'browser'];
|
|
5
|
+
/** Every string an `exports` map can resolve to, conditions and subpaths included. */
|
|
6
|
+
function exportTargets(value) {
|
|
7
|
+
if (typeof value === 'string')
|
|
8
|
+
return [value];
|
|
9
|
+
if (Array.isArray(value))
|
|
10
|
+
return value.flatMap(exportTargets);
|
|
11
|
+
if (isRecord(value))
|
|
12
|
+
return Object.values(value).flatMap(exportTargets);
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
/** The workspace packages of a census, read from their `package.json` files, sorted by dir. */
|
|
16
|
+
export function readPackages(root, census) {
|
|
17
|
+
const indexable = new Set(census.filter((r) => r.status === 'indexable').map((r) => r.path));
|
|
18
|
+
const packages = [];
|
|
19
|
+
for (const record of census) {
|
|
20
|
+
// Never-read files (excluded, secret) have no hash; their content is not ours to read.
|
|
21
|
+
if (basename(record.path) !== 'package.json' || record.hash === null)
|
|
22
|
+
continue;
|
|
23
|
+
let pkg;
|
|
24
|
+
try {
|
|
25
|
+
pkg = JSON.parse(readFileSync(join(root, record.path), 'utf8'));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
continue; // an unreadable package.json names no package
|
|
29
|
+
}
|
|
30
|
+
if (!isRecord(pkg))
|
|
31
|
+
continue;
|
|
32
|
+
const dir = dirname(record.path);
|
|
33
|
+
const values = [
|
|
34
|
+
...ENTRY_FIELDS.map((field) => pkg[field]).filter((v) => typeof v === 'string'),
|
|
35
|
+
...exportTargets(pkg.exports),
|
|
36
|
+
];
|
|
37
|
+
const entries = new Set();
|
|
38
|
+
const unresolved = new Set();
|
|
39
|
+
for (const value of values) {
|
|
40
|
+
// Keep unresolved entries explicit. Guessing a build-output-to-source mapping could
|
|
41
|
+
// misidentify the public surface and hide the package's real entry.
|
|
42
|
+
const path = posix.join(dir, value);
|
|
43
|
+
if (!value.includes('*') && indexable.has(path))
|
|
44
|
+
entries.add(path);
|
|
45
|
+
else
|
|
46
|
+
unresolved.add(value);
|
|
47
|
+
}
|
|
48
|
+
packages.push({
|
|
49
|
+
dir,
|
|
50
|
+
name: typeof pkg.name === 'string' ? pkg.name : null,
|
|
51
|
+
private: pkg.private === true,
|
|
52
|
+
entries: [...entries].sort(),
|
|
53
|
+
unresolved: [...unresolved].sort(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return packages.sort((a, b) => (a.dir < b.dir ? -1 : a.dir > b.dir ? 1 : 0));
|
|
57
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Options that only shape emit or diagnostics. They never change which declaration a name
|
|
4
|
+
* resolves to, so projects differing only in these share one program.
|
|
5
|
+
*/
|
|
6
|
+
const RESOLUTION_NEUTRAL = new Set([
|
|
7
|
+
'allowImportingTsExtensions',
|
|
8
|
+
'allowUnreachableCode',
|
|
9
|
+
'allowUnusedLabels',
|
|
10
|
+
'alwaysStrict',
|
|
11
|
+
'checkJs',
|
|
12
|
+
'composite',
|
|
13
|
+
'configFile',
|
|
14
|
+
'configFilePath',
|
|
15
|
+
'declaration',
|
|
16
|
+
'declarationDir',
|
|
17
|
+
'declarationMap',
|
|
18
|
+
'diagnostics',
|
|
19
|
+
'emitBOM',
|
|
20
|
+
'emitDeclarationOnly',
|
|
21
|
+
'erasableSyntaxOnly',
|
|
22
|
+
'extendedDiagnostics',
|
|
23
|
+
'forceConsistentCasingInFileNames',
|
|
24
|
+
'generateCpuProfile',
|
|
25
|
+
'importHelpers',
|
|
26
|
+
'incremental',
|
|
27
|
+
'inlineSourceMap',
|
|
28
|
+
'inlineSources',
|
|
29
|
+
'isolatedDeclarations',
|
|
30
|
+
'isolatedModules',
|
|
31
|
+
'listEmittedFiles',
|
|
32
|
+
'listFiles',
|
|
33
|
+
'mapRoot',
|
|
34
|
+
'newLine',
|
|
35
|
+
'noCheck',
|
|
36
|
+
'noEmit',
|
|
37
|
+
'noEmitHelpers',
|
|
38
|
+
'noEmitOnError',
|
|
39
|
+
'noErrorTruncation',
|
|
40
|
+
'noFallthroughCasesInSwitch',
|
|
41
|
+
'noImplicitOverride',
|
|
42
|
+
'noImplicitReturns',
|
|
43
|
+
'noPropertyAccessFromIndexSignature',
|
|
44
|
+
'noUncheckedSideEffectImports',
|
|
45
|
+
'noUnusedLocals',
|
|
46
|
+
'noUnusedParameters',
|
|
47
|
+
'outDir',
|
|
48
|
+
'outFile',
|
|
49
|
+
'preserveConstEnums',
|
|
50
|
+
'pretty',
|
|
51
|
+
'removeComments',
|
|
52
|
+
'rewriteRelativeImportExtensions',
|
|
53
|
+
'rootDir',
|
|
54
|
+
'skipDefaultLibCheck',
|
|
55
|
+
'skipLibCheck',
|
|
56
|
+
'sourceMap',
|
|
57
|
+
'sourceRoot',
|
|
58
|
+
'stripInternal',
|
|
59
|
+
'traceResolution',
|
|
60
|
+
'tsBuildInfoFile',
|
|
61
|
+
'verbatimModuleSyntax',
|
|
62
|
+
]);
|
|
63
|
+
function relevantOptions(options) {
|
|
64
|
+
const relevant = {};
|
|
65
|
+
for (const key of Object.keys(options).sort()) {
|
|
66
|
+
if (!RESOLUTION_NEUTRAL.has(key))
|
|
67
|
+
relevant[key] = options[key];
|
|
68
|
+
}
|
|
69
|
+
return relevant;
|
|
70
|
+
}
|
|
71
|
+
function fingerprint(options) {
|
|
72
|
+
return JSON.stringify(relevantOptions(options));
|
|
73
|
+
}
|
|
74
|
+
/** The resolution-relevant options whose values differ between groups: why there are several. */
|
|
75
|
+
export function splitBy(groups) {
|
|
76
|
+
const values = new Map();
|
|
77
|
+
const all = groups.map((group) => relevantOptions(group.options));
|
|
78
|
+
for (const options of all) {
|
|
79
|
+
for (const key of Object.keys(options))
|
|
80
|
+
values.set(key, new Set());
|
|
81
|
+
}
|
|
82
|
+
for (const [key, seen] of values) {
|
|
83
|
+
for (const options of all)
|
|
84
|
+
seen.add(JSON.stringify(options[key]) ?? 'unset');
|
|
85
|
+
}
|
|
86
|
+
return [...values]
|
|
87
|
+
.filter(([, seen]) => seen.size > 1)
|
|
88
|
+
.map(([key]) => key)
|
|
89
|
+
.sort();
|
|
90
|
+
}
|
|
91
|
+
/** D43: the compiler options of the analysis program. */
|
|
92
|
+
export function analysisOptions(options) {
|
|
93
|
+
const result = { ...options };
|
|
94
|
+
result.noEmit = true;
|
|
95
|
+
result.verbatimModuleSyntax = false;
|
|
96
|
+
result.isolatedModules = false;
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* One program for the whole index scope when every owning tsconfig resolves names the same way;
|
|
101
|
+
* otherwise one program per set of compatible tsconfigs (recorded in the summary).
|
|
102
|
+
*/
|
|
103
|
+
export function groupPrograms(ts, root, owners) {
|
|
104
|
+
const host = { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => undefined };
|
|
105
|
+
const cache = new Map();
|
|
106
|
+
const byFingerprint = new Map();
|
|
107
|
+
const errors = [];
|
|
108
|
+
for (const config of [...owners.keys()].sort()) {
|
|
109
|
+
const parsed = ts.getParsedCommandLineOfConfigFile(join(root, config), {}, host, cache);
|
|
110
|
+
if (parsed === undefined) {
|
|
111
|
+
errors.push(`${config}: cannot be read or parsed`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const options = analysisOptions(parsed.options);
|
|
115
|
+
const key = fingerprint(options);
|
|
116
|
+
let group = byFingerprint.get(key);
|
|
117
|
+
if (group === undefined) {
|
|
118
|
+
group = { configs: [], options, rootNames: [] };
|
|
119
|
+
byFingerprint.set(key, group);
|
|
120
|
+
}
|
|
121
|
+
group.configs.push(config);
|
|
122
|
+
for (const file of owners.get(config) ?? [])
|
|
123
|
+
group.rootNames.push(join(root, file));
|
|
124
|
+
}
|
|
125
|
+
const groups = [...byFingerprint.values()];
|
|
126
|
+
for (const group of groups)
|
|
127
|
+
group.rootNames.sort();
|
|
128
|
+
return { groups, errors };
|
|
129
|
+
}
|
|
130
|
+
// Default library files never change for one TypeScript install; programs share them.
|
|
131
|
+
const libraryFiles = new Map();
|
|
132
|
+
function isRedirectedSourceFile(sf) {
|
|
133
|
+
return 'redirectInfo' in sf && sf.redirectInfo !== undefined;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A compiler host that returns the previous program's source file for every file it holds, so a
|
|
137
|
+
* new program over the same files parses nothing again and has no checker yet. Library files are
|
|
138
|
+
* shared across programs: a dependency change is a lockfile change, which forces a cold build.
|
|
139
|
+
*/
|
|
140
|
+
export function createAnalysisHost(ts, options, previous) {
|
|
141
|
+
const host = ts.createCompilerHost(options, true);
|
|
142
|
+
const read = host.getSourceFile.bind(host);
|
|
143
|
+
const libraryDir = host.getDefaultLibLocation?.() ?? '';
|
|
144
|
+
// A program keeps its host, so the host must not keep `previous`: that would keep the old
|
|
145
|
+
// program, and its checker, alive for as long as the new one.
|
|
146
|
+
const caseKey = (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
|
147
|
+
const reusable = new Map();
|
|
148
|
+
for (const sf of previous?.getSourceFiles() ?? []) {
|
|
149
|
+
// TypeScript owns package redirects and expects the original parsed file from the host.
|
|
150
|
+
const parsed = isRedirectedSourceFile(sf) ? sf.redirectInfo.unredirected : sf;
|
|
151
|
+
reusable.set(caseKey(sf.fileName), parsed);
|
|
152
|
+
}
|
|
153
|
+
host.getSourceFile = (fileName, languageVersion, onError, shouldCreate) => {
|
|
154
|
+
const old = reusable.get(caseKey(fileName));
|
|
155
|
+
if (old !== undefined)
|
|
156
|
+
return old;
|
|
157
|
+
const isLibrary = libraryDir !== '' && fileName.startsWith(libraryDir);
|
|
158
|
+
const target = typeof languageVersion === 'object' ? languageVersion.languageVersion : languageVersion;
|
|
159
|
+
const cacheKey = `${fileName}\u0000${target}`;
|
|
160
|
+
if (isLibrary) {
|
|
161
|
+
const cached = libraryFiles.get(cacheKey);
|
|
162
|
+
if (cached !== undefined)
|
|
163
|
+
return cached;
|
|
164
|
+
}
|
|
165
|
+
const sf = read(fileName, languageVersion, onError, shouldCreate);
|
|
166
|
+
if (sf !== undefined && isLibrary)
|
|
167
|
+
libraryFiles.set(cacheKey, sf);
|
|
168
|
+
return sf;
|
|
169
|
+
};
|
|
170
|
+
return host;
|
|
171
|
+
}
|