alp-code 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +770 -0
- package/LICENSE +21 -0
- package/README.md +295 -0
- package/alp.config.yaml +5 -0
- package/dist/src/agents/agent-definition.js +28 -0
- package/dist/src/agents/capability-catalog.js +33 -0
- package/dist/src/agents/compaction.js +36 -0
- package/dist/src/agents/errors.js +12 -0
- package/dist/src/agents/librarian.js +38 -0
- package/dist/src/agents/main.js +37 -0
- package/dist/src/agents/memory-grant.js +29 -0
- package/dist/src/agents/model-context.js +70 -0
- package/dist/src/agents/modes.js +134 -0
- package/dist/src/agents/oracle.js +36 -0
- package/dist/src/agents/read-thread.js +38 -0
- package/dist/src/agents/registry.js +238 -0
- package/dist/src/agents/render-identity.js +38 -0
- package/dist/src/agents/review.js +37 -0
- package/dist/src/agents/search.js +37 -0
- package/dist/src/agents/shared/house-rules.js +33 -0
- package/dist/src/agents/shared/principal.js +18 -0
- package/dist/src/agents/shared/voice.js +29 -0
- package/dist/src/agents/titling.js +32 -0
- package/dist/src/agents/types.js +15 -0
- package/dist/src/backend/execution-backend.js +2 -0
- package/dist/src/backend/local-execution-store.js +144 -0
- package/dist/src/backend/local-process-backend.js +533 -0
- package/dist/src/backend/local-supervisor.js +104 -0
- package/dist/src/cli/alp.js +380 -0
- package/dist/src/cli/commands/context.js +203 -0
- package/dist/src/cli/commands/delegate.js +136 -0
- package/dist/src/cli/commands/identity-sync.js +31 -0
- package/dist/src/cli/commands/init.js +184 -0
- package/dist/src/cli/commands/mode.js +22 -0
- package/dist/src/cli/commands/principal.js +114 -0
- package/dist/src/cli/commands/run-main.js +90 -0
- package/dist/src/cli/commands/runtime.js +21 -0
- package/dist/src/cli/mode-preference-store.js +62 -0
- package/dist/src/cli/mode-selector.js +178 -0
- package/dist/src/cli/update-check.js +77 -0
- package/dist/src/context/checkpoint.js +134 -0
- package/dist/src/context/compact-journal.js +153 -0
- package/dist/src/context/compact-payload.js +121 -0
- package/dist/src/context/continuity.js +70 -0
- package/dist/src/context/types.js +2 -0
- package/dist/src/delegation/backend-registry.js +40 -0
- package/dist/src/delegation/delegation-service.js +300 -0
- package/dist/src/delegation/types.js +12 -0
- package/dist/src/execution/execution-policy.js +96 -0
- package/dist/src/execution/execution-service.js +115 -0
- package/dist/src/execution/execution-store.js +78 -0
- package/dist/src/execution/identity-capsule.js +65 -0
- package/dist/src/execution/types.js +12 -0
- package/dist/src/hooks/execution-bridge.js +84 -0
- package/dist/src/index.js +4 -0
- package/dist/src/memory/adapters/markdown-file-store.js +257 -0
- package/dist/src/memory/adapters/memory-api-client.js +2 -0
- package/dist/src/memory/adapters/memory-path-mapper.js +76 -0
- package/dist/src/memory/adapters/remote-api-store.js +25 -0
- package/dist/src/memory/context-ranker.js +21 -0
- package/dist/src/memory/errors.js +58 -0
- package/dist/src/memory/memory-service.js +149 -0
- package/dist/src/memory/memory-store.js +2 -0
- package/dist/src/memory/types.js +2 -0
- package/dist/src/policy/capability-policy.js +29 -0
- package/dist/src/policy/delegation-policy.js +25 -0
- package/dist/src/policy/errors.js +10 -0
- package/dist/src/policy/invariants.js +31 -0
- package/dist/src/policy/memory-policy.js +22 -0
- package/dist/src/policy/policy-engine.js +85 -0
- package/dist/src/policy/types.js +8 -0
- package/dist/src/policy/workspace-policy.js +77 -0
- package/dist/src/principal/principal-profile-store.js +89 -0
- package/dist/src/runtime/adapter-files.js +147 -0
- package/dist/src/runtime/claude-adapter.js +177 -0
- package/dist/src/runtime/codex-adapter.js +169 -0
- package/dist/src/runtime/permission-rules.js +156 -0
- package/dist/src/runtime/render-session-context.js +124 -0
- package/dist/src/runtime/render-task-input.js +33 -0
- package/dist/src/runtime/runtime-adapter.js +2 -0
- package/dist/src/runtime/runtime-preference-store.js +66 -0
- package/dist/src/runtime/runtime-selector.js +178 -0
- package/dist/src/runtime/types.js +2 -0
- package/dist/src/runtime/windows-shim.js +57 -0
- package/dist/src/state-paths.js +49 -0
- package/dist/src/workflow/output-validator.js +27 -0
- package/dist/src/workflow/repair-policy.js +8 -0
- package/dist/src/workflow/types.js +22 -0
- package/dist/src/workflow/workflow-runner.js +81 -0
- package/hooks/compact-record.cjs +109 -0
- package/hooks/session-boot.cjs +112 -0
- package/hooks/session-end.cjs +34 -0
- package/package.json +48 -0
- package/scaffold/memory/INDEX.md +27 -0
- package/scaffold/memory/README.md +76 -0
- package/scaffold/memory/projects/INDEX.md +22 -0
- package/scaffold/memory/projects/PROTOCOL.md +128 -0
- package/scaffold/memory/projects/_template/PROJECT.md +45 -0
- package/scripts/alp.cjs +126 -0
- package/scripts/alp.ps1 +4 -0
- package/scripts/alp.sh +3 -0
- package/scripts/bootstrap.cjs +144 -0
- package/scripts/checkout-release.cjs +30 -0
- package/scripts/delegate.cjs +19 -0
- package/scripts/doctor.cjs +158 -0
- package/scripts/doctor.sh +3 -0
- package/scripts/ensure-state.cjs +22 -0
- package/scripts/lib/cli-link.cjs +375 -0
- package/scripts/lib/codex-role.cjs +18 -0
- package/scripts/lib/delegation/command-runner.cjs +108 -0
- package/scripts/lib/delegation/config.cjs +81 -0
- package/scripts/lib/install-paths.cjs +154 -0
- package/scripts/lib/release-manifest.cjs +42 -0
- package/scripts/lib/semver-lite.cjs +20 -0
- package/scripts/lib/state.cjs +274 -0
- package/scripts/lib/uninstall.cjs +252 -0
- package/scripts/lib/update-check-worker.cjs +21 -0
- package/scripts/lib/update.cjs +395 -0
- package/scripts/run-role.cjs +42 -0
- package/scripts/run-role.ps1 +4 -0
- package/scripts/run-role.sh +3 -0
- package/scripts/sync-project-index.sh +167 -0
- package/skills/agent-memory/SKILL.md +109 -0
- package/skills/alp-debug/SKILL.md +90 -0
- package/skills/alp-debug/references/defense-in-depth.md +118 -0
- package/skills/alp-debug/references/investigation-methodology.md +106 -0
- package/skills/alp-debug/references/log-and-ci-analysis.md +96 -0
- package/skills/alp-debug/references/performance-diagnostics.md +112 -0
- package/skills/alp-debug/references/reporting-standards.md +120 -0
- package/skills/alp-debug/references/root-cause-tracing.md +134 -0
- package/skills/alp-debug/references/systematic-debugging.md +93 -0
- package/skills/alp-debug/references/verification.md +86 -0
- package/skills/alp-debug/scripts/find-polluter.sh +63 -0
- package/skills/alp-debug/scripts/find-polluter.test.md +102 -0
- package/skills/alp-plan/SKILL.md +128 -0
- package/skills/alp-plan/references/archive-workflow.md +77 -0
- package/skills/alp-plan/references/codebase-understanding.md +55 -0
- package/skills/alp-plan/references/output-standards.md +96 -0
- package/skills/alp-plan/references/plan-organization.md +129 -0
- package/skills/alp-plan/references/red-team-personas.md +76 -0
- package/skills/alp-plan/references/red-team-workflow.md +81 -0
- package/skills/alp-plan/references/research-phase.md +57 -0
- package/skills/alp-plan/references/scope-challenge.md +82 -0
- package/skills/alp-plan/references/solution-design.md +76 -0
- package/skills/alp-plan/references/validate-question-framework.md +89 -0
- package/skills/alp-plan/references/validate-workflow.md +83 -0
- package/skills/alp-predict/SKILL.md +98 -0
- package/skills/alp-scenario/SKILL.md +86 -0
- package/skills/code-review/SKILL.md +111 -0
- package/skills/code-review/references/code-review-reception.md +114 -0
- package/skills/code-review/references/edge-case-scouting.md +78 -0
- package/skills/code-review/references/verification-before-completion.md +117 -0
- package/skills/delegation/SKILL.md +46 -0
- package/skills/docs-seeker/.env.example +15 -0
- package/skills/docs-seeker/SKILL.md +87 -0
- package/skills/docs-seeker/package.json +25 -0
- package/skills/docs-seeker/references/advanced.md +82 -0
- package/skills/docs-seeker/references/context7-patterns.md +68 -0
- package/skills/docs-seeker/references/errors.md +72 -0
- package/skills/docs-seeker/scripts/analyze-llms-txt.js +211 -0
- package/skills/docs-seeker/scripts/detect-topic.js +172 -0
- package/skills/docs-seeker/scripts/fetch-docs.js +213 -0
- package/skills/docs-seeker/scripts/tests/run-tests.js +72 -0
- package/skills/docs-seeker/scripts/tests/test-analyze-llms.js +119 -0
- package/skills/docs-seeker/scripts/tests/test-detect-topic.js +112 -0
- package/skills/docs-seeker/scripts/tests/test-fetch-docs.js +84 -0
- package/skills/docs-seeker/scripts/utils/env-loader.js +94 -0
- package/skills/docs-seeker/workflows/library-search.md +73 -0
- package/skills/docs-seeker/workflows/repo-analysis.md +90 -0
- package/skills/docs-seeker/workflows/topic-search.md +69 -0
- package/skills/git/SKILL.md +121 -0
- package/skills/git/references/branch-management.md +90 -0
- package/skills/git/references/commit-standards.md +82 -0
- package/skills/git/references/gh-cli-guide.md +132 -0
- package/skills/git/references/safety-protocols.md +86 -0
- package/skills/git/references/workflow-commit.md +89 -0
- package/skills/git/references/workflow-merge.md +63 -0
- package/skills/git/references/workflow-pr.md +70 -0
- package/skills/git/references/workflow-push.md +62 -0
- package/skills/gkg/SKILL.md +87 -0
- package/skills/gkg/references/cli-commands.md +92 -0
- package/skills/gkg/references/http-api.md +99 -0
- package/skills/gkg/references/language-support.md +54 -0
- package/skills/problem-solving/SKILL.md +86 -0
- package/skills/problem-solving/references/attribution.md +48 -0
- package/skills/problem-solving/references/collision-zone-thinking.md +71 -0
- package/skills/problem-solving/references/inversion-exercise.md +88 -0
- package/skills/problem-solving/references/meta-pattern-recognition.md +80 -0
- package/skills/problem-solving/references/scale-game.md +82 -0
- package/skills/problem-solving/references/simplification-cascades.md +83 -0
- package/skills/problem-solving/references/when-stuck.md +76 -0
- package/skills/repomix/SKILL.md +94 -0
- package/skills/repomix/references/configuration.md +134 -0
- package/skills/repomix/references/usage-patterns.md +106 -0
- package/skills/repomix/scripts/.coverage +0 -0
- package/skills/repomix/scripts/README.md +179 -0
- package/skills/repomix/scripts/repomix_batch.py +455 -0
- package/skills/repomix/scripts/repos.example.json +15 -0
- package/skills/repomix/scripts/requirements.txt +15 -0
- package/skills/repomix/scripts/tests/test_repomix_batch.py +531 -0
- package/skills/research/SKILL.md +107 -0
- package/skills/security-scan/SKILL.md +101 -0
- package/skills/security-scan/references/secret-patterns.md +75 -0
- package/skills/security-scan/references/vulnerability-patterns.md +136 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.titlingAgent = void 0;
|
|
4
|
+
const agent_definition_1 = require("./agent-definition");
|
|
5
|
+
const voice_1 = require("./shared/voice");
|
|
6
|
+
const types_1 = require("../workflow/types");
|
|
7
|
+
exports.titlingAgent = (0, agent_definition_1.defineAgent)({
|
|
8
|
+
id: "titling",
|
|
9
|
+
displayName: "Titling 🏷️",
|
|
10
|
+
model: { claude: "claude-haiku-4-5", codex: "gpt-5.6-luna" },
|
|
11
|
+
reasoningEffort: { claude: "low", codex: "low" },
|
|
12
|
+
reportsTo: "main",
|
|
13
|
+
delegatesTo: [],
|
|
14
|
+
// Một cái tiêu đề gần như không cần gì; sàn là có chủ ý.
|
|
15
|
+
autoCompactTokens: { claude: 100_000, codex: 100_000 },
|
|
16
|
+
capabilities: {
|
|
17
|
+
tools: [],
|
|
18
|
+
skills: [],
|
|
19
|
+
subagents: [],
|
|
20
|
+
mcpServers: [],
|
|
21
|
+
memory: { read: ["private:titling"], write: ["private:titling"] },
|
|
22
|
+
workspace: { readRoots: [], writeRoots: [] },
|
|
23
|
+
},
|
|
24
|
+
instructions: () => (0, voice_1.renderInstructions)("Titling, the thread-title specialist", "Infer the primary intent and return exactly one short title in the thread's main language.",
|
|
25
|
+
// No house rules: titling holds no tools and no memory but its own, so every one of them
|
|
26
|
+
// governs something it cannot reach. Its whole contract is the one line below.
|
|
27
|
+
["No quotes, label, explanation, alternatives, trailing punctuation, task execution, or principal communication."], { audience: "machine" }),
|
|
28
|
+
workflow: (0, types_1.defineLinearWorkflow)("title-thread", [
|
|
29
|
+
{ id: "TITLE", allowedTools: [] },
|
|
30
|
+
]),
|
|
31
|
+
output: (0, voice_1.textOutput)("thread-title"),
|
|
32
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIME_IDS = exports.TOOL_CATALOG = void 0;
|
|
4
|
+
exports.TOOL_CATALOG = [
|
|
5
|
+
"Read",
|
|
6
|
+
"Write",
|
|
7
|
+
"Edit",
|
|
8
|
+
"Glob",
|
|
9
|
+
"Grep",
|
|
10
|
+
"Bash",
|
|
11
|
+
"WebSearch",
|
|
12
|
+
"WebFetch",
|
|
13
|
+
"Skill",
|
|
14
|
+
];
|
|
15
|
+
exports.RUNTIME_IDS = ["claude", "codex"];
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileLocalExecutionStore = exports.InMemoryLocalExecutionStore = void 0;
|
|
4
|
+
exports.localStateFile = localStateFile;
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
/** Default store for a backend constructed without a state directory, and for tests. */
|
|
8
|
+
class InMemoryLocalExecutionStore {
|
|
9
|
+
records = new Map();
|
|
10
|
+
get(executionId) {
|
|
11
|
+
return this.records.get(executionId) ?? null;
|
|
12
|
+
}
|
|
13
|
+
put(record) {
|
|
14
|
+
this.records.set(record.executionId, Object.freeze({ ...record }));
|
|
15
|
+
}
|
|
16
|
+
update(executionId, patch) {
|
|
17
|
+
const current = this.records.get(executionId);
|
|
18
|
+
if (!current)
|
|
19
|
+
return null;
|
|
20
|
+
const next = Object.freeze({ ...current, ...patch, updatedAt: new Date().toISOString() });
|
|
21
|
+
this.records.set(executionId, next);
|
|
22
|
+
return next;
|
|
23
|
+
}
|
|
24
|
+
remove(executionId) {
|
|
25
|
+
this.records.delete(executionId);
|
|
26
|
+
}
|
|
27
|
+
list() {
|
|
28
|
+
return Object.freeze([...this.records.values()]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.InMemoryLocalExecutionStore = InMemoryLocalExecutionStore;
|
|
32
|
+
/**
|
|
33
|
+
* Durable record of every execution this backend started, written to `<stateDir>/local.json`.
|
|
34
|
+
*
|
|
35
|
+
* Locking is not optional here, unlike in `FileDelegationExecutionStore`: `status()`
|
|
36
|
+
* reconciles a dead pid into a terminal record, so two concurrent `alp` processes polling
|
|
37
|
+
* the same execution both read-modify-write, and the loser's update would vanish. The lock
|
|
38
|
+
* is a directory because `mkdir` is atomic on every filesystem this runs on; a lock older
|
|
39
|
+
* than `STALE_LOCK_MS` is assumed to belong to a process that died holding it.
|
|
40
|
+
*/
|
|
41
|
+
class FileLocalExecutionStore {
|
|
42
|
+
static STALE_LOCK_MS = 30_000;
|
|
43
|
+
static LOCK_TIMEOUT_MS = 5_000;
|
|
44
|
+
file;
|
|
45
|
+
constructor(options) {
|
|
46
|
+
this.file = (0, node_path_1.resolve)(options.file);
|
|
47
|
+
}
|
|
48
|
+
get(executionId) {
|
|
49
|
+
return this.read().executions[executionId] ?? null;
|
|
50
|
+
}
|
|
51
|
+
put(record) {
|
|
52
|
+
this.mutate((state) => {
|
|
53
|
+
state.executions[record.executionId] = { ...record };
|
|
54
|
+
return undefined;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
update(executionId, patch) {
|
|
58
|
+
return this.mutate((state) => {
|
|
59
|
+
const current = state.executions[executionId];
|
|
60
|
+
if (!current)
|
|
61
|
+
return null;
|
|
62
|
+
const next = { ...current, ...patch, updatedAt: new Date().toISOString() };
|
|
63
|
+
state.executions[executionId] = next;
|
|
64
|
+
return next;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
remove(executionId) {
|
|
68
|
+
this.mutate((state) => {
|
|
69
|
+
delete state.executions[executionId];
|
|
70
|
+
return undefined;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
list() {
|
|
74
|
+
return Object.freeze(Object.values(this.read().executions));
|
|
75
|
+
}
|
|
76
|
+
read() {
|
|
77
|
+
try {
|
|
78
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(this.file, "utf8"));
|
|
79
|
+
return { version: 1, executions: { ...(parsed.executions ?? {}) } };
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error.code === "ENOENT")
|
|
83
|
+
return { version: 1, executions: {} };
|
|
84
|
+
throw new Error(`local delegation state is unreadable at ${this.file}: ${error.message}`, { cause: error });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
write(state) {
|
|
88
|
+
const directory = (0, node_path_1.dirname)(this.file);
|
|
89
|
+
(0, node_fs_1.mkdirSync)(directory, { recursive: true, mode: 0o700 });
|
|
90
|
+
const temporary = `${this.file}.${process.pid}.tmp`;
|
|
91
|
+
try {
|
|
92
|
+
(0, node_fs_1.writeFileSync)(temporary, `${JSON.stringify(state, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
93
|
+
(0, node_fs_1.renameSync)(temporary, this.file);
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
(0, node_fs_1.rmSync)(temporary, { force: true });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
mutate(change) {
|
|
100
|
+
const unlock = this.lock();
|
|
101
|
+
try {
|
|
102
|
+
const state = this.read();
|
|
103
|
+
const value = change(state);
|
|
104
|
+
this.write(state);
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
unlock();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
lock() {
|
|
112
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(this.file), { recursive: true, mode: 0o700 });
|
|
113
|
+
const lockDirectory = `${this.file}.lock`;
|
|
114
|
+
const deadline = Date.now() + FileLocalExecutionStore.LOCK_TIMEOUT_MS;
|
|
115
|
+
for (;;) {
|
|
116
|
+
try {
|
|
117
|
+
(0, node_fs_1.mkdirSync)(lockDirectory);
|
|
118
|
+
return () => (0, node_fs_1.rmSync)(lockDirectory, { recursive: true, force: true });
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error.code !== "EEXIST")
|
|
122
|
+
throw error;
|
|
123
|
+
try {
|
|
124
|
+
if (Date.now() - (0, node_fs_1.statSync)(lockDirectory).mtimeMs > FileLocalExecutionStore.STALE_LOCK_MS) {
|
|
125
|
+
(0, node_fs_1.rmSync)(lockDirectory, { recursive: true, force: true });
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch { /* the holder released it between our failed mkdir and this stat */ }
|
|
130
|
+
if (Date.now() >= deadline)
|
|
131
|
+
throw new Error(`timed out locking local delegation state ${this.file}`);
|
|
132
|
+
sleepSync(20);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.FileLocalExecutionStore = FileLocalExecutionStore;
|
|
138
|
+
/** Blocks the thread without a busy loop; the lock is held for microseconds at a time. */
|
|
139
|
+
function sleepSync(milliseconds) {
|
|
140
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
|
|
141
|
+
}
|
|
142
|
+
function localStateFile(stateDir) {
|
|
143
|
+
return (0, node_path_1.join)((0, node_path_1.resolve)(stateDir), "local.json");
|
|
144
|
+
}
|