tech-os 0.0.0-stage → 0.1.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 +152 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +54 -0
- package/dist/commands/guide.d.ts +1 -0
- package/dist/commands/guide.js +30 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.js +139 -0
- package/dist/commands/run.d.ts +9 -0
- package/dist/commands/run.js +171 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +69 -0
- package/dist/core/paths.d.ts +13 -0
- package/dist/core/paths.js +23 -0
- package/dist/core/plan-parser.d.ts +28 -0
- package/dist/core/plan-parser.js +94 -0
- package/dist/tests/plan-parser.test.d.ts +1 -0
- package/dist/tests/plan-parser.test.js +42 -0
- package/docs/tech-os-guia.html +590 -0
- package/docs/tech-os-guia.pdf +0 -0
- package/package.json +50 -4
- package/templates/profiles/_dominio.md +9 -0
- package/templates/profiles/estudo.md +14 -0
- package/templates/profiles/mvp.md +21 -0
- package/templates/profiles/producao.md +23 -0
- package/templates/rules/cursor-rule.mdc +6 -0
- package/templates/rules/tech-os-core.md +28 -0
- package/templates/skills/tos-blueprint/SKILL.md +29 -0
- package/templates/skills/tos-contratos/SKILL.md +22 -0
- package/templates/skills/tos-discovery/SKILL.md +39 -0
- package/templates/skills/tos-manifesto/SKILL.md +34 -0
- package/templates/skills/tos-planejar/SKILL.md +38 -0
- package/templates/skills/tos-sync/SKILL.md +23 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = path.dirname(__filename);
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the root directory of the installed `tech-os` package
|
|
7
|
+
* (works both from `src/` during development and `dist/` when built).
|
|
8
|
+
*/
|
|
9
|
+
export function getPackageRoot() {
|
|
10
|
+
return path.resolve(__dirname, '..', '..');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolves a path inside the package's `templates/` directory.
|
|
14
|
+
*/
|
|
15
|
+
export function getTemplatePath(...segments) {
|
|
16
|
+
return path.join(getPackageRoot(), 'templates', ...segments);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the `.tech-os` directory in the target project workspace.
|
|
20
|
+
*/
|
|
21
|
+
export function getTechOsDir(cwd = process.cwd()) {
|
|
22
|
+
return path.join(cwd, '.tech-os');
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type SliceStatus = 'pending' | 'in_progress' | 'done';
|
|
2
|
+
export type SliceMode = 'AUTO' | 'HUMANO';
|
|
3
|
+
export interface PlanSlice {
|
|
4
|
+
id: string;
|
|
5
|
+
status: SliceStatus;
|
|
6
|
+
mode: SliceMode;
|
|
7
|
+
title: string;
|
|
8
|
+
deps: string[];
|
|
9
|
+
us: string;
|
|
10
|
+
lineIndex: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function statusToChar(status: SliceStatus): string;
|
|
13
|
+
/**
|
|
14
|
+
* Parses the markdown content of `04-plano.md` into structured slices.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parsePlanContent(content: string): PlanSlice[];
|
|
17
|
+
/**
|
|
18
|
+
* Reads and parses a `04-plano.md` file from disk.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readPlanFile(filePath: string): Promise<PlanSlice[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Finds the next unblocked slice (pending or in_progress) whose dependencies are all `done`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function findNextUnblockedSlice(slices: PlanSlice[]): PlanSlice | null;
|
|
25
|
+
/**
|
|
26
|
+
* Updates the status checkbox of a given slice ID in `04-plano.md`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function updateSliceStatus(filePath: string, sliceId: string, newStatus: SliceStatus): Promise<void>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
const SLICE_REGEX = /^\s*-\s+\[([ x~])\]\s+(F\d+)\s+\[(AUTO|HUMANO)\]\s+(.+?)(?:\s+\|\s+deps:\s*([^|]+?))?(?:\s+\|\s+us:\s*(.+?))?\s*$/;
|
|
3
|
+
function charToStatus(ch) {
|
|
4
|
+
if (ch === 'x')
|
|
5
|
+
return 'done';
|
|
6
|
+
if (ch === '~')
|
|
7
|
+
return 'in_progress';
|
|
8
|
+
return 'pending';
|
|
9
|
+
}
|
|
10
|
+
export function statusToChar(status) {
|
|
11
|
+
if (status === 'done')
|
|
12
|
+
return 'x';
|
|
13
|
+
if (status === 'in_progress')
|
|
14
|
+
return '~';
|
|
15
|
+
return ' ';
|
|
16
|
+
}
|
|
17
|
+
function parseDeps(raw) {
|
|
18
|
+
if (!raw)
|
|
19
|
+
return [];
|
|
20
|
+
const trimmed = raw.trim();
|
|
21
|
+
if (trimmed === '-' || trimmed === '—' || trimmed === '')
|
|
22
|
+
return [];
|
|
23
|
+
return trimmed
|
|
24
|
+
.split(',')
|
|
25
|
+
.map((d) => d.trim())
|
|
26
|
+
.filter(Boolean);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parses the markdown content of `04-plano.md` into structured slices.
|
|
30
|
+
*/
|
|
31
|
+
export function parsePlanContent(content) {
|
|
32
|
+
const lines = content.split(/\r?\n/);
|
|
33
|
+
const slices = [];
|
|
34
|
+
for (let i = 0; i < lines.length; i++) {
|
|
35
|
+
const match = lines[i].match(SLICE_REGEX);
|
|
36
|
+
if (!match)
|
|
37
|
+
continue;
|
|
38
|
+
const [, statusChar, id, mode, title, rawDeps, rawUs] = match;
|
|
39
|
+
slices.push({
|
|
40
|
+
id,
|
|
41
|
+
status: charToStatus(statusChar),
|
|
42
|
+
mode: mode,
|
|
43
|
+
title: title.trim(),
|
|
44
|
+
deps: parseDeps(rawDeps),
|
|
45
|
+
us: rawUs ? rawUs.trim() : '-',
|
|
46
|
+
lineIndex: i,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return slices;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Reads and parses a `04-plano.md` file from disk.
|
|
53
|
+
*/
|
|
54
|
+
export async function readPlanFile(filePath) {
|
|
55
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
56
|
+
return parsePlanContent(content);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Finds the next unblocked slice (pending or in_progress) whose dependencies are all `done`.
|
|
60
|
+
*/
|
|
61
|
+
export function findNextUnblockedSlice(slices) {
|
|
62
|
+
const doneIds = new Set(slices.filter((s) => s.status === 'done').map((s) => s.id));
|
|
63
|
+
for (const slice of slices) {
|
|
64
|
+
if (slice.status === 'done')
|
|
65
|
+
continue;
|
|
66
|
+
const allDepsDone = slice.deps.every((dep) => doneIds.has(dep));
|
|
67
|
+
if (allDepsDone) {
|
|
68
|
+
return slice;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Updates the status checkbox of a given slice ID in `04-plano.md`.
|
|
75
|
+
*/
|
|
76
|
+
export async function updateSliceStatus(filePath, sliceId, newStatus) {
|
|
77
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
78
|
+
const eol = content.includes('\r\n') ? '\r\n' : '\n';
|
|
79
|
+
const lines = content.split(/\r?\n/);
|
|
80
|
+
const targetChar = statusToChar(newStatus);
|
|
81
|
+
let updated = false;
|
|
82
|
+
for (let i = 0; i < lines.length; i++) {
|
|
83
|
+
const match = lines[i].match(SLICE_REGEX);
|
|
84
|
+
if (match && match[2] === sliceId) {
|
|
85
|
+
lines[i] = lines[i].replace(/^(\s*-\s+\[)[ x~](\])/, `$1${targetChar}$2`);
|
|
86
|
+
updated = true;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!updated) {
|
|
91
|
+
throw new Error(`Fatia ${sliceId} não encontrada em ${filePath}`);
|
|
92
|
+
}
|
|
93
|
+
await fs.writeFile(filePath, lines.join(eol), 'utf-8');
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { parsePlanContent, findNextUnblockedSlice } from '../core/plan-parser.js';
|
|
4
|
+
describe('plan-parser', () => {
|
|
5
|
+
const samplePlan = `# Plano: 001-auth
|
|
6
|
+
|
|
7
|
+
- [x] F01 [AUTO] Criar schema de usuários | deps: - | us: US-1
|
|
8
|
+
- [ ] F02 [AUTO] Implementar serviço de login | deps: F01 | us: US-1
|
|
9
|
+
- [ ] F03 [HUMANO] Revisar tokens e expiração | deps: F02 | us: -
|
|
10
|
+
- [ ] F04 [AUTO] Criar rota POST /login + testes | deps: F03 | us: US-1
|
|
11
|
+
`;
|
|
12
|
+
it('parses slices with status, mode, deps, and us', () => {
|
|
13
|
+
const slices = parsePlanContent(samplePlan);
|
|
14
|
+
assert.equal(slices.length, 4);
|
|
15
|
+
assert.deepEqual(slices[0], {
|
|
16
|
+
id: 'F01',
|
|
17
|
+
status: 'done',
|
|
18
|
+
mode: 'AUTO',
|
|
19
|
+
title: 'Criar schema de usuários',
|
|
20
|
+
deps: [],
|
|
21
|
+
us: 'US-1',
|
|
22
|
+
lineIndex: 2,
|
|
23
|
+
});
|
|
24
|
+
assert.deepEqual(slices[1].deps, ['F01']);
|
|
25
|
+
assert.equal(slices[2].mode, 'HUMANO');
|
|
26
|
+
});
|
|
27
|
+
it('finds the next unblocked slice', () => {
|
|
28
|
+
const slices = parsePlanContent(samplePlan);
|
|
29
|
+
const next = findNextUnblockedSlice(slices);
|
|
30
|
+
assert.equal(next?.id, 'F02');
|
|
31
|
+
});
|
|
32
|
+
it('returns null when remaining slices are blocked on unfinished deps', () => {
|
|
33
|
+
const blockedPlan = `
|
|
34
|
+
- [ ] F01 [HUMANO] Aprovar contrato | deps: - | us: -
|
|
35
|
+
- [ ] F02 [AUTO] Implementar rota | deps: F01 | us: US-1
|
|
36
|
+
`;
|
|
37
|
+
const slices = parsePlanContent(blockedPlan);
|
|
38
|
+
const next = findNextUnblockedSlice(slices);
|
|
39
|
+
assert.equal(next?.id, 'F01');
|
|
40
|
+
assert.equal(next?.mode, 'HUMANO');
|
|
41
|
+
});
|
|
42
|
+
});
|