@dewtech/dare-cli 2.16.0 → 2.17.0

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.
Files changed (86) hide show
  1. package/README.md +98 -0
  2. package/dist/__tests__/refine.test.d.ts +2 -0
  3. package/dist/__tests__/refine.test.d.ts.map +1 -0
  4. package/dist/__tests__/refine.test.js +186 -0
  5. package/dist/__tests__/refine.test.js.map +1 -0
  6. package/dist/__tests__/review.test.d.ts +2 -0
  7. package/dist/__tests__/review.test.d.ts.map +1 -0
  8. package/dist/__tests__/review.test.js +242 -0
  9. package/dist/__tests__/review.test.js.map +1 -0
  10. package/dist/__tests__/update.test.d.ts +2 -0
  11. package/dist/__tests__/update.test.d.ts.map +1 -0
  12. package/dist/__tests__/update.test.js +150 -0
  13. package/dist/__tests__/update.test.js.map +1 -0
  14. package/dist/bin/dare.js +6 -0
  15. package/dist/bin/dare.js.map +1 -1
  16. package/dist/commands/execute.d.ts.map +1 -1
  17. package/dist/commands/execute.js +76 -0
  18. package/dist/commands/execute.js.map +1 -1
  19. package/dist/commands/refine.d.ts +16 -0
  20. package/dist/commands/refine.d.ts.map +1 -0
  21. package/dist/commands/refine.js +167 -0
  22. package/dist/commands/refine.js.map +1 -0
  23. package/dist/commands/review.d.ts +16 -0
  24. package/dist/commands/review.d.ts.map +1 -0
  25. package/dist/commands/review.js +106 -0
  26. package/dist/commands/review.js.map +1 -0
  27. package/dist/commands/update.d.ts +13 -0
  28. package/dist/commands/update.d.ts.map +1 -0
  29. package/dist/commands/update.js +149 -0
  30. package/dist/commands/update.js.map +1 -0
  31. package/dist/types/Refine.types.d.ts +96 -0
  32. package/dist/types/Refine.types.d.ts.map +1 -0
  33. package/dist/types/Refine.types.js +19 -0
  34. package/dist/types/Refine.types.js.map +1 -0
  35. package/dist/types/Review.types.d.ts +86 -0
  36. package/dist/types/Review.types.d.ts.map +1 -0
  37. package/dist/types/Review.types.js +15 -0
  38. package/dist/types/Review.types.js.map +1 -0
  39. package/dist/types/UpdateManifest.types.d.ts +91 -0
  40. package/dist/types/UpdateManifest.types.d.ts.map +1 -0
  41. package/dist/types/UpdateManifest.types.js +13 -0
  42. package/dist/types/UpdateManifest.types.js.map +1 -0
  43. package/dist/utils/ReviewRunner.d.ts +42 -0
  44. package/dist/utils/ReviewRunner.d.ts.map +1 -0
  45. package/dist/utils/ReviewRunner.js +175 -0
  46. package/dist/utils/ReviewRunner.js.map +1 -0
  47. package/dist/utils/UpdateApplier.d.ts +42 -0
  48. package/dist/utils/UpdateApplier.d.ts.map +1 -0
  49. package/dist/utils/UpdateApplier.js +207 -0
  50. package/dist/utils/UpdateApplier.js.map +1 -0
  51. package/dist/utils/UpdateDetector.d.ts +56 -0
  52. package/dist/utils/UpdateDetector.d.ts.map +1 -0
  53. package/dist/utils/UpdateDetector.js +164 -0
  54. package/dist/utils/UpdateDetector.js.map +1 -0
  55. package/dist/utils/complexity-analyzer.d.ts +60 -0
  56. package/dist/utils/complexity-analyzer.d.ts.map +1 -0
  57. package/dist/utils/complexity-analyzer.js +292 -0
  58. package/dist/utils/complexity-analyzer.js.map +1 -0
  59. package/dist/utils/project-generator.d.ts.map +1 -1
  60. package/dist/utils/project-generator.js +21 -2
  61. package/dist/utils/project-generator.js.map +1 -1
  62. package/dist/utils/static-analyzer.d.ts +29 -0
  63. package/dist/utils/static-analyzer.d.ts.map +1 -0
  64. package/dist/utils/static-analyzer.js +390 -0
  65. package/dist/utils/static-analyzer.js.map +1 -0
  66. package/dist/utils/version-compare.d.ts +27 -0
  67. package/dist/utils/version-compare.d.ts.map +1 -0
  68. package/dist/utils/version-compare.js +47 -0
  69. package/dist/utils/version-compare.js.map +1 -0
  70. package/package.json +1 -1
  71. package/templates/UPDATE-MANIFEST.json +48 -0
  72. package/templates/ide/antigravity/.agents/skills/dare-blueprint/SKILL.md +180 -36
  73. package/templates/ide/antigravity/.agents/skills/dare-refine/SKILL.md +114 -0
  74. package/templates/ide/antigravity/.agents/skills/dare-review/SKILL.md +111 -0
  75. package/templates/ide/antigravity/.agents/skills/dare-tasks/SKILL.md +41 -0
  76. package/templates/ide/antigravity/templates/TASK-SPEC-template.md +45 -4
  77. package/templates/ide/claude/.claude/commands/dare-blueprint.md +56 -0
  78. package/templates/ide/claude/.claude/commands/dare-dag-build.md +41 -0
  79. package/templates/ide/claude/.claude/commands/dare-refine.md +145 -0
  80. package/templates/ide/claude/.claude/commands/dare-review.md +113 -0
  81. package/templates/ide/claude/templates/TASK-SPEC-template.md +45 -4
  82. package/templates/ide/cursor/.cursor/commands/generate-blueprint.md +45 -0
  83. package/templates/ide/cursor/.cursor/commands/generate-tasks.md +42 -0
  84. package/templates/ide/cursor/.cursor/commands/refine-task.md +107 -0
  85. package/templates/ide/cursor/.cursor/commands/review-task.md +91 -0
  86. package/templates/ide/cursor/templates/TASK-SPEC-template.md +45 -4
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Detects what `dare update` needs to do for a given project.
3
+ *
4
+ * Pure planning — it never writes to disk. Loads the manifest, reads the
5
+ * project's `dare.config.json`, and produces an `UpdatePlan` the applier can
6
+ * execute (or the dev can simply preview with `--dry-run`).
7
+ */
8
+ import fs from 'fs-extra';
9
+ import path from 'path';
10
+ import crypto from 'crypto';
11
+ import { createRequire } from 'module';
12
+ import { fileURLToPath } from 'url';
13
+ import { compareVersions, isNewerThan, sortVersionsAscending, } from './version-compare.js';
14
+ const require = createRequire(import.meta.url);
15
+ /** Path to `templates/UPDATE-MANIFEST.json`, shipped with the CLI. */
16
+ function getManifestPath() {
17
+ // `import.meta.url` resolves to .../dist/utils/UpdateDetector.js once built.
18
+ // The manifest lives at .../templates/UPDATE-MANIFEST.json, two levels up.
19
+ const here = fileURLToPath(import.meta.url);
20
+ return path.resolve(path.dirname(here), '..', '..', 'templates', 'UPDATE-MANIFEST.json');
21
+ }
22
+ export async function loadManifest() {
23
+ const manifestPath = getManifestPath();
24
+ if (!(await fs.pathExists(manifestPath))) {
25
+ throw new Error(`UPDATE-MANIFEST.json not found at ${manifestPath}`);
26
+ }
27
+ const data = (await fs.readJSON(manifestPath));
28
+ if (data.schemaVersion !== 1) {
29
+ throw new Error(`Unsupported manifest schemaVersion ${data.schemaVersion} (this CLI understands 1).`);
30
+ }
31
+ return data;
32
+ }
33
+ /** Read the current CLI version from the bundled `package.json`. */
34
+ export function getCliVersion() {
35
+ const pkg = require('../../package.json');
36
+ return pkg.version;
37
+ }
38
+ /**
39
+ * Legacy `dare init` versions (pre-2.17) wrote a hardcoded `"0.1.0"` placeholder
40
+ * that nothing read. Treat it as "this project was never tracked" — the update
41
+ * flow will assume the project is on 2.16.0 (the last release before this field
42
+ * carried meaning) and run the unification migration.
43
+ */
44
+ const LEGACY_PLACEHOLDER_VERSION = '0.1.0';
45
+ /** Baseline assumed for projects with the legacy placeholder or no `version`. */
46
+ export const LEGACY_BASELINE_VERSION = '2.16.0';
47
+ /**
48
+ * Resolve the "effective DARE version" of a project, handling the legacy
49
+ * `"0.1.0"` placeholder that was hardcoded by pre-2.17 `dare init`.
50
+ */
51
+ export function resolveProjectVersion(cfg) {
52
+ const raw = cfg.version;
53
+ if (!raw || raw === LEGACY_PLACEHOLDER_VERSION) {
54
+ return { version: LEGACY_BASELINE_VERSION, isLegacy: true };
55
+ }
56
+ return { version: raw, isLegacy: false };
57
+ }
58
+ /** Load and return `dare.config.json` from the given project root. */
59
+ export async function readProjectConfig(projectRoot) {
60
+ const configPath = path.join(projectRoot, 'dare.config.json');
61
+ if (!(await fs.pathExists(configPath))) {
62
+ throw new Error(`dare.config.json not found in ${projectRoot}. Is this a DARE project? Run \`dare init\` first.`);
63
+ }
64
+ return (await fs.readJSON(configPath));
65
+ }
66
+ /**
67
+ * Filter a single change against the IDE configured for this project. A change
68
+ * with `appliesTo: ['*']` (or no `appliesTo`) is universal.
69
+ *
70
+ * Hybrid setups (`hybrid` = cursor+antigravity, `claude-hybrid` = claude+cursor)
71
+ * accept changes targeted at any of their member IDEs.
72
+ */
73
+ export function changeAppliesToIde(change, ide) {
74
+ const targets = change.appliesTo ?? ['*'];
75
+ if (targets.includes('*'))
76
+ return true;
77
+ if (!ide)
78
+ return false;
79
+ if (targets.includes(ide))
80
+ return true;
81
+ // Hybrid expansions
82
+ if (ide === 'hybrid') {
83
+ return targets.includes('cursor') || targets.includes('antigravity');
84
+ }
85
+ if (ide === 'claude-hybrid') {
86
+ return targets.includes('claude-code') || targets.includes('cursor');
87
+ }
88
+ return false;
89
+ }
90
+ /**
91
+ * Build the update plan: every release between `from` (exclusive) and `to`
92
+ * (inclusive), with its changes filtered down to what applies to this IDE.
93
+ */
94
+ export function buildUpdatePlan(manifest, fromVersion, toVersion, ide) {
95
+ const allVersions = Object.keys(manifest.releases);
96
+ const sorted = sortVersionsAscending(allVersions);
97
+ const pending = sorted.filter((v) => {
98
+ const newerThanFrom = isNewerThan(v, fromVersion);
99
+ const notNewerThanTo = compareVersions(v, toVersion) !== 1;
100
+ return newerThanFrom && notNewerThanTo;
101
+ });
102
+ const pendingReleases = pending.map((version) => ({
103
+ version,
104
+ release: manifest.releases[version],
105
+ }));
106
+ const applicableChanges = [];
107
+ for (const { release } of pendingReleases) {
108
+ for (const change of release.changes) {
109
+ if (changeAppliesToIde(change, ide)) {
110
+ applicableChanges.push(change);
111
+ }
112
+ }
113
+ }
114
+ return {
115
+ fromVersion,
116
+ toVersion,
117
+ pendingReleases,
118
+ applicableChanges,
119
+ };
120
+ }
121
+ /** SHA-256 hex digest of file content; returns `null` if the file is absent. */
122
+ export async function hashFile(absPath) {
123
+ if (!(await fs.pathExists(absPath)))
124
+ return null;
125
+ const buf = await fs.readFile(absPath);
126
+ return crypto.createHash('sha256').update(buf).digest('hex');
127
+ }
128
+ /**
129
+ * Classify what we'd be doing to a single file on disk:
130
+ * - `identical` → new template content already matches what's on disk
131
+ * - `missing` → file absent in the project, safe to create
132
+ * - `apply` → file present and matches `previousHash`, safe to overwrite
133
+ * - `customized` → file present but doesn't match `previousHash`; ask the dev
134
+ *
135
+ * `newContent` is the bytes we'd write; `previousHash` is the manifest's record
136
+ * of what the file looked like in the prior version (optional — without it we
137
+ * can't tell `apply` from `customized` and conservatively return `customized`).
138
+ */
139
+ export async function classifyChange(projectRoot, change, newContent) {
140
+ // Schema-only changes (path includes `#`) are handled by migrations,
141
+ // not by file copy. Treat them as `apply`.
142
+ if (change.path.includes('#'))
143
+ return 'apply';
144
+ const target = path.join(projectRoot, change.path);
145
+ const currentHash = await hashFile(target);
146
+ if (change.type === 'removed') {
147
+ return currentHash === null ? 'identical' : 'apply';
148
+ }
149
+ if (currentHash === null)
150
+ return 'missing';
151
+ if (newContent !== null) {
152
+ const newHash = crypto
153
+ .createHash('sha256')
154
+ .update(typeof newContent === 'string' ? Buffer.from(newContent) : newContent)
155
+ .digest('hex');
156
+ if (newHash === currentHash)
157
+ return 'identical';
158
+ }
159
+ if (change.previousHash && currentHash === change.previousHash) {
160
+ return 'apply';
161
+ }
162
+ return 'customized';
163
+ }
164
+ //# sourceMappingURL=UpdateDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UpdateDetector.js","sourceRoot":"","sources":["../../src/utils/UpdateDetector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAQpC,OAAO,EACL,eAAe,EACf,WAAW,EACX,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,sEAAsE;AACtE,SAAS,eAAe;IACtB,6EAA6E;IAC7E,2EAA2E;IAC3E,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG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a task spec for signals that correlate with implementation effort
5
+ * and aggregates them into a single score → bucket. The breakdown is
6
+ * preserved so the CLI / agent can explain *why* a task scored high.
7
+ *
8
+ * Signals (weights tuned empirically — start conservative; bump as we learn):
9
+ * - Files to create/modify (1 each, cap at 10)
10
+ * - Public functions/endpoints declared in spec (1.5 each, cap at 10)
11
+ * - Test cases listed (0.5 each, cap at 8)
12
+ * - Inbound dependencies in dare-dag.yaml (0.5 each, no cap)
13
+ * - "Heavy" keywords in prompt/spec (+2 each: refactor, migrate, integrate,
14
+ * multiple, audit, replace, rewrite, parallelize, cross-cutting)
15
+ * - HIGH complexity declared by author (+3 baseline)
16
+ *
17
+ * Buckets:
18
+ * 0–5 → LOW
19
+ * 6–12 → MED
20
+ * 13–20 → HIGH ← recommends split
21
+ * 21+ → CRITICAL ← strongly recommends split
22
+ *
23
+ * The thresholds are tunable via `dare.config.json#refine.thresholds` (see
24
+ * Frente 4) — defaults below.
25
+ */
26
+ import type { ComplexityLevel, ComplexityReport, SplitProposal } from '../types/Refine.types.js';
27
+ export interface ComplexityThresholds {
28
+ low: number;
29
+ med: number;
30
+ high: number;
31
+ }
32
+ export declare const DEFAULT_THRESHOLDS: ComplexityThresholds;
33
+ export declare function levelFromScore(score: number, thresholds?: ComplexityThresholds): ComplexityLevel;
34
+ export interface AnalyzeOptions {
35
+ /** Override default thresholds (e.g. from dare.config.json#refine). */
36
+ thresholds?: ComplexityThresholds;
37
+ /** Extra `depends_on` count from `dare-dag.yaml` (optional — caller resolves). */
38
+ dependsOnCount?: number;
39
+ }
40
+ /**
41
+ * Build a complexity report for a single task. Returns `null` if the spec
42
+ * can't be found, so the caller can produce a user-friendly error.
43
+ */
44
+ export declare function analyzeTaskComplexity(taskId: string, projectRoot: string, options?: AnalyzeOptions): Promise<ComplexityReport | null>;
45
+ /**
46
+ * Produce a coarse split proposal. The algorithm:
47
+ * 1. Group files by top-level directory (e.g. `src/auth/*` vs `tests/*`
48
+ * vs `migrations/*`).
49
+ * 2. Each group becomes a candidate sub-task. If a group has more than
50
+ * `maxFilesPerSubtask` files, split it further alphabetically.
51
+ * 3. Generate suffixed ids: `task-034a`, `task-034b`, ...
52
+ *
53
+ * Intentionally not too clever — the IDE agent (via the `dare-refine` skill)
54
+ * is expected to refine this with semantic awareness. The CLI proposal is
55
+ * a sane default that gets it 70% of the way there.
56
+ */
57
+ export declare function proposeSplit(taskId: string, files: string[], options?: {
58
+ maxFilesPerSubtask?: number;
59
+ }): SplitProposal;
60
+ //# sourceMappingURL=complexity-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complexity-analyzer.d.ts","sourceRoot":"","sources":["../../src/utils/complexity-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAGhB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAIlC,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,kBAAkB,EAAE,oBAIhC,CAAC;AA+GF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,oBAAyC,GACpD,eAAe,CAKjB;AAID,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAuFlC;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,GAAE;IAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,aAAa,CAoDf"}
@@ -0,0 +1,292 @@
1
+ /**
2
+ * Deterministic complexity heuristic for `dare refine`.
3
+ *
4
+ * Scans a task spec for signals that correlate with implementation effort
5
+ * and aggregates them into a single score → bucket. The breakdown is
6
+ * preserved so the CLI / agent can explain *why* a task scored high.
7
+ *
8
+ * Signals (weights tuned empirically — start conservative; bump as we learn):
9
+ * - Files to create/modify (1 each, cap at 10)
10
+ * - Public functions/endpoints declared in spec (1.5 each, cap at 10)
11
+ * - Test cases listed (0.5 each, cap at 8)
12
+ * - Inbound dependencies in dare-dag.yaml (0.5 each, no cap)
13
+ * - "Heavy" keywords in prompt/spec (+2 each: refactor, migrate, integrate,
14
+ * multiple, audit, replace, rewrite, parallelize, cross-cutting)
15
+ * - HIGH complexity declared by author (+3 baseline)
16
+ *
17
+ * Buckets:
18
+ * 0–5 → LOW
19
+ * 6–12 → MED
20
+ * 13–20 → HIGH ← recommends split
21
+ * 21+ → CRITICAL ← strongly recommends split
22
+ *
23
+ * The thresholds are tunable via `dare.config.json#refine.thresholds` (see
24
+ * Frente 4) — defaults below.
25
+ */
26
+ import fs from 'fs-extra';
27
+ import path from 'path';
28
+ import { findSpecFile, parseFilesFromSpec } from './ReviewRunner.js';
29
+ export const DEFAULT_THRESHOLDS = {
30
+ low: 5,
31
+ med: 12,
32
+ high: 20,
33
+ };
34
+ /** Maximum contribution from any single signal — keeps the score bounded. */
35
+ const SIGNAL_CAPS = {
36
+ files: 10,
37
+ functions: 10,
38
+ tests: 8,
39
+ };
40
+ /** Weights per occurrence. */
41
+ const WEIGHTS = {
42
+ perFile: 1,
43
+ perFunction: 1.5,
44
+ perTest: 0.5,
45
+ perDependency: 0.5,
46
+ heavyKeyword: 2,
47
+ authorDeclaredHigh: 3,
48
+ };
49
+ /** Keywords that historically correlate with "this is bigger than it looks". */
50
+ const HEAVY_KEYWORDS = [
51
+ 'refactor',
52
+ 'refatorar',
53
+ 'migrate',
54
+ 'migrar',
55
+ 'migração',
56
+ 'integrate',
57
+ 'integrar',
58
+ 'integração',
59
+ 'multiple',
60
+ 'múltiplos',
61
+ 'audit',
62
+ 'auditar',
63
+ 'replace',
64
+ 'substituir',
65
+ 'rewrite',
66
+ 'reescrever',
67
+ 'parallelize',
68
+ 'paralelizar',
69
+ 'cross-cutting',
70
+ 'orchestrate',
71
+ 'orquestrar',
72
+ ];
73
+ // ── Signal extractors ────────────────────────────────────────────────────────
74
+ /**
75
+ * Count public functions/endpoints declared in the spec. We look at:
76
+ * - "Implementar `POST /…`" style mentions
77
+ * - "função `name()`" / "function `name()`"
78
+ * - Code-fence assinaturas (`fn x() -> ...`, `function x()`, `def x()`)
79
+ *
80
+ * Imperfect, but consistent — the test for refinement is "does this slope
81
+ * up monotonically with effort?", not "is this exact?".
82
+ */
83
+ function countDeclaredFunctions(specMarkdown) {
84
+ const patterns = [
85
+ // HTTP verbs inside backticks: `POST /auth/login`, `GET /users/:id`
86
+ /`(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+\/[^`]+`/gi,
87
+ // Function-like in backticks: `name()`, `name(arg: Type)`
88
+ /`\w+\s*\([^)]*\)`/g,
89
+ // Inline `fn x(...)` / `function x(...)` / `def x(...)` / `func x(...)`
90
+ /\b(function|fn|func|def|method)\s+\w+\s*\(/g,
91
+ ];
92
+ let total = 0;
93
+ for (const re of patterns) {
94
+ const matches = specMarkdown.match(re);
95
+ if (matches)
96
+ total += matches.length;
97
+ }
98
+ // Deduplicate-ish: a single endpoint may match both verb pattern and code-block.
99
+ // Halve to avoid double-counting; floor so a single hit still counts as 1.
100
+ return Math.max(1, Math.floor(total / 2));
101
+ }
102
+ /**
103
+ * Count test cases listed in the spec. We look at checkbox-style entries
104
+ * under the "Testes" / "Testing" section and `should_*` / `it(...)` names.
105
+ */
106
+ function countDeclaredTests(specMarkdown) {
107
+ const patterns = [
108
+ /^\s*-\s*\[\s*\]\s*(Teste|Test)\b/gim,
109
+ /\bshould_[a-z_]+/g,
110
+ /\bit\(['"]/g,
111
+ ];
112
+ let total = 0;
113
+ for (const re of patterns) {
114
+ const matches = specMarkdown.match(re);
115
+ if (matches)
116
+ total += matches.length;
117
+ }
118
+ return total;
119
+ }
120
+ /** Count occurrences of heavy keywords (case-insensitive, word-boundary). */
121
+ function countHeavyKeywords(specMarkdown) {
122
+ const lower = specMarkdown.toLowerCase();
123
+ let total = 0;
124
+ for (const kw of HEAVY_KEYWORDS) {
125
+ const re = new RegExp(`\\b${kw.toLowerCase()}\\b`, 'g');
126
+ const matches = lower.match(re);
127
+ if (matches)
128
+ total += matches.length;
129
+ }
130
+ return total;
131
+ }
132
+ /** Parse `**Complexidade:** HIGH` or similar from the spec header. */
133
+ function authorDeclaredHigh(specMarkdown) {
134
+ return /\*\*Complexidade:\*\*\s*HIGH/i.test(specMarkdown);
135
+ }
136
+ // ── Bucket selection ─────────────────────────────────────────────────────────
137
+ export function levelFromScore(score, thresholds = DEFAULT_THRESHOLDS) {
138
+ if (score <= thresholds.low)
139
+ return 'LOW';
140
+ if (score <= thresholds.med)
141
+ return 'MED';
142
+ if (score <= thresholds.high)
143
+ return 'HIGH';
144
+ return 'CRITICAL';
145
+ }
146
+ /**
147
+ * Build a complexity report for a single task. Returns `null` if the spec
148
+ * can't be found, so the caller can produce a user-friendly error.
149
+ */
150
+ export async function analyzeTaskComplexity(taskId, projectRoot, options = {}) {
151
+ const specPath = await findSpecFile(projectRoot, taskId);
152
+ if (!specPath) {
153
+ return {
154
+ taskId,
155
+ specPath: null,
156
+ score: 0,
157
+ level: 'LOW',
158
+ recommendsSplit: false,
159
+ signals: [
160
+ { kind: 'no-spec', weight: 0, detail: 'Spec não encontrada — refinamento ignorado.' },
161
+ ],
162
+ };
163
+ }
164
+ const md = await fs.readFile(specPath, 'utf-8');
165
+ const projectRelSpec = path.relative(projectRoot, specPath).replace(/\\/g, '/');
166
+ const fileCount = parseFilesFromSpec(md).length;
167
+ const fnCount = countDeclaredFunctions(md);
168
+ const testCount = countDeclaredTests(md);
169
+ const kwCount = countHeavyKeywords(md);
170
+ const deps = options.dependsOnCount ?? 0;
171
+ const high = authorDeclaredHigh(md);
172
+ const signals = [];
173
+ if (fileCount > 0) {
174
+ const w = Math.min(fileCount, SIGNAL_CAPS.files) * WEIGHTS.perFile;
175
+ signals.push({
176
+ kind: 'files',
177
+ weight: w,
178
+ detail: `${fileCount} arquivo(s) a criar/modificar`,
179
+ });
180
+ }
181
+ if (fnCount > 0) {
182
+ const w = Math.min(fnCount, SIGNAL_CAPS.functions) * WEIGHTS.perFunction;
183
+ signals.push({
184
+ kind: 'functions',
185
+ weight: w,
186
+ detail: `${fnCount} função(ões)/endpoint(s) público(s)`,
187
+ });
188
+ }
189
+ if (testCount > 0) {
190
+ const w = Math.min(testCount, SIGNAL_CAPS.tests) * WEIGHTS.perTest;
191
+ signals.push({
192
+ kind: 'tests',
193
+ weight: w,
194
+ detail: `${testCount} teste(s) declarado(s)`,
195
+ });
196
+ }
197
+ if (deps > 0) {
198
+ signals.push({
199
+ kind: 'dependencies',
200
+ weight: deps * WEIGHTS.perDependency,
201
+ detail: `${deps} dependência(s) (depends_on)`,
202
+ });
203
+ }
204
+ if (kwCount > 0) {
205
+ signals.push({
206
+ kind: 'keywords',
207
+ weight: kwCount * WEIGHTS.heavyKeyword,
208
+ detail: `${kwCount} palavra-chave(s) "pesada(s)" (refactor/migrate/integrate/...)`,
209
+ });
210
+ }
211
+ if (high) {
212
+ signals.push({
213
+ kind: 'author-high',
214
+ weight: WEIGHTS.authorDeclaredHigh,
215
+ detail: 'Spec já declarada como HIGH pelo autor',
216
+ });
217
+ }
218
+ signals.sort((a, b) => b.weight - a.weight);
219
+ const score = signals.reduce((acc, s) => acc + s.weight, 0);
220
+ const level = levelFromScore(score, options.thresholds ?? DEFAULT_THRESHOLDS);
221
+ const recommendsSplit = level === 'HIGH' || level === 'CRITICAL';
222
+ return {
223
+ taskId,
224
+ specPath: projectRelSpec,
225
+ score,
226
+ level,
227
+ recommendsSplit,
228
+ signals,
229
+ };
230
+ }
231
+ // ── Split proposal ───────────────────────────────────────────────────────────
232
+ /**
233
+ * Produce a coarse split proposal. The algorithm:
234
+ * 1. Group files by top-level directory (e.g. `src/auth/*` vs `tests/*`
235
+ * vs `migrations/*`).
236
+ * 2. Each group becomes a candidate sub-task. If a group has more than
237
+ * `maxFilesPerSubtask` files, split it further alphabetically.
238
+ * 3. Generate suffixed ids: `task-034a`, `task-034b`, ...
239
+ *
240
+ * Intentionally not too clever — the IDE agent (via the `dare-refine` skill)
241
+ * is expected to refine this with semantic awareness. The CLI proposal is
242
+ * a sane default that gets it 70% of the way there.
243
+ */
244
+ export function proposeSplit(taskId, files, options = {}) {
245
+ const maxFiles = options.maxFilesPerSubtask ?? 4;
246
+ if (files.length === 0) {
247
+ return {
248
+ originalTaskId: taskId,
249
+ subtasks: [],
250
+ notes: 'Nenhum arquivo listado na spec — split automático impossível. ' +
251
+ 'Adicione a tabela "ARQUIVOS A CRIAR / MODIFICAR" ou rode `/dare-refine <id>` para o agente sugerir.',
252
+ };
253
+ }
254
+ // Group by top-level directory (or first 2 segments if same root).
255
+ const groups = new Map();
256
+ for (const f of files) {
257
+ const parts = f.split('/');
258
+ const key = parts.length >= 2 ? `${parts[0]}/${parts[1]}` : parts[0];
259
+ if (!groups.has(key))
260
+ groups.set(key, []);
261
+ groups.get(key).push(f);
262
+ }
263
+ const subtasks = [];
264
+ let suffixIdx = 0;
265
+ for (const [groupKey, groupFiles] of groups) {
266
+ // Split overlarge groups alphabetically.
267
+ const sorted = [...groupFiles].sort();
268
+ const chunks = [];
269
+ for (let i = 0; i < sorted.length; i += maxFiles) {
270
+ chunks.push(sorted.slice(i, i + maxFiles));
271
+ }
272
+ for (const chunk of chunks) {
273
+ const suffix = String.fromCharCode(97 + suffixIdx); // a, b, c, ...
274
+ suffixIdx++;
275
+ subtasks.push({
276
+ id: `${taskId}${suffix}`,
277
+ title: `${taskId}${suffix}: ${groupKey}`,
278
+ files: chunk,
279
+ rationale: `Slice de ${groupKey} (${chunk.length} arquivo(s)) — cabe em uma conversa.`,
280
+ estimatedLevel: chunk.length >= maxFiles ? 'MED' : 'LOW',
281
+ });
282
+ }
283
+ }
284
+ return {
285
+ originalTaskId: taskId,
286
+ subtasks,
287
+ notes: `Split proposto em ${subtasks.length} sub-task(s) agrupando por diretório raiz. ` +
288
+ `Cada slice fica ≤ ${maxFiles} arquivos. Revise: o agrupamento por diretório é uma heurística — ` +
289
+ `o agente pode reorganizar se o domínio sugerir slices melhores.`,
290
+ };
291
+ }
292
+ //# sourceMappingURL=complexity-analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complexity-analyzer.js","sourceRoot":"","sources":["../../src/utils/complexity-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAiBrE,MAAM,CAAC,MAAM,kBAAkB,GAAyB;IACtD,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;CACT,CAAC;AAEF,6EAA6E;AAC7E,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE;IACb,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,8BAA8B;AAC9B,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,GAAG;IAChB,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,CAAC;IACf,kBAAkB,EAAE,CAAC;CACtB,CAAC;AAEF,gFAAgF;AAChF,MAAM,cAAc,GAAG;IACrB,UAAU;IACV,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,UAAU;IACV,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SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,aAAa,CAAC;IAC/C,WAAW,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC;IACpD,GAAG,EAAE,QAAQ,GAAG,aAAa,GAAG,QAAQ,GAAG,aAAa,GAAG,eAAe,CAAC;IAC3E,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACtC,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzC,2FAA2F;IAC3F,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAgJnF;AAED,wBAAsB,4BAA4B,CAChD,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAwCf"}
@@ -1,6 +1,13 @@
1
1
  import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
  import chalk from 'chalk';
