Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
timeout-minutes: 10
strategy:
matrix:
node: ['22', 'lts/*']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
- run: node --test test/deps/*.test.mjs

validate:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 'lts/*'
- run: npm install -g @anthropic-ai/claude-code@2.1.295
- run: claude plugin validate --strict .
- run: claude plugin validate --strict ./plugins/git
- run: claude plugin validate --strict ./plugins/workflow
219 changes: 219 additions & 0 deletions docs/plan/2026-10-09-feat-deps-triage-plugin-plan.md

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions plugins/deps/scripts/lib/core/args.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/** The `parseArgs` configuration for the triage CLI. */
export const PARSE_OPTIONS = Object.freeze({
options: {
pr: { type: 'string' },
'body-file': { type: 'string' },
},
allowPositionals: true,
strict: true,
});

const COMMANDS = ['collect', 'comment'];
const POSITIVE_INTEGER = /^[1-9]\d*$/;

function parsePrNumber(text) {
if (typeof text !== 'string' || !POSITIVE_INTEGER.test(text)) {
return null;
}
const number = Number(text);
return Number.isSafeInteger(number) ? number : null;
}

function validateCollect(values, extra) {
if (values.pr !== undefined || values['body-file'] !== undefined) {
return { ok: false, error: 'collect takes an optional PR number, not --pr or --body-file' };
}
if (extra.length > 1) {
return { ok: false, error: 'collect takes at most one PR number' };
}
if (extra.length === 0) {
return { ok: true, command: 'collect', pr: null };
}
const pr = parsePrNumber(extra[0]);
if (pr === null) {
return { ok: false, error: `PR number must be a positive integer, got: ${extra[0]}` };
}
return { ok: true, command: 'collect', pr };
}

function validateComment(values, extra) {
if (extra.length > 0) {
return { ok: false, error: 'comment takes no positional arguments; use --pr and --body-file' };
}
const pr = parsePrNumber(values.pr);
if (pr === null) {
return { ok: false, error: 'comment requires --pr <positive integer>' };
}
const bodyFile = values['body-file'];
if (typeof bodyFile !== 'string' || bodyFile === '') {
return { ok: false, error: 'comment requires --body-file <path>' };
}
return { ok: true, command: 'comment', pr, bodyFile };
}

/**
* Validates the output of `parseArgs` called with {@link PARSE_OPTIONS}.
*
* @param {{ values: Record<string, string | undefined>, positionals: string[] }} parsed
* @returns {{ ok: true, command: 'collect', pr: number | null } | { ok: true, command: 'comment', pr: number, bodyFile: string } | { ok: false, error: string }}
*/
export function validateArgs({ values, positionals }) {
const [command, ...extra] = positionals;
if (command === 'collect') {
return validateCollect(values, extra);
}
if (command === 'comment') {
return validateComment(values, extra);
}
const shown = command === undefined ? 'missing command' : `unknown command: ${command}`;
return { ok: false, error: `${shown}; expected one of: ${COMMANDS.join(', ')}` };
}
Loading
Loading