create-atm 0.1.0-beta.1 → 0.1.7
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/README.md +1 -1
- package/dist/index.js +71 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
npx create-atm test-app --agent claude-code
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
The command creates `test-app`, runs `atm bootstrap`, renders `.atm/memory/atm-chart.md`, and installs the requested
|
|
11
|
+
The command creates `test-app`, runs `atm bootstrap`, renders `.atm/memory/atm-chart.md`, and installs the requested editor integration with `atm integration add <editor-id>`. Integrations are opt-in; running without `--agent` initializes the ATM project and rule chart only.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
npx create-atm test-app
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import {
|
|
4
|
-
import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
|
|
5
4
|
import path from 'node:path';
|
|
6
5
|
import { fileURLToPath } from 'node:url';
|
|
7
6
|
export const createAtmPackage = {
|
|
@@ -21,12 +20,32 @@ export function runCreateAtm(argv = process.argv.slice(2)) {
|
|
|
21
20
|
mkdirSync(targetRoot, { recursive: true });
|
|
22
21
|
const distTag = resolveCreateAtmDistTag(options.tag);
|
|
23
22
|
writeDistTagSelection(targetRoot, distTag);
|
|
24
|
-
|
|
23
|
+
let atmExecution = resolveAtmExecutionPlan(distTag.requestedTag);
|
|
25
24
|
const steps = [];
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (atmExecution.source !== 'source-tree') {
|
|
26
|
+
const runtime = installTargetRuntime(targetRoot, distTag.npmPackageSpec);
|
|
27
|
+
steps.push(runtime.step);
|
|
28
|
+
if (runtime.execution)
|
|
29
|
+
atmExecution = runtime.execution;
|
|
30
|
+
}
|
|
31
|
+
const plannedSteps = [
|
|
32
|
+
{ name: 'bootstrap', args: ['bootstrap', '--cwd', targetRoot, '--json'] },
|
|
33
|
+
{ name: 'atm-chart render', args: ['atm-chart', 'render', '--cwd', targetRoot, '--json'] }
|
|
34
|
+
];
|
|
28
35
|
if (options.agent) {
|
|
29
|
-
|
|
36
|
+
plannedSteps.push({ name: `integration add ${options.agent}`, args: ['integration', 'add', options.agent, '--cwd', targetRoot, '--json'] });
|
|
37
|
+
if (options.agent === 'codex') {
|
|
38
|
+
plannedSteps.push({ name: 'guide install-skill host', args: ['guide', 'install-skill', '--target', 'host', '--cwd', targetRoot, '--json'] });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (atmExecution.source === 'target-dependency') {
|
|
42
|
+
plannedSteps.push({ name: 'first-use next', args: ['next', '--cwd', targetRoot, '--json'] });
|
|
43
|
+
}
|
|
44
|
+
for (const step of steps.some((entry) => entry.exitCode !== 0) ? [] : plannedSteps) {
|
|
45
|
+
const result = runAtmStep(step.name, atmExecution, step.args);
|
|
46
|
+
steps.push(result);
|
|
47
|
+
if (result.exitCode !== 0)
|
|
48
|
+
break;
|
|
30
49
|
}
|
|
31
50
|
const failedStep = steps.find((step) => step.exitCode !== 0);
|
|
32
51
|
const payload = {
|
|
@@ -43,6 +62,7 @@ export function runCreateAtm(argv = process.argv.slice(2)) {
|
|
|
43
62
|
agent: options.agent ?? null,
|
|
44
63
|
atmEntrypoint: atmExecution.display,
|
|
45
64
|
atmEntrypointSource: atmExecution.source,
|
|
65
|
+
runtimeVersion: atmExecution.runtimeVersion ?? null,
|
|
46
66
|
distTag,
|
|
47
67
|
durationMs: Date.now() - startedAt,
|
|
48
68
|
steps: steps.map((step) => ({
|
|
@@ -55,6 +75,44 @@ export function runCreateAtm(argv = process.argv.slice(2)) {
|
|
|
55
75
|
writePayload(payload, options.json);
|
|
56
76
|
return failedStep ? failedStep.exitCode : 0;
|
|
57
77
|
}
|
|
78
|
+
function installTargetRuntime(targetRoot, packageSpec) {
|
|
79
|
+
writeFileSync(path.join(targetRoot, 'package.json'), `${JSON.stringify({ private: true, type: 'module' }, null, 2)}\n`);
|
|
80
|
+
const npmCli = process.env.npm_execpath?.endsWith('npm-cli.js')
|
|
81
|
+
? process.env.npm_execpath
|
|
82
|
+
: path.join(path.dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
83
|
+
const npmExecution = existsSync(npmCli)
|
|
84
|
+
? { command: process.execPath, argsPrefix: [npmCli], display: 'npm', source: 'npm-dist-tag', cwd: targetRoot }
|
|
85
|
+
: { command: 'npm', argsPrefix: [], display: 'npm', source: 'npm-dist-tag', cwd: targetRoot };
|
|
86
|
+
const step = runAtmStep('runtime install', npmExecution, ['install', '--save-exact', '--ignore-scripts', '--no-audit', '--no-fund', packageSpec]);
|
|
87
|
+
if (step.exitCode !== 0)
|
|
88
|
+
return { step };
|
|
89
|
+
try {
|
|
90
|
+
const packageRoot = path.join(targetRoot, 'node_modules', '@ai-atomic-framework', 'cli');
|
|
91
|
+
const installed = JSON.parse(readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
92
|
+
const manifest = JSON.parse(readFileSync(path.join(targetRoot, 'package.json'), 'utf8'));
|
|
93
|
+
const lock = JSON.parse(readFileSync(path.join(targetRoot, 'package-lock.json'), 'utf8'));
|
|
94
|
+
if (installed.name !== '@ai-atomic-framework/cli' || typeof installed.version !== 'string'
|
|
95
|
+
|| manifest.dependencies?.[installed.name] !== installed.version
|
|
96
|
+
|| lock.packages?.['node_modules/@ai-atomic-framework/cli']?.version !== installed.version
|
|
97
|
+
|| typeof installed.bin?.atm !== 'string')
|
|
98
|
+
throw new Error('Target runtime is not an exact locked official CLI dependency.');
|
|
99
|
+
const binPath = realpathSync(path.resolve(packageRoot, installed.bin.atm));
|
|
100
|
+
const relative = path.relative(realpathSync(packageRoot), binPath);
|
|
101
|
+
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
|
|
102
|
+
throw new Error('Target CLI bin is outside its package.');
|
|
103
|
+
const launcher = path.join(targetRoot, 'atm.mjs');
|
|
104
|
+
const importPath = `./${path.relative(targetRoot, binPath).replace(/\\/g, '/')}`;
|
|
105
|
+
writeFileSync(launcher, `#!/usr/bin/env node\nimport ${JSON.stringify(importPath)};\n`);
|
|
106
|
+
return { step, execution: {
|
|
107
|
+
command: process.execPath, argsPrefix: [launcher], display: 'node atm.mjs', source: 'target-dependency',
|
|
108
|
+
runtimeVersion: installed.version, cwd: targetRoot,
|
|
109
|
+
env: { ...process.env, ATM_PINNED_RUNNER_SOURCE: launcher }
|
|
110
|
+
} };
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return { step: { ...step, exitCode: 1, stderr: error instanceof Error ? error.message : String(error) } };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
58
116
|
function parseArgs(argv) {
|
|
59
117
|
const args = [...argv];
|
|
60
118
|
const projectName = args.find((arg) => !arg.startsWith('-'));
|
|
@@ -119,11 +177,9 @@ function writeDistTagSelection(targetRoot, selection) {
|
|
|
119
177
|
writeFileSync(selectionPath, `${JSON.stringify(selection, null, 2)}\n`, 'utf8');
|
|
120
178
|
}
|
|
121
179
|
function resolveAtmExecutionPlan(tag) {
|
|
122
|
-
const require = createRequire(import.meta.url);
|
|
123
180
|
try {
|
|
124
|
-
const cliIndexPath =
|
|
125
|
-
const
|
|
126
|
-
const packagedEntrypoint = path.join(packageRoot, 'dist', 'atm.mjs');
|
|
181
|
+
const cliIndexPath = fileURLToPath(import.meta.resolve('@ai-atomic-framework/cli'));
|
|
182
|
+
const packagedEntrypoint = path.join(path.dirname(cliIndexPath), 'atm.mjs');
|
|
127
183
|
if (existsSync(packagedEntrypoint) && tag === 'latest') {
|
|
128
184
|
return {
|
|
129
185
|
command: process.execPath,
|
|
@@ -162,7 +218,10 @@ function runAtmStep(name, atmExecution, args) {
|
|
|
162
218
|
const startedAt = Date.now();
|
|
163
219
|
const child = spawnSync(atmExecution.command, [...atmExecution.argsPrefix, ...args], {
|
|
164
220
|
encoding: 'utf8',
|
|
165
|
-
windowsHide: true
|
|
221
|
+
windowsHide: true,
|
|
222
|
+
cwd: atmExecution.cwd,
|
|
223
|
+
env: atmExecution.env,
|
|
224
|
+
timeout: 180_000
|
|
166
225
|
});
|
|
167
226
|
return {
|
|
168
227
|
name,
|
|
@@ -181,7 +240,7 @@ function writePayload(payload, json) {
|
|
|
181
240
|
process.stdout.write(`[create-atm] ${message}\n`);
|
|
182
241
|
}
|
|
183
242
|
const isDirectRun = process.argv[1]
|
|
184
|
-
?
|
|
243
|
+
? realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))
|
|
185
244
|
: false;
|
|
186
245
|
if (isDirectRun) {
|
|
187
246
|
process.exitCode = runCreateAtm();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-atm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create an ATM governance framework starter project with optional agent pack onboarding.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"lint": "eslint ."
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-atomic-framework/cli": "0.1.
|
|
32
|
+
"@ai-atomic-framework/cli": "0.1.7"
|
|
33
33
|
},
|
|
34
34
|
"types": "./dist/index.d.ts"
|
|
35
35
|
}
|