@oss-autopilot/core 3.0.1 → 3.2.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.
@@ -1090,4 +1090,84 @@ export const commands = [
1090
1090
  });
1091
1091
  },
1092
1092
  },
1093
+ // ── Guidelines (#867) ──────────────────────────────────────────────────
1094
+ {
1095
+ name: 'guidelines',
1096
+ register(program) {
1097
+ const group = program
1098
+ .command('guidelines')
1099
+ .description('Manage per-repo learning guidelines extracted from PR feedback (#867)');
1100
+ group
1101
+ .command('view')
1102
+ .description('Read the per-repo guidelines file (returns null when none exists or in local mode)')
1103
+ .requiredOption('--repo <owner/repo>', 'Repository identifier')
1104
+ .option('--json', 'Output as JSON')
1105
+ .action(async (options) => {
1106
+ await executeAction(options, async () => (await import('./commands/guidelines.js')).runGuidelinesView({ repo: options.repo }), (data) => {
1107
+ if (data.content === null) {
1108
+ console.log(`No guidelines stored for ${data.repo} (storage: ${data.storageMode}).`);
1109
+ }
1110
+ else {
1111
+ console.log(`# Guidelines for ${data.repo} (${data.byteSize} bytes)\n`);
1112
+ console.log(data.content);
1113
+ }
1114
+ });
1115
+ });
1116
+ group
1117
+ .command('store')
1118
+ .description('Persist per-repo guidelines (overwrites). Reads markdown content from --content or stdin.')
1119
+ .requiredOption('--repo <owner/repo>', 'Repository identifier')
1120
+ .option('--content <markdown>', 'Markdown content. If omitted, reads from stdin.')
1121
+ .option('--json', 'Output as JSON')
1122
+ .action(async (options) => {
1123
+ await executeAction(options, async () => {
1124
+ const content = options.content ?? (await readStdin());
1125
+ return (await import('./commands/guidelines.js')).runGuidelinesStore({ repo: options.repo, content });
1126
+ }, (data) => {
1127
+ console.log(`Stored ${data.byteSize} bytes of guidelines for ${data.repo}.`);
1128
+ });
1129
+ });
1130
+ group
1131
+ .command('reset')
1132
+ .description('Tombstone the guidelines file for a repo (subsequent reads return null)')
1133
+ .requiredOption('--repo <owner/repo>', 'Repository identifier')
1134
+ .option('--json', 'Output as JSON')
1135
+ .action(async (options) => {
1136
+ await executeAction(options, async () => (await import('./commands/guidelines.js')).runGuidelinesReset({ repo: options.repo }), (data) => {
1137
+ console.log(data.deleted
1138
+ ? `Reset guidelines for ${data.repo}.`
1139
+ : `No guidelines existed for ${data.repo}; nothing to reset.`);
1140
+ });
1141
+ });
1142
+ group
1143
+ .command('fetch-corpus')
1144
+ .description('Fetch raw PR comment bundles for the host extract-learnings prompt to consume')
1145
+ .requiredOption('--repo <owner/repo>', 'Repository identifier')
1146
+ .option('--limit <n>', 'Max PRs to process (1-10, default 5)', (v) => parseInt(v, 10))
1147
+ .option('--force', 'Re-fetch even when commentsFetchedAt is already set')
1148
+ .option('--json', 'Output as JSON')
1149
+ .action(async (options) => {
1150
+ await executeAction(options, async () => (await import('./commands/guidelines.js')).runFetchCorpus({
1151
+ repo: options.repo,
1152
+ limit: options.limit,
1153
+ forceRefetch: options.force,
1154
+ }), (data) => {
1155
+ console.log(`Fetched ${data.prCount} PR comment bundle(s) for ${data.repo}.`);
1156
+ if (data.skipped > 0) {
1157
+ console.log(` Skipped ${data.skipped} PR(s) already processed (use --force to re-fetch).`);
1158
+ }
1159
+ });
1160
+ });
1161
+ },
1162
+ },
1093
1163
  ];
1164
+ /** Read full stdin content. Used when `guidelines store` content isn't passed inline. */
1165
+ async function readStdin() {
1166
+ if (process.stdin.isTTY) {
1167
+ throw new Error('No --content provided and stdin is a TTY. Pipe content or pass --content "...".');
1168
+ }
1169
+ let data = '';
1170
+ for await (const chunk of process.stdin)
1171
+ data += chunk;
1172
+ return data;
1173
+ }