kodu 2.2.0 → 3.0.2
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 +24 -3
- package/bin/kodu.js +40 -0
- package/package.json +12 -67
- package/scripts/install.js +68 -0
- package/scripts/postinstall.js +22 -0
- package/AGENTS.md +0 -214
- package/__tests__/core/fs/fs.service.test.ts +0 -72
- package/__tests__/core/registry/registry.service.test.ts +0 -82
- package/__tests__/shared/cleaner/cleaner.service.test.ts +0 -102
- package/__tests__/shared/git/git.service.test.ts +0 -84
- package/__tests__/shared/runbook/runbook.service.test.ts +0 -104
- package/__tests__/shared/tokenizer/tokenizer.service.test.ts +0 -45
- package/biome.json +0 -50
- package/dist/package.json +0 -96
- package/dist/src/app.module.d.ts +0 -2
- package/dist/src/app.module.js +0 -42
- package/dist/src/app.module.js.map +0 -1
- package/dist/src/commands/clean/clean.command.d.ts +0 -37
- package/dist/src/commands/clean/clean.command.js +0 -240
- package/dist/src/commands/clean/clean.command.js.map +0 -1
- package/dist/src/commands/clean/clean.module.d.ts +0 -2
- package/dist/src/commands/clean/clean.module.js +0 -26
- package/dist/src/commands/clean/clean.module.js.map +0 -1
- package/dist/src/commands/init/init.command.d.ts +0 -10
- package/dist/src/commands/init/init.command.js +0 -96
- package/dist/src/commands/init/init.command.js.map +0 -1
- package/dist/src/commands/init/init.module.d.ts +0 -2
- package/dist/src/commands/init/init.module.js +0 -22
- package/dist/src/commands/init/init.module.js.map +0 -1
- package/dist/src/commands/ops/ops-add.command.d.ts +0 -18
- package/dist/src/commands/ops/ops-add.command.js +0 -102
- package/dist/src/commands/ops/ops-add.command.js.map +0 -1
- package/dist/src/commands/ops/ops-init.command.d.ts +0 -22
- package/dist/src/commands/ops/ops-init.command.js +0 -130
- package/dist/src/commands/ops/ops-init.command.js.map +0 -1
- package/dist/src/commands/ops/ops-list.command.d.ts +0 -12
- package/dist/src/commands/ops/ops-list.command.js +0 -73
- package/dist/src/commands/ops/ops-list.command.js.map +0 -1
- package/dist/src/commands/ops/ops-path.command.d.ts +0 -9
- package/dist/src/commands/ops/ops-path.command.js +0 -52
- package/dist/src/commands/ops/ops-path.command.js.map +0 -1
- package/dist/src/commands/ops/ops-runbook.command.d.ts +0 -12
- package/dist/src/commands/ops/ops-runbook.command.js +0 -81
- package/dist/src/commands/ops/ops-runbook.command.js.map +0 -1
- package/dist/src/commands/ops/ops-status.command.d.ts +0 -11
- package/dist/src/commands/ops/ops-status.command.js +0 -62
- package/dist/src/commands/ops/ops-status.command.js.map +0 -1
- package/dist/src/commands/ops/ops-use.command.d.ts +0 -12
- package/dist/src/commands/ops/ops-use.command.js +0 -76
- package/dist/src/commands/ops/ops-use.command.js.map +0 -1
- package/dist/src/commands/ops/ops.command.d.ts +0 -7
- package/dist/src/commands/ops/ops.command.js +0 -56
- package/dist/src/commands/ops/ops.command.js.map +0 -1
- package/dist/src/commands/ops/ops.helpers.d.ts +0 -2
- package/dist/src/commands/ops/ops.helpers.js +0 -11
- package/dist/src/commands/ops/ops.helpers.js.map +0 -1
- package/dist/src/commands/ops/ops.module.d.ts +0 -2
- package/dist/src/commands/ops/ops.module.js +0 -36
- package/dist/src/commands/ops/ops.module.js.map +0 -1
- package/dist/src/commands/pack/pack.command.d.ts +0 -51
- package/dist/src/commands/pack/pack.command.js +0 -355
- package/dist/src/commands/pack/pack.command.js.map +0 -1
- package/dist/src/commands/pack/pack.module.d.ts +0 -2
- package/dist/src/commands/pack/pack.module.js +0 -27
- package/dist/src/commands/pack/pack.module.js.map +0 -1
- package/dist/src/core/config/config.module.d.ts +0 -2
- package/dist/src/core/config/config.module.js +0 -23
- package/dist/src/core/config/config.module.js.map +0 -1
- package/dist/src/core/config/config.schema.d.ts +0 -19
- package/dist/src/core/config/config.schema.js +0 -56
- package/dist/src/core/config/config.schema.js.map +0 -1
- package/dist/src/core/config/config.service.d.ts +0 -7
- package/dist/src/core/config/config.service.js +0 -49
- package/dist/src/core/config/config.service.js.map +0 -1
- package/dist/src/core/config/prompt.service.d.ts +0 -10
- package/dist/src/core/config/prompt.service.js +0 -80
- package/dist/src/core/config/prompt.service.js.map +0 -1
- package/dist/src/core/file-system/fs.module.d.ts +0 -2
- package/dist/src/core/file-system/fs.module.js +0 -21
- package/dist/src/core/file-system/fs.module.js.map +0 -1
- package/dist/src/core/file-system/fs.service.d.ts +0 -27
- package/dist/src/core/file-system/fs.service.js +0 -203
- package/dist/src/core/file-system/fs.service.js.map +0 -1
- package/dist/src/core/registry/registry.module.d.ts +0 -2
- package/dist/src/core/registry/registry.module.js +0 -22
- package/dist/src/core/registry/registry.module.js.map +0 -1
- package/dist/src/core/registry/registry.schema.d.ts +0 -24
- package/dist/src/core/registry/registry.schema.js +0 -21
- package/dist/src/core/registry/registry.schema.js.map +0 -1
- package/dist/src/core/registry/registry.service.d.ts +0 -16
- package/dist/src/core/registry/registry.service.js +0 -91
- package/dist/src/core/registry/registry.service.js.map +0 -1
- package/dist/src/core/ui/ui.module.d.ts +0 -2
- package/dist/src/core/ui/ui.module.js +0 -22
- package/dist/src/core/ui/ui.module.js.map +0 -1
- package/dist/src/core/ui/ui.service.d.ts +0 -22
- package/dist/src/core/ui/ui.service.js +0 -43
- package/dist/src/core/ui/ui.service.js.map +0 -1
- package/dist/src/main.d.ts +0 -2
- package/dist/src/main.js +0 -16
- package/dist/src/main.js.map +0 -1
- package/dist/src/shared/cleaner/cleaner.service.d.ts +0 -23
- package/dist/src/shared/cleaner/cleaner.service.js +0 -223
- package/dist/src/shared/cleaner/cleaner.service.js.map +0 -1
- package/dist/src/shared/cleaner/cleaner.types.d.ts +0 -21
- package/dist/src/shared/cleaner/cleaner.types.js +0 -3
- package/dist/src/shared/cleaner/cleaner.types.js.map +0 -1
- package/dist/src/shared/constants.d.ts +0 -4
- package/dist/src/shared/constants.js +0 -113
- package/dist/src/shared/constants.js.map +0 -1
- package/dist/src/shared/deps/deps.module.d.ts +0 -2
- package/dist/src/shared/deps/deps.module.js +0 -21
- package/dist/src/shared/deps/deps.module.js.map +0 -1
- package/dist/src/shared/deps/deps.service.d.ts +0 -15
- package/dist/src/shared/deps/deps.service.js +0 -114
- package/dist/src/shared/deps/deps.service.js.map +0 -1
- package/dist/src/shared/git/git.module.d.ts +0 -2
- package/dist/src/shared/git/git.module.js +0 -21
- package/dist/src/shared/git/git.module.js.map +0 -1
- package/dist/src/shared/git/git.service.d.ts +0 -5
- package/dist/src/shared/git/git.service.js +0 -56
- package/dist/src/shared/git/git.service.js.map +0 -1
- package/dist/src/shared/runbook/runbook.module.d.ts +0 -2
- package/dist/src/shared/runbook/runbook.module.js +0 -22
- package/dist/src/shared/runbook/runbook.module.js.map +0 -1
- package/dist/src/shared/runbook/runbook.service.d.ts +0 -20
- package/dist/src/shared/runbook/runbook.service.js +0 -118
- package/dist/src/shared/runbook/runbook.service.js.map +0 -1
- package/dist/src/shared/runbook/runbook.templates.d.ts +0 -6
- package/dist/src/shared/runbook/runbook.templates.js +0 -49
- package/dist/src/shared/runbook/runbook.templates.js.map +0 -1
- package/dist/src/shared/tokenizer/tokenizer.module.d.ts +0 -2
- package/dist/src/shared/tokenizer/tokenizer.module.js +0 -21
- package/dist/src/shared/tokenizer/tokenizer.module.js.map +0 -1
- package/dist/src/shared/tokenizer/tokenizer.service.d.ts +0 -10
- package/dist/src/shared/tokenizer/tokenizer.service.js +0 -36
- package/dist/src/shared/tokenizer/tokenizer.service.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/docs/todo.md +0 -7
- package/knip.json +0 -10
- package/kodu.json +0 -63
- package/kodu.schema.json +0 -100
- package/lefthook.yml +0 -11
- package/nest-cli.json +0 -8
- package/registry.schema.json +0 -39
- package/scripts/generate-json-schema.ts +0 -27
- package/skills/ac/SKILL.md +0 -239
- package/skills/al/SKILL.md +0 -98
- package/skills/audit/SKILL.md +0 -205
- package/skills/audit/audit-baseline-template.yml +0 -188
- package/skills/audit/runtime-detect.md +0 -64
- package/skills/audit/stacks/_generic.md +0 -41
- package/skills/audit/stacks/_registry.md +0 -47
- package/skills/audit/stacks/go.md +0 -66
- package/skills/audit/stacks/java.md +0 -44
- package/skills/audit/stacks/node.md +0 -57
- package/skills/audit/stacks/python.md +0 -45
- package/skills/audit/stacks/rust.md +0 -44
- package/skills/audit-api-contracts/SKILL.md +0 -201
- package/skills/audit-architecture/SKILL.md +0 -200
- package/skills/audit-bugs/SKILL.md +0 -226
- package/skills/audit-concurrency/SKILL.md +0 -197
- package/skills/audit-deployment/SKILL.md +0 -218
- package/skills/audit-docs/SKILL.md +0 -209
- package/skills/audit-errors/SKILL.md +0 -216
- package/skills/audit-logging/SKILL.md +0 -197
- package/skills/audit-matrix/SKILL.md +0 -245
- package/skills/audit-meta/SKILL.md +0 -120
- package/skills/audit-naming/SKILL.md +0 -200
- package/skills/audit-owasp/SKILL.md +0 -223
- package/skills/audit-performance/SKILL.md +0 -199
- package/skills/audit-reinvention/SKILL.md +0 -214
- package/skills/audit-secrets/SKILL.md +0 -198
- package/skills/audit-tests/SKILL.md +0 -210
- package/skills/audit-validation/SKILL.md +0 -206
- package/skills/audit-verify/SKILL.md +0 -139
- package/skills/audit-yagni/SKILL.md +0 -188
- package/skills/doc-gen/SKILL.md +0 -490
- package/skills/doc-gen/scripts/doc_gen.py +0 -911
- package/skills/generate-project-docs/SKILL.md +0 -380
- package/skills/implement-project/SKILL.md +0 -409
- package/skills/liteend-init/SKILL.md +0 -84
- package/skills/litefront-init/SKILL.md +0 -96
- package/skills/litefront-prototype/SKILL.md +0 -484
- package/skills/ops/SKILL.md +0 -94
- package/skills/post-call-task-builder/SKILL.md +0 -419
- package/skills/project-setup-standardizer/SKILL.md +0 -285
- package/skills/skills-best-practices/SKILL.md +0 -415
- package/skills/start/SKILL.md +0 -319
- package/skills/tech-blueprint/SKILL.md +0 -890
- package/skills/tech-blueprint/scripts/blueprint_validator.py +0 -417
- package/src/app.module.ts +0 -29
- package/src/commands/clean/clean.command.ts +0 -235
- package/src/commands/clean/clean.module.ts +0 -13
- package/src/commands/init/init.command.ts +0 -92
- package/src/commands/init/init.module.ts +0 -9
- package/src/commands/ops/ops-add.command.ts +0 -83
- package/src/commands/ops/ops-init.command.ts +0 -125
- package/src/commands/ops/ops-list.command.ts +0 -57
- package/src/commands/ops/ops-path.command.ts +0 -38
- package/src/commands/ops/ops-runbook.command.ts +0 -74
- package/src/commands/ops/ops-status.command.ts +0 -47
- package/src/commands/ops/ops-use.command.ts +0 -76
- package/src/commands/ops/ops.command.ts +0 -42
- package/src/commands/ops/ops.helpers.ts +0 -20
- package/src/commands/ops/ops.module.ts +0 -23
- package/src/commands/pack/pack.command.ts +0 -347
- package/src/commands/pack/pack.module.ts +0 -14
- package/src/core/config/config.module.ts +0 -10
- package/src/core/config/config.schema.ts +0 -58
- package/src/core/config/config.service.ts +0 -43
- package/src/core/config/prompt.service.ts +0 -80
- package/src/core/file-system/fs.module.ts +0 -8
- package/src/core/file-system/fs.service.ts +0 -248
- package/src/core/registry/registry.module.ts +0 -9
- package/src/core/registry/registry.schema.ts +0 -46
- package/src/core/registry/registry.service.ts +0 -128
- package/src/core/ui/ui.module.ts +0 -9
- package/src/core/ui/ui.service.ts +0 -39
- package/src/main.ts +0 -12
- package/src/shared/cleaner/cleaner.service.ts +0 -289
- package/src/shared/cleaner/cleaner.types.ts +0 -23
- package/src/shared/constants.ts +0 -118
- package/src/shared/deps/deps.module.ts +0 -8
- package/src/shared/deps/deps.service.ts +0 -175
- package/src/shared/git/git.module.ts +0 -8
- package/src/shared/git/git.service.ts +0 -47
- package/src/shared/runbook/runbook.module.ts +0 -9
- package/src/shared/runbook/runbook.service.ts +0 -164
- package/src/shared/runbook/runbook.templates.ts +0 -66
- package/src/shared/tokenizer/tokenizer.module.ts +0 -8
- package/src/shared/tokenizer/tokenizer.service.ts +0 -30
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -28
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { Injectable } from '@nestjs/common';
|
|
4
|
-
import {
|
|
5
|
-
type ProjectConfig,
|
|
6
|
-
projectConfigSchema,
|
|
7
|
-
} from '../../core/registry/registry.schema';
|
|
8
|
-
import { type DetectedStack, renderRunbook } from './runbook.templates';
|
|
9
|
-
|
|
10
|
-
const RUNBOOK_DIR = '.runbook';
|
|
11
|
-
const GITIGNORE_ENTRY = '/.runbook/';
|
|
12
|
-
/** Эквивалентные записи `.runbook/` в `.gitignore` — считаем дублем. */
|
|
13
|
-
const GITIGNORE_EQUIVALENTS = new Set([
|
|
14
|
-
'/.runbook/',
|
|
15
|
-
'/.runbook',
|
|
16
|
-
'.runbook/',
|
|
17
|
-
'.runbook',
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
/** Результат настройки `.gitignore`. */
|
|
21
|
-
export type GitignoreResult = 'created' | 'added' | 'present' | 'no-git';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Работа с per-project директорией `.runbook/`: скаффолд, чтение/запись
|
|
25
|
-
* `config.json`, чтение `runbook.md` и идемпотентная настройка `.gitignore`.
|
|
26
|
-
*/
|
|
27
|
-
@Injectable()
|
|
28
|
-
export class RunbookService {
|
|
29
|
-
dirPath(root: string = process.cwd()): string {
|
|
30
|
-
return path.join(root, RUNBOOK_DIR);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
configPath(root: string = process.cwd()): string {
|
|
34
|
-
return path.join(root, RUNBOOK_DIR, 'config.json');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
runbookPath(root: string = process.cwd()): string {
|
|
38
|
-
return path.join(root, RUNBOOK_DIR, 'runbook.md');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Инициализирован ли проект (есть `.runbook/config.json`). */
|
|
42
|
-
async exists(root: string = process.cwd()): Promise<boolean> {
|
|
43
|
-
return this.pathExists(this.configPath(root));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async readConfig(root: string = process.cwd()): Promise<ProjectConfig> {
|
|
47
|
-
const content = await fs.readFile(this.configPath(root), 'utf8');
|
|
48
|
-
return projectConfigSchema.parse(JSON.parse(content));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async writeConfig(
|
|
52
|
-
config: ProjectConfig,
|
|
53
|
-
root: string = process.cwd(),
|
|
54
|
-
): Promise<void> {
|
|
55
|
-
const validated = projectConfigSchema.parse(config);
|
|
56
|
-
await fs.mkdir(this.dirPath(root), { recursive: true });
|
|
57
|
-
await fs.writeFile(
|
|
58
|
-
this.configPath(root),
|
|
59
|
-
`${JSON.stringify(validated, null, 2)}\n`,
|
|
60
|
-
'utf8',
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async readRunbook(root: string = process.cwd()): Promise<string> {
|
|
65
|
-
return fs.readFile(this.runbookPath(root), 'utf8');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Создаёт `.runbook/` с config.json и (если ещё нет) runbook.md.
|
|
70
|
-
* Существующий runbook.md не перезаписывается — ручные правки сохраняются.
|
|
71
|
-
*/
|
|
72
|
-
async scaffold(
|
|
73
|
-
options: { project: string; stands: string[]; activeStand: string },
|
|
74
|
-
root: string = process.cwd(),
|
|
75
|
-
): Promise<void> {
|
|
76
|
-
await fs.mkdir(this.dirPath(root), { recursive: true });
|
|
77
|
-
|
|
78
|
-
await this.writeConfig(
|
|
79
|
-
{
|
|
80
|
-
project: options.project,
|
|
81
|
-
activeStand: options.activeStand,
|
|
82
|
-
stands: options.stands,
|
|
83
|
-
},
|
|
84
|
-
root,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
if (!(await this.pathExists(this.runbookPath(root)))) {
|
|
88
|
-
const detected = await this.detectStack(root);
|
|
89
|
-
const markdown = renderRunbook(options.project, options.stands, detected);
|
|
90
|
-
await fs.writeFile(this.runbookPath(root), markdown, 'utf8');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** Определяет наличие docker-compose / Dockerfile / .env.example. */
|
|
95
|
-
async detectStack(root: string = process.cwd()): Promise<DetectedStack> {
|
|
96
|
-
const [composeYml, composeYaml, dockerfile, envExample] = await Promise.all(
|
|
97
|
-
[
|
|
98
|
-
this.pathExists(path.join(root, 'docker-compose.yml')),
|
|
99
|
-
this.pathExists(path.join(root, 'docker-compose.yaml')),
|
|
100
|
-
this.pathExists(path.join(root, 'Dockerfile')),
|
|
101
|
-
this.pathExists(path.join(root, '.env.example')),
|
|
102
|
-
],
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
compose: composeYml || composeYaml,
|
|
107
|
-
dockerfile,
|
|
108
|
-
envExample,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Гарантирует, что `.runbook/` игнорируется git — автоматически и идемпотентно.
|
|
114
|
-
* - не git-репозиторий → ничего не пишем, возвращаем 'no-git';
|
|
115
|
-
* - запись уже есть → 'present';
|
|
116
|
-
* - `.gitignore` отсутствует → создаём с записью → 'created';
|
|
117
|
-
* - иначе дописываем в конец → 'added'.
|
|
118
|
-
*/
|
|
119
|
-
async ensureGitignore(
|
|
120
|
-
root: string = process.cwd(),
|
|
121
|
-
): Promise<GitignoreResult> {
|
|
122
|
-
if (!(await this.pathExists(path.join(root, '.git')))) {
|
|
123
|
-
return 'no-git';
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const gitignorePath = path.join(root, '.gitignore');
|
|
127
|
-
let content = '';
|
|
128
|
-
let fileExists = true;
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
content = await fs.readFile(gitignorePath, 'utf8');
|
|
132
|
-
} catch {
|
|
133
|
-
fileExists = false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const alreadyIgnored = content
|
|
137
|
-
.split(/\r?\n/)
|
|
138
|
-
.map((line) => line.trim())
|
|
139
|
-
.some((line) => GITIGNORE_EQUIVALENTS.has(line));
|
|
140
|
-
|
|
141
|
-
if (alreadyIgnored) {
|
|
142
|
-
return 'present';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const trimmed = content.trimEnd();
|
|
146
|
-
const next =
|
|
147
|
-
trimmed.length > 0
|
|
148
|
-
? `${trimmed}\n${GITIGNORE_ENTRY}\n`
|
|
149
|
-
: `${GITIGNORE_ENTRY}\n`;
|
|
150
|
-
|
|
151
|
-
await fs.writeFile(gitignorePath, next, 'utf8');
|
|
152
|
-
|
|
153
|
-
return fileExists ? 'added' : 'created';
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private async pathExists(target: string): Promise<boolean> {
|
|
157
|
-
try {
|
|
158
|
-
await fs.access(target);
|
|
159
|
-
return true;
|
|
160
|
-
} catch {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/** Что удалось определить про проект (для подсказок в runbook). */
|
|
2
|
-
export type DetectedStack = {
|
|
3
|
-
compose: boolean;
|
|
4
|
-
dockerfile: boolean;
|
|
5
|
-
envExample: boolean;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const STAND_TITLES: Record<string, string> = {
|
|
9
|
-
local: 'локальная разработка',
|
|
10
|
-
dev: 'dev-стенд',
|
|
11
|
-
stage: 'stage-стенд',
|
|
12
|
-
prod: 'production (осторожно!)',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function renderStandSection(stand: string, detected: DetectedStack): string {
|
|
16
|
-
const title = STAND_TITLES[stand] ?? stand;
|
|
17
|
-
|
|
18
|
-
const startCmd = detected.compose
|
|
19
|
-
? 'docker compose up -d'
|
|
20
|
-
: '<команда запуска, напр. docker compose up -d>';
|
|
21
|
-
const logsCmd = detected.compose
|
|
22
|
-
? 'docker compose logs -f'
|
|
23
|
-
: '<команда логов>';
|
|
24
|
-
const envNote = detected.envExample
|
|
25
|
-
? 'Скопируй `.env.example` → `.env` и заполни значения.'
|
|
26
|
-
: '<откуда взять переменные окружения / секреты>';
|
|
27
|
-
|
|
28
|
-
return [
|
|
29
|
-
`## Стенд: ${stand} (${title})`,
|
|
30
|
-
'',
|
|
31
|
-
'- **Где живёт / доступ**: <ssh user@host или localhost>',
|
|
32
|
-
'- **Рабочая директория**: <путь на сервере или локально>',
|
|
33
|
-
'- **Получить код**: `git clone <repo>` (первый раз) / `git pull` (обновить)',
|
|
34
|
-
`- **Запуск**: \`${startCmd}\``,
|
|
35
|
-
`- **Логи**: \`${logsCmd}\``,
|
|
36
|
-
'- **Деплой**: <пошаговые команды деплоя на этот стенд>',
|
|
37
|
-
'- **Откат**: <как откатиться, если что-то пошло не так>',
|
|
38
|
-
`- **Переменные окружения / секреты**: ${envNote}`,
|
|
39
|
-
'',
|
|
40
|
-
].join('\n');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Стартовый runbook для проекта. Заполняется человеком/агентом — конкретные
|
|
45
|
-
* команды и пути подставляются под реальную инфраструктуру.
|
|
46
|
-
*/
|
|
47
|
-
export function renderRunbook(
|
|
48
|
-
project: string,
|
|
49
|
-
stands: string[],
|
|
50
|
-
detected: DetectedStack,
|
|
51
|
-
): string {
|
|
52
|
-
const header = [
|
|
53
|
-
`# Runbook: ${project}`,
|
|
54
|
-
'',
|
|
55
|
-
'> Этот файл описывает, как работать со стендами проекта.',
|
|
56
|
-
'> Он лежит в `.gitignore` и не коммитится — здесь могут быть хосты и пути.',
|
|
57
|
-
'> Заполни плейсхолдеры `<...>` под свою инфраструктуру.',
|
|
58
|
-
'',
|
|
59
|
-
].join('\n');
|
|
60
|
-
|
|
61
|
-
const sections = stands
|
|
62
|
-
.map((stand) => renderStandSection(stand, detected))
|
|
63
|
-
.join('\n');
|
|
64
|
-
|
|
65
|
-
return `${header}\n${sections}`;
|
|
66
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { encodingForModel, getEncoding } from 'js-tiktoken';
|
|
3
|
-
import { DEFAULT_PRICE_PER_MILLION } from '../constants';
|
|
4
|
-
|
|
5
|
-
type TokenEstimate = {
|
|
6
|
-
tokens: number;
|
|
7
|
-
usdEstimate: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
@Injectable()
|
|
11
|
-
export class TokenizerService {
|
|
12
|
-
private encoder?: ReturnType<typeof getEncoding>;
|
|
13
|
-
|
|
14
|
-
count(text: string): TokenEstimate {
|
|
15
|
-
const tokens = this.getEncoder().encode(text).length;
|
|
16
|
-
const usdEstimate = (tokens / 1_000_000) * DEFAULT_PRICE_PER_MILLION;
|
|
17
|
-
return { tokens, usdEstimate };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private getEncoder() {
|
|
21
|
-
if (!this.encoder) {
|
|
22
|
-
try {
|
|
23
|
-
this.encoder = encodingForModel('gpt-4o');
|
|
24
|
-
} catch {
|
|
25
|
-
this.encoder = getEncoding('o200k_base');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return this.encoder;
|
|
29
|
-
}
|
|
30
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2023",
|
|
4
|
-
"module": "nodenext",
|
|
5
|
-
"moduleResolution": "nodenext",
|
|
6
|
-
"resolvePackageJsonExports": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"isolatedModules": true,
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"removeComments": true,
|
|
11
|
-
"emitDecoratorMetadata": true,
|
|
12
|
-
"experimentalDecorators": true,
|
|
13
|
-
"allowSyntheticDefaultImports": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"outDir": "./dist",
|
|
16
|
-
"baseUrl": "./",
|
|
17
|
-
"incremental": true,
|
|
18
|
-
"skipLibCheck": true,
|
|
19
|
-
"strict": true,
|
|
20
|
-
"strictNullChecks": true,
|
|
21
|
-
"forceConsistentCasingInFileNames": true,
|
|
22
|
-
"noImplicitAny": false,
|
|
23
|
-
"noEmit": true,
|
|
24
|
-
"strictBindCallApply": false,
|
|
25
|
-
"noFallthroughCasesInSwitch": false
|
|
26
|
-
},
|
|
27
|
-
"include": ["src", "*.ts"]
|
|
28
|
-
}
|