agjan 0.0.10 → 0.0.12

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 (119) hide show
  1. package/README.md +2 -2
  2. package/bin/agjan.mjs +9 -2
  3. package/dist/adapters/claude-code.js +105 -0
  4. package/dist/adapters/copilot.js +80 -0
  5. package/dist/auto.js +24 -0
  6. package/dist/baseline.js +66 -0
  7. package/dist/browser.js +46 -0
  8. package/dist/cli.js +164 -0
  9. package/dist/commands/branch.js +71 -0
  10. package/dist/commands/check.js +420 -0
  11. package/dist/commands/fix.js +122 -0
  12. package/dist/commands/gates.js +462 -0
  13. package/dist/commands/lint.js +76 -0
  14. package/dist/commands/log.js +72 -0
  15. package/dist/commands/map.js +47 -0
  16. package/dist/commands/new.js +65 -0
  17. package/dist/commands/pr-summary.js +168 -0
  18. package/dist/commands/progress.js +42 -0
  19. package/dist/commands/report.js +105 -0
  20. package/dist/commands/review.js +146 -0
  21. package/dist/commands/setup.js +393 -0
  22. package/dist/commands/status.js +303 -0
  23. package/dist/commands/ui-test.js +39 -0
  24. package/dist/config.js +110 -0
  25. package/dist/context.js +56 -0
  26. package/dist/copilot-mcp.js +56 -0
  27. package/dist/documents.js +207 -0
  28. package/dist/errors.js +15 -0
  29. package/dist/feature.js +221 -0
  30. package/dist/fix.js +117 -0
  31. package/dist/git.js +88 -0
  32. package/{src/hash.mjs → dist/hash.js} +11 -14
  33. package/dist/hook.js +47 -0
  34. package/dist/json-file.js +26 -0
  35. package/dist/log.js +50 -0
  36. package/dist/managed.js +182 -0
  37. package/dist/mcp-config.js +76 -0
  38. package/dist/mcp.js +142 -0
  39. package/dist/plan.js +40 -0
  40. package/dist/progress-view.js +494 -0
  41. package/dist/progress.js +106 -0
  42. package/{src/review-policy.mjs → dist/review-policy.js} +39 -47
  43. package/dist/review.js +435 -0
  44. package/dist/scope.js +30 -0
  45. package/dist/terminal.js +127 -0
  46. package/dist/test-results.js +101 -0
  47. package/dist/tests-map.js +29 -0
  48. package/dist/types.js +5 -0
  49. package/dist/ui.js +136 -0
  50. package/dist/usage.js +116 -0
  51. package/dist/validate.js +46 -0
  52. package/docs/guide.md +98 -37
  53. package/kit/domains/btp/domain.json +4 -4
  54. package/kit/hooks/guard.mjs +48 -119
  55. package/kit/skills/agjan-build/SKILL.md +14 -8
  56. package/kit/skills/agjan-design/SKILL.md +42 -6
  57. package/kit/skills/agjan-fix/SKILL.md +9 -10
  58. package/kit/skills/agjan-map/SKILL.md +9 -10
  59. package/kit/skills/agjan-spec/SKILL.md +22 -11
  60. package/kit/skills/agjan-verify/SKILL.md +46 -19
  61. package/kit/skills/cap-developer/SKILL.md +10 -2
  62. package/kit/skills/cap-developer/references/handlers.md +11 -9
  63. package/kit/skills/cap-developer/references/project-setup.md +21 -8
  64. package/kit/skills/cap-developer/references/testing.md +38 -14
  65. package/kit/skills/cap-developer/references/typescript.md +143 -0
  66. package/kit/skills/cap-developer/references/validation-security.md +26 -8
  67. package/kit/skills/fiori-developer/SKILL.md +20 -5
  68. package/kit/skills/fiori-developer/references/app-setup.md +91 -16
  69. package/kit/skills/fiori-developer/references/elements.md +19 -5
  70. package/kit/skills/fiori-developer/references/freestyle-ts.md +5 -1
  71. package/kit/skills/fiori-developer/references/testing.md +109 -15
  72. package/kit/templates/agents-block.md +7 -3
  73. package/package.json +11 -3
  74. package/schemas/approvals.schema.json +23 -2
  75. package/schemas/config.schema.json +0 -5
  76. package/schemas/log.schema.json +1 -1
  77. package/src/adapters/claude-code.mjs +0 -121
  78. package/src/adapters/copilot.mjs +0 -89
  79. package/src/baseline.mjs +0 -66
  80. package/src/cli.mjs +0 -155
  81. package/src/commands/branch.mjs +0 -60
  82. package/src/commands/check.mjs +0 -365
  83. package/src/commands/fix.mjs +0 -116
  84. package/src/commands/gates.mjs +0 -264
  85. package/src/commands/lint.mjs +0 -74
  86. package/src/commands/log.mjs +0 -60
  87. package/src/commands/map.mjs +0 -47
  88. package/src/commands/new.mjs +0 -53
  89. package/src/commands/pr-summary.mjs +0 -137
  90. package/src/commands/progress.mjs +0 -40
  91. package/src/commands/report.mjs +0 -115
  92. package/src/commands/review.mjs +0 -76
  93. package/src/commands/setup.mjs +0 -383
  94. package/src/commands/status.mjs +0 -248
  95. package/src/config.mjs +0 -122
  96. package/src/context.mjs +0 -67
  97. package/src/copilot-mcp.mjs +0 -56
  98. package/src/documents.mjs +0 -188
  99. package/src/errors.mjs +0 -16
  100. package/src/feature.mjs +0 -225
  101. package/src/fix.mjs +0 -108
  102. package/src/git.mjs +0 -83
  103. package/src/hook.mjs +0 -48
  104. package/src/json-file.mjs +0 -24
  105. package/src/log.mjs +0 -51
  106. package/src/managed.mjs +0 -178
  107. package/src/mcp-config.mjs +0 -83
  108. package/src/mcp.mjs +0 -147
  109. package/src/plan.mjs +0 -45
  110. package/src/progress-view.mjs +0 -466
  111. package/src/progress.mjs +0 -85
  112. package/src/review.mjs +0 -413
  113. package/src/scope.mjs +0 -30
  114. package/src/terminal.mjs +0 -118
  115. package/src/test-results.mjs +0 -111
  116. package/src/tests-map.mjs +0 -29
  117. package/src/ui.mjs +0 -136
  118. package/src/usage.mjs +0 -118
  119. package/src/validate.mjs +0 -41
