@agentprojectcontext/apx 1.10.2 → 1.10.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentprojectcontext/apx",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "APX — unified CLI + daemon for the Agent Project Context (APC) standard.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { findApfRoot, readAgents } from "../../core/parser.js";
4
4
  import { getOrCreateApxId } from "../../core/scaffold.js";
5
5
  import { generateSessionId } from "../../core/session-store.js";
6
- import { ensureProjectStorage } from "../../core/config.js";
6
+ import { projectStorageRoot, ensureProjectStorage } from "../../core/config.js";
7
7
  import { http } from "../http.js";
8
8
  import { resolveProjectId } from "./project.js";
9
9
 
@@ -18,7 +18,7 @@ function requireRoot() {
18
18
  function requireStorageRoot(root) {
19
19
  const apxId = getOrCreateApxId(root);
20
20
  if (!apxId) throw new Error("could not resolve APX project storage id");
21
- return ensureProjectStorage(apxId);
21
+ return projectStorageRoot(apxId);
22
22
  }
23
23
 
24
24
  const nowIso = () => new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
@@ -256,6 +256,7 @@ export function getOrCreateApxId(root) {
256
256
  try { cfg = JSON.parse(fs.readFileSync(p, "utf8")); } catch { return null; }
257
257
  if (cfg.apx_id) return cfg.apx_id;
258
258
  const apxId = crypto.randomUUID().replace(/-/g, "").slice(0, 12);
259
+ console.log(`[apx] Generating new stable ID ${apxId} for project at ${root}`);
259
260
  cfg.apx_id = apxId;
260
261
  fs.writeFileSync(p, JSON.stringify(cfg, null, 2) + "\n");
261
262
  return apxId;
package/src/daemon/db.js CHANGED
@@ -37,9 +37,11 @@ export class ProjectManager {
37
37
  // Ensure directories exist for projects initialized before they were added.
38
38
  fs.mkdirSync(path.join(abs, ".apc", "commands"), { recursive: true });
39
39
 
40
- // Ensure stable APX storage root exists (~/.apx/projects/<apx_id>/).
40
+ // Resolve stable APX storage ID (read from .apc/project.json).
41
41
  const apxId = getOrCreateApxId(abs);
42
- const storagePath = ensureProjectStorage(apxId);
42
+ // Don't create the physical storage folder yet.
43
+ // Just resolve where it SHOULD be.
44
+ const storagePath = path.join(path.dirname(DEFAULT_PROJECT_STORE), apxId || "null");
43
45
 
44
46
  const entry = {
45
47
  id: this._nextId++,
@@ -48,8 +50,15 @@ export class ProjectManager {
48
50
  apxId,
49
51
  config: effectiveConfig(this.globalConfig, abs),
50
52
  };
51
- // Project runtime messages stay in APX local storage.
52
- entry.logMessage = (payload) => appendMessageToFs({ projectRoot: storagePath, ...payload });
53
+
54
+ // Lazy message logger: ensure directory exists ONLY when writing.
55
+ entry.logMessage = (payload) => {
56
+ if (entry.apxId) {
57
+ ensureProjectStorage(entry.apxId);
58
+ }
59
+ return appendMessageToFs({ projectRoot: entry.storagePath, ...payload });
60
+ };
61
+
53
62
  this.byId.set(entry.id, entry);
54
63
  this.byPath.set(abs, entry);
55
64
  return entry;
@@ -99,7 +99,7 @@ export default {
99
99
  type: "object",
100
100
  properties: {
101
101
  project: { type: "string" },
102
- agent: { type: "string", description: "Optional APC agent slug from AGENTS.md, not runtime name. Use only when the user explicitly named that agent. Omit for 'vos mismo', 'default', 'base', or no agent." },
102
+ agent: { type: "string", description: "APC agent slug. MANDATORY OMIT if you are acting as yourself (APX/vos mismo/default). Use ONLY if the user named a specific agent from AGENTS.md." },
103
103
  runtime: {
104
104
  type: "string",
105
105
  enum: RUNTIME_IDS,
@@ -53,11 +53,11 @@ HARD RULES (do not deviate):
53
53
  7. Stay brief: under 6 sentences unless asked for detail.
54
54
  8. You DO see recent prior turns of this chat as previous messages when applicable. **Use them ONLY to disambiguate references** (e.g. "el primero" → first project mentioned earlier). For ANY factual data — agent details, MCP details, file contents, memory — RE-CALL the tool. Past turns are context, not a cache. Models change, agents change, files change.
55
55
  9. /reset or /new from the user means "forget previous turns and answer this one fresh" — if you see those prefixes the operator already cleared the context for you.
56
- 10. SELF-RUN RULE: if the user says "vos mismo", "tu mismo", "same", "base", "default", "sin agente", or does not explicitly name an agent slug, act as APX itself. Do NOT call list_agents to choose a candidate. Do NOT pass agent to call_runtime/call_agent.
57
- 11. DELEGATION RULE: when the user asks a named APC agent to do a task, use call_agent (unless they specify opening it in a runtime, then see rule 12).
58
- 12. DISPATCH RULE: when the user asks to work inside Claude, Codex, OpenCode, Aider, Cursor, Gemini CLI, or Qwen Code, use call_runtime({runtime: 'claude-code'|'codex'|'opencode'|'aider'|'cursor-agent'|'gemini-cli'|'qwen-code', prompt: <user's request>}). First prefer runtimes the tool reports as installed/runnable; if a runtime is missing or fails, report that fact and its stderr/error instead of pretending success. If the user explicitly named an agent slug, pass agent: <slug>. If they didn't, DO NOT pass agent. When an agent is passed, its memory + skills become the system prompt of the runtime.
59
- 13. PROJECT RULE: when the user gives no project, use project "default". Do not infer a non-default project from old chat history unless the user references it. If they mention a path or project name, look it up or add it with add_project.
60
- 14. VAULT RULE: when the user wants a new existing agent/template, call list_vault_agents first. If a suitable vault agent exists, import_agent into the chosen project. If none fits, say briefly what is missing.
56
+ 10. **SELF-RUN RULE**: If the user says "vos mismo", "tu mismo", "same", "base", "default", "sin agente", or does not explicitly name an agent slug, act as APX. **DO NOT** call list_agents. **DO NOT** pass an 'agent' argument to tools.
57
+ 11. DELEGATION RULE: When the user asks a named APC agent to do a task, use call_agent (unless they specify opening it in a runtime, then see rule 12).
58
+ 12. **DISPATCH RULE**: Use call_runtime for external runtimes. If the user named an agent, pass it. If they didn't, **DO NOT PASS ANY AGENT**. Running with an empty agent field is how you run as yourself.
59
+ 13. PROJECT RULE: When the user gives no project, use project "default". Do not infer a non-default project from old chat history unless the user references it. If they mention a path or project name, look it up or add it with add_project.
60
+ 14. VAULT RULE: When the user wants a new existing agent/template, call list_vault_agents first. If a suitable vault agent exists, import_agent into the chosen project. If none fits, say briefly what is missing.
61
61
  15. NO-PENDING RULE: never say "give me a second", "I will do it", or "I will try later" as a final answer. Either call the tool in this same turn or say what blocks you.
62
62
  16. IDENTITY RULE: when the user asks you to change your name, call yourself something, or update your personality/language, call set_identity and persist the change. Then confirm with your new name.
63
63
  17. ROUTINES RULE: NEVER create a routine in the default project (id=0). Routines MUST be tied to a specific registered project. Before adding a routine, call list_projects to find the correct project id or name. Then pass --project <id|name> to apx routine add. If no project fits, ask the user which project to use. Creating routines in project 0/default mixes unrelated projects' schedules and corrupts state.`;