baselane 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,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 Mohammad Omar
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # baselane
2
+
3
+ Git-native package manager for AI coding harnesses. `baselane` audits a repo, applies
4
+ workflow packs (agent rules, skills, subagent configs) into `AGENTS.md`/`CLAUDE.md`/
5
+ `.claude/` and friends, and keeps them in sync as packs change — without ever clobbering
6
+ content you already own.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm install -g baselane
12
+ ```
13
+
14
+ Requires Node 24+.
15
+
16
+ ## Usage
17
+
18
+ Audit a repo and see what packs would apply:
19
+
20
+ ```sh
21
+ baselane audit .
22
+ ```
23
+
24
+ Apply a workflow pack (e.g. the `disciplined-workflow` pack) into the current repo:
25
+
26
+ ```sh
27
+ baselane apply . --pack disciplined-workflow
28
+ ```
29
+
30
+ Install a specific pack or skill by version, and check for drift later:
31
+
32
+ ```sh
33
+ baselane install @baselane/frontend-taste@1.2.0
34
+ baselane drift
35
+ ```
36
+
37
+ See `baselane --help` for the full command reference (`apply`, `distribute`, `draft-pack`,
38
+ `graph`, `map`, `install`, `update`, `drift`, `publish`).
39
+
40
+ Full docs: https://baselane.sh
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ // Plain .mjs re-exec shim, two modes:
3
+ // - published tarball: `dist/bin.js` exists (built at publish time, see package.json
4
+ // "build"/"prepublishOnly") — run it directly with plain node, no experimental flags.
5
+ // - workspace dev tree: no `dist/`, ships `src/*.ts` as-is (see AGENTS.md) — re-launch node
6
+ // with the flag that lets it load TypeScript sources directly.
7
+ import { spawn } from "node:child_process";
8
+ import { existsSync } from "node:fs";
9
+ import { fileURLToPath } from "node:url";
10
+ import { dirname, join } from "node:path";
11
+
12
+ const here = dirname(fileURLToPath(import.meta.url));
13
+ const distBin = join(here, "..", "dist", "bin.js");
14
+ const isBuilt = existsSync(distBin);
15
+
16
+ if (!isBuilt) {
17
+ const majorVersion = Number(process.versions.node.split(".")[0]);
18
+ if (majorVersion < 24) {
19
+ console.error(
20
+ `baselane requires Node 24+ (found Node ${process.versions.node}). ` +
21
+ "Install a newer Node and try again.",
22
+ );
23
+ process.exit(1);
24
+ }
25
+ }
26
+
27
+ const args = isBuilt
28
+ ? [distBin, ...process.argv.slice(2)]
29
+ : ["--experimental-transform-types", "--no-warnings", join(here, "..", "src", "bin.ts"), ...process.argv.slice(2)];
30
+
31
+ const child = spawn(process.execPath, args, { stdio: "inherit" });
32
+
33
+ child.on("exit", (code, signal) => {
34
+ if (signal) {
35
+ process.kill(process.pid, signal);
36
+ } else {
37
+ process.exit(code ?? 1);
38
+ }
39
+ });
40
+
41
+ child.on("error", (err) => {
42
+ console.error(`baselane: failed to launch (${err.message})`);
43
+ process.exit(1);
44
+ });
@@ -0,0 +1,16 @@
1
+ import { type WorkflowPack } from "@baselane/packs";
2
+ export interface ApplyOptions {
3
+ force: boolean;
4
+ dryRun: boolean;
5
+ }
6
+ export interface ApplyResult {
7
+ /** Paths written (or that would be written, on dry-run). */
8
+ written: string[];
9
+ /** Paths left untouched because they exist and force is off. */
10
+ skipped: string[];
11
+ }
12
+ export declare function assertInsideDir(rootDir: string, rel: string): string;
13
+ export declare function applyResolvedPack(targetDir: string, pack: WorkflowPack, opts: ApplyOptions): Promise<ApplyResult>;
14
+ /** Built-in-pack convenience wrapper over applyResolvedPack — kept so existing callers that
15
+ * only ever deal in built-in pack ids don't need to load the pack themselves. */
16
+ export declare function applyPack(targetDir: string, packId: string, opts: ApplyOptions): Promise<ApplyResult>;
package/dist/apply.js ADDED
@@ -0,0 +1,103 @@
1
+ import { lstat, mkdir, readFile, stat, writeFile } from "node:fs/promises";
2
+ import { dirname, join, resolve, sep } from "node:path";
3
+ import { isEntryFile, loadBuiltinPack, mergeManagedRegion, renderPack } from "@baselane/packs";
4
+ async function exists(path) {
5
+ try {
6
+ await stat(path);
7
+ return true;
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ }
13
+ // Lexical containment only — mirrors apps/agent/src/fs-ops.ts resolveInside.
14
+ // Builtin packs only ever produce safe keys today; this guard exists ahead of
15
+ // any future external/third-party pack loading. It does NOT follow symlinks —
16
+ // assertNoSymlinkWithin below is the runtime companion that refuses those.
17
+ export function assertInsideDir(rootDir, rel) {
18
+ const abs = resolve(rootDir, rel);
19
+ const rootAbs = resolve(rootDir);
20
+ if (abs !== rootAbs && !abs.startsWith(rootAbs + sep)) {
21
+ throw new Error(`pack file "${rel}" escapes target dir`);
22
+ }
23
+ return abs;
24
+ }
25
+ // #30: lexical containment is defeated by a symlinked directory inside the target — a `.claude`
26
+ // symlink pointing outside would let a write escape even though the path is lexically inside.
27
+ // Walk each path segment and refuse if any is a symlink, mirroring apps/agent/src/fs-ops.ts's
28
+ // assertNoSymlinkWithin (which apply.ts previously only CLAIMED to mirror). Matters once
29
+ // untrusted/AI-drafted packs can be applied. Segments the pack key on "/" (its keys are always
30
+ // forward-slash joined), same as fs-ops.ts.
31
+ async function assertNoSymlinkWithin(rootDir, rel) {
32
+ let current = resolve(rootDir);
33
+ for (const segment of rel.split("/")) {
34
+ current = join(current, segment);
35
+ let stats;
36
+ try {
37
+ stats = await lstat(current);
38
+ }
39
+ catch (err) {
40
+ const code = err.code;
41
+ if (code === "ENOENT" || code === "ENOTDIR")
42
+ return; // remainder doesn't exist yet — mkdir makes real dirs
43
+ throw err;
44
+ }
45
+ if (stats.isSymbolicLink()) {
46
+ throw new Error(`pack file "${rel}" traverses a symlink ("${segment}") — refusing`);
47
+ }
48
+ }
49
+ }
50
+ // #6: the actual apply logic against an already-resolved pack — a built-in id (applyPack
51
+ // below) or a custom pack loaded from --pack-file and validatePack'd by the caller. Neither
52
+ // path trusts an unvalidated pack object; this function just doesn't care which one it got.
53
+ export async function applyResolvedPack(targetDir, pack, opts) {
54
+ const target = await stat(targetDir).catch(() => null);
55
+ if (!target || !target.isDirectory()) {
56
+ throw new Error(`target is not a directory: ${targetDir}`);
57
+ }
58
+ const files = renderPack(pack);
59
+ const written = [];
60
+ const skipped = [];
61
+ for (const [rel, content] of Object.entries(files)) {
62
+ const abs = assertInsideDir(targetDir, rel);
63
+ // Refuse before ANY read/write of abs (entry-file merge included) so a symlinked segment
64
+ // can neither exfiltrate an existing file's contents nor redirect a write outside the target.
65
+ await assertNoSymlinkWithin(targetDir, rel);
66
+ // ENTRY files (AGENTS.md/CLAUDE.md/...) region-merge into whatever is already on
67
+ // disk instead of being skipped or clobbered — preserving a developer's existing
68
+ // content is always safe, so this ignores force/skip and applies every time.
69
+ if (isEntryFile(rel)) {
70
+ const existing = (await exists(abs)) ? await readFile(abs, "utf8") : null;
71
+ const merged = mergeManagedRegion(existing, content, pack.id, pack.version);
72
+ // #33: the merge is idempotent — re-applying the same pack version onto an already-merged
73
+ // file reproduces the same bytes. Only count/write it when the merge actually changes
74
+ // something, so --dry-run doesn't claim "written" for a no-op, and a real apply doesn't
75
+ // needlessly rewrite an untouched file.
76
+ const changed = merged !== existing;
77
+ if (changed) {
78
+ written.push(rel);
79
+ if (!opts.dryRun) {
80
+ await mkdir(dirname(abs), { recursive: true });
81
+ await writeFile(abs, merged, "utf8");
82
+ }
83
+ }
84
+ continue;
85
+ }
86
+ if (!opts.force && (await exists(abs))) {
87
+ skipped.push(rel);
88
+ continue;
89
+ }
90
+ written.push(rel);
91
+ if (!opts.dryRun) {
92
+ await mkdir(dirname(abs), { recursive: true });
93
+ await writeFile(abs, content, "utf8");
94
+ }
95
+ }
96
+ return { written: written.sort(), skipped: skipped.sort() };
97
+ }
98
+ /** Built-in-pack convenience wrapper over applyResolvedPack — kept so existing callers that
99
+ * only ever deal in built-in pack ids don't need to load the pack themselves. */
100
+ export async function applyPack(targetDir, packId, opts) {
101
+ const pack = await loadBuiltinPack(packId);
102
+ return applyResolvedPack(targetDir, pack, opts);
103
+ }
@@ -0,0 +1,8 @@
1
+ import { type AnalysisProfile } from "@baselane/analyze";
2
+ export interface AuditResult {
3
+ profile: AnalysisProfile;
4
+ packs: string[];
5
+ recommended: string;
6
+ }
7
+ export declare function auditRepo(dir: string): Promise<AuditResult>;
8
+ export declare function formatAuditReport(r: AuditResult): string;
package/dist/audit.js ADDED
@@ -0,0 +1,30 @@
1
+ import { analyze, LocalDirFileSource } from "@baselane/analyze";
2
+ import { listBuiltinPacks } from "@baselane/packs";
3
+ export async function auditRepo(dir) {
4
+ const profile = await analyze(new LocalDirFileSource(dir));
5
+ const packs = await listBuiltinPacks();
6
+ // Flagship default; every pack remains selectable via `apply --pack`.
7
+ const recommended = "software-engineer-harness";
8
+ return { profile, packs, recommended };
9
+ }
10
+ export function formatAuditReport(r) {
11
+ const p = r.profile;
12
+ const fw = p.frameworks.length
13
+ ? p.frameworks.map((f) => (f.version ? `${f.name}@${f.version}` : f.name)).join(", ")
14
+ : "none detected";
15
+ return [
16
+ "baselane audit",
17
+ "",
18
+ `Languages: ${p.languages.join(", ") || "none detected"}`,
19
+ `Package manager: ${p.packageManager ?? "none detected"}`,
20
+ `Layout: ${p.layout}`,
21
+ `Frameworks: ${fw}`,
22
+ `Commands: build=${p.commands.build ?? "-"} test=${p.commands.test ?? "-"} lint=${p.commands.lint ?? "-"}`,
23
+ `Test suite: ${p.hasTestSuite ? "yes" : "no"}`,
24
+ "",
25
+ `Available packs: ${r.packs.join(", ")}`,
26
+ `Recommended pack: ${r.recommended}`,
27
+ "",
28
+ "Next: baselane apply <dir> --pack " + r.recommended,
29
+ ].join("\n");
30
+ }
package/dist/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,2 @@
1
+ import { main } from "./cli.js";
2
+ process.exit(await main(process.argv.slice(2)));
package/dist/cli.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare const USAGE: string;
2
+ export interface CliDeps {
3
+ fetchImpl?: typeof fetch;
4
+ }
5
+ export declare function main(argv: string[], deps?: CliDeps): Promise<number>;