@cmnwlth/seed 0.1.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Kristof Feys
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,71 @@
1
+ import { NewNoteInput } from '@cmnwlth/core';
2
+
3
+ /** Options for {@link mineGitHistory}. */
4
+ interface MineGitHistoryOptions {
5
+ /** How many of the most-recent commits to scan. Defaults to 200. */
6
+ maxCommits?: number;
7
+ }
8
+ /**
9
+ * Mine a git repository into candidate notes: ADRs under `docs/adr/` become `decision`
10
+ * candidates, and notable commits / merged PRs become `memory` candidates. Deterministic
11
+ * and offline — pure git/file parsing, stable ordering, no network or LLM. Returns `[]`
12
+ * gracefully when `repoDir` is not a git repo or has no commits.
13
+ *
14
+ * @param repoDir Absolute path to the repository to mine.
15
+ * @param opts Tuning options; see {@link MineGitHistoryOptions}.
16
+ * @returns Candidate notes: ADR decisions first, then git memories.
17
+ */
18
+ declare function mineGitHistory(repoDir: string, opts?: MineGitHistoryOptions): Promise<NewNoteInput[]>;
19
+
20
+ /**
21
+ * Import agent-config files from a repo into `memory` candidate notes. Looks for
22
+ * `CLAUDE.md`, `.cursorrules`, `AGENTS.md`, `.github/copilot-instructions.md`, and any
23
+ * `.claude/rules/*.md`. Missing files are skipped silently. Output is deterministic,
24
+ * sorted by relative path. Each note's title is the file's first `# ` heading if present,
25
+ * otherwise `Project config: <filename>`; the body is the file content (capped).
26
+ *
27
+ * @param repoDir Absolute path to the repository to scan.
28
+ * @returns One `memory` candidate per config file found, tagged `["config", "seed"]`.
29
+ */
30
+ declare function importConfigs(repoDir: string): Promise<NewNoteInput[]>;
31
+
32
+ /** Options for {@link gatherCandidates}. */
33
+ type GatherOptions = MineGitHistoryOptions;
34
+ /** Per-source candidate counts, for previews and reporting. */
35
+ interface GatherBySource {
36
+ /** ADR-derived `decision` candidates. */
37
+ adr: number;
38
+ /** Commit / merged-PR `memory` candidates. */
39
+ git: number;
40
+ /** Agent-config `memory` candidates. */
41
+ config: number;
42
+ }
43
+ /** Result of {@link gatherCandidates}: the full candidate list plus per-source counts. */
44
+ interface GatherResult {
45
+ candidates: NewNoteInput[];
46
+ bySource: GatherBySource;
47
+ }
48
+ /**
49
+ * Gather all cold-start seed candidates from a repository: ADR decisions and notable git
50
+ * commits (via {@link mineGitHistory}) plus agent-config files (via {@link importConfigs}).
51
+ * This is the umbrella the CLI and wizard call. Deterministic and offline; output order is
52
+ * stable — ADR candidates, then git candidates, then config candidates — so a preview run
53
+ * matches the subsequent apply run.
54
+ *
55
+ * @param repoDir Absolute path to the repository to seed from.
56
+ * @param opts Tuning options; see {@link GatherOptions}.
57
+ * @returns The concatenated candidate list and per-source counts.
58
+ */
59
+ declare function gatherCandidates(repoDir: string, opts?: GatherOptions): Promise<GatherResult>;
60
+
61
+ /**
62
+ * Run the `commonwealth-seed` CLI. `preview` prints a human summary; `gather` prints the
63
+ * candidates as a JSON array (and nothing else) on stdout for piping into
64
+ * `commonwealth-curate capture`. Returns the process exit code.
65
+ *
66
+ * @param argv Arguments after `node <script>` (i.e. `process.argv.slice(2)`).
67
+ * @returns Exit code: 0 on success, 2 on usage error.
68
+ */
69
+ declare function run(argv: string[]): Promise<number>;
70
+
71
+ export { type GatherBySource, type GatherOptions, type GatherResult, type MineGitHistoryOptions, gatherCandidates, importConfigs, mineGitHistory, run };
package/dist/index.js ADDED
@@ -0,0 +1,268 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { parseArgs } from "util";
5
+
6
+ // src/config-importer.ts
7
+ import { promises as fs } from "fs";
8
+ import path from "path";
9
+ var BODY_CAP = 4e3;
10
+ var FIXED_CONFIG_PATHS = [
11
+ "CLAUDE.md",
12
+ ".cursorrules",
13
+ "AGENTS.md",
14
+ path.join(".github", "copilot-instructions.md")
15
+ ];
16
+ var RULES_DIR = path.join(".claude", "rules");
17
+ function capBody(text) {
18
+ const trimmed = text.trim();
19
+ return trimmed.length > BODY_CAP ? trimmed.slice(0, BODY_CAP) : trimmed;
20
+ }
21
+ async function collectConfigPaths(repoDir) {
22
+ const found = [];
23
+ for (const rel of FIXED_CONFIG_PATHS) {
24
+ try {
25
+ const stat = await fs.stat(path.join(repoDir, rel));
26
+ if (stat.isFile()) found.push(rel);
27
+ } catch {
28
+ }
29
+ }
30
+ try {
31
+ const entries = await fs.readdir(path.join(repoDir, RULES_DIR));
32
+ for (const name of entries) {
33
+ if (name.toLowerCase().endsWith(".md")) {
34
+ found.push(path.join(RULES_DIR, name));
35
+ }
36
+ }
37
+ } catch {
38
+ }
39
+ return [...new Set(found)].sort();
40
+ }
41
+ async function importConfigs(repoDir) {
42
+ const relPaths = await collectConfigPaths(repoDir);
43
+ const notes = [];
44
+ for (const rel of relPaths) {
45
+ let content;
46
+ try {
47
+ content = await fs.readFile(path.join(repoDir, rel), "utf8");
48
+ } catch {
49
+ continue;
50
+ }
51
+ const filename = path.basename(rel);
52
+ const headingMatch = content.match(/^#\s+(.+)$/m);
53
+ const title = headingMatch ? headingMatch[1].trim() : `Project config: ${filename}`;
54
+ notes.push({
55
+ kind: "memory",
56
+ title,
57
+ body: capBody(content),
58
+ tags: ["config", "seed"]
59
+ });
60
+ }
61
+ return notes;
62
+ }
63
+
64
+ // src/git-miner.ts
65
+ import { execFile } from "child_process";
66
+ import { promises as fs2 } from "fs";
67
+ import path2 from "path";
68
+ import { promisify } from "util";
69
+ var execFileAsync = promisify(execFile);
70
+ var BODY_CAP2 = 4e3;
71
+ var FIELD_SEP = String.fromCharCode(31);
72
+ var RECORD_SEP = String.fromCharCode(30);
73
+ var TRIVIAL_SUBJECT = /^(?:(?:wip|fixup|bump)(?=$|[\s:!])|merge branch\b|chore\(deps\))/i;
74
+ var SQUASH_PR = /\(#(\d+)\)\s*$/;
75
+ var MERGE_PR = /^Merge pull request #(\d+) from /;
76
+ function normalizeTitle(title) {
77
+ return title.trim().replace(/\s+/g, " ").toLowerCase();
78
+ }
79
+ function capBody2(text) {
80
+ const trimmed = text.trim();
81
+ return trimmed.length > BODY_CAP2 ? trimmed.slice(0, BODY_CAP2) : trimmed;
82
+ }
83
+ async function mineAdrs(repoDir) {
84
+ const adrDir = path2.join(repoDir, "docs", "adr");
85
+ let entries;
86
+ try {
87
+ entries = await fs2.readdir(adrDir);
88
+ } catch {
89
+ return [];
90
+ }
91
+ const files = entries.filter((name) => name.toLowerCase().endsWith(".md")).filter((name) => {
92
+ const lower = name.toLowerCase();
93
+ return lower !== "readme.md" && lower !== "index.md";
94
+ }).sort();
95
+ const notes = [];
96
+ for (const name of files) {
97
+ const full = path2.join(adrDir, name);
98
+ let content;
99
+ try {
100
+ content = await fs2.readFile(full, "utf8");
101
+ } catch {
102
+ continue;
103
+ }
104
+ const headingMatch = content.match(/^#\s+(.+)$/m);
105
+ const title = headingMatch ? headingMatch[1].trim() : name.replace(/\.md$/i, "");
106
+ notes.push({
107
+ kind: "decision",
108
+ title,
109
+ body: capBody2(content),
110
+ // These are literal ADRs, so they map to `decision` notes. Whether they actually
111
+ // stage is governed by curate's autoAdr gate downstream — that's the wizard's concern.
112
+ tags: ["adr", "seed"]
113
+ });
114
+ }
115
+ return notes;
116
+ }
117
+ async function readCommits(repoDir, maxCommits) {
118
+ const format = ["%s", "%b"].join(FIELD_SEP) + RECORD_SEP;
119
+ let stdout;
120
+ try {
121
+ const result = await execFileAsync(
122
+ "git",
123
+ ["log", `--max-count=${maxCommits}`, `--pretty=format:${format}`],
124
+ { cwd: repoDir, maxBuffer: 64 * 1024 * 1024 }
125
+ );
126
+ stdout = result.stdout;
127
+ } catch {
128
+ return [];
129
+ }
130
+ return stdout.split(RECORD_SEP).map((record) => record.replace(/^\n+/, "")).filter((record) => record.length > 0).map((record) => {
131
+ const [subject = "", body = ""] = record.split(FIELD_SEP);
132
+ return { subject: subject.trim(), body: body.trim() };
133
+ }).filter((record) => record.subject.length > 0);
134
+ }
135
+ function minePrsAndCommits(commits) {
136
+ const notes = [];
137
+ const seen = /* @__PURE__ */ new Set();
138
+ for (const { subject, body } of commits) {
139
+ const squashMatch = subject.match(SQUASH_PR);
140
+ const mergeMatch = subject.match(MERGE_PR);
141
+ const prNumber = squashMatch?.[1] ?? mergeMatch?.[1] ?? null;
142
+ const title = squashMatch ? subject.replace(SQUASH_PR, "").trim() : subject;
143
+ if (title.length === 0) continue;
144
+ if (prNumber === null && TRIVIAL_SUBJECT.test(subject)) continue;
145
+ const hasBody = body.length > 0;
146
+ if (prNumber === null && !hasBody) continue;
147
+ if (mergeMatch && !hasBody) continue;
148
+ const key = normalizeTitle(title);
149
+ if (seen.has(key)) continue;
150
+ seen.add(key);
151
+ const tags = prNumber !== null ? ["git", "seed", "pr"] : ["git", "seed"];
152
+ notes.push({
153
+ kind: "memory",
154
+ title,
155
+ body: capBody2(hasBody ? body : title),
156
+ tags
157
+ });
158
+ }
159
+ return notes;
160
+ }
161
+ async function mineGitHistory(repoDir, opts) {
162
+ const maxCommits = opts?.maxCommits ?? 200;
163
+ const adrs = await mineAdrs(repoDir);
164
+ const commits = await readCommits(repoDir, maxCommits);
165
+ const gitNotes = minePrsAndCommits(commits);
166
+ return [...adrs, ...gitNotes];
167
+ }
168
+
169
+ // src/seed.ts
170
+ async function gatherCandidates(repoDir, opts) {
171
+ const gitCandidates = await mineGitHistory(repoDir, opts);
172
+ const configCandidates = await importConfigs(repoDir);
173
+ const adr = gitCandidates.filter((n) => n.kind === "decision");
174
+ const git = gitCandidates.filter((n) => n.kind !== "decision");
175
+ const candidates = [...adr, ...git, ...configCandidates];
176
+ return {
177
+ candidates,
178
+ bySource: {
179
+ adr: adr.length,
180
+ git: git.length,
181
+ config: configCandidates.length
182
+ }
183
+ };
184
+ }
185
+
186
+ // src/index.ts
187
+ var PREVIEW_SAMPLE_LIMIT = 10;
188
+ function printUsage() {
189
+ process.stderr.write(
190
+ [
191
+ "commonwealth-seed \u2014 produce cold-start seed candidates from a repo",
192
+ "",
193
+ "Usage:",
194
+ " commonwealth-seed preview [--repo <dir>] Summarize candidates for eyeballing",
195
+ " commonwealth-seed gather [--repo <dir>] Emit candidates as JSON (pipe to curate)",
196
+ "",
197
+ "Pipe into curate to stage them:",
198
+ " commonwealth-seed gather | commonwealth-curate capture",
199
+ ""
200
+ ].join("\n")
201
+ );
202
+ }
203
+ async function run(argv) {
204
+ const [command, ...rest] = argv;
205
+ if (command === void 0 || command === "--help" || command === "-h") {
206
+ printUsage();
207
+ return command === void 0 ? 2 : 0;
208
+ }
209
+ if (command !== "preview" && command !== "gather") {
210
+ process.stderr.write(`Unknown command: ${command}
211
+ `);
212
+ printUsage();
213
+ return 2;
214
+ }
215
+ let repo;
216
+ try {
217
+ const { values } = parseArgs({
218
+ args: rest,
219
+ options: {
220
+ repo: { type: "string" }
221
+ },
222
+ allowPositionals: false
223
+ });
224
+ repo = values.repo ?? process.cwd();
225
+ } catch (err) {
226
+ process.stderr.write(`${err.message}
227
+ `);
228
+ printUsage();
229
+ return 2;
230
+ }
231
+ const { candidates, bySource } = await gatherCandidates(repo);
232
+ if (command === "gather") {
233
+ process.stdout.write(JSON.stringify(candidates) + "\n");
234
+ return 0;
235
+ }
236
+ const lines = [];
237
+ lines.push(`${candidates.length} candidate${candidates.length === 1 ? "" : "s"}`);
238
+ lines.push(`adr: ${bySource.adr}, git: ${bySource.git}, config: ${bySource.config}`);
239
+ if (candidates.length > 0) {
240
+ lines.push("");
241
+ lines.push("Sample titles:");
242
+ for (const note of candidates.slice(0, PREVIEW_SAMPLE_LIMIT)) {
243
+ lines.push(` - [${note.kind}] ${note.title}`);
244
+ }
245
+ if (candidates.length > PREVIEW_SAMPLE_LIMIT) {
246
+ lines.push(` \u2026 and ${candidates.length - PREVIEW_SAMPLE_LIMIT} more`);
247
+ }
248
+ }
249
+ process.stdout.write(lines.join("\n") + "\n");
250
+ return 0;
251
+ }
252
+ var isEntrypoint = process.argv[1] !== void 0 && import.meta.url === new URL(`file://${process.argv[1]}`).href;
253
+ if (isEntrypoint) {
254
+ run(process.argv.slice(2)).then((code) => {
255
+ process.exitCode = code;
256
+ }).catch((err) => {
257
+ process.stderr.write(`${err.stack ?? String(err)}
258
+ `);
259
+ process.exitCode = 1;
260
+ });
261
+ }
262
+ export {
263
+ gatherCandidates,
264
+ importConfigs,
265
+ mineGitHistory,
266
+ run
267
+ };
268
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/config-importer.ts","../src/git-miner.ts","../src/seed.ts"],"sourcesContent":["import { parseArgs } from \"node:util\";\nimport { gatherCandidates } from \"./seed.js\";\n\nexport { mineGitHistory, type MineGitHistoryOptions } from \"./git-miner.js\";\nexport { importConfigs } from \"./config-importer.js\";\nexport {\n gatherCandidates,\n type GatherOptions,\n type GatherResult,\n type GatherBySource,\n} from \"./seed.js\";\n\n/** How many sample titles the `preview` subcommand prints. */\nconst PREVIEW_SAMPLE_LIMIT = 10;\n\n/** Print human-readable usage to stderr. */\nfunction printUsage(): void {\n process.stderr.write(\n [\n \"commonwealth-seed — produce cold-start seed candidates from a repo\",\n \"\",\n \"Usage:\",\n \" commonwealth-seed preview [--repo <dir>] Summarize candidates for eyeballing\",\n \" commonwealth-seed gather [--repo <dir>] Emit candidates as JSON (pipe to curate)\",\n \"\",\n \"Pipe into curate to stage them:\",\n \" commonwealth-seed gather | commonwealth-curate capture\",\n \"\",\n ].join(\"\\n\"),\n );\n}\n\n/**\n * Run the `commonwealth-seed` CLI. `preview` prints a human summary; `gather` prints the\n * candidates as a JSON array (and nothing else) on stdout for piping into\n * `commonwealth-curate capture`. Returns the process exit code.\n *\n * @param argv Arguments after `node <script>` (i.e. `process.argv.slice(2)`).\n * @returns Exit code: 0 on success, 2 on usage error.\n */\nexport async function run(argv: string[]): Promise<number> {\n const [command, ...rest] = argv;\n\n if (command === undefined || command === \"--help\" || command === \"-h\") {\n printUsage();\n return command === undefined ? 2 : 0;\n }\n\n if (command !== \"preview\" && command !== \"gather\") {\n process.stderr.write(`Unknown command: ${command}\\n`);\n printUsage();\n return 2;\n }\n\n let repo: string;\n try {\n const { values } = parseArgs({\n args: rest,\n options: {\n repo: { type: \"string\" },\n },\n allowPositionals: false,\n });\n repo = values.repo ?? process.cwd();\n } catch (err) {\n process.stderr.write(`${(err as Error).message}\\n`);\n printUsage();\n return 2;\n }\n\n const { candidates, bySource } = await gatherCandidates(repo);\n\n if (command === \"gather\") {\n process.stdout.write(JSON.stringify(candidates) + \"\\n\");\n return 0;\n }\n\n // preview\n const lines: string[] = [];\n lines.push(`${candidates.length} candidate${candidates.length === 1 ? \"\" : \"s\"}`);\n lines.push(`adr: ${bySource.adr}, git: ${bySource.git}, config: ${bySource.config}`);\n if (candidates.length > 0) {\n lines.push(\"\");\n lines.push(\"Sample titles:\");\n for (const note of candidates.slice(0, PREVIEW_SAMPLE_LIMIT)) {\n lines.push(` - [${note.kind}] ${note.title}`);\n }\n if (candidates.length > PREVIEW_SAMPLE_LIMIT) {\n lines.push(` … and ${candidates.length - PREVIEW_SAMPLE_LIMIT} more`);\n }\n }\n process.stdout.write(lines.join(\"\\n\") + \"\\n\");\n return 0;\n}\n\nconst isEntrypoint =\n process.argv[1] !== undefined && import.meta.url === new URL(`file://${process.argv[1]}`).href;\n\nif (isEntrypoint) {\n run(process.argv.slice(2))\n .then((code) => {\n process.exitCode = code;\n })\n .catch((err: unknown) => {\n process.stderr.write(`${(err as Error).stack ?? String(err)}\\n`);\n process.exitCode = 1;\n });\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport type { NewNoteInput } from \"@cmnwlth/core\";\n\n/** Max characters retained from any imported config file. */\nconst BODY_CAP = 4000;\n\n/**\n * Fixed agent-config paths to import when present, relative to the repo root. Order here\n * is the tiebreak base; final output is re-sorted by path for determinism.\n */\nconst FIXED_CONFIG_PATHS = [\n \"CLAUDE.md\",\n \".cursorrules\",\n \"AGENTS.md\",\n path.join(\".github\", \"copilot-instructions.md\"),\n];\n\n/** Directory of extra rule files to glob (each `*.md` becomes its own note). */\nconst RULES_DIR = path.join(\".claude\", \"rules\");\n\n/** Cap a string to {@link BODY_CAP} characters after trimming. */\nfunction capBody(text: string): string {\n const trimmed = text.trim();\n return trimmed.length > BODY_CAP ? trimmed.slice(0, BODY_CAP) : trimmed;\n}\n\n/** Collect the set of relative config paths that exist under `repoDir`, sorted. */\nasync function collectConfigPaths(repoDir: string): Promise<string[]> {\n const found: string[] = [];\n\n for (const rel of FIXED_CONFIG_PATHS) {\n try {\n const stat = await fs.stat(path.join(repoDir, rel));\n if (stat.isFile()) found.push(rel);\n } catch {\n // Missing file — skip silently.\n }\n }\n\n try {\n const entries = await fs.readdir(path.join(repoDir, RULES_DIR));\n for (const name of entries) {\n if (name.toLowerCase().endsWith(\".md\")) {\n found.push(path.join(RULES_DIR, name));\n }\n }\n } catch {\n // No rules dir — skip silently.\n }\n\n // Deterministic ordering, sorted by relative path.\n return [...new Set(found)].sort();\n}\n\n/**\n * Import agent-config files from a repo into `memory` candidate notes. Looks for\n * `CLAUDE.md`, `.cursorrules`, `AGENTS.md`, `.github/copilot-instructions.md`, and any\n * `.claude/rules/*.md`. Missing files are skipped silently. Output is deterministic,\n * sorted by relative path. Each note's title is the file's first `# ` heading if present,\n * otherwise `Project config: <filename>`; the body is the file content (capped).\n *\n * @param repoDir Absolute path to the repository to scan.\n * @returns One `memory` candidate per config file found, tagged `[\"config\", \"seed\"]`.\n */\nexport async function importConfigs(repoDir: string): Promise<NewNoteInput[]> {\n const relPaths = await collectConfigPaths(repoDir);\n\n const notes: NewNoteInput[] = [];\n for (const rel of relPaths) {\n let content: string;\n try {\n content = await fs.readFile(path.join(repoDir, rel), \"utf8\");\n } catch {\n continue;\n }\n const filename = path.basename(rel);\n const headingMatch = content.match(/^#\\s+(.+)$/m);\n const title = headingMatch ? headingMatch[1]!.trim() : `Project config: ${filename}`;\n notes.push({\n kind: \"memory\",\n title,\n body: capBody(content),\n tags: [\"config\", \"seed\"],\n });\n }\n return notes;\n}\n","import { execFile } from \"node:child_process\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { promisify } from \"node:util\";\nimport type { NewNoteInput } from \"@cmnwlth/core\";\n\nconst execFileAsync = promisify(execFile);\n\n/** Max characters retained from any single mined body. */\nconst BODY_CAP = 4000;\n\n/**\n * Control-character separators so commit fields/records never collide with commit\n * content. Git's unit separator (0x1f) and record separator (0x1e) are safe: they cannot\n * appear in a commit subject or body. Built via char codes to keep source bytes clean.\n */\nconst FIELD_SEP = String.fromCharCode(0x1f);\nconst RECORD_SEP = String.fromCharCode(0x1e);\n\n/** Options for {@link mineGitHistory}. */\nexport interface MineGitHistoryOptions {\n /** How many of the most-recent commits to scan. Defaults to 200. */\n maxCommits?: number;\n}\n\n/**\n * Subjects that are noise and never worth a memory note (unless they carry a #N).\n * Anchored to token boundaries so real work isn't dropped: \"wip\"/\"bump\"/\"fixup\" must be a\n * whole token (kept: \"wipe out cache\", \"bumper feature\", \"fixups after review\"); \"merge\n * branch\" needs a word boundary (kept: \"merge branches together\"); \"chore(deps)\" is exact.\n */\nconst TRIVIAL_SUBJECT = /^(?:(?:wip|fixup|bump)(?=$|[\\s:!])|merge branch\\b|chore\\(deps\\))/i;\n\n/** Squash-merge suffix, e.g. \"feat: add auth (#12)\". */\nconst SQUASH_PR = /\\(#(\\d+)\\)\\s*$/;\n\n/** GitHub merge-commit subject, e.g. \"Merge pull request #13 from x/y\". */\nconst MERGE_PR = /^Merge pull request #(\\d+) from /;\n\n/** Trim, collapse internal whitespace, and lowercase a title for dedupe keys. */\nfunction normalizeTitle(title: string): string {\n return title.trim().replace(/\\s+/g, \" \").toLowerCase();\n}\n\n/** Cap a string to {@link BODY_CAP} characters after trimming. */\nfunction capBody(text: string): string {\n const trimmed = text.trim();\n return trimmed.length > BODY_CAP ? trimmed.slice(0, BODY_CAP) : trimmed;\n}\n\n/**\n * Parse ADR markdown files under `docs/adr/`, skipping `README.md` and `index.md`.\n * Each becomes a `decision` candidate. Ordering is stable (sorted by filename).\n */\nasync function mineAdrs(repoDir: string): Promise<NewNoteInput[]> {\n const adrDir = path.join(repoDir, \"docs\", \"adr\");\n let entries: string[];\n try {\n entries = await fs.readdir(adrDir);\n } catch {\n return [];\n }\n\n const files = entries\n .filter((name) => name.toLowerCase().endsWith(\".md\"))\n .filter((name) => {\n const lower = name.toLowerCase();\n return lower !== \"readme.md\" && lower !== \"index.md\";\n })\n .sort();\n\n const notes: NewNoteInput[] = [];\n for (const name of files) {\n const full = path.join(adrDir, name);\n let content: string;\n try {\n content = await fs.readFile(full, \"utf8\");\n } catch {\n continue;\n }\n const headingMatch = content.match(/^#\\s+(.+)$/m);\n const title = headingMatch ? headingMatch[1]!.trim() : name.replace(/\\.md$/i, \"\");\n notes.push({\n kind: \"decision\",\n title,\n body: capBody(content),\n // These are literal ADRs, so they map to `decision` notes. Whether they actually\n // stage is governed by curate's autoAdr gate downstream — that's the wizard's concern.\n tags: [\"adr\", \"seed\"],\n });\n }\n return notes;\n}\n\n/**\n * Read the most-recent commits (subject + body) as structured records. Returns `[]` if\n * the directory is not a git repo or has no commits.\n */\nasync function readCommits(\n repoDir: string,\n maxCommits: number,\n): Promise<{ subject: string; body: string }[]> {\n const format = [\"%s\", \"%b\"].join(FIELD_SEP) + RECORD_SEP;\n let stdout: string;\n try {\n const result = await execFileAsync(\n \"git\",\n [\"log\", `--max-count=${maxCommits}`, `--pretty=format:${format}`],\n { cwd: repoDir, maxBuffer: 64 * 1024 * 1024 },\n );\n stdout = result.stdout;\n } catch {\n return [];\n }\n\n return stdout\n .split(RECORD_SEP)\n .map((record) => record.replace(/^\\n+/, \"\"))\n .filter((record) => record.length > 0)\n .map((record) => {\n const [subject = \"\", body = \"\"] = record.split(FIELD_SEP);\n return { subject: subject.trim(), body: body.trim() };\n })\n .filter((record) => record.subject.length > 0);\n}\n\n/**\n * Turn commits into `memory` candidates. Captures both squash-merge subjects\n * (`… (#N)`) and GitHub merge commits (`Merge pull request #N …`); skips trivia.\n */\nfunction minePrsAndCommits(commits: { subject: string; body: string }[]): NewNoteInput[] {\n const notes: NewNoteInput[] = [];\n const seen = new Set<string>();\n\n for (const { subject, body } of commits) {\n const squashMatch = subject.match(SQUASH_PR);\n const mergeMatch = subject.match(MERGE_PR);\n const prNumber = squashMatch?.[1] ?? mergeMatch?.[1] ?? null;\n\n // Title: strip a trailing \"(#N)\" from squash subjects; keep merge subjects as-is.\n const title = squashMatch ? subject.replace(SQUASH_PR, \"\").trim() : subject;\n if (title.length === 0) continue;\n\n // Skip trivia by subject, unless it carries a #N (then it's a real PR/merge).\n if (prNumber === null && TRIVIAL_SUBJECT.test(subject)) continue;\n\n // Skip commits with an empty/trivial body AND no #N reference.\n const hasBody = body.length > 0;\n if (prNumber === null && !hasBody) continue;\n\n // A raw GitHub merge commit with no description is boilerplate (\"Merge pull request\n // #N from x/y\") — skip it rather than echo the subject as the body. Squash subjects\n // (#N) carry real content, so keep those even without a body.\n if (mergeMatch && !hasBody) continue;\n\n const key = normalizeTitle(title);\n if (seen.has(key)) continue;\n seen.add(key);\n\n const tags = prNumber !== null ? [\"git\", \"seed\", \"pr\"] : [\"git\", \"seed\"];\n notes.push({\n kind: \"memory\",\n title,\n body: capBody(hasBody ? body : title),\n tags,\n });\n }\n return notes;\n}\n\n/**\n * Mine a git repository into candidate notes: ADRs under `docs/adr/` become `decision`\n * candidates, and notable commits / merged PRs become `memory` candidates. Deterministic\n * and offline — pure git/file parsing, stable ordering, no network or LLM. Returns `[]`\n * gracefully when `repoDir` is not a git repo or has no commits.\n *\n * @param repoDir Absolute path to the repository to mine.\n * @param opts Tuning options; see {@link MineGitHistoryOptions}.\n * @returns Candidate notes: ADR decisions first, then git memories.\n */\nexport async function mineGitHistory(\n repoDir: string,\n opts?: MineGitHistoryOptions,\n): Promise<NewNoteInput[]> {\n const maxCommits = opts?.maxCommits ?? 200;\n const adrs = await mineAdrs(repoDir);\n const commits = await readCommits(repoDir, maxCommits);\n const gitNotes = minePrsAndCommits(commits);\n return [...adrs, ...gitNotes];\n}\n","import type { NewNoteInput } from \"@cmnwlth/core\";\nimport { importConfigs } from \"./config-importer.js\";\nimport { mineGitHistory, type MineGitHistoryOptions } from \"./git-miner.js\";\n\n/** Options for {@link gatherCandidates}. */\nexport type GatherOptions = MineGitHistoryOptions;\n\n/** Per-source candidate counts, for previews and reporting. */\nexport interface GatherBySource {\n /** ADR-derived `decision` candidates. */\n adr: number;\n /** Commit / merged-PR `memory` candidates. */\n git: number;\n /** Agent-config `memory` candidates. */\n config: number;\n}\n\n/** Result of {@link gatherCandidates}: the full candidate list plus per-source counts. */\nexport interface GatherResult {\n candidates: NewNoteInput[];\n bySource: GatherBySource;\n}\n\n/**\n * Gather all cold-start seed candidates from a repository: ADR decisions and notable git\n * commits (via {@link mineGitHistory}) plus agent-config files (via {@link importConfigs}).\n * This is the umbrella the CLI and wizard call. Deterministic and offline; output order is\n * stable — ADR candidates, then git candidates, then config candidates — so a preview run\n * matches the subsequent apply run.\n *\n * @param repoDir Absolute path to the repository to seed from.\n * @param opts Tuning options; see {@link GatherOptions}.\n * @returns The concatenated candidate list and per-source counts.\n */\nexport async function gatherCandidates(\n repoDir: string,\n opts?: GatherOptions,\n): Promise<GatherResult> {\n const gitCandidates = await mineGitHistory(repoDir, opts);\n const configCandidates = await importConfigs(repoDir);\n\n // mineGitHistory returns ADR (decision) candidates first, then git (memory) candidates.\n // Split them back out so bySource is accurate and ordering is explicit.\n const adr = gitCandidates.filter((n) => n.kind === \"decision\");\n const git = gitCandidates.filter((n) => n.kind !== \"decision\");\n\n const candidates = [...adr, ...git, ...configCandidates];\n return {\n candidates,\n bySource: {\n adr: adr.length,\n git: git.length,\n config: configCandidates.length,\n },\n };\n}\n"],"mappings":";;;AAAA,SAAS,iBAAiB;;;ACA1B,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AAIjB,IAAM,WAAW;AAMjB,IAAM,qBAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;A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C3B,eAAW,QAAQ,WAAW,MAAM,GAAG,oBAAoB,GAAG;AAC5D,YAAM,KAAK,QAAQ,KAAK,IAAI,KAAK,KAAK,KAAK,EAAE;AAAA,IAC/C;AACA,QAAI,WAAW,SAAS,sBAAsB;AAC5C,YAAM,KAAK,gBAAW,WAAW,SAAS,oBAAoB,OAAO;AAAA,IACvE;AAAA,EACF;AACA,UAAQ,OAAO,MAAM,MAAM,KAAK,IAAI,IAAI,IAAI;AAC5C,SAAO;AACT;AAEA,IAAM,eACJ,QAAQ,KAAK,CAAC,MAAM,UAAa,YAAY,QAAQ,IAAI,IAAI,UAAU,QAAQ,KAAK,CAAC,CAAC,EAAE,EAAE;AAE5F,IAAI,cAAc;AAChB,MAAI,QAAQ,KAAK,MAAM,CAAC,CAAC,EACtB,KAAK,CAAC,SAAS;AACd,YAAQ,WAAW;AAAA,EACrB,CAAC,EACA,MAAM,CAAC,QAAiB;AACvB,YAAQ,OAAO,MAAM,GAAI,IAAc,SAAS,OAAO,GAAG,CAAC;AAAA,CAAI;AAC/D,YAAQ,WAAW;AAAA,EACrB,CAAC;AACL;","names":["fs","path","BODY_CAP","capBody"]}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@cmnwlth/seed",
3
+ "version": "0.1.0",
4
+ "description": "Cold-start seeding: mine git history + import agent-config into candidate notes",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "commonwealth-seed": "./dist/index.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "dependencies": {
16
+ "@cmnwlth/core": "0.1.0"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public",
20
+ "provenance": true
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/kristoffeys/commonwealth.git",
25
+ "directory": "packages/seed"
26
+ },
27
+ "homepage": "https://github.com/kristoffeys/commonwealth#readme",
28
+ "bugs": "https://github.com/kristoffeys/commonwealth/issues",
29
+ "scripts": {
30
+ "build": "tsup",
31
+ "typecheck": "tsc --noEmit"
32
+ }
33
+ }