@pecot/workflow-mcp 8.0.1-dev.52 → 8.0.1-dev.54

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pecot-w",
3
- "version": "8.0.1-dev.52",
3
+ "version": "8.0.1-dev.54",
4
4
  "description": "pecot-w (pecot-workflow) workflow automation plugin for Claude Code - skills, hooks, agents, and commands for AI-assisted development",
5
5
  "author": {
6
6
  "name": "pecot"
@@ -54,7 +54,8 @@ hosts.json の scopes。無い、または配列でないときは空
54
54
  export declare function scopesFor(host: string): readonly string[];
55
55
  /**
56
56
  認証用の .env を生成または更新して、そのパスを返す。
57
- 無ければ新規作成する。あるときは、ホストの環境変数名が書かれていない場合だけ追記する
57
+ 無ければ新規作成する。あるときは、ホストの環境変数名が書かれていない場合だけ追記する。
58
+ 設定ディレクトリが無ければ何も書かずに undefined を返す(.gitignore の無い clone にトークンのファイルを置かない)
58
59
  */
59
- export declare function ensureEnvironmentFile(host: string): string;
60
+ export declare function ensureEnvironmentFile(host: string): string | undefined;
60
61
  //# sourceMappingURL=auth.d.ts.map
@@ -138,10 +138,14 @@ const ENVIRONMENT_FILE_HEADER = `# pecot-cli 認証設定
138
138
  `;
139
139
  /**
140
140
  認証用の .env を生成または更新して、そのパスを返す。
141
- 無ければ新規作成する。あるときは、ホストの環境変数名が書かれていない場合だけ追記する
141
+ 無ければ新規作成する。あるときは、ホストの環境変数名が書かれていない場合だけ追記する。
142
+ 設定ディレクトリが無ければ何も書かずに undefined を返す(.gitignore の無い clone にトークンのファイルを置かない)
142
143
  */
143
144
  export function ensureEnvironmentFile(host) {
144
- const file = path.join(configDirectory(), '.env');
145
+ const directory = configDirectory();
146
+ if (!existsSync(directory))
147
+ return undefined;
148
+ const file = path.join(directory, '.env');
145
149
  const name = getEnvironmentVariableName(host);
146
150
  const entry = environmentEntry(host);
147
151
  try {
@@ -123,10 +123,12 @@ export declare class GitHubClientBase {
123
123
  readonly linkedRepositoriesCache: Map<string, readonly LinkedRepository[]>;
124
124
  constructor(options: Readonly<GitHubClientOptions>);
125
125
  private resolveToken;
126
+ private failAuthentication;
126
127
  private tokenFromEnvironment;
127
128
  private tokenFromGh;
128
129
  /**
129
- 認証エラーの文を作る。.env が無ければ生成し、あるときはホストの変数が無ければ追記する
130
+ 認証エラーの文を作る。.env が無ければ生成し、あるときはホストの変数が無ければ追記する。
131
+ 設定ディレクトリが無く .env を作れないときは、gh auth login と起動前の環境変数を案内する
130
132
  */
131
133
  private authErrorMessage;
132
134
  private requestHeaders;
@@ -323,7 +323,10 @@ export class GitHubClientBase {
323
323
  }
324
324
  // config/.env → ルート .env → gh auth token の順
325
325
  resolveToken(host) {
326
- return this.tokenFromEnvironment(host) ?? this.tokenFromGh(host);
326
+ return this.tokenFromEnvironment(host) ?? this.tokenFromGh(host) ?? this.failAuthentication(host);
327
+ }
328
+ failAuthentication(host) {
329
+ throw new GitHubAuthError(this.authErrorMessage(host));
327
330
  }
328
331
  tokenFromEnvironment(host) {
329
332
  loadEnvironmentFile(path.join(configDirectory(), '.env'));
@@ -342,17 +345,29 @@ export class GitHubClientBase {
342
345
  const result = spawnSync('gh', arguments_, { encoding: 'utf8', timeout: this.ghTimeoutMilliseconds });
343
346
  // gh が無い・時間切れ(error)、終了コードが 0 でない、または出力が空
344
347
  const token = result.error === undefined && result.status === 0 ? pythonStrip(result.stdout) : '';
345
- if (token.length === 0)
346
- throw new GitHubAuthError(this.authErrorMessage(host));
347
- return token;
348
+ return token.length === 0 ? undefined : token;
348
349
  }
349
350
  /**
350
- 認証エラーの文を作る。.env が無ければ生成し、あるときはホストの変数が無ければ追記する
351
+ 認証エラーの文を作る。.env が無ければ生成し、あるときはホストの変数が無ければ追記する。
352
+ 設定ディレクトリが無く .env を作れないときは、gh auth login と起動前の環境変数を案内する
351
353
  */
352
354
  authErrorMessage(host) {
353
355
  const file = ensureEnvironmentFile(host);
354
356
  const scopes = scopesFor(host);
355
357
  const scopesLine = scopes.length > 0 ? ` required scopes: ${scopes.join(', ')}` : '';
358
+ if (file === undefined) {
359
+ return [
360
+ 'authentication error: could not get a GitHub API token',
361
+ '',
362
+ 'authenticate with the GitHub CLI:',
363
+ ` gh auth login -h ${host}`,
364
+ '',
365
+ 'or set a token in an environment variable:',
366
+ `1. get a token: ${tokenUrlFor(host)}`,
367
+ ...(scopesLine === '' ? [] : [scopesLine]),
368
+ `2. set it in ${getEnvironmentVariableName(host)} before starting pecot (for the MCP server, before starting the session)`,
369
+ ].join('\n');
370
+ }
356
371
  return `authentication error: could not get a GitHub API token
357
372
 
358
373
  ${file} was generated. Set the token as follows:
@@ -380,16 +395,8 @@ or authenticate with the GitHub CLI:
380
395
  if (this.usedFallback)
381
396
  return false;
382
397
  this.usedFallback = true;
383
- let newToken;
384
- try {
385
- newToken = this.tokenFromGh(this.host);
386
- }
387
- catch (error) {
388
- if (error instanceof GitHubAuthError)
389
- return false;
390
- throw error;
391
- }
392
- if (newToken === this.token)
398
+ const newToken = this.tokenFromGh(this.host);
399
+ if (newToken === undefined || newToken === this.token)
393
400
  return false;
394
401
  this.diagnostics.warning(TOKEN_FALLBACK_WARNING);
395
402
  this.token = newToken;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pecot/workflow-mcp",
3
- "version": "8.0.1-dev.52",
3
+ "version": "8.0.1-dev.54",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@pecot/workflow-mcp",
9
- "version": "8.0.1-dev.52",
9
+ "version": "8.0.1-dev.54",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/server": "^2.4.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pecot/workflow-mcp",
3
- "version": "8.0.1-dev.52",
3
+ "version": "8.0.1-dev.54",
4
4
  "type": "module",
5
5
  "description": "pecot-workflow MCP server (standalone distribution)",
6
6
  "license": "MIT",