@aipper/aiws 0.0.28 → 0.0.30
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/README.md +18 -2
- package/bin/aiws.js +2 -2
- package/dist/aiws-package.d.ts +4 -0
- package/dist/aiws-package.js +11 -0
- package/dist/aiws-package.js.map +1 -0
- package/dist/aiws-paths.d.ts +48 -0
- package/dist/aiws-paths.js +129 -0
- package/dist/aiws-paths.js.map +1 -0
- package/dist/backup.d.ts +27 -0
- package/dist/backup.js +125 -0
- package/dist/backup.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +773 -0
- package/dist/cli.js.map +1 -0
- package/dist/codex-prompts.d.ts +17 -0
- package/dist/codex-prompts.js +49 -0
- package/dist/codex-prompts.js.map +1 -0
- package/dist/codex-skills.d.ts +17 -0
- package/dist/codex-skills.js +75 -0
- package/dist/codex-skills.js.map +1 -0
- package/dist/commands/change-advice.d.ts +25 -0
- package/dist/commands/change-advice.js +197 -0
- package/dist/commands/change-advice.js.map +1 -0
- package/dist/commands/change-evidence-command.d.ts +29 -0
- package/dist/commands/change-evidence-command.js +213 -0
- package/dist/commands/change-evidence-command.js.map +1 -0
- package/dist/commands/change-evidence-entry.d.ts +16 -0
- package/dist/commands/change-evidence-entry.js +35 -0
- package/dist/commands/change-evidence-entry.js.map +1 -0
- package/dist/commands/change-evidence.d.ts +108 -0
- package/dist/commands/change-evidence.js +341 -0
- package/dist/commands/change-evidence.js.map +1 -0
- package/dist/commands/change-finish.d.ts +71 -0
- package/dist/commands/change-finish.js +387 -0
- package/dist/commands/change-finish.js.map +1 -0
- package/dist/commands/change-git-status.d.ts +22 -0
- package/dist/commands/change-git-status.js +50 -0
- package/dist/commands/change-git-status.js.map +1 -0
- package/dist/commands/change-lifecycle-entry.d.ts +29 -0
- package/{src → dist}/commands/change-lifecycle-entry.js +21 -28
- package/dist/commands/change-lifecycle-entry.js.map +1 -0
- package/dist/commands/change-lifecycle.d.ts +56 -0
- package/dist/commands/change-lifecycle.js +211 -0
- package/dist/commands/change-lifecycle.js.map +1 -0
- package/dist/commands/change-metrics-command.d.ts +12 -0
- package/dist/commands/change-metrics-command.js +110 -0
- package/dist/commands/change-metrics-command.js.map +1 -0
- package/dist/commands/change-next-command.d.ts +18 -0
- package/dist/commands/change-next-command.js +138 -0
- package/dist/commands/change-next-command.js.map +1 -0
- package/dist/commands/change-review-gates.d.ts +107 -0
- package/dist/commands/change-review-gates.js +329 -0
- package/dist/commands/change-review-gates.js.map +1 -0
- package/dist/commands/change-scope-gate.d.ts +21 -0
- package/dist/commands/change-scope-gate.js +32 -0
- package/dist/commands/change-scope-gate.js.map +1 -0
- package/dist/commands/change-start.d.ts +30 -0
- package/dist/commands/change-start.js +91 -0
- package/dist/commands/change-start.js.map +1 -0
- package/dist/commands/change-state-command.d.ts +3 -0
- package/dist/commands/change-state-command.js +32 -0
- package/dist/commands/change-state-command.js.map +1 -0
- package/dist/commands/change-status-command.d.ts +13 -0
- package/dist/commands/change-status-command.js +126 -0
- package/dist/commands/change-status-command.js.map +1 -0
- package/dist/commands/change-status-context.d.ts +58 -0
- package/dist/commands/change-status-context.js +166 -0
- package/dist/commands/change-status-context.js.map +1 -0
- package/dist/commands/change-task-stats.d.ts +24 -0
- package/dist/commands/change-task-stats.js +66 -0
- package/dist/commands/change-task-stats.js.map +1 -0
- package/dist/commands/change-validate-entry.d.ts +17 -0
- package/dist/commands/change-validate-entry.js +44 -0
- package/dist/commands/change-validate-entry.js.map +1 -0
- package/dist/commands/change-validate.d.ts +32 -0
- package/dist/commands/change-validate.js +128 -0
- package/dist/commands/change-validate.js.map +1 -0
- package/dist/commands/change.d.ts +322 -0
- package/dist/commands/change.js +1731 -0
- package/dist/commands/change.js.map +1 -0
- package/dist/commands/codex-install-prompts.d.ts +4 -0
- package/dist/commands/codex-install-prompts.js +68 -0
- package/dist/commands/codex-install-prompts.js.map +1 -0
- package/dist/commands/codex-install-skills.d.ts +4 -0
- package/dist/commands/codex-install-skills.js +74 -0
- package/dist/commands/codex-install-skills.js.map +1 -0
- package/dist/commands/codex-status-prompts.d.ts +4 -0
- package/dist/commands/codex-status-prompts.js +44 -0
- package/dist/commands/codex-status-prompts.js.map +1 -0
- package/dist/commands/codex-status-skills.d.ts +4 -0
- package/dist/commands/codex-status-skills.js +54 -0
- package/dist/commands/codex-status-skills.js.map +1 -0
- package/dist/commands/codex-uninstall-prompts.d.ts +4 -0
- package/dist/commands/codex-uninstall-prompts.js +51 -0
- package/dist/commands/codex-uninstall-prompts.js.map +1 -0
- package/dist/commands/codex-uninstall-skills.d.ts +4 -0
- package/dist/commands/codex-uninstall-skills.js +59 -0
- package/dist/commands/codex-uninstall-skills.js.map +1 -0
- package/dist/commands/dashboard.d.ts +222 -0
- package/dist/commands/dashboard.js +193 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/hooks-install.d.ts +4 -0
- package/dist/commands/hooks-install.js +90 -0
- package/dist/commands/hooks-install.js.map +1 -0
- package/dist/commands/hooks-status.d.ts +4 -0
- package/dist/commands/hooks-status.js +89 -0
- package/dist/commands/hooks-status.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +100 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/opencode-auto.d.ts +11 -0
- package/dist/commands/opencode-auto.js +158 -0
- package/dist/commands/opencode-auto.js.map +1 -0
- package/dist/commands/opencode-status.d.ts +4 -0
- package/dist/commands/opencode-status.js +75 -0
- package/dist/commands/opencode-status.js.map +1 -0
- package/dist/commands/opencode-supervise.d.ts +24 -0
- package/dist/commands/opencode-supervise.js +188 -0
- package/dist/commands/opencode-supervise.js.map +1 -0
- package/dist/commands/rollback.d.ts +4 -0
- package/dist/commands/rollback.js +12 -0
- package/dist/commands/rollback.js.map +1 -0
- package/dist/commands/update.d.ts +4 -0
- package/dist/commands/update.js +212 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.d.ts +4 -0
- package/dist/commands/validate.js +222 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/ws-commit.d.ts +5 -0
- package/dist/commands/ws-commit.js +39 -0
- package/dist/commands/ws-commit.js.map +1 -0
- package/dist/commands/ws-deliver.d.ts +5 -0
- package/dist/commands/ws-deliver.js +59 -0
- package/dist/commands/ws-deliver.js.map +1 -0
- package/dist/commands/ws-finish.d.ts +5 -0
- package/dist/commands/ws-finish.js +142 -0
- package/dist/commands/ws-finish.js.map +1 -0
- package/dist/commands/ws-handoff.d.ts +5 -0
- package/dist/commands/ws-handoff.js +35 -0
- package/dist/commands/ws-handoff.js.map +1 -0
- package/dist/commands/ws-migrate.d.ts +5 -0
- package/dist/commands/ws-migrate.js +41 -0
- package/dist/commands/ws-migrate.js.map +1 -0
- package/dist/commands/ws-plan-verify.d.ts +5 -0
- package/dist/commands/ws-plan-verify.js +38 -0
- package/dist/commands/ws-plan-verify.js.map +1 -0
- package/dist/commands/ws-pull.d.ts +5 -0
- package/dist/commands/ws-pull.js +26 -0
- package/dist/commands/ws-pull.js.map +1 -0
- package/dist/commands/ws-push.d.ts +5 -0
- package/dist/commands/ws-push.js +68 -0
- package/dist/commands/ws-push.js.map +1 -0
- package/dist/commands/ws-submodule-setup.d.ts +5 -0
- package/dist/commands/ws-submodule-setup.js +55 -0
- package/dist/commands/ws-submodule-setup.js.map +1 -0
- package/dist/commands/ws-verify-before-complete.d.ts +5 -0
- package/dist/commands/ws-verify-before-complete.js +35 -0
- package/dist/commands/ws-verify-before-complete.js.map +1 -0
- package/dist/dashboard/app.d.ts +1 -0
- package/dist/dashboard/app.js +370 -0
- package/dist/dashboard/app.js.map +1 -0
- package/dist/delegation/cli.d.ts +6 -0
- package/dist/delegation/cli.js +14 -0
- package/dist/delegation/cli.js.map +1 -0
- package/dist/delegation/index.d.ts +35 -0
- package/dist/delegation/index.js +118 -0
- package/dist/delegation/index.js.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -0
- package/dist/exec.d.ts +9 -0
- package/dist/exec.js +22 -0
- package/dist/exec.js.map +1 -0
- package/dist/fs.d.ts +9 -0
- package/dist/fs.js +62 -0
- package/dist/fs.js.map +1 -0
- package/dist/governance.d.ts +10 -0
- package/dist/governance.js +135 -0
- package/dist/governance.js.map +1 -0
- package/dist/hash.d.ts +3 -0
- package/dist/hash.js +13 -0
- package/dist/hash.js.map +1 -0
- package/dist/hooks/deploy-claude.d.ts +13 -0
- package/dist/hooks/deploy-claude.js +67 -0
- package/dist/hooks/deploy-claude.js.map +1 -0
- package/dist/journal.d.ts +22 -0
- package/dist/journal.js +112 -0
- package/dist/journal.js.map +1 -0
- package/dist/json-schema-lite.d.ts +22 -0
- package/dist/json-schema-lite.js +148 -0
- package/dist/json-schema-lite.js.map +1 -0
- package/dist/managed-blocks.d.ts +24 -0
- package/dist/managed-blocks.js +84 -0
- package/dist/managed-blocks.js.map +1 -0
- package/dist/manifest.d.ts +24 -0
- package/dist/manifest.js +145 -0
- package/dist/manifest.js.map +1 -0
- package/dist/opencode-env.d.ts +62 -0
- package/dist/opencode-env.js +178 -0
- package/dist/opencode-env.js.map +1 -0
- package/dist/path-utils.d.ts +2 -0
- package/dist/path-utils.js +8 -0
- package/dist/path-utils.js.map +1 -0
- package/dist/spec.d.ts +17 -0
- package/dist/spec.js +174 -0
- package/dist/spec.js.map +1 -0
- package/dist/template.d.ts +20 -0
- package/dist/template.js +123 -0
- package/dist/template.js.map +1 -0
- package/dist/workspace.d.ts +4 -0
- package/dist/workspace.js +19 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +11 -3
- package/src/aiws-package.js +0 -15
- package/src/backup.js +0 -149
- package/src/cli.js +0 -647
- package/src/codex-prompts.js +0 -74
- package/src/codex-skills.js +0 -111
- package/src/commands/change-advice.js +0 -200
- package/src/commands/change-evidence-command.js +0 -242
- package/src/commands/change-evidence-entry.js +0 -40
- package/src/commands/change-evidence.js +0 -340
- package/src/commands/change-finish.js +0 -484
- package/src/commands/change-git-status.js +0 -53
- package/src/commands/change-lifecycle.js +0 -236
- package/src/commands/change-metrics-command.js +0 -110
- package/src/commands/change-next-command.js +0 -129
- package/src/commands/change-review-gates.js +0 -315
- package/src/commands/change-scope-gate.js +0 -34
- package/src/commands/change-start.js +0 -120
- package/src/commands/change-state-command.js +0 -40
- package/src/commands/change-status-command.js +0 -134
- package/src/commands/change-status-context.js +0 -202
- package/src/commands/change-task-stats.js +0 -64
- package/src/commands/change-validate-entry.js +0 -45
- package/src/commands/change-validate.js +0 -127
- package/src/commands/change.js +0 -2087
- package/src/commands/codex-install-prompts.js +0 -68
- package/src/commands/codex-install-skills.js +0 -74
- package/src/commands/codex-status-prompts.js +0 -55
- package/src/commands/codex-status-skills.js +0 -63
- package/src/commands/codex-uninstall-prompts.js +0 -55
- package/src/commands/codex-uninstall-skills.js +0 -62
- package/src/commands/dashboard.js +0 -205
- package/src/commands/hooks-install.js +0 -92
- package/src/commands/hooks-status.js +0 -95
- package/src/commands/init.js +0 -93
- package/src/commands/opencode-status.js +0 -61
- package/src/commands/rollback.js +0 -13
- package/src/commands/update.js +0 -133
- package/src/commands/validate.js +0 -222
- package/src/dashboard/app.js +0 -371
- package/src/errors.js +0 -15
- package/src/exec.js +0 -34
- package/src/fs.js +0 -91
- package/src/governance.js +0 -159
- package/src/hash.js +0 -25
- package/src/json-schema-lite.js +0 -164
- package/src/managed-blocks.js +0 -131
- package/src/manifest.js +0 -153
- package/src/opencode-env.js +0 -76
- package/src/path-utils.js +0 -20
- package/src/spec.js +0 -195
- package/src/template.js +0 -187
- package/src/workspace.js +0 -23
- /package/{src → dist}/dashboard/index.html +0 -0
- /package/{src → dist}/dashboard/style.css +0 -0
package/src/spec.js
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { pathExists, readText } from "./fs.js";
|
|
6
|
-
import { UserError } from "./errors.js";
|
|
7
|
-
import { validateJsonSchemaLite } from "./json-schema-lite.js";
|
|
8
|
-
|
|
9
|
-
const specJsonDocCache = new Map();
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @returns {Promise<{ rootDir: string, version: string }>}
|
|
13
|
-
*/
|
|
14
|
-
export async function loadSpecPackage() {
|
|
15
|
-
const require = createRequire(import.meta.url);
|
|
16
|
-
|
|
17
|
-
/** @type {string | null} */
|
|
18
|
-
let pkgJsonPath = null;
|
|
19
|
-
try {
|
|
20
|
-
pkgJsonPath = require.resolve("@aipper/aiws-spec/package.json");
|
|
21
|
-
} catch {
|
|
22
|
-
pkgJsonPath = null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** @type {string} */
|
|
26
|
-
let rootDir;
|
|
27
|
-
if (pkgJsonPath) {
|
|
28
|
-
rootDir = path.dirname(pkgJsonPath);
|
|
29
|
-
} else {
|
|
30
|
-
const here = fileURLToPath(import.meta.url);
|
|
31
|
-
rootDir = path.resolve(path.dirname(here), "../../spec");
|
|
32
|
-
const fallbackPkg = path.join(rootDir, "package.json");
|
|
33
|
-
if (!(await pathExists(fallbackPkg))) {
|
|
34
|
-
throw new UserError("Cannot locate @aipper/aiws-spec. Install it or run inside the monorepo.", {
|
|
35
|
-
exitCode: 1,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const pkg = JSON.parse(await readText(path.join(rootDir, "package.json")));
|
|
41
|
-
const version = String(pkg.version || "").trim() || "0.0.0";
|
|
42
|
-
return { rootDir, version };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @param {string} templateId
|
|
47
|
-
*/
|
|
48
|
-
export async function loadTemplate(templateId) {
|
|
49
|
-
if (!templateId || templateId.includes("..") || templateId.includes("/") || templateId.includes("\\")) {
|
|
50
|
-
throw new UserError(`Invalid template id: ${templateId}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const spec = await loadSpecPackage();
|
|
54
|
-
const templateDir = path.join(spec.rootDir, "templates", templateId);
|
|
55
|
-
const manifestPath = path.join(templateDir, "manifest.json");
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
await fs.access(manifestPath);
|
|
59
|
-
} catch {
|
|
60
|
-
throw new UserError(`Template not found: ${templateId}`, {
|
|
61
|
-
details: `Missing: ${manifestPath}`,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const manifest = JSON.parse(await readText(manifestPath));
|
|
66
|
-
return { templateId, templateDir, manifest, specVersion: spec.version };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @param {string} relPath
|
|
71
|
-
*/
|
|
72
|
-
async function loadSpecJsonDoc(relPath) {
|
|
73
|
-
const spec = await loadSpecPackage();
|
|
74
|
-
const absPath = path.join(spec.rootDir, relPath);
|
|
75
|
-
const cacheKey = `${spec.rootDir}:${relPath}`;
|
|
76
|
-
if (specJsonDocCache.has(cacheKey)) {
|
|
77
|
-
return { spec, data: specJsonDocCache.get(cacheKey), absPath };
|
|
78
|
-
}
|
|
79
|
-
const raw = await readText(absPath);
|
|
80
|
-
let data;
|
|
81
|
-
try {
|
|
82
|
-
data = JSON.parse(raw);
|
|
83
|
-
} catch (error) {
|
|
84
|
-
throw new UserError(`Invalid JSON in spec doc: ${relPath}`, {
|
|
85
|
-
details: error instanceof Error ? error.message : String(error),
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
specJsonDocCache.set(cacheKey, data);
|
|
89
|
-
return { spec, data, absPath };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async function loadValidatedSpecJsonDoc(relPath, schemaRelPath) {
|
|
93
|
-
const loaded = await loadSpecJsonDoc(relPath);
|
|
94
|
-
const { data: schema } = await loadSpecJsonDoc(schemaRelPath);
|
|
95
|
-
validateJsonSchemaLite(loaded.data, schema, { source: loaded.absPath });
|
|
96
|
-
return loaded;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export async function loadWorkflowGovernanceRules() {
|
|
100
|
-
const relPath = path.join("docs", "workflow-governance-rules.json");
|
|
101
|
-
const schemaRelPath = path.join("docs", "workflow-governance-rules.schema.json");
|
|
102
|
-
const { spec, data } = await loadValidatedSpecJsonDoc(relPath, schemaRelPath);
|
|
103
|
-
const governanceRules = data.governanceRules;
|
|
104
|
-
const guidanceRules = data.guidanceRules;
|
|
105
|
-
return {
|
|
106
|
-
ok: true,
|
|
107
|
-
source: "@aipper/aiws-spec/docs/workflow-governance-rules.json",
|
|
108
|
-
specVersion: spec.version,
|
|
109
|
-
version: Number(data?.version || 1),
|
|
110
|
-
description: String(data?.description || ""),
|
|
111
|
-
governanceRules,
|
|
112
|
-
guidanceRules,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export async function loadWorkflowStageContracts() {
|
|
117
|
-
const relPath = path.join("docs", "workflow-stage-contracts.json");
|
|
118
|
-
const schemaRelPath = path.join("docs", "workflow-stage-contracts.schema.json");
|
|
119
|
-
const { spec, data } = await loadValidatedSpecJsonDoc(relPath, schemaRelPath);
|
|
120
|
-
const stages = data.stages;
|
|
121
|
-
return {
|
|
122
|
-
ok: true,
|
|
123
|
-
source: "@aipper/aiws-spec/docs/workflow-stage-contracts.json",
|
|
124
|
-
specVersion: spec.version,
|
|
125
|
-
version: Number(data?.version || 1),
|
|
126
|
-
description: String(data?.description || ""),
|
|
127
|
-
standardChain: Array.isArray(data?.standardChain) ? data.standardChain : [],
|
|
128
|
-
notes: Array.isArray(data?.notes) ? data.notes : [],
|
|
129
|
-
stages,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export async function loadWorkflowRouterRules() {
|
|
134
|
-
const relPath = path.join("docs", "workflow-router-rules.json");
|
|
135
|
-
const schemaRelPath = path.join("docs", "workflow-router-rules.schema.json");
|
|
136
|
-
const { spec, data } = await loadValidatedSpecJsonDoc(relPath, schemaRelPath);
|
|
137
|
-
return {
|
|
138
|
-
ok: true,
|
|
139
|
-
source: "@aipper/aiws-spec/docs/workflow-router-rules.json",
|
|
140
|
-
specVersion: spec.version,
|
|
141
|
-
version: Number(data?.version || 1),
|
|
142
|
-
title: String(data?.title || ""),
|
|
143
|
-
description: String(data?.description || ""),
|
|
144
|
-
truthFiles: Array.isArray(data?.truthFiles) ? data.truthFiles : [],
|
|
145
|
-
bootstrapEntry: data.bootstrapEntry,
|
|
146
|
-
universalSequence: Array.isArray(data?.universalSequence) ? data.universalSequence : [],
|
|
147
|
-
routingRules: Array.isArray(data?.routingRules) ? data.routingRules : [],
|
|
148
|
-
routeCases: Array.isArray(data?.routeCases) ? data.routeCases : [],
|
|
149
|
-
clarificationTriggers: Array.isArray(data?.clarificationTriggers) ? data.clarificationTriggers : [],
|
|
150
|
-
universalRules: Array.isArray(data?.universalRules) ? data.universalRules : [],
|
|
151
|
-
notes: Array.isArray(data?.notes) ? data.notes : [],
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export async function loadWorkflowReviewGates() {
|
|
156
|
-
const relPath = path.join("docs", "workflow-review-gates.json");
|
|
157
|
-
const schemaRelPath = path.join("docs", "workflow-review-gates.schema.json");
|
|
158
|
-
const { spec, data } = await loadValidatedSpecJsonDoc(relPath, schemaRelPath);
|
|
159
|
-
return {
|
|
160
|
-
ok: true,
|
|
161
|
-
source: "@aipper/aiws-spec/docs/workflow-review-gates.json",
|
|
162
|
-
specVersion: spec.version,
|
|
163
|
-
version: Number(data?.version || 1),
|
|
164
|
-
title: String(data?.title || ""),
|
|
165
|
-
description: String(data?.description || ""),
|
|
166
|
-
gates: Array.isArray(data?.gates) ? data.gates : [],
|
|
167
|
-
unifiedRules: Array.isArray(data?.unifiedRules) ? data.unifiedRules : [],
|
|
168
|
-
evidence: Array.isArray(data?.evidence) ? data.evidence : [],
|
|
169
|
-
notes: Array.isArray(data?.notes) ? data.notes : [],
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export async function loadWorkflowDelegationContracts() {
|
|
174
|
-
const relPath = path.join("docs", "workflow-delegation-contracts.json");
|
|
175
|
-
const schemaRelPath = path.join("docs", "workflow-delegation-contracts.schema.json");
|
|
176
|
-
const { spec, data } = await loadValidatedSpecJsonDoc(relPath, schemaRelPath);
|
|
177
|
-
return {
|
|
178
|
-
ok: true,
|
|
179
|
-
source: "@aipper/aiws-spec/docs/workflow-delegation-contracts.json",
|
|
180
|
-
specVersion: spec.version,
|
|
181
|
-
version: Number(data?.version || 1),
|
|
182
|
-
title: String(data?.title || ""),
|
|
183
|
-
description: String(data?.description || ""),
|
|
184
|
-
purpose: Array.isArray(data?.purpose) ? data.purpose : [],
|
|
185
|
-
truthFiles: Array.isArray(data?.truthFiles) ? data.truthFiles : [],
|
|
186
|
-
delegationFlow: Array.isArray(data?.delegationFlow) ? data.delegationFlow : [],
|
|
187
|
-
roleTypes: Array.isArray(data?.roleTypes) ? data.roleTypes : [],
|
|
188
|
-
artifactTargets: Array.isArray(data?.artifactTargets) ? data.artifactTargets : [],
|
|
189
|
-
reviewConvergence: data?.reviewConvergence || {},
|
|
190
|
-
fallbackMode: data?.fallbackMode || {},
|
|
191
|
-
toolCapabilityMatrix: Array.isArray(data?.toolCapabilityMatrix) ? data.toolCapabilityMatrix : [],
|
|
192
|
-
universalRules: Array.isArray(data?.universalRules) ? data.universalRules : [],
|
|
193
|
-
notes: Array.isArray(data?.notes) ? data.notes : [],
|
|
194
|
-
};
|
|
195
|
-
}
|
package/src/template.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import { listFilesRecursive, pathExists, copyFile, readText, writeText, ensureDir } from "./fs.js";
|
|
4
|
-
import { normalizeRel, joinRel } from "./path-utils.js";
|
|
5
|
-
import { normalizeNewlines } from "./hash.js";
|
|
6
|
-
import { extractTemplateBlock, upsertManagedBlock } from "./managed-blocks.js";
|
|
7
|
-
import { UserError } from "./errors.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Extract a leading YAML frontmatter chunk when present.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} text normalized
|
|
13
|
-
* @returns {{ chunk: string, rest: string } | null}
|
|
14
|
-
*/
|
|
15
|
-
function extractLeadingFrontmatter(text) {
|
|
16
|
-
const t = normalizeNewlines(text);
|
|
17
|
-
if (!t.startsWith("---\n")) return null;
|
|
18
|
-
const end = t.indexOf("\n---\n", 4);
|
|
19
|
-
if (end === -1) return null;
|
|
20
|
-
const closeEnd = end + "\n---\n".length;
|
|
21
|
-
return {
|
|
22
|
-
chunk: t.slice(0, closeEnd),
|
|
23
|
-
rest: t.slice(closeEnd),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Keep command metadata in sync without overwriting managed-block files wholesale.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} currentText normalized
|
|
31
|
-
* @param {string} templateText normalized
|
|
32
|
-
* @returns {{ nextText: string, changed: boolean }}
|
|
33
|
-
*/
|
|
34
|
-
function syncLeadingFrontmatter(currentText, templateText) {
|
|
35
|
-
const templateFm = extractLeadingFrontmatter(templateText);
|
|
36
|
-
if (!templateFm) return { nextText: currentText, changed: false };
|
|
37
|
-
|
|
38
|
-
const currentFm = extractLeadingFrontmatter(currentText);
|
|
39
|
-
if (!currentFm) {
|
|
40
|
-
const nextText = `${templateFm.chunk}${currentText}`;
|
|
41
|
-
return { nextText, changed: nextText !== currentText };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const nextText = `${templateFm.chunk}${currentFm.rest}`;
|
|
45
|
-
return { nextText, changed: nextText !== currentText };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Template file candidates for a given manifest/workspace path.
|
|
50
|
-
*
|
|
51
|
-
* NOTE: npm excludes files named `.gitignore` from published tarballs, even when placed under templates/.
|
|
52
|
-
* We store it as `gitignore` in templates and map it back at runtime.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} relPosix
|
|
55
|
-
* @returns {string[]}
|
|
56
|
-
*/
|
|
57
|
-
function templateRelCandidates(relPosix) {
|
|
58
|
-
const rel = normalizeRel(relPosix);
|
|
59
|
-
if (!rel) return [];
|
|
60
|
-
/** @type {string[]} */
|
|
61
|
-
const out = [rel];
|
|
62
|
-
if (rel === ".gitignore" || rel.endsWith("/.gitignore")) {
|
|
63
|
-
out.push(rel.replace(/(^|\/)\.gitignore$/, "$1gitignore"));
|
|
64
|
-
}
|
|
65
|
-
return Array.from(new Set(out));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Resolve a template source file path for a given workspace-relative path.
|
|
70
|
-
*
|
|
71
|
-
* @param {string} templateDir
|
|
72
|
-
* @param {string} relPosix
|
|
73
|
-
*/
|
|
74
|
-
async function resolveTemplateSourcePath(templateDir, relPosix) {
|
|
75
|
-
for (const cand of templateRelCandidates(relPosix)) {
|
|
76
|
-
const abs = templatePath(templateDir, cand);
|
|
77
|
-
if (await pathExists(abs)) return abs;
|
|
78
|
-
}
|
|
79
|
-
return templatePath(templateDir, relPosix);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Expand manifest paths, supporting patterns ending with `/**`.
|
|
84
|
-
*
|
|
85
|
-
* @param {string} templateDir
|
|
86
|
-
* @param {string[]} entries
|
|
87
|
-
*/
|
|
88
|
-
export async function expandManifestEntries(templateDir, entries) {
|
|
89
|
-
/** @type {Set<string>} */
|
|
90
|
-
const out = new Set();
|
|
91
|
-
|
|
92
|
-
for (const raw of entries) {
|
|
93
|
-
const e = normalizeRel(raw);
|
|
94
|
-
if (!e) continue;
|
|
95
|
-
if (e.includes("**")) {
|
|
96
|
-
const idx = e.indexOf("**");
|
|
97
|
-
const prefix = e.slice(0, idx).replace(/\/+$/, "");
|
|
98
|
-
if (!prefix) continue;
|
|
99
|
-
const files = await listFilesRecursive(templateDir, prefix);
|
|
100
|
-
for (const f of files) out.add(normalizeRel(f));
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
out.add(e);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return Array.from(out).sort();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @param {string} templateDir
|
|
111
|
-
* @param {string} relPosix
|
|
112
|
-
*/
|
|
113
|
-
export function templatePath(templateDir, relPosix) {
|
|
114
|
-
const rel = normalizeRel(relPosix);
|
|
115
|
-
return path.join(templateDir, ...rel.split("/"));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Copy a template file to workspace, creating parent directories.
|
|
120
|
-
*
|
|
121
|
-
* @param {{ templateDir: string, workspaceRoot: string, relPosix: string, chmod?: number }} options
|
|
122
|
-
*/
|
|
123
|
-
export async function copyTemplateFileToWorkspace(options) {
|
|
124
|
-
const rel = normalizeRel(options.relPosix);
|
|
125
|
-
const src = await resolveTemplateSourcePath(options.templateDir, rel);
|
|
126
|
-
const dest = joinRel(options.workspaceRoot, rel);
|
|
127
|
-
if (!(await pathExists(src))) {
|
|
128
|
-
const tried = templateRelCandidates(rel).map((c) => templatePath(options.templateDir, c));
|
|
129
|
-
throw new UserError(`Template file missing: ${options.relPosix}`, { details: `Tried:\n- ${tried.join("\n- ")}` });
|
|
130
|
-
}
|
|
131
|
-
await copyFile(src, dest, typeof options.chmod === "number" ? { chmod: options.chmod } : undefined);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Upsert one or more managed blocks from template into an existing workspace file.
|
|
136
|
-
*
|
|
137
|
-
* @param {{ templateDir: string, workspaceRoot: string, fileRel: string, blockIds: string[], insertIfMissing: boolean }} options
|
|
138
|
-
* @returns {Promise<{ changed: boolean }>}
|
|
139
|
-
*/
|
|
140
|
-
export async function applyManagedBlocksFromTemplate(options) {
|
|
141
|
-
const fileRel = normalizeRel(options.fileRel);
|
|
142
|
-
const dest = joinRel(options.workspaceRoot, fileRel);
|
|
143
|
-
const src = await resolveTemplateSourcePath(options.templateDir, fileRel);
|
|
144
|
-
|
|
145
|
-
if (!(await pathExists(src))) {
|
|
146
|
-
const tried = templateRelCandidates(fileRel).map((c) => templatePath(options.templateDir, c));
|
|
147
|
-
throw new UserError(`Template file missing: ${fileRel}`, { details: `Tried:\n- ${tried.join("\n- ")}` });
|
|
148
|
-
}
|
|
149
|
-
const templateText = normalizeNewlines(await readText(src));
|
|
150
|
-
|
|
151
|
-
if (!(await pathExists(dest))) {
|
|
152
|
-
await ensureDir(path.dirname(dest));
|
|
153
|
-
await writeText(dest, templateText);
|
|
154
|
-
return { changed: true };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const currentText = normalizeNewlines(await readText(dest));
|
|
158
|
-
const syncedFrontmatter = syncLeadingFrontmatter(currentText, templateText);
|
|
159
|
-
let nextText = syncedFrontmatter.nextText;
|
|
160
|
-
let anyChanged = syncedFrontmatter.changed;
|
|
161
|
-
|
|
162
|
-
for (const blockId of options.blockIds) {
|
|
163
|
-
const { blockChunk, innerText } = extractTemplateBlock(templateText, blockId);
|
|
164
|
-
const res = upsertManagedBlock(nextText, blockId, innerText, {
|
|
165
|
-
insertIfMissing: options.insertIfMissing,
|
|
166
|
-
templateBlockChunk: blockChunk,
|
|
167
|
-
});
|
|
168
|
-
nextText = res.nextText;
|
|
169
|
-
if (res.changed) anyChanged = true;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (anyChanged) {
|
|
173
|
-
await writeText(dest, nextText);
|
|
174
|
-
}
|
|
175
|
-
return { changed: anyChanged };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Ensure workspace has a directory.
|
|
180
|
-
*
|
|
181
|
-
* @param {string} workspaceRoot
|
|
182
|
-
* @param {string} relPosix
|
|
183
|
-
*/
|
|
184
|
-
export async function ensureWorkspaceDir(workspaceRoot, relPosix) {
|
|
185
|
-
const abs = joinRel(workspaceRoot, relPosix);
|
|
186
|
-
await fs.mkdir(abs, { recursive: true });
|
|
187
|
-
}
|
package/src/workspace.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import { pathExists } from "./fs.js";
|
|
4
|
-
import { UserError } from "./errors.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {string} targetPath
|
|
8
|
-
* @param {{ create?: boolean }=} options
|
|
9
|
-
*/
|
|
10
|
-
export async function resolveWorkspaceRoot(targetPath, options) {
|
|
11
|
-
const abs = path.resolve(process.cwd(), targetPath || ".");
|
|
12
|
-
if (await pathExists(abs)) {
|
|
13
|
-
const st = await fs.stat(abs);
|
|
14
|
-
if (!st.isDirectory()) throw new UserError(`Not a directory: ${abs}`);
|
|
15
|
-
return abs;
|
|
16
|
-
}
|
|
17
|
-
if (options?.create) {
|
|
18
|
-
await fs.mkdir(abs, { recursive: true });
|
|
19
|
-
return abs;
|
|
20
|
-
}
|
|
21
|
-
throw new UserError(`Path does not exist: ${abs}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
File without changes
|
|
File without changes
|