peaks-cli 1.4.2 → 2.0.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.
- package/.claude-plugin/marketplace.json +51 -0
- package/CHANGELOG.md +238 -0
- package/README-en.md +226 -0
- package/README.md +152 -122
- package/dist/src/cli/commands/agent-commands.d.ts +20 -0
- package/dist/src/cli/commands/agent-commands.js +48 -0
- package/dist/src/cli/commands/audit-commands.d.ts +18 -0
- package/dist/src/cli/commands/audit-commands.js +138 -0
- package/dist/src/cli/commands/classify-classify-commands.d.ts +19 -0
- package/dist/src/cli/commands/classify-classify-commands.js +151 -0
- package/dist/src/cli/commands/code-review-commands.d.ts +34 -0
- package/dist/src/cli/commands/code-review-commands.js +83 -0
- package/dist/src/cli/commands/config-commands.js +90 -0
- package/dist/src/cli/commands/context-commands.d.ts +21 -0
- package/dist/src/cli/commands/context-commands.js +167 -0
- package/dist/src/cli/commands/core-artifact-commands.js +60 -2
- package/dist/src/cli/commands/hook-handle.js +50 -0
- package/dist/src/cli/commands/loop-commands.d.ts +21 -0
- package/dist/src/cli/commands/loop-commands.js +128 -0
- package/dist/src/cli/commands/openspec-commands.js +37 -0
- package/dist/src/cli/commands/preferences-commands.d.ts +2 -0
- package/dist/src/cli/commands/preferences-commands.js +147 -0
- package/dist/src/cli/commands/skill-conformance-commands.d.ts +9 -0
- package/dist/src/cli/commands/skill-conformance-commands.js +39 -0
- package/dist/src/cli/commands/understand-commands.js +34 -0
- package/dist/src/cli/commands/upgrade-commands.d.ts +23 -0
- package/dist/src/cli/commands/upgrade-commands.js +57 -0
- package/dist/src/cli/commands/workflow-commands.js +70 -0
- package/dist/src/cli/commands/workspace-commands.js +86 -0
- package/dist/src/cli/program.js +30 -0
- package/dist/src/services/agent/ecc-agent-service.d.ts +47 -0
- package/dist/src/services/agent/ecc-agent-service.js +143 -0
- package/dist/src/services/artifacts/request-artifact-service.js +14 -0
- package/dist/src/services/audit/backing-detector.d.ts +24 -0
- package/dist/src/services/audit/backing-detector.js +59 -0
- package/dist/src/services/audit/classifier.d.ts +38 -0
- package/dist/src/services/audit/classifier.js +127 -0
- package/dist/src/services/audit/enforcers/active-skill-resolver.d.ts +29 -0
- package/dist/src/services/audit/enforcers/active-skill-resolver.js +71 -0
- package/dist/src/services/audit/enforcers/design-draft-confirm.d.ts +25 -0
- package/dist/src/services/audit/enforcers/design-draft-confirm.js +54 -0
- package/dist/src/services/audit/enforcers/lint-audit-regression.d.ts +21 -0
- package/dist/src/services/audit/enforcers/lint-audit-regression.js +86 -0
- package/dist/src/services/audit/enforcers/lint-catalog-governance.d.ts +27 -0
- package/dist/src/services/audit/enforcers/lint-catalog-governance.js +38 -0
- package/dist/src/services/audit/enforcers/lint-cli-back.d.ts +16 -0
- package/dist/src/services/audit/enforcers/lint-cli-back.js +35 -0
- package/dist/src/services/audit/enforcers/lint-output-style.d.ts +11 -0
- package/dist/src/services/audit/enforcers/lint-output-style.js +94 -0
- package/dist/src/services/audit/enforcers/lint-reference-integrity.d.ts +6 -0
- package/dist/src/services/audit/enforcers/lint-reference-integrity.js +83 -0
- package/dist/src/services/audit/enforcers/lint-reference-shape.d.ts +30 -0
- package/dist/src/services/audit/enforcers/lint-reference-shape.js +272 -0
- package/dist/src/services/audit/enforcers/lint-style.d.ts +49 -0
- package/dist/src/services/audit/enforcers/lint-style.js +173 -0
- package/dist/src/services/audit/enforcers/lint-workflow-shape.d.ts +5 -0
- package/dist/src/services/audit/enforcers/lint-workflow-shape.js +141 -0
- package/dist/src/services/audit/enforcers/login-gate.d.ts +23 -0
- package/dist/src/services/audit/enforcers/login-gate.js +40 -0
- package/dist/src/services/audit/enforcers/mock-placement.d.ts +25 -0
- package/dist/src/services/audit/enforcers/mock-placement.js +48 -0
- package/dist/src/services/audit/enforcers/no-root-pollution.d.ts +21 -0
- package/dist/src/services/audit/enforcers/no-root-pollution.js +56 -0
- package/dist/src/services/audit/enforcers/pre-rd-scan.d.ts +22 -0
- package/dist/src/services/audit/enforcers/pre-rd-scan.js +23 -0
- package/dist/src/services/audit/enforcers/prototype-fidelity.d.ts +25 -0
- package/dist/src/services/audit/enforcers/prototype-fidelity.js +75 -0
- package/dist/src/services/audit/enforcers/resume-detection.d.ts +21 -0
- package/dist/src/services/audit/enforcers/resume-detection.js +52 -0
- package/dist/src/services/audit/enforcers/solo-code-ban.d.ts +23 -0
- package/dist/src/services/audit/enforcers/solo-code-ban.js +27 -0
- package/dist/src/services/audit/enforcers/sub-agent-sid.d.ts +25 -0
- package/dist/src/services/audit/enforcers/sub-agent-sid.js +63 -0
- package/dist/src/services/audit/enforcers/tech-doc-presence.d.ts +28 -0
- package/dist/src/services/audit/enforcers/tech-doc-presence.js +35 -0
- package/dist/src/services/audit/red-line-catalog-p2-a.d.ts +21 -0
- package/dist/src/services/audit/red-line-catalog-p2-a.js +233 -0
- package/dist/src/services/audit/red-line-catalog-p2-b.d.ts +19 -0
- package/dist/src/services/audit/red-line-catalog-p2-b.js +225 -0
- package/dist/src/services/audit/red-line-catalog.d.ts +51 -0
- package/dist/src/services/audit/red-line-catalog.js +210 -0
- package/dist/src/services/audit/red-lines-service.d.ts +23 -0
- package/dist/src/services/audit/red-lines-service.js +486 -0
- package/dist/src/services/audit/scanners/openspec-scanner.d.ts +15 -0
- package/dist/src/services/audit/scanners/openspec-scanner.js +55 -0
- package/dist/src/services/audit/scanners/rules-tree-scanner.d.ts +16 -0
- package/dist/src/services/audit/scanners/rules-tree-scanner.js +56 -0
- package/dist/src/services/audit/scanners/skills-tree-scanner.d.ts +17 -0
- package/dist/src/services/audit/scanners/skills-tree-scanner.js +46 -0
- package/dist/src/services/audit/static-service.d.ts +57 -0
- package/dist/src/services/audit/static-service.js +125 -0
- package/dist/src/services/audit/types.d.ts +69 -0
- package/dist/src/services/audit/types.js +13 -0
- package/dist/src/services/classify/classify-service.d.ts +42 -0
- package/dist/src/services/classify/classify-service.js +122 -0
- package/dist/src/services/classify/classify-types.d.ts +79 -0
- package/dist/src/services/classify/classify-types.js +90 -0
- package/dist/src/services/code-review/ocr-service.d.ts +129 -0
- package/dist/src/services/code-review/ocr-service.js +362 -0
- package/dist/src/services/config/config-migration.d.ts +32 -0
- package/dist/src/services/config/config-migration.js +92 -0
- package/dist/src/services/config/config-restore.d.ts +10 -0
- package/dist/src/services/config/config-restore.js +47 -0
- package/dist/src/services/config/config-rollback.d.ts +13 -0
- package/dist/src/services/config/config-rollback.js +26 -0
- package/dist/src/services/config/config-service.d.ts +35 -2
- package/dist/src/services/config/config-service.js +81 -0
- package/dist/src/services/config/config-types.d.ts +58 -0
- package/dist/src/services/config/config-types.js +6 -0
- package/dist/src/services/doctor/doctor-service.js +96 -0
- package/dist/src/services/ide/adapters/hermes-adapter.d.ts +21 -0
- package/dist/src/services/ide/adapters/hermes-adapter.js +51 -0
- package/dist/src/services/ide/adapters/openclaw-adapter.d.ts +14 -0
- package/dist/src/services/ide/adapters/openclaw-adapter.js +42 -0
- package/dist/src/services/ide/ide-registry.js +7 -0
- package/dist/src/services/ide/ide-types.d.ts +1 -1
- package/dist/src/services/openspec/openspec-propose-from-doctor-service.d.ts +31 -0
- package/dist/src/services/openspec/openspec-propose-from-doctor-service.js +95 -0
- package/dist/src/services/preferences/preferences-service.d.ts +6 -0
- package/dist/src/services/preferences/preferences-service.js +43 -0
- package/dist/src/services/preferences/preferences-types.d.ts +90 -0
- package/dist/src/services/preferences/preferences-types.js +38 -0
- package/dist/src/services/skills/skill-conformance-service.d.ts +40 -0
- package/dist/src/services/skills/skill-conformance-service.js +136 -0
- package/dist/src/services/skills/skill-runbook-service.js +44 -10
- package/dist/src/services/skills/sync-service.d.ts +43 -0
- package/dist/src/services/skills/sync-service.js +99 -0
- package/dist/src/services/slice/slice-check-service.js +166 -13
- package/dist/src/services/slice/slice-check-types.d.ts +1 -1
- package/dist/src/services/standards/migrate-claude-rules-service.d.ts +19 -0
- package/dist/src/services/standards/migrate-claude-rules-service.js +193 -0
- package/dist/src/services/understand/understand-scan-service.js +15 -2
- package/dist/src/services/understand/understand-types.d.ts +26 -0
- package/dist/src/services/upgrade/1x-detector-service.d.ts +7 -0
- package/dist/src/services/upgrade/1x-detector-service.js +94 -0
- package/dist/src/services/upgrade/gitignore-migrate-service.d.ts +56 -0
- package/dist/src/services/upgrade/gitignore-migrate-service.js +170 -0
- package/dist/src/services/upgrade/upgrade-service.d.ts +47 -0
- package/dist/src/services/upgrade/upgrade-service.js +381 -0
- package/dist/src/services/workspace/sid-naming-guard.d.ts +14 -0
- package/dist/src/services/workspace/sid-naming-guard.js +31 -0
- package/dist/src/services/workspace/workspace-archive-service.d.ts +19 -0
- package/dist/src/services/workspace/workspace-archive-service.js +32 -0
- package/dist/src/services/workspace/workspace-clean-service.d.ts +41 -0
- package/dist/src/services/workspace/workspace-clean-service.js +86 -0
- package/dist/src/services/workspace/workspace-state-service.d.ts +7 -0
- package/dist/src/services/workspace/workspace-state-service.js +43 -0
- package/dist/src/shared/change-id.js +4 -1
- package/dist/src/shared/version.d.ts +1 -1
- package/dist/src/shared/version.js +1 -1
- package/package.json +8 -2
- package/schemas/doctor-report.schema.json +1 -1
- package/scripts/install-skills.mjs +296 -12
- package/skills/peaks-doctor/SKILL.md +59 -0
- package/skills/peaks-doctor/references/doctor-check-catalog.md +31 -0
- package/skills/peaks-doctor/references/from-doctor-flow.md +64 -0
- package/skills/peaks-doctor/test_prompts.json +17 -0
- package/skills/peaks-ide/SKILL.md +2 -0
- package/skills/peaks-qa/SKILL.md +9 -7
- package/skills/peaks-qa/references/artifact-per-request.md +19 -5
- package/skills/peaks-qa/references/qa-perf-test-plan.md +6 -6
- package/skills/peaks-qa/references/qa-runbook.md +1 -1
- package/skills/peaks-rd/SKILL.md +25 -10
- package/skills/peaks-rd/references/ocr-integration.md +214 -0
- package/skills/peaks-rd/references/rd-fanout-contracts.md +70 -0
- package/skills/peaks-rd/references/rd-runbook.md +1 -1
- package/skills/peaks-solo/SKILL.md +10 -4
- package/skills/peaks-solo/references/step-0-55-1x-detection.md +82 -0
- package/skills/peaks-solo/references/workflow-gates-and-types.md +9 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 2.0 canonical ignore block. Mirrors the same paths
|
|
3
|
+
* peaks-cli's own .gitignore uses; kept in lockstep manually
|
|
4
|
+
* (the peaks-cli root .gitignore is the source of truth).
|
|
5
|
+
*
|
|
6
|
+
* Sentinel: every emitted line carries the marker comment so
|
|
7
|
+
* the migration can detect "already-migrated" and stay
|
|
8
|
+
* idempotent.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PEAKS_2_0_BLOCK_SENTINEL = "# peaks-cli 2.0 canonical ignore block \u2014 managed by `peaks upgrade --to 2.0`";
|
|
11
|
+
export declare const CANONICAL_2_0_PEAKS_BLOCK: string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns true when `line` is a wholesale ignore of the entire
|
|
14
|
+
* `.peaks/` tree (the 1.x pattern that breaks 2.0 tracking).
|
|
15
|
+
*
|
|
16
|
+
* Examples that match: `.peaks` `.peaks/` `/.peaks` `/.peaks/` ` .peaks/ `
|
|
17
|
+
* Examples that DON'T: `.peaks/_runtime/` `# .peaks/ comment` `.peaks_other`
|
|
18
|
+
*/
|
|
19
|
+
export declare function isStaleWholesalePeaksRule(line: string): boolean;
|
|
20
|
+
export interface MigrateGitignoreContentResult {
|
|
21
|
+
/** True if at least one stale wholesale .peaks rule was removed OR the canonical block was appended. */
|
|
22
|
+
readonly changed: boolean;
|
|
23
|
+
/** The exact lines that were removed (verbatim, with original whitespace). */
|
|
24
|
+
readonly removedRules: readonly string[];
|
|
25
|
+
/** The migrated content (always ends with a newline). */
|
|
26
|
+
readonly content: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pure function: takes the .gitignore content, returns the
|
|
30
|
+
* migrated content + diff summary. No I/O.
|
|
31
|
+
*/
|
|
32
|
+
export declare function migrateGitignoreContent(input: string): MigrateGitignoreContentResult;
|
|
33
|
+
export interface MigrateGitignoreFileInput {
|
|
34
|
+
readonly projectRoot: string;
|
|
35
|
+
readonly apply?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface MigrateGitignoreFileResult {
|
|
38
|
+
/** True if .gitignore is absent (nothing to migrate). */
|
|
39
|
+
readonly missing: boolean;
|
|
40
|
+
/** True if the migration would change the file. */
|
|
41
|
+
readonly changed: boolean;
|
|
42
|
+
/** True only if `apply: true` AND `changed: true`. */
|
|
43
|
+
readonly appliedWrite: boolean;
|
|
44
|
+
/** Absolute path to the timestamped backup file, or null. */
|
|
45
|
+
readonly backupPath: string | null;
|
|
46
|
+
/** Removed lines (verbatim). */
|
|
47
|
+
readonly removedRules: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* FS variant: reads .gitignore, runs migration, optionally
|
|
51
|
+
* writes the result + a timestamped backup of the original.
|
|
52
|
+
*
|
|
53
|
+
* Date.now() is used for the backup suffix; in test environments
|
|
54
|
+
* where determinism matters, the caller can stub Date via vi.
|
|
55
|
+
*/
|
|
56
|
+
export declare function migrateGitignoreFile(input: MigrateGitignoreFileInput): MigrateGitignoreFileResult;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .gitignore 1.x → 2.0 migration service.
|
|
3
|
+
*
|
|
4
|
+
* Real bug surfaced by ice-cola dogfood 2026-06-12:
|
|
5
|
+
* - 1.x consumer projects often have a wholesale `/.peaks/` (or
|
|
6
|
+
* `.peaks/` / `.peaks`) entry in their .gitignore — the 1.x
|
|
7
|
+
* install treated .peaks/ as the tool's ephemeral working
|
|
8
|
+
* directory.
|
|
9
|
+
* - In 2.0 the .peaks/ tree is split: most subdirectories
|
|
10
|
+
* remain ignored (_runtime, _sub_agents, audit, etc.) but
|
|
11
|
+
* several MUST be tracked: .peaks/standards/,
|
|
12
|
+
* .peaks/memory/*.md (durable LLM-authored memories),
|
|
13
|
+
* .peaks/PROJECT.md, and the user opt-in dotfiles.
|
|
14
|
+
* - A wholesale `.peaks/` ignore silently hides every 2.0
|
|
15
|
+
* tracked artifact, violating the "one-key completion" tenet
|
|
16
|
+
* because the user runs upgrade, sees 6/6 pass, then git
|
|
17
|
+
* status shows no new tracked files — the upgrade looks
|
|
18
|
+
* "done" but nothing landed in git.
|
|
19
|
+
*
|
|
20
|
+
* The service:
|
|
21
|
+
* 1. Reads the project's .gitignore (string in / string out;
|
|
22
|
+
* no I/O in the pure function).
|
|
23
|
+
* 2. Detects every line that is a wholesale-ignore of .peaks/
|
|
24
|
+
* (with or without leading slash, with or without trailing
|
|
25
|
+
* slash, ignoring surrounding whitespace).
|
|
26
|
+
* 3. Removes those lines and appends the canonical 2.0 block
|
|
27
|
+
* (granular subpaths) if not already present.
|
|
28
|
+
* 4. The FS variant `migrateGitignoreFile` adds backup +
|
|
29
|
+
* atomic write on top.
|
|
30
|
+
*
|
|
31
|
+
* Idempotent: re-running on a migrated .gitignore is a no-op.
|
|
32
|
+
*
|
|
33
|
+
* Spec reference: docs/superpowers/specs/2026-06-11-peaks-cli-l1-l2-l3-redesign.md §8.4
|
|
34
|
+
* (per-project state in .peaks/preferences.json, durable
|
|
35
|
+
* memories in .peaks/memory/*.md).
|
|
36
|
+
*/
|
|
37
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
38
|
+
import { join } from 'node:path';
|
|
39
|
+
/**
|
|
40
|
+
* The 2.0 canonical ignore block. Mirrors the same paths
|
|
41
|
+
* peaks-cli's own .gitignore uses; kept in lockstep manually
|
|
42
|
+
* (the peaks-cli root .gitignore is the source of truth).
|
|
43
|
+
*
|
|
44
|
+
* Sentinel: every emitted line carries the marker comment so
|
|
45
|
+
* the migration can detect "already-migrated" and stay
|
|
46
|
+
* idempotent.
|
|
47
|
+
*/
|
|
48
|
+
export const PEAKS_2_0_BLOCK_SENTINEL = '# peaks-cli 2.0 canonical ignore block — managed by `peaks upgrade --to 2.0`';
|
|
49
|
+
export const CANONICAL_2_0_PEAKS_BLOCK = [
|
|
50
|
+
PEAKS_2_0_BLOCK_SENTINEL,
|
|
51
|
+
'.peaks/_runtime/',
|
|
52
|
+
'.peaks/_dogfood/',
|
|
53
|
+
'.peaks/_sub_agents/',
|
|
54
|
+
'.peaks/audit/',
|
|
55
|
+
'.peaks/system/',
|
|
56
|
+
'.peaks/runtime/',
|
|
57
|
+
'.peaks/preferences.json',
|
|
58
|
+
'.peaks/memory/upgrade-2.0-*.md',
|
|
59
|
+
].join('\n');
|
|
60
|
+
/**
|
|
61
|
+
* Returns true when `line` is a wholesale ignore of the entire
|
|
62
|
+
* `.peaks/` tree (the 1.x pattern that breaks 2.0 tracking).
|
|
63
|
+
*
|
|
64
|
+
* Examples that match: `.peaks` `.peaks/` `/.peaks` `/.peaks/` ` .peaks/ `
|
|
65
|
+
* Examples that DON'T: `.peaks/_runtime/` `# .peaks/ comment` `.peaks_other`
|
|
66
|
+
*/
|
|
67
|
+
export function isStaleWholesalePeaksRule(line) {
|
|
68
|
+
const trimmed = line.trim();
|
|
69
|
+
if (trimmed.length === 0)
|
|
70
|
+
return false;
|
|
71
|
+
if (trimmed.startsWith('#'))
|
|
72
|
+
return false;
|
|
73
|
+
// Strip leading slash (relative-to-repo-root convention) and
|
|
74
|
+
// trailing slash (directory marker); both equivalent in
|
|
75
|
+
// .gitignore semantics for wholesale ignore.
|
|
76
|
+
const normalized = trimmed.replace(/^\//, '').replace(/\/$/, '');
|
|
77
|
+
return normalized === '.peaks';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Pure function: takes the .gitignore content, returns the
|
|
81
|
+
* migrated content + diff summary. No I/O.
|
|
82
|
+
*/
|
|
83
|
+
export function migrateGitignoreContent(input) {
|
|
84
|
+
const lines = input.split('\n');
|
|
85
|
+
const removed = [];
|
|
86
|
+
const kept = [];
|
|
87
|
+
for (const line of lines) {
|
|
88
|
+
if (isStaleWholesalePeaksRule(line)) {
|
|
89
|
+
removed.push(line.trim());
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
kept.push(line);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Already-migrated detection: if the canonical block is
|
|
96
|
+
// already present AND nothing was removed, this is a no-op.
|
|
97
|
+
const hasCanonicalBlock = input.includes(PEAKS_2_0_BLOCK_SENTINEL);
|
|
98
|
+
if (removed.length === 0 && hasCanonicalBlock) {
|
|
99
|
+
return { changed: false, removedRules: [], content: input };
|
|
100
|
+
}
|
|
101
|
+
// Already-migrated AND nothing stale: no-op, return original
|
|
102
|
+
// verbatim so byte-equality holds for idempotency.
|
|
103
|
+
if (removed.length === 0 && !hasCanonicalBlock) {
|
|
104
|
+
// Check whether there's anything peaks-related at all; if
|
|
105
|
+
// not, treat as no-op (the user explicitly chose not to
|
|
106
|
+
// ignore .peaks/ — respect that).
|
|
107
|
+
return { changed: false, removedRules: [], content: input };
|
|
108
|
+
}
|
|
109
|
+
// Removed at least one stale rule. Append canonical block
|
|
110
|
+
// if not already present.
|
|
111
|
+
let body = kept.join('\n');
|
|
112
|
+
if (!body.endsWith('\n') && body.length > 0) {
|
|
113
|
+
body += '\n';
|
|
114
|
+
}
|
|
115
|
+
if (!hasCanonicalBlock) {
|
|
116
|
+
body += CANONICAL_2_0_PEAKS_BLOCK + '\n';
|
|
117
|
+
}
|
|
118
|
+
return { changed: true, removedRules: removed, content: body };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* FS variant: reads .gitignore, runs migration, optionally
|
|
122
|
+
* writes the result + a timestamped backup of the original.
|
|
123
|
+
*
|
|
124
|
+
* Date.now() is used for the backup suffix; in test environments
|
|
125
|
+
* where determinism matters, the caller can stub Date via vi.
|
|
126
|
+
*/
|
|
127
|
+
export function migrateGitignoreFile(input) {
|
|
128
|
+
const path = join(input.projectRoot, '.gitignore');
|
|
129
|
+
if (!existsSync(path)) {
|
|
130
|
+
return {
|
|
131
|
+
missing: true,
|
|
132
|
+
changed: false,
|
|
133
|
+
appliedWrite: false,
|
|
134
|
+
backupPath: null,
|
|
135
|
+
removedRules: [],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const before = readFileSync(path, 'utf8');
|
|
139
|
+
const result = migrateGitignoreContent(before);
|
|
140
|
+
if (!result.changed) {
|
|
141
|
+
return {
|
|
142
|
+
missing: false,
|
|
143
|
+
changed: false,
|
|
144
|
+
appliedWrite: false,
|
|
145
|
+
backupPath: null,
|
|
146
|
+
removedRules: [],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (input.apply !== true) {
|
|
150
|
+
return {
|
|
151
|
+
missing: false,
|
|
152
|
+
changed: true,
|
|
153
|
+
appliedWrite: false,
|
|
154
|
+
backupPath: null,
|
|
155
|
+
removedRules: result.removedRules,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// Apply: write backup first, then atomic-overwrite the original.
|
|
159
|
+
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
|
160
|
+
const backupPath = join(input.projectRoot, `.gitignore.peaks-2.0-backup-${ts}`);
|
|
161
|
+
writeFileSync(backupPath, before, 'utf8');
|
|
162
|
+
writeFileSync(path, result.content, 'utf8');
|
|
163
|
+
return {
|
|
164
|
+
missing: false,
|
|
165
|
+
changed: true,
|
|
166
|
+
appliedWrite: true,
|
|
167
|
+
backupPath,
|
|
168
|
+
removedRules: result.removedRules,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface UpgradeInput {
|
|
2
|
+
readonly projectRoot: string;
|
|
3
|
+
/**
|
|
4
|
+
* When true, the umbrella is being invoked from the
|
|
5
|
+
* `npm i -g peaks-cli` postinstall. Suppresses the
|
|
6
|
+
* interactive prompts and accepts soft-fail on any
|
|
7
|
+
* sub-step.
|
|
8
|
+
*/
|
|
9
|
+
readonly auto?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* When omitted, the sub-commands are inferred from PATH
|
|
12
|
+
* (the postinstall puts the binary there). The umbrella
|
|
13
|
+
* never blocks on a missing binary — it surfaces the
|
|
14
|
+
* install hint in `nextActions` instead.
|
|
15
|
+
*/
|
|
16
|
+
readonly peaksBin?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SubStepResult {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly status: 'pass' | 'fail' | 'skipped';
|
|
21
|
+
readonly exitCode: number | null;
|
|
22
|
+
readonly stdout: string;
|
|
23
|
+
readonly stderr: string;
|
|
24
|
+
readonly durationMs: number;
|
|
25
|
+
}
|
|
26
|
+
export interface UpgradeResult {
|
|
27
|
+
readonly applied: boolean;
|
|
28
|
+
readonly fromVersion: string | null;
|
|
29
|
+
readonly toVersion: string;
|
|
30
|
+
readonly projectRoot: string;
|
|
31
|
+
readonly steps: readonly SubStepResult[];
|
|
32
|
+
readonly passedCount: number;
|
|
33
|
+
readonly failedCount: number;
|
|
34
|
+
readonly skippedCount: number;
|
|
35
|
+
readonly auditBefore: {
|
|
36
|
+
totalRedLines: number;
|
|
37
|
+
cliBacked: number;
|
|
38
|
+
} | null;
|
|
39
|
+
readonly auditAfter: {
|
|
40
|
+
totalRedLines: number;
|
|
41
|
+
cliBacked: number;
|
|
42
|
+
} | null;
|
|
43
|
+
readonly upgradeRecordPath: string | null;
|
|
44
|
+
readonly nextActions: readonly string[];
|
|
45
|
+
readonly warnings: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
export declare function runUpgrade(input: UpgradeInput): UpgradeResult;
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* peaks upgrade --to 2.0 — umbrella service for the 1.x → 2.0
|
|
3
|
+
* migration.
|
|
4
|
+
*
|
|
5
|
+
* Per the "one-key completion" + "minimal-user-operation" tenets
|
|
6
|
+
* (2026-06-11), the typical upgrade path is:
|
|
7
|
+
*
|
|
8
|
+
* $ npm i -g peaks-cli@2.0 # postinstall does everything
|
|
9
|
+
*
|
|
10
|
+
* OR (postinstall skipped / manual fallback):
|
|
11
|
+
*
|
|
12
|
+
* $ peaks upgrade --to 2.0
|
|
13
|
+
*
|
|
14
|
+
* The umbrella orchestrates 7 sub-commands:
|
|
15
|
+
* 1. config migrate (already ships as `peaks config migrate`)
|
|
16
|
+
* 2. standards migrate (`peaks standards migrate --from-claude-rules`)
|
|
17
|
+
* 3. memory extract (already ships as `peaks memory extract`)
|
|
18
|
+
* 4. hooks install (already ships as `peaks hooks install`)
|
|
19
|
+
* 5. skill sync (this session, `peaks skill sync --all`)
|
|
20
|
+
* 6. audit verify (already ships as `peaks audit red-lines`)
|
|
21
|
+
* 7. write upgrade record (in-process, .peaks/memory/upgrade-2.0-*.md)
|
|
22
|
+
*
|
|
23
|
+
* Each sub-step is a thin shell-out to the existing CLI; the
|
|
24
|
+
* umbrella's only in-process work is the audit and the upgrade
|
|
25
|
+
* record write. Sub-step failures are SOFT (logged + nextActions
|
|
26
|
+
* populated) so the umbrella never blocks a successful partial
|
|
27
|
+
* upgrade.
|
|
28
|
+
*/
|
|
29
|
+
import { spawnSync } from 'node:child_process';
|
|
30
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
31
|
+
import { join, dirname, relative, resolve } from 'node:path';
|
|
32
|
+
import { fileURLToPath } from 'node:url';
|
|
33
|
+
import { runRedLinesAudit } from '../audit/red-lines-service.js';
|
|
34
|
+
import { savePreferences } from '../preferences/preferences-service.js';
|
|
35
|
+
import { migrateGitignoreFile } from './gitignore-migrate-service.js';
|
|
36
|
+
const STEPS = [
|
|
37
|
+
{ name: 'config-migrate', args: (p) => ['config', 'migrate', '--project', p, '--apply', '--json'] },
|
|
38
|
+
{ name: 'standards-migrate', args: (p) => ['standards', 'migrate', '--from-claude-rules', '--project', p, '--apply', '--json'] },
|
|
39
|
+
// memory extract is special: its --artifact takes literal file
|
|
40
|
+
// paths (memory-service rejects glob patterns via realpathSync).
|
|
41
|
+
// The umbrella expands the three documented patterns
|
|
42
|
+
// (skills/**/SKILL.md, CLAUDE.md, .claude/rules/**/*.md) on disk
|
|
43
|
+
// and passes the resulting literal list. See runUpgrade's special
|
|
44
|
+
// case below for the args resolution; the args function here is
|
|
45
|
+
// a placeholder so the STEPS table stays uniform.
|
|
46
|
+
{ name: 'memory-extract', args: (p) => ['memory', 'extract', '--project', p, '--json'] },
|
|
47
|
+
{ name: 'hooks-install', args: (p) => ['hooks', 'install', '--project', p, '--json'] },
|
|
48
|
+
{ name: 'skill-sync', args: (p) => ['skill', 'sync', '--all', '--project', p, '--json'] },
|
|
49
|
+
{ name: 'audit-verify', args: (p) => ['audit', 'red-lines', '--project', p, '--json'] },
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Walk `<root>` recursively and collect every file whose basename
|
|
53
|
+
* matches `predicate`. Returns absolute paths.
|
|
54
|
+
*
|
|
55
|
+
* Mirrors `readMarkdownFilesRecursive` in
|
|
56
|
+
* src/services/standards/migrate-claude-rules-service.ts so the
|
|
57
|
+
* umbrella does not pull a new glob dependency (Node 20+ engine
|
|
58
|
+
* constraint — `fs.globSync` requires Node 22+).
|
|
59
|
+
*/
|
|
60
|
+
function collectFilesRecursive(root, predicate) {
|
|
61
|
+
if (!existsSync(root))
|
|
62
|
+
return [];
|
|
63
|
+
const stat = statSync(root);
|
|
64
|
+
if (stat.isFile()) {
|
|
65
|
+
return predicate(root.split(/[\\/]/).pop() ?? '') ? [root] : [];
|
|
66
|
+
}
|
|
67
|
+
if (!stat.isDirectory())
|
|
68
|
+
return [];
|
|
69
|
+
const out = [];
|
|
70
|
+
for (const entry of readdirSync(root)) {
|
|
71
|
+
const child = join(root, entry);
|
|
72
|
+
let childStat;
|
|
73
|
+
try {
|
|
74
|
+
childStat = statSync(child);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (childStat.isFile()) {
|
|
80
|
+
if (predicate(entry))
|
|
81
|
+
out.push(child);
|
|
82
|
+
}
|
|
83
|
+
else if (childStat.isDirectory()) {
|
|
84
|
+
out.push(...collectFilesRecursive(child, predicate));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve the three documented memory-extract artifact patterns
|
|
91
|
+
* against a real project tree. Returns project-relative paths
|
|
92
|
+
* (memory-service joins them with --project root) so the
|
|
93
|
+
* realpathSync inside memory-service's assertInsideProject
|
|
94
|
+
* succeeds.
|
|
95
|
+
*
|
|
96
|
+
* Patterns:
|
|
97
|
+
* - skills/[asterisk][asterisk]/SKILL.md (project-root convention)
|
|
98
|
+
* - .claude/skills/[asterisk][asterisk]/SKILL.md (Claude-Code consumer convention; ice-cola)
|
|
99
|
+
* - CLAUDE.md
|
|
100
|
+
* - .claude/rules/[asterisk][asterisk]/[asterisk].md
|
|
101
|
+
*
|
|
102
|
+
* Returns an empty list when none of the roots exist. The
|
|
103
|
+
* caller marks the step skipped in that case.
|
|
104
|
+
*/
|
|
105
|
+
function expandMemoryArtifacts(projectRoot) {
|
|
106
|
+
const out = [];
|
|
107
|
+
// skills/**/SKILL.md (peaks-cli repo convention)
|
|
108
|
+
const skillFiles = collectFilesRecursive(join(projectRoot, 'skills'), (name) => name === 'SKILL.md');
|
|
109
|
+
for (const abs of skillFiles) {
|
|
110
|
+
out.push(relative(projectRoot, abs));
|
|
111
|
+
}
|
|
112
|
+
// .claude/skills/**/SKILL.md (Claude-Code consumer convention;
|
|
113
|
+
// surfaced by ice-cola dogfood 2026-06-12 — the 1.x install
|
|
114
|
+
// landed skills under .claude/skills/, not <root>/skills/)
|
|
115
|
+
const claudeSkillFiles = collectFilesRecursive(join(projectRoot, '.claude', 'skills'), (name) => name === 'SKILL.md');
|
|
116
|
+
for (const abs of claudeSkillFiles) {
|
|
117
|
+
out.push(relative(projectRoot, abs));
|
|
118
|
+
}
|
|
119
|
+
// CLAUDE.md (literal)
|
|
120
|
+
const claudeMd = join(projectRoot, 'CLAUDE.md');
|
|
121
|
+
if (existsSync(claudeMd) && statSync(claudeMd).isFile()) {
|
|
122
|
+
out.push('CLAUDE.md');
|
|
123
|
+
}
|
|
124
|
+
// .claude/rules/**/*.md
|
|
125
|
+
const claudeRules = collectFilesRecursive(join(projectRoot, '.claude', 'rules'), (name) => name.endsWith('.md'));
|
|
126
|
+
for (const abs of claudeRules) {
|
|
127
|
+
out.push(relative(projectRoot, abs));
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
function read1xVersion(cwd) {
|
|
132
|
+
const home = process.env['HOME'] ?? process.env['USERPROFILE'] ?? '';
|
|
133
|
+
if (home.length === 0)
|
|
134
|
+
return null;
|
|
135
|
+
const global = join(home, '.peaks', 'config.json');
|
|
136
|
+
if (!existsSync(global))
|
|
137
|
+
return null;
|
|
138
|
+
try {
|
|
139
|
+
const raw = JSON.parse(readFileSync(global, 'utf8'));
|
|
140
|
+
if (typeof raw.version === 'string')
|
|
141
|
+
return raw.version;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// ignore
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
function runStep(peaksBin, name, args, timeoutMs = 60_000) {
|
|
149
|
+
const start = Date.now();
|
|
150
|
+
// The global `peaks` shim is a `/bin/sh` symlink script (the
|
|
151
|
+
// npm install postinstall creates `peaks` → `peaks.sh` on
|
|
152
|
+
// Windows). cmd.exe (the default Windows shell) cannot run
|
|
153
|
+
// `.sh` scripts directly, so the shim fails with "unknown
|
|
154
|
+
// command 'migrate'" etc. The fix: prefer the local node
|
|
155
|
+
// binary + the peaks.js script path. The umbrella resolves
|
|
156
|
+
// the script path at startup; only falls back to `peaks` if
|
|
157
|
+
// no script path is available (Unix-only).
|
|
158
|
+
let command;
|
|
159
|
+
let spawnArgs;
|
|
160
|
+
if (peaksBin.includes('\\') || peaksBin.includes('/')) {
|
|
161
|
+
// peaksBin is a real path (e.g. /c/.../bin/peaks.js);
|
|
162
|
+
// invoke directly via node.
|
|
163
|
+
command = process.execPath;
|
|
164
|
+
spawnArgs = [peaksBin, ...args];
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// peaksBin is just "peaks" — best-effort shell exec.
|
|
168
|
+
command = peaksBin;
|
|
169
|
+
spawnArgs = args;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const result = spawnSync(command, spawnArgs, {
|
|
173
|
+
encoding: 'utf8',
|
|
174
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
175
|
+
timeout: timeoutMs,
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
name,
|
|
179
|
+
status: result.status === 0 ? 'pass' : 'fail',
|
|
180
|
+
exitCode: result.status,
|
|
181
|
+
stdout: result.stdout ?? '',
|
|
182
|
+
stderr: result.stderr ?? '',
|
|
183
|
+
durationMs: Date.now() - start,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
188
|
+
return {
|
|
189
|
+
name,
|
|
190
|
+
status: 'fail',
|
|
191
|
+
exitCode: null,
|
|
192
|
+
stdout: '',
|
|
193
|
+
stderr: message,
|
|
194
|
+
durationMs: Date.now() - start,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function writeUpgradeRecord(projectRoot, result) {
|
|
199
|
+
try {
|
|
200
|
+
const memoryDir = join(projectRoot, '.peaks', 'memory');
|
|
201
|
+
mkdirSync(memoryDir, { recursive: true });
|
|
202
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
203
|
+
const file = join(memoryDir, `upgrade-2.0-${date}.md`);
|
|
204
|
+
const lines = [];
|
|
205
|
+
lines.push(`# Upgrade to peaks-cli 2.0 — ${date}`);
|
|
206
|
+
lines.push('');
|
|
207
|
+
lines.push(`> Auto-generated by \`peaks upgrade --to 2.0${result.applied ? ' --auto' : ''}\`.`);
|
|
208
|
+
lines.push(`> Per the "one-key completion" + "minimal-user-operation" tenets.`);
|
|
209
|
+
lines.push('');
|
|
210
|
+
if (result.fromVersion !== null) {
|
|
211
|
+
lines.push(`**From version**: ${result.fromVersion}`);
|
|
212
|
+
}
|
|
213
|
+
lines.push(`**To version**: 2.0.0`);
|
|
214
|
+
lines.push(`**Project root**: \`${result.projectRoot}\``);
|
|
215
|
+
lines.push('');
|
|
216
|
+
lines.push('## Sub-step results');
|
|
217
|
+
lines.push('');
|
|
218
|
+
lines.push('| step | status | exitCode | durationMs |');
|
|
219
|
+
lines.push('|------|--------|----------|------------|');
|
|
220
|
+
for (const step of result.steps) {
|
|
221
|
+
lines.push(`| ${step.name} | ${step.status} | ${step.exitCode ?? 'n/a'} | ${step.durationMs} |`);
|
|
222
|
+
}
|
|
223
|
+
lines.push('');
|
|
224
|
+
if (result.auditBefore !== null || result.auditAfter !== null) {
|
|
225
|
+
lines.push('## Audit snapshot');
|
|
226
|
+
lines.push('');
|
|
227
|
+
if (result.auditBefore !== null) {
|
|
228
|
+
lines.push(`- Before: totalRedLines=${result.auditBefore.totalRedLines}, cliBacked=${result.auditBefore.cliBacked}`);
|
|
229
|
+
}
|
|
230
|
+
if (result.auditAfter !== null) {
|
|
231
|
+
lines.push(`- After: totalRedLines=${result.auditAfter.totalRedLines}, cliBacked=${result.auditAfter.cliBacked}`);
|
|
232
|
+
}
|
|
233
|
+
lines.push('');
|
|
234
|
+
}
|
|
235
|
+
lines.push('## Next actions');
|
|
236
|
+
lines.push('');
|
|
237
|
+
for (const a of result.nextActions) {
|
|
238
|
+
lines.push(`- ${a}`);
|
|
239
|
+
}
|
|
240
|
+
writeFileSync(file, lines.join('\n') + '\n', 'utf8');
|
|
241
|
+
return file;
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
process.stderr.write(`peaks upgrade: failed to write upgrade record: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
export function runUpgrade(input) {
|
|
249
|
+
// Resolve the peaks binary. Default: the peaks.js script
|
|
250
|
+
// co-located with this compiled module (the user just installed
|
|
251
|
+
// peaks-cli globally, but the global `peaks` shim is a .sh
|
|
252
|
+
// script that cmd.exe can't run on Windows). Falling back
|
|
253
|
+
// to just "peaks" lets the umbrella work when invoked from
|
|
254
|
+
// a Unix-style environment that can run the shim directly.
|
|
255
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
256
|
+
// Walk up from the compiled location to find bin/peaks.js.
|
|
257
|
+
// The compiled service lives at dist/src/services/upgrade/upgrade-service.js;
|
|
258
|
+
// bin/peaks.js is at the peaks-cli root.
|
|
259
|
+
const peaksBin = input.peaksBin ??
|
|
260
|
+
resolve(here, '..', '..', '..', '..', 'bin', 'peaks.js');
|
|
261
|
+
const fallbackPeaks = 'peaks';
|
|
262
|
+
const resolvedPeaksBin = existsSync(peaksBin) ? peaksBin : fallbackPeaks;
|
|
263
|
+
const fromVersion = read1xVersion(input.projectRoot);
|
|
264
|
+
const steps = [];
|
|
265
|
+
const warnings = [];
|
|
266
|
+
const nextActions = [];
|
|
267
|
+
// Ensure .peaks/preferences.json exists. This is the file the
|
|
268
|
+
// 1.x detector keys off — without it, `peaks upgrade --detect-1x`
|
|
269
|
+
// keeps returning isOneX=true after a successful upgrade and the
|
|
270
|
+
// user gets stuck in a re-prompt loop. savePreferences with an
|
|
271
|
+
// empty override merges with DEFAULT_PREFERENCES and writes; if
|
|
272
|
+
// the file already exists the user's values are preserved.
|
|
273
|
+
// Real bug surfaced by ice-cola dogfood 2026-06-12.
|
|
274
|
+
try {
|
|
275
|
+
savePreferences(input.projectRoot, {});
|
|
276
|
+
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
warnings.push(`ensure-preferences failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
279
|
+
}
|
|
280
|
+
// Migrate .gitignore so 2.0 tracked artifacts
|
|
281
|
+
// (.peaks/standards/, .peaks/memory/*.md durable memories,
|
|
282
|
+
// .peaks/PROJECT.md) aren't silently hidden by a 1.x wholesale
|
|
283
|
+
// `/.peaks/` ignore rule. Real bug surfaced by ice-cola dogfood
|
|
284
|
+
// 2026-06-12: every consumer artifact was being dropped from git
|
|
285
|
+
// status. Service is idempotent + creates a timestamped backup
|
|
286
|
+
// before any write.
|
|
287
|
+
try {
|
|
288
|
+
const giResult = migrateGitignoreFile({ projectRoot: input.projectRoot, apply: true });
|
|
289
|
+
if (giResult.changed && giResult.appliedWrite && giResult.backupPath !== null) {
|
|
290
|
+
nextActions.push(`Updated .gitignore — removed stale wholesale .peaks rule(s): ${giResult.removedRules.join(', ')}. Backup at ${giResult.backupPath}.`);
|
|
291
|
+
}
|
|
292
|
+
else if (giResult.missing) {
|
|
293
|
+
warnings.push('gitignore-migrate skipped: project has no .gitignore');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
warnings.push(`gitignore-migrate failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
298
|
+
}
|
|
299
|
+
// Audit BEFORE the upgrade (baseline)
|
|
300
|
+
let auditBefore = null;
|
|
301
|
+
try {
|
|
302
|
+
const r = runRedLinesAudit({ projectRoot: input.projectRoot });
|
|
303
|
+
auditBefore = { totalRedLines: r.audit.totalRedLines, cliBacked: r.audit.cliBacked };
|
|
304
|
+
}
|
|
305
|
+
catch (err) {
|
|
306
|
+
warnings.push(`audit-before failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
307
|
+
}
|
|
308
|
+
// Run the 6 sub-steps
|
|
309
|
+
for (const step of STEPS) {
|
|
310
|
+
if (step.name === 'memory-extract') {
|
|
311
|
+
// Special case: expand the three glob patterns to literal
|
|
312
|
+
// paths before spawning. memory-service rejects literal
|
|
313
|
+
// '**' in artifact paths (assertInsideProject's realpathSync
|
|
314
|
+
// throws ENOENT) and refuses to run without --artifact.
|
|
315
|
+
const artifacts = expandMemoryArtifacts(input.projectRoot);
|
|
316
|
+
if (artifacts.length === 0) {
|
|
317
|
+
steps.push({
|
|
318
|
+
name: 'memory-extract',
|
|
319
|
+
status: 'skipped',
|
|
320
|
+
exitCode: null,
|
|
321
|
+
stdout: '',
|
|
322
|
+
stderr: 'no skills/, CLAUDE.md, or .claude/rules/ artifacts found in the project',
|
|
323
|
+
durationMs: 0,
|
|
324
|
+
});
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
const args = ['memory', 'extract', '--project', input.projectRoot, '--artifact', ...artifacts, '--apply', '--json'];
|
|
328
|
+
const r = runStep(resolvedPeaksBin, 'memory-extract', args);
|
|
329
|
+
steps.push(r);
|
|
330
|
+
if (r.status === 'fail') {
|
|
331
|
+
warnings.push(`memory-extract failed: ${r.stderr.slice(0, 200)}`);
|
|
332
|
+
}
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const args = step.args(input.projectRoot);
|
|
336
|
+
const r = runStep(resolvedPeaksBin, step.name, args);
|
|
337
|
+
steps.push(r);
|
|
338
|
+
if (r.status === 'fail') {
|
|
339
|
+
warnings.push(`${step.name} failed: ${r.stderr.slice(0, 200)}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Audit AFTER the upgrade (verify)
|
|
343
|
+
let auditAfter = null;
|
|
344
|
+
try {
|
|
345
|
+
const r = runRedLinesAudit({ projectRoot: input.projectRoot });
|
|
346
|
+
auditAfter = { totalRedLines: r.audit.totalRedLines, cliBacked: r.audit.cliBacked };
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
warnings.push(`audit-after failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
350
|
+
}
|
|
351
|
+
const passedCount = steps.filter((s) => s.status === 'pass').length;
|
|
352
|
+
const failedCount = steps.filter((s) => s.status === 'fail').length;
|
|
353
|
+
const skippedCount = steps.filter((s) => s.status === 'skipped').length;
|
|
354
|
+
const applied = failedCount === 0;
|
|
355
|
+
if (failedCount > 0) {
|
|
356
|
+
nextActions.push(`${failedCount} sub-step(s) failed. Run \`peaks upgrade --to 2.0\` again to retry the failed steps.`);
|
|
357
|
+
}
|
|
358
|
+
if (input.auto !== true) {
|
|
359
|
+
nextActions.push('Run `peaks audit red-lines --project .` to verify the L2 catalog is healthy.');
|
|
360
|
+
}
|
|
361
|
+
nextActions.push('See `docs/UPGRADING-2.0.md` for the manual fallback if this auto-upgrade fails.');
|
|
362
|
+
// Write the upgrade record (always, even on partial failure —
|
|
363
|
+
// the user gets a forensic artifact either way)
|
|
364
|
+
const partial = {
|
|
365
|
+
applied,
|
|
366
|
+
fromVersion,
|
|
367
|
+
toVersion: '2.0.0',
|
|
368
|
+
projectRoot: input.projectRoot,
|
|
369
|
+
steps,
|
|
370
|
+
passedCount,
|
|
371
|
+
failedCount,
|
|
372
|
+
skippedCount,
|
|
373
|
+
auditBefore,
|
|
374
|
+
auditAfter,
|
|
375
|
+
upgradeRecordPath: null,
|
|
376
|
+
nextActions,
|
|
377
|
+
warnings,
|
|
378
|
+
};
|
|
379
|
+
const upgradeRecordPath = writeUpgradeRecord(input.projectRoot, partial);
|
|
380
|
+
return { ...partial, upgradeRecordPath };
|
|
381
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SID naming guard. Enforces the "two-axis" convention from spec §0:
|
|
3
|
+
* session id: YYYY-MM-DD-session-<3-6 chars lowercase alnum>
|
|
4
|
+
* change id: kebab-case
|
|
5
|
+
*
|
|
6
|
+
* Spec §8.7 — bare forms (sid-3 / sid-h / sid-r / unknown-sid) are
|
|
7
|
+
* migrated to `_archive/invalid-sids/`, NOT tolerated.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SID_FORMAT_DESCRIPTION = "<YYYY-MM-DD>-session-<3-6 chars lowercase alnum>, e.g. 2026-06-11-session-abc123";
|
|
10
|
+
export declare function isValidSessionId(sid: string): boolean;
|
|
11
|
+
export declare function isValidChangeId(cid: string): boolean;
|
|
12
|
+
export declare function isBareSid(name: string): boolean;
|
|
13
|
+
export declare function assertValidSessionId(sid: string): void;
|
|
14
|
+
export declare function assertValidChangeId(cid: string): void;
|