@planu/cli 5.7.21 → 5.7.23
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/CHANGELOG.md +52 -0
- package/dist/.planu-build.json +1 -1
- package/dist/cli/commands/release.js +23 -10
- package/dist/cli/commands/spec.js +2 -32
- package/dist/config/registries/error-recovery.json +18 -18
- package/dist/config/registries/legacy-guidance.json +33 -1
- package/dist/config/server-instructions.js +16 -20
- package/dist/config/skill-templates/planu-release.md +3 -3
- package/dist/config/token-waste-autopilot.json +1 -1
- package/dist/core/shared/object.d.ts +3 -0
- package/dist/core/shared/object.js +12 -0
- package/dist/engine/config-loader.js +24 -32
- package/dist/engine/conventions-ttl.d.ts +2 -0
- package/dist/engine/conventions-ttl.js +1 -1
- package/dist/engine/detectors/library-detector-langs3b.d.ts +0 -5
- package/dist/engine/detectors/library-detector-langs3b.js +2 -16
- package/dist/engine/detectors/library-detector-langs5.d.ts +0 -1
- package/dist/engine/detectors/library-detector-langs5.js +2 -16
- package/dist/engine/detectors/otel-detector.js +4 -3
- package/dist/engine/detectors/otel-ecosystem-detectors.d.ts +0 -4
- package/dist/engine/detectors/otel-ecosystem-detectors.js +2 -14
- package/dist/engine/detectors/toml-dependencies.d.ts +2 -0
- package/dist/engine/detectors/toml-dependencies.js +16 -0
- package/dist/engine/drift-detection/release-status-drift.js +2 -17
- package/dist/engine/errors/registry-loader.js +3 -2
- package/dist/engine/evidence-gates/artifact-reader.d.ts +78 -0
- package/dist/engine/evidence-gates/artifact-reader.js +19 -7
- package/dist/engine/health/auto-fixer.js +2 -2
- package/dist/engine/minimality/policy-loader.js +1 -11
- package/dist/engine/model-tier-resolver.js +3 -11
- package/dist/engine/platform-detector/desktop.js +3 -13
- package/dist/engine/platform-detector/games.js +3 -13
- package/dist/engine/release-pipeline/release-spec-closer.d.ts +1 -0
- package/dist/engine/release-pipeline/release-spec-closer.js +1 -1
- package/dist/engine/safety/cross-process-lock.js +6 -21
- package/dist/engine/safety/lock-scavenger.d.ts +3 -1
- package/dist/engine/safety/lock-scavenger.js +3 -3
- package/dist/engine/score-to-grade.d.ts +2 -0
- package/dist/engine/score-to-grade.js +16 -0
- package/dist/engine/spec-grounding/contract.js +2 -1
- package/dist/engine/spec-grounding/grounding-entry-parser.d.ts +0 -1
- package/dist/engine/spec-grounding/grounding-entry-parser.js +1 -3
- package/dist/engine/telemetry/health-checker.js +2 -20
- package/dist/engine/telemetry/telemetry-client.d.ts +1 -0
- package/dist/engine/telemetry/telemetry-client.js +1 -1
- package/dist/engine/test-scaffold-generator/advanced-scaffold.js +1 -24
- package/dist/engine/token-optimizer/analytics.d.ts +1 -1
- package/dist/engine/token-optimizer/analytics.js +2 -22
- package/dist/engine/token-optimizer/policy-loader.js +1 -11
- package/dist/engine/validation-evidence-ledger.d.ts +1 -0
- package/dist/engine/validation-evidence-ledger.js +44 -3
- package/dist/engine/workers/handlers/code-map.js +4 -46
- package/dist/engine/workers/handlers/collect-files.d.ts +3 -0
- package/dist/engine/workers/handlers/collect-files.js +53 -0
- package/dist/engine/workers/handlers/documentation.js +4 -49
- package/dist/engine/workers/handlers/optimization.js +4 -46
- package/dist/engine/workers/handlers/security-audit.js +4 -45
- package/dist/hosts/codex/config-scaffold.js +1 -1
- package/dist/hosts/gemini/config-scaffold.js +1 -1
- package/dist/storage/spec-index.js +8 -3
- package/dist/storage/token-ledger-store.d.ts +1 -1
- package/dist/storage/token-ledger-store.js +2 -22
- package/dist/tools/audit.js +1 -15
- package/dist/tools/claude-settings-file.d.ts +3 -0
- package/dist/tools/claude-settings-file.js +19 -0
- package/dist/tools/create-spec/post-creation.d.ts +1 -1
- package/dist/tools/create-spec/post-creation.js +7 -49
- package/dist/tools/create-spec.js +1 -1
- package/dist/tools/facilitate.js +6 -6
- package/dist/tools/init-project/result-builder.js +4 -4
- package/dist/tools/reconcile-interactive-question-hooks.js +3 -18
- package/dist/tools/reconcile-session-safeguard-hook.js +3 -18
- package/dist/tools/reconcile-spec-sanctity-hook.js +4 -19
- package/dist/tools/safe-handler.js +1 -1
- package/dist/tools/status-handler.js +1 -1
- package/dist/tools/tool-registry/core-tools.js +3 -1
- package/dist/tools/update-status/evidence-payload.d.ts +180 -0
- package/dist/tools/update-status/evidence-payload.js +76 -0
- package/dist/tools/update-status/index.js +30 -0
- package/dist/tools/validate.js +2 -16
- package/dist/types/evidence-gates.d.ts +9 -0
- package/dist/types/lifecycle.d.ts +1 -10
- package/dist/types/spec/inputs.d.ts +2 -1
- package/dist/types/token-ledger.d.ts +1 -0
- package/dist/types/token-ledger.js +21 -1
- package/package.json +1 -1
- package/planu-plugin.json +14 -4
- package/src/i18n/messages/en.json +2 -2
- package/src/i18n/messages/es.json +2 -2
- package/src/i18n/messages/pt.json +2 -2
- package/dist/engine/detectors/cicd-detector.d.ts +0 -7
- package/dist/engine/detectors/cicd-detector.js +0 -170
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { isTelemetryEnabled } from './telemetry-store.js';
|
|
6
|
-
import { sendTelemetryEvent } from './telemetry-client.js';
|
|
6
|
+
import { sendTelemetryEvent, isValidTelemetryEndpoint } from './telemetry-client.js';
|
|
7
7
|
// eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
8
8
|
import { hashProjectPath, projectDataDir } from '../../storage/base-store.js';
|
|
9
9
|
import { networkFetch, withNetworkConsent } from '../network-policy.js';
|
|
@@ -47,24 +47,6 @@ function checkEndpointConfigured(endpoint) {
|
|
|
47
47
|
detail: 'Telemetry endpoint configured',
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function isLoopbackHost(hostname) {
|
|
51
|
-
return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]';
|
|
52
|
-
}
|
|
53
|
-
function isValidTelemetryEndpoint(endpoint) {
|
|
54
|
-
if (!endpoint || endpoint.trim() === '') {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
const parsed = new URL(endpoint.trim());
|
|
59
|
-
return (parsed.username === '' &&
|
|
60
|
-
parsed.password === '' &&
|
|
61
|
-
(parsed.protocol === 'https:' ||
|
|
62
|
-
(parsed.protocol === 'http:' && isLoopbackHost(parsed.hostname))));
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
50
|
function checkTokenConfigured(token) {
|
|
69
51
|
return token?.trim()
|
|
70
52
|
? { name: 'token-configured', status: 'ok', detail: 'Telemetry token configured' }
|
|
@@ -235,7 +217,7 @@ function sendTestDiagnosticEvent() {
|
|
|
235
217
|
function buildRecommendation(status) {
|
|
236
218
|
switch (status) {
|
|
237
219
|
case 'disabled':
|
|
238
|
-
return '
|
|
220
|
+
return 'Set PLANU_TELEMETRY=on and PLANU_TELEMETRY_CONSENT_VERSION=1 to enable usage tracking';
|
|
239
221
|
case 'misconfigured':
|
|
240
222
|
return 'Set valid PLANU_TELEMETRY_ENDPOINT and PLANU_TELEMETRY_TOKEN values.';
|
|
241
223
|
case 'degraded':
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TelemetryEvent, TelemetryEnvelopeEventName, TelemetryEnvelopeInput } from '../../types/index.js';
|
|
2
|
+
export declare function isValidTelemetryEndpoint(endpoint: string | undefined): endpoint is string;
|
|
2
3
|
/** Fire-and-forget; absence or staleness of opt-in prevents any network access. */
|
|
3
4
|
export declare function sendTelemetryEvent(event: TelemetryEvent): void;
|
|
4
5
|
/**
|
|
@@ -6,7 +6,7 @@ import { buildTelemetryEnvelope, TELEMETRY_SESSION_ID } from './event-envelope.j
|
|
|
6
6
|
function isLoopbackHost(hostname) {
|
|
7
7
|
return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]';
|
|
8
8
|
}
|
|
9
|
-
function isValidTelemetryEndpoint(endpoint) {
|
|
9
|
+
export function isValidTelemetryEndpoint(endpoint) {
|
|
10
10
|
if (!endpoint || endpoint.trim() === '') {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { technologyValue } from '../technology-registry.js';
|
|
2
|
-
import { toSnake } from './helpers.js';
|
|
2
|
+
import { toSnake, getFrameworkExt, getFrameworkRunCommand } from './helpers.js';
|
|
3
3
|
// === E2E test scaffold ===
|
|
4
4
|
/**
|
|
5
5
|
* Generate an E2E test scaffold (Playwright by default).
|
|
@@ -15,29 +15,6 @@ export function generateE2ETestScaffold(specTitle, framework) {
|
|
|
15
15
|
runCommand,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function getFrameworkExt(framework) {
|
|
19
|
-
const extMap = {
|
|
20
|
-
pytest: 'py',
|
|
21
|
-
junit: 'java',
|
|
22
|
-
xunit: 'cs',
|
|
23
|
-
rspec: 'rb',
|
|
24
|
-
'go-test': 'go',
|
|
25
|
-
};
|
|
26
|
-
return extMap[framework] ?? 'ts';
|
|
27
|
-
}
|
|
28
|
-
function getFrameworkRunCommand(framework) {
|
|
29
|
-
const commandMap = {
|
|
30
|
-
vitest: 'npx vitest run',
|
|
31
|
-
jest: 'npx jest',
|
|
32
|
-
mocha: 'npx mocha',
|
|
33
|
-
pytest: 'python -m pytest',
|
|
34
|
-
junit: 'mvn test',
|
|
35
|
-
xunit: 'dotnet test',
|
|
36
|
-
rspec: 'bundle exec rspec',
|
|
37
|
-
'go-test': 'go test ./...',
|
|
38
|
-
};
|
|
39
|
-
return commandMap[framework];
|
|
40
|
-
}
|
|
41
18
|
function buildE2EContent(title) {
|
|
42
19
|
return [
|
|
43
20
|
"import { test, expect } from '@playwright/test';",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LedgerEntry, type LedgerAggregation, type BudgetConfig, type LedgerBudgetStatus, type DailyBreakdown, type TrendResult, type Anomaly, type TopConsumer, type OptimizationSavings } from '../../types/index.js';
|
|
2
2
|
export type { DailyBreakdown, TrendResult, Anomaly, TopConsumer, OptimizationSavings };
|
|
3
3
|
export declare function aggregateEntries(entries: LedgerEntry[]): LedgerAggregation;
|
|
4
4
|
export declare function computeDailyBreakdown(entries: LedgerEntry[]): DailyBreakdown[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Cost Analytics Engine (SPEC-182)
|
|
2
2
|
// Aggregations, trends, anomaly detection, and projections from token ledger data
|
|
3
|
+
import { emptyLedgerAggregation, } from '../../types/index.js';
|
|
3
4
|
// ---------------------------------------------------------------------------
|
|
4
5
|
// Constants
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
@@ -55,33 +56,12 @@ function computeEstimationAccuracy(estimatedCount, actualForEstimated, estimated
|
|
|
55
56
|
overEstimationPercent: ((estimatedSum - actualForEstimated) / actualForEstimated) * 100,
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
|
-
function buildEmptyAggregation() {
|
|
59
|
-
return {
|
|
60
|
-
totalTokens: 0,
|
|
61
|
-
totalInputTokens: 0,
|
|
62
|
-
totalOutputTokens: 0,
|
|
63
|
-
totalCostUsd: 0,
|
|
64
|
-
totalEstimatedCostUsd: 0,
|
|
65
|
-
entryCount: 0,
|
|
66
|
-
uniqueTools: 0,
|
|
67
|
-
uniqueModels: 0,
|
|
68
|
-
uniqueSessions: 0,
|
|
69
|
-
avgTokensPerCall: 0,
|
|
70
|
-
avgCostPerCall: 0,
|
|
71
|
-
tokensByTool: {},
|
|
72
|
-
costByTool: {},
|
|
73
|
-
tokensByModel: {},
|
|
74
|
-
costByModel: {},
|
|
75
|
-
estimationAccuracy: 100,
|
|
76
|
-
overEstimationPercent: 0,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
59
|
function incrementRecord(rec, key, val) {
|
|
80
60
|
return { ...rec, [key]: (rec[key] ?? 0) + val };
|
|
81
61
|
}
|
|
82
62
|
export function aggregateEntries(entries) {
|
|
83
63
|
if (entries.length === 0) {
|
|
84
|
-
return
|
|
64
|
+
return emptyLedgerAggregation();
|
|
85
65
|
}
|
|
86
66
|
const result = entries.reduce((a, e) => {
|
|
87
67
|
const hasEst = e.estimatedTokens !== undefined;
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { isRecord, mergeDeep } from '../../core/shared/object.js';
|
|
4
5
|
function configPath() {
|
|
5
6
|
return join(dirname(fileURLToPath(import.meta.url)), '../../config/token-waste-autopilot.json');
|
|
6
7
|
}
|
|
7
|
-
function isRecord(value) {
|
|
8
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
-
}
|
|
10
|
-
function mergeDeep(base, override) {
|
|
11
|
-
const result = { ...base };
|
|
12
|
-
for (const [key, value] of Object.entries(override)) {
|
|
13
|
-
const current = result[key];
|
|
14
|
-
result[key] = isRecord(current) && isRecord(value) ? mergeDeep(current, value) : value;
|
|
15
|
-
}
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
8
|
function assertStringArray(value, path) {
|
|
19
9
|
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
|
|
20
10
|
throw new Error(`Invalid token waste policy at ${path}: expected string[]`);
|
|
@@ -26,4 +26,5 @@ export declare function recordValidationOutcome(args: {
|
|
|
26
26
|
reason: string;
|
|
27
27
|
source?: string;
|
|
28
28
|
}): void;
|
|
29
|
+
export declare function readPassedValidationReceipt(projectId: string, key: string): ValidationEvidenceReceipt | null;
|
|
29
30
|
//# sourceMappingURL=validation-evidence-ledger.d.ts.map
|
|
@@ -258,7 +258,29 @@ function writeReceiptAtomically(projectId, receipt) {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function isValidationEvidenceIdentity(value) {
|
|
262
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
const identity = value;
|
|
266
|
+
const hexDigest = /^[a-f0-9]{64}$/;
|
|
267
|
+
return (identity.schemaVersion === VALIDATION_EVIDENCE_SCHEMA_VERSION &&
|
|
268
|
+
typeof identity.capability === 'string' &&
|
|
269
|
+
identity.capability.trim() !== '' &&
|
|
270
|
+
typeof identity.normalizedCommand === 'string' &&
|
|
271
|
+
identity.normalizedCommand.trim() !== '' &&
|
|
272
|
+
typeof identity.sourceTreeDigest === 'string' &&
|
|
273
|
+
hexDigest.test(identity.sourceTreeDigest) &&
|
|
274
|
+
typeof identity.lockDigest === 'string' &&
|
|
275
|
+
hexDigest.test(identity.lockDigest) &&
|
|
276
|
+
typeof identity.configDigest === 'string' &&
|
|
277
|
+
hexDigest.test(identity.configDigest) &&
|
|
278
|
+
typeof identity.toolchainDigest === 'string' &&
|
|
279
|
+
hexDigest.test(identity.toolchainDigest) &&
|
|
280
|
+
typeof identity.selectedScopeDigest === 'string' &&
|
|
281
|
+
hexDigest.test(identity.selectedScopeDigest));
|
|
282
|
+
}
|
|
283
|
+
function isWellFormedPassedReceipt(value, key) {
|
|
262
284
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
263
285
|
return false;
|
|
264
286
|
}
|
|
@@ -266,8 +288,7 @@ function isMatchingSuccessfulReceipt(value, key, identity) {
|
|
|
266
288
|
if (receipt.schemaVersion !== VALIDATION_EVIDENCE_SCHEMA_VERSION ||
|
|
267
289
|
receipt.key !== key ||
|
|
268
290
|
receipt.status !== 'passed' ||
|
|
269
|
-
!receipt.identity ||
|
|
270
|
-
digestJson(receipt.identity) !== digestJson(identity) ||
|
|
291
|
+
!isValidationEvidenceIdentity(receipt.identity) ||
|
|
271
292
|
typeof receipt.producer !== 'string' ||
|
|
272
293
|
receipt.producer.trim() === '' ||
|
|
273
294
|
typeof receipt.durationMs !== 'number' ||
|
|
@@ -285,6 +306,26 @@ function isMatchingSuccessfulReceipt(value, key, identity) {
|
|
|
285
306
|
}
|
|
286
307
|
return computeValidationEvidenceKey(receipt.identity) === key;
|
|
287
308
|
}
|
|
309
|
+
function isMatchingSuccessfulReceipt(value, key, identity) {
|
|
310
|
+
return (isWellFormedPassedReceipt(value, key) && digestJson(value.identity) === digestJson(identity));
|
|
311
|
+
}
|
|
312
|
+
export function readPassedValidationReceipt(projectId, key) {
|
|
313
|
+
try {
|
|
314
|
+
const path = validationReceiptPath(projectId, key);
|
|
315
|
+
const stat = lstatSync(path);
|
|
316
|
+
if (!stat.isFile() || stat.size <= 0 || stat.size > MAX_RECEIPT_BYTES) {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
|
|
320
|
+
if (!isWellFormedPassedReceipt(parsed, key)) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
return parsed;
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
288
329
|
function normalizeRelativePath(path) {
|
|
289
330
|
return path.trim().replaceAll('\\', '/').replace(/^\.\//, '');
|
|
290
331
|
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
// engine/workers/handlers/code-map.ts — Builds codebase structure map (SPEC-078 AC-08)
|
|
2
|
-
import { readFile
|
|
3
|
-
import {
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { extname, relative } from 'node:path';
|
|
4
|
+
import { collectFiles, DEFAULT_CODE_EXTS } from './collect-files.js';
|
|
4
5
|
// ---------------------------------------------------------------------------
|
|
5
6
|
// Constants
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
|
-
const IGNORE_DIRS = new Set([
|
|
8
|
-
'node_modules',
|
|
9
|
-
'.git',
|
|
10
|
-
'dist',
|
|
11
|
-
'build',
|
|
12
|
-
'__pycache__',
|
|
13
|
-
'target',
|
|
14
|
-
'.venv',
|
|
15
|
-
'vendor',
|
|
16
|
-
'coverage',
|
|
17
|
-
]);
|
|
18
|
-
const CODE_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java', '.kt']);
|
|
19
8
|
const ENTRY_POINT_NAMES = new Set([
|
|
20
9
|
'main',
|
|
21
10
|
'index',
|
|
@@ -35,37 +24,6 @@ const ENTRY_POINT_NAMES = new Set([
|
|
|
35
24
|
'lib.rs',
|
|
36
25
|
]);
|
|
37
26
|
// ---------------------------------------------------------------------------
|
|
38
|
-
// File collection
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
async function collectFiles(dir, files) {
|
|
41
|
-
let entries;
|
|
42
|
-
try {
|
|
43
|
-
entries = await readdir(dir);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
for (const entry of entries) {
|
|
49
|
-
if (IGNORE_DIRS.has(entry)) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const fullPath = join(dir, entry);
|
|
53
|
-
let st;
|
|
54
|
-
try {
|
|
55
|
-
st = await stat(fullPath);
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (st.isDirectory()) {
|
|
61
|
-
await collectFiles(fullPath, files);
|
|
62
|
-
}
|
|
63
|
-
else if (st.isFile() && CODE_EXTS.has(extname(fullPath))) {
|
|
64
|
-
files.push(fullPath);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// ---------------------------------------------------------------------------
|
|
69
27
|
// Export detection — pattern-table approach to keep complexity low
|
|
70
28
|
// ---------------------------------------------------------------------------
|
|
71
29
|
const TS_EXPORT_PATTERNS = [
|
|
@@ -159,7 +117,7 @@ export async function runCodeMap(projectDir, _changedFiles) {
|
|
|
159
117
|
const start = Date.now();
|
|
160
118
|
const findings = [];
|
|
161
119
|
const allFiles = [];
|
|
162
|
-
await collectFiles(projectDir, allFiles);
|
|
120
|
+
await collectFiles(projectDir, allFiles, DEFAULT_CODE_EXTS);
|
|
163
121
|
// Count files by extension
|
|
164
122
|
const extCounts = new Map();
|
|
165
123
|
const entryPoints = [];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
2
|
+
import { join, extname } from 'node:path';
|
|
3
|
+
const IGNORE_DIRS = new Set([
|
|
4
|
+
'node_modules',
|
|
5
|
+
'.git',
|
|
6
|
+
'dist',
|
|
7
|
+
'build',
|
|
8
|
+
'__pycache__',
|
|
9
|
+
'target',
|
|
10
|
+
'.venv',
|
|
11
|
+
'vendor',
|
|
12
|
+
'coverage',
|
|
13
|
+
]);
|
|
14
|
+
export const DEFAULT_CODE_EXTS = new Set([
|
|
15
|
+
'.ts',
|
|
16
|
+
'.tsx',
|
|
17
|
+
'.js',
|
|
18
|
+
'.jsx',
|
|
19
|
+
'.py',
|
|
20
|
+
'.go',
|
|
21
|
+
'.rs',
|
|
22
|
+
'.java',
|
|
23
|
+
'.kt',
|
|
24
|
+
]);
|
|
25
|
+
export async function collectFiles(dir, files, codeExts) {
|
|
26
|
+
let entries;
|
|
27
|
+
try {
|
|
28
|
+
entries = await readdir(dir);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
if (IGNORE_DIRS.has(entry)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const fullPath = join(dir, entry);
|
|
38
|
+
let st;
|
|
39
|
+
try {
|
|
40
|
+
st = await stat(fullPath);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (st.isDirectory()) {
|
|
46
|
+
await collectFiles(fullPath, files, codeExts);
|
|
47
|
+
}
|
|
48
|
+
else if (st.isFile() && codeExts.has(extname(fullPath))) {
|
|
49
|
+
files.push(fullPath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=collect-files.js.map
|
|
@@ -1,52 +1,7 @@
|
|
|
1
1
|
// engine/workers/handlers/documentation.ts — Finds undocumented exports (SPEC-078 AC-09)
|
|
2
|
-
import { readFile
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
// Constants
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
const IGNORE_DIRS = new Set([
|
|
8
|
-
'node_modules',
|
|
9
|
-
'.git',
|
|
10
|
-
'dist',
|
|
11
|
-
'build',
|
|
12
|
-
'__pycache__',
|
|
13
|
-
'target',
|
|
14
|
-
'.venv',
|
|
15
|
-
'vendor',
|
|
16
|
-
'coverage',
|
|
17
|
-
]);
|
|
18
|
-
const CODE_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java', '.kt']);
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// File collection
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
async function collectFiles(dir, files) {
|
|
23
|
-
let entries;
|
|
24
|
-
try {
|
|
25
|
-
entries = await readdir(dir);
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
for (const entry of entries) {
|
|
31
|
-
if (IGNORE_DIRS.has(entry)) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const fullPath = join(dir, entry);
|
|
35
|
-
let st;
|
|
36
|
-
try {
|
|
37
|
-
st = await stat(fullPath);
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (st.isDirectory()) {
|
|
43
|
-
await collectFiles(fullPath, files);
|
|
44
|
-
}
|
|
45
|
-
else if (st.isFile() && CODE_EXTS.has(extname(fullPath))) {
|
|
46
|
-
files.push(fullPath);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { extname, relative } from 'node:path';
|
|
4
|
+
import { collectFiles, DEFAULT_CODE_EXTS } from './collect-files.js';
|
|
50
5
|
// ---------------------------------------------------------------------------
|
|
51
6
|
// Documentation checks per language
|
|
52
7
|
// ---------------------------------------------------------------------------
|
|
@@ -143,7 +98,7 @@ export async function runDocumentation(projectDir, _changedFiles) {
|
|
|
143
98
|
const start = Date.now();
|
|
144
99
|
const findings = [];
|
|
145
100
|
const allFiles = [];
|
|
146
|
-
await collectFiles(projectDir, allFiles);
|
|
101
|
+
await collectFiles(projectDir, allFiles, DEFAULT_CODE_EXTS);
|
|
147
102
|
let totalExports = 0;
|
|
148
103
|
let undocumentedExports = 0;
|
|
149
104
|
for (const file of allFiles) {
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
// engine/workers/handlers/optimization.ts — Detects perf anti-patterns (SPEC-078 AC-07)
|
|
2
|
-
import { readFile
|
|
3
|
-
import {
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { extname, relative } from 'node:path';
|
|
4
|
+
import { collectFiles, DEFAULT_CODE_EXTS } from './collect-files.js';
|
|
4
5
|
// ---------------------------------------------------------------------------
|
|
5
6
|
// Config
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
const MAX_FILE_LINES = 400;
|
|
8
|
-
const IGNORE_DIRS = new Set([
|
|
9
|
-
'node_modules',
|
|
10
|
-
'.git',
|
|
11
|
-
'dist',
|
|
12
|
-
'build',
|
|
13
|
-
'__pycache__',
|
|
14
|
-
'target',
|
|
15
|
-
'.venv',
|
|
16
|
-
'vendor',
|
|
17
|
-
'coverage',
|
|
18
|
-
]);
|
|
19
|
-
const CODE_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java', '.kt']);
|
|
20
9
|
// ---------------------------------------------------------------------------
|
|
21
10
|
// Complexity keywords per language
|
|
22
11
|
// ---------------------------------------------------------------------------
|
|
@@ -32,37 +21,6 @@ const COMPLEXITY_KEYWORDS = {
|
|
|
32
21
|
'.kt': [/\bif\b/, /\belse\b/, /\bfor\b/, /\bwhile\b/, /\bwhen\b/, /\bcatch\b/],
|
|
33
22
|
};
|
|
34
23
|
// ---------------------------------------------------------------------------
|
|
35
|
-
// File collection
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
async function collectFiles(dir, files) {
|
|
38
|
-
let entries;
|
|
39
|
-
try {
|
|
40
|
-
entries = await readdir(dir);
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
for (const entry of entries) {
|
|
46
|
-
if (IGNORE_DIRS.has(entry)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const fullPath = join(dir, entry);
|
|
50
|
-
let st;
|
|
51
|
-
try {
|
|
52
|
-
st = await stat(fullPath);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (st.isDirectory()) {
|
|
58
|
-
await collectFiles(fullPath, files);
|
|
59
|
-
}
|
|
60
|
-
else if (st.isFile() && CODE_EXTS.has(extname(fullPath))) {
|
|
61
|
-
files.push(fullPath);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// ---------------------------------------------------------------------------
|
|
66
24
|
// Analysis helpers
|
|
67
25
|
// ---------------------------------------------------------------------------
|
|
68
26
|
function countComplexity(lines, ext) {
|
|
@@ -109,7 +67,7 @@ export async function runOptimization(projectDir, _changedFiles) {
|
|
|
109
67
|
const start = Date.now();
|
|
110
68
|
const findings = [];
|
|
111
69
|
const allFiles = [];
|
|
112
|
-
await collectFiles(projectDir, allFiles);
|
|
70
|
+
await collectFiles(projectDir, allFiles, DEFAULT_CODE_EXTS);
|
|
113
71
|
// Track imports for circular dependency detection
|
|
114
72
|
const importGraph = new Map();
|
|
115
73
|
for (const file of allFiles) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// engine/workers/handlers/security-audit.ts — Detects security vulnerabilities (SPEC-078 AC-06)
|
|
2
|
-
import { readFile
|
|
3
|
-
import {
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { extname, basename, relative } from 'node:path';
|
|
4
|
+
import { collectFiles } from './collect-files.js';
|
|
4
5
|
const PATTERNS = [
|
|
5
6
|
// Hardcoded secrets
|
|
6
7
|
{
|
|
@@ -97,17 +98,6 @@ const PATTERNS = [
|
|
|
97
98
|
// ---------------------------------------------------------------------------
|
|
98
99
|
// Ignore patterns
|
|
99
100
|
// ---------------------------------------------------------------------------
|
|
100
|
-
const IGNORE_DIRS = new Set([
|
|
101
|
-
'node_modules',
|
|
102
|
-
'.git',
|
|
103
|
-
'dist',
|
|
104
|
-
'build',
|
|
105
|
-
'__pycache__',
|
|
106
|
-
'target',
|
|
107
|
-
'.venv',
|
|
108
|
-
'vendor',
|
|
109
|
-
'coverage',
|
|
110
|
-
]);
|
|
111
101
|
const SKIP_FILES = new Set(['.env.example', '.env.template', '.env.sample']);
|
|
112
102
|
const CODE_EXTS = new Set([
|
|
113
103
|
'.ts',
|
|
@@ -125,37 +115,6 @@ const CODE_EXTS = new Set([
|
|
|
125
115
|
'.toml',
|
|
126
116
|
'.cfg',
|
|
127
117
|
]);
|
|
128
|
-
// ---------------------------------------------------------------------------
|
|
129
|
-
// File scanning
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
async function collectFiles(dir, files) {
|
|
132
|
-
let entries;
|
|
133
|
-
try {
|
|
134
|
-
entries = await readdir(dir);
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
for (const entry of entries) {
|
|
140
|
-
if (IGNORE_DIRS.has(entry)) {
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const fullPath = join(dir, entry);
|
|
144
|
-
let st;
|
|
145
|
-
try {
|
|
146
|
-
st = await stat(fullPath);
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
if (st.isDirectory()) {
|
|
152
|
-
await collectFiles(fullPath, files);
|
|
153
|
-
}
|
|
154
|
-
else if (st.isFile() && CODE_EXTS.has(extname(fullPath))) {
|
|
155
|
-
files.push(fullPath);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
118
|
function isTestOrExample(filePath) {
|
|
160
119
|
const base = basename(filePath);
|
|
161
120
|
return (SKIP_FILES.has(base) ||
|
|
@@ -175,7 +134,7 @@ export async function runSecurityAudit(projectDir, _changedFiles) {
|
|
|
175
134
|
const start = Date.now();
|
|
176
135
|
const findings = [];
|
|
177
136
|
const allFiles = [];
|
|
178
|
-
await collectFiles(projectDir, allFiles);
|
|
137
|
+
await collectFiles(projectDir, allFiles, CODE_EXTS);
|
|
179
138
|
const filesToScan = allFiles.filter((f) => !isTestOrExample(f));
|
|
180
139
|
for (const file of filesToScan) {
|
|
181
140
|
let content;
|
|
@@ -34,7 +34,7 @@ startup_timeout_sec = 120
|
|
|
34
34
|
spec_path = "planu/specs"
|
|
35
35
|
|
|
36
36
|
[access]
|
|
37
|
-
# Role required to invoke destructive Planu tools (
|
|
37
|
+
# Role required to invoke destructive Planu tools (update_status).
|
|
38
38
|
# Valid values: owner, admin, member, viewer
|
|
39
39
|
min_role_for_mutations = "member"
|
|
40
40
|
`;
|
|
@@ -84,7 +84,7 @@ function buildPlanuMultimodalSkillMd() {
|
|
|
84
84
|
'1. Attach the image/PDF/Figma export to your message',
|
|
85
85
|
'2. Say "create a spec from this design"',
|
|
86
86
|
'3. Planu automatically chains:',
|
|
87
|
-
' -
|
|
87
|
+
' - component hints are extracted from the frames automatically',
|
|
88
88
|
' - Figma token extraction (if tokens file detected)',
|
|
89
89
|
' - `create_spec` — creates the spec with visual context',
|
|
90
90
|
'',
|
|
@@ -98,11 +98,16 @@ async function parseSpecRecord(projectPath, specMdPath) {
|
|
|
98
98
|
export async function loadSpecIndex(projectPath) {
|
|
99
99
|
const specFiles = await glob(join(projectPath, 'planu', 'specs', '*', 'spec.md'));
|
|
100
100
|
const parsed = await Promise.all(specFiles.map((specMdPath) => parseSpecRecord(projectPath, specMdPath)));
|
|
101
|
+
const records = parsed.filter((record) => record !== null);
|
|
102
|
+
records.sort((left, right) => (left.specPath < right.specPath ? -1 : 1));
|
|
101
103
|
const specs = {};
|
|
102
|
-
for (const record of
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
for (const record of records) {
|
|
105
|
+
const existing = specs[record.id];
|
|
106
|
+
if (existing) {
|
|
107
|
+
reportClassifiedDegradation('SPEC_INDEX_DUPLICATE_ID', new Error(`${record.id}: ${record.specPath} shadowed by ${existing.specPath}`));
|
|
108
|
+
continue;
|
|
105
109
|
}
|
|
110
|
+
specs[record.id] = record;
|
|
106
111
|
}
|
|
107
112
|
const index = { generatedAt: new Date().toISOString(), specs };
|
|
108
113
|
// A read-only checkout (or a concurrent writer) must not turn a successful
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LedgerEntry, type LedgerFilter, type LedgerAggregation, type MonthlyLedger } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Append a new entry to the current month's ledger file.
|
|
4
4
|
*/
|