@@ -1,111 +0,0 @@
1
- import { existsSync, readFileSync, statSync } from 'node:fs';
2
- import { join } from 'node:path';
3
-
4
- /**
5
- * Test results (design 6.6): with `verify.<area>.results` configured, an automated AC
6
- * must have a test case containing its id that ran and passed. Formats: JUnit XML (node
7
- * --test, jest-junit, mocha-junit-reporter, ...), Jest JSON (`--json`) and Mocha JSON
8
- * (`--reporter json`). Each result is { name, status: passed | failed | skipped }.
9
- */
10
-
11
- const ENTITIES = { lt: '<', gt: '>', amp: '&', quot: '"', apos: "'" };
12
-
13
- function decode(text) {
14
- return text.replace(/&(#x?[0-9a-fA-F]+|[a-z]+);/g, (whole, code) => {
15
- if (code[0] === '#') return String.fromCodePoint(code[1] === 'x' ? parseInt(code.slice(2), 16) : Number(code.slice(1)));
16
- return ENTITIES[code] ?? whole;
17
- });
18
- }
19
-
20
- function attribute(tag, name) {
21
- const match = new RegExp(`\\s${name}\\s*=\\s*("([^"]*)"|'([^']*)')`).exec(tag);
22
- return match ? decode(match[2] ?? match[3]) : '';
23
- }
24
-
25
- function parseJUnit(text) {
26
- const results = [];
27
- // Attributes as quoted strings: XML allows a literal '>' inside a value (name="&lt;next>").
28
- const testcase = /<testcase\b((?:\s+[^\s=/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/>|>([\s\S]*?)<\/testcase>)/g;
29
- for (const match of text.matchAll(testcase)) {
30
- const body = match[3] ?? '';
31
- const status = /<(failure|error)\b/.test(body) ? 'failed' : /<skipped\b/.test(body) ? 'skipped' : 'passed';
32
- const name = [attribute(match[1], 'classname'), attribute(match[1], 'name')].filter(Boolean).join(' ');
33
- results.push({ name, status });
34
- }
35
- return results;
36
- }
37
-
38
- function parseJson(data) {
39
- // Jest: { testResults: [{ assertionResults: [{ fullName, status }] }] }
40
- if (Array.isArray(data?.testResults)) {
41
- return data.testResults.flatMap((file) =>
42
- (file.assertionResults ?? []).map((a) => ({
43
- name: a.fullName ?? a.title ?? '',
44
- status: a.status === 'passed' ? 'passed' : a.status === 'failed' ? 'failed' : 'skipped',
45
- })),
46
- );
47
- }
48
- // Mocha: { passes: [{ fullTitle }], failures: [...], pending: [...] }
49
- if (Array.isArray(data?.passes) || Array.isArray(data?.failures)) {
50
- const list = (items, status) => (items ?? []).map((t) => ({ name: t.fullTitle ?? t.title ?? '', status }));
51
- return [...list(data.passes, 'passed'), ...list(data.failures, 'failed'), ...list(data.pending, 'skipped')];
52
- }
53
- return null;
54
- }
55
-
56
- /** Parses one results file; returns null when the format is not recognized. */
57
- export function parseResults(text) {
58
- const trimmed = text.trimStart();
59
- if (trimmed.startsWith('<')) return parseJUnit(text);
60
- try {
61
- return parseJson(JSON.parse(trimmed));
62
- } catch {
63
- return null;
64
- }
65
- }
66
-
67
- /** The configured results files of the given areas, read and parsed. */
68
- export function loadResults(root, config, areaNames) {
69
- const files = [...new Set(areaNames.flatMap((name) => {
70
- const results = config.verify?.[name]?.results;
71
- return results ? (Array.isArray(results) ? results : [results]) : [];
72
- }))];
73
- const loaded = [];
74
- const missing = [];
75
- const unreadable = [];
76
- for (const file of files) {
77
- const path = join(root, file);
78
- if (!existsSync(path)) {
79
- missing.push(file);
80
- continue;
81
- }
82
- const results = parseResults(readFileSync(path, 'utf8'));
83
- if (results === null) unreadable.push(file);
84
- else loaded.push({ file, mtimeMs: statSync(path).mtimeMs, results });
85
- }
86
- return { configured: files.length > 0, files: loaded, missing, unreadable };
87
- }
88
-
89
- /** Per AC id of the feature: how many matching test cases passed, failed or were skipped. */
90
- export function acResults(loaded, key) {
91
- const pattern = new RegExp(`\\b${key}-AC[1-9][0-9]*\\b`, 'g');
92
- const counts = new Map();
93
- for (const { results } of loaded.files) {
94
- for (const r of results) {
95
- for (const id of new Set(r.name.match(pattern) ?? [])) {
96
- const c = counts.get(id) ?? { passed: 0, failed: 0, skipped: 0 };
97
- c[r.status] += 1;
98
- counts.set(id, c);
99
- }
100
- }
101
- }
102
- return counts;
103
- }
104
-
105
- /** A short verdict per AC for summaries: passed (n), failed, skipped, not run. */
106
- export function resultLabel(counts) {
107
- if (!counts) return 'not run';
108
- if (counts.failed) return 'failed';
109
- if (counts.passed) return `passed (${counts.passed})`;
110
- return 'skipped';
111
- }
package/src/tests-map.mjs DELETED
@@ -1,29 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { git } from './git.mjs';
4
- import { matcher } from './scope.mjs';
5
-
6
- /** Tracked and untracked (not ignored) files of the repository. */
7
- export function repoFiles(root) {
8
- return git(root, ['ls-files', '--cached', '--others', '--exclude-standard']).split('\n').filter(Boolean);
9
- }
10
-
11
- /** For each AC id of the feature key, the test files that mention it. */
12
- export function acTestFiles(root, config, areaNames, key) {
13
- const isTest = matcher(areaNames.flatMap((name) => config.tests[name] ?? []));
14
- const pattern = new RegExp(`\\b${key}-AC[1-9][0-9]*\\b`, 'g');
15
- const found = new Map();
16
- for (const file of repoFiles(root).filter(isTest)) {
17
- let text;
18
- try {
19
- text = readFileSync(join(root, file), 'utf8');
20
- } catch {
21
- continue; // deleted in the working tree
22
- }
23
- for (const match of text.matchAll(pattern)) {
24
- if (!found.has(match[0])) found.set(match[0], new Set());
25
- found.get(match[0]).add(file);
26
- }
27
- }
28
- return found;
29
- }
package/src/ui.mjs DELETED
@@ -1,136 +0,0 @@
1
- /**
2
- * Terminal styling for human-facing output. Colors only when the stream is a terminal, so
3
- * agents (whose shell tools are not terminals), pipes, CI logs and tests get plain text.
4
- * NO_COLOR turns colors off (https://no-color.org), FORCE_COLOR turns them on.
5
- */
6
-
7
- const CODES = {
8
- bold: [1, 22],
9
- dim: [2, 22],
10
- red: [31, 39],
11
- green: [32, 39],
12
- yellow: [33, 39],
13
- blue: [34, 39],
14
- magenta: [35, 39],
15
- cyan: [36, 39],
16
- gray: [90, 39],
17
- };
18
-
19
- export function colorEnabled(stream, env = process.env) {
20
- // FORCE_COLOR wins over NO_COLOR, as in Node itself.
21
- if ('FORCE_COLOR' in env) return env.FORCE_COLOR !== '0' && env.FORCE_COLOR !== 'false';
22
- if ('NO_COLOR' in env && env.NO_COLOR !== '') return false;
23
- return Boolean(stream?.isTTY) && env.TERM !== 'dumb';
24
- }
25
-
26
- /** Style functions for one stream: `s.red('text')`; identity functions when colors are off. */
27
- export function createStyle(stream, env = process.env) {
28
- const enabled = colorEnabled(stream, env);
29
- const style = {
30
- enabled,
31
- truecolor: enabled && /^(truecolor|24bit)$/i.test(env.COLORTERM ?? ''),
32
- // The agjan mark: on a terminal (also with NO_COLOR, then without colors), never for
33
- // agents, pipes or CI; AGJAN_BANNER=0 turns it off.
34
- brand: env.AGJAN_BANNER !== '0' && (enabled || Boolean(stream?.isTTY)),
35
- };
36
- for (const [name, [open, close]] of Object.entries(CODES)) {
37
- style[name] = enabled ? (text) => `\x1b[${open}m${text}\x1b[${close}m` : (text) => String(text);
38
- }
39
- // Brand teal (#2EC4A0); cyan where the terminal has no true color.
40
- style.teal = !enabled ? (text) => String(text) : style.truecolor ? (text) => `\x1b[38;2;46;196;160m${text}\x1b[39m` : style.cyan;
41
- style.violet = !enabled ? (text) => String(text) : style.truecolor ? (text) => `\x1b[38;2;168;145;245m${text}\x1b[39m` : style.magenta;
42
- return style;
43
- }
44
-
45
- /** Colors for the words the commands print: states, verdicts, severities, levels. */
46
- const TONES = {
47
- green: ['ok', 'approved', 'pass', 'done', 'resolved', 'accepted', 'current', 'created', 'installed', 'merged', 'passed'],
48
- yellow: ['warn', 'draft', 'pass-with-notes', 'open', 'due', 'proposed', 'updated', 'major', 'pending', 'kept', 'removed'],
49
- red: ['error', 'fail', 'stale', 'blocked', 'rejected', 'blocker', 'blocks', 'modified', 'missing', 'failed'],
50
- gray: ['unchanged', 'minor', 'none'],
51
- };
52
- const TONE_OF = new Map(Object.entries(TONES).flatMap(([tone, words]) => words.map((w) => [w, tone])));
53
-
54
- /** Colors a known status word (`approved` green, `stale` red, ...); other text unchanged. */
55
- export function tone(style, word) {
56
- const name = TONE_OF.get(String(word).trim());
57
- return name ? style[name](word) : String(word);
58
- }
59
-
60
- /** Pads by the plain text's length, so colored columns stay aligned. */
61
- export function pad(styled, plain, width) {
62
- return styled + ' '.repeat(Math.max(width - String(plain).length, 0));
63
- }
64
-
65
- /** Summary line color: red with errors, yellow with warnings only, green otherwise. */
66
- export function verdictColor(style, errors, warnings) {
67
- if (errors) return style.red;
68
- if (warnings) return style.yellow;
69
- return style.green;
70
- }
71
-
72
- /** Status words inside Markdown text: whole words only, `pass-with-notes` before `pass`. */
73
- const WORDS = new RegExp(`(?<![\\w-])(${[...TONE_OF.keys()].sort((a, b) => b.length - a.length).join('|')})(?![\\w-])`, 'g');
74
-
75
- /**
76
- * Highlights Markdown for reading on a terminal: headings, bold text, table rules and the
77
- * known status words. The text stays valid Markdown once the colors are stripped.
78
- */
79
- export function highlightMarkdown(style, text) {
80
- if (!style.enabled) return text;
81
- return text
82
- .split('\n')
83
- .map((line) => {
84
- if (/^#{1,6} /.test(line)) return style.bold(style.cyan(line));
85
- if (/^\|[-| ]+\|$/.test(line)) return style.gray(line);
86
- return line
87
- .replace(/\*\*([^*]+)\*\*/g, (_, inner) => style.bold(`**${inner}**`))
88
- .replace(WORDS, (word) => tone(style, word))
89
- .replace(/^\||(?<= )\|/g, (bar) => style.gray(bar));
90
- })
91
- .join('\n');
92
- }
93
-
94
- /**
95
- * The agjan mark (the "ag" of the app icon: the bowl of the a with its teal stem, and the
96
- * g with its descender) with two lines of text beside it. Empty when the brand is off.
97
- */
98
- export function mark(style, version, line2 = 'spec-driven work with AI agents, gated by you', line3 = '') {
99
- if (!style.brand) return [];
100
- const stem = style.teal('┃');
101
- return [
102
- '',
103
- ` ╭─╮${stem}╭─╮╷ ${style.bold('agjan')} ${version}`,
104
- ` ╰─╯${stem}╰─╯│ ${line2}`,
105
- ` ╶─╯ ${line3 ? style.gray(line3) : ''}`.trimEnd(),
106
- '',
107
- ];
108
- }
109
-
110
- /**
111
- * The mark blinks twice (its two bowls close and open), on a real terminal only: not in
112
- * CI, not when the brand is off, not for streams that tests pass. `lines` is what
113
- * mark() returned and was just written.
114
- */
115
- export async function blink(ctx, lines) {
116
- if (!lines.length || !ctx.isTTY || process.env.CI) return;
117
- const open = [lines[1], lines[2]];
118
- const closed = [lines[1].replace(/╭─╮/g, ' '), lines[2].replace(/╰─╯/g, '╶─╴')];
119
- const draw = ([top, bottom]) => ctx.write(`\x1b[${lines.length - 1}A\r\x1b[2K${top}\n\x1b[2K${bottom}\n\x1b[${lines.length - 3}B`);
120
- const wait = (ms) => new Promise((done) => setTimeout(done, ms));
121
- ctx.write('\x1b[?25l');
122
- try {
123
- for (const [frame, ms] of [[closed, 120], [open, 220], [closed, 120], [open, 0]]) {
124
- draw(frame);
125
- await wait(ms);
126
- }
127
- } finally {
128
- ctx.write('\x1b[?25h');
129
- }
130
- }
131
-
132
- /** The one-line mark for frequent commands: `┃ agjan 0.0.6 · status`. Empty when the brand is off. */
133
- export function markLine(style, version, what) {
134
- if (!style.brand) return [];
135
- return [`${style.teal('┃')} ${style.bold('agjan')} ${style.gray(`${version} · ${what}`)}`];
136
- }
package/src/usage.mjs DELETED
@@ -1,118 +0,0 @@
1
- import { existsSync, readFileSync, readdirSync, realpathSync } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { join } from 'node:path';
4
-
5
- /**
6
- * Actual model and token usage from the hosts' own session records (design 12.2,
7
- * host experiments item 4), never from the model's statements. Both formats are
8
- * internal to the hosts: anything unexpected is skipped, and the report then says
9
- * "unknown". Each record: { at (ms), host, model, input, cacheRead, cacheWrite, output,
10
- * agent: 'main' | 'subagent' }.
11
- */
12
-
13
- function readLines(file) {
14
- try {
15
- return readFileSync(file, 'utf8').split('\n');
16
- } catch {
17
- return [];
18
- }
19
- }
20
-
21
- function parse(line) {
22
- try {
23
- return JSON.parse(line);
24
- } catch {
25
- return null;
26
- }
27
- }
28
-
29
- function sameDir(a, b) {
30
- try {
31
- return realpathSync(a) === realpathSync(b);
32
- } catch {
33
- return a === b;
34
- }
35
- }
36
-
37
- /** Claude Code: ~/.claude/projects/<cwd with every non [A-Za-z0-9-] as '-'>/…jsonl. */
38
- export function claudeUsage(root, { home = process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude') } = {}) {
39
- const dir = join(home, 'projects', realpathOr(root).replace(/[^A-Za-z0-9-]/g, '-'));
40
- if (!existsSync(dir)) return [];
41
- const files = [];
42
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
43
- if (entry.isFile() && entry.name.endsWith('.jsonl')) files.push(join(dir, entry.name));
44
- const sub = join(dir, entry.name, 'subagents');
45
- if (entry.isDirectory() && existsSync(sub)) {
46
- for (const f of readdirSync(sub)) if (f.endsWith('.jsonl')) files.push(join(sub, f));
47
- }
48
- }
49
- const seen = new Set();
50
- const records = [];
51
- for (const file of files) {
52
- for (const line of readLines(file)) {
53
- const entry = parse(line);
54
- const usage = entry?.message?.usage;
55
- if (entry?.type !== 'assistant' || !usage || !entry.timestamp) continue;
56
- // One response can be written as several lines with the same request id.
57
- const key = entry.requestId ?? entry.message.id ?? `${file}:${entry.uuid}`;
58
- if (seen.has(key)) continue;
59
- seen.add(key);
60
- records.push({
61
- at: Date.parse(entry.timestamp),
62
- host: 'claude-code',
63
- model: entry.message.model ?? 'unknown',
64
- input: usage.input_tokens ?? 0,
65
- cacheRead: usage.cache_read_input_tokens ?? 0,
66
- cacheWrite: usage.cache_creation_input_tokens ?? 0,
67
- output: usage.output_tokens ?? 0,
68
- agent: entry.isSidechain ? 'subagent' : 'main',
69
- });
70
- }
71
- }
72
- return records;
73
- }
74
-
75
- function realpathOr(path) {
76
- try {
77
- return realpathSync(path);
78
- } catch {
79
- return path;
80
- }
81
- }
82
-
83
- /** GitHub Copilot CLI: ~/.copilot/session-state/<id>/events.jsonl of sessions in this repository. */
84
- export function copilotUsage(root, { home = process.env.COPILOT_HOME ?? join(homedir(), '.copilot') } = {}) {
85
- const dir = join(home, 'session-state');
86
- if (!existsSync(dir)) return [];
87
- const records = [];
88
- for (const id of readdirSync(dir)) {
89
- const lines = readLines(join(dir, id, 'events.jsonl'));
90
- const start = lines.map(parse).find((e) => e?.type === 'session.start');
91
- const context = start?.data?.context ?? {};
92
- const where = context.gitRoot ?? context.cwd;
93
- if (!where || !sameDir(where, root)) continue;
94
- for (const line of lines) {
95
- const event = parse(line);
96
- const usage = event?.type === 'session.usage_record' ? event.data?.usage : null;
97
- if (!usage || !event.timestamp) continue;
98
- records.push({
99
- at: Date.parse(event.timestamp),
100
- host: 'copilot',
101
- model: usage.model ?? 'unknown',
102
- input: usage.inputTokens ?? 0,
103
- cacheRead: usage.cacheReadTokens ?? 0,
104
- cacheWrite: usage.cacheWriteTokens ?? 0,
105
- output: usage.outputTokens ?? 0,
106
- agent: usage.initiator === 'sub-agent' ? 'subagent' : 'main',
107
- });
108
- }
109
- }
110
- return records;
111
- }
112
-
113
- /** Usage of all hosts in this repository between `from` and `to` (ms). */
114
- export function usageBetween(root, from, to, homes = {}) {
115
- return [...claudeUsage(root, { home: homes.claude }), ...copilotUsage(root, { home: homes.copilot })]
116
- .filter((r) => r.at >= from && r.at <= to)
117
- .sort((a, b) => a.at - b.at);
118
- }
package/src/validate.mjs DELETED
@@ -1,41 +0,0 @@
1
- import { resolveArea } from './config.mjs';
2
-
3
- /** Structural problems of the feature's documents, prefixed with the file name. */
4
- export function documentProblems(feature) {
5
- const problems = [];
6
- for (const name of ['spec', 'design', 'tasks']) {
7
- const doc = feature[name];
8
- if (doc) problems.push(...doc.parsed.problems.map((p) => `${name}.md: ${p}`));
9
- }
10
- return problems;
11
- }
12
-
13
- /**
14
- * Consistency between design, tasks, spec and configuration: areas exist and are
15
- * enabled, every task belongs to an approved area, every `covers` id is a spec AC, and
16
- * every AC is covered by at least one task.
17
- */
18
- export function designProblems(feature, config) {
19
- const problems = [];
20
- if (!feature.design || !feature.tasks || !feature.spec) return problems;
21
- const designAreas = new Set();
22
- for (const id of feature.design.parsed.areas) {
23
- const area = resolveArea(config, id);
24
- if (!area) problems.push(`design.md: area '${id}' is not an area of the enabled domains (${config.domains.join(', ')})`);
25
- else designAreas.add(area.id);
26
- }
27
- const acIds = new Set(feature.spec.parsed.acs.map((ac) => ac.id));
28
- const covered = new Set();
29
- for (const task of feature.tasks.parsed.tasks) {
30
- const area = resolveArea(config, task.area ?? '');
31
- if (!area || !designAreas.has(area.id)) problems.push(`tasks.md: ${task.id} area '${task.area}' is not one of the design's areas`);
32
- for (const id of task.covers) {
33
- if (!acIds.has(id)) problems.push(`tasks.md: ${task.id} covers '${id}', which is not an AC of the spec`);
34
- covered.add(id);
35
- }
36
- }
37
- for (const id of acIds) {
38
- if (!covered.has(id)) problems.push(`${id} is not covered by any task`);
39
- }
40
- return problems;
41
- }