@mytechtoday/augment-extensions 3.1.0 → 3.2.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/AGENTS.md +123 -0
- package/README.md +981 -32
- package/augment-extensions/coding-standards/q/CHANGELOG.md +16 -0
- package/augment-extensions/coding-standards/q/README.md +53 -0
- package/augment-extensions/coding-standards/q/examples/ArrayAndTupleNamingConventions.qs +27 -0
- package/augment-extensions/coding-standards/q/examples/CallableAliasNamingConventions.qs +20 -0
- package/augment-extensions/coding-standards/q/examples/CircuitCompositionNamingConventions.qs +24 -0
- package/augment-extensions/coding-standards/q/examples/ConstantValueNamingConventions.qs +19 -0
- package/augment-extensions/coding-standards/q/examples/EntryPointAttributeNamingConventions.qs +17 -0
- package/augment-extensions/coding-standards/q/examples/FunctorApplicationInControlledCircuits.qs +84 -0
- package/augment-extensions/coding-standards/q/examples/FunctorSpecializationNamingConventions.qs +29 -0
- package/augment-extensions/coding-standards/q/examples/GenericTypeParameterNamingConventions.qs +20 -0
- package/augment-extensions/coding-standards/q/examples/HamiltonianOperatorNamingConventions.qs +24 -0
- package/augment-extensions/coding-standards/q/examples/MeasurementResultNamingConventions.qs +48 -0
- package/augment-extensions/coding-standards/q/examples/NamespaceNamingConventions.qs +30 -0
- package/augment-extensions/coding-standards/q/examples/OperationAndFunctionNamingConventions.qs +31 -0
- package/augment-extensions/coding-standards/q/examples/OracleCallableNamingConventions.qs +41 -0
- package/augment-extensions/coding-standards/q/examples/PauliBasisNamingConventions.qs +42 -0
- package/augment-extensions/coding-standards/q/examples/PauliOperatorNamingConventions.qs +24 -0
- package/augment-extensions/coding-standards/q/examples/QubitManagementAndTeleportation.qs +94 -0
- package/augment-extensions/coding-standards/q/examples/QubitNamingConventions.qs +53 -0
- package/augment-extensions/coding-standards/q/examples/QubitRegisterNamingConventions.qs +30 -0
- package/augment-extensions/coding-standards/q/examples/StateVectorNamingConventions.qs +23 -0
- package/augment-extensions/coding-standards/q/examples/UserDefinedTypeNamingConventions.qs +22 -0
- package/augment-extensions/coding-standards/q/examples/VariableAndParameterNamingConventions.qs +26 -0
- package/augment-extensions/coding-standards/q/examples/bell-state.qs +21 -0
- package/augment-extensions/coding-standards/q/metadata.json +38 -0
- package/augment-extensions/coding-standards/q/module.json +29 -0
- package/augment-extensions/coding-standards/q/rules/q-error-handling.md +143 -0
- package/augment-extensions/coding-standards/q/rules/q-naming-conventions.md +82 -0
- package/augment-extensions/coding-standards/q/rules/q-performance-optimization.md +10 -0
- package/augment-extensions/coding-standards/q/rules/q-qubit-management.md +10 -0
- package/augment-extensions/coding-standards/q/rules/q-security.md +10 -0
- package/augment-extensions/coding-standards/q/rules/q-standards.md +127 -0
- package/augment-extensions/coding-standards/q/rules/q-testing.md +10 -0
- package/augment-extensions/visual-design/CHANGELOG.md +2 -2
- package/augment-extensions/visual-design/README.md +31 -8
- package/augment-extensions/visual-design/VERSION +1 -0
- package/augment-extensions/visual-design/__tests__/README.md +32 -18
- package/augment-extensions/visual-design/__tests__/guidance-contract.test.ts +355 -0
- package/augment-extensions/visual-design/__tests__/vendor-styles.test.ts +23 -5
- package/augment-extensions/visual-design/domains/other/dotnet-application.ts +1 -1
- package/augment-extensions/visual-design/domains/other/mobile-application.ts +3 -4
- package/augment-extensions/visual-design/domains/other/os-application.ts +1 -1
- package/augment-extensions/visual-design/domains/other/windows-platform.ts +1 -1
- package/augment-extensions/visual-design/domains/web-page-styles/amazon-cloudscape.ts +4 -4
- package/augment-extensions/visual-design/domains/web-page-styles/google-modern.ts +10 -10
- package/augment-extensions/visual-design/domains/web-page-styles/microsoft-fluent.ts +3 -3
- package/augment-extensions/visual-design/examples/README.md +2 -0
- package/augment-extensions/visual-design/examples/basic-usage.md +5 -3
- package/augment-extensions/visual-design/examples/vendor-comparison.md +2 -2
- package/augment-extensions/visual-design/guidelines/coverage-map.md +30 -0
- package/augment-extensions/visual-design/guidelines/design-levels.md +211 -0
- package/augment-extensions/visual-design/guidelines/index.md +5 -0
- package/augment-extensions/visual-design/metadata.json +26 -5
- package/augment-extensions/visual-design/module.json +39 -6
- package/augment-extensions/visual-design/rules/accessibility-and-color.md +51 -0
- package/augment-extensions/visual-design/rules/design-practice.md +55 -0
- package/augment-extensions/visual-design/rules/index.md +34 -0
- package/augment-extensions/visual-design/rules/platform-guidance.md +47 -0
- package/augment-extensions/visual-design/scripts/validate-guidance.cjs +233 -0
- package/augment-extensions/visual-design/skills/README.md +11 -0
- package/augment-extensions/visual-design/skills/design-brief.md +40 -0
- package/augment-extensions/visual-design/skills/design-review.md +38 -0
- package/augment-extensions/visual-design/skills/responsive-validation/SKILL.md +94 -0
- package/augment-extensions/visual-design/skills/responsive-validation/scripts/responsive-sweep.cjs +457 -0
- package/augment-extensions/visual-design/style-selector.ts +4 -4
- package/augment-extensions/visual-design/types.ts +101 -46
- package/augment-extensions/visual-design/visual-design-core.ts +8 -8
- package/cli/dist/adapters/banner.d.ts +62 -0
- package/cli/dist/adapters/banner.d.ts.map +1 -0
- package/cli/dist/adapters/banner.js +105 -0
- package/cli/dist/adapters/banner.js.map +1 -0
- package/cli/dist/adapters/claude-code.d.ts +13 -0
- package/cli/dist/adapters/claude-code.d.ts.map +1 -0
- package/cli/dist/adapters/claude-code.js +79 -0
- package/cli/dist/adapters/claude-code.js.map +1 -0
- package/cli/dist/adapters/copilot.d.ts +17 -0
- package/cli/dist/adapters/copilot.d.ts.map +1 -0
- package/cli/dist/adapters/copilot.js +81 -0
- package/cli/dist/adapters/copilot.js.map +1 -0
- package/cli/dist/adapters/cursor.d.ts +16 -0
- package/cli/dist/adapters/cursor.d.ts.map +1 -0
- package/cli/dist/adapters/cursor.js +99 -0
- package/cli/dist/adapters/cursor.js.map +1 -0
- package/cli/dist/adapters/index.d.ts +25 -0
- package/cli/dist/adapters/index.d.ts.map +1 -0
- package/cli/dist/adapters/index.js +59 -0
- package/cli/dist/adapters/index.js.map +1 -0
- package/cli/dist/adapters/types.d.ts +113 -0
- package/cli/dist/adapters/types.d.ts.map +1 -0
- package/cli/dist/adapters/types.js +13 -0
- package/cli/dist/adapters/types.js.map +1 -0
- package/cli/dist/adapters/windsurf.d.ts +14 -0
- package/cli/dist/adapters/windsurf.d.ts.map +1 -0
- package/cli/dist/adapters/windsurf.js +78 -0
- package/cli/dist/adapters/windsurf.js.map +1 -0
- package/cli/dist/analysis/index.d.ts +1 -0
- package/cli/dist/analysis/index.d.ts.map +1 -1
- package/cli/dist/analysis/index.js +1 -0
- package/cli/dist/analysis/index.js.map +1 -1
- package/cli/dist/analysis/pattern-analyzer.d.ts +6 -0
- package/cli/dist/analysis/pattern-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/pattern-analyzer.js +100 -0
- package/cli/dist/analysis/pattern-analyzer.js.map +1 -0
- package/cli/dist/cli.js +62 -35
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/code-analysis.d.ts.map +1 -1
- package/cli/dist/commands/code-analysis.js +22 -2
- package/cli/dist/commands/code-analysis.js.map +1 -1
- package/cli/dist/commands/export.d.ts +81 -0
- package/cli/dist/commands/export.d.ts.map +1 -0
- package/cli/dist/commands/export.js +334 -0
- package/cli/dist/commands/export.js.map +1 -0
- package/cli/dist/commands/gui.d.ts +3 -1
- package/cli/dist/commands/gui.d.ts.map +1 -1
- package/cli/dist/commands/gui.js +263 -22
- package/cli/dist/commands/gui.js.map +1 -1
- package/cli/dist/commands/init.d.ts +2 -0
- package/cli/dist/commands/init.d.ts.map +1 -1
- package/cli/dist/commands/init.js +95 -3
- package/cli/dist/commands/init.js.map +1 -1
- package/cli/dist/commands/lifecycle.d.ts +14 -0
- package/cli/dist/commands/lifecycle.d.ts.map +1 -0
- package/cli/dist/commands/lifecycle.js +463 -0
- package/cli/dist/commands/lifecycle.js.map +1 -0
- package/cli/dist/commands/link.d.ts +3 -0
- package/cli/dist/commands/link.d.ts.map +1 -1
- package/cli/dist/commands/link.js +126 -16
- package/cli/dist/commands/link.js.map +1 -1
- package/cli/dist/commands/list.js +2 -2
- package/cli/dist/commands/list.js.map +1 -1
- package/cli/dist/commands/mcp.d.ts +1 -2
- package/cli/dist/commands/mcp.d.ts.map +1 -1
- package/cli/dist/commands/mcp.js +20 -20
- package/cli/dist/commands/mcp.js.map +1 -1
- package/cli/dist/commands/module-management.d.ts +9 -0
- package/cli/dist/commands/module-management.d.ts.map +1 -0
- package/cli/dist/commands/module-management.js +420 -0
- package/cli/dist/commands/module-management.js.map +1 -0
- package/cli/dist/commands/self-remove.d.ts.map +1 -1
- package/cli/dist/commands/self-remove.js +98 -44
- package/cli/dist/commands/self-remove.js.map +1 -1
- package/cli/dist/commands/show.d.ts +1 -1
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +21 -10
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/commands/showCompleted.d.ts +1 -0
- package/cli/dist/commands/showCompleted.d.ts.map +1 -1
- package/cli/dist/commands/showCompleted.js +4 -3
- package/cli/dist/commands/showCompleted.js.map +1 -1
- package/cli/dist/commands/skill.d.ts +7 -1
- package/cli/dist/commands/skill.d.ts.map +1 -1
- package/cli/dist/commands/skill.js +79 -21
- package/cli/dist/commands/skill.js.map +1 -1
- package/cli/dist/commands/unlink.d.ts.map +1 -1
- package/cli/dist/commands/unlink.js +38 -2
- package/cli/dist/commands/unlink.js.map +1 -1
- package/cli/dist/commands/update.d.ts.map +1 -1
- package/cli/dist/commands/update.js +6 -16
- package/cli/dist/commands/update.js.map +1 -1
- package/cli/dist/commands/upgrade.d.ts +2 -0
- package/cli/dist/commands/upgrade.d.ts.map +1 -1
- package/cli/dist/commands/upgrade.js +22 -5
- package/cli/dist/commands/upgrade.js.map +1 -1
- package/cli/dist/commands/use.d.ts.map +1 -1
- package/cli/dist/commands/use.js +2 -68
- package/cli/dist/commands/use.js.map +1 -1
- package/cli/dist/core/compatibility-checker.d.ts +37 -1
- package/cli/dist/core/compatibility-checker.d.ts.map +1 -1
- package/cli/dist/core/compatibility-checker.js +133 -12
- package/cli/dist/core/compatibility-checker.js.map +1 -1
- package/cli/dist/gui/state/navigation-state.d.ts +20 -0
- package/cli/dist/gui/state/navigation-state.d.ts.map +1 -0
- package/cli/dist/gui/state/navigation-state.js +115 -0
- package/cli/dist/gui/state/navigation-state.js.map +1 -0
- package/cli/dist/gui/state/selection-state.d.ts +21 -0
- package/cli/dist/gui/state/selection-state.d.ts.map +1 -0
- package/cli/dist/gui/state/selection-state.js +117 -0
- package/cli/dist/gui/state/selection-state.js.map +1 -0
- package/cli/dist/lib/export-runner.d.ts +76 -0
- package/cli/dist/lib/export-runner.d.ts.map +1 -0
- package/cli/dist/lib/export-runner.js +111 -0
- package/cli/dist/lib/export-runner.js.map +1 -0
- package/cli/dist/lib/mcp-detection.d.ts +40 -0
- package/cli/dist/lib/mcp-detection.d.ts.map +1 -0
- package/cli/dist/lib/mcp-detection.js +167 -0
- package/cli/dist/lib/mcp-detection.js.map +1 -0
- package/cli/dist/lib/mirror-coordination.d.ts +57 -0
- package/cli/dist/lib/mirror-coordination.d.ts.map +1 -0
- package/cli/dist/lib/mirror-coordination.js +151 -0
- package/cli/dist/lib/mirror-coordination.js.map +1 -0
- package/cli/dist/lib/mirror-runner.d.ts +123 -0
- package/cli/dist/lib/mirror-runner.d.ts.map +1 -0
- package/cli/dist/lib/mirror-runner.js +579 -0
- package/cli/dist/lib/mirror-runner.js.map +1 -0
- package/cli/dist/lib/module-resolver.d.ts +65 -0
- package/cli/dist/lib/module-resolver.d.ts.map +1 -0
- package/cli/dist/lib/module-resolver.js +211 -0
- package/cli/dist/lib/module-resolver.js.map +1 -0
- package/cli/dist/lib/source-hash.d.ts +62 -0
- package/cli/dist/lib/source-hash.d.ts.map +1 -0
- package/cli/dist/lib/source-hash.js +99 -0
- package/cli/dist/lib/source-hash.js.map +1 -0
- package/cli/dist/types/coordination-export.d.ts +33 -0
- package/cli/dist/types/coordination-export.d.ts.map +1 -0
- package/cli/dist/types/coordination-export.js +28 -0
- package/cli/dist/types/coordination-export.js.map +1 -0
- package/cli/dist/types/lifecycle.d.ts +81 -0
- package/cli/dist/types/lifecycle.d.ts.map +1 -0
- package/cli/dist/types/lifecycle.js +3 -0
- package/cli/dist/types/lifecycle.js.map +1 -0
- package/cli/dist/utils/beads-sync.d.ts +4 -0
- package/cli/dist/utils/beads-sync.d.ts.map +1 -1
- package/cli/dist/utils/beads-sync.js.map +1 -1
- package/cli/dist/utils/catalog-sync.d.ts.map +1 -1
- package/cli/dist/utils/catalog-sync.js +41 -8
- package/cli/dist/utils/catalog-sync.js.map +1 -1
- package/cli/dist/utils/coordination-queries.d.ts +3 -0
- package/cli/dist/utils/coordination-queries.d.ts.map +1 -1
- package/cli/dist/utils/coordination-queries.js.map +1 -1
- package/cli/dist/utils/extensions-config.d.ts +29 -0
- package/cli/dist/utils/extensions-config.d.ts.map +1 -0
- package/cli/dist/utils/extensions-config.js +151 -0
- package/cli/dist/utils/extensions-config.js.map +1 -0
- package/cli/dist/utils/extractCommandHelp.d.ts.map +1 -1
- package/cli/dist/utils/extractCommandHelp.js +8 -2
- package/cli/dist/utils/extractCommandHelp.js.map +1 -1
- package/cli/dist/utils/file-tracking.d.ts +4 -0
- package/cli/dist/utils/file-tracking.d.ts.map +1 -1
- package/cli/dist/utils/file-tracking.js.map +1 -1
- package/cli/dist/utils/inspection-cache.d.ts +8 -0
- package/cli/dist/utils/inspection-cache.d.ts.map +1 -1
- package/cli/dist/utils/inspection-cache.js +12 -0
- package/cli/dist/utils/inspection-cache.js.map +1 -1
- package/cli/dist/utils/inspection-handlers.d.ts.map +1 -1
- package/cli/dist/utils/inspection-handlers.js +230 -52
- package/cli/dist/utils/inspection-handlers.js.map +1 -1
- package/cli/dist/utils/install-rules.d.ts +20 -0
- package/cli/dist/utils/install-rules.d.ts.map +1 -1
- package/cli/dist/utils/install-rules.js +367 -0
- package/cli/dist/utils/install-rules.js.map +1 -1
- package/cli/dist/utils/interactive-prompt.d.ts +7 -0
- package/cli/dist/utils/interactive-prompt.d.ts.map +1 -0
- package/cli/dist/utils/interactive-prompt.js +41 -0
- package/cli/dist/utils/interactive-prompt.js.map +1 -0
- package/cli/dist/utils/lifecycle.d.ts +47 -0
- package/cli/dist/utils/lifecycle.d.ts.map +1 -0
- package/cli/dist/utils/lifecycle.js +841 -0
- package/cli/dist/utils/lifecycle.js.map +1 -0
- package/cli/dist/utils/mcp-integration.d.ts +24 -3
- package/cli/dist/utils/mcp-integration.d.ts.map +1 -1
- package/cli/dist/utils/mcp-integration.js +364 -151
- package/cli/dist/utils/mcp-integration.js.map +1 -1
- package/cli/dist/utils/module-system.d.ts +5 -0
- package/cli/dist/utils/module-system.d.ts.map +1 -1
- package/cli/dist/utils/module-system.js +113 -29
- package/cli/dist/utils/module-system.js.map +1 -1
- package/cli/dist/utils/openspec-sync.d.ts +4 -0
- package/cli/dist/utils/openspec-sync.d.ts.map +1 -1
- package/cli/dist/utils/openspec-sync.js.map +1 -1
- package/cli/dist/utils/plugin-system.js +1 -1
- package/cli/dist/utils/plugin-system.js.map +1 -1
- package/cli/dist/utils/skill-system.d.ts +11 -0
- package/cli/dist/utils/skill-system.d.ts.map +1 -1
- package/cli/dist/utils/skill-system.js +101 -3
- package/cli/dist/utils/skill-system.js.map +1 -1
- package/cli/dist/utils/zip-archive.d.ts +25 -0
- package/cli/dist/utils/zip-archive.d.ts.map +1 -0
- package/cli/dist/utils/zip-archive.js +287 -0
- package/cli/dist/utils/zip-archive.js.map +1 -0
- package/modules.md +21 -4
- package/package.json +138 -140
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getLifecycleArtifactPath = getLifecycleArtifactPath;
|
|
40
|
+
exports.getLifecycleBackupRoot = getLifecycleBackupRoot;
|
|
41
|
+
exports.getLifecycleArchiveRoot = getLifecycleArchiveRoot;
|
|
42
|
+
exports.getLifecycleReportRoot = getLifecycleReportRoot;
|
|
43
|
+
exports.inspectLifecycleArtifact = inspectLifecycleArtifact;
|
|
44
|
+
exports.loadLifecycleArtifact = loadLifecycleArtifact;
|
|
45
|
+
exports.writeLifecycleArtifact = writeLifecycleArtifact;
|
|
46
|
+
exports.refreshLifecycleArtifact = refreshLifecycleArtifact;
|
|
47
|
+
exports.createLifecycleOperation = createLifecycleOperation;
|
|
48
|
+
exports.completeLifecycleOperation = completeLifecycleOperation;
|
|
49
|
+
exports.createLifecycleBackup = createLifecycleBackup;
|
|
50
|
+
exports.restoreLifecycleBackup = restoreLifecycleBackup;
|
|
51
|
+
exports.restoreExtensionsConfigFromArtifact = restoreExtensionsConfigFromArtifact;
|
|
52
|
+
exports.createAiPromptsArchive = createAiPromptsArchive;
|
|
53
|
+
exports.restoreAiPromptsArchive = restoreAiPromptsArchive;
|
|
54
|
+
exports.createLifecycleSnapshotFromArtifact = createLifecycleSnapshotFromArtifact;
|
|
55
|
+
exports.detectLifecycleIssues = detectLifecycleIssues;
|
|
56
|
+
exports.buildLifecycleSnapshot = buildLifecycleSnapshot;
|
|
57
|
+
exports.exportLifecycleReport = exportLifecycleReport;
|
|
58
|
+
exports.writeLifecycleReportFile = writeLifecycleReportFile;
|
|
59
|
+
exports.listSafeFixes = listSafeFixes;
|
|
60
|
+
exports.getLatestLifecycleBackup = getLatestLifecycleBackup;
|
|
61
|
+
const fs = __importStar(require("fs"));
|
|
62
|
+
const path = __importStar(require("path"));
|
|
63
|
+
const semver_1 = __importDefault(require("semver"));
|
|
64
|
+
const fs_1 = require("fs");
|
|
65
|
+
const module_system_1 = require("./module-system");
|
|
66
|
+
const extensions_config_1 = require("./extensions-config");
|
|
67
|
+
const zip_archive_1 = require("./zip-archive");
|
|
68
|
+
const LIFECYCLE_SCHEMA_VERSION = 1;
|
|
69
|
+
const LIFECYCLE_ROOT_DIR = 'lifecycle';
|
|
70
|
+
const LIFECYCLE_BACKUP_DIR = 'backups';
|
|
71
|
+
const LIFECYCLE_ARCHIVE_DIR = 'archives';
|
|
72
|
+
const LIFECYCLE_REPORT_DIR = 'reports';
|
|
73
|
+
const LIFECYCLE_ARTIFACT_FILE = 'lifecycle.json';
|
|
74
|
+
const AI_PROMPTS_DIR = 'ai-prompts';
|
|
75
|
+
const COMMAND_HELP_PATH = path.join('.augment', 'COMMAND_HELP.md');
|
|
76
|
+
const AUGMENT_RULES_DIR = path.join('.augment', 'rules');
|
|
77
|
+
const AUGMENT_CONFIG_PATH = path.join('.augment', 'extensions.json');
|
|
78
|
+
const VERSION_FILE_PATH = path.join('package.json');
|
|
79
|
+
const LIFECYCLE_APPLICATION_NAME = 'augment-extensions';
|
|
80
|
+
const LIFECYCLE_STATUS_VALUES = [
|
|
81
|
+
'not-installed',
|
|
82
|
+
'installation-detected',
|
|
83
|
+
'installation-in-progress',
|
|
84
|
+
'installation-completed',
|
|
85
|
+
'installation-partially-completed',
|
|
86
|
+
'installation-failed',
|
|
87
|
+
'upgrade-available',
|
|
88
|
+
'upgrade-in-progress',
|
|
89
|
+
'rollback-available',
|
|
90
|
+
'rollback-in-progress',
|
|
91
|
+
'uninstallation-pending-confirmation',
|
|
92
|
+
'uninstallation-in-progress',
|
|
93
|
+
'uninstallation-partially-completed',
|
|
94
|
+
'uninstallation-completed',
|
|
95
|
+
'diagnostic-analysis-in-progress',
|
|
96
|
+
'repair-available',
|
|
97
|
+
'repair-in-progress',
|
|
98
|
+
'recovery-required',
|
|
99
|
+
];
|
|
100
|
+
const LIFECYCLE_OPERATION_NAME_VALUES = [
|
|
101
|
+
'init',
|
|
102
|
+
'update',
|
|
103
|
+
'upgrade',
|
|
104
|
+
'migrate',
|
|
105
|
+
'self-remove',
|
|
106
|
+
'repair',
|
|
107
|
+
'rollback',
|
|
108
|
+
'diagnose',
|
|
109
|
+
'report',
|
|
110
|
+
];
|
|
111
|
+
const LIFECYCLE_OPERATION_STATUS_VALUES = [
|
|
112
|
+
'running',
|
|
113
|
+
'succeeded',
|
|
114
|
+
'failed',
|
|
115
|
+
];
|
|
116
|
+
function nowIso() {
|
|
117
|
+
return new Date().toISOString();
|
|
118
|
+
}
|
|
119
|
+
function readPackageVersion() {
|
|
120
|
+
const packagePath = path.join(__dirname, '../../../package.json');
|
|
121
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packagePath, 'utf-8'));
|
|
122
|
+
return typeof packageJson.version === 'string' ? packageJson.version : '0.0.0';
|
|
123
|
+
}
|
|
124
|
+
function lifecycleRoot(projectRoot) {
|
|
125
|
+
return path.join(projectRoot, '.augment', LIFECYCLE_ROOT_DIR);
|
|
126
|
+
}
|
|
127
|
+
function getLifecycleArtifactPath(projectRoot) {
|
|
128
|
+
return path.join(projectRoot, '.augment', LIFECYCLE_ARTIFACT_FILE);
|
|
129
|
+
}
|
|
130
|
+
function getLifecycleBackupRoot(projectRoot) {
|
|
131
|
+
return path.join(lifecycleRoot(projectRoot), LIFECYCLE_BACKUP_DIR);
|
|
132
|
+
}
|
|
133
|
+
function getLifecycleArchiveRoot(projectRoot) {
|
|
134
|
+
return path.join(lifecycleRoot(projectRoot), LIFECYCLE_ARCHIVE_DIR);
|
|
135
|
+
}
|
|
136
|
+
function getLifecycleReportRoot(projectRoot) {
|
|
137
|
+
return path.join(lifecycleRoot(projectRoot), LIFECYCLE_REPORT_DIR);
|
|
138
|
+
}
|
|
139
|
+
function ensureLifecycleDirectories(projectRoot) {
|
|
140
|
+
(0, fs_1.mkdirSync)(path.join(projectRoot, '.augment'), { recursive: true });
|
|
141
|
+
(0, fs_1.mkdirSync)(lifecycleRoot(projectRoot), { recursive: true });
|
|
142
|
+
(0, fs_1.mkdirSync)(getLifecycleBackupRoot(projectRoot), { recursive: true });
|
|
143
|
+
(0, fs_1.mkdirSync)(getLifecycleArchiveRoot(projectRoot), { recursive: true });
|
|
144
|
+
(0, fs_1.mkdirSync)(getLifecycleReportRoot(projectRoot), { recursive: true });
|
|
145
|
+
}
|
|
146
|
+
function stableClone(value) {
|
|
147
|
+
return JSON.parse(JSON.stringify(value));
|
|
148
|
+
}
|
|
149
|
+
function safeReadJson(filePath) {
|
|
150
|
+
try {
|
|
151
|
+
return JSON.parse((0, fs_1.readFileSync)(filePath, 'utf-8'));
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function writeJsonAtomic(filePath, data) {
|
|
158
|
+
const tempPath = `${filePath}.tmp`;
|
|
159
|
+
(0, fs_1.writeFileSync)(tempPath, `${JSON.stringify(data, null, 2)}\n`, 'utf-8');
|
|
160
|
+
(0, fs_1.renameSync)(tempPath, filePath);
|
|
161
|
+
}
|
|
162
|
+
function normalizeLinkedModuleRecord(entry) {
|
|
163
|
+
if (typeof entry === 'string') {
|
|
164
|
+
return { name: entry, version: '0.0.0' };
|
|
165
|
+
}
|
|
166
|
+
const objectEntry = (entry ?? {});
|
|
167
|
+
const name = typeof objectEntry.name === 'string'
|
|
168
|
+
? objectEntry.name
|
|
169
|
+
: typeof objectEntry.id === 'string'
|
|
170
|
+
? objectEntry.id
|
|
171
|
+
: '(unknown)';
|
|
172
|
+
const version = typeof objectEntry.version === 'string' ? objectEntry.version : '0.0.0';
|
|
173
|
+
return {
|
|
174
|
+
...objectEntry,
|
|
175
|
+
name,
|
|
176
|
+
version,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function snapshotExtensionsConfig(projectRoot, fallback) {
|
|
180
|
+
const loaded = (0, extensions_config_1.loadExtensionsConfig)(projectRoot);
|
|
181
|
+
if (loaded.exists && loaded.valid) {
|
|
182
|
+
return stableClone({
|
|
183
|
+
...loaded.config,
|
|
184
|
+
modules: Array.isArray(loaded.config.modules)
|
|
185
|
+
? loaded.config.modules.map((entry) => normalizeLinkedModuleRecord(entry))
|
|
186
|
+
: []
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
if (fallback) {
|
|
190
|
+
return stableClone(fallback.extensionsConfig);
|
|
191
|
+
}
|
|
192
|
+
return { modules: [] };
|
|
193
|
+
}
|
|
194
|
+
function isRecord(value) {
|
|
195
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
196
|
+
}
|
|
197
|
+
function isStringArray(value) {
|
|
198
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string');
|
|
199
|
+
}
|
|
200
|
+
function isLifecycleStatusValue(value) {
|
|
201
|
+
return typeof value === 'string' && LIFECYCLE_STATUS_VALUES.includes(value);
|
|
202
|
+
}
|
|
203
|
+
function isLifecycleOperationNameValue(value) {
|
|
204
|
+
return typeof value === 'string' && LIFECYCLE_OPERATION_NAME_VALUES.includes(value);
|
|
205
|
+
}
|
|
206
|
+
function isLifecycleOperationStatusValue(value) {
|
|
207
|
+
return typeof value === 'string' && LIFECYCLE_OPERATION_STATUS_VALUES.includes(value);
|
|
208
|
+
}
|
|
209
|
+
function hasLifecycleValidationIssue(issues) {
|
|
210
|
+
return issues.some((issue) => issue.id.startsWith('lifecycle-artifact-'));
|
|
211
|
+
}
|
|
212
|
+
function validateLifecycleArtifactData(artifactPath, parsed) {
|
|
213
|
+
const issues = [];
|
|
214
|
+
if (!isRecord(parsed)) {
|
|
215
|
+
issues.push(buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact is corrupted', 'The lifecycle artifact could not be parsed as a JSON object.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will replace the corrupted copy after confirmation.', 'refresh-artifact', [`Checked path: ${artifactPath}`]));
|
|
216
|
+
return { artifact: null, issues };
|
|
217
|
+
}
|
|
218
|
+
const schemaVersion = parsed.schemaVersion;
|
|
219
|
+
if (schemaVersion !== LIFECYCLE_SCHEMA_VERSION) {
|
|
220
|
+
issues.push(buildIssue('lifecycle-artifact-unsupported-schema', 'critical', 'Lifecycle artifact schema is unsupported', typeof schemaVersion === 'number'
|
|
221
|
+
? `The lifecycle artifact uses schema version ${schemaVersion}, but this CLI supports ${LIFECYCLE_SCHEMA_VERSION}.`
|
|
222
|
+
: 'The lifecycle artifact is missing a supported schema version.', artifactPath, true, 'Export a diagnostic report, then regenerate the artifact with the current CLI.', 'high', true, ['read lifecycle artifact'], true, 'A new artifact will be generated using the supported schema.', 'refresh-artifact', [`Checked path: ${artifactPath}`, `Observed schema version: ${String(schemaVersion)}`]));
|
|
223
|
+
}
|
|
224
|
+
const application = parsed.application;
|
|
225
|
+
if (!isRecord(application) || typeof application.name !== 'string' || typeof application.version !== 'string') {
|
|
226
|
+
issues.push(buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact metadata is incomplete', 'The lifecycle artifact is missing application metadata.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will replace the incomplete copy after confirmation.', 'refresh-artifact', [`Checked path: ${artifactPath}`]));
|
|
227
|
+
}
|
|
228
|
+
else if (application.name !== LIFECYCLE_APPLICATION_NAME) {
|
|
229
|
+
issues.push(buildIssue('lifecycle-artifact-wrong-identity', 'critical', 'Lifecycle artifact belongs to a different application', `The artifact application name is ${application.name}, not ${LIFECYCLE_APPLICATION_NAME}.`, artifactPath, true, 'Review the diagnostic report and refresh the artifact only if this project owns the file.', 'high', true, ['read lifecycle artifact'], true, 'The artifact will be rebuilt for this project after confirmation.', 'refresh-artifact', [`Checked path: ${artifactPath}`, `Observed application name: ${application.name}`]));
|
|
230
|
+
}
|
|
231
|
+
if (typeof parsed.projectRoot !== 'string') {
|
|
232
|
+
issues.push(buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact is missing the project root', 'The lifecycle artifact does not record the project root path.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will include the missing project root.', 'refresh-artifact', [`Checked path: ${artifactPath}`]));
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const resolvedProjectRoot = path.resolve(parsed.projectRoot);
|
|
236
|
+
const currentProjectRoot = path.resolve(path.dirname(artifactPath), '..');
|
|
237
|
+
if (resolvedProjectRoot !== currentProjectRoot) {
|
|
238
|
+
issues.push(buildIssue('artifact-project-mismatch', 'warning', 'Lifecycle artifact was created for a different project root', `The artifact records ${resolvedProjectRoot}, but the current project root is ${currentProjectRoot}.`, artifactPath, false, 'Review the report before using the artifact for restoration.', 'medium', true, ['read lifecycle artifact'], false, 'The diagnostic report will keep the mismatch visible for review.', 'refresh-artifact', [`Artifact project root: ${resolvedProjectRoot}`, `Current project root: ${currentProjectRoot}`]));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (!isLifecycleStatusValue(parsed.status)) {
|
|
242
|
+
issues.push(buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact status is invalid', 'The lifecycle artifact records an unknown status value.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will contain a supported status.', 'refresh-artifact', [`Checked path: ${artifactPath}`, `Observed status: ${String(parsed.status)}`]));
|
|
243
|
+
}
|
|
244
|
+
const lastOperation = parsed.lastOperation;
|
|
245
|
+
if (!isRecord(lastOperation) || !isLifecycleOperationNameValue(lastOperation.name) || !isLifecycleOperationStatusValue(lastOperation.status) || typeof lastOperation.startedAt !== 'string') {
|
|
246
|
+
issues.push(buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact operation history is incomplete', 'The lifecycle artifact is missing a valid last operation record.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will include a valid last operation record.', 'refresh-artifact', [`Checked path: ${artifactPath}`]));
|
|
247
|
+
}
|
|
248
|
+
if (!isRecord(parsed.extensionsConfig) || !Array.isArray(parsed.extensionsConfig.modules)) {
|
|
249
|
+
issues.push(buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact configuration snapshot is incomplete', 'The lifecycle artifact is missing the captured extensions configuration.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will include a captured configuration snapshot.', 'refresh-artifact', [`Checked path: ${artifactPath}`]));
|
|
250
|
+
}
|
|
251
|
+
if (!Array.isArray(parsed.backups) || !Array.isArray(parsed.archives) || !Array.isArray(parsed.issues)) {
|
|
252
|
+
issues.push(buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact collections are incomplete', 'The lifecycle artifact is missing one or more collection fields.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will include complete collection fields.', 'refresh-artifact', [`Checked path: ${artifactPath}`]));
|
|
253
|
+
}
|
|
254
|
+
if (issues.some((issue) => issue.severity === 'critical')) {
|
|
255
|
+
return { artifact: null, issues };
|
|
256
|
+
}
|
|
257
|
+
const record = parsed;
|
|
258
|
+
const currentProjectRoot = path.resolve(path.dirname(artifactPath), '..');
|
|
259
|
+
const applicationRecord = isRecord(record.application) ? record.application : undefined;
|
|
260
|
+
const lastOperationRecord = isRecord(record.lastOperation) ? record.lastOperation : undefined;
|
|
261
|
+
const extensionsConfigRecord = isRecord(record.extensionsConfig) ? record.extensionsConfig : undefined;
|
|
262
|
+
const backupRecords = Array.isArray(record.backups) ? record.backups : [];
|
|
263
|
+
const archiveRecords = Array.isArray(record.archives) ? record.archives : [];
|
|
264
|
+
const issueRecords = Array.isArray(record.issues) ? record.issues : [];
|
|
265
|
+
const extensionModules = extensionsConfigRecord && Array.isArray(extensionsConfigRecord.modules)
|
|
266
|
+
? extensionsConfigRecord.modules
|
|
267
|
+
: [];
|
|
268
|
+
const artifact = {
|
|
269
|
+
...record,
|
|
270
|
+
schemaVersion: LIFECYCLE_SCHEMA_VERSION,
|
|
271
|
+
application: {
|
|
272
|
+
name: applicationRecord && typeof applicationRecord.name === 'string' ? applicationRecord.name : LIFECYCLE_APPLICATION_NAME,
|
|
273
|
+
version: applicationRecord && typeof applicationRecord.version === 'string' ? applicationRecord.version : readPackageVersion(),
|
|
274
|
+
},
|
|
275
|
+
projectRoot: typeof record.projectRoot === 'string' ? path.resolve(record.projectRoot) : currentProjectRoot,
|
|
276
|
+
status: isLifecycleStatusValue(record.status) ? record.status : 'recovery-required',
|
|
277
|
+
createdAt: typeof record.createdAt === 'string' ? record.createdAt : nowIso(),
|
|
278
|
+
updatedAt: typeof record.updatedAt === 'string' ? record.updatedAt : nowIso(),
|
|
279
|
+
lastOperation: {
|
|
280
|
+
name: lastOperationRecord && isLifecycleOperationNameValue(lastOperationRecord.name) ? lastOperationRecord.name : 'diagnose',
|
|
281
|
+
status: lastOperationRecord && isLifecycleOperationStatusValue(lastOperationRecord.status) ? lastOperationRecord.status : 'failed',
|
|
282
|
+
startedAt: lastOperationRecord && typeof lastOperationRecord.startedAt === 'string' ? lastOperationRecord.startedAt : nowIso(),
|
|
283
|
+
finishedAt: lastOperationRecord && typeof lastOperationRecord.finishedAt === 'string' ? lastOperationRecord.finishedAt : undefined,
|
|
284
|
+
error: lastOperationRecord && typeof lastOperationRecord.error === 'string' ? lastOperationRecord.error : undefined,
|
|
285
|
+
},
|
|
286
|
+
extensionsConfig: {
|
|
287
|
+
...(extensionsConfigRecord ?? {}),
|
|
288
|
+
modules: extensionModules.map((entry) => normalizeLinkedModuleRecord(entry)),
|
|
289
|
+
},
|
|
290
|
+
backups: backupRecords,
|
|
291
|
+
archives: archiveRecords,
|
|
292
|
+
issues: issueRecords,
|
|
293
|
+
notes: isStringArray(record.notes) ? record.notes : undefined,
|
|
294
|
+
};
|
|
295
|
+
return { artifact, issues };
|
|
296
|
+
}
|
|
297
|
+
function inspectLifecycleArtifact(projectRoot) {
|
|
298
|
+
const artifactPath = getLifecycleArtifactPath(projectRoot);
|
|
299
|
+
if (!(0, fs_1.existsSync)(artifactPath)) {
|
|
300
|
+
return {
|
|
301
|
+
exists: false,
|
|
302
|
+
valid: true,
|
|
303
|
+
artifact: null,
|
|
304
|
+
issues: [],
|
|
305
|
+
artifactPath,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
const parsed = JSON.parse((0, fs_1.readFileSync)(artifactPath, 'utf-8'));
|
|
310
|
+
const validation = validateLifecycleArtifactData(artifactPath, parsed);
|
|
311
|
+
const hasFatalValidationIssue = validation.issues.some((issue) => issue.severity === 'critical');
|
|
312
|
+
return {
|
|
313
|
+
exists: true,
|
|
314
|
+
valid: !hasFatalValidationIssue && validation.artifact !== null,
|
|
315
|
+
artifact: validation.artifact,
|
|
316
|
+
issues: validation.issues,
|
|
317
|
+
artifactPath,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
322
|
+
return {
|
|
323
|
+
exists: true,
|
|
324
|
+
valid: false,
|
|
325
|
+
artifact: null,
|
|
326
|
+
artifactPath,
|
|
327
|
+
error: message,
|
|
328
|
+
issues: [
|
|
329
|
+
buildIssue('lifecycle-artifact-corrupted', 'critical', 'Lifecycle artifact is corrupted', 'The lifecycle artifact could not be parsed as JSON.', artifactPath, true, 'Export a diagnostic report, then rebuild the artifact from a verified installation or backup.', 'high', true, ['read lifecycle artifact'], true, 'A repaired lifecycle artifact will replace the corrupted copy after confirmation.', 'refresh-artifact', [`Checked path: ${artifactPath}`, `Parse error: ${message}`]),
|
|
330
|
+
],
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function buildIssue(id, severity, title, message, pathLabel, blocksLifecycle, recommendedSolution, riskLevel, reversible, requiredPermissions, confirmationRequired, expectedResult, safeFix, evidence = []) {
|
|
335
|
+
return {
|
|
336
|
+
id,
|
|
337
|
+
severity,
|
|
338
|
+
title,
|
|
339
|
+
message,
|
|
340
|
+
evidence,
|
|
341
|
+
path: pathLabel,
|
|
342
|
+
blocksLifecycle,
|
|
343
|
+
recommendedSolution,
|
|
344
|
+
riskLevel,
|
|
345
|
+
reversible,
|
|
346
|
+
requiredPermissions,
|
|
347
|
+
confirmationRequired,
|
|
348
|
+
expectedResult,
|
|
349
|
+
safeFix,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function getLatestBackup(projectRoot) {
|
|
353
|
+
const root = getLifecycleBackupRoot(projectRoot);
|
|
354
|
+
if (!(0, fs_1.existsSync)(root)) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
const backupDirs = fs.readdirSync(root, { withFileTypes: true })
|
|
358
|
+
.filter((dirent) => dirent.isDirectory())
|
|
359
|
+
.map((dirent) => path.join(root, dirent.name))
|
|
360
|
+
.sort((a, b) => b.localeCompare(a));
|
|
361
|
+
for (const backupPath of backupDirs) {
|
|
362
|
+
const manifestPath = path.join(backupPath, 'manifest.json');
|
|
363
|
+
const manifest = safeReadJson(manifestPath);
|
|
364
|
+
if (manifest && typeof manifest.id === 'string') {
|
|
365
|
+
return manifest;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
function moduleUpgradeIssues(projectRoot, artifact) {
|
|
371
|
+
const loaded = (0, extensions_config_1.loadExtensionsConfig)(projectRoot);
|
|
372
|
+
if (!loaded.exists || !loaded.valid) {
|
|
373
|
+
return [];
|
|
374
|
+
}
|
|
375
|
+
const issues = [];
|
|
376
|
+
const modules = Array.isArray(loaded.config.modules) ? loaded.config.modules : [];
|
|
377
|
+
for (const moduleEntry of modules) {
|
|
378
|
+
const normalized = normalizeLinkedModuleRecord(moduleEntry);
|
|
379
|
+
const found = (0, module_system_1.findModule)(normalized.name);
|
|
380
|
+
if (!found) {
|
|
381
|
+
issues.push(buildIssue(`linked-module-missing:${normalized.name}`, 'warning', `Linked module missing from repository: ${normalized.name}`, `The linked module ${normalized.name} no longer resolves in this checkout.`, normalized.name, false, 'Re-link the module or remove the stale record from .augment/extensions.json.', 'medium', true, ['read module tree'], true, 'The stale record will be replaced or removed.', 'refresh-artifact', [`Linked module snapshot version: ${normalized.version}`]));
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const currentVersion = found.metadata.version;
|
|
385
|
+
try {
|
|
386
|
+
if ((0, module_system_1.compareSemanticVersions)(currentVersion, normalized.version) > 0) {
|
|
387
|
+
issues.push(buildIssue(`module-upgrade-available:${normalized.name}`, 'info', `Module upgrade available: ${normalized.name}`, `The repository now ships ${currentVersion}, which is newer than the linked version ${normalized.version}.`, normalized.name, false, `Run augx upgrade ${normalized.name} or augx update to refresh the linked module record.`, 'low', true, ['read module tree', 'write .augment/extensions.json'], false, 'The linked module record will match the latest local module version.', 'refresh-artifact', [`Linked version: ${normalized.version}`, `Repository version: ${currentVersion}`]));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (artifact && semver_1.default.valid(artifact.application.version) && semver_1.default.valid(readPackageVersion())) {
|
|
395
|
+
const currentAppVersion = readPackageVersion();
|
|
396
|
+
if (semver_1.default.gt(currentAppVersion, artifact.application.version)) {
|
|
397
|
+
issues.push(buildIssue('application-upgrade-available', 'info', 'Application upgrade available', `The stored lifecycle artifact records ${artifact.application.version}, but the current package is ${currentAppVersion}.`, getLifecycleArtifactPath(projectRoot), false, 'Run the CLI upgrade path for the package, then refresh the lifecycle artifact.', 'low', true, ['read package metadata'], false, 'The lifecycle artifact will reflect the current package version.', 'refresh-artifact', [`Stored application version: ${artifact.application.version}`, `Current application version: ${currentAppVersion}`]));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return issues;
|
|
401
|
+
}
|
|
402
|
+
function detectCoreIssues(projectRoot, artifact, artifactKnownPresent = Boolean(artifact)) {
|
|
403
|
+
const issues = [];
|
|
404
|
+
const configPath = path.join(projectRoot, AUGMENT_CONFIG_PATH);
|
|
405
|
+
const config = (0, extensions_config_1.loadExtensionsConfig)(projectRoot);
|
|
406
|
+
if (!config.exists) {
|
|
407
|
+
issues.push(buildIssue('missing-installation', 'critical', 'Augment Extensions is not installed', 'No .augment/extensions.json file was found in this project.', AUGMENT_CONFIG_PATH, true, 'Run augx init to create the project installation, or restore a retained lifecycle artifact.', 'high', true, ['write .augment'], false, 'A new .augment/extensions.json file will be created.', 'recreate-config', [`Checked path: ${configPath}`]));
|
|
408
|
+
return issues;
|
|
409
|
+
}
|
|
410
|
+
if (!config.valid) {
|
|
411
|
+
issues.push(buildIssue('invalid-installation-config', 'critical', 'The installation configuration is invalid', config.error || 'The .augment/extensions.json file could not be parsed.', AUGMENT_CONFIG_PATH, true, 'Restore the last backup or recreate the installation configuration from the lifecycle artifact.', 'high', true, ['write .augment'], true, 'A valid .augment/extensions.json file will replace the invalid one.', 'restore-backup', [`Checked path: ${configPath}`]));
|
|
412
|
+
return issues;
|
|
413
|
+
}
|
|
414
|
+
const modules = Array.isArray(config.config.modules) ? config.config.modules.map(normalizeLinkedModuleRecord) : [];
|
|
415
|
+
if (modules.length === 0 && !artifactKnownPresent) {
|
|
416
|
+
issues.push(buildIssue('installation-detected', 'info', 'Installation detected', 'The project has a valid .augment/extensions.json file, but no lifecycle artifact has been written yet.', AUGMENT_CONFIG_PATH, false, 'Run augx lifecycle status or augx lifecycle repair to create the canonical lifecycle artifact.', 'low', true, ['write .augment'], false, 'The lifecycle artifact will be created and the installation will be tracked.', 'refresh-artifact', ['A valid configuration file exists, but no lifecycle artifact is present.']));
|
|
417
|
+
}
|
|
418
|
+
const characterCountRule = path.join(projectRoot, AUGMENT_RULES_DIR, 'character-count-management.md');
|
|
419
|
+
if (!(0, fs_1.existsSync)(characterCountRule)) {
|
|
420
|
+
issues.push(buildIssue('missing-core-rule-character-count', 'high', 'Character count rule is missing', 'The canonical .augment/rules/character-count-management.md file is absent.', path.join(AUGMENT_RULES_DIR, 'character-count-management.md'), false, 'Run augx lifecycle repair to reinstall the core rule set.', 'medium', true, ['write .augment/rules'], false, 'The character count rule will be restored.', 'reinstall-core-rules', [`Checked path: ${characterCountRule}`]));
|
|
421
|
+
}
|
|
422
|
+
const emDashRule = path.join(projectRoot, AUGMENT_RULES_DIR, 'no-em-dash.md');
|
|
423
|
+
if (!(0, fs_1.existsSync)(emDashRule)) {
|
|
424
|
+
issues.push(buildIssue('missing-core-rule-em-dash', 'high', 'No-em-dash rule is missing', 'The canonical .augment/rules/no-em-dash.md file is absent.', path.join(AUGMENT_RULES_DIR, 'no-em-dash.md'), false, 'Run augx lifecycle repair to reinstall the core rule set.', 'medium', true, ['write .augment/rules'], false, 'The no-em-dash rule will be restored.', 'reinstall-core-rules', [`Checked path: ${emDashRule}`]));
|
|
425
|
+
}
|
|
426
|
+
const commandHelp = path.join(projectRoot, COMMAND_HELP_PATH);
|
|
427
|
+
if (!(0, fs_1.existsSync)(commandHelp)) {
|
|
428
|
+
issues.push(buildIssue('missing-command-help', 'warning', 'Command help reference is missing', 'The .augment/COMMAND_HELP.md file has not been generated.', COMMAND_HELP_PATH, false, 'Run augx lifecycle repair to regenerate command help.', 'low', true, ['write .augment'], false, 'The command help reference will be regenerated.', 'rebuild-command-help', [`Checked path: ${commandHelp}`]));
|
|
429
|
+
}
|
|
430
|
+
const promptsDir = path.join(projectRoot, AI_PROMPTS_DIR);
|
|
431
|
+
if (!(0, fs_1.existsSync)(promptsDir)) {
|
|
432
|
+
issues.push(buildIssue('missing-ai-prompts-directory', 'warning', 'ai-prompts directory is missing', 'The ai-prompts source directory could not be found in the project root.', AI_PROMPTS_DIR, false, 'Restore the directory from the repository or re-clone the checkout before continuing.', 'medium', true, ['read repository files'], false, 'The ai-prompts directory will be available again.', artifact?.archives.length ? 'restore-ai-prompts-directory' : undefined, [`Checked path: ${promptsDir}`]));
|
|
433
|
+
}
|
|
434
|
+
else if ((artifact?.archives ?? []).length === 0) {
|
|
435
|
+
issues.push(buildIssue('missing-ai-prompts-archive', 'info', 'ai-prompts archive is missing', 'The lifecycle artifact does not yet retain a ZIP archive of the ai-prompts directory.', AI_PROMPTS_DIR, false, 'Run augx lifecycle repair to archive ai-prompts safely.', 'low', true, ['write .augment/lifecycle'], false, 'A ZIP archive of ai-prompts will be retained in the lifecycle artifact.', 'rebuild-ai-prompts-archive', [`Checked path: ${promptsDir}`]));
|
|
436
|
+
}
|
|
437
|
+
const backup = getLatestBackup(projectRoot);
|
|
438
|
+
if (backup) {
|
|
439
|
+
issues.push(buildIssue('rollback-available', 'info', 'Rollback is available', `A backup exists at ${path.relative(projectRoot, backup.path)}`, path.relative(projectRoot, backup.path), false, 'Run augx lifecycle rollback to restore the retained backup if the current state is not correct.', 'low', true, ['read backup files', 'write .augment'], true, 'The last known good installation state will be restored.', 'restore-backup', [`Backup id: ${backup.id}`, `Backup reason: ${backup.reason}`]));
|
|
440
|
+
}
|
|
441
|
+
const artifactIssues = artifact?.issues ?? [];
|
|
442
|
+
for (const issue of artifactIssues) {
|
|
443
|
+
if (issue.severity === 'critical' || issue.severity === 'high') {
|
|
444
|
+
issues.push(issue);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
issues.push(...moduleUpgradeIssues(projectRoot, artifact));
|
|
448
|
+
return issues;
|
|
449
|
+
}
|
|
450
|
+
function deriveLifecycleStatus(projectRoot, artifact, issues) {
|
|
451
|
+
if (hasLifecycleValidationIssue(issues)) {
|
|
452
|
+
return 'recovery-required';
|
|
453
|
+
}
|
|
454
|
+
if (!artifact) {
|
|
455
|
+
const config = (0, extensions_config_1.loadExtensionsConfig)(projectRoot);
|
|
456
|
+
if (!config.exists) {
|
|
457
|
+
return 'not-installed';
|
|
458
|
+
}
|
|
459
|
+
if (!config.valid) {
|
|
460
|
+
return 'installation-failed';
|
|
461
|
+
}
|
|
462
|
+
return 'installation-detected';
|
|
463
|
+
}
|
|
464
|
+
if (artifact.lastOperation.status === 'running') {
|
|
465
|
+
switch (artifact.lastOperation.name) {
|
|
466
|
+
case 'init':
|
|
467
|
+
return 'installation-in-progress';
|
|
468
|
+
case 'upgrade':
|
|
469
|
+
case 'update':
|
|
470
|
+
return 'upgrade-in-progress';
|
|
471
|
+
case 'rollback':
|
|
472
|
+
return 'rollback-in-progress';
|
|
473
|
+
case 'self-remove':
|
|
474
|
+
return 'uninstallation-in-progress';
|
|
475
|
+
case 'repair':
|
|
476
|
+
return 'repair-in-progress';
|
|
477
|
+
case 'diagnose':
|
|
478
|
+
return 'diagnostic-analysis-in-progress';
|
|
479
|
+
default:
|
|
480
|
+
return 'diagnostic-analysis-in-progress';
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (artifact.lastOperation.status === 'failed') {
|
|
484
|
+
if (artifact.lastOperation.name === 'self-remove') {
|
|
485
|
+
return 'uninstallation-partially-completed';
|
|
486
|
+
}
|
|
487
|
+
if (artifact.lastOperation.name === 'rollback') {
|
|
488
|
+
return 'recovery-required';
|
|
489
|
+
}
|
|
490
|
+
return 'recovery-required';
|
|
491
|
+
}
|
|
492
|
+
if (!(0, fs_1.existsSync)(path.join(projectRoot, AUGMENT_CONFIG_PATH))) {
|
|
493
|
+
if (artifact.backups.length > 0) {
|
|
494
|
+
return 'rollback-available';
|
|
495
|
+
}
|
|
496
|
+
return 'recovery-required';
|
|
497
|
+
}
|
|
498
|
+
const config = (0, extensions_config_1.loadExtensionsConfig)(projectRoot);
|
|
499
|
+
if (!config.valid) {
|
|
500
|
+
return 'installation-failed';
|
|
501
|
+
}
|
|
502
|
+
const missingCoreFiles = issues.some((issue) => issue.safeFix === 'reinstall-core-rules' || issue.safeFix === 'rebuild-command-help');
|
|
503
|
+
if (missingCoreFiles) {
|
|
504
|
+
return 'installation-partially-completed';
|
|
505
|
+
}
|
|
506
|
+
if (issues.some((issue) => issue.id === 'rollback-available')) {
|
|
507
|
+
return 'rollback-available';
|
|
508
|
+
}
|
|
509
|
+
if (issues.some((issue) => issue.id === 'application-upgrade-available' || issue.id.startsWith('module-upgrade-available'))) {
|
|
510
|
+
return 'upgrade-available';
|
|
511
|
+
}
|
|
512
|
+
if (artifact.status === 'uninstallation-pending-confirmation') {
|
|
513
|
+
return 'uninstallation-pending-confirmation';
|
|
514
|
+
}
|
|
515
|
+
if (artifact.status === 'uninstallation-completed') {
|
|
516
|
+
return 'uninstallation-completed';
|
|
517
|
+
}
|
|
518
|
+
return 'installation-completed';
|
|
519
|
+
}
|
|
520
|
+
function createDefaultOperation(name) {
|
|
521
|
+
return {
|
|
522
|
+
name,
|
|
523
|
+
status: 'running',
|
|
524
|
+
startedAt: nowIso(),
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function mergeOperations(existing, override) {
|
|
528
|
+
if (!existing) {
|
|
529
|
+
return {
|
|
530
|
+
name: override?.name ?? 'diagnose',
|
|
531
|
+
status: override?.status ?? 'running',
|
|
532
|
+
startedAt: override?.startedAt ?? nowIso(),
|
|
533
|
+
finishedAt: override?.finishedAt,
|
|
534
|
+
error: override?.error,
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
...existing,
|
|
539
|
+
...override,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function loadLifecycleArtifact(projectRoot) {
|
|
543
|
+
const inspection = inspectLifecycleArtifact(projectRoot);
|
|
544
|
+
return inspection.valid ? inspection.artifact : null;
|
|
545
|
+
}
|
|
546
|
+
function writeLifecycleArtifact(projectRoot, artifact, options = {}) {
|
|
547
|
+
ensureLifecycleDirectories(projectRoot);
|
|
548
|
+
const artifactPath = getLifecycleArtifactPath(projectRoot);
|
|
549
|
+
if ((0, fs_1.existsSync)(artifactPath) && !options.allowOverwriteInvalidArtifact) {
|
|
550
|
+
const inspection = inspectLifecycleArtifact(projectRoot);
|
|
551
|
+
if (inspection.exists && !inspection.valid) {
|
|
552
|
+
throw new Error(`Refusing to overwrite an invalid lifecycle artifact without explicit recovery: ${artifactPath}`);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
writeJsonAtomic(artifactPath, artifact);
|
|
556
|
+
return artifact;
|
|
557
|
+
}
|
|
558
|
+
function refreshLifecycleArtifact(projectRoot, options = {}) {
|
|
559
|
+
const inspection = inspectLifecycleArtifact(projectRoot);
|
|
560
|
+
if (inspection.exists && !inspection.valid && !options.allowOverwriteInvalidArtifact) {
|
|
561
|
+
throw new Error(`Refusing to refresh an invalid lifecycle artifact without explicit recovery: ${inspection.artifactPath}`);
|
|
562
|
+
}
|
|
563
|
+
const existing = inspection.valid ? inspection.artifact : null;
|
|
564
|
+
const currentConfig = snapshotExtensionsConfig(projectRoot, existing ?? undefined);
|
|
565
|
+
const currentIssues = options.issues ??
|
|
566
|
+
(inspection.exists && !inspection.valid && options.allowOverwriteInvalidArtifact
|
|
567
|
+
? collectLifecycleIssuesWithoutArtifact(projectRoot)
|
|
568
|
+
: detectLifecycleIssues(projectRoot));
|
|
569
|
+
const currentStatus = options.status ?? deriveLifecycleStatus(projectRoot, existing, currentIssues);
|
|
570
|
+
const operation = mergeOperations(existing?.lastOperation, options.operation);
|
|
571
|
+
const backups = existing?.backups ? [...existing.backups] : [];
|
|
572
|
+
const archives = existing?.archives ? [...existing.archives] : [];
|
|
573
|
+
if (options.backup && !backups.some((item) => item.id === options.backup.id)) {
|
|
574
|
+
backups.push(options.backup);
|
|
575
|
+
}
|
|
576
|
+
if (options.archive && !archives.some((item) => item.id === options.archive.id)) {
|
|
577
|
+
archives.push(options.archive);
|
|
578
|
+
}
|
|
579
|
+
const artifact = {
|
|
580
|
+
schemaVersion: LIFECYCLE_SCHEMA_VERSION,
|
|
581
|
+
application: {
|
|
582
|
+
name: 'augment-extensions',
|
|
583
|
+
version: readPackageVersion(),
|
|
584
|
+
},
|
|
585
|
+
projectRoot: path.resolve(projectRoot),
|
|
586
|
+
status: currentStatus,
|
|
587
|
+
createdAt: existing?.createdAt ?? nowIso(),
|
|
588
|
+
updatedAt: nowIso(),
|
|
589
|
+
lastOperation: operation,
|
|
590
|
+
extensionsConfig: currentConfig,
|
|
591
|
+
backups,
|
|
592
|
+
archives,
|
|
593
|
+
issues: currentIssues,
|
|
594
|
+
notes: options.notes,
|
|
595
|
+
};
|
|
596
|
+
return writeLifecycleArtifact(projectRoot, artifact, {
|
|
597
|
+
allowOverwriteInvalidArtifact: options.allowOverwriteInvalidArtifact,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
function createLifecycleOperation(name) {
|
|
601
|
+
return createDefaultOperation(name);
|
|
602
|
+
}
|
|
603
|
+
function completeLifecycleOperation(operation, status, error) {
|
|
604
|
+
return {
|
|
605
|
+
...operation,
|
|
606
|
+
status,
|
|
607
|
+
finishedAt: nowIso(),
|
|
608
|
+
error,
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function createLifecycleBackup(projectRoot, reason) {
|
|
612
|
+
ensureLifecycleDirectories(projectRoot);
|
|
613
|
+
const backupId = nowIso().replace(/[:.]/g, '-');
|
|
614
|
+
const backupDir = path.join(getLifecycleBackupRoot(projectRoot), backupId);
|
|
615
|
+
(0, fs_1.mkdirSync)(backupDir, { recursive: true });
|
|
616
|
+
const files = [];
|
|
617
|
+
const candidates = [
|
|
618
|
+
AUGMENT_CONFIG_PATH,
|
|
619
|
+
path.join('.augment', LIFECYCLE_ARTIFACT_FILE),
|
|
620
|
+
COMMAND_HELP_PATH,
|
|
621
|
+
path.join('.vscode', 'extensions.json'),
|
|
622
|
+
];
|
|
623
|
+
for (const relativePath of candidates) {
|
|
624
|
+
const sourcePath = path.join(projectRoot, relativePath);
|
|
625
|
+
if (!(0, fs_1.existsSync)(sourcePath)) {
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
const targetPath = path.join(backupDir, relativePath);
|
|
629
|
+
(0, fs_1.mkdirSync)(path.dirname(targetPath), { recursive: true });
|
|
630
|
+
(0, fs_1.copyFileSync)(sourcePath, targetPath);
|
|
631
|
+
files.push({
|
|
632
|
+
path: relativePath,
|
|
633
|
+
checksum: (0, zip_archive_1.checksumFile)(targetPath),
|
|
634
|
+
size: fs.statSync(targetPath).size,
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
const backup = {
|
|
638
|
+
id: backupId,
|
|
639
|
+
createdAt: nowIso(),
|
|
640
|
+
reason,
|
|
641
|
+
path: backupDir,
|
|
642
|
+
files,
|
|
643
|
+
};
|
|
644
|
+
writeJsonAtomic(path.join(backupDir, 'manifest.json'), backup);
|
|
645
|
+
return backup;
|
|
646
|
+
}
|
|
647
|
+
function restoreLifecycleBackup(projectRoot, backup) {
|
|
648
|
+
for (const file of backup.files) {
|
|
649
|
+
const backupFilePath = path.join(backup.path, file.path);
|
|
650
|
+
if (!(0, fs_1.existsSync)(backupFilePath)) {
|
|
651
|
+
throw new Error(`Backup file missing: ${backupFilePath}`);
|
|
652
|
+
}
|
|
653
|
+
if ((0, zip_archive_1.checksumFile)(backupFilePath) !== file.checksum) {
|
|
654
|
+
throw new Error(`Backup checksum mismatch: ${backupFilePath}`);
|
|
655
|
+
}
|
|
656
|
+
const targetPath = path.join(projectRoot, file.path);
|
|
657
|
+
(0, fs_1.mkdirSync)(path.dirname(targetPath), { recursive: true });
|
|
658
|
+
(0, fs_1.copyFileSync)(backupFilePath, targetPath);
|
|
659
|
+
}
|
|
660
|
+
return backup;
|
|
661
|
+
}
|
|
662
|
+
function restoreExtensionsConfigFromArtifact(projectRoot) {
|
|
663
|
+
const inspection = inspectLifecycleArtifact(projectRoot);
|
|
664
|
+
if (!inspection.valid || !inspection.artifact) {
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
ensureLifecycleDirectories(projectRoot);
|
|
668
|
+
const configPath = path.join(projectRoot, AUGMENT_CONFIG_PATH);
|
|
669
|
+
const config = {
|
|
670
|
+
...stableClone(inspection.artifact.extensionsConfig),
|
|
671
|
+
modules: Array.isArray(inspection.artifact.extensionsConfig.modules)
|
|
672
|
+
? inspection.artifact.extensionsConfig.modules.map((entry) => normalizeLinkedModuleRecord(entry))
|
|
673
|
+
: [],
|
|
674
|
+
};
|
|
675
|
+
(0, fs_1.mkdirSync)(path.dirname(configPath), { recursive: true });
|
|
676
|
+
writeJsonAtomic(configPath, config);
|
|
677
|
+
return refreshLifecycleArtifact(projectRoot, {
|
|
678
|
+
status: 'installation-completed',
|
|
679
|
+
operation: {
|
|
680
|
+
name: 'repair',
|
|
681
|
+
status: 'succeeded',
|
|
682
|
+
startedAt: nowIso(),
|
|
683
|
+
finishedAt: nowIso(),
|
|
684
|
+
},
|
|
685
|
+
notes: ['Restored .augment/extensions.json from the retained lifecycle artifact.'],
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
function createAiPromptsArchive(projectRoot, reason) {
|
|
689
|
+
const promptsDir = path.join(projectRoot, AI_PROMPTS_DIR);
|
|
690
|
+
if (!(0, fs_1.existsSync)(promptsDir)) {
|
|
691
|
+
throw new Error(`Source directory not found: ${promptsDir}`);
|
|
692
|
+
}
|
|
693
|
+
ensureLifecycleDirectories(projectRoot);
|
|
694
|
+
const archiveId = nowIso().replace(/[:.]/g, '-');
|
|
695
|
+
const archivePath = path.join(getLifecycleArchiveRoot(projectRoot), `${archiveId}.zip`);
|
|
696
|
+
const archiveResult = (0, zip_archive_1.createZipArchiveFromDirectory)(promptsDir, archivePath, {
|
|
697
|
+
rootFolder: AI_PROMPTS_DIR,
|
|
698
|
+
});
|
|
699
|
+
return {
|
|
700
|
+
id: archiveId,
|
|
701
|
+
createdAt: nowIso(),
|
|
702
|
+
path: archiveResult.path,
|
|
703
|
+
checksum: archiveResult.checksum,
|
|
704
|
+
source: reason,
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
async function restoreAiPromptsArchive(zipPath, destinationDir) {
|
|
708
|
+
return (0, zip_archive_1.extractZipArchiveSafely)(zipPath, destinationDir, { force: true });
|
|
709
|
+
}
|
|
710
|
+
function collectLifecycleIssues(projectRoot, inspection) {
|
|
711
|
+
const issues = [...inspection.issues];
|
|
712
|
+
const artifact = inspection.artifact;
|
|
713
|
+
issues.push(...detectCoreIssues(projectRoot, artifact, inspection.exists));
|
|
714
|
+
if (artifact) {
|
|
715
|
+
for (const issue of artifact.issues) {
|
|
716
|
+
if (issue.severity === 'critical' || issue.severity === 'high') {
|
|
717
|
+
issues.push(issue);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
issues.push(...moduleUpgradeIssues(projectRoot, artifact));
|
|
722
|
+
const deduped = new Map();
|
|
723
|
+
for (const issue of issues) {
|
|
724
|
+
if (!deduped.has(issue.id)) {
|
|
725
|
+
deduped.set(issue.id, issue);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return Array.from(deduped.values());
|
|
729
|
+
}
|
|
730
|
+
function collectLifecycleIssuesWithoutArtifact(projectRoot) {
|
|
731
|
+
return collectLifecycleIssues(projectRoot, {
|
|
732
|
+
exists: false,
|
|
733
|
+
valid: true,
|
|
734
|
+
artifact: null,
|
|
735
|
+
issues: [],
|
|
736
|
+
artifactPath: getLifecycleArtifactPath(projectRoot),
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
function createDiagnosticArtifact(projectRoot, inspection, status, issues) {
|
|
740
|
+
const now = nowIso();
|
|
741
|
+
const artifact = inspection.artifact;
|
|
742
|
+
return {
|
|
743
|
+
schemaVersion: LIFECYCLE_SCHEMA_VERSION,
|
|
744
|
+
application: {
|
|
745
|
+
name: LIFECYCLE_APPLICATION_NAME,
|
|
746
|
+
version: readPackageVersion(),
|
|
747
|
+
},
|
|
748
|
+
projectRoot: path.resolve(projectRoot),
|
|
749
|
+
status,
|
|
750
|
+
createdAt: artifact?.createdAt ?? now,
|
|
751
|
+
updatedAt: now,
|
|
752
|
+
lastOperation: artifact?.lastOperation ?? {
|
|
753
|
+
name: 'diagnose',
|
|
754
|
+
status: 'failed',
|
|
755
|
+
startedAt: now,
|
|
756
|
+
finishedAt: now,
|
|
757
|
+
error: inspection.error ?? 'Lifecycle artifact validation failed.',
|
|
758
|
+
},
|
|
759
|
+
extensionsConfig: artifact?.extensionsConfig ?? snapshotExtensionsConfig(projectRoot),
|
|
760
|
+
backups: artifact?.backups ?? [],
|
|
761
|
+
archives: artifact?.archives ?? [],
|
|
762
|
+
issues,
|
|
763
|
+
notes: artifact?.notes,
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
function createLifecycleSnapshotFromArtifact(projectRoot, artifact, issues) {
|
|
767
|
+
const repairableIssues = issues.filter((issue) => Boolean(issue.safeFix));
|
|
768
|
+
const latestBackup = getLatestBackup(projectRoot);
|
|
769
|
+
const status = deriveLifecycleStatus(projectRoot, artifact, issues);
|
|
770
|
+
return {
|
|
771
|
+
status,
|
|
772
|
+
issues,
|
|
773
|
+
repairableIssues,
|
|
774
|
+
backupCount: artifact.backups.length,
|
|
775
|
+
archiveCount: artifact.archives.length,
|
|
776
|
+
installedModuleCount: Array.isArray(artifact.extensionsConfig.modules)
|
|
777
|
+
? artifact.extensionsConfig.modules.length
|
|
778
|
+
: 0,
|
|
779
|
+
rollbackAvailable: Boolean(latestBackup),
|
|
780
|
+
upgradeAvailable: issues.some((issue) => issue.id === 'application-upgrade-available' || issue.id.startsWith('module-upgrade-available')),
|
|
781
|
+
artifact,
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
function detectLifecycleIssues(projectRoot) {
|
|
785
|
+
return collectLifecycleIssues(projectRoot, inspectLifecycleArtifact(projectRoot));
|
|
786
|
+
}
|
|
787
|
+
function buildLifecycleSnapshot(projectRoot) {
|
|
788
|
+
const inspection = inspectLifecycleArtifact(projectRoot);
|
|
789
|
+
const issues = collectLifecycleIssues(projectRoot, inspection);
|
|
790
|
+
const status = deriveLifecycleStatus(projectRoot, inspection.artifact, issues);
|
|
791
|
+
let artifact;
|
|
792
|
+
if (inspection.exists && !inspection.valid) {
|
|
793
|
+
artifact = createDiagnosticArtifact(projectRoot, inspection, status, issues);
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
artifact = refreshLifecycleArtifact(projectRoot, {
|
|
797
|
+
status,
|
|
798
|
+
operation: {
|
|
799
|
+
name: 'diagnose',
|
|
800
|
+
status: 'succeeded',
|
|
801
|
+
startedAt: nowIso(),
|
|
802
|
+
finishedAt: nowIso(),
|
|
803
|
+
},
|
|
804
|
+
issues,
|
|
805
|
+
allowOverwriteInvalidArtifact: true,
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
return createLifecycleSnapshotFromArtifact(projectRoot, artifact, issues);
|
|
809
|
+
}
|
|
810
|
+
function exportLifecycleReport(snapshot) {
|
|
811
|
+
return {
|
|
812
|
+
schemaVersion: LIFECYCLE_SCHEMA_VERSION,
|
|
813
|
+
generatedAt: nowIso(),
|
|
814
|
+
status: snapshot.status,
|
|
815
|
+
installedModuleCount: snapshot.installedModuleCount,
|
|
816
|
+
backupCount: snapshot.backupCount,
|
|
817
|
+
archiveCount: snapshot.archiveCount,
|
|
818
|
+
upgradeAvailable: snapshot.upgradeAvailable,
|
|
819
|
+
rollbackAvailable: snapshot.rollbackAvailable,
|
|
820
|
+
issues: snapshot.issues.map((issue) => ({
|
|
821
|
+
...issue,
|
|
822
|
+
evidence: issue.evidence.map((value) => value.includes('\\') || value.includes('/') ? '<redacted-path>' : value),
|
|
823
|
+
})),
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function writeLifecycleReportFile(projectRoot, snapshot, outputPath) {
|
|
827
|
+
ensureLifecycleDirectories(projectRoot);
|
|
828
|
+
const reportId = nowIso().replace(/[:.]/g, '-');
|
|
829
|
+
const reportPath = outputPath
|
|
830
|
+
? path.resolve(projectRoot, outputPath)
|
|
831
|
+
: path.join(getLifecycleReportRoot(projectRoot), `${reportId}.json`);
|
|
832
|
+
writeJsonAtomic(reportPath, exportLifecycleReport(snapshot));
|
|
833
|
+
return reportPath;
|
|
834
|
+
}
|
|
835
|
+
function listSafeFixes(snapshot) {
|
|
836
|
+
return Array.from(new Set(snapshot.repairableIssues.map((issue) => issue.safeFix).filter(Boolean)));
|
|
837
|
+
}
|
|
838
|
+
function getLatestLifecycleBackup(projectRoot) {
|
|
839
|
+
return getLatestBackup(projectRoot);
|
|
840
|
+
}
|
|
841
|
+
//# sourceMappingURL=lifecycle.js.map
|