@monte3l/groundwork 0.0.0 → 0.1.0-next.1
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 +21 -0
- package/bin/m3l-groundwork.mjs +2 -2
- package/dist/harness/rules.js +1 -0
- package/dist/main.d.ts +15 -0
- package/dist/main.js +46 -11
- package/dist/report.js +1 -1
- package/package.json +4 -13
- package/templates/core/bin/lib/harness-rules.mjs +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Enrico Lionello
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/m3l-groundwork.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import { main } from "../dist/main.js";
|
|
3
|
+
import { main, CliUsageError } from "../dist/main.js";
|
|
4
4
|
|
|
5
5
|
try {
|
|
6
6
|
main(process.argv.slice(2));
|
|
7
7
|
} catch (error) {
|
|
8
8
|
console.error(error instanceof Error ? error.message : String(error));
|
|
9
|
-
process.exitCode = 1;
|
|
9
|
+
process.exitCode = error instanceof CliUsageError ? 2 : 1;
|
|
10
10
|
}
|
package/dist/harness/rules.js
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -11,6 +11,21 @@ export interface CliOptions {
|
|
|
11
11
|
listPacks: boolean;
|
|
12
12
|
packs: string[];
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Thrown for a bad invocation (unknown flag, missing target dir, missing flag
|
|
16
|
+
* value, contradictory mode flags) -- distinguished from a runtime error so the
|
|
17
|
+
* CLI exits 2, not 1.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```sh
|
|
21
|
+
* npx @monte3l/groundwork@next ./my-app --bogus
|
|
22
|
+
* # stderr: unrecognized option: --bogus (followed by the usage text)
|
|
23
|
+
* echo $? # 2 -- a runtime failure exits 1 instead
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class CliUsageError extends Error {
|
|
27
|
+
readonly name = "CliUsageError";
|
|
28
|
+
}
|
|
14
29
|
/** Parses argv into structured options. Throws with USAGE on a missing target dir, unless --help/--version/--list-packs is present. */
|
|
15
30
|
export declare function parseArgs(argv: string[]): CliOptions;
|
|
16
31
|
/** Resolves `templates/core` for a source checkout or a published tarball -- see `assets.ts`. */
|
package/dist/main.js
CHANGED
|
@@ -37,8 +37,8 @@ const USAGE = [
|
|
|
37
37
|
" --fresh Force fresh-bootstrap mode, even if the target looks pre-existing",
|
|
38
38
|
" --pack <name> Install an opt-in pack from templates/packs/ (fresh mode only; repeatable)",
|
|
39
39
|
" --list-packs Print every available pack and exit",
|
|
40
|
-
" --help
|
|
41
|
-
" --version
|
|
40
|
+
" --help, -h Print this message",
|
|
41
|
+
" --version, -v Print the CLI's version",
|
|
42
42
|
"",
|
|
43
43
|
"With no --adopt/--fresh override, the target directory is inspected: an",
|
|
44
44
|
"empty or missing directory bootstraps fresh; a directory that already",
|
|
@@ -56,6 +56,30 @@ const REPEATABLE_VALUE_FLAGS = new Set(["--pack"]);
|
|
|
56
56
|
const HELP_FLAGS = new Set(["--help", "-h"]);
|
|
57
57
|
const VERSION_FLAGS = new Set(["--version", "-v"]);
|
|
58
58
|
const LIST_PACKS_FLAGS = new Set(["--list-packs"]);
|
|
59
|
+
const BOOLEAN_FLAGS = new Set([
|
|
60
|
+
"--skip-install",
|
|
61
|
+
"--force",
|
|
62
|
+
"--adopt",
|
|
63
|
+
"--fresh",
|
|
64
|
+
...LIST_PACKS_FLAGS,
|
|
65
|
+
...HELP_FLAGS,
|
|
66
|
+
...VERSION_FLAGS,
|
|
67
|
+
]);
|
|
68
|
+
/**
|
|
69
|
+
* Thrown for a bad invocation (unknown flag, missing target dir, missing flag
|
|
70
|
+
* value, contradictory mode flags) -- distinguished from a runtime error so the
|
|
71
|
+
* CLI exits 2, not 1.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```sh
|
|
75
|
+
* npx @monte3l/groundwork@next ./my-app --bogus
|
|
76
|
+
* # stderr: unrecognized option: --bogus (followed by the usage text)
|
|
77
|
+
* echo $? # 2 -- a runtime failure exits 1 instead
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export class CliUsageError extends Error {
|
|
81
|
+
name = "CliUsageError";
|
|
82
|
+
}
|
|
59
83
|
/** Splits argv into positionals, boolean flags, and value-flag pairs -- a value-flag's value is never mistaken for a positional. */
|
|
60
84
|
function tokenizeArgv(argv) {
|
|
61
85
|
const positional = [];
|
|
@@ -72,22 +96,27 @@ function tokenizeArgv(argv) {
|
|
|
72
96
|
}
|
|
73
97
|
if (REPEATABLE_VALUE_FLAGS.has(arg)) {
|
|
74
98
|
const value = argv[i + 1];
|
|
75
|
-
if (value
|
|
76
|
-
|
|
77
|
-
existing.push(value);
|
|
78
|
-
repeatableValues.set(arg, existing);
|
|
79
|
-
i++;
|
|
99
|
+
if (value === undefined || value.startsWith("-")) {
|
|
100
|
+
throw new CliUsageError(`${arg} requires a value\n\n${USAGE}`);
|
|
80
101
|
}
|
|
102
|
+
const existing = repeatableValues.get(arg) ?? [];
|
|
103
|
+
existing.push(value);
|
|
104
|
+
repeatableValues.set(arg, existing);
|
|
105
|
+
i++;
|
|
81
106
|
continue;
|
|
82
107
|
}
|
|
83
108
|
if (VALUE_FLAGS.has(arg)) {
|
|
84
109
|
const value = argv[i + 1];
|
|
85
|
-
if (value
|
|
86
|
-
|
|
87
|
-
i++;
|
|
110
|
+
if (value === undefined || value.startsWith("-")) {
|
|
111
|
+
throw new CliUsageError(`${arg} requires a value\n\n${USAGE}`);
|
|
88
112
|
}
|
|
113
|
+
values.set(arg, value);
|
|
114
|
+
i++;
|
|
89
115
|
continue;
|
|
90
116
|
}
|
|
117
|
+
if (!BOOLEAN_FLAGS.has(arg)) {
|
|
118
|
+
throw new CliUsageError(`unrecognized option: ${arg}\n\n${USAGE}`);
|
|
119
|
+
}
|
|
91
120
|
flags.add(arg);
|
|
92
121
|
}
|
|
93
122
|
return { positional, flags, values, repeatableValues };
|
|
@@ -112,9 +141,15 @@ export function parseArgs(argv) {
|
|
|
112
141
|
packs: [],
|
|
113
142
|
};
|
|
114
143
|
}
|
|
144
|
+
if (flags.has("--adopt") && flags.has("--fresh")) {
|
|
145
|
+
throw new CliUsageError(`--adopt and --fresh are mutually exclusive\n\n${USAGE}`);
|
|
146
|
+
}
|
|
115
147
|
const targetArg = positional[0];
|
|
116
148
|
if (targetArg === undefined) {
|
|
117
|
-
throw new
|
|
149
|
+
throw new CliUsageError(USAGE);
|
|
150
|
+
}
|
|
151
|
+
if (positional.length > 1) {
|
|
152
|
+
throw new CliUsageError(`unexpected argument(s): ${positional.slice(1).join(" ")}\n\n${USAGE}`);
|
|
118
153
|
}
|
|
119
154
|
const targetDir = resolve(targetArg);
|
|
120
155
|
const explicitName = values.get("--name");
|
package/dist/report.js
CHANGED
|
@@ -280,7 +280,7 @@ export function renderReport(inventory) {
|
|
|
280
280
|
const sections = [
|
|
281
281
|
"# Adoption report",
|
|
282
282
|
"",
|
|
283
|
-
`Generated ${inventory.generatedAt} by m3l-groundwork ${inventory.cliVersion}.`,
|
|
283
|
+
`Generated ${inventory.generatedAt} by m3l-groundwork ${inventory.cliVersion} (inventory schema ${inventory.schemaVersion}).`,
|
|
284
284
|
"",
|
|
285
285
|
`**Mode:** adopt -- ${inventory.modeSignal}`,
|
|
286
286
|
"",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monte3l/groundwork",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-next.1",
|
|
4
4
|
"description": "Deterministic Phase A bootstrapper: writes the m3l-groundwork baseline (toolchain + Claude Code harness) into a new directory, or surveys an existing project read-only. No prompts, no network beyond the package install.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -27,13 +27,7 @@
|
|
|
27
27
|
"bin": {
|
|
28
28
|
"m3l-groundwork": "bin/m3l-groundwork.mjs"
|
|
29
29
|
},
|
|
30
|
-
"main": "./dist/main.js",
|
|
31
|
-
"types": "./dist/main.d.ts",
|
|
32
30
|
"exports": {
|
|
33
|
-
".": {
|
|
34
|
-
"types": "./dist/main.d.ts",
|
|
35
|
-
"import": "./dist/main.js"
|
|
36
|
-
},
|
|
37
31
|
"./package.json": "./package.json"
|
|
38
32
|
},
|
|
39
33
|
"files": [
|
|
@@ -48,12 +42,9 @@
|
|
|
48
42
|
"access": "public",
|
|
49
43
|
"provenance": true
|
|
50
44
|
},
|
|
51
|
-
"scripts": {
|
|
52
|
-
"prepack": "node scripts/vendor-assets.mjs vendor",
|
|
53
|
-
"postpack": "node scripts/vendor-assets.mjs clean"
|
|
54
|
-
},
|
|
55
45
|
"dependencies": {},
|
|
56
46
|
"devDependencies": {
|
|
57
47
|
"typescript": "^6.0.3"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
48
|
+
},
|
|
49
|
+
"scripts": {}
|
|
50
|
+
}
|