4
+ import { createRequire } from 'module';
5
+ const requireFromHere = createRequire(import.meta.url);
6
+ /** Reads the CLI's own version from its bundled package.json. */
7
+ function getFrameworkVersion() {
8
+ const pkg = requireFromHere('../../package.json');
9
+ return pkg.version;
10
+ }
4
11
  import { generateCursorRules, generateAntigravityRules, generateSharedConfig, generateMcpCursorRules, generateMcpAntigravityRules, generateClaudeCodeRules, generateMcpClaudeCodeRules, generateClaudeCommands, generateClaudeSettings, } from './templates.js';
5
12
  import { bootstrapBackend, bootstrapFrontend, bootstrapMcp, } from './stack-bootstrap.js';
6
13
  export async function generateProjectStructure(config) {
@@ -25,7 +32,19 @@ export async function generateProjectStructure(config) {
25
32
  graphrag,
26
33
  mcp,
27
34
  toolchain: config.toolchain ?? 'auto',
28
- version: '0.1.0',
35
+ version: getFrameworkVersion(),
36
+ // Anti-stub gates introduced in v2.17.
37
+ // `review.onComplete` is opt-in (default off) so existing projects don't
38
+ // change behavior on upgrade; new projects get it on.
39
+ review: {
40
+ onComplete: true,
41
+ strict: false,
42
+ },
43
+ refine: {
44
+ // Thresholds map heuristic score → LOW/MED/HIGH/CRITICAL. See
45
+ // `complexity-analyzer.ts` for defaults; override per project here.
46
+ thresholds: { low: 5, med: 12, high: 20 },
47
+ },
29
48
  };
30
49
  if (structure === 'mcp-server') {
31
50
  configData.mcpTransport = config.mcpTransport;
@@ -125,7 +144,7 @@ export async function installDareToExistingProject(projectDir, config) {
125
144
  const { name, structure, backend, frontend, ide, graphrag, mcp } = config;
126
145
  await fs.ensureDir(path.join(outputDir, 'DARE'));
127
146
  await fs.ensureDir(path.join(outputDir, 'DARE', 'EXECUTION'));
128
- const configData = { name, structure, backend, frontend, ide, graphrag, mcp, version: '0.1.0', installedAt: new Date().toISOString() };
147
+ const configData = { name, structure, backend, frontend, ide, graphrag, mcp, version: getFrameworkVersion(), installedAt: new Date().toISOString() };
129
148
  if (structure === 'mcp-server') {
130
149
  configData.mcpTransport = config.mcpTransport;
131
150
  configData.mcpLanguage = config.mcpLanguage;