diff --git a/.agent/project.md b/.agent/project.md index c6c00c2..e7fce88 100644 --- a/.agent/project.md +++ b/.agent/project.md @@ -1,32 +1,18 @@ -## KON Repository Rules +# KON Project Instruction Router -### Repository Role and Twin-Project Relationship +## Required Project References -- This is a legacy Classic ASP application maintained alongside `KON-KIWI`; the two repositories are near twins whose main differences are presentation and styling. -- Preserve current routes, includes, sessions, authentication, authorization, form fields, redirects, uploads, downloads, and MSSQL behavior while the application remains in service. -- Before changing shared-looking behavior, compare the corresponding KON-KIWI implementation and determine whether the change belongs in both repositories or only this one. -- Do not copy a change across the pair blindly. Preserve intentional branding, layout, CSS, asset, configuration, customer, and deployment differences. -- Keep maintenance and small approved feature work narrowly scoped. Do not modernize unrelated business areas or shared include trees as a side effect. +Before each related task, read the current contents of every matching reference below, even if it was read earlier in the session. -### Encoding and File Safety +| Task scope | Required reference | +|---|---| +| Any substantive analysis, planning, implementation, debugging, review, or documentation work in this repository | `.agent/references/repository-rules.md` | -- Treat Classic ASP, include, script, and configuration files as potentially CP949/EUC-KR with CRLF. Verify each touched file's encoding, BOM state, line endings, response code page, and charset behavior before and after editing. -- Never run a repository-wide UTF-8 conversion, formatter, or line-ending normalization. Inspect byte-level diffs and Korean comments, messages, labels, and data after every approved text change. -- Treat existing connection settings and operational configuration as sensitive legacy material. Do not echo their values into chat, logs, fixtures, generated documentation, or completion reports, and do not alter them without explicit task scope. +If a task spans multiple scopes, read every matching reference. Do not assume remembered content is current. -### Runtime and Repository Data +## Harness Workflow -- `Project`, `log`, `ProjectUpload`, `uploadFile`, `WebProject`, `_ServerLog`, and `Files` retain only `.gitkeep`; do not add runtime contents from these directories to Git. -- `store` is intentionally versioned. Preserve its tracked contents and do not add it to ignore rules or remove it as cleanup without explicit approval. -- Do not modify uploaded files, generated projects, logs, or runtime artifacts during analysis or validation. - -### Data and Migration Direction - -- Trace include chains and shared DB helpers before changing SQL, authentication, authorization, sessions, uploads, or file handling. -- Parameterize new or changed values while preserving ADO parameter order, types, result shapes, transactions, null behavior, and ordering. -- The long-term direction is staged migration to a Spring Boot backend and Next.js/TypeScript frontend. For now, record relevant migration observations briefly and prioritize safe legacy maintenance. - -### Harness and Verification - -- `AGENTS.md` and `CLAUDE.md` are generated. Edit `.agent/profile.yml` or `.agent/project.md`, then recompose instead of editing generated files. -- Do not start IIS, connect to a real database, send external requests, or mutate production-like data during validation without separate approval. +- `AGENTS.md` and `CLAUDE.md` are generated outputs. Never edit them directly. +- Edit `.agent/project.md` only when routing changes. Store durable project detail in `.agent/references/`. +- A reference-only content change does not require recomposition when its route is unchanged. Run harness verification to validate routing and UTF-8. +- Recompose and verify after changing `.agent/project.md`, `.agent/profile.yml`, or another composed instruction source. diff --git a/.agent/references/repository-rules.md b/.agent/references/repository-rules.md new file mode 100644 index 0000000..c6c00c2 --- /dev/null +++ b/.agent/references/repository-rules.md @@ -0,0 +1,32 @@ +## KON Repository Rules + +### Repository Role and Twin-Project Relationship + +- This is a legacy Classic ASP application maintained alongside `KON-KIWI`; the two repositories are near twins whose main differences are presentation and styling. +- Preserve current routes, includes, sessions, authentication, authorization, form fields, redirects, uploads, downloads, and MSSQL behavior while the application remains in service. +- Before changing shared-looking behavior, compare the corresponding KON-KIWI implementation and determine whether the change belongs in both repositories or only this one. +- Do not copy a change across the pair blindly. Preserve intentional branding, layout, CSS, asset, configuration, customer, and deployment differences. +- Keep maintenance and small approved feature work narrowly scoped. Do not modernize unrelated business areas or shared include trees as a side effect. + +### Encoding and File Safety + +- Treat Classic ASP, include, script, and configuration files as potentially CP949/EUC-KR with CRLF. Verify each touched file's encoding, BOM state, line endings, response code page, and charset behavior before and after editing. +- Never run a repository-wide UTF-8 conversion, formatter, or line-ending normalization. Inspect byte-level diffs and Korean comments, messages, labels, and data after every approved text change. +- Treat existing connection settings and operational configuration as sensitive legacy material. Do not echo their values into chat, logs, fixtures, generated documentation, or completion reports, and do not alter them without explicit task scope. + +### Runtime and Repository Data + +- `Project`, `log`, `ProjectUpload`, `uploadFile`, `WebProject`, `_ServerLog`, and `Files` retain only `.gitkeep`; do not add runtime contents from these directories to Git. +- `store` is intentionally versioned. Preserve its tracked contents and do not add it to ignore rules or remove it as cleanup without explicit approval. +- Do not modify uploaded files, generated projects, logs, or runtime artifacts during analysis or validation. + +### Data and Migration Direction + +- Trace include chains and shared DB helpers before changing SQL, authentication, authorization, sessions, uploads, or file handling. +- Parameterize new or changed values while preserving ADO parameter order, types, result shapes, transactions, null behavior, and ordering. +- The long-term direction is staged migration to a Spring Boot backend and Next.js/TypeScript frontend. For now, record relevant migration observations briefly and prioritize safe legacy maintenance. + +### Harness and Verification + +- `AGENTS.md` and `CLAUDE.md` are generated. Edit `.agent/profile.yml` or `.agent/project.md`, then recompose instead of editing generated files. +- Do not start IIS, connect to a real database, send external requests, or mutate production-like data during validation without separate approval. diff --git a/.agents/skills/attention-aware-communication/SKILL.md b/.agents/skills/attention-aware-communication/SKILL.md new file mode 100644 index 0000000..e27dde4 --- /dev/null +++ b/.agents/skills/attention-aware-communication/SKILL.md @@ -0,0 +1,41 @@ +--- +name: attention-aware-communication +description: Shape substantive answers, progress updates, and completion reports for fast, accurate reading without reducing the underlying work. +--- + + +# Attention-Aware Communication + +This skill changes presentation only. Investigate, implement, and verify as deeply as the task requires. + +## Default: Attention-kind + +- Put the bottom line in the first sentence and use plain Korean. +- Say the least that fully answers, then stop. Remove preambles, padding, repetition, and closing restatements. +- Never omit a number, scope condition, risk, prerequisite, uncertainty, or other fact that could cause the user to act incorrectly. +- For genuine breadth, explain the one or two most important points first, name the remaining areas, and let the user choose whether to expand them. Do not use this to defer required caveats or a complete focused answer. +- When the user asks for a detailed explanation, walkthrough, rationale, or full picture, suspend brevity and provide the necessary detail in scannable sections. +- When asked for a deliverable such as a command, message, snippet, or commit text, return the deliverable without unnecessary framing unless safety or correctness requires context. +- Ask one blocking question at a time and put it last. Keep working when a non-blocking assumption is safe. + +## Progress and Completion: Rundown + +Use Rundown formatting when a task has multiple steps or mixed states: + +- Start with a one-line outcome that includes any blocker. +- Distinguish verified completion, work in progress, work not started, and unknown state. Omit empty categories. +- Put each blocker or material risk on its own line. +- Report only observed states. Mark an unknown as unknown and state what check would resolve it. +- End with the next action or a small numbered choice only when the user must decide. + +## Explicit-Only: Spartan + +Use Spartan style only when the user explicitly asks for it: + +- Lead with the complete answer in one sentence. +- Be terse, blunt, and direct; remove warmth, hedging, transitions, narration, and summaries. +- Keep all load-bearing facts, warnings, and conditions even when they make the answer longer. +- If the user also asks for depth, provide the full detail in short, separated blocks. diff --git a/.agents/skills/karpathy-guidelines/SKILL.md b/.agents/skills/karpathy-guidelines/SKILL.md new file mode 100644 index 0000000..bbb7791 --- /dev/null +++ b/.agents/skills/karpathy-guidelines/SKILL.md @@ -0,0 +1,37 @@ +--- +name: karpathy-guidelines +description: Keep implementation, refactoring, and code review assumption-aware, simple, surgical, and tied to verifiable success criteria. +--- + + +# Karpathy Guidelines + +Use these guidelines while implementing, refactoring, or reviewing code. They refine execution quality but do not expand the approved task scope. + +## Think Before Coding + +- Inspect the relevant code and repository conventions before choosing a solution. +- Surface an assumption when different choices would materially change behavior, compatibility, data, or scope. +- Ask only when the decision cannot be discovered safely and a reasonable assumption would be risky. Otherwise proceed with the smallest reasonable assumption and report it. + +## Simplicity First + +- Implement the smallest complete solution that satisfies the observable requirement. +- Do not add speculative abstractions, extension points, configuration, fallback paths, or dependencies for hypothetical future use. +- Prefer an existing repository pattern or standard-library capability over a new local framework. + +## Surgical Changes + +- Every changed line must trace to the approved objective, required validation, or a necessary compatibility adjustment. +- Preserve existing naming, structure, public behavior, and formatting outside that boundary. +- Do not mix the task with unrelated cleanup. Remove dead code, duplication, or ceremony introduced by the current change before finishing. + +## Goal-Driven Execution + +- Translate the request into observable success criteria before implementation. +- Choose the narrowest check that can fail for the behavior being changed, then run broader repository checks when appropriate. +- Iterate only within the approved scope until the criteria pass or a concrete blocker is established. +- Before reporting completion, inspect the final diff for unnecessary code and use `verification-before-completion` for fresh evidence. diff --git a/.agents/skills/project-reference-loader/SKILL.md b/.agents/skills/project-reference-loader/SKILL.md new file mode 100644 index 0000000..febb5b7 --- /dev/null +++ b/.agents/skills/project-reference-loader/SKILL.md @@ -0,0 +1,29 @@ +--- +name: project-reference-loader +description: Load the current project-specific and shared reference documents routed by AGENTS.md before substantive repository analysis, implementation, debugging, review, or planning. +--- + + +# Project Reference Loader + +Use the repository's generated `AGENTS.md` as the routing entrypoint. + +## Workflow + +1. Find the `Required Project References` and shared-contract reference routes that match the current task. +2. Read the current contents of every matching file before relying on remembered project behavior, even when the file was read earlier in the session. +3. If the task crosses multiple scopes, read every matching reference. Do not load unrelated references merely because they exist. +4. Treat routed references as binding project instructions within their stated scope. Resolve conflicts using the precedence rules in `AGENTS.md`. +5. If a required reference is missing, unreadable, outside the repository, or internally inconsistent, stop the affected work and report the exact problem instead of guessing. + +## Change Handling + +- Edit authored project detail under `.agent/references/` when the durable rule belongs only to that repository. +- Edit the provider's `.agent/consumer-references/` when the rule is part of a shared consumer contract. +- Never edit generated `.agent-harness/references/` copies directly. +- Changing `.agent/references/` does not require recomposing `AGENTS.md` when its route is unchanged; changing routing, `project.md`, `consumer.md`, or shared reference sources does. + +Before completion, confirm that the references used still exist and that the result does not contradict them. This skill does not expand authorization to edit, commit, push, deploy, connect to external systems, or perform destructive operations. diff --git a/.agents/skills/verification-before-completion/SKILL.md b/.agents/skills/verification-before-completion/SKILL.md new file mode 100644 index 0000000..05e21ed --- /dev/null +++ b/.agents/skills/verification-before-completion/SKILL.md @@ -0,0 +1,38 @@ +--- +name: verification-before-completion +description: Require fresh, claim-specific evidence before reporting work complete, fixed, passing, ready, or safe to commit or publish. +--- + + +# Verification Before Completion + +No completion claim without fresh evidence. This workflow verifies status; it does not authorize a commit, push, deployment, database operation, or other protected action. + +## Verification Gate + +Before making a success claim: + +1. State the exact claim internally and identify which observable check can prove or disprove it. +2. Run the relevant command or inspection fresh after the final change. Use repository-defined commands; do not invent a substitute that proves a different property. +3. Read the complete result needed for the claim, including the exit code, failure count, skipped checks, and generated changes. +4. Compare the evidence with the claim and the approved acceptance criteria. +5. Report only the status supported by that evidence. + +## Evidence Rules + +- A passing lint does not prove compilation, a passing build does not prove runtime behavior, and a passing narrow test does not prove unrelated requirements. +- For a regression test, establish that it is capable of detecting the defect when practical; do not treat an always-passing test as proof. +- Recheck the worktree or final diff after generators, formatters, tests, or builds that may create or alter files. +- Separate verified results, failures, checks not run, and pre-existing failures. Never quietly merge them into a success statement. +- For delegated work, inspect the returned changes and run the relevant verification yourself before accepting the completion claim. +- For absence or universal claims such as “no occurrences” or “all projects,” use a check whose scope actually covers the claim. + +## Reporting + +- Cite the commands or inspections actually run and summarize their observed results. +- If a required check cannot run, state the actual incomplete or blocked status and the exact reason. +- Do not use “should work,” “probably passes,” “seems correct,” or similar language as a substitute for verification. +- Do not claim completion while a required check is failing or while known correctness, encoding, security, or generated-output drift remains unresolved. diff --git a/.claude/skills/attention-aware-communication/SKILL.md b/.claude/skills/attention-aware-communication/SKILL.md new file mode 100644 index 0000000..e27dde4 --- /dev/null +++ b/.claude/skills/attention-aware-communication/SKILL.md @@ -0,0 +1,41 @@ +--- +name: attention-aware-communication +description: Shape substantive answers, progress updates, and completion reports for fast, accurate reading without reducing the underlying work. +--- + + +# Attention-Aware Communication + +This skill changes presentation only. Investigate, implement, and verify as deeply as the task requires. + +## Default: Attention-kind + +- Put the bottom line in the first sentence and use plain Korean. +- Say the least that fully answers, then stop. Remove preambles, padding, repetition, and closing restatements. +- Never omit a number, scope condition, risk, prerequisite, uncertainty, or other fact that could cause the user to act incorrectly. +- For genuine breadth, explain the one or two most important points first, name the remaining areas, and let the user choose whether to expand them. Do not use this to defer required caveats or a complete focused answer. +- When the user asks for a detailed explanation, walkthrough, rationale, or full picture, suspend brevity and provide the necessary detail in scannable sections. +- When asked for a deliverable such as a command, message, snippet, or commit text, return the deliverable without unnecessary framing unless safety or correctness requires context. +- Ask one blocking question at a time and put it last. Keep working when a non-blocking assumption is safe. + +## Progress and Completion: Rundown + +Use Rundown formatting when a task has multiple steps or mixed states: + +- Start with a one-line outcome that includes any blocker. +- Distinguish verified completion, work in progress, work not started, and unknown state. Omit empty categories. +- Put each blocker or material risk on its own line. +- Report only observed states. Mark an unknown as unknown and state what check would resolve it. +- End with the next action or a small numbered choice only when the user must decide. + +## Explicit-Only: Spartan + +Use Spartan style only when the user explicitly asks for it: + +- Lead with the complete answer in one sentence. +- Be terse, blunt, and direct; remove warmth, hedging, transitions, narration, and summaries. +- Keep all load-bearing facts, warnings, and conditions even when they make the answer longer. +- If the user also asks for depth, provide the full detail in short, separated blocks. diff --git a/.claude/skills/karpathy-guidelines/SKILL.md b/.claude/skills/karpathy-guidelines/SKILL.md new file mode 100644 index 0000000..bbb7791 --- /dev/null +++ b/.claude/skills/karpathy-guidelines/SKILL.md @@ -0,0 +1,37 @@ +--- +name: karpathy-guidelines +description: Keep implementation, refactoring, and code review assumption-aware, simple, surgical, and tied to verifiable success criteria. +--- + + +# Karpathy Guidelines + +Use these guidelines while implementing, refactoring, or reviewing code. They refine execution quality but do not expand the approved task scope. + +## Think Before Coding + +- Inspect the relevant code and repository conventions before choosing a solution. +- Surface an assumption when different choices would materially change behavior, compatibility, data, or scope. +- Ask only when the decision cannot be discovered safely and a reasonable assumption would be risky. Otherwise proceed with the smallest reasonable assumption and report it. + +## Simplicity First + +- Implement the smallest complete solution that satisfies the observable requirement. +- Do not add speculative abstractions, extension points, configuration, fallback paths, or dependencies for hypothetical future use. +- Prefer an existing repository pattern or standard-library capability over a new local framework. + +## Surgical Changes + +- Every changed line must trace to the approved objective, required validation, or a necessary compatibility adjustment. +- Preserve existing naming, structure, public behavior, and formatting outside that boundary. +- Do not mix the task with unrelated cleanup. Remove dead code, duplication, or ceremony introduced by the current change before finishing. + +## Goal-Driven Execution + +- Translate the request into observable success criteria before implementation. +- Choose the narrowest check that can fail for the behavior being changed, then run broader repository checks when appropriate. +- Iterate only within the approved scope until the criteria pass or a concrete blocker is established. +- Before reporting completion, inspect the final diff for unnecessary code and use `verification-before-completion` for fresh evidence. diff --git a/.claude/skills/project-reference-loader/SKILL.md b/.claude/skills/project-reference-loader/SKILL.md new file mode 100644 index 0000000..febb5b7 --- /dev/null +++ b/.claude/skills/project-reference-loader/SKILL.md @@ -0,0 +1,29 @@ +--- +name: project-reference-loader +description: Load the current project-specific and shared reference documents routed by AGENTS.md before substantive repository analysis, implementation, debugging, review, or planning. +--- + + +# Project Reference Loader + +Use the repository's generated `AGENTS.md` as the routing entrypoint. + +## Workflow + +1. Find the `Required Project References` and shared-contract reference routes that match the current task. +2. Read the current contents of every matching file before relying on remembered project behavior, even when the file was read earlier in the session. +3. If the task crosses multiple scopes, read every matching reference. Do not load unrelated references merely because they exist. +4. Treat routed references as binding project instructions within their stated scope. Resolve conflicts using the precedence rules in `AGENTS.md`. +5. If a required reference is missing, unreadable, outside the repository, or internally inconsistent, stop the affected work and report the exact problem instead of guessing. + +## Change Handling + +- Edit authored project detail under `.agent/references/` when the durable rule belongs only to that repository. +- Edit the provider's `.agent/consumer-references/` when the rule is part of a shared consumer contract. +- Never edit generated `.agent-harness/references/` copies directly. +- Changing `.agent/references/` does not require recomposing `AGENTS.md` when its route is unchanged; changing routing, `project.md`, `consumer.md`, or shared reference sources does. + +Before completion, confirm that the references used still exist and that the result does not contradict them. This skill does not expand authorization to edit, commit, push, deploy, connect to external systems, or perform destructive operations. diff --git a/.claude/skills/verification-before-completion/SKILL.md b/.claude/skills/verification-before-completion/SKILL.md new file mode 100644 index 0000000..05e21ed --- /dev/null +++ b/.claude/skills/verification-before-completion/SKILL.md @@ -0,0 +1,38 @@ +--- +name: verification-before-completion +description: Require fresh, claim-specific evidence before reporting work complete, fixed, passing, ready, or safe to commit or publish. +--- + + +# Verification Before Completion + +No completion claim without fresh evidence. This workflow verifies status; it does not authorize a commit, push, deployment, database operation, or other protected action. + +## Verification Gate + +Before making a success claim: + +1. State the exact claim internally and identify which observable check can prove or disprove it. +2. Run the relevant command or inspection fresh after the final change. Use repository-defined commands; do not invent a substitute that proves a different property. +3. Read the complete result needed for the claim, including the exit code, failure count, skipped checks, and generated changes. +4. Compare the evidence with the claim and the approved acceptance criteria. +5. Report only the status supported by that evidence. + +## Evidence Rules + +- A passing lint does not prove compilation, a passing build does not prove runtime behavior, and a passing narrow test does not prove unrelated requirements. +- For a regression test, establish that it is capable of detecting the defect when practical; do not treat an always-passing test as proof. +- Recheck the worktree or final diff after generators, formatters, tests, or builds that may create or alter files. +- Separate verified results, failures, checks not run, and pre-existing failures. Never quietly merge them into a success statement. +- For delegated work, inspect the returned changes and run the relevant verification yourself before accepting the completion claim. +- For absence or universal claims such as “no occurrences” or “all projects,” use a check whose scope actually covers the claim. + +## Reporting + +- Cite the commands or inspections actually run and summarize their observed results. +- If a required check cannot run, state the actual incomplete or blocked status and the exact reason. +- Do not use “should work,” “probably passes,” “seems correct,” or similar language as a substitute for verification. +- Do not claim completion while a required check is failing or while known correctness, encoding, security, or generated-output drift remains unresolved. diff --git a/AGENTS.md b/AGENTS.md index 58830c4..97da875 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,6 +35,13 @@ Later and more specific instructions may override earlier general instructions o - Lead with the result or decision, then provide only the detail needed to verify it. - Do not create or retain a full session transcript. +### Attention-Aware Response Style + +- Use `attention-aware-communication` for substantive answers, progress updates, and completion reports. +- Default to concise, bottom-line-first Korean without omitting a condition, risk, number, or uncertainty needed for a correct decision. +- Give full detail when the user requests depth. Use Spartan style only when explicitly requested. +- Presentation rules never reduce investigation, implementation, validation, or reporting obligations. + ## Work Authorization - The default workflow is discussion first and explicit execution approval second. @@ -152,6 +159,13 @@ Preferred human-facing tools: - If a possible secret is discovered, do not repeat it. Report only its location, type, and recommended containment action. - Do not rotate, revoke, copy, or otherwise modify credentials unless that exact action is explicitly authorized. +## Workflow Skills + +- Use `project-reference-loader` before substantive repository analysis, planning, implementation, debugging, or review. Read only the current project and shared references routed for that task, and reread them for each related task even if they were loaded earlier in the session. +- Use `karpathy-guidelines` when implementing, refactoring, or reviewing code. It keeps assumptions visible, changes surgical, and success criteria verifiable. +- Use `verification-before-completion` before claiming that work is complete, fixed, passing, ready, or safe to commit or publish. +- A skill does not expand task scope or authorize Git publication, database execution, deployment, destructive actions, or external communication. + ## Validation - Discover supported build, test, lint, type-check, and formatting commands from repository files and project instructions. Do not invent commands. @@ -241,35 +255,21 @@ When implementation is complete, report in Korean: - Separate intentional product or behavior changes from framework-only migration changes so each can be reviewed independently. - For standalone React applications, the default planned target is Next.js with TypeScript unless the project profile explicitly declares another approved target. -## KON Repository Rules +# KON Project Instruction Router -### Repository Role and Twin-Project Relationship +## Required Project References -- This is a legacy Classic ASP application maintained alongside `KON-KIWI`; the two repositories are near twins whose main differences are presentation and styling. -- Preserve current routes, includes, sessions, authentication, authorization, form fields, redirects, uploads, downloads, and MSSQL behavior while the application remains in service. -- Before changing shared-looking behavior, compare the corresponding KON-KIWI implementation and determine whether the change belongs in both repositories or only this one. -- Do not copy a change across the pair blindly. Preserve intentional branding, layout, CSS, asset, configuration, customer, and deployment differences. -- Keep maintenance and small approved feature work narrowly scoped. Do not modernize unrelated business areas or shared include trees as a side effect. +Before each related task, read the current contents of every matching reference below, even if it was read earlier in the session. -### Encoding and File Safety +| Task scope | Required reference | +|---|---| +| Any substantive analysis, planning, implementation, debugging, review, or documentation work in this repository | `.agent/references/repository-rules.md` | -- Treat Classic ASP, include, script, and configuration files as potentially CP949/EUC-KR with CRLF. Verify each touched file's encoding, BOM state, line endings, response code page, and charset behavior before and after editing. -- Never run a repository-wide UTF-8 conversion, formatter, or line-ending normalization. Inspect byte-level diffs and Korean comments, messages, labels, and data after every approved text change. -- Treat existing connection settings and operational configuration as sensitive legacy material. Do not echo their values into chat, logs, fixtures, generated documentation, or completion reports, and do not alter them without explicit task scope. +If a task spans multiple scopes, read every matching reference. Do not assume remembered content is current. -### Runtime and Repository Data +## Harness Workflow -- `Project`, `log`, `ProjectUpload`, `uploadFile`, `WebProject`, `_ServerLog`, and `Files` retain only `.gitkeep`; do not add runtime contents from these directories to Git. -- `store` is intentionally versioned. Preserve its tracked contents and do not add it to ignore rules or remove it as cleanup without explicit approval. -- Do not modify uploaded files, generated projects, logs, or runtime artifacts during analysis or validation. - -### Data and Migration Direction - -- Trace include chains and shared DB helpers before changing SQL, authentication, authorization, sessions, uploads, or file handling. -- Parameterize new or changed values while preserving ADO parameter order, types, result shapes, transactions, null behavior, and ordering. -- The long-term direction is staged migration to a Spring Boot backend and Next.js/TypeScript frontend. For now, record relevant migration observations briefly and prioritize safe legacy maintenance. - -### Harness and Verification - -- `AGENTS.md` and `CLAUDE.md` are generated. Edit `.agent/profile.yml` or `.agent/project.md`, then recompose instead of editing generated files. -- Do not start IIS, connect to a real database, send external requests, or mutate production-like data during validation without separate approval. +- `AGENTS.md` and `CLAUDE.md` are generated outputs. Never edit them directly. +- Edit `.agent/project.md` only when routing changes. Store durable project detail in `.agent/references/`. +- A reference-only content change does not require recomposition when its route is unchanged. Run harness verification to validate routing and UTF-8. +- Recompose and verify after changing `.agent/project.md`, `.agent/profile.yml`, or another composed instruction source. diff --git a/include/ajax_contact.asp b/include/ajax_contact.asp index 08c7c2d..b4a8d88 100644 --- a/include/ajax_contact.asp +++ b/include/ajax_contact.asp @@ -105,6 +105,63 @@ .Parameters("@TARGET") = TARGET .Execute , , adExecuteNoRecords End With + CASE "EXTERNAL_API_LOG" + Dim LOG_API_NAME, LOG_IDKEY, LOG_RESULT, LOG_HTTP_MESSAGE, LOG_MESSAGE_SIZE + LOG_API_NAME = Trim(Request("API_NAME")) + LOG_IDKEY = Trim(Request("IDKEY")) + LOG_RESULT = Trim(Request("RESULT")) + LOG_HTTP_MESSAGE = Request("HTTP_MESSAGE") + + IF Len(LOG_API_NAME) = 0 OR Len(LOG_API_NAME) > 30 OR Len(PKEY) > 20 OR Len(LOG_IDKEY) > 100 OR Len(LOG_RESULT) = 0 OR Len(LOG_RESULT) > 10 THEN + Response.Status = "400 Bad Request" + Response.Write "Invalid log parameters" + Response.End + END IF + + IF Len(PSIDX) > 0 THEN + Set PSIDX_CHECK = Server.CreateObject("VBScript.RegExp") + PSIDX_CHECK.Pattern = "^-?[0-9]{1,19}$" + IF NOT PSIDX_CHECK.Test(PSIDX) THEN + Response.Status = "400 Bad Request" + Response.Write "Invalid PSIDX" + Response.End + END IF + END IF + + LOG_MESSAGE_SIZE = Len(LOG_HTTP_MESSAGE) + IF LOG_MESSAGE_SIZE = 0 THEN LOG_MESSAGE_SIZE = 1 + + SQL = " INSERT INTO KON_EXTERNAL_API_LOG (API_NAME, PKEY, IDKEY, PSIDX, RESULT, HTTP_MESSAGE) VALUES (?, ?, ?, CAST(NULLIF(?, '') AS BIGINT), ?, ?) " + With ObjCmd + .ActiveConnection = DBConn + .CommandText = SQL + .CommandType = adCmdText + .Parameters.Append .CreateParameter("@API_NAME", adVarChar, adParamInput, 30) + .Parameters.Append .CreateParameter("@PKEY", adVarChar, adParamInput, 20) + .Parameters.Append .CreateParameter("@IDKEY", adVarChar, adParamInput, 100) + .Parameters.Append .CreateParameter("@PSIDX", adVarChar, adParamInput, 20) + .Parameters.Append .CreateParameter("@RESULT", adVarChar, adParamInput, 10) + .Parameters.Append .CreateParameter("@HTTP_MESSAGE", adLongVarWChar, adParamInput, LOG_MESSAGE_SIZE) + .Parameters("@API_NAME") = LOG_API_NAME + IF Len(PKEY) = 0 THEN + .Parameters("@PKEY") = Null + ELSE + .Parameters("@PKEY") = PKEY + END IF + IF Len(LOG_IDKEY) = 0 THEN + .Parameters("@IDKEY") = Null + ELSE + .Parameters("@IDKEY") = LOG_IDKEY + END IF + .Parameters("@PSIDX") = PSIDX + .Parameters("@RESULT") = LOG_RESULT + IF Len(LOG_HTTP_MESSAGE) = 0 THEN + .Parameters("@HTTP_MESSAGE") = Null + ELSE + .Parameters("@HTTP_MESSAGE") = LOG_HTTP_MESSAGE + END IF + .Execute , , adExecuteNoRecords + End With END SELECT '-- DELETE ' CASE "DELETE" diff --git a/module/survey.js b/module/survey.js index 80356af..70a512f 100644 --- a/module/survey.js +++ b/module/survey.js @@ -100,53 +100,34 @@ kon.survey = (function () { } sessionStorage.setItem("N_PAGE_"+kon.survey.IDKEY, nextinput.val()); - if(nextinput.val() == "END"){ - /////박준성 여기서 KART를 호출해서 파생변수 반들기 + var apiWaits = []; + if (nextinput.val() === "END") { var isKiwi = 0; - $.ajax({ - url: "https://rapi.kric.com/api/v1/project/derived/"+isKiwi+"/"+kon.survey.PKEY+"/"+kon.survey.IDKEY, - type: "POST", - contentType: "application/json; charset=utf-8", - cache: false, - async: true, - //success: function (data) {}, - error: function (x, h, r) { - console.log(x); - console.log(h); - console.log(r); - } - }); + var kartRequestUrl = "https://rapi.kric.com/api/v1/project/derived/"+isKiwi+"/"+kon.survey.PKEY+"/"+kon.survey.IDKEY; + apiWaits.push(callLoggedApi(kartRequestUrl, "DERIVED", kon.survey.IDKEY, "", "")); } - if(surveyType == "LIST"){ + if (surveyType === "LIST") { var contactMappingList = ajax_returnData("/include/ajax_contact.asp", { "CRUD": "SELECT", "COMMAND": "CONTACT_SURVEY", "PKEY": kon.survey.PKEY }); - if(contactMappingList.length > 0){ - if(pagename == "INDEX"){ - callContactStatusApi(contactMappingList, kon.survey.IDKEY, "start") - } + if (Array.isArray(contactMappingList) && contactMappingList.length > 0) { + var statuses = []; + if (pagename === "INDEX") statuses.push("start"); + if (["PREV", "END"].includes(nextinput.val())) statuses.push("complete"); + else if (nextinput.val() === "SCREEN") statuses.push("screen"); + else if (nextinput.val() === "QUOTA") statuses.push("quota"); - if(["PREV","END", "SCREEN", "QUOTA"].includes(nextinput.val())){ - var status = "complete" - - if(nextinput.val() == "SCREEN"){ - status = "screen" - } - else if(nextinput.val() == "QUOTA"){ - status = "quota" - } - - callContactStatusApi(contactMappingList, kon.survey.IDKEY, status) + if (statuses.length > 0) { + apiWaits.push(callContactStatusApi(contactMappingList, kon.survey.IDKEY, statuses)); } } } - form.attr("onsubmit", ""); - form.submit(); + submitNextPage(form, apiWaits); }, error: function (x, h, r) { console.log(x); console.log(h); @@ -156,8 +137,71 @@ kon.survey = (function () { }) } - function callContactStatusApi(contactMappingList, idkey, status) { - var contactRouteUrl = "/api/external/"; + function submitNextPage(form, waits) { + var remaining = waits.length; + if (remaining === 0) { + form.attr("onsubmit", ""); + form.submit(); + return; + } + waits.forEach(function (wait) { + wait.always(function () { + remaining--; + if (remaining === 0) { + form.attr("onsubmit", ""); + form.submit(); + } + }); + }); + } + + function logExternalApi(apiName, idkey, psidx, result, message) { + ajax_call("/include/ajax_contact.asp", { + "CRUD": "INSERT", + "COMMAND": "EXTERNAL_API_LOG", + "API_NAME": apiName, + "PKEY": kon.survey.PKEY, + "IDKEY": idkey, + "PSIDX": psidx == null ? "" : psidx, + "RESULT": result, + "HTTP_MESSAGE": message || "" + }); + } + + function apiErrorMessage(x, h, r) { + return "HTTP " + x.status + " | " + (r || h) + " | " + (x.responseText || ""); + } + + function callLoggedApi(url, apiName, idkey, psidx, message) { + var prefix = message ? message + " | " : ""; + logExternalApi(apiName, idkey, psidx, "REQUEST", message); + return $.ajax({ + url: url, + type: "POST", + contentType: "application/json; charset=utf-8", + cache: false, + async: true, + timeout: 30000, + success: function (data, h, x) { + logExternalApi(apiName, idkey, psidx, "SUCCESS", prefix + "HTTP " + x.status); + }, + error: function (x, h, r) { + logExternalApi(apiName, idkey, psidx, "FAIL", prefix + apiErrorMessage(x, h, r)); + console.log(x); + console.log(h); + console.log(r); + } + }); + } + + function callContactStatusApi(contactMappingList, idkey, statuses) { + var allRequestsDone = $.Deferred(); + var mappingsLeft = contactMappingList.length; + + function finishMapping() { + mappingsLeft--; + if (mappingsLeft === 0) allRequestsDone.resolve(); + } contactMappingList.forEach(function (mapping) { var targetSystem = String(mapping.TARGET_SYSTEM || "").toUpperCase(); @@ -167,42 +211,54 @@ kon.survey = (function () { case "PROD": contactBaseUrl = "https://contact.kric.com"; break; - case "DEV": contactBaseUrl = "https://test-contact.kric.com"; break; - case "LOCAL": contactBaseUrl = "http://localhost:4000"; break; - default: console.error("지원하지 않는 TARGET_SYSTEM:", mapping.TARGET_SYSTEM); + finishMapping(); return; } -console.log(contactBaseUrl, mapping) - $.ajax({ - url: contactBaseUrl + contactRouteUrl + status - + "?psidx=" + encodeURIComponent(mapping.PSIDX) - + "&sid=" + encodeURIComponent(idkey), - type: "POST", - contentType: "application/json; charset=utf-8", - cache: false, - async: true, - error: function (x, h, r) { - console.log(x); - console.log(h); - console.log(r); + + var nextStatusIndex = 0; + + // 같은 매핑의 상태는 start 다음 complete 순서로 호출한다. + function sendNextStatus() { + if (nextStatusIndex >= statuses.length) { + finishMapping(); + return; } - }); + + var status = statuses[nextStatusIndex]; + nextStatusIndex++; + + var contactApiUrl = contactBaseUrl + "/api/external/" + status + + "?psidx=" + encodeURIComponent(mapping.PSIDX) + + "&sid=" + encodeURIComponent(idkey); + + callLoggedApi( + contactApiUrl, + "CONTACT_" + status.toUpperCase(), + idkey, + mapping.PSIDX, + "TARGET_SYSTEM=" + targetSystem + ).always(sendNextStatus); + } + + sendNextStatus(); }); + + return allRequestsDone.promise(); } function serializeform(form,arr) { /* 폼 데이터 정렬 */ var data = {} var inputdata = {} /* 기본 인풋 제외 */ - var basis_info = ["USEPREV", "PAGENAME", "NEXTPAGE", "PCODE", "IDKEY", "SURVEYTYPE", "QNUMBER", "PCOLOR", "ROTATION","GLOBALVARIABLE","GLOBALSURVEY","CAMPAIGNID","TK","SPRINGID","KABANGID"]; + var basis_info = ["USEPREV", "PAGENAME", "NEXTPAGE", "PCODE", "IDKEY", "SURVEYTYPE", "QNUMBER", "PCOLOR", "ROTATION","GLOBALVARIABLE","GLOBALSURVEY","CAMPAIGNID","TK","SPRINGID","KABANGID", "CONTACTPID"]; if(arr) { if(typeof(arr) === "string") arr = [arr];