@stackbilt/cli 0.1.1
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/__tests__/classify.test.d.ts +2 -0
- package/dist/__tests__/classify.test.d.ts.map +1 -0
- package/dist/__tests__/classify.test.js +41 -0
- package/dist/__tests__/classify.test.js.map +1 -0
- package/dist/bin.d.ts +6 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +22 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/audit.d.ts +9 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +192 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/classify.d.ts +9 -0
- package/dist/commands/classify.d.ts.map +1 -0
- package/dist/commands/classify.js +45 -0
- package/dist/commands/classify.js.map +1 -0
- package/dist/commands/doctor.d.ts +8 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +130 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/drift.d.ts +9 -0
- package/dist/commands/drift.d.ts.map +1 -0
- package/dist/commands/drift.js +178 -0
- package/dist/commands/drift.js.map +1 -0
- package/dist/commands/init.d.ts +15 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +141 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/setup.d.ts +8 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +140 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/validate.d.ts +9 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +170 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/config.d.ts +60 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +145 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/classify.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const classify_1 = require("../commands/classify");
|
|
5
|
+
const baseOptions = {
|
|
6
|
+
configPath: '.charter',
|
|
7
|
+
format: 'text',
|
|
8
|
+
ciMode: false,
|
|
9
|
+
yes: false,
|
|
10
|
+
};
|
|
11
|
+
(0, vitest_1.describe)('classifyCommand', () => {
|
|
12
|
+
(0, vitest_1.it)('returns 0 (SUCCESS) for valid subject', async () => {
|
|
13
|
+
vitest_1.vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
14
|
+
const exitCode = await (0, classify_1.classifyCommand)(baseOptions, ['fix', 'button', 'color']);
|
|
15
|
+
(0, vitest_1.expect)(exitCode).toBe(0);
|
|
16
|
+
vitest_1.vi.restoreAllMocks();
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)('throws CLIError when no subject provided', async () => {
|
|
19
|
+
await (0, vitest_1.expect)((0, classify_1.classifyCommand)(baseOptions, [])).rejects.toThrow('Usage:');
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.it)('outputs valid JSON in json format', async () => {
|
|
22
|
+
const logs = [];
|
|
23
|
+
vitest_1.vi.spyOn(console, 'log').mockImplementation((msg) => logs.push(msg));
|
|
24
|
+
await (0, classify_1.classifyCommand)({ ...baseOptions, format: 'json' }, ['OAuth', 'integration']);
|
|
25
|
+
const output = JSON.parse(logs[0]);
|
|
26
|
+
(0, vitest_1.expect)(output).toHaveProperty('suggestedClass');
|
|
27
|
+
(0, vitest_1.expect)(output).toHaveProperty('confidence');
|
|
28
|
+
(0, vitest_1.expect)(output).toHaveProperty('signals');
|
|
29
|
+
(0, vitest_1.expect)(output).toHaveProperty('recommendation');
|
|
30
|
+
vitest_1.vi.restoreAllMocks();
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.it)('filters out flag arguments from subject', async () => {
|
|
33
|
+
const logs = [];
|
|
34
|
+
vitest_1.vi.spyOn(console, 'log').mockImplementation((msg) => logs.push(msg));
|
|
35
|
+
await (0, classify_1.classifyCommand)({ ...baseOptions, format: 'json' }, ['--format', 'json', 'readme', 'update']);
|
|
36
|
+
const output = JSON.parse(logs[0]);
|
|
37
|
+
(0, vitest_1.expect)(output.suggestedClass).toBe('SURFACE');
|
|
38
|
+
vitest_1.vi.restoreAllMocks();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=classify.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.test.js","sourceRoot":"","sources":["../../src/__tests__/classify.test.ts"],"names":[],"mappings":";;AAAA,mCAAkD;AAClD,mDAAuD;AAGvD,MAAM,WAAW,GAAe;IAC9B,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,KAAK;IACb,GAAG,EAAE,KAAK;CACX,CAAC;AAEF,IAAA,iBAAQ,EAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAA,WAAE,EAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,WAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAe,EAAC,WAAW,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QAChF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,WAAE,CAAC,eAAe,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE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IAAA,0BAAe,EAAC,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;QAEpG,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,IAAA,eAAM,EAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE9C,WAAE,CAAC,eAAe,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA;;GAEG"}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* charter CLI entrypoint
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const index_1 = require("./index");
|
|
8
|
+
(0, index_1.run)(process.argv.slice(2))
|
|
9
|
+
.then((exitCode) => {
|
|
10
|
+
process.exitCode = exitCode;
|
|
11
|
+
})
|
|
12
|
+
.catch((err) => {
|
|
13
|
+
if (err instanceof index_1.CLIError) {
|
|
14
|
+
console.error(`charter: ${err.message}`);
|
|
15
|
+
process.exitCode = err.exitCode;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
19
|
+
console.error(`charter: ${msg}`);
|
|
20
|
+
process.exitCode = index_1.EXIT_CODE.RUNTIME_ERROR;
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;AAEA;;GAEG;;AAEH,mCAAmD;AAEnD,IAAA,WAAG,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACvB,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACjB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC9B,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IACtB,IAAI,GAAG,YAAY,gBAAQ,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACzC,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAChC,OAAO;IACT,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,CAAC,CAAC;IACjC,OAAO,CAAC,QAAQ,GAAG,iBAAS,CAAC,aAAa,CAAC;AAC7C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* charter audit
|
|
3
|
+
*
|
|
4
|
+
* Generates a governance audit report for the current repository.
|
|
5
|
+
* Summarizes governance coverage, pattern adoption, and policy compliance.
|
|
6
|
+
*/
|
|
7
|
+
import type { CLIOptions } from '../index';
|
|
8
|
+
export declare function auditCommand(options: CLIOptions): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAqC3C,wBAAsB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBvE"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* charter audit
|
|
4
|
+
*
|
|
5
|
+
* Generates a governance audit report for the current repository.
|
|
6
|
+
* Summarizes governance coverage, pattern adoption, and policy compliance.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.auditCommand = auditCommand;
|
|
43
|
+
const node_child_process_1 = require("node:child_process");
|
|
44
|
+
const fs = __importStar(require("node:fs"));
|
|
45
|
+
const index_1 = require("../index");
|
|
46
|
+
const config_1 = require("../config");
|
|
47
|
+
const git_1 = require("@stackbilt/git");
|
|
48
|
+
const git_2 = require("@stackbilt/git");
|
|
49
|
+
async function auditCommand(options) {
|
|
50
|
+
const config = (0, config_1.loadConfig)(options.configPath);
|
|
51
|
+
const patterns = (0, config_1.loadPatterns)(options.configPath);
|
|
52
|
+
const report = generateAuditReport(config.project, options.configPath, patterns);
|
|
53
|
+
if (options.format === 'json') {
|
|
54
|
+
console.log(JSON.stringify(report, null, 2));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
printReport(report);
|
|
58
|
+
}
|
|
59
|
+
if (options.ciMode && report.score.overall < 50) {
|
|
60
|
+
return index_1.EXIT_CODE.POLICY_VIOLATION;
|
|
61
|
+
}
|
|
62
|
+
return index_1.EXIT_CODE.SUCCESS;
|
|
63
|
+
}
|
|
64
|
+
function generateAuditReport(projectName, configPath, patterns) {
|
|
65
|
+
const commits = getRecentCommits(50);
|
|
66
|
+
const parsed = (0, git_1.parseAllTrailers)(commits);
|
|
67
|
+
const linkedCommits = new Set();
|
|
68
|
+
parsed.governedBy.forEach((t) => linkedCommits.add(t.commitSha));
|
|
69
|
+
parsed.resolvesRequest.forEach((t) => linkedCommits.add(t.commitSha));
|
|
70
|
+
let highRiskUnlinked = 0;
|
|
71
|
+
for (const commit of commits) {
|
|
72
|
+
if (!linkedCommits.has(commit.sha)) {
|
|
73
|
+
const risk = (0, git_2.assessCommitRisk)(commit.files_changed, commit.message);
|
|
74
|
+
if (risk === 'HIGH')
|
|
75
|
+
highRiskUnlinked++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const coveragePercent = commits.length > 0
|
|
79
|
+
? Math.round((linkedCommits.size / commits.length) * 100)
|
|
80
|
+
: 0;
|
|
81
|
+
const activePatterns = patterns.filter((p) => p.status === 'ACTIVE');
|
|
82
|
+
const categories = {};
|
|
83
|
+
for (const p of activePatterns) {
|
|
84
|
+
categories[p.category] = (categories[p.category] || 0) + 1;
|
|
85
|
+
}
|
|
86
|
+
const policiesDir = `${configPath}/policies`;
|
|
87
|
+
const policyFiles = fs.existsSync(policiesDir)
|
|
88
|
+
? fs.readdirSync(policiesDir).filter((f) => f.endsWith('.md'))
|
|
89
|
+
: [];
|
|
90
|
+
const trailerScore = Math.min(100, coveragePercent * 1.5);
|
|
91
|
+
const patternScore = Math.min(100, activePatterns.length * 20);
|
|
92
|
+
const policyScore = Math.min(100, policyFiles.length * 33);
|
|
93
|
+
const overall = Math.round((trailerScore * 0.5) + (patternScore * 0.3) + (policyScore * 0.2));
|
|
94
|
+
return {
|
|
95
|
+
project: projectName,
|
|
96
|
+
generatedAt: new Date().toISOString(),
|
|
97
|
+
configVersion: '0.1',
|
|
98
|
+
git: {
|
|
99
|
+
totalCommits: commits.length,
|
|
100
|
+
commitsWithTrailers: linkedCommits.size,
|
|
101
|
+
coveragePercent,
|
|
102
|
+
highRiskUnlinked,
|
|
103
|
+
governedByRefs: parsed.governedBy.map((t) => t.reference),
|
|
104
|
+
resolvesRequestRefs: parsed.resolvesRequest.map((t) => t.reference),
|
|
105
|
+
},
|
|
106
|
+
patterns: {
|
|
107
|
+
total: patterns.length,
|
|
108
|
+
active: activePatterns.length,
|
|
109
|
+
categories,
|
|
110
|
+
},
|
|
111
|
+
policies: {
|
|
112
|
+
files: policyFiles,
|
|
113
|
+
},
|
|
114
|
+
score: {
|
|
115
|
+
overall,
|
|
116
|
+
breakdown: {
|
|
117
|
+
trailerCoverage: Math.round(trailerScore),
|
|
118
|
+
patternDefinitions: Math.round(patternScore),
|
|
119
|
+
policyDocumentation: Math.round(policyScore),
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function printReport(report) {
|
|
125
|
+
const scoreIcon = report.score.overall >= 70 ? '[ok]'
|
|
126
|
+
: report.score.overall >= 40 ? '[warn]'
|
|
127
|
+
: '[fail]';
|
|
128
|
+
console.log('');
|
|
129
|
+
console.log(' Charter Governance Audit');
|
|
130
|
+
console.log(` Project: ${report.project}`);
|
|
131
|
+
console.log(` Score: ${scoreIcon} ${report.score.overall}/100`);
|
|
132
|
+
console.log('');
|
|
133
|
+
console.log(' Git Governance Coverage');
|
|
134
|
+
console.log(` Commits analyzed: ${report.git.totalCommits}`);
|
|
135
|
+
console.log(` With trailers: ${report.git.commitsWithTrailers} (${report.git.coveragePercent}%)`);
|
|
136
|
+
console.log(` High-risk unlinked: ${report.git.highRiskUnlinked}`);
|
|
137
|
+
console.log('');
|
|
138
|
+
console.log(' Blessed Stack Patterns');
|
|
139
|
+
console.log(` Total defined: ${report.patterns.total}`);
|
|
140
|
+
console.log(` Active: ${report.patterns.active}`);
|
|
141
|
+
console.log(` Categories: ${Object.entries(report.patterns.categories).map(([k, v]) => `${k}(${v})`).join(', ') || 'none'}`);
|
|
142
|
+
console.log('');
|
|
143
|
+
console.log(' Policy Documentation');
|
|
144
|
+
console.log(` Policy files: ${report.policies.files.length}`);
|
|
145
|
+
for (const file of report.policies.files) {
|
|
146
|
+
console.log(` - ${file}`);
|
|
147
|
+
}
|
|
148
|
+
console.log('');
|
|
149
|
+
console.log(' Score Breakdown');
|
|
150
|
+
console.log(` Trailer coverage: ${report.score.breakdown.trailerCoverage}/100 (50% weight)`);
|
|
151
|
+
console.log(` Pattern definitions: ${report.score.breakdown.patternDefinitions}/100 (30% weight)`);
|
|
152
|
+
console.log(` Policy documentation: ${report.score.breakdown.policyDocumentation}/100 (20% weight)`);
|
|
153
|
+
console.log('');
|
|
154
|
+
}
|
|
155
|
+
function getRecentCommits(count) {
|
|
156
|
+
try {
|
|
157
|
+
const log = (0, node_child_process_1.execSync)(`git log -${count} --format='%H|%an|%aI|%B---END---' --name-only 2>/dev/null`, { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
|
|
158
|
+
const commits = [];
|
|
159
|
+
const entries = log.split('---END---');
|
|
160
|
+
for (const entry of entries) {
|
|
161
|
+
const lines = entry.trim().split('\n').filter((l) => l.trim());
|
|
162
|
+
if (lines.length === 0)
|
|
163
|
+
continue;
|
|
164
|
+
const firstLine = lines[0];
|
|
165
|
+
if (!firstLine.includes('|'))
|
|
166
|
+
continue;
|
|
167
|
+
const pipeIdx = firstLine.indexOf('|');
|
|
168
|
+
const sha = firstLine.slice(0, pipeIdx).replace(/'/g, '');
|
|
169
|
+
const rest = firstLine.slice(pipeIdx + 1);
|
|
170
|
+
const [author, timestamp, ...msgParts] = rest.split('|');
|
|
171
|
+
const files = [];
|
|
172
|
+
for (let i = 1; i < lines.length; i++) {
|
|
173
|
+
const line = lines[i].trim();
|
|
174
|
+
if (line && !line.includes('|')) {
|
|
175
|
+
files.push(line);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
commits.push({
|
|
179
|
+
sha,
|
|
180
|
+
author: author || 'unknown',
|
|
181
|
+
timestamp: timestamp || new Date().toISOString(),
|
|
182
|
+
message: msgParts.join('|') || '',
|
|
183
|
+
files_changed: files,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return commits;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCH,oCAiBC;AAxDD,2DAA8C;AAC9C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,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;YAED,OAAO,CAAC,IAAI,CAAC;gBACX,GAAG;gBACH,MAAM,EAAE,MAAM,IAAI,SAAS;gBAC3B,SAAS,EAAE,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBAChD,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;gBACjC,aAAa,EAAE,KAAK;aACrB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* charter classify <subject>
|
|
3
|
+
*
|
|
4
|
+
* Classifies a change description as SURFACE/LOCAL/CROSS_CUTTING.
|
|
5
|
+
* Pure heuristic - no LLM required.
|
|
6
|
+
*/
|
|
7
|
+
import type { CLIOptions } from '../index';
|
|
8
|
+
export declare function classifyCommand(options: CLIOptions, args: string[]): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=classify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/commands/classify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,wBAAsB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA0C1F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* charter classify <subject>
|
|
4
|
+
*
|
|
5
|
+
* Classifies a change description as SURFACE/LOCAL/CROSS_CUTTING.
|
|
6
|
+
* Pure heuristic - no LLM required.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.classifyCommand = classifyCommand;
|
|
10
|
+
const index_1 = require("../index");
|
|
11
|
+
const classify_1 = require("@stackbilt/classify");
|
|
12
|
+
async function classifyCommand(options, args) {
|
|
13
|
+
const subject = args.filter((a) => !a.startsWith('--')).join(' ');
|
|
14
|
+
if (!subject) {
|
|
15
|
+
throw new index_1.CLIError('Usage: charter classify <change description>\nExample: charter classify "Add OAuth2 integration for partner API"');
|
|
16
|
+
}
|
|
17
|
+
const result = (0, classify_1.heuristicClassify)(subject);
|
|
18
|
+
const recommendation = (0, classify_1.determineRecommendation)(result.suggestedClass, 'CLEAR', false);
|
|
19
|
+
if (options.format === 'json') {
|
|
20
|
+
console.log(JSON.stringify({ ...result, recommendation }, null, 2));
|
|
21
|
+
return index_1.EXIT_CODE.SUCCESS;
|
|
22
|
+
}
|
|
23
|
+
const icon = result.suggestedClass === 'CROSS_CUTTING' ? '[high]'
|
|
24
|
+
: result.suggestedClass === 'LOCAL' ? '[mid]'
|
|
25
|
+
: '[low]';
|
|
26
|
+
const recIcon = recommendation === 'APPROVE' ? '[ok]'
|
|
27
|
+
: recommendation === 'ESCALATE' ? '[escalate]'
|
|
28
|
+
: '[warn]';
|
|
29
|
+
console.log('');
|
|
30
|
+
console.log(` ${icon} Classification: ${result.suggestedClass}`);
|
|
31
|
+
console.log(` Confidence: ${result.confidence}`);
|
|
32
|
+
console.log(` Recommendation: ${recIcon} ${recommendation}`);
|
|
33
|
+
console.log('');
|
|
34
|
+
console.log(' Signals:');
|
|
35
|
+
for (const signal of result.signals) {
|
|
36
|
+
console.log(` - ${signal}`);
|
|
37
|
+
}
|
|
38
|
+
console.log('');
|
|
39
|
+
if (result.suggestedClass === 'CROSS_CUTTING') {
|
|
40
|
+
console.log(' [warn] Cross-cutting changes require architectural review.');
|
|
41
|
+
console.log('');
|
|
42
|
+
}
|
|
43
|
+
return index_1.EXIT_CODE.SUCCESS;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=classify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../../src/commands/classify.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,0CA0CC;AA7CD,oCAA+C;AAC/C,kDAAiF;AAE1E,KAAK,UAAU,eAAe,CAAC,OAAmB,EAAE,IAAc;IACvE,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAElE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,gBAAQ,CAChB,kHAAkH,CACnH,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,4BAAiB,EAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAA,kCAAuB,EAAC,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAEtF,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACpE,OAAO,iBAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,cAAc,KAAK,eAAe,CAAC,CAAC,CAAC,QAAQ;QAC/D,CAAC,CAAC,MAAM,CAAC,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO;YAC7C,CAAC,CAAC,OAAO,CAAC;IAEZ,MAAM,OAAO,GAAG,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM;QACnD,CAAC,CAAC,cAAc,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY;YAC9C,CAAC,CAAC,QAAQ,CAAC;IAEb,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,oBAAoB,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IAClE,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,wBAAwB,OAAO,IAAI,cAAc,EAAE,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,IAAI,MAAM,CAAC,cAAc,KAAK,eAAe,EAAE,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,iBAAS,CAAC,OAAO,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* charter doctor
|
|
3
|
+
*
|
|
4
|
+
* Prints environment and configuration diagnostics for humans and agents.
|
|
5
|
+
*/
|
|
6
|
+
import type { CLIOptions } from '../index';
|
|
7
|
+
export declare function doctorCommand(options: CLIOptions): Promise<number>;
|
|
8
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAa3C,wBAAsB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA+DxE"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* charter doctor
|
|
4
|
+
*
|
|
5
|
+
* Prints environment and configuration diagnostics for humans and agents.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.doctorCommand = doctorCommand;
|
|
42
|
+
const node_child_process_1 = require("node:child_process");
|
|
43
|
+
const fs = __importStar(require("node:fs"));
|
|
44
|
+
const path = __importStar(require("node:path"));
|
|
45
|
+
const index_1 = require("../index");
|
|
46
|
+
const config_1 = require("../config");
|
|
47
|
+
async function doctorCommand(options) {
|
|
48
|
+
const checks = [];
|
|
49
|
+
const configFile = path.join(options.configPath, 'config.json');
|
|
50
|
+
const inGitRepo = isGitRepo();
|
|
51
|
+
checks.push({
|
|
52
|
+
name: 'git repository',
|
|
53
|
+
status: inGitRepo ? 'PASS' : 'WARN',
|
|
54
|
+
details: inGitRepo ? 'Repository detected.' : 'Not inside a git repository.',
|
|
55
|
+
});
|
|
56
|
+
const hasConfig = fs.existsSync(configFile);
|
|
57
|
+
checks.push({
|
|
58
|
+
name: 'config file',
|
|
59
|
+
status: hasConfig ? 'PASS' : 'WARN',
|
|
60
|
+
details: hasConfig ? `${configFile} exists.` : `${configFile} not found. Run charter setup.`,
|
|
61
|
+
});
|
|
62
|
+
if (hasConfig) {
|
|
63
|
+
checks.push(validateJSONConfig(configFile));
|
|
64
|
+
}
|
|
65
|
+
const patterns = (0, config_1.loadPatterns)(options.configPath);
|
|
66
|
+
checks.push({
|
|
67
|
+
name: 'patterns',
|
|
68
|
+
status: patterns.length > 0 ? 'PASS' : 'WARN',
|
|
69
|
+
details: patterns.length > 0
|
|
70
|
+
? `${patterns.length} pattern(s) loaded.`
|
|
71
|
+
: 'No patterns found in .charter/patterns/*.json.',
|
|
72
|
+
});
|
|
73
|
+
const policyDir = path.join(options.configPath, 'policies');
|
|
74
|
+
const policyCount = fs.existsSync(policyDir)
|
|
75
|
+
? fs.readdirSync(policyDir).filter((f) => f.endsWith('.md')).length
|
|
76
|
+
: 0;
|
|
77
|
+
checks.push({
|
|
78
|
+
name: 'policy docs',
|
|
79
|
+
status: policyCount > 0 ? 'PASS' : 'WARN',
|
|
80
|
+
details: policyCount > 0 ? `${policyCount} markdown policy file(s).` : 'No policy markdown files found.',
|
|
81
|
+
});
|
|
82
|
+
const hasWarn = checks.some((check) => check.status === 'WARN');
|
|
83
|
+
const result = {
|
|
84
|
+
status: hasWarn ? 'WARN' : 'PASS',
|
|
85
|
+
checks,
|
|
86
|
+
};
|
|
87
|
+
if (options.format === 'json') {
|
|
88
|
+
console.log(JSON.stringify(result, null, 2));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.log(` Doctor status: ${result.status}`);
|
|
92
|
+
for (const check of result.checks) {
|
|
93
|
+
const icon = check.status === 'PASS' ? '[ok]' : '[warn]';
|
|
94
|
+
console.log(` ${icon} ${check.name}: ${check.details}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (options.ciMode && hasWarn) {
|
|
98
|
+
return index_1.EXIT_CODE.POLICY_VIOLATION;
|
|
99
|
+
}
|
|
100
|
+
return index_1.EXIT_CODE.SUCCESS;
|
|
101
|
+
}
|
|
102
|
+
function isGitRepo() {
|
|
103
|
+
try {
|
|
104
|
+
(0, node_child_process_1.execSync)('git rev-parse --is-inside-work-tree', {
|
|
105
|
+
stdio: 'ignore',
|
|
106
|
+
});
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function validateJSONConfig(configFile) {
|
|
114
|
+
try {
|
|
115
|
+
JSON.parse(fs.readFileSync(configFile, 'utf-8'));
|
|
116
|
+
return {
|
|
117
|
+
name: 'config parse',
|
|
118
|
+
status: 'PASS',
|
|
119
|
+
details: 'config.json is valid JSON.',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return {
|
|
124
|
+
name: 'config parse',
|
|
125
|
+
status: 'WARN',
|
|
126
|
+
details: 'config.json is invalid JSON.',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBH,sCA+DC;AA/ED,2DAA8C;AAC9C,4CAA8B;AAC9B,gDAAkC;AAElC,oCAAqC;AACrC,sCAAyC;AAWlC,KAAK,UAAU,aAAa,CAAC,OAAmB;IACrD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;IAE9B,MAAM,CAAC,IAAI,CAAC;QACV,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACnC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,8BAA8B;KAC7E,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,CAAC,IAAI,CAAC;QACV,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACnC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,UAAU,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,gCAAgC;KAC7F,CAAC,CAAC;IAEH,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC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B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,8BAA8B;SACxC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* charter drift
|
|
3
|
+
*
|
|
4
|
+
* Scans files for governance drift - codebase patterns that violate
|
|
5
|
+
* the blessed stack defined in .charter/patterns/.
|
|
6
|
+
*/
|
|
7
|
+
import type { CLIOptions } from '../index';
|
|
8
|
+
export declare function driftCommand(options: CLIOptions, args: string[]): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=drift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/commands/drift.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAM3C,wBAAsB,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA4CvF"}
|