@anhlp/alp-core 0.0.0-beta.2 → 0.0.1-beta.10
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/dist/backup.js +106 -4
- package/dist/bridges.d.ts +26 -0
- package/dist/bridges.js +96 -0
- package/dist/gate-ledger.d.ts +30 -0
- package/dist/gate-ledger.js +99 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/library-edit.d.ts +57 -5
- package/dist/library-edit.js +216 -11
- package/dist/library.d.ts +14 -1
- package/dist/library.js +73 -5
- package/dist/migrations.js +1 -1
- package/dist/models.d.ts +74 -0
- package/dist/models.js +67 -1
- package/dist/packaged.d.ts +122 -0
- package/dist/packaged.js +125 -0
- package/dist/packs.d.ts +57 -0
- package/dist/packs.js +247 -0
- package/dist/permissions.d.ts +3 -2
- package/dist/permissions.js +6 -3
- package/dist/profiles.js +6 -6
- package/dist/providers.d.ts +4 -5
- package/dist/providers.js +26 -5
- package/dist/skill-validate.d.ts +85 -0
- package/dist/skill-validate.js +298 -0
- package/dist/task-rows.d.ts +5 -0
- package/dist/task-rows.js +1 -1
- package/dist/tasks.d.ts +23 -4
- package/dist/tasks.js +103 -9
- package/dist/types.d.ts +3 -0
- package/dist/upgrade.d.ts +10 -0
- package/dist/upgrade.js +112 -6
- package/dist/user-settings.d.ts +2 -0
- package/dist/user-settings.js +40 -1
- package/dist/user-worktree.d.ts +29 -0
- package/dist/user-worktree.js +242 -0
- package/dist/validation.d.ts +1 -0
- package/dist/validation.js +35 -13
- package/package.json +34 -2
- package/src/backup.js +106 -5
- package/src/bridges.js +113 -0
- package/src/gate-ledger.js +125 -0
- package/src/index.js +1 -0
- package/src/library-edit.js +227 -12
- package/src/library.js +96 -6
- package/src/migrations.js +1 -1
- package/src/models.js +87 -1
- package/src/packaged.js +207 -0
- package/src/packs.js +246 -0
- package/src/permissions.d.ts +3 -2
- package/src/permissions.js +13 -3
- package/src/profiles.js +7 -7
- package/src/providers.js +23 -7
- package/src/resolver.js +1 -1
- package/src/skill-validate.js +287 -0
- package/src/task-rows.js +1 -1
- package/src/tasks.d.ts +23 -4
- package/src/tasks.js +137 -10
- package/src/types.d.ts +3 -0
- package/src/upgrade.js +54 -6
- package/src/user-settings.d.ts +2 -0
- package/src/user-settings.js +51 -1
- package/src/user-worktree.js +259 -0
- package/src/validation.d.ts +1 -0
- package/src/validation.js +43 -14
- package/templates/ALP.md +52 -52
- package/templates/agents/lead/AGENT.md +77 -74
- package/templates/agents/main/AGENT.md +153 -141
- package/templates/agents/oracle/AGENT.md +38 -37
- package/templates/agents/peer/AGENT.md +56 -52
- package/templates/agents/reviewer/AGENT.md +63 -65
- package/templates/agents/supervisor/AGENT.md +63 -63
- package/templates/packs/architecture/agents/architect/AGENT.md +41 -0
- package/templates/packs/architecture/agents/architect/agent.json +5 -0
- package/templates/packs/architecture/agents/docs-maintainer/AGENT.md +33 -0
- package/templates/packs/architecture/agents/docs-maintainer/agent.json +4 -0
- package/templates/packs/architecture/pack.json +7 -0
- package/templates/packs/architecture/teams/blueprint/HOUSE_RULES.md +12 -0
- package/templates/packs/architecture/teams/blueprint/team.json +19 -0
- package/templates/packs/backend/pack.json +6 -0
- package/templates/packs/backend/skills/backend-development/SKILL.md +102 -0
- package/templates/packs/backend/skills/backend-development/references/api-design.md +96 -0
- package/templates/packs/backend/skills/backend-development/references/authentication.md +78 -0
- package/templates/packs/backend/skills/backend-development/references/error-handling.md +86 -0
- package/templates/packs/backend/skills/backend-development/references/testing.md +81 -0
- package/templates/packs/backend/skills/databases/SKILL.md +103 -0
- package/templates/packs/backend/skills/databases/references/query-performance.md +87 -0
- package/templates/packs/backend/skills/databases/references/schema-and-migrations.md +87 -0
- package/templates/packs/design/pack.json +6 -0
- package/templates/packs/design/skills/ui-design/SKILL.md +86 -0
- package/templates/packs/design/skills/ui-design/references/design-tokens.md +67 -0
- package/templates/packs/design/skills/ui-design/references/interaction-states.md +73 -0
- package/templates/packs/design/skills/ui-design/references/layout-and-typography.md +71 -0
- package/templates/packs/design/skills/ui-design/references/ui-review.md +83 -0
- package/templates/packs/frontend/pack.json +6 -0
- package/templates/packs/frontend/skills/frontend-development/SKILL.md +105 -0
- package/templates/packs/frontend/skills/frontend-development/references/accessibility.md +86 -0
- package/templates/packs/frontend/skills/frontend-development/references/components-and-state.md +79 -0
- package/templates/packs/frontend/skills/frontend-development/references/data-fetching.md +86 -0
- package/templates/packs/frontend/skills/frontend-development/references/frameworks.md +77 -0
- package/templates/packs/frontend/skills/frontend-development/references/performance.md +78 -0
- package/templates/packs/integration/pack.json +6 -0
- package/templates/packs/integration/skills/mcp-integration/SKILL.md +100 -0
- package/templates/packs/integration/skills/mcp-integration/references/server-implementation.md +95 -0
- package/templates/packs/integration/skills/mcp-integration/references/testing.md +78 -0
- package/templates/packs/integration/skills/mcp-integration/references/tool-design.md +97 -0
- package/templates/packs/operations/pack.json +6 -0
- package/templates/packs/operations/skills/devops/SKILL.md +85 -0
- package/templates/packs/operations/skills/devops/references/ci-cd.md +84 -0
- package/templates/packs/operations/skills/devops/references/containers.md +85 -0
- package/templates/packs/operations/skills/devops/references/deployment-and-rollback.md +85 -0
- package/templates/packs/operations/skills/devops/references/observability.md +86 -0
- package/templates/packs/quality/pack.json +6 -0
- package/templates/packs/quality/skills/web-testing/SKILL.md +102 -0
- package/templates/packs/quality/skills/web-testing/references/e2e.md +85 -0
- package/templates/packs/quality/skills/web-testing/references/performance-testing.md +85 -0
- package/templates/packs/quality/skills/web-testing/references/security-testing.md +78 -0
- package/templates/packs/quality/skills/web-testing/references/unit-and-component.md +78 -0
- package/templates/role-skills.json +4 -4
- package/templates/skills/architecture-docs/SKILL.md +81 -0
- package/templates/skills/architecture-docs/references/adr.md +62 -0
- package/templates/skills/architecture-docs/references/diagrams.md +60 -0
- package/templates/skills/architecture-docs/references/evidence-rules.md +49 -0
- package/templates/skills/bug-loop/SKILL.md +41 -40
- package/templates/skills/bug-loop/references/test-proof.md +21 -19
- package/templates/skills/compact/SKILL.md +34 -0
- package/templates/skills/curate/SKILL.md +36 -0
- package/templates/skills/feature-architecture/SKILL.md +90 -0
- package/templates/skills/feature-architecture/references/architecture-contract.md +95 -0
- package/templates/skills/feature-architecture/references/feature-design.md +69 -0
- package/templates/skills/feature-architecture/scripts/check-boundaries.mjs +270 -0
- package/templates/skills/goal-griller/SKILL.md +27 -27
- package/templates/skills/prompt-leverage/SKILL.md +29 -27
- package/templates/skills/prompt-leverage/references/brief-template.md +9 -9
- package/templates/skills/release-readiness/SKILL.md +83 -0
- package/templates/skills/release-readiness/references/checklist.md +40 -0
- package/templates/skills/release-readiness/references/verdict-template.md +53 -0
- package/templates/skills/safe-refactor/SKILL.md +84 -0
- package/templates/skills/safe-refactor/references/characterization-tests.md +57 -0
- package/templates/skills/safe-refactor/references/compatibility-checklist.md +56 -0
- package/templates/skills/security-review/SKILL.md +87 -0
- package/templates/skills/security-review/references/checklist.md +74 -0
- package/templates/skills/security-review/references/severity.md +61 -0
- package/templates/skills/sequence-execution-plan/SKILL.md +41 -38
- package/templates/skills/sequence-execution-plan/references/plan-template.md +5 -5
- package/templates/skills/skill-authoring/SKILL.md +84 -0
- package/templates/skills/skill-authoring/references/evaluation.md +45 -0
- package/templates/skills/skill-authoring/references/skill-anatomy.md +74 -0
- package/templates/skills/skill-authoring/references/trigger-design.md +52 -0
- package/templates/skills/smart-commits/SKILL.md +37 -36
- package/templates/skills/test-strategy/SKILL.md +83 -0
- package/templates/skills/test-strategy/references/contract-tests.md +46 -0
- package/templates/skills/test-strategy/references/risk-matrix.md +53 -0
- package/templates/skills/xia/SKILL.md +40 -38
- package/templates/teams/cafe/HOUSE_RULES.md +1 -1
- package/templates/teams/cafe/team.json +1 -1
- package/templates/teams/pho/HOUSE_RULES.md +1 -1
- package/templates/teams/pho/team.json +1 -1
package/dist/providers.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export function validateProvider(config: any, source: any, id: any): any;
|
|
3
3
|
/**
|
|
4
4
|
* A provider of the library, with its id; undefined when there is none.
|
|
5
|
-
* @returns {Promise<{ id: string, kind: 'acp' | 'antigravity', label: string, description?: string, command: string, args: string[], env: Record<string, string>, models?: Array<{ id: string, label?: string, description?: string }>, additionalModels?: Array<{ id: string, label?: string, description?: string }>, enabled?: boolean, params?: Record<string, unknown
|
|
5
|
+
* @returns {Promise<{ id: string, kind: 'acp' | 'antigravity', label: string, description?: string, command: string, args: string[], env: Record<string, string>, models?: Array<{ id: string, label?: string, description?: string }>, additionalModels?: Array<{ id: string, label?: string, description?: string }>, enabled?: boolean, params?: Record<string, unknown> } | undefined>}
|
|
6
6
|
*/
|
|
7
7
|
export function loadProvider(library: any, id: any): Promise<{
|
|
8
8
|
id: string;
|
|
@@ -24,10 +24,9 @@ export function loadProvider(library: any, id: any): Promise<{
|
|
|
24
24
|
}>;
|
|
25
25
|
enabled?: boolean;
|
|
26
26
|
params?: Record<string, unknown>;
|
|
27
|
-
readOnlyMode?: "instructions" | "reject";
|
|
28
27
|
} | undefined>;
|
|
29
28
|
/** Every provider of the library, by id. */
|
|
30
|
-
export function listProviders(library: any): Promise<{
|
|
29
|
+
export function listProviders(library: any, { onError }?: {}): Promise<{
|
|
31
30
|
id: string;
|
|
32
31
|
kind: "acp" | "antigravity";
|
|
33
32
|
label: string;
|
|
@@ -47,7 +46,6 @@ export function listProviders(library: any): Promise<{
|
|
|
47
46
|
}>;
|
|
48
47
|
enabled?: boolean;
|
|
49
48
|
params?: Record<string, unknown>;
|
|
50
|
-
readOnlyMode?: "instructions" | "reject";
|
|
51
49
|
}[]>;
|
|
52
50
|
/**
|
|
53
51
|
* Splits an ACP model id, `<provider>` or `<provider>/<model>`, as resolveSession keeps it
|
|
@@ -63,11 +61,12 @@ export function acpModel(model: any): {
|
|
|
63
61
|
* native executable it calls, or the Node script, under this Node. A bare name with an .exe or
|
|
64
62
|
* .com on PATH, any other command, and every command elsewhere are returned as they are.
|
|
65
63
|
* @param {string} command @param {string[]} [args] @param {Record<string, string | undefined>} [env]
|
|
66
|
-
* @returns {{ command: string, args: string[] }}
|
|
64
|
+
* @returns {{ command: string, args: string[], env?: Record<string, string> }}
|
|
67
65
|
*/
|
|
68
66
|
export function launchCommand(command: string, args?: string[], env?: Record<string, string | undefined>): {
|
|
69
67
|
command: string;
|
|
70
68
|
args: string[];
|
|
69
|
+
env?: Record<string, string>;
|
|
71
70
|
};
|
|
72
71
|
/**
|
|
73
72
|
* ACP providers (ALPD §46): agents that speak the Agent Client Protocol, such as Gemini
|
package/dist/providers.js
CHANGED
|
@@ -4,7 +4,9 @@ import { readdir, readFile } from "node:fs/promises";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { AlpError } from "./errors.js";
|
|
6
6
|
import { settingsKeys, unknownMessage } from "./validation.js";
|
|
7
|
-
|
|
7
|
+
import { scriptCommand } from "./packaged.js";
|
|
8
|
+
var legacyWarnings = /* @__PURE__ */ new Set();
|
|
9
|
+
var PROVIDER_SETTINGS = ["$schema", "kind", "label", "description", "command", "args", "env", "models", "additionalModels", "enabled", "params"];
|
|
8
10
|
var BUILTIN_RUNTIMES = ["codex", "claude", "acp", "antigravity"];
|
|
9
11
|
var RESERVED_PROVIDERS = [...BUILTIN_RUNTIMES, "alp"];
|
|
10
12
|
var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -16,11 +18,11 @@ function validateProvider(config, source, id) {
|
|
|
16
18
|
};
|
|
17
19
|
if (id !== void 0) check(validId(id) && (!RESERVED_PROVIDERS.includes(id) || id === "antigravity" && config?.kind === "antigravity"), `'${id}' cannot name a provider: ${RESERVED_PROVIDERS.join(", ")} are taken`);
|
|
18
20
|
check(object(config), "expected an object");
|
|
21
|
+
check(!Object.hasOwn(config, "readOnlyMode"), "readOnlyMode was removed; delete it and choose the session mode (read-only, workspace-write or full-access). Existing native sessions keep their mode");
|
|
19
22
|
const { unknown } = settingsKeys(config, PROVIDER_SETTINGS);
|
|
20
23
|
check(!unknown.length, unknown.length ? unknownMessage(unknown[0], PROVIDER_SETTINGS) : "");
|
|
21
24
|
check(["acp", "antigravity"].includes(config.kind), 'kind must be "acp" or "antigravity"');
|
|
22
25
|
if (config.kind === "antigravity" && id !== void 0) check(id === "antigravity", "Antigravity must use provider ID antigravity");
|
|
23
|
-
if (config.readOnlyMode !== void 0) check(config.kind === "antigravity" && ["instructions", "reject"].includes(config.readOnlyMode), 'readOnlyMode is only for Antigravity and must be "instructions" or "reject"');
|
|
24
26
|
for (const key of ["label", "description"]) if (config[key] !== void 0) check(typeof config[key] === "string", `${key} must be a string`);
|
|
25
27
|
check(nonempty(config.command), "command must be a nonempty string");
|
|
26
28
|
if (config.args !== void 0) check(Array.isArray(config.args) && config.args.every((arg) => typeof arg === "string"), "args must be a list of strings");
|
|
@@ -50,11 +52,19 @@ async function loadProvider(library, id) {
|
|
|
50
52
|
} catch (cause) {
|
|
51
53
|
throw new AlpError("INVALID_PROVIDER", `${file}: ${cause.message}`, { cause });
|
|
52
54
|
}
|
|
55
|
+
if (config?.kind === "antigravity" && Object.hasOwn(config, "readOnlyMode")) {
|
|
56
|
+
config = { ...config };
|
|
57
|
+
delete config.readOnlyMode;
|
|
58
|
+
if (!legacyWarnings.has(file)) {
|
|
59
|
+
legacyWarnings.add(file);
|
|
60
|
+
console.warn(`${file}: readOnlyMode was removed; delete it and select a session mode (read-only, workspace-write or full-access). Existing sessions keep their mode.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
53
63
|
validateProvider(config, file, id);
|
|
54
64
|
const command = /[\\/]/.test(config.command) ? path.resolve(path.dirname(file), config.command) : config.command;
|
|
55
65
|
return { id, ...config, label: config.label ?? id, command, args: config.args ?? [], env: config.env ?? {} };
|
|
56
66
|
}
|
|
57
|
-
async function listProviders(library) {
|
|
67
|
+
async function listProviders(library, { onError } = {}) {
|
|
58
68
|
if (!library) return [];
|
|
59
69
|
let names = [];
|
|
60
70
|
try {
|
|
@@ -64,7 +74,14 @@ async function listProviders(library) {
|
|
|
64
74
|
}
|
|
65
75
|
const providers = [];
|
|
66
76
|
for (const name of names.filter((name2) => name2.endsWith(".json")).sort()) {
|
|
67
|
-
|
|
77
|
+
let provider;
|
|
78
|
+
try {
|
|
79
|
+
provider = await loadProvider(library, name.slice(0, -5));
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (!onError) throw error;
|
|
82
|
+
onError(error, name);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
68
85
|
if (provider) providers.push(provider);
|
|
69
86
|
}
|
|
70
87
|
return providers;
|
|
@@ -82,7 +99,11 @@ function launchCommand(command, args = [], env = process.env) {
|
|
|
82
99
|
if (!existsSync(shim)) continue;
|
|
83
100
|
const text = readFileSync(shim, "utf8");
|
|
84
101
|
const script = /"%_prog%"((?:\s+[^\s"]+)*)\s+"%~?dp0%\\?([^"]+)"\s+%\*/i.exec(text);
|
|
85
|
-
if (script)
|
|
102
|
+
if (script) {
|
|
103
|
+
const flags = script[1].split(/\s+/).filter(Boolean);
|
|
104
|
+
const run = scriptCommand(path.join(directory, script[2]), args);
|
|
105
|
+
return { command: run.command, args: [...flags, ...run.args] };
|
|
106
|
+
}
|
|
86
107
|
const native = /^\s*"%~?dp0%\\?([^"]+\.(?:exe|com))"\s+%\*/im.exec(text);
|
|
87
108
|
if (native) return { command: path.join(directory, native[1]), args };
|
|
88
109
|
break;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses the YAML subset skills use: `key: scalar`, quoted scalars, block scalars (`|`, `>`),
|
|
3
|
+
* multi-line plain scalars, comments, and one level of `key:` + indented `sub: value` (metadata).
|
|
4
|
+
* Anything else (sequences, flow collections, anchors, tags) is reported as unsupported.
|
|
5
|
+
* @returns {{ data: Record<string, unknown>, problems: string[] }}
|
|
6
|
+
*/
|
|
7
|
+
export function parseFrontmatter(text: any): {
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
problems: string[];
|
|
10
|
+
};
|
|
11
|
+
/** The frontmatter block and body of a SKILL.md, or undefined frontmatter when it has none. */
|
|
12
|
+
export function splitSkill(text: any): {
|
|
13
|
+
frontmatter: string;
|
|
14
|
+
body: any;
|
|
15
|
+
} | {
|
|
16
|
+
frontmatter: undefined;
|
|
17
|
+
body: any;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The relative files a Markdown text points to: link targets and code spans naming a resource
|
|
21
|
+
* directory (`references/x.md`). URLs, anchors and template placeholders are skipped.
|
|
22
|
+
*/
|
|
23
|
+
export function skillReferences(markdown: any): any[];
|
|
24
|
+
/**
|
|
25
|
+
* Checks frontmatter text against the specification. `directory` is the skill directory's name.
|
|
26
|
+
* @returns {{ data: Record<string, unknown>, findings: Array<{ level: 'error' | 'warning', code: string, message: string }> }}
|
|
27
|
+
*/
|
|
28
|
+
export function checkFrontmatter(frontmatter: any, directory: any, { strict }?: {
|
|
29
|
+
strict?: boolean | undefined;
|
|
30
|
+
}): {
|
|
31
|
+
data: Record<string, unknown>;
|
|
32
|
+
findings: Array<{
|
|
33
|
+
level: "error" | "warning";
|
|
34
|
+
code: string;
|
|
35
|
+
message: string;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Validates one skill directory.
|
|
40
|
+
* @param {string} directory absolute or relative path of the skill directory
|
|
41
|
+
* @param {{ mode?: 'strict' | 'legacy', shipped?: boolean }} [options] `shipped`: the skill ships in
|
|
42
|
+
* ALP's templates, which bundles carry as UTF-8 text, so every file must be text
|
|
43
|
+
* @returns {Promise<{ name: string, directory: string, mode: 'strict' | 'legacy', ok: boolean, errors: Finding[], warnings: Finding[], files: number }>}
|
|
44
|
+
* @typedef {{ code: string, message: string, file?: string }} Finding
|
|
45
|
+
*/
|
|
46
|
+
export function validateSkill(directory: string, { mode, shipped }?: {
|
|
47
|
+
mode?: "strict" | "legacy";
|
|
48
|
+
shipped?: boolean;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
name: string;
|
|
51
|
+
directory: string;
|
|
52
|
+
mode: "strict" | "legacy";
|
|
53
|
+
ok: boolean;
|
|
54
|
+
errors: Finding[];
|
|
55
|
+
warnings: Finding[];
|
|
56
|
+
files: number;
|
|
57
|
+
}>;
|
|
58
|
+
/** One line per finding, for a terminal. */
|
|
59
|
+
export function formatValidation(report: any): string;
|
|
60
|
+
/**
|
|
61
|
+
* Skill validation (Agent Skills format, https://agentskills.io/specification): a skill is a
|
|
62
|
+
* directory holding SKILL.md, whose YAML frontmatter names it and says what it is for, and the
|
|
63
|
+
* references, scripts and assets SKILL.md points to.
|
|
64
|
+
*
|
|
65
|
+
* Two modes. `strict` is for skills ALP ships, packs and new skills: format problems are errors.
|
|
66
|
+
* `legacy` (the default) is for skills already in a user's library or project: format problems
|
|
67
|
+
* are warnings with a migration hint, since ALP never rewrites them and the runtime keeps loading
|
|
68
|
+
* them. A symlink leaving the skill, a broken symlink or an unreadable file is an error in both
|
|
69
|
+
* modes; a plain path leaving the skill is an error in strict mode and a warning in legacy mode. Validation only reads; it never runs a script or follows a link outside the skill.
|
|
70
|
+
*/
|
|
71
|
+
/** Frontmatter keys of the Agent Skills specification. */
|
|
72
|
+
export const SPEC_KEYS: string[];
|
|
73
|
+
export const NAME_MAX: 64;
|
|
74
|
+
export const DESCRIPTION_MAX: 1024;
|
|
75
|
+
/** How much of a description ALP's skill index shows (resolve.ts SKILL_DESCRIPTION_CHARS). */
|
|
76
|
+
export const INDEX_DESCRIPTION_CHARS: 400;
|
|
77
|
+
export function specName(name: any): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Validates one skill directory.
|
|
80
|
+
*/
|
|
81
|
+
export type Finding = {
|
|
82
|
+
code: string;
|
|
83
|
+
message: string;
|
|
84
|
+
file?: string;
|
|
85
|
+
};
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// packages/core/src/skill-validate.js
|
|
2
|
+
import { lstat, readFile, readdir, realpath, stat } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
var SPEC_KEYS = ["name", "description", "license", "compatibility", "metadata", "allowed-tools"];
|
|
5
|
+
var RUNTIME_KEYS = ["argument-hint", "disable-model-invocation", "user-invocable", "model", "version", "when_to_use", "mode"];
|
|
6
|
+
var NAME_MAX = 64;
|
|
7
|
+
var DESCRIPTION_MAX = 1024;
|
|
8
|
+
var INDEX_DESCRIPTION_CHARS = 400;
|
|
9
|
+
var COMPATIBILITY_MAX = 500;
|
|
10
|
+
var BODY_LINES_RECOMMENDED = 500;
|
|
11
|
+
var MAX_FILES = 2e3;
|
|
12
|
+
var NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
13
|
+
var TRIGGER_RE = /\b(use|when|before|after|whenever|for)\b|dùng|khi/i;
|
|
14
|
+
var specName = (name) => typeof name === "string" && name.length >= 1 && name.length <= NAME_MAX && NAME_RE.test(name);
|
|
15
|
+
function doubleQuoted(raw) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(`"${raw.replace(/\\'/g, "'")}"`);
|
|
18
|
+
} catch {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function parseFrontmatter(text) {
|
|
23
|
+
const lines = text.split(/\r?\n/);
|
|
24
|
+
const data = {};
|
|
25
|
+
const problems = [];
|
|
26
|
+
const indent = (line) => /^ */.exec(line)[0].length;
|
|
27
|
+
let i = 0;
|
|
28
|
+
const scalar = (raw, key, baseIndent) => {
|
|
29
|
+
const value = raw.trim();
|
|
30
|
+
if (!value) {
|
|
31
|
+
const nested = {};
|
|
32
|
+
let found = false;
|
|
33
|
+
while (i < lines.length && (lines[i].trim() === "" || lines[i].trimStart().startsWith("#") || indent(lines[i]) > baseIndent)) {
|
|
34
|
+
const line = lines[i++];
|
|
35
|
+
if (!line.trim() || line.trimStart().startsWith("#")) continue;
|
|
36
|
+
const match = /^\s+([^:#\s][^:]*?):(?:\s+(.*)|\s*)$/.exec(line);
|
|
37
|
+
if (!match) {
|
|
38
|
+
problems.push(`${key}: unsupported YAML in '${line.trim()}' (use "key: value" lines)`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
found = true;
|
|
42
|
+
nested[match[1].trim()] = scalar(match[2] ?? "", `${key}.${match[1].trim()}`, indent(line));
|
|
43
|
+
}
|
|
44
|
+
return found ? nested : "";
|
|
45
|
+
}
|
|
46
|
+
if (value.startsWith('"')) {
|
|
47
|
+
const end = /^"((?:[^"\\]|\\.)*)"\s*(?:#.*)?$/.exec(value);
|
|
48
|
+
if (!end) {
|
|
49
|
+
problems.push(`${key}: unterminated or multi-line double-quoted value`);
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
const parsed = doubleQuoted(end[1]);
|
|
53
|
+
if (parsed === void 0) problems.push(`${key}: invalid escape in double-quoted value`);
|
|
54
|
+
return parsed;
|
|
55
|
+
}
|
|
56
|
+
if (value.startsWith("'")) {
|
|
57
|
+
const end = /^'((?:[^']|'')*)'\s*(?:#.*)?$/.exec(value);
|
|
58
|
+
if (!end) {
|
|
59
|
+
problems.push(`${key}: unterminated or multi-line single-quoted value`);
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
return end[1].replaceAll("''", "'");
|
|
63
|
+
}
|
|
64
|
+
const block = /^([|>])([+-]?)([1-9]?)([+-]?)\s*(?:#.*)?$/.exec(value);
|
|
65
|
+
if (block?.[3]) problems.push(`${key}: block scalar indentation indicators are not supported; indent the text instead`);
|
|
66
|
+
if (block) {
|
|
67
|
+
const body = [];
|
|
68
|
+
while (i < lines.length && (lines[i].trim() === "" || indent(lines[i]) > baseIndent)) body.push(lines[i++]);
|
|
69
|
+
while (body.length && !body[body.length - 1].trim()) body.pop();
|
|
70
|
+
const width = Math.min(...body.filter((line) => line.trim()).map(indent));
|
|
71
|
+
const content = body.map((line) => line.slice(Number.isFinite(width) ? width : 0));
|
|
72
|
+
const joined = block[1] === "|" ? content.join("\n") : content.join("\n").replace(/([^\n])\n(?=[^\n])/g, "$1 ");
|
|
73
|
+
return (block[2] || block[4]) === "-" ? joined : `${joined}
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
if (/^[[{&*!%@`]/.test(value) || value.startsWith("- ")) {
|
|
77
|
+
problems.push(`${key}: unsupported YAML value '${value.slice(0, 40)}' (use a plain or quoted string)`);
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
let plain = value.replace(/\s+#.*$/, "");
|
|
81
|
+
while (i < lines.length && lines[i].trim() && indent(lines[i]) > baseIndent && !lines[i].trimStart().startsWith("#")) plain += ` ${lines[i++].trim()}`;
|
|
82
|
+
if (/:\s/.test(plain) || plain.endsWith(":")) problems.push(`${key}: plain value contains ": " which YAML rejects; quote the value`);
|
|
83
|
+
return plain;
|
|
84
|
+
};
|
|
85
|
+
while (i < lines.length) {
|
|
86
|
+
const line = lines[i++];
|
|
87
|
+
if (!line.trim() || line.trimStart().startsWith("#")) continue;
|
|
88
|
+
if (indent(line) > 0) {
|
|
89
|
+
problems.push(`unexpected indentation: '${line.trim().slice(0, 40)}'`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const match = /^([^:#\s][^:]*?):(?:\s+(.*)|\s*)$/.exec(line);
|
|
93
|
+
if (!match) {
|
|
94
|
+
problems.push(`not a "key: value" line: '${line.trim().slice(0, 40)}'`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const key = match[1].trim();
|
|
98
|
+
if (Object.hasOwn(data, key)) problems.push(`${key}: duplicate key`);
|
|
99
|
+
data[key] = scalar(match[2] ?? "", key, 0);
|
|
100
|
+
}
|
|
101
|
+
return { data, problems };
|
|
102
|
+
}
|
|
103
|
+
function splitSkill(text) {
|
|
104
|
+
const match = /^?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text);
|
|
105
|
+
return match ? { frontmatter: match[1], body: text.slice(match[0].length) } : { frontmatter: void 0, body: text };
|
|
106
|
+
}
|
|
107
|
+
function skillReferences(markdown) {
|
|
108
|
+
const found = /* @__PURE__ */ new Set();
|
|
109
|
+
const withoutFences = markdown.replace(/^(```|~~~)[\s\S]*?^\1/gm, "");
|
|
110
|
+
for (const match of withoutFences.matchAll(/\]\(\s*<?([^)\s>]+)>?(?:\s+"[^"]*")?\s*\)/g)) found.add(match[1]);
|
|
111
|
+
for (const match of withoutFences.matchAll(/`([^`\s]+)`/g)) {
|
|
112
|
+
if (/^(?:\.\/)?references\/[^*<>{}$]+\.[a-z0-9]+$/i.test(match[1])) found.add(match[1]);
|
|
113
|
+
}
|
|
114
|
+
return [...found].filter((target) => !/^[a-z][\w+.-]*:/i.test(target) && !target.startsWith("#") && !target.startsWith("//")).map((target) => {
|
|
115
|
+
const plain = target.split("#")[0];
|
|
116
|
+
try {
|
|
117
|
+
return decodeURI(plain);
|
|
118
|
+
} catch {
|
|
119
|
+
return plain;
|
|
120
|
+
}
|
|
121
|
+
}).filter(Boolean);
|
|
122
|
+
}
|
|
123
|
+
var inside = (root, target) => {
|
|
124
|
+
const relative = path.relative(root, target);
|
|
125
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
126
|
+
};
|
|
127
|
+
function checkFrontmatter(frontmatter, directory, { strict = false } = {}) {
|
|
128
|
+
const findings = [];
|
|
129
|
+
const format = (code, message) => findings.push({ level: strict ? "error" : "warning", code, message });
|
|
130
|
+
const error = (code, message) => findings.push({ level: "error", code, message });
|
|
131
|
+
const warn = (code, message) => findings.push({ level: "warning", code, message });
|
|
132
|
+
if (frontmatter === void 0) {
|
|
133
|
+
format("NO_FRONTMATTER", 'SKILL.md has no YAML frontmatter; add "---\\nname: ...\\ndescription: ...\\n---" so agents see what the skill is for');
|
|
134
|
+
return { data: {}, findings };
|
|
135
|
+
}
|
|
136
|
+
const { data, problems } = parseFrontmatter(frontmatter);
|
|
137
|
+
for (const problem of problems) format("YAML", `frontmatter: ${problem}`);
|
|
138
|
+
const { name, description } = data;
|
|
139
|
+
if (name === void 0) format("NAME_MISSING", "frontmatter has no name");
|
|
140
|
+
else if (typeof name !== "string" || !specName(name)) format("NAME_FORMAT", `name '${name}' must be 1-${NAME_MAX} lowercase letters, digits and single hyphens, not starting or ending with one`);
|
|
141
|
+
if (typeof name === "string" && directory !== void 0 && name !== directory) format("NAME_DIRECTORY", `name '${name}' differs from its directory '${directory}'; agents find it by the directory name`);
|
|
142
|
+
if (directory !== void 0 && !specName(directory)) format("DIRECTORY_NAME", `directory '${directory}' is not a valid skill name; rename it to lowercase letters, digits and hyphens`);
|
|
143
|
+
if (description === void 0 || typeof description === "string" && !description.trim()) format("DESCRIPTION_MISSING", "frontmatter has no description: it is all an agent sees before opening the skill");
|
|
144
|
+
else if (typeof description !== "string") format("DESCRIPTION_FORMAT", "description must be text");
|
|
145
|
+
else {
|
|
146
|
+
const flat = description.replace(/\s+/g, " ").trim();
|
|
147
|
+
if (flat.length > DESCRIPTION_MAX) format("DESCRIPTION_LENGTH", `description has ${flat.length} characters; the limit is ${DESCRIPTION_MAX}`);
|
|
148
|
+
else if (flat.length > INDEX_DESCRIPTION_CHARS) warn("DESCRIPTION_CLIPPED", `description has ${flat.length} characters; ALP's skill index shows the first ${INDEX_DESCRIPTION_CHARS}`);
|
|
149
|
+
if (flat.length < 40) warn("DESCRIPTION_SHORT", "description is under 40 characters; say what the skill does and when to use it");
|
|
150
|
+
if (!TRIGGER_RE.test(flat)) warn("DESCRIPTION_TRIGGER", 'description does not say when to use the skill (for example "Use when ...")');
|
|
151
|
+
if (/[<>]/.test(flat)) format("DESCRIPTION_ANGLE", "description contains < or >, which some runtimes reject");
|
|
152
|
+
}
|
|
153
|
+
if (data.compatibility !== void 0 && (typeof data.compatibility !== "string" || data.compatibility.length > COMPATIBILITY_MAX)) format("COMPATIBILITY", `compatibility must be text of at most ${COMPATIBILITY_MAX} characters`);
|
|
154
|
+
if (data.license !== void 0 && typeof data.license !== "string") format("LICENSE", "license must be text");
|
|
155
|
+
if (data["allowed-tools"] !== void 0 && typeof data["allowed-tools"] !== "string") format("ALLOWED_TOOLS", "allowed-tools must be a space-separated string");
|
|
156
|
+
if (data["allowed-tools"] !== void 0) warn("ALLOWED_TOOLS_ADVISORY", "allowed-tools is advisory: ALP permissions come from the session mode and permission profiles, never from a skill");
|
|
157
|
+
if (data.metadata !== void 0 && (typeof data.metadata !== "object" || data.metadata === null || Object.values(data.metadata).some((value) => typeof value !== "string"))) format("METADATA", "metadata must map names to text values");
|
|
158
|
+
for (const key of Object.keys(data)) {
|
|
159
|
+
if (SPEC_KEYS.includes(key)) continue;
|
|
160
|
+
if (RUNTIME_KEYS.includes(key)) format("RUNTIME_KEY", `'${key}' is specific to one runtime; other runtimes ignore it`);
|
|
161
|
+
else format("UNKNOWN_KEY", `unknown frontmatter key '${key}'; the specification allows ${SPEC_KEYS.join(", ")}`);
|
|
162
|
+
}
|
|
163
|
+
return { data, findings };
|
|
164
|
+
}
|
|
165
|
+
var isText = (buffer) => !buffer.includes(0) && Buffer.from(buffer.toString("utf8"), "utf8").equals(buffer);
|
|
166
|
+
async function validateSkill(directory, { mode = "legacy", shipped = false } = {}) {
|
|
167
|
+
const root = path.resolve(directory);
|
|
168
|
+
const strict = mode === "strict";
|
|
169
|
+
const findings = [];
|
|
170
|
+
const add = (level, code, message, file) => findings.push({ level, code, message, ...file ? { file } : {} });
|
|
171
|
+
const format = (code, message, file) => add(strict ? "error" : "warning", code, message, file);
|
|
172
|
+
const result = () => {
|
|
173
|
+
const errors = findings.filter((f) => f.level === "error").map(({ level, ...f }) => f);
|
|
174
|
+
const warnings = findings.filter((f) => f.level === "warning").map(({ level, ...f }) => f);
|
|
175
|
+
return { name: path.basename(root), directory: root, mode, ok: errors.length === 0, errors, warnings, files };
|
|
176
|
+
};
|
|
177
|
+
let files = 0;
|
|
178
|
+
const info = await lstat(root).catch(() => void 0);
|
|
179
|
+
if (!info) {
|
|
180
|
+
add("error", "NOT_FOUND", `no skill directory at ${root}`);
|
|
181
|
+
return result();
|
|
182
|
+
}
|
|
183
|
+
if (info.isSymbolicLink()) add("warning", "DIRECTORY_LINK", "the skill directory is a symbolic link; its contents are checked where it points");
|
|
184
|
+
const real = await realpath(root).catch(() => root);
|
|
185
|
+
if (!await stat(real).then((s) => s.isDirectory(), () => false)) {
|
|
186
|
+
add("error", "NOT_DIRECTORY", `${root} is not a directory`);
|
|
187
|
+
return result();
|
|
188
|
+
}
|
|
189
|
+
const markdown = [];
|
|
190
|
+
let stopped = false;
|
|
191
|
+
const walk = async (relative) => {
|
|
192
|
+
let entries;
|
|
193
|
+
try {
|
|
194
|
+
entries = await readdir(path.join(real, relative), { withFileTypes: true });
|
|
195
|
+
} catch (error) {
|
|
196
|
+
add("error", "UNREADABLE", `${relative || "."} cannot be read: ${error.code ?? error.message}`, relative || void 0);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
200
|
+
if (stopped) return;
|
|
201
|
+
const rel = path.join(relative, entry.name);
|
|
202
|
+
const full = path.join(real, rel);
|
|
203
|
+
if (++files > MAX_FILES) {
|
|
204
|
+
stopped = true;
|
|
205
|
+
add("error", "TOO_MANY_FILES", `more than ${MAX_FILES} files; a skill should hold instructions and small resources`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (entry.name === "node_modules" || entry.name === ".git") {
|
|
209
|
+
add("warning", "BUNDLED_DEPENDENCIES", `${rel} is bundled; skills must not carry installed dependencies or repositories`, rel);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (entry.isSymbolicLink()) {
|
|
213
|
+
const target = await realpath(full).catch(() => void 0);
|
|
214
|
+
if (target === void 0) add("error", "BROKEN_SYMLINK", `${rel} is a symbolic link to nothing`, rel);
|
|
215
|
+
else if (!inside(real, target)) add("error", "UNSAFE_SYMLINK", `${rel} links outside the skill (${target})`, rel);
|
|
216
|
+
else if (shipped) add("error", "SHIPPED_SYMLINK", `${rel} is a symbolic link; shipped skills hold plain files`, rel);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (entry.isDirectory()) {
|
|
220
|
+
await walk(rel);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (!entry.isFile()) {
|
|
224
|
+
add("error", "SPECIAL_FILE", `${rel} is not a regular file`, rel);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const posix = rel.split(path.sep).join("/");
|
|
228
|
+
if (shipped || posix.endsWith(".md") || posix.startsWith("scripts/")) {
|
|
229
|
+
let buffer;
|
|
230
|
+
try {
|
|
231
|
+
buffer = await readFile(full);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
add("error", "UNREADABLE", `${rel} cannot be read: ${error.code ?? error.message}`, rel);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (shipped && !isText(buffer)) add("error", "SHIPPED_BINARY", `${rel} is not UTF-8 text; ALP bundles carry shipped skills as text`, rel);
|
|
237
|
+
if (posix.endsWith(".md")) markdown.push([posix, buffer.toString("utf8")]);
|
|
238
|
+
if (posix.startsWith("scripts/") && !shipped && process.platform !== "win32" && buffer.subarray(0, 2).toString() === "#!" && !((await stat(full)).mode & 73)) {
|
|
239
|
+
add("warning", "SCRIPT_NOT_EXECUTABLE", `${rel} has a #! line but is not executable; run it with its interpreter or chmod +x it`, rel);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
await walk("");
|
|
245
|
+
const skillFile = markdown.find(([file]) => file === "SKILL.md");
|
|
246
|
+
if (!skillFile) {
|
|
247
|
+
const other = await readdir(real).then((list) => list.find((name) => name.toLowerCase() === "skill.md"), () => void 0);
|
|
248
|
+
add("error", "SKILL_MD_MISSING", other ? `found ${other}; the file must be named SKILL.md` : "no SKILL.md");
|
|
249
|
+
return result();
|
|
250
|
+
}
|
|
251
|
+
const { frontmatter, body } = splitSkill(skillFile[1]);
|
|
252
|
+
for (const finding of checkFrontmatter(frontmatter, path.basename(root), { strict }).findings) add(finding.level, finding.code, finding.message, "SKILL.md");
|
|
253
|
+
if (!body.trim()) format("BODY_EMPTY", "SKILL.md has no instructions after its frontmatter", "SKILL.md");
|
|
254
|
+
const lines = body.split("\n").length;
|
|
255
|
+
if (lines > BODY_LINES_RECOMMENDED) add("warning", "BODY_LONG", `SKILL.md body has ${lines} lines; move detail into references/ (recommended under ${BODY_LINES_RECOMMENDED})`, "SKILL.md");
|
|
256
|
+
for (const [file, text] of markdown) {
|
|
257
|
+
const content = file === "SKILL.md" ? body : text;
|
|
258
|
+
for (const target of skillReferences(content)) {
|
|
259
|
+
if (path.isAbsolute(target) || /^[a-z]:[\\/]/i.test(target) || target.startsWith("~")) {
|
|
260
|
+
format("ABSOLUTE_REFERENCE", `${file} names the absolute path ${target}; use a path relative to the skill`, file);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const resolved = path.resolve(real, path.dirname(file), target);
|
|
264
|
+
if (!inside(real, resolved)) {
|
|
265
|
+
format("REFERENCE_OUTSIDE", `${file} points outside the skill: ${target}`, file);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const linked = await lstat(resolved).catch(() => void 0);
|
|
269
|
+
if (!linked) {
|
|
270
|
+
format("BROKEN_REFERENCE", `${file} points to ${target}, which does not exist`, file);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (linked.isSymbolicLink()) {
|
|
274
|
+
const target2 = await realpath(resolved).catch(() => void 0);
|
|
275
|
+
if (!target2 || !inside(real, target2)) add("error", "REFERENCE_OUTSIDE", `${file} points through a link outside the skill: ${target}`, file);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return result();
|
|
280
|
+
}
|
|
281
|
+
function formatValidation(report) {
|
|
282
|
+
const head = `${report.ok ? "ok " : "FAIL"} ${report.name} (${report.mode}) ${report.directory}`;
|
|
283
|
+
const rows = [...report.errors.map((f) => ` error ${f.code}: ${f.message}`), ...report.warnings.map((f) => ` warning ${f.code}: ${f.message}`)];
|
|
284
|
+
return [head, ...rows].join("\n");
|
|
285
|
+
}
|
|
286
|
+
export {
|
|
287
|
+
DESCRIPTION_MAX,
|
|
288
|
+
INDEX_DESCRIPTION_CHARS,
|
|
289
|
+
NAME_MAX,
|
|
290
|
+
SPEC_KEYS,
|
|
291
|
+
checkFrontmatter,
|
|
292
|
+
formatValidation,
|
|
293
|
+
parseFrontmatter,
|
|
294
|
+
skillReferences,
|
|
295
|
+
specName,
|
|
296
|
+
splitSkill,
|
|
297
|
+
validateSkill
|
|
298
|
+
};
|
package/dist/task-rows.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export function taskRows(projectRoot: string): Promise<{
|
|
|
25
25
|
summary: string;
|
|
26
26
|
} | undefined;
|
|
27
27
|
approvals?: {
|
|
28
|
+
rejected?: {
|
|
29
|
+
reason?: string | undefined;
|
|
30
|
+
at: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
options?: string[] | undefined;
|
|
28
33
|
gate: string;
|
|
29
34
|
note: string;
|
|
30
35
|
}[] | undefined;
|
package/dist/task-rows.js
CHANGED
|
@@ -13,7 +13,7 @@ async function taskRows(projectRoot) {
|
|
|
13
13
|
}
|
|
14
14
|
const rows = tasks.map((task) => {
|
|
15
15
|
const row = summarize(task, tasks);
|
|
16
|
-
const approvals = task.status === "closed" ? [] : task.gates.filter((gate) => gate.kind === "human" && !gate.resolved).map((gate) => ({ gate: gate.id, note: gate.note ?? "" }));
|
|
16
|
+
const approvals = task.status === "closed" ? [] : task.gates.filter((gate) => gate.kind === "human" && !gate.resolved).map((gate) => ({ gate: gate.id, note: gate.note ?? "", ...gate.options?.length ? { options: gate.options } : {}, ...gate.rejected ? { rejected: { at: gate.rejected.at, ...gate.rejected.reason ? { reason: gate.rejected.reason } : {} } } : {} }));
|
|
17
17
|
const waits = task.status === "closed" ? [] : gatesOf(task, tasks);
|
|
18
18
|
return {
|
|
19
19
|
id: task.id,
|
package/dist/tasks.d.ts
CHANGED
|
@@ -47,8 +47,15 @@ export type TaskGate = {
|
|
|
47
47
|
ref?: string;
|
|
48
48
|
at: string;
|
|
49
49
|
by: string;
|
|
50
|
-
|
|
50
|
+
/** A human gate's answers; choosing any of them approves it. */
|
|
51
|
+
options?: string[];
|
|
52
|
+
resolved?: { at: string; by: string; note?: string; choice?: string; channel?: GateChannel; notified?: string; overridden?: true };
|
|
53
|
+
/** A human gate ALP opened that a task file edit showed cleared or removed: reopened (t-ca1f). */
|
|
54
|
+
tampered?: { at?: string | null; by?: string | null; removed?: true };
|
|
55
|
+
/** The user's latest rejection; the gate stays open. */
|
|
56
|
+
rejected?: { at: string; by: string; reason?: string; channel?: GateChannel; notified?: string };
|
|
51
57
|
};
|
|
58
|
+
export type GateChannel = 'paseo' | 'web' | 'cli';
|
|
52
59
|
|
|
53
60
|
export type TaskInput = {
|
|
54
61
|
title?: string;
|
|
@@ -93,7 +100,7 @@ export function createTask(projectRoot: string, input: TaskInput & { title: stri
|
|
|
93
100
|
export function updateTask(projectRoot: string, id: string, input: TaskInput & { note?: string }, by: string, options?: WriteOptions): Promise<Task>;
|
|
94
101
|
export function linkTask(projectRoot: string, id: string, change: { add?: TaskLinks; remove?: TaskLinks }, by: string, options?: WriteOptions): Promise<Task>;
|
|
95
102
|
export function startTask(projectRoot: string, id: string, assignee: { agent: string; session?: string; assignment?: string; pid?: number; pidStartedAt?: number; epoch?: string }, by: string, options?: WriteOptions): Promise<Task>;
|
|
96
|
-
export function closeTask(projectRoot: string, id: string, close: { reason?: CloseReason; summary?: string; unverified?: string }, by: string, options?: WriteOptions): Promise<Task>;
|
|
103
|
+
export function closeTask(projectRoot: string, id: string, close: { reason?: CloseReason; summary?: string; unverified?: string; agent?: boolean; channel?: GateChannel }, by: string, options?: WriteOptions): Promise<Task>;
|
|
97
104
|
export function verificationFailed(task: Task): boolean;
|
|
98
105
|
export function recordVerification(projectRoot: string, id: string, verification: { passed: boolean; where?: string; commands?: Array<{ step: string; command: string; exitCode: number; ms: number; output?: string; timedOut?: boolean }>; skipped?: string }, by: string): Promise<Task>;
|
|
99
106
|
export function reopenTask(projectRoot: string, id: string, reopen: { note?: string }, by: string, options?: WriteOptions): Promise<Task>;
|
|
@@ -107,8 +114,16 @@ export function startRefusal(task: Task, tasks: Task[]): string | undefined;
|
|
|
107
114
|
export function gateOpen(gate: TaskGate, now?: number): boolean;
|
|
108
115
|
export function describeGate(gate: TaskGate): string;
|
|
109
116
|
export function gatesOf(task: Task, tasks: Task[]): string[];
|
|
110
|
-
export
|
|
111
|
-
export
|
|
117
|
+
export const GATE_OPTIONS: number;
|
|
118
|
+
export const GATE_OPTION_CHARS: number;
|
|
119
|
+
export const GATE_CHANNELS: GateChannel[];
|
|
120
|
+
export const GATE_REJECT_LABELS: string[];
|
|
121
|
+
export function addGate(projectRoot: string, id: string, gate: { kind: GateKind; note?: string; until?: string; ref?: string | number; options?: string[] }, by: string): Promise<Task>;
|
|
122
|
+
export function resolveGate(projectRoot: string, id: string, gateId: string, resolve: { by: string; note?: string; remove?: boolean; ifRev?: number; choice?: string; channel?: GateChannel }): Promise<Task>;
|
|
123
|
+
export function rejectGate(projectRoot: string, id: string, gateId: string, reject: { by: string; reason?: string; ifRev?: number; channel?: GateChannel }): Promise<Task>;
|
|
124
|
+
export type GateDecision = { task: Task; gate: TaskGate; decision: 'approved' | 'rejected'; record: NonNullable<TaskGate['resolved'] | TaskGate['rejected']> };
|
|
125
|
+
export function gateDecisions(tasks: Task[]): GateDecision[];
|
|
126
|
+
export function markGateNotified(projectRoot: string, id: string, gateId: string, decision: 'approved' | 'rejected', at?: string): Promise<boolean>;
|
|
112
127
|
export function checkGates(projectRoot: string, gh: (args: string[], options: { cwd: string }) => Promise<string>): Promise<{ cleared: Array<{ task: string; gate: string; detail: string }>; pending: Array<{ task: string; gate: string; detail: string }>; errors: Array<{ task: string; gate: string; error: string }> }>;
|
|
113
128
|
export function compactTasks(projectRoot: string, options: { days?: number; dryRun?: boolean }, by: string): Promise<Array<{ id: string; before: number; after: number }>>;
|
|
114
129
|
export type TaskBatch = {
|
|
@@ -126,3 +141,7 @@ export type EpicReport = { id: string; title: string; status: TaskStatus; tasks:
|
|
|
126
141
|
export function epicReport(id: string, tasks: Task[]): EpicReport;
|
|
127
142
|
export function landedParents(tasks: Task[]): Array<{ task: Task; children: number }>;
|
|
128
143
|
export function withTaskLock<T>(projectRoot: string, work: () => Promise<T>): Promise<T>;
|
|
144
|
+
|
|
145
|
+
/** Set in every agent process ALP starts (t-ca1f). */
|
|
146
|
+
export const AGENT_MARKER: 'ALP_AGENT_SESSION';
|
|
147
|
+
export function isAgentProcess(env?: NodeJS.ProcessEnv): boolean;
|