@skillmarkdown/cli 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +1 -1
- package/dist/commands/init.js +4 -4
- package/dist/commands/login.js +23 -114
- package/dist/commands/logout.js +4 -4
- package/dist/commands/validate.js +4 -4
- package/dist/lib/{auth-config.js → auth/config.js} +4 -4
- package/dist/lib/{firebase-auth.js → auth/firebase-auth.js} +1 -1
- package/dist/lib/{github-device-flow.js → auth/github-device-flow.js} +1 -1
- package/dist/lib/auth/login-flags.js +22 -0
- package/dist/lib/auth/login-flow.js +56 -0
- package/dist/lib/auth/login-status.js +34 -0
- package/dist/lib/scaffold/templates/index.js +18 -0
- package/dist/lib/{templates.js → scaffold/templates/resources.js} +0 -36
- package/dist/lib/scaffold/templates/skill-markdown.js +38 -0
- package/dist/lib/{validator.js → validation/validator.js} +1 -1
- package/package.json +2 -2
- /package/dist/lib/{auth-defaults.js → auth/defaults.js} +0 -0
- /package/dist/lib/{auth-session.js → auth/session.js} +0 -0
- /package/dist/lib/{normalize-name.js → scaffold/normalize-name.js} +0 -0
- /package/dist/lib/{scaffold.js → scaffold/scaffold.js} +0 -0
- /package/dist/lib/{skill-spec.js → scaffold/skill-spec.js} +0 -0
- /package/dist/lib/{cli-text.js → shared/cli-text.js} +0 -0
- /package/dist/lib/{command-output.js → shared/command-output.js} +0 -0
- /package/dist/lib/{http.js → shared/http.js} +0 -0
- /package/dist/lib/{upstream-validator.js → validation/upstream-validator.js} +0 -0
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ By default, `login` uses the project’s built-in development config. You can ov
|
|
|
106
106
|
- `SKILLMD_FIREBASE_PROJECT_ID`
|
|
107
107
|
|
|
108
108
|
See `.env.example` for the expected keys.
|
|
109
|
-
Maintainers: built-in defaults are defined in `src/lib/auth
|
|
109
|
+
Maintainers: built-in defaults are defined in `src/lib/auth/defaults.ts`.
|
|
110
110
|
|
|
111
111
|
Example override file:
|
|
112
112
|
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ const init_1 = require("./commands/init");
|
|
|
5
5
|
const login_1 = require("./commands/login");
|
|
6
6
|
const logout_1 = require("./commands/logout");
|
|
7
7
|
const validate_1 = require("./commands/validate");
|
|
8
|
-
const cli_text_1 = require("./lib/cli-text");
|
|
8
|
+
const cli_text_1 = require("./lib/shared/cli-text");
|
|
9
9
|
const COMMAND_HANDLERS = {
|
|
10
10
|
init: init_1.runInitCommand,
|
|
11
11
|
validate: validate_1.runValidateCommand,
|
package/dist/commands/init.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runInitCommand = runInitCommand;
|
|
4
|
-
const cli_text_1 = require("../lib/cli-text");
|
|
5
|
-
const command_output_1 = require("../lib/command-output");
|
|
6
|
-
const scaffold_1 = require("../lib/scaffold");
|
|
7
|
-
const validator_1 = require("../lib/validator");
|
|
4
|
+
const cli_text_1 = require("../lib/shared/cli-text");
|
|
5
|
+
const command_output_1 = require("../lib/shared/command-output");
|
|
6
|
+
const scaffold_1 = require("../lib/scaffold/scaffold");
|
|
7
|
+
const validator_1 = require("../lib/validation/validator");
|
|
8
8
|
function parseInitArgs(args) {
|
|
9
9
|
let skipValidation = false;
|
|
10
10
|
let template = "minimal";
|
package/dist/commands/login.js
CHANGED
|
@@ -1,64 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runLoginCommand = runLoginCommand;
|
|
4
|
-
const cli_text_1 = require("../lib/cli-text");
|
|
5
|
-
const command_output_1 = require("../lib/command-output");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const github_device_flow_1 = require("../lib/github-device-flow");
|
|
9
|
-
const firebase_auth_1 = require("../lib/firebase-auth");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (const arg of args) {
|
|
14
|
-
if (arg === "--status") {
|
|
15
|
-
status = true;
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
if (arg === "--reauth") {
|
|
19
|
-
reauth = true;
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
return { status: false, reauth: false, valid: false };
|
|
23
|
-
}
|
|
24
|
-
if (status && reauth) {
|
|
25
|
-
return { status: false, reauth: false, valid: false };
|
|
26
|
-
}
|
|
27
|
-
return { status, reauth, valid: true };
|
|
28
|
-
}
|
|
29
|
-
function formatSessionProject(session, currentConfigProjectId) {
|
|
30
|
-
if (!session.projectId) {
|
|
31
|
-
if (currentConfigProjectId) {
|
|
32
|
-
return { label: `unknown (current config: ${currentConfigProjectId})`, mismatch: false };
|
|
33
|
-
}
|
|
34
|
-
return { label: "unknown", mismatch: false };
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
label: session.projectId,
|
|
38
|
-
mismatch: Boolean(currentConfigProjectId && session.projectId !== currentConfigProjectId),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function printSessionStatus(session, currentConfigProjectId) {
|
|
42
|
-
if (!session) {
|
|
43
|
-
console.log("Not logged in.");
|
|
44
|
-
return 1;
|
|
45
|
-
}
|
|
46
|
-
const project = formatSessionProject(session, currentConfigProjectId);
|
|
47
|
-
if (session.email) {
|
|
48
|
-
console.log(`Logged in with GitHub as ${session.email} (project: ${project.label}).`);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
console.log(`Logged in with GitHub (uid: ${session.uid}, project: ${project.label}).`);
|
|
52
|
-
}
|
|
53
|
-
if (project.mismatch && currentConfigProjectId) {
|
|
54
|
-
console.log(`Current CLI config targets project '${currentConfigProjectId}'. ` +
|
|
55
|
-
"Run 'skillmd login --reauth' to switch projects.");
|
|
56
|
-
}
|
|
57
|
-
return 0;
|
|
58
|
-
}
|
|
4
|
+
const cli_text_1 = require("../lib/shared/cli-text");
|
|
5
|
+
const command_output_1 = require("../lib/shared/command-output");
|
|
6
|
+
const config_1 = require("../lib/auth/config");
|
|
7
|
+
const session_1 = require("../lib/auth/session");
|
|
8
|
+
const github_device_flow_1 = require("../lib/auth/github-device-flow");
|
|
9
|
+
const firebase_auth_1 = require("../lib/auth/firebase-auth");
|
|
10
|
+
const login_flow_1 = require("../lib/auth/login-flow");
|
|
11
|
+
const login_flags_1 = require("../lib/auth/login-flags");
|
|
12
|
+
const login_status_1 = require("../lib/auth/login-status");
|
|
59
13
|
function requireConfig(env) {
|
|
60
14
|
try {
|
|
61
|
-
return (0,
|
|
15
|
+
return (0, config_1.getLoginEnvConfig)(env);
|
|
62
16
|
}
|
|
63
17
|
catch (error) {
|
|
64
18
|
const message = error instanceof Error ? error.message : "invalid login configuration";
|
|
@@ -68,72 +22,27 @@ function requireConfig(env) {
|
|
|
68
22
|
}
|
|
69
23
|
}
|
|
70
24
|
async function runLoginCommand(args, options = {}) {
|
|
71
|
-
const { status, reauth, valid } =
|
|
25
|
+
const { status, reauth, valid } = (0, login_flags_1.parseLoginFlags)(args);
|
|
72
26
|
if (!valid) {
|
|
73
27
|
return (0, command_output_1.failWithUsage)("skillmd login: unsupported argument(s)", cli_text_1.LOGIN_USAGE);
|
|
74
28
|
}
|
|
75
|
-
const readSessionFn = options.readSession ??
|
|
76
|
-
const writeSessionFn = options.writeSession ??
|
|
77
|
-
const clearSessionFn = options.clearSession ??
|
|
29
|
+
const readSessionFn = options.readSession ?? session_1.readAuthSession;
|
|
30
|
+
const writeSessionFn = options.writeSession ?? session_1.writeAuthSession;
|
|
31
|
+
const clearSessionFn = options.clearSession ?? session_1.clearAuthSession;
|
|
78
32
|
try {
|
|
79
33
|
const config = requireConfig(options.env ?? process.env);
|
|
80
34
|
if (status) {
|
|
81
|
-
return printSessionStatus(readSessionFn(), config.firebaseProjectId);
|
|
82
|
-
}
|
|
83
|
-
const existingSession = readSessionFn();
|
|
84
|
-
if (existingSession && !reauth) {
|
|
85
|
-
const verifyRefreshTokenFn = options.verifyRefreshToken ?? firebase_auth_1.verifyFirebaseRefreshToken;
|
|
86
|
-
try {
|
|
87
|
-
const validation = await verifyRefreshTokenFn(config.firebaseApiKey, existingSession.refreshToken);
|
|
88
|
-
if (validation.valid) {
|
|
89
|
-
const project = formatSessionProject(existingSession, config.firebaseProjectId);
|
|
90
|
-
if (existingSession.email) {
|
|
91
|
-
console.log(`Already logged in as ${existingSession.email} (project: ${project.label}). ` +
|
|
92
|
-
"Run 'skillmd logout' first.");
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
console.log(`Already logged in (uid: ${existingSession.uid}, project: ${project.label}). ` +
|
|
96
|
-
"Run 'skillmd logout' first.");
|
|
97
|
-
}
|
|
98
|
-
if (project.mismatch) {
|
|
99
|
-
console.log(`Current CLI config targets project '${config.firebaseProjectId}'. ` +
|
|
100
|
-
"Run 'skillmd login --reauth' to switch projects.");
|
|
101
|
-
}
|
|
102
|
-
return 0;
|
|
103
|
-
}
|
|
104
|
-
clearSessionFn();
|
|
105
|
-
console.log("Existing session is no longer valid. Starting re-authentication.");
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
109
|
-
console.error(`skillmd login: unable to verify existing session (${message}). ` +
|
|
110
|
-
"Keeping current session. Run 'skillmd login --reauth' to force reauthentication.");
|
|
111
|
-
return 1;
|
|
112
|
-
}
|
|
35
|
+
return (0, login_status_1.printSessionStatus)(readSessionFn(), config.firebaseProjectId);
|
|
113
36
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const firebaseSession = await signInFn(config.firebaseApiKey, token.accessToken);
|
|
123
|
-
writeSessionFn({
|
|
124
|
-
provider: "github",
|
|
125
|
-
uid: firebaseSession.localId,
|
|
126
|
-
email: firebaseSession.email,
|
|
127
|
-
refreshToken: firebaseSession.refreshToken,
|
|
128
|
-
projectId: config.firebaseProjectId,
|
|
37
|
+
return await (0, login_flow_1.executeLoginFlow)(config, reauth, {
|
|
38
|
+
readSession: readSessionFn,
|
|
39
|
+
writeSession: writeSessionFn,
|
|
40
|
+
clearSession: clearSessionFn,
|
|
41
|
+
requestDeviceCode: options.requestDeviceCode ?? github_device_flow_1.requestDeviceCode,
|
|
42
|
+
pollForAccessToken: options.pollForAccessToken ?? github_device_flow_1.pollForAccessToken,
|
|
43
|
+
signInWithGitHubAccessToken: options.signInWithGitHubAccessToken ?? firebase_auth_1.signInWithGitHubAccessToken,
|
|
44
|
+
verifyRefreshToken: options.verifyRefreshToken ?? firebase_auth_1.verifyFirebaseRefreshToken,
|
|
129
45
|
});
|
|
130
|
-
if (firebaseSession.email) {
|
|
131
|
-
console.log(`Login successful. Signed in as ${firebaseSession.email} (project: ${config.firebaseProjectId}).`);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
console.log(`Login successful (project: ${config.firebaseProjectId}).`);
|
|
135
|
-
}
|
|
136
|
-
return 0;
|
|
137
46
|
}
|
|
138
47
|
catch (error) {
|
|
139
48
|
const message = error instanceof Error ? error.message : "Unknown error";
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runLogoutCommand = runLogoutCommand;
|
|
4
|
-
const cli_text_1 = require("../lib/cli-text");
|
|
5
|
-
const command_output_1 = require("../lib/command-output");
|
|
6
|
-
const
|
|
4
|
+
const cli_text_1 = require("../lib/shared/cli-text");
|
|
5
|
+
const command_output_1 = require("../lib/shared/command-output");
|
|
6
|
+
const session_1 = require("../lib/auth/session");
|
|
7
7
|
function runLogoutCommand(args, options = {}) {
|
|
8
8
|
if (args.length > 0) {
|
|
9
9
|
return (0, command_output_1.failWithUsage)("skillmd logout: unsupported argument(s)", cli_text_1.LOGOUT_USAGE);
|
|
10
10
|
}
|
|
11
11
|
try {
|
|
12
|
-
const clearSessionFn = options.clearSession ??
|
|
12
|
+
const clearSessionFn = options.clearSession ?? session_1.clearAuthSession;
|
|
13
13
|
const removed = clearSessionFn();
|
|
14
14
|
if (removed) {
|
|
15
15
|
console.log("Logged out.");
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runValidateCommand = runValidateCommand;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
-
const cli_text_1 = require("../lib/cli-text");
|
|
6
|
-
const command_output_1 = require("../lib/command-output");
|
|
7
|
-
const upstream_validator_1 = require("../lib/upstream-validator");
|
|
8
|
-
const validator_1 = require("../lib/validator");
|
|
5
|
+
const cli_text_1 = require("../lib/shared/cli-text");
|
|
6
|
+
const command_output_1 = require("../lib/shared/command-output");
|
|
7
|
+
const upstream_validator_1 = require("../lib/validation/upstream-validator");
|
|
8
|
+
const validator_1 = require("../lib/validation/validator");
|
|
9
9
|
function runValidateCommand(args, options = {}) {
|
|
10
10
|
try {
|
|
11
11
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -5,7 +5,7 @@ exports.getDefaultUserEnvPath = getDefaultUserEnvPath;
|
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_os_1 = require("node:os");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
-
const
|
|
8
|
+
const defaults_1 = require("./defaults");
|
|
9
9
|
const USER_ENV_RELATIVE_PATH = ".skillmd/.env";
|
|
10
10
|
function parseDotEnv(content) {
|
|
11
11
|
const values = {};
|
|
@@ -52,9 +52,9 @@ function pickValue(...candidates) {
|
|
|
52
52
|
}
|
|
53
53
|
function getLoginEnvConfig(env = process.env, options = {}) {
|
|
54
54
|
const dotEnv = loadDotEnv(getDefaultUserEnvPath(options));
|
|
55
|
-
const githubClientId = pickValue(env.SKILLMD_GITHUB_CLIENT_ID, dotEnv.SKILLMD_GITHUB_CLIENT_ID,
|
|
56
|
-
const firebaseApiKey = pickValue(env.SKILLMD_FIREBASE_API_KEY, dotEnv.SKILLMD_FIREBASE_API_KEY,
|
|
57
|
-
const firebaseProjectId = pickValue(env.SKILLMD_FIREBASE_PROJECT_ID, dotEnv.SKILLMD_FIREBASE_PROJECT_ID,
|
|
55
|
+
const githubClientId = pickValue(env.SKILLMD_GITHUB_CLIENT_ID, dotEnv.SKILLMD_GITHUB_CLIENT_ID, defaults_1.DEFAULT_LOGIN_AUTH_CONFIG.githubClientId);
|
|
56
|
+
const firebaseApiKey = pickValue(env.SKILLMD_FIREBASE_API_KEY, dotEnv.SKILLMD_FIREBASE_API_KEY, defaults_1.DEFAULT_LOGIN_AUTH_CONFIG.firebaseApiKey);
|
|
57
|
+
const firebaseProjectId = pickValue(env.SKILLMD_FIREBASE_PROJECT_ID, dotEnv.SKILLMD_FIREBASE_PROJECT_ID, defaults_1.DEFAULT_LOGIN_AUTH_CONFIG.firebaseProjectId);
|
|
58
58
|
if (!githubClientId || !firebaseApiKey || !firebaseProjectId) {
|
|
59
59
|
throw new Error("missing login configuration");
|
|
60
60
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signInWithGitHubAccessToken = signInWithGitHubAccessToken;
|
|
4
4
|
exports.verifyFirebaseRefreshToken = verifyFirebaseRefreshToken;
|
|
5
|
-
const http_1 = require("
|
|
5
|
+
const http_1 = require("../shared/http");
|
|
6
6
|
const FIREBASE_HTTP_TIMEOUT_MS = 10000;
|
|
7
7
|
async function parseJsonApiResponse(response, apiLabel) {
|
|
8
8
|
const text = await response.text();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requestDeviceCode = requestDeviceCode;
|
|
4
4
|
exports.pollForAccessToken = pollForAccessToken;
|
|
5
|
-
const http_1 = require("
|
|
5
|
+
const http_1 = require("../shared/http");
|
|
6
6
|
const GITHUB_DEVICE_CODE_URL = "https://github.com/login/device/code";
|
|
7
7
|
const GITHUB_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
|
|
8
8
|
const GITHUB_HTTP_TIMEOUT_MS = 10000;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLoginFlags = parseLoginFlags;
|
|
4
|
+
function parseLoginFlags(args) {
|
|
5
|
+
let status = false;
|
|
6
|
+
let reauth = false;
|
|
7
|
+
for (const arg of args) {
|
|
8
|
+
if (arg === "--status") {
|
|
9
|
+
status = true;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (arg === "--reauth") {
|
|
13
|
+
reauth = true;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
return { status: false, reauth: false, valid: false };
|
|
17
|
+
}
|
|
18
|
+
if (status && reauth) {
|
|
19
|
+
return { status: false, reauth: false, valid: false };
|
|
20
|
+
}
|
|
21
|
+
return { status, reauth, valid: true };
|
|
22
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeLoginFlow = executeLoginFlow;
|
|
4
|
+
const login_status_1 = require("./login-status");
|
|
5
|
+
async function executeLoginFlow(config, reauth, dependencies) {
|
|
6
|
+
const existingSession = dependencies.readSession();
|
|
7
|
+
if (existingSession && !reauth) {
|
|
8
|
+
try {
|
|
9
|
+
const validation = await dependencies.verifyRefreshToken(config.firebaseApiKey, existingSession.refreshToken);
|
|
10
|
+
if (validation.valid) {
|
|
11
|
+
const project = (0, login_status_1.formatSessionProject)(existingSession, config.firebaseProjectId);
|
|
12
|
+
if (existingSession.email) {
|
|
13
|
+
console.log(`Already logged in as ${existingSession.email} (project: ${project.label}). ` +
|
|
14
|
+
"Run 'skillmd logout' first.");
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
console.log(`Already logged in (uid: ${existingSession.uid}, project: ${project.label}). ` +
|
|
18
|
+
"Run 'skillmd logout' first.");
|
|
19
|
+
}
|
|
20
|
+
if (project.mismatch) {
|
|
21
|
+
console.log(`Current CLI config targets project '${config.firebaseProjectId}'. ` +
|
|
22
|
+
"Run 'skillmd login --reauth' to switch projects.");
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
dependencies.clearSession();
|
|
27
|
+
console.log("Existing session is no longer valid. Starting re-authentication.");
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
31
|
+
console.error(`skillmd login: unable to verify existing session (${message}). ` +
|
|
32
|
+
"Keeping current session. Run 'skillmd login --reauth' to force reauthentication.");
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const deviceCode = await dependencies.requestDeviceCode(config.githubClientId);
|
|
37
|
+
console.log("Open this URL in your browser to authorize skillmd:");
|
|
38
|
+
console.log(deviceCode.verificationUriComplete ?? deviceCode.verificationUri);
|
|
39
|
+
console.log(`Then enter code: ${deviceCode.userCode}`);
|
|
40
|
+
const token = await dependencies.pollForAccessToken(config.githubClientId, deviceCode.deviceCode, deviceCode.interval, deviceCode.expiresIn);
|
|
41
|
+
const firebaseSession = await dependencies.signInWithGitHubAccessToken(config.firebaseApiKey, token.accessToken);
|
|
42
|
+
dependencies.writeSession({
|
|
43
|
+
provider: "github",
|
|
44
|
+
uid: firebaseSession.localId,
|
|
45
|
+
email: firebaseSession.email,
|
|
46
|
+
refreshToken: firebaseSession.refreshToken,
|
|
47
|
+
projectId: config.firebaseProjectId,
|
|
48
|
+
});
|
|
49
|
+
if (firebaseSession.email) {
|
|
50
|
+
console.log(`Login successful. Signed in as ${firebaseSession.email} (project: ${config.firebaseProjectId}).`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log(`Login successful (project: ${config.firebaseProjectId}).`);
|
|
54
|
+
}
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatSessionProject = formatSessionProject;
|
|
4
|
+
exports.printSessionStatus = printSessionStatus;
|
|
5
|
+
function formatSessionProject(session, currentConfigProjectId) {
|
|
6
|
+
if (!session.projectId) {
|
|
7
|
+
if (currentConfigProjectId) {
|
|
8
|
+
return { label: `unknown (current config: ${currentConfigProjectId})`, mismatch: false };
|
|
9
|
+
}
|
|
10
|
+
return { label: "unknown", mismatch: false };
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
label: session.projectId,
|
|
14
|
+
mismatch: Boolean(currentConfigProjectId && session.projectId !== currentConfigProjectId),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function printSessionStatus(session, currentConfigProjectId) {
|
|
18
|
+
if (!session) {
|
|
19
|
+
console.log("Not logged in.");
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
const project = formatSessionProject(session, currentConfigProjectId);
|
|
23
|
+
if (session.email) {
|
|
24
|
+
console.log(`Logged in with GitHub as ${session.email} (project: ${project.label}).`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.log(`Logged in with GitHub (uid: ${session.uid}, project: ${project.label}).`);
|
|
28
|
+
}
|
|
29
|
+
if (project.mismatch && currentConfigProjectId) {
|
|
30
|
+
console.log(`Current CLI config targets project '${currentConfigProjectId}'. ` +
|
|
31
|
+
"Run 'skillmd login --reauth' to switch projects.");
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./skill-markdown"), exports);
|
|
18
|
+
__exportStar(require("./resources"), exports);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildSkillMarkdown = buildSkillMarkdown;
|
|
4
|
-
exports.buildMinimalSkillMarkdown = buildMinimalSkillMarkdown;
|
|
5
|
-
exports.buildVerboseSkillMarkdown = buildVerboseSkillMarkdown;
|
|
6
3
|
exports.buildGitignore = buildGitignore;
|
|
7
4
|
exports.buildScriptsReadme = buildScriptsReadme;
|
|
8
5
|
exports.buildExtractScriptPython = buildExtractScriptPython;
|
|
@@ -11,39 +8,6 @@ exports.buildFormsReference = buildFormsReference;
|
|
|
11
8
|
exports.buildAssetsReadme = buildAssetsReadme;
|
|
12
9
|
exports.buildReportTemplate = buildReportTemplate;
|
|
13
10
|
exports.buildLookupTableCsv = buildLookupTableCsv;
|
|
14
|
-
const skill_spec_1 = require("./skill-spec");
|
|
15
|
-
const SECTION_PLACEHOLDERS = {
|
|
16
|
-
Scope: "Define the boundaries of this skill: what it should and should not handle.",
|
|
17
|
-
"When to use": "Describe the signals or request patterns that should trigger this skill. Keep SKILL.md focused and move deep details into references/ files.",
|
|
18
|
-
Inputs: "List required and optional inputs, expected formats, and assumptions. Add structured templates to references/FORMS.md when helpful.",
|
|
19
|
-
Outputs: "Describe expected outputs, side effects, and completion criteria. Use assets/report-template.md when a fixed output structure is useful.",
|
|
20
|
-
"Steps / Procedure": "Provide ordered steps the agent should follow, including key decision points. See [the reference guide](references/REFERENCE.md) for detailed rules. Run helper scripts such as scripts/extract.py when needed.",
|
|
21
|
-
Examples: "Add one or two realistic examples of inputs and expected outputs.",
|
|
22
|
-
"Limitations / Failure modes": "Document known limitations, failure cases, and recommended recovery actions.",
|
|
23
|
-
"Security / Tool access": "State required tools/permissions and any security constraints. If needed, set frontmatter allowed-tools to pre-approve tool usage.",
|
|
24
|
-
};
|
|
25
|
-
function buildSkillMarkdown(name) {
|
|
26
|
-
const sections = skill_spec_1.STRICT_SECTION_TITLES.map((title) => `## ${title}\n\n${SECTION_PLACEHOLDERS[title]}`).join("\n\n");
|
|
27
|
-
return `---
|
|
28
|
-
name: ${name}
|
|
29
|
-
description: Explain what this skill does and when an agent should use it.
|
|
30
|
-
# compatibility: "Optional: environment requirements (products, packages, network access)."
|
|
31
|
-
# metadata:
|
|
32
|
-
# author: "your-org"
|
|
33
|
-
# version: "1.0.0"
|
|
34
|
-
# allowed-tools: "Optional: space-delimited pre-approved tools."
|
|
35
|
-
license: Optional. Add a license name or reference to a bundled license file.
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
${sections}
|
|
39
|
-
`;
|
|
40
|
-
}
|
|
41
|
-
function buildMinimalSkillMarkdown(name) {
|
|
42
|
-
return buildSkillMarkdown(name);
|
|
43
|
-
}
|
|
44
|
-
function buildVerboseSkillMarkdown(name) {
|
|
45
|
-
return buildSkillMarkdown(name);
|
|
46
|
-
}
|
|
47
11
|
function buildGitignore() {
|
|
48
12
|
return `node_modules/
|
|
49
13
|
dist/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSkillMarkdown = buildSkillMarkdown;
|
|
4
|
+
exports.buildMinimalSkillMarkdown = buildMinimalSkillMarkdown;
|
|
5
|
+
exports.buildVerboseSkillMarkdown = buildVerboseSkillMarkdown;
|
|
6
|
+
const skill_spec_1 = require("../skill-spec");
|
|
7
|
+
const SECTION_PLACEHOLDERS = {
|
|
8
|
+
Scope: "Define the boundaries of this skill: what it should and should not handle.",
|
|
9
|
+
"When to use": "Describe the signals or request patterns that should trigger this skill. Keep SKILL.md focused and move deep details into references/ files.",
|
|
10
|
+
Inputs: "List required and optional inputs, expected formats, and assumptions. Add structured templates to references/FORMS.md when helpful.",
|
|
11
|
+
Outputs: "Describe expected outputs, side effects, and completion criteria. Use assets/report-template.md when a fixed output structure is useful.",
|
|
12
|
+
"Steps / Procedure": "Provide ordered steps the agent should follow, including key decision points. See [the reference guide](references/REFERENCE.md) for detailed rules. Run helper scripts such as scripts/extract.py when needed.",
|
|
13
|
+
Examples: "Add one or two realistic examples of inputs and expected outputs.",
|
|
14
|
+
"Limitations / Failure modes": "Document known limitations, failure cases, and recommended recovery actions.",
|
|
15
|
+
"Security / Tool access": "State required tools/permissions and any security constraints. If needed, set frontmatter allowed-tools to pre-approve tool usage.",
|
|
16
|
+
};
|
|
17
|
+
function buildSkillMarkdown(name) {
|
|
18
|
+
const sections = skill_spec_1.STRICT_SECTION_TITLES.map((title) => `## ${title}\n\n${SECTION_PLACEHOLDERS[title]}`).join("\n\n");
|
|
19
|
+
return `---
|
|
20
|
+
name: ${name}
|
|
21
|
+
description: Explain what this skill does and when an agent should use it.
|
|
22
|
+
# compatibility: "Optional: environment requirements (products, packages, network access)."
|
|
23
|
+
# metadata:
|
|
24
|
+
# author: "your-org"
|
|
25
|
+
# version: "1.0.0"
|
|
26
|
+
# allowed-tools: "Optional: space-delimited pre-approved tools."
|
|
27
|
+
license: Optional. Add a license name or reference to a bundled license file.
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
${sections}
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
function buildMinimalSkillMarkdown(name) {
|
|
34
|
+
return buildSkillMarkdown(name);
|
|
35
|
+
}
|
|
36
|
+
function buildVerboseSkillMarkdown(name) {
|
|
37
|
+
return buildSkillMarkdown(name);
|
|
38
|
+
}
|
|
@@ -4,7 +4,7 @@ exports.validateSkill = validateSkill;
|
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const yaml_1 = require("yaml");
|
|
7
|
-
const skill_spec_1 = require("
|
|
7
|
+
const skill_spec_1 = require("../scaffold/skill-spec");
|
|
8
8
|
const SKILL_FILE = "SKILL.md";
|
|
9
9
|
function stripUtf8Bom(content) {
|
|
10
10
|
return content.replace(/^\uFEFF/, "");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillmarkdown/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI for scaffolding SKILL.md-based AI skills",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"prepublishOnly": "npm run clean && npm run build",
|
|
26
26
|
"smoke:link": "bash ./scripts/smoke-link.sh",
|
|
27
27
|
"smoke:pack": "bash ./scripts/smoke-pack.sh",
|
|
28
|
-
"test": "npm run build && node --test tests
|
|
28
|
+
"test": "npm run build && node --test \"tests/**/*.test.js\""
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=18"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|