@ai-dossier/cli 0.2.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/README.md +419 -0
- package/bin/ai-dossier +3 -0
- package/bin/dossier-verify +435 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +77 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/cache.d.ts +3 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +239 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/checksum.d.ts +3 -0
- package/dist/commands/checksum.d.ts.map +1 -0
- package/dist/commands/checksum.js +116 -0
- package/dist/commands/checksum.js.map +1 -0
- package/dist/commands/config-cmd.d.ts +3 -0
- package/dist/commands/config-cmd.d.ts.map +1 -0
- package/dist/commands/config-cmd.js +117 -0
- package/dist/commands/config-cmd.js.map +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +130 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/export.d.ts +3 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +55 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/format.d.ts +3 -0
- package/dist/commands/format.d.ts.map +1 -0
- package/dist/commands/format.js +66 -0
- package/dist/commands/format.js.map +1 -0
- package/dist/commands/from-file.d.ts +3 -0
- package/dist/commands/from-file.d.ts.map +1 -0
- package/dist/commands/from-file.js +136 -0
- package/dist/commands/from-file.js.map +1 -0
- package/dist/commands/get.d.ts +3 -0
- package/dist/commands/get.d.ts.map +1 -0
- package/dist/commands/get.js +65 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +159 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +98 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install-skill.d.ts +3 -0
- package/dist/commands/install-skill.d.ts.map +1 -0
- package/dist/commands/install-skill.js +131 -0
- package/dist/commands/install-skill.js.map +1 -0
- package/dist/commands/keys.d.ts +3 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +170 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/lint.d.ts +3 -0
- package/dist/commands/lint.d.ts.map +1 -0
- package/dist/commands/lint.js +105 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +173 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +33 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +19 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/prompt-hook.d.ts +3 -0
- package/dist/commands/prompt-hook.d.ts.map +1 -0
- package/dist/commands/prompt-hook.js +101 -0
- package/dist/commands/prompt-hook.js.map +1 -0
- package/dist/commands/publish.d.ts +3 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +142 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/pull.d.ts +3 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +69 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/remove.d.ts +3 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +65 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/reset-hooks.d.ts +3 -0
- package/dist/commands/reset-hooks.d.ts.map +1 -0
- package/dist/commands/reset-hooks.js +52 -0
- package/dist/commands/reset-hooks.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +281 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/search.d.ts +3 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +137 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/sign.d.ts +3 -0
- package/dist/commands/sign.d.ts.map +1 -0
- package/dist/commands/sign.js +143 -0
- package/dist/commands/sign.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +152 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +41 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +28 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +87 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +29 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +98 -0
- package/dist/credentials.js.map +1 -0
- package/dist/github-url.d.ts +22 -0
- package/dist/github-url.d.ts.map +1 -0
- package/dist/github-url.js +34 -0
- package/dist/github-url.js.map +1 -0
- package/dist/helpers.d.ts +145 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +597 -0
- package/dist/helpers.js.map +1 -0
- package/dist/hooks.d.ts +38 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +155 -0
- package/dist/hooks.js.map +1 -0
- package/dist/oauth.d.ts +22 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +118 -0
- package/dist/oauth.js.map +1 -0
- package/dist/registry-client.d.ts +86 -0
- package/dist/registry-client.d.ts.map +1 -0
- package/dist/registry-client.js +225 -0
- package/dist/registry-client.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerValidateCommand = registerValidateCommand;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const helpers_1 = require("../helpers");
|
|
10
|
+
function registerValidateCommand(program) {
|
|
11
|
+
program
|
|
12
|
+
.command('validate')
|
|
13
|
+
.description('Validate dossier frontmatter structure')
|
|
14
|
+
.argument('<file>', 'Dossier file to validate')
|
|
15
|
+
.option('--strict', 'Treat warnings as errors')
|
|
16
|
+
.option('--quiet', 'Only output errors (no warnings)')
|
|
17
|
+
.option('--json', 'Output results as JSON')
|
|
18
|
+
.action((file, options) => {
|
|
19
|
+
const dossierFile = node_path_1.default.resolve(file);
|
|
20
|
+
if (!node_fs_1.default.existsSync(dossierFile)) {
|
|
21
|
+
if (options.json) {
|
|
22
|
+
console.log(JSON.stringify({
|
|
23
|
+
valid: false,
|
|
24
|
+
errors: [`File not found: ${dossierFile}`],
|
|
25
|
+
warnings: [],
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log(`❌ File not found: ${dossierFile}`);
|
|
30
|
+
}
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const content = node_fs_1.default.readFileSync(dossierFile, 'utf8');
|
|
34
|
+
const errors = [];
|
|
35
|
+
const warnings = [];
|
|
36
|
+
let frontmatter = null;
|
|
37
|
+
const jsonMatch = content.match(/^---dossier\s*\n([\s\S]*?)\n---/);
|
|
38
|
+
const yamlMatch = !jsonMatch && content.match(/^---\s*\n([\s\S]*?)\n---/);
|
|
39
|
+
if (jsonMatch) {
|
|
40
|
+
try {
|
|
41
|
+
frontmatter = JSON.parse(jsonMatch[1]);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
errors.push(`Invalid JSON in frontmatter: ${err.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (yamlMatch) {
|
|
48
|
+
warnings.push('YAML frontmatter detected - basic validation only');
|
|
49
|
+
frontmatter = {};
|
|
50
|
+
const lines = yamlMatch[1].split('\n');
|
|
51
|
+
for (const line of lines) {
|
|
52
|
+
const match = line.match(/^(\w+):\s*(.*)$/);
|
|
53
|
+
if (match) {
|
|
54
|
+
let value = match[2].trim();
|
|
55
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
56
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
57
|
+
value = value.slice(1, -1);
|
|
58
|
+
}
|
|
59
|
+
frontmatter[match[1]] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
errors.push('No frontmatter found. Expected ---dossier or --- at start of file.');
|
|
65
|
+
}
|
|
66
|
+
if (frontmatter && errors.length === 0) {
|
|
67
|
+
for (const field of helpers_1.REQUIRED_FIELDS) {
|
|
68
|
+
if (!frontmatter[field]) {
|
|
69
|
+
errors.push(`Missing required field: ${field}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!options.quiet) {
|
|
73
|
+
for (const field of helpers_1.RECOMMENDED_FIELDS) {
|
|
74
|
+
if (!frontmatter[field]) {
|
|
75
|
+
warnings.push(`Missing recommended field: ${field}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (frontmatter.risk_level &&
|
|
80
|
+
!helpers_1.VALID_RISK_LEVELS.includes(frontmatter.risk_level.toLowerCase())) {
|
|
81
|
+
warnings.push(`Unknown risk_level: "${frontmatter.risk_level}" (expected: ${helpers_1.VALID_RISK_LEVELS.join(', ')})`);
|
|
82
|
+
}
|
|
83
|
+
if (frontmatter.status && !helpers_1.VALID_STATUSES.includes(frontmatter.status)) {
|
|
84
|
+
warnings.push(`Unknown status: "${frontmatter.status}" (expected: ${helpers_1.VALID_STATUSES.join(', ')})`);
|
|
85
|
+
}
|
|
86
|
+
if (frontmatter.version && !/^\d+\.\d+(\.\d+)?(-[\w.]+)?$/.test(frontmatter.version)) {
|
|
87
|
+
warnings.push(`Version "${frontmatter.version}" doesn't follow semver format (e.g., 1.0.0)`);
|
|
88
|
+
}
|
|
89
|
+
if (frontmatter.dossier_schema_version && frontmatter.dossier_schema_version !== '1.0.0') {
|
|
90
|
+
warnings.push(`Unknown schema version: ${frontmatter.dossier_schema_version} (current: 1.0.0)`);
|
|
91
|
+
}
|
|
92
|
+
if (frontmatter.signature && !frontmatter.checksum) {
|
|
93
|
+
warnings.push('Dossier is signed but has no checksum');
|
|
94
|
+
}
|
|
95
|
+
if (!options.quiet && frontmatter.risk_level) {
|
|
96
|
+
const risk = frontmatter.risk_level.toLowerCase();
|
|
97
|
+
if ((risk === 'high' || risk === 'critical') && !frontmatter.signature) {
|
|
98
|
+
warnings.push(`${risk}-risk dossier is not signed`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const hasErrors = errors.length > 0;
|
|
103
|
+
const hasWarnings = warnings.length > 0;
|
|
104
|
+
const valid = options.strict ? !hasErrors && !hasWarnings : !hasErrors;
|
|
105
|
+
if (options.json) {
|
|
106
|
+
console.log(JSON.stringify({
|
|
107
|
+
valid,
|
|
108
|
+
file: dossierFile,
|
|
109
|
+
errors,
|
|
110
|
+
warnings,
|
|
111
|
+
frontmatter: frontmatter
|
|
112
|
+
? {
|
|
113
|
+
title: frontmatter.title,
|
|
114
|
+
version: frontmatter.version,
|
|
115
|
+
schema_version: frontmatter.dossier_schema_version,
|
|
116
|
+
}
|
|
117
|
+
: null,
|
|
118
|
+
}, null, 2));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.log(`\n📋 Dossier Validation\n`);
|
|
122
|
+
console.log(` File: ${node_path_1.default.basename(dossierFile)}`);
|
|
123
|
+
if (frontmatter?.title) {
|
|
124
|
+
console.log(` Title: ${frontmatter.title}`);
|
|
125
|
+
}
|
|
126
|
+
if (frontmatter?.version) {
|
|
127
|
+
console.log(` Version: ${frontmatter.version}`);
|
|
128
|
+
}
|
|
129
|
+
if (errors.length > 0) {
|
|
130
|
+
console.log(`\n❌ Errors (${errors.length}):`);
|
|
131
|
+
for (const err of errors) {
|
|
132
|
+
console.log(` • ${err}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (warnings.length > 0 && !options.quiet) {
|
|
136
|
+
console.log(`\n⚠️ Warnings (${warnings.length}):`);
|
|
137
|
+
for (const warn of warnings) {
|
|
138
|
+
console.log(` • ${warn}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (valid) {
|
|
142
|
+
console.log(`\n✅ Valid${hasWarnings ? ' (with warnings)' : ''}`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.log(`\n❌ Invalid`);
|
|
146
|
+
}
|
|
147
|
+
console.log('');
|
|
148
|
+
}
|
|
149
|
+
process.exit(valid ? 0 : 1);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":";;;;;AAKA,0DA8KC;AAnLD,sDAAyB;AACzB,0DAA6B;AAE7B,wCAAoG;AAEpG,SAAgB,uBAAuB,CAAC,OAAgB;IACtD,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,wCAAwC,CAAC;SACrD,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,CAAC;SAC9C,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;SAC9C,MAAM,CAAC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"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqC5D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerVerifyCommand = registerVerifyCommand;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
function registerVerifyCommand(program) {
|
|
6
|
+
program
|
|
7
|
+
.command('verify')
|
|
8
|
+
.description('Verify dossier integrity and authenticity')
|
|
9
|
+
.argument('<file>', 'Dossier file or URL to verify')
|
|
10
|
+
.option('--verbose', 'Show detailed verification output')
|
|
11
|
+
.option('--skip-checksum', 'Skip checksum verification (DANGEROUS)')
|
|
12
|
+
.option('--skip-signature', 'Skip signature verification')
|
|
13
|
+
.option('--skip-author-check', 'Skip author whitelist/blacklist')
|
|
14
|
+
.option('--skip-dossier-check', 'Skip dossier whitelist/blacklist')
|
|
15
|
+
.option('--skip-risk-assessment', 'Skip risk level checks')
|
|
16
|
+
.option('--skip-review', 'Skip review dossier execution')
|
|
17
|
+
.option('--skip-all-checks', 'Skip ALL verifications (VERY DANGEROUS)')
|
|
18
|
+
.option('--review-dossier <file>', 'Custom review dossier')
|
|
19
|
+
.action(async (file, options) => {
|
|
20
|
+
const result = await (0, helpers_1.runVerification)(file, options);
|
|
21
|
+
if (!result.passed) {
|
|
22
|
+
console.log('❌ Verification failed\n');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
if (options.verbose) {
|
|
26
|
+
console.log('✅ All verification stages passed\n');
|
|
27
|
+
console.log('Stages completed:');
|
|
28
|
+
result.stages.forEach((s) => {
|
|
29
|
+
const status = s.passed ? '✅' : s.skipped ? '⚠️' : '❌';
|
|
30
|
+
const demo = s.demo ? ' (demo)' : '';
|
|
31
|
+
console.log(` ${status} Stage ${s.stage}: ${s.name}${demo}`);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log('✅ Verification passed\n');
|
|
36
|
+
console.log('Run with --verbose for detailed stage information');
|
|
37
|
+
}
|
|
38
|
+
process.exit(0);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/commands/verify.ts"],"names":[],"mappings":";;AAIA,sDAqCC;AAvCD,wCAA6C;AAE7C,SAAgB,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,2CAA2C,CAAC;SACxD,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,CAAC;SACnD,MAAM,CAAC,WAAW,EAAE,mCAAmC,CAAC;SACxD,MAAM,CAAC,iBAAiB,EAAE,wCAAwC,CAAC;SACnE,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC;SACzD,MAAM,CAAC,qBAAqB,EAAE,iCAAiC,CAAC;SAChE,MAAM,CAAC,sBAAsB,EAAE,kCAAkC,CAAC;SAClE,MAAM,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;SAC1D,MAAM,CAAC,eAAe,EAAE,+BAA+B,CAAC;SACxD,MAAM,CAAC,mBAAmB,EAAE,yCAAyC,CAAC;SACtE,MAAM,CAAC,yBAAyB,EAAE,uBAAuB,CAAC;SAC1D,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,OAAoD,EAAE,EAAE;QACnF,MAAM,MAAM,GAAG,MAAM,IAAA,yBAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEpD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YACjC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC1B,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;gBACvD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrC,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,UAAU,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;YAChE,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwB5D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerWhoamiCommand = registerWhoamiCommand;
|
|
4
|
+
const credentials_1 = require("../credentials");
|
|
5
|
+
function registerWhoamiCommand(program) {
|
|
6
|
+
program
|
|
7
|
+
.command('whoami')
|
|
8
|
+
.description('Show current registry user')
|
|
9
|
+
.action(() => {
|
|
10
|
+
const credentials = (0, credentials_1.loadCredentials)();
|
|
11
|
+
if (!credentials) {
|
|
12
|
+
console.log('\nℹ️ Not logged in');
|
|
13
|
+
console.log(' Run `dossier login` to authenticate\n');
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
if ((0, credentials_1.isExpired)(credentials)) {
|
|
17
|
+
console.log('\n⚠️ Credentials expired');
|
|
18
|
+
console.log(' Run `dossier login` to re-authenticate\n');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
console.log(`\n👤 ${credentials.username}`);
|
|
22
|
+
if (credentials.orgs.length > 0) {
|
|
23
|
+
console.log(` Organizations: ${credentials.orgs.join(', ')}`);
|
|
24
|
+
}
|
|
25
|
+
console.log('');
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;AAGA,sDAwBC;AA1BD,gDAA4D;AAE5D,SAAgB,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,4BAA4B,CAAC;SACzC,MAAM,CAAC,GAAG,EAAE;QACX,MAAM,WAAW,GAAG,IAAA,6BAAe,GAAE,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,IAAA,uBAAS,EAAC,WAAW,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACzC,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,QAAQ,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC5C,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,qBAAqB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for Dossier CLI
|
|
3
|
+
* Handles reading and writing user preferences to ~/.dossier/config.json
|
|
4
|
+
*/
|
|
5
|
+
export interface DossierConfig {
|
|
6
|
+
defaultLlm: string;
|
|
7
|
+
theme: string;
|
|
8
|
+
auditLog: boolean;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
declare const CONFIG_DIR: string;
|
|
12
|
+
declare const CONFIG_FILE: string;
|
|
13
|
+
declare const DEFAULT_CONFIG: DossierConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Ensure config directory exists
|
|
16
|
+
*/
|
|
17
|
+
declare function ensureConfigDir(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Load configuration from file
|
|
20
|
+
*/
|
|
21
|
+
declare function loadConfig(): DossierConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Save configuration to file
|
|
24
|
+
*/
|
|
25
|
+
declare function saveConfig(config: DossierConfig): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get a specific config value
|
|
28
|
+
*/
|
|
29
|
+
declare function getConfig(key: string): unknown;
|
|
30
|
+
/**
|
|
31
|
+
* Set a specific config value
|
|
32
|
+
*/
|
|
33
|
+
declare function setConfig(key: string, value: unknown): boolean;
|
|
34
|
+
export { ensureConfigDir, loadConfig, saveConfig, getConfig, setConfig, CONFIG_DIR, CONFIG_FILE, DEFAULT_CONFIG, };
|
|
35
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,UAAU,QAAsC,CAAC;AACvD,QAAA,MAAM,WAAW,QAAuC,CAAC;AAEzD,QAAA,MAAM,cAAc,EAAE,aAIrB,CAAC;AAEF;;GAEG;AACH,iBAAS,eAAe,IAAI,IAAI,CAI/B;AAED;;GAEG;AACH,iBAAS,UAAU,IAAI,aAAa,CAenC;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAYlD;AAED;;GAEG;AACH,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGvC;AAED;;GAEG;AACH,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAIvD;AAED,OAAO,EACL,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,cAAc,GACf,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration management for Dossier CLI
|
|
4
|
+
* Handles reading and writing user preferences to ~/.dossier/config.json
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.DEFAULT_CONFIG = exports.CONFIG_FILE = exports.CONFIG_DIR = void 0;
|
|
11
|
+
exports.ensureConfigDir = ensureConfigDir;
|
|
12
|
+
exports.loadConfig = loadConfig;
|
|
13
|
+
exports.saveConfig = saveConfig;
|
|
14
|
+
exports.getConfig = getConfig;
|
|
15
|
+
exports.setConfig = setConfig;
|
|
16
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
|
+
const CONFIG_DIR = node_path_1.default.join(node_os_1.default.homedir(), '.dossier');
|
|
20
|
+
exports.CONFIG_DIR = CONFIG_DIR;
|
|
21
|
+
const CONFIG_FILE = node_path_1.default.join(CONFIG_DIR, 'config.json');
|
|
22
|
+
exports.CONFIG_FILE = CONFIG_FILE;
|
|
23
|
+
const DEFAULT_CONFIG = {
|
|
24
|
+
defaultLlm: 'auto',
|
|
25
|
+
theme: 'auto',
|
|
26
|
+
auditLog: true,
|
|
27
|
+
};
|
|
28
|
+
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
29
|
+
/**
|
|
30
|
+
* Ensure config directory exists
|
|
31
|
+
*/
|
|
32
|
+
function ensureConfigDir() {
|
|
33
|
+
if (!node_fs_1.default.existsSync(CONFIG_DIR)) {
|
|
34
|
+
node_fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load configuration from file
|
|
39
|
+
*/
|
|
40
|
+
function loadConfig() {
|
|
41
|
+
try {
|
|
42
|
+
if (!node_fs_1.default.existsSync(CONFIG_FILE)) {
|
|
43
|
+
return { ...DEFAULT_CONFIG };
|
|
44
|
+
}
|
|
45
|
+
const configData = node_fs_1.default.readFileSync(CONFIG_FILE, 'utf8');
|
|
46
|
+
const config = JSON.parse(configData);
|
|
47
|
+
// Merge with defaults to ensure all keys exist
|
|
48
|
+
return { ...DEFAULT_CONFIG, ...config };
|
|
49
|
+
}
|
|
50
|
+
catch (_error) {
|
|
51
|
+
console.error('⚠️ Warning: Could not read config file, using defaults');
|
|
52
|
+
return { ...DEFAULT_CONFIG };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Save configuration to file
|
|
57
|
+
*/
|
|
58
|
+
function saveConfig(config) {
|
|
59
|
+
try {
|
|
60
|
+
ensureConfigDir();
|
|
61
|
+
node_fs_1.default.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), {
|
|
62
|
+
encoding: 'utf8',
|
|
63
|
+
mode: 0o600,
|
|
64
|
+
});
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('❌ Error: Could not save config file:', error.message);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get a specific config value
|
|
74
|
+
*/
|
|
75
|
+
function getConfig(key) {
|
|
76
|
+
const config = loadConfig();
|
|
77
|
+
return config[key];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Set a specific config value
|
|
81
|
+
*/
|
|
82
|
+
function setConfig(key, value) {
|
|
83
|
+
const config = loadConfig();
|
|
84
|
+
config[key] = value;
|
|
85
|
+
return saveConfig(config);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAsFD,0CAAe;AACf,gCAAU;AACV,gCAAU;AACV,8BAAS;AAC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AAC;QACH,eAAe,EAAE,CAAC;QAClB,iBAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;YAC7D,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QAChF,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,GAAW,EAAE,KAAc;IAC5C,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACpB,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential storage for Dossier registry authentication.
|
|
3
|
+
* Stores credentials at ~/.dossier/credentials.json with secure file permissions.
|
|
4
|
+
*/
|
|
5
|
+
export interface Credentials {
|
|
6
|
+
token: string;
|
|
7
|
+
username: string;
|
|
8
|
+
orgs: string[];
|
|
9
|
+
expiresAt: string | null;
|
|
10
|
+
}
|
|
11
|
+
declare const CREDENTIALS_FILE: string;
|
|
12
|
+
/**
|
|
13
|
+
* Save credentials to file with secure permissions (0600).
|
|
14
|
+
*/
|
|
15
|
+
declare function saveCredentials(credentials: Credentials): void;
|
|
16
|
+
/**
|
|
17
|
+
* Load credentials from file.
|
|
18
|
+
*/
|
|
19
|
+
declare function loadCredentials(): Credentials | null;
|
|
20
|
+
/**
|
|
21
|
+
* Delete the credentials file.
|
|
22
|
+
*/
|
|
23
|
+
declare function deleteCredentials(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check if credentials are expired.
|
|
26
|
+
*/
|
|
27
|
+
declare function isExpired(credentials: Pick<Credentials, 'expiresAt'>): boolean;
|
|
28
|
+
export { CREDENTIALS_FILE, saveCredentials, loadCredentials, deleteCredentials, isExpired };
|
|
29
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,QAAA,MAAM,gBAAgB,QAA4C,CAAC;AAWnE;;GAEG;AACH,iBAAS,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CASvD;AAED;;GAEG;AACH,iBAAS,eAAe,IAAI,WAAW,GAAG,IAAI,CA8B7C;AAED;;GAEG;AACH,iBAAS,iBAAiB,IAAI,OAAO,CAMpC;AAED;;GAEG;AACH,iBAAS,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,OAAO,CAUvE;AAED,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Credential storage for Dossier registry authentication.
|
|
4
|
+
* Stores credentials at ~/.dossier/credentials.json with secure file permissions.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CREDENTIALS_FILE = void 0;
|
|
11
|
+
exports.saveCredentials = saveCredentials;
|
|
12
|
+
exports.loadCredentials = loadCredentials;
|
|
13
|
+
exports.deleteCredentials = deleteCredentials;
|
|
14
|
+
exports.isExpired = isExpired;
|
|
15
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
const config_1 = require("./config");
|
|
18
|
+
const CREDENTIALS_FILE = node_path_1.default.join(config_1.CONFIG_DIR, 'credentials.json');
|
|
19
|
+
exports.CREDENTIALS_FILE = CREDENTIALS_FILE;
|
|
20
|
+
/**
|
|
21
|
+
* Ensure the config directory exists.
|
|
22
|
+
*/
|
|
23
|
+
function ensureConfigDir() {
|
|
24
|
+
if (!node_fs_1.default.existsSync(config_1.CONFIG_DIR)) {
|
|
25
|
+
node_fs_1.default.mkdirSync(config_1.CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Save credentials to file with secure permissions (0600).
|
|
30
|
+
*/
|
|
31
|
+
function saveCredentials(credentials) {
|
|
32
|
+
ensureConfigDir();
|
|
33
|
+
const data = {
|
|
34
|
+
token: credentials.token,
|
|
35
|
+
username: credentials.username,
|
|
36
|
+
orgs: credentials.orgs || [],
|
|
37
|
+
expires_at: credentials.expiresAt || null,
|
|
38
|
+
};
|
|
39
|
+
node_fs_1.default.writeFileSync(CREDENTIALS_FILE, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Load credentials from file.
|
|
43
|
+
*/
|
|
44
|
+
function loadCredentials() {
|
|
45
|
+
if (!node_fs_1.default.existsSync(CREDENTIALS_FILE)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// Verify file permissions haven't been loosened
|
|
50
|
+
const stats = node_fs_1.default.statSync(CREDENTIALS_FILE);
|
|
51
|
+
const otherPerms = stats.mode & 0o077;
|
|
52
|
+
if (otherPerms !== 0) {
|
|
53
|
+
console.error(`⚠️ Warning: ${CREDENTIALS_FILE} has insecure permissions (${(stats.mode & 0o777).toString(8)}). ` +
|
|
54
|
+
`Expected 0600. Credentials may have been compromised. Fixing permissions.`);
|
|
55
|
+
node_fs_1.default.chmodSync(CREDENTIALS_FILE, 0o600);
|
|
56
|
+
}
|
|
57
|
+
const raw = node_fs_1.default.readFileSync(CREDENTIALS_FILE, 'utf8');
|
|
58
|
+
const data = JSON.parse(raw);
|
|
59
|
+
if (!data.token || !data.username) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
token: data.token,
|
|
64
|
+
username: data.username,
|
|
65
|
+
orgs: data.orgs || [],
|
|
66
|
+
expiresAt: data.expires_at || null,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Delete the credentials file.
|
|
75
|
+
*/
|
|
76
|
+
function deleteCredentials() {
|
|
77
|
+
if (node_fs_1.default.existsSync(CREDENTIALS_FILE)) {
|
|
78
|
+
node_fs_1.default.unlinkSync(CREDENTIALS_FILE);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if credentials are expired.
|
|
85
|
+
*/
|
|
86
|
+
function isExpired(credentials) {
|
|
87
|
+
if (!credentials.expiresAt) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const expires = new Date(credentials.expiresAt);
|
|
92
|
+
return Date.now() > expires.getTime();
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAmGwB,0CAAe;AAAE,0CAAe;AAAE,8CAAiB;AAAE,8BAAS;AAjGzF,sDAAyB;AACzB,0DAA6B;AAC7B,qCAAsC;AAStC,MAAM,gBAAgB,GAAG,mBAAI,CAAC,IAAI,CAAC,mBAAU,EAAE,kBAAkB,CAAC,CAAC;AAsF1D,4CAAgB;AApFzB;;GAEG;AACH,SAAS,eAAe;IACtB,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,mBAAU,CAAC,EAAE,CAAC;QAC/B,iBAAE,CAAC,SAAS,CAAC,mBAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,WAAwB;IAC/C,eAAe,EAAE,CAAC;IAClB,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,WAAW,CAAC,KAAK;QACxB,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,EAAE;QAC5B,UAAU,EAAE,WAAW,CAAC,SAAS,IAAI,IAAI;KAC1C,CAAC;IACF,iBAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACrF,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,gDAAgD;QAChD,MAAM,KAAK,GAA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,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub URL utilities for dossier CLI
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Convert GitHub blob URL to raw URL
|
|
6
|
+
*
|
|
7
|
+
* GitHub blob URLs return HTML pages, not raw file content.
|
|
8
|
+
* This function converts them to raw.githubusercontent.com URLs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Converts blob URLs to raw URLs
|
|
12
|
+
* convertGitHubBlobToRaw('https://github.com/owner/repo/blob/main/path/file.md')
|
|
13
|
+
* // => 'https://raw.githubusercontent.com/owner/repo/main/path/file.md'
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Leaves other URLs unchanged
|
|
17
|
+
* convertGitHubBlobToRaw('https://example.com/file.md')
|
|
18
|
+
* // => 'https://example.com/file.md'
|
|
19
|
+
*/
|
|
20
|
+
declare function convertGitHubBlobToRaw(url: string): string;
|
|
21
|
+
export { convertGitHubBlobToRaw };
|
|
22
|
+
//# sourceMappingURL=github-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-url.d.ts","sourceRoot":"","sources":["../src/github-url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUnD;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GitHub URL utilities for dossier CLI
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertGitHubBlobToRaw = convertGitHubBlobToRaw;
|
|
7
|
+
/**
|
|
8
|
+
* Convert GitHub blob URL to raw URL
|
|
9
|
+
*
|
|
10
|
+
* GitHub blob URLs return HTML pages, not raw file content.
|
|
11
|
+
* This function converts them to raw.githubusercontent.com URLs.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Converts blob URLs to raw URLs
|
|
15
|
+
* convertGitHubBlobToRaw('https://github.com/owner/repo/blob/main/path/file.md')
|
|
16
|
+
* // => 'https://raw.githubusercontent.com/owner/repo/main/path/file.md'
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Leaves other URLs unchanged
|
|
20
|
+
* convertGitHubBlobToRaw('https://example.com/file.md')
|
|
21
|
+
* // => 'https://example.com/file.md'
|
|
22
|
+
*/
|
|
23
|
+
function convertGitHubBlobToRaw(url) {
|
|
24
|
+
// https://github.com/OWNER/REPO/blob/BRANCH/PATH
|
|
25
|
+
// -> https://raw.githubusercontent.com/OWNER/REPO/BRANCH/PATH
|
|
26
|
+
const githubBlobRegex = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/(.+)$/;
|
|
27
|
+
const match = url.match(githubBlobRegex);
|
|
28
|
+
if (match) {
|
|
29
|
+
const [, owner, repo, rest] = match;
|
|
30
|
+
return `https://raw.githubusercontent.com/${owner}/${repo}/${rest}`;
|
|
31
|
+
}
|
|
32
|
+
return url;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=github-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-url.js","sourceRoot":"","sources":["../src/github-url.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA8BM,wDAAsB;AA5B/B;;;;;;;;;;;;;;;GAeG;AACH,SAAS,sBAAsB,CAAC,GAAW;IACzC,iDAAiD;IACjD,8DAA8D;IAC9D,MAAM,eAAe,GAAG,uDAAuD,CAAC;IAChF,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACzC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;QACpC,OAAO,qCAAqC,KAAK,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;IACtE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|