@bobby_z/openspec 0.0.1
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/LICENSE +22 -0
- package/README.md +204 -0
- package/bin/openspec.js +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +482 -0
- package/dist/commands/change.d.ts +35 -0
- package/dist/commands/change.js +277 -0
- package/dist/commands/completion.d.ts +72 -0
- package/dist/commands/completion.js +257 -0
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.js +198 -0
- package/dist/commands/feedback.d.ts +9 -0
- package/dist/commands/feedback.js +183 -0
- package/dist/commands/schema.d.ts +6 -0
- package/dist/commands/schema.js +869 -0
- package/dist/commands/show.d.ts +14 -0
- package/dist/commands/show.js +132 -0
- package/dist/commands/spec.d.ts +15 -0
- package/dist/commands/spec.js +225 -0
- package/dist/commands/validate.d.ts +24 -0
- package/dist/commands/validate.js +294 -0
- package/dist/commands/workflow/index.d.ts +17 -0
- package/dist/commands/workflow/index.js +12 -0
- package/dist/commands/workflow/instructions.d.ts +29 -0
- package/dist/commands/workflow/instructions.js +381 -0
- package/dist/commands/workflow/new-change.d.ts +11 -0
- package/dist/commands/workflow/new-change.js +44 -0
- package/dist/commands/workflow/schemas.d.ts +10 -0
- package/dist/commands/workflow/schemas.js +34 -0
- package/dist/commands/workflow/shared.d.ts +52 -0
- package/dist/commands/workflow/shared.js +111 -0
- package/dist/commands/workflow/status.d.ts +14 -0
- package/dist/commands/workflow/status.js +58 -0
- package/dist/commands/workflow/templates.d.ts +16 -0
- package/dist/commands/workflow/templates.js +68 -0
- package/dist/core/archive.d.ts +11 -0
- package/dist/core/archive.js +328 -0
- package/dist/core/artifact-graph/graph.d.ts +56 -0
- package/dist/core/artifact-graph/graph.js +141 -0
- package/dist/core/artifact-graph/index.d.ts +7 -0
- package/dist/core/artifact-graph/index.js +13 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +143 -0
- package/dist/core/artifact-graph/instruction-loader.js +214 -0
- package/dist/core/artifact-graph/resolver.d.ts +81 -0
- package/dist/core/artifact-graph/resolver.js +257 -0
- package/dist/core/artifact-graph/schema.d.ts +13 -0
- package/dist/core/artifact-graph/schema.js +108 -0
- package/dist/core/artifact-graph/state.d.ts +12 -0
- package/dist/core/artifact-graph/state.js +54 -0
- package/dist/core/artifact-graph/types.d.ts +45 -0
- package/dist/core/artifact-graph/types.js +43 -0
- package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
- package/dist/core/command-generation/adapters/amazon-q.js +26 -0
- package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
- package/dist/core/command-generation/adapters/antigravity.js +26 -0
- package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
- package/dist/core/command-generation/adapters/auggie.js +27 -0
- package/dist/core/command-generation/adapters/claude.d.ts +13 -0
- package/dist/core/command-generation/adapters/claude.js +50 -0
- package/dist/core/command-generation/adapters/cline.d.ts +14 -0
- package/dist/core/command-generation/adapters/cline.js +27 -0
- package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
- package/dist/core/command-generation/adapters/codebuddy.js +28 -0
- package/dist/core/command-generation/adapters/codex.d.ts +16 -0
- package/dist/core/command-generation/adapters/codex.js +39 -0
- package/dist/core/command-generation/adapters/continue.d.ts +13 -0
- package/dist/core/command-generation/adapters/continue.js +28 -0
- package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
- package/dist/core/command-generation/adapters/costrict.js +27 -0
- package/dist/core/command-generation/adapters/crush.d.ts +13 -0
- package/dist/core/command-generation/adapters/crush.js +30 -0
- package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
- package/dist/core/command-generation/adapters/cursor.js +44 -0
- package/dist/core/command-generation/adapters/devagent.d.ts +15 -0
- package/dist/core/command-generation/adapters/devagent.js +28 -0
- package/dist/core/command-generation/adapters/factory.d.ts +13 -0
- package/dist/core/command-generation/adapters/factory.js +27 -0
- package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
- package/dist/core/command-generation/adapters/gemini.js +26 -0
- package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
- package/dist/core/command-generation/adapters/github-copilot.js +26 -0
- package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
- package/dist/core/command-generation/adapters/iflow.js +29 -0
- package/dist/core/command-generation/adapters/index.d.ts +28 -0
- package/dist/core/command-generation/adapters/index.js +28 -0
- package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/kilocode.js +23 -0
- package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
- package/dist/core/command-generation/adapters/opencode.js +29 -0
- package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
- package/dist/core/command-generation/adapters/qoder.js +30 -0
- package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
- package/dist/core/command-generation/adapters/qwen.js +26 -0
- package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/roocode.js +27 -0
- package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
- package/dist/core/command-generation/adapters/windsurf.js +51 -0
- package/dist/core/command-generation/generator.d.ts +21 -0
- package/dist/core/command-generation/generator.js +27 -0
- package/dist/core/command-generation/index.d.ts +22 -0
- package/dist/core/command-generation/index.js +24 -0
- package/dist/core/command-generation/registry.d.ts +36 -0
- package/dist/core/command-generation/registry.js +90 -0
- package/dist/core/command-generation/types.d.ts +56 -0
- package/dist/core/command-generation/types.js +8 -0
- package/dist/core/completions/command-registry.d.ts +7 -0
- package/dist/core/completions/command-registry.js +454 -0
- package/dist/core/completions/completion-provider.d.ts +60 -0
- package/dist/core/completions/completion-provider.js +102 -0
- package/dist/core/completions/factory.d.ts +64 -0
- package/dist/core/completions/factory.js +75 -0
- package/dist/core/completions/generators/bash-generator.d.ts +32 -0
- package/dist/core/completions/generators/bash-generator.js +174 -0
- package/dist/core/completions/generators/fish-generator.d.ts +32 -0
- package/dist/core/completions/generators/fish-generator.js +157 -0
- package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
- package/dist/core/completions/generators/powershell-generator.js +207 -0
- package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
- package/dist/core/completions/generators/zsh-generator.js +250 -0
- package/dist/core/completions/installers/bash-installer.d.ts +87 -0
- package/dist/core/completions/installers/bash-installer.js +318 -0
- package/dist/core/completions/installers/fish-installer.d.ts +43 -0
- package/dist/core/completions/installers/fish-installer.js +143 -0
- package/dist/core/completions/installers/powershell-installer.d.ts +88 -0
- package/dist/core/completions/installers/powershell-installer.js +327 -0
- package/dist/core/completions/installers/zsh-installer.d.ts +125 -0
- package/dist/core/completions/installers/zsh-installer.js +449 -0
- package/dist/core/completions/templates/bash-templates.d.ts +6 -0
- package/dist/core/completions/templates/bash-templates.js +24 -0
- package/dist/core/completions/templates/fish-templates.d.ts +7 -0
- package/dist/core/completions/templates/fish-templates.js +39 -0
- package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
- package/dist/core/completions/templates/powershell-templates.js +25 -0
- package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
- package/dist/core/completions/templates/zsh-templates.js +36 -0
- package/dist/core/completions/types.d.ts +79 -0
- package/dist/core/completions/types.js +2 -0
- package/dist/core/config-prompts.d.ts +9 -0
- package/dist/core/config-prompts.js +34 -0
- package/dist/core/config-schema.d.ts +76 -0
- package/dist/core/config-schema.js +200 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.js +175 -0
- package/dist/core/converters/json-converter.d.ts +6 -0
- package/dist/core/converters/json-converter.js +51 -0
- package/dist/core/global-config.d.ts +39 -0
- package/dist/core/global-config.js +115 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +3 -0
- package/dist/core/init.d.ts +32 -0
- package/dist/core/init.js +447 -0
- package/dist/core/legacy-cleanup.d.ts +162 -0
- package/dist/core/legacy-cleanup.js +520 -0
- package/dist/core/list.d.ts +9 -0
- package/dist/core/list.js +171 -0
- package/dist/core/parsers/change-parser.d.ts +13 -0
- package/dist/core/parsers/change-parser.js +193 -0
- package/dist/core/parsers/markdown-parser.d.ts +22 -0
- package/dist/core/parsers/markdown-parser.js +187 -0
- package/dist/core/parsers/requirement-blocks.d.ts +37 -0
- package/dist/core/parsers/requirement-blocks.js +201 -0
- package/dist/core/project-config.d.ts +64 -0
- package/dist/core/project-config.js +223 -0
- package/dist/core/schemas/base.schema.d.ts +13 -0
- package/dist/core/schemas/base.schema.js +13 -0
- package/dist/core/schemas/change.schema.d.ts +73 -0
- package/dist/core/schemas/change.schema.js +31 -0
- package/dist/core/schemas/index.d.ts +4 -0
- package/dist/core/schemas/index.js +4 -0
- package/dist/core/schemas/spec.schema.d.ts +18 -0
- package/dist/core/schemas/spec.schema.js +15 -0
- package/dist/core/shared/index.d.ts +8 -0
- package/dist/core/shared/index.js +8 -0
- package/dist/core/shared/skill-generation.d.ts +42 -0
- package/dist/core/shared/skill-generation.js +80 -0
- package/dist/core/shared/tool-detection.d.ts +66 -0
- package/dist/core/shared/tool-detection.js +140 -0
- package/dist/core/specs-apply.d.ts +73 -0
- package/dist/core/specs-apply.js +384 -0
- package/dist/core/styles/palette.d.ts +7 -0
- package/dist/core/styles/palette.js +8 -0
- package/dist/core/templates/index.d.ts +8 -0
- package/dist/core/templates/index.js +9 -0
- package/dist/core/templates/skill-templates.d.ts +122 -0
- package/dist/core/templates/skill-templates.js +3437 -0
- package/dist/core/update.d.ts +42 -0
- package/dist/core/update.js +311 -0
- package/dist/core/validation/constants.d.ts +34 -0
- package/dist/core/validation/constants.js +40 -0
- package/dist/core/validation/types.d.ts +18 -0
- package/dist/core/validation/types.js +2 -0
- package/dist/core/validation/validator.d.ts +33 -0
- package/dist/core/validation/validator.js +409 -0
- package/dist/core/view.d.ts +8 -0
- package/dist/core/view.js +168 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/prompts/searchable-multi-select.d.ts +27 -0
- package/dist/prompts/searchable-multi-select.js +149 -0
- package/dist/telemetry/config.d.ts +32 -0
- package/dist/telemetry/config.js +68 -0
- package/dist/telemetry/index.d.ts +31 -0
- package/dist/telemetry/index.js +145 -0
- package/dist/ui/ascii-patterns.d.ts +16 -0
- package/dist/ui/ascii-patterns.js +133 -0
- package/dist/ui/welcome-screen.d.ts +10 -0
- package/dist/ui/welcome-screen.js +146 -0
- package/dist/utils/change-metadata.d.ts +51 -0
- package/dist/utils/change-metadata.js +147 -0
- package/dist/utils/change-utils.d.ts +62 -0
- package/dist/utils/change-utils.js +121 -0
- package/dist/utils/command-references.d.ts +18 -0
- package/dist/utils/command-references.js +20 -0
- package/dist/utils/file-system.d.ts +36 -0
- package/dist/utils/file-system.js +281 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/interactive.d.ts +18 -0
- package/dist/utils/interactive.js +21 -0
- package/dist/utils/item-discovery.d.ts +4 -0
- package/dist/utils/item-discovery.js +72 -0
- package/dist/utils/match.d.ts +3 -0
- package/dist/utils/match.js +22 -0
- package/dist/utils/shell-detection.d.ts +20 -0
- package/dist/utils/shell-detection.js +41 -0
- package/dist/utils/task-progress.d.ts +8 -0
- package/dist/utils/task-progress.js +36 -0
- package/package.json +83 -0
- package/schemas/spec-driven/schema.yaml +151 -0
- package/schemas/spec-driven/templates/design.md +21 -0
- package/schemas/spec-driven/templates/proposal.md +25 -0
- package/schemas/spec-driven/templates/spec.md +10 -0
- package/schemas/spec-driven/templates/tasks.md +9 -0
- package/scripts/postinstall.js +147 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Command
|
|
3
|
+
*
|
|
4
|
+
* Displays artifact completion status for a change.
|
|
5
|
+
*/
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { loadChangeContext, formatChangeStatus, } from '../../core/artifact-graph/index.js';
|
|
9
|
+
import { validateChangeExists, validateSchemaExists, getStatusIndicator, getStatusColor, } from './shared.js';
|
|
10
|
+
// -----------------------------------------------------------------------------
|
|
11
|
+
// Command Implementation
|
|
12
|
+
// -----------------------------------------------------------------------------
|
|
13
|
+
export async function statusCommand(options) {
|
|
14
|
+
const spinner = ora('Loading change status...').start();
|
|
15
|
+
try {
|
|
16
|
+
const projectRoot = process.cwd();
|
|
17
|
+
const changeName = await validateChangeExists(options.change, projectRoot);
|
|
18
|
+
// Validate schema if explicitly provided
|
|
19
|
+
if (options.schema) {
|
|
20
|
+
validateSchemaExists(options.schema, projectRoot);
|
|
21
|
+
}
|
|
22
|
+
// loadChangeContext will auto-detect schema from metadata if not provided
|
|
23
|
+
const context = loadChangeContext(projectRoot, changeName, options.schema);
|
|
24
|
+
const status = formatChangeStatus(context);
|
|
25
|
+
spinner.stop();
|
|
26
|
+
if (options.json) {
|
|
27
|
+
console.log(JSON.stringify(status, null, 2));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
printStatusText(status);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
spinner.stop();
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function printStatusText(status) {
|
|
38
|
+
const doneCount = status.artifacts.filter((a) => a.status === 'done').length;
|
|
39
|
+
const total = status.artifacts.length;
|
|
40
|
+
console.log(`Change: ${status.changeName}`);
|
|
41
|
+
console.log(`Schema: ${status.schemaName}`);
|
|
42
|
+
console.log(`Progress: ${doneCount}/${total} artifacts complete`);
|
|
43
|
+
console.log();
|
|
44
|
+
for (const artifact of status.artifacts) {
|
|
45
|
+
const indicator = getStatusIndicator(artifact.status);
|
|
46
|
+
const color = getStatusColor(artifact.status);
|
|
47
|
+
let line = `${indicator} ${artifact.id}`;
|
|
48
|
+
if (artifact.status === 'blocked' && artifact.missingDeps && artifact.missingDeps.length > 0) {
|
|
49
|
+
line += color(` (blocked by: ${artifact.missingDeps.join(', ')})`);
|
|
50
|
+
}
|
|
51
|
+
console.log(line);
|
|
52
|
+
}
|
|
53
|
+
if (status.isComplete) {
|
|
54
|
+
console.log();
|
|
55
|
+
console.log(chalk.green('All artifacts complete!'));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Templates Command
|
|
3
|
+
*
|
|
4
|
+
* Shows resolved template paths for all artifacts in a schema.
|
|
5
|
+
*/
|
|
6
|
+
export interface TemplatesOptions {
|
|
7
|
+
schema?: string;
|
|
8
|
+
json?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface TemplateInfo {
|
|
11
|
+
artifactId: string;
|
|
12
|
+
templatePath: string;
|
|
13
|
+
source: 'project' | 'user' | 'package';
|
|
14
|
+
}
|
|
15
|
+
export declare function templatesCommand(options: TemplatesOptions): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Templates Command
|
|
3
|
+
*
|
|
4
|
+
* Shows resolved template paths for all artifacts in a schema.
|
|
5
|
+
*/
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { resolveSchema, getSchemaDir, ArtifactGraph, } from '../../core/artifact-graph/index.js';
|
|
9
|
+
import { validateSchemaExists, DEFAULT_SCHEMA } from './shared.js';
|
|
10
|
+
// -----------------------------------------------------------------------------
|
|
11
|
+
// Command Implementation
|
|
12
|
+
// -----------------------------------------------------------------------------
|
|
13
|
+
export async function templatesCommand(options) {
|
|
14
|
+
const spinner = ora('Loading templates...').start();
|
|
15
|
+
try {
|
|
16
|
+
const projectRoot = process.cwd();
|
|
17
|
+
const schemaName = validateSchemaExists(options.schema ?? DEFAULT_SCHEMA, projectRoot);
|
|
18
|
+
const schema = resolveSchema(schemaName, projectRoot);
|
|
19
|
+
const graph = ArtifactGraph.fromSchema(schema);
|
|
20
|
+
const schemaDir = getSchemaDir(schemaName, projectRoot);
|
|
21
|
+
// Determine the source (project, user, or package)
|
|
22
|
+
const { getUserSchemasDir, getProjectSchemasDir, } = await import('../../core/artifact-graph/resolver.js');
|
|
23
|
+
const projectSchemasDir = getProjectSchemasDir(projectRoot);
|
|
24
|
+
const userSchemasDir = getUserSchemasDir();
|
|
25
|
+
// Determine source by checking if schemaDir is inside each base directory
|
|
26
|
+
// Using path.relative is more robust than startsWith for path comparisons
|
|
27
|
+
const isInsideDir = (child, parent) => {
|
|
28
|
+
const relative = path.relative(parent, child);
|
|
29
|
+
return !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
30
|
+
};
|
|
31
|
+
let source;
|
|
32
|
+
if (isInsideDir(schemaDir, projectSchemasDir)) {
|
|
33
|
+
source = 'project';
|
|
34
|
+
}
|
|
35
|
+
else if (isInsideDir(schemaDir, userSchemasDir)) {
|
|
36
|
+
source = 'user';
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
source = 'package';
|
|
40
|
+
}
|
|
41
|
+
const templates = graph.getAllArtifacts().map((artifact) => ({
|
|
42
|
+
artifactId: artifact.id,
|
|
43
|
+
templatePath: path.join(schemaDir, 'templates', artifact.template),
|
|
44
|
+
source,
|
|
45
|
+
}));
|
|
46
|
+
spinner.stop();
|
|
47
|
+
if (options.json) {
|
|
48
|
+
const output = {};
|
|
49
|
+
for (const t of templates) {
|
|
50
|
+
output[t.artifactId] = { path: t.templatePath, source: t.source };
|
|
51
|
+
}
|
|
52
|
+
console.log(JSON.stringify(output, null, 2));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
console.log(`Schema: ${schemaName}`);
|
|
56
|
+
console.log(`Source: ${source}`);
|
|
57
|
+
console.log();
|
|
58
|
+
for (const t of templates) {
|
|
59
|
+
console.log(`${t.artifactId}:`);
|
|
60
|
+
console.log(` ${t.templatePath}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
spinner.stop();
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class ArchiveCommand {
|
|
2
|
+
execute(changeName?: string, options?: {
|
|
3
|
+
yes?: boolean;
|
|
4
|
+
skipSpecs?: boolean;
|
|
5
|
+
noValidate?: boolean;
|
|
6
|
+
validate?: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
private selectChange;
|
|
9
|
+
private getArchiveDate;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { getTaskProgressForChange, formatTaskStatus, } from "../utils/task-progress.js";
|
|
4
|
+
import { Validator } from "./validation/validator.js";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { findSpecUpdates, buildUpdatedSpec, writeUpdatedSpec, } from "./specs-apply.js";
|
|
7
|
+
/**
|
|
8
|
+
* Recursively copy a directory. Used when fs.rename fails (e.g. EPERM on Windows).
|
|
9
|
+
*/
|
|
10
|
+
async function copyDirRecursive(src, dest) {
|
|
11
|
+
await fs.mkdir(dest, { recursive: true });
|
|
12
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
const srcPath = path.join(src, entry.name);
|
|
15
|
+
const destPath = path.join(dest, entry.name);
|
|
16
|
+
if (entry.isDirectory()) {
|
|
17
|
+
await copyDirRecursive(srcPath, destPath);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
await fs.copyFile(srcPath, destPath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Move a directory from src to dest. On Windows, fs.rename() often fails with
|
|
26
|
+
* EPERM when the directory is non-empty or another process has it open (IDE,
|
|
27
|
+
* file watcher, antivirus). Fall back to copy-then-remove when rename fails
|
|
28
|
+
* with EPERM or EXDEV.
|
|
29
|
+
*/
|
|
30
|
+
async function moveDirectory(src, dest) {
|
|
31
|
+
try {
|
|
32
|
+
await fs.rename(src, dest);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const code = err?.code;
|
|
36
|
+
if (code === "EPERM" || code === "EXDEV") {
|
|
37
|
+
await copyDirRecursive(src, dest);
|
|
38
|
+
await fs.rm(src, { recursive: true, force: true });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class ArchiveCommand {
|
|
46
|
+
async execute(changeName, options = {}) {
|
|
47
|
+
const targetPath = ".";
|
|
48
|
+
const changesDir = path.join(targetPath, "openspec", "changes");
|
|
49
|
+
const archiveDir = path.join(changesDir, "archive");
|
|
50
|
+
const mainSpecsDir = path.join(targetPath, "openspec", "specs");
|
|
51
|
+
// Check if changes directory exists
|
|
52
|
+
try {
|
|
53
|
+
await fs.access(changesDir);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new Error("未找到 OpenSpec 变更目录,请先执行 'openspec init'。");
|
|
57
|
+
}
|
|
58
|
+
// Get change name interactively if not provided
|
|
59
|
+
if (!changeName) {
|
|
60
|
+
const selectedChange = await this.selectChange(changesDir);
|
|
61
|
+
if (!selectedChange) {
|
|
62
|
+
console.log("未选择变更,已取消。");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
changeName = selectedChange;
|
|
66
|
+
}
|
|
67
|
+
const changeDir = path.join(changesDir, changeName);
|
|
68
|
+
// Verify change exists
|
|
69
|
+
try {
|
|
70
|
+
const stat = await fs.stat(changeDir);
|
|
71
|
+
if (!stat.isDirectory()) {
|
|
72
|
+
throw new Error(`未找到变更 "${changeName}"。`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
throw new Error(`未找到变更 "${changeName}"。`);
|
|
77
|
+
}
|
|
78
|
+
const skipValidation = options.validate === false || options.noValidate === true;
|
|
79
|
+
// Validate specs and change before archiving
|
|
80
|
+
if (!skipValidation) {
|
|
81
|
+
const validator = new Validator();
|
|
82
|
+
let hasValidationErrors = false;
|
|
83
|
+
// Validate proposal.md (non-blocking unless strict mode desired in future)
|
|
84
|
+
const changeFile = path.join(changeDir, "proposal.md");
|
|
85
|
+
try {
|
|
86
|
+
await fs.access(changeFile);
|
|
87
|
+
const changeReport = await validator.validateChange(changeFile);
|
|
88
|
+
// Proposal validation is informative only (do not block archive)
|
|
89
|
+
if (!changeReport.valid) {
|
|
90
|
+
console.log(chalk.yellow(`\nproposal.md 中的提案警告(不阻塞):`));
|
|
91
|
+
for (const issue of changeReport.issues) {
|
|
92
|
+
const symbol = issue.level === "ERROR"
|
|
93
|
+
? "⚠"
|
|
94
|
+
: issue.level === "WARNING"
|
|
95
|
+
? "⚠"
|
|
96
|
+
: "ℹ";
|
|
97
|
+
console.log(chalk.yellow(` ${symbol} ${issue.message}`));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Change file doesn't exist, skip validation
|
|
103
|
+
}
|
|
104
|
+
// Validate delta-formatted spec files under the change directory if present
|
|
105
|
+
const changeSpecsDir = path.join(changeDir, "specs");
|
|
106
|
+
let hasDeltaSpecs = false;
|
|
107
|
+
try {
|
|
108
|
+
const candidates = await fs.readdir(changeSpecsDir, {
|
|
109
|
+
withFileTypes: true,
|
|
110
|
+
});
|
|
111
|
+
for (const c of candidates) {
|
|
112
|
+
if (c.isDirectory()) {
|
|
113
|
+
try {
|
|
114
|
+
const candidatePath = path.join(changeSpecsDir, c.name, "spec.md");
|
|
115
|
+
await fs.access(candidatePath);
|
|
116
|
+
const content = await fs.readFile(candidatePath, "utf-8");
|
|
117
|
+
if (/^##\s+(ADDED|MODIFIED|REMOVED|RENAMED)\s+Requirements/m.test(content)) {
|
|
118
|
+
hasDeltaSpecs = true;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch { }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch { }
|
|
127
|
+
if (hasDeltaSpecs) {
|
|
128
|
+
const deltaReport = await validator.validateChangeDeltaSpecs(changeDir);
|
|
129
|
+
if (!deltaReport.valid) {
|
|
130
|
+
hasValidationErrors = true;
|
|
131
|
+
console.log(chalk.red(`\n变更增量规范校验错误:`));
|
|
132
|
+
for (const issue of deltaReport.issues) {
|
|
133
|
+
if (issue.level === "ERROR") {
|
|
134
|
+
console.log(chalk.red(` ✗ ${issue.message}`));
|
|
135
|
+
}
|
|
136
|
+
else if (issue.level === "WARNING") {
|
|
137
|
+
console.log(chalk.yellow(` ⚠ ${issue.message}`));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (hasValidationErrors) {
|
|
143
|
+
console.log(chalk.red("\n校验未通过,请修正后再归档。"));
|
|
144
|
+
console.log(chalk.yellow("若需跳过校验(不推荐),可使用 --no-validate。"));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Log warning when validation is skipped
|
|
150
|
+
const timestamp = new Date().toISOString();
|
|
151
|
+
if (!options.yes) {
|
|
152
|
+
const { confirm } = await import("@inquirer/prompts");
|
|
153
|
+
const proceed = await confirm({
|
|
154
|
+
message: chalk.yellow("⚠️ 警告:跳过校验可能归档无效规范。是否继续?(y/N)"),
|
|
155
|
+
default: false,
|
|
156
|
+
});
|
|
157
|
+
if (!proceed) {
|
|
158
|
+
console.log("已取消归档。");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
console.log(chalk.yellow(`\n⚠️ 警告:跳过校验可能归档无效规范。`));
|
|
164
|
+
}
|
|
165
|
+
console.log(chalk.yellow(`[${timestamp}] 已跳过变更校验:${changeName}`));
|
|
166
|
+
console.log(chalk.yellow(`涉及目录:${changeDir}`));
|
|
167
|
+
}
|
|
168
|
+
// Show progress and check for incomplete tasks
|
|
169
|
+
const progress = await getTaskProgressForChange(changesDir, changeName);
|
|
170
|
+
const status = formatTaskStatus(progress);
|
|
171
|
+
console.log(`任务状态:${status}`);
|
|
172
|
+
const incompleteTasks = Math.max(progress.total - progress.completed, 0);
|
|
173
|
+
if (incompleteTasks > 0) {
|
|
174
|
+
if (!options.yes) {
|
|
175
|
+
const { confirm } = await import("@inquirer/prompts");
|
|
176
|
+
const proceed = await confirm({
|
|
177
|
+
message: `警告:发现 ${incompleteTasks} 个未完成任务。是否继续?`,
|
|
178
|
+
default: false,
|
|
179
|
+
});
|
|
180
|
+
if (!proceed) {
|
|
181
|
+
console.log("已取消归档。");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
console.log(`警告:发现 ${incompleteTasks} 个未完成任务,因 --yes 将继续。`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Handle spec updates unless skipSpecs flag is set
|
|
190
|
+
if (options.skipSpecs) {
|
|
191
|
+
console.log("已跳过规范更新(已指定 --skip-specs)。");
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// Find specs to update
|
|
195
|
+
const specUpdates = await findSpecUpdates(changeDir, mainSpecsDir);
|
|
196
|
+
if (specUpdates.length > 0) {
|
|
197
|
+
console.log("\n待更新规范:");
|
|
198
|
+
for (const update of specUpdates) {
|
|
199
|
+
const status = update.exists ? "update" : "create";
|
|
200
|
+
const capability = path.basename(path.dirname(update.target));
|
|
201
|
+
console.log(` ${capability}: ${status}`);
|
|
202
|
+
}
|
|
203
|
+
let shouldUpdateSpecs = true;
|
|
204
|
+
if (!options.yes) {
|
|
205
|
+
const { confirm } = await import("@inquirer/prompts");
|
|
206
|
+
shouldUpdateSpecs = await confirm({
|
|
207
|
+
message: "是否执行规范更新?",
|
|
208
|
+
default: true,
|
|
209
|
+
});
|
|
210
|
+
if (!shouldUpdateSpecs) {
|
|
211
|
+
console.log("跳过规范更新,继续归档。");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (shouldUpdateSpecs) {
|
|
215
|
+
// Prepare all updates first (validation pass, no writes)
|
|
216
|
+
const prepared = [];
|
|
217
|
+
try {
|
|
218
|
+
for (const update of specUpdates) {
|
|
219
|
+
const built = await buildUpdatedSpec(update, changeName);
|
|
220
|
+
prepared.push({
|
|
221
|
+
update,
|
|
222
|
+
rebuilt: built.rebuilt,
|
|
223
|
+
counts: built.counts,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
console.log(String(err.message || err));
|
|
229
|
+
console.log("已中止,未修改任何文件。");
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
// All validations passed; pre-validate rebuilt full spec and then write files and display counts
|
|
233
|
+
let totals = { added: 0, modified: 0, removed: 0, renamed: 0 };
|
|
234
|
+
for (const p of prepared) {
|
|
235
|
+
const specName = path.basename(path.dirname(p.update.target));
|
|
236
|
+
if (!skipValidation) {
|
|
237
|
+
const report = await new Validator().validateSpecContent(specName, p.rebuilt);
|
|
238
|
+
if (!report.valid) {
|
|
239
|
+
console.log(chalk.red(`\n重建规范 ${specName} 的校验错误(不会写入更改):`));
|
|
240
|
+
for (const issue of report.issues) {
|
|
241
|
+
if (issue.level === "ERROR")
|
|
242
|
+
console.log(chalk.red(` ✗ ${issue.message}`));
|
|
243
|
+
else if (issue.level === "WARNING")
|
|
244
|
+
console.log(chalk.yellow(` ⚠ ${issue.message}`));
|
|
245
|
+
}
|
|
246
|
+
console.log("已中止,未修改任何文件。");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
await writeUpdatedSpec(p.update, p.rebuilt, p.counts);
|
|
251
|
+
totals.added += p.counts.added;
|
|
252
|
+
totals.modified += p.counts.modified;
|
|
253
|
+
totals.removed += p.counts.removed;
|
|
254
|
+
totals.renamed += p.counts.renamed;
|
|
255
|
+
}
|
|
256
|
+
console.log(`Totals: + ${totals.added}, ~ ${totals.modified}, - ${totals.removed}, → ${totals.renamed}`);
|
|
257
|
+
console.log("规范已更新。");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// Create archive directory with date prefix
|
|
262
|
+
const archiveName = `${this.getArchiveDate()}-${changeName}`;
|
|
263
|
+
const archivePath = path.join(archiveDir, archiveName);
|
|
264
|
+
// Check if archive already exists
|
|
265
|
+
try {
|
|
266
|
+
await fs.access(archivePath);
|
|
267
|
+
throw new Error(`归档目录 "${archiveName}" 已存在。`);
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
if (error.code !== "ENOENT") {
|
|
271
|
+
throw error;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// Create archive directory if needed
|
|
275
|
+
await fs.mkdir(archiveDir, { recursive: true });
|
|
276
|
+
// Move change to archive (uses copy+remove on EPERM/EXDEV, e.g. Windows)
|
|
277
|
+
await moveDirectory(changeDir, archivePath);
|
|
278
|
+
console.log(`变更 "${changeName}" 已归档为 "${archiveName}"。`);
|
|
279
|
+
}
|
|
280
|
+
async selectChange(changesDir) {
|
|
281
|
+
const { select } = await import("@inquirer/prompts");
|
|
282
|
+
// Get all directories in changes (excluding archive)
|
|
283
|
+
const entries = await fs.readdir(changesDir, { withFileTypes: true });
|
|
284
|
+
const changeDirs = entries
|
|
285
|
+
.filter((entry) => entry.isDirectory() && entry.name !== "archive")
|
|
286
|
+
.map((entry) => entry.name)
|
|
287
|
+
.sort();
|
|
288
|
+
if (changeDirs.length === 0) {
|
|
289
|
+
console.log("未找到进行中的变更。");
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
// Build choices with progress inline to avoid duplicate lists
|
|
293
|
+
let choices = changeDirs.map((name) => ({ name, value: name }));
|
|
294
|
+
try {
|
|
295
|
+
const progressList = [];
|
|
296
|
+
for (const id of changeDirs) {
|
|
297
|
+
const progress = await getTaskProgressForChange(changesDir, id);
|
|
298
|
+
const status = formatTaskStatus(progress);
|
|
299
|
+
progressList.push({ id, status });
|
|
300
|
+
}
|
|
301
|
+
const nameWidth = Math.max(...progressList.map((p) => p.id.length));
|
|
302
|
+
choices = progressList.map((p) => ({
|
|
303
|
+
name: `${p.id.padEnd(nameWidth)} ${p.status}`,
|
|
304
|
+
value: p.id,
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
// If anything fails, fall back to simple names
|
|
309
|
+
choices = changeDirs.map((name) => ({ name, value: name }));
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
const answer = await select({
|
|
313
|
+
message: "选择要归档的变更",
|
|
314
|
+
choices,
|
|
315
|
+
});
|
|
316
|
+
return answer;
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
// User cancelled (Ctrl+C)
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
getArchiveDate() {
|
|
324
|
+
// Returns date in YYYY-MM-DD format
|
|
325
|
+
return new Date().toISOString().split("T")[0];
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Artifact, SchemaYaml, CompletedSet, BlockedArtifacts } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents an artifact dependency graph.
|
|
4
|
+
* Provides methods for querying build order, ready artifacts, and completion status.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ArtifactGraph {
|
|
7
|
+
private artifacts;
|
|
8
|
+
private schema;
|
|
9
|
+
private constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Creates an ArtifactGraph from a YAML file path.
|
|
12
|
+
*/
|
|
13
|
+
static fromYaml(filePath: string): ArtifactGraph;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an ArtifactGraph from YAML content string.
|
|
16
|
+
*/
|
|
17
|
+
static fromYamlContent(yamlContent: string): ArtifactGraph;
|
|
18
|
+
/**
|
|
19
|
+
* Creates an ArtifactGraph from a pre-validated schema object.
|
|
20
|
+
*/
|
|
21
|
+
static fromSchema(schema: SchemaYaml): ArtifactGraph;
|
|
22
|
+
/**
|
|
23
|
+
* Gets a single artifact by ID.
|
|
24
|
+
*/
|
|
25
|
+
getArtifact(id: string): Artifact | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Gets all artifacts in the graph.
|
|
28
|
+
*/
|
|
29
|
+
getAllArtifacts(): Artifact[];
|
|
30
|
+
/**
|
|
31
|
+
* Gets the schema name.
|
|
32
|
+
*/
|
|
33
|
+
getName(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the schema version.
|
|
36
|
+
*/
|
|
37
|
+
getVersion(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Computes the topological build order using Kahn's algorithm.
|
|
40
|
+
* Returns artifact IDs in the order they should be built.
|
|
41
|
+
*/
|
|
42
|
+
getBuildOrder(): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Gets artifacts that are ready to be created (all dependencies completed).
|
|
45
|
+
*/
|
|
46
|
+
getNextArtifacts(completed: CompletedSet): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Checks if all artifacts in the graph are completed.
|
|
49
|
+
*/
|
|
50
|
+
isComplete(completed: CompletedSet): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Gets blocked artifacts and their unmet dependencies.
|
|
53
|
+
*/
|
|
54
|
+
getBlocked(completed: CompletedSet): BlockedArtifacts;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { loadSchema, parseSchema } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents an artifact dependency graph.
|
|
4
|
+
* Provides methods for querying build order, ready artifacts, and completion status.
|
|
5
|
+
*/
|
|
6
|
+
export class ArtifactGraph {
|
|
7
|
+
artifacts;
|
|
8
|
+
schema;
|
|
9
|
+
constructor(schema) {
|
|
10
|
+
this.schema = schema;
|
|
11
|
+
this.artifacts = new Map(schema.artifacts.map(a => [a.id, a]));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates an ArtifactGraph from a YAML file path.
|
|
15
|
+
*/
|
|
16
|
+
static fromYaml(filePath) {
|
|
17
|
+
const schema = loadSchema(filePath);
|
|
18
|
+
return new ArtifactGraph(schema);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates an ArtifactGraph from YAML content string.
|
|
22
|
+
*/
|
|
23
|
+
static fromYamlContent(yamlContent) {
|
|
24
|
+
const schema = parseSchema(yamlContent);
|
|
25
|
+
return new ArtifactGraph(schema);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates an ArtifactGraph from a pre-validated schema object.
|
|
29
|
+
*/
|
|
30
|
+
static fromSchema(schema) {
|
|
31
|
+
return new ArtifactGraph(schema);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets a single artifact by ID.
|
|
35
|
+
*/
|
|
36
|
+
getArtifact(id) {
|
|
37
|
+
return this.artifacts.get(id);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets all artifacts in the graph.
|
|
41
|
+
*/
|
|
42
|
+
getAllArtifacts() {
|
|
43
|
+
return Array.from(this.artifacts.values());
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the schema name.
|
|
47
|
+
*/
|
|
48
|
+
getName() {
|
|
49
|
+
return this.schema.name;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Gets the schema version.
|
|
53
|
+
*/
|
|
54
|
+
getVersion() {
|
|
55
|
+
return this.schema.version;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Computes the topological build order using Kahn's algorithm.
|
|
59
|
+
* Returns artifact IDs in the order they should be built.
|
|
60
|
+
*/
|
|
61
|
+
getBuildOrder() {
|
|
62
|
+
const inDegree = new Map();
|
|
63
|
+
const dependents = new Map();
|
|
64
|
+
// Initialize all artifacts
|
|
65
|
+
for (const artifact of this.artifacts.values()) {
|
|
66
|
+
inDegree.set(artifact.id, artifact.requires.length);
|
|
67
|
+
dependents.set(artifact.id, []);
|
|
68
|
+
}
|
|
69
|
+
// Build reverse adjacency (who depends on whom)
|
|
70
|
+
for (const artifact of this.artifacts.values()) {
|
|
71
|
+
for (const req of artifact.requires) {
|
|
72
|
+
dependents.get(req).push(artifact.id);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Start with roots (in-degree 0), sorted for determinism
|
|
76
|
+
const queue = [...this.artifacts.keys()]
|
|
77
|
+
.filter(id => inDegree.get(id) === 0)
|
|
78
|
+
.sort();
|
|
79
|
+
const result = [];
|
|
80
|
+
while (queue.length > 0) {
|
|
81
|
+
const current = queue.shift();
|
|
82
|
+
result.push(current);
|
|
83
|
+
// Collect newly ready artifacts, then sort before adding
|
|
84
|
+
const newlyReady = [];
|
|
85
|
+
for (const dep of dependents.get(current)) {
|
|
86
|
+
const newDegree = inDegree.get(dep) - 1;
|
|
87
|
+
inDegree.set(dep, newDegree);
|
|
88
|
+
if (newDegree === 0) {
|
|
89
|
+
newlyReady.push(dep);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
queue.push(...newlyReady.sort());
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets artifacts that are ready to be created (all dependencies completed).
|
|
98
|
+
*/
|
|
99
|
+
getNextArtifacts(completed) {
|
|
100
|
+
const ready = [];
|
|
101
|
+
for (const artifact of this.artifacts.values()) {
|
|
102
|
+
if (completed.has(artifact.id)) {
|
|
103
|
+
continue; // Already completed
|
|
104
|
+
}
|
|
105
|
+
const allDepsCompleted = artifact.requires.every(req => completed.has(req));
|
|
106
|
+
if (allDepsCompleted) {
|
|
107
|
+
ready.push(artifact.id);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Sort for deterministic ordering
|
|
111
|
+
return ready.sort();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Checks if all artifacts in the graph are completed.
|
|
115
|
+
*/
|
|
116
|
+
isComplete(completed) {
|
|
117
|
+
for (const artifact of this.artifacts.values()) {
|
|
118
|
+
if (!completed.has(artifact.id)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Gets blocked artifacts and their unmet dependencies.
|
|
126
|
+
*/
|
|
127
|
+
getBlocked(completed) {
|
|
128
|
+
const blocked = {};
|
|
129
|
+
for (const artifact of this.artifacts.values()) {
|
|
130
|
+
if (completed.has(artifact.id)) {
|
|
131
|
+
continue; // Already completed
|
|
132
|
+
}
|
|
133
|
+
const unmetDeps = artifact.requires.filter(req => !completed.has(req));
|
|
134
|
+
if (unmetDeps.length > 0) {
|
|
135
|
+
blocked[artifact.id] = unmetDeps.sort();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return blocked;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ArtifactSchema, SchemaYamlSchema, type Artifact, type SchemaYaml, type CompletedSet, type BlockedArtifacts, } from './types.js';
|
|
2
|
+
export { loadSchema, parseSchema, SchemaValidationError } from './schema.js';
|
|
3
|
+
export { ArtifactGraph } from './graph.js';
|
|
4
|
+
export { detectCompleted } from './state.js';
|
|
5
|
+
export { resolveSchema, listSchemas, listSchemasWithInfo, getSchemaDir, getPackageSchemasDir, getUserSchemasDir, SchemaLoadError, type SchemaInfo, } from './resolver.js';
|
|
6
|
+
export { loadTemplate, loadChangeContext, generateInstructions, formatChangeStatus, TemplateLoadError, type ChangeContext, type ArtifactInstructions, type DependencyInfo, type ArtifactStatus, type ChangeStatus, } from './instruction-loader.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|