@bitakit/cli 0.2.0 → 0.2.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/README.md +1 -1
- package/package.json +3 -3
- package/src/agent-rules.mjs +11 -0
- package/src/index.mjs +7 -1
- package/src/init.mjs +9 -2
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ npx bitakit init
|
|
|
21
21
|
In an existing Next.js or TanStack Start app, `init` writes `bitakit.config.ts`, wraps
|
|
22
22
|
`next.config` with `withBitaKit` (or adds `bitakit()` to the Vite plugins), mounts
|
|
23
23
|
`<BitaKitProvider>` around `{children}` of the root layout, adds the catch-all route that renders
|
|
24
|
-
`<PluginPage />`, ignores `src/bitakit.gen
|
|
24
|
+
`<PluginPage />`, ignores `src/bitakit.gen.*`, appends the agent rules to `AGENTS.md` and makes `CLAUDE.md` import it (an existing `CLAUDE.md` only gains the `@AGENTS.md` line). It prints what it wrote (`+` new file, `~`
|
|
25
25
|
changed file) and what it skipped. Files that already carry the wiring are never touched, so it
|
|
26
26
|
is safe to run again; a shape it cannot edit (for example a CommonJS `next.config.js`) is
|
|
27
27
|
skipped with the line to add by hand. Packages are not installed: `init` lists the missing ones
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitakit/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "BitaKit project commands: add plugins and contributions, check a project with doctor.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"test": "node --test tests/*.test.mjs"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@bitakit/core": "^0.2.
|
|
26
|
-
"@bitakit/discovery": "^0.2.
|
|
25
|
+
"@bitakit/core": "^0.2.1",
|
|
26
|
+
"@bitakit/discovery": "^0.2.1",
|
|
27
27
|
"commander": "15.0.0",
|
|
28
28
|
"typescript": "^5.9.3"
|
|
29
29
|
},
|
package/src/agent-rules.mjs
CHANGED
|
@@ -8,6 +8,17 @@ export const bitakitIdentity = 'BitaKit is a composition layer for building apps
|
|
|
8
8
|
export const agentRulesBegin = '<!-- BEGIN:bitakit-agent-rules -->';
|
|
9
9
|
export const agentRulesEnd = '<!-- END:bitakit-agent-rules -->';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Claude Code reads `CLAUDE.md`, not `AGENTS.md`, so the app's `CLAUDE.md` imports the rules with
|
|
13
|
+
* `@AGENTS.md`. Returns the file to write: a new one, or `existing` with the import appended;
|
|
14
|
+
* `existing` is returned unchanged when it already imports AGENTS.md.
|
|
15
|
+
*/
|
|
16
|
+
export function claudeFileFor(existing) {
|
|
17
|
+
const text = existing?.trim() ? existing : undefined;
|
|
18
|
+
if (!text) return '@AGENTS.md\n';
|
|
19
|
+
return /^@AGENTS\.md\s*$/m.test(text) ? existing : `${text.trimEnd()}\n\n@AGENTS.md\n`;
|
|
20
|
+
}
|
|
21
|
+
|
|
11
22
|
/**
|
|
12
23
|
* The guidance block for coding assistants in an app's AGENTS.md, shared by create-app and
|
|
13
24
|
* `bitakit init`. Ordered by learning level: where each task goes first, then the rules, then
|
package/src/index.mjs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/** Programmatic API shared by the `bitakit` CLI and the project generator. */
|
|
2
2
|
export { addPlugin, addContribution, writeNewFiles, contributionKinds } from './add.mjs';
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
agentRules,
|
|
5
|
+
agentRulesBegin,
|
|
6
|
+
agentRulesEnd,
|
|
7
|
+
bitakitIdentity,
|
|
8
|
+
claudeFileFor,
|
|
9
|
+
} from './agent-rules.mjs';
|
|
4
10
|
export { buildPlugin } from './build.mjs';
|
|
5
11
|
export { doctor } from './doctor.mjs';
|
|
6
12
|
export {
|
package/src/init.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
-
import { agentRules, agentRulesBegin } from './agent-rules.mjs';
|
|
4
|
+
import { agentRules, agentRulesBegin, claudeFileFor } from './agent-rules.mjs';
|
|
5
5
|
import { exists, findProject } from './project.mjs';
|
|
6
6
|
import { appRoutes, catchAllRoute, rootLayouts, shellGroup } from './routes.mjs';
|
|
7
7
|
|
|
@@ -119,7 +119,8 @@ function wrapLayout(source, fileName, specifier, framework) {
|
|
|
119
119
|
/**
|
|
120
120
|
* Wires an existing Next.js or TanStack Start app: `bitakit.config.ts`, the config wrapper or
|
|
121
121
|
* Vite plugin, the provider in the root layout, the catch-all route for plugin pages, the
|
|
122
|
-
* `.gitignore` entry and the agent rules in `AGENTS.md` (the same block create-app writes)
|
|
122
|
+
* `.gitignore` entry and the agent rules in `AGENTS.md` (the same block create-app writes), which
|
|
123
|
+
* `CLAUDE.md` imports.
|
|
123
124
|
* Files that already carry the wiring are never touched.
|
|
124
125
|
* Returns `written` (absolute paths; `created` is false for an edited file), `skipped` with the
|
|
125
126
|
* reason for each, and the BitaKit packages the app still has to install.
|
|
@@ -244,6 +245,12 @@ export async function initProject({ cwd } = {}) {
|
|
|
244
245
|
agents === undefined,
|
|
245
246
|
);
|
|
246
247
|
}
|
|
248
|
+
// Claude Code loads CLAUDE.md, so it imports the rules; an existing file only gets the import line.
|
|
249
|
+
const claudeFile = at('CLAUDE.md');
|
|
250
|
+
const claude = await read(claudeFile);
|
|
251
|
+
const claudeNext = claudeFileFor(claude);
|
|
252
|
+
if (claudeNext === claude) skip(claudeFile, 'already imports AGENTS.md');
|
|
253
|
+
else await put(claudeFile, claudeNext, claude === undefined);
|
|
247
254
|
const install = [
|
|
248
255
|
'@bitakit/core',
|
|
249
256
|
'@bitakit/discovery',